Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once 'D:\USR\apache\htdocs\s2.localhost\Phoenix_demo\classes\Model.php';
- class View
- {
- /**
- * Path to document root (absolute)
- */
- private $DOC_ROOT;
- /**
- * @var class Model
- */
- private $model;
- /**
- *Path to templates' dir (absolute)
- *
- * @var string
- */
- private $templateDir = '';
- /**
- *
- * @param class_Model $model
- * @param string $doc_root Path to document root (absolute) of web server
- * @param string $templateDir Path to templates' dir (absolute)
- */
- public function __construct(Model $model, $doc_root, $templateDir)
- {
- $this->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;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment