DOC_ROOT = $doc_root; $this->model = $model; $this->templateDir = $templateDir; } /** * Возвращает текст нужной страницы. * @param string $page * @return string Текст страницы */ public function output($page) { ob_start(); switch ($page) { case 'main': //объявляем и заполняем переменные, которые затем нужны будут в шаблоне $header = $this->DOC_ROOT . '/Phoenix_demo/Private/tpl_header.php'; $color_on = $this->model->getColor(); $changes = $this->model->getChanges(); $tpl_changes = $this->templateDir . '/tpl_changes.php'; $citations = $this->model->getQuotes(); $count = $this->model->getNumOfQuotes(); $tpl_citations = $this->templateDir . '/tpl_citations.php'; //вызывает общий шаблон страницы, который использует $tpl include $this->templateDir . 'tpl_main.php'; break; default: break; } return ob_get_clean(); } /** * Отсылает указанную страницу пользователю. * @param string $page */ public function render($page) { $contents = $this->output($page); echo $contents; } }