public static function View($controllerOutput) { if (method_exists($controllerOutput, 'TemplateName')) { $view = new ViewTemplate($controllerOutput->TemplateName(), $controllerOutput->model); echo $view->GetResponse()->saveHTML(); } else { echo json_encode($controllerOutput->model); } }
public function __construct($template, $model) { echo $template . '<br>'; // [A][a] Pattern and Final docs $this->doc = new DOMDocument(); $this->response = new DOMDocument(); // [A][b.1] Root Result Element(s) $inspector = $this->response->createElement('html'); $this->response->appendChild($inspector); $head = $inspector->appendChild($this->response->createElement('head')); $style = $head->appendChild($this->response->createElement('style')); $title = $head->appendChild($this->response->createElement('title')); $inspector = $inspector->appendChild($this->response->createElement('body')); $this->parentReponse = NULL; // [A][b.2] Root Document Template $this->doc->load(getcwd() . "/{$template}") or die("Template failed (" . getcwd() . "/{$template})."); $view = $this->doc->documentElement; $title->nodeValue = $view->getAttribute('title'); // Copy the title from the root view note attr' if ($view->getAttribute('template') != '') { $parent = new ViewTemplate($view->getAttribute('template'), $model); $place = $parent->GetResponse()->getElementsByTagName('mvc:child'); //echo var_dump($place->item(0)); $this->response = $parent->GetResponse(); //echo var_dump($this->response); $inspector = $place->item(0); //$this->response->createElement('div'); //$this->response->replaceChild($inspector, $place->item(0)); $head = $this->response->getElementsByTagName('head')->item(0); $style = $this->response->getElementsByTagName('style')->item(0); $title = $this->response->getElementsByTagName('title')->item(0); } $this->compile($this->doc, $view, $this->response, $inspector, $head, $title, $style, $model); }