fork download
  1. <?php
  2.  
  3. class Template{
  4.  
  5. private $arr = array();
  6. private $nameTPL;
  7. private $header;
  8. private $footer;
  9.  
  10. /* заполнение аргументов */
  11. function set($name, $value){ $this->arr[$name] = $value; }
  12. function get($name){ return $this->arr[$name]; }
  13.  
  14. /* настройка шаблонизации */
  15. function getTemplate($nameTPL, $ctrlName, $header = true, $footer = true){
  16. $this->nameTPL = APP.$ctrlName.'/view/'.$nameTPL.'.tpl';
  17. $this->header = $header;
  18. $this->footer = $footer;
  19. }
  20.  
  21. /* запуск и вывод шаблонов */
  22. function runTemplate(){
  23.  
  24. # подгружаем header.tpl
  25. if($this->header == true){
  26. $file = ENGINE.'/template/header.tpl';
  27. if(file_exists($file)) require_once $file;
  28. else echo 'Error::Шаблон header.tpl отсутствует!';
  29. }
  30.  
  31. # подгружаем основной шаблон
  32. if(file_exists($this->nameTPL)) require_once $this->nameTPL;
  33. else echo 'Error::Шаблон отсутствует!';
  34.  
  35. # подгружаем footer.tpl
  36. if($this->footer == true){
  37. $file = ENGINE.'/template/footer.tpl';
  38. if(file_exists($file)) require_once $file;
  39. else echo 'Error::Шаблон footer.tpl отсутствует!';
  40. }
  41. }
  42. }
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Standard output is empty