Просмотр файла system/classes/template.php

Размер файла: 1.28Kb
  1. <?php
  2. /**********************************
  3. * @package: PerfCMS *
  4. * @year: 2012 *
  5. * @author: Artas *
  6. * @link: http://perfcms.pp.ua *
  7. **********************************/
  8. class Template {
  9. public $type;
  10. public $format = '.html';
  11. public $tpln = 'default';
  12. public $html;
  13. public $values = array();
  14.  
  15. public function __construct() {
  16. // $this->type = browser_type();
  17. $this->type = 'wap';
  18. }
  19.  
  20. public function parse($tpl_name)
  21. {
  22. global $stylen;
  23. if(empty($tpl_name) || !file_exists(TPL.'/themes/'.$this->type.'/'. $stylen .'/'.$tpl_name . $this->format))
  24. {
  25. return false;
  26. }
  27. else
  28. {
  29. $this->html = file_get_contents(TPL.'/themes/'.$this->type.'/'. $stylen .'/'.$tpl_name . $this->format);
  30. }
  31. }
  32.  
  33. public function set_value($key, $var)
  34. {
  35. $key = '{'.$key.'}';
  36. $this->values[$key] = $var;
  37. }
  38.  
  39.  
  40. public function view()
  41. {
  42. foreach($this->values as $find => $replace)
  43. {
  44. $this->html = str_replace($find, $replace, $this->html);
  45. }
  46. echo $this->html;
  47. }
  48. public function div($div, $content)
  49. {
  50. echo "<div class=\"{$div}\">{$content}</div>\n";
  51. }
  52. }