Пример #1
0
 static function make_view($template, $layout = false)
 {
     # get the template type
     $template = PROJECT_VIEWS . '/' . $template;
     $type = ViewFactory::get_template_type($template);
     if ($type === false) {
         throw new MissingTemplate("No recognizable template was found at {$template}.");
     }
     # return the right view depending on the extension of the template
     switch ($type) {
         case 'phtml':
             $the_view = new PHTMLView("{$template}.{$type}");
             break;
         case 'pxml':
             $the_view = new PXMLView("{$template}.{$type}");
             break;
         case 'pjs':
             $the_view = new PJSView("{$template}.{$type}");
             break;
         case 'xsl':
             $the_view = new XSLTView("{$template}.{$type}");
             break;
         default:
             throw new UnknownViewType("ViewFactory doesn't know how to use a {$type} file.");
     }
     return $the_view;
 }
Пример #2
0
 function parse($layout_template = false)
 {
     parent::parse($layout_template);
     # unpack the props
     #extract($this->props);
     # trap the buffer
     ob_start();
     # include the template
     include $this->template;
     # get the buffer contents
     $parsed = ob_get_contents();
     # clean the buffer
     ob_clean();
     # if there is a layout
     if ($this->layout) {
         # find the type
         $type = ViewFactory::get_template_type($layout_template);
         if ($type) {
             # push the content into the layout
             $content_for_layout = $parsed;
             # include the template
             include $this->layout . ".{$type}";
             # get the buffer contents
             $parsed = ob_get_contents();
         }
     }
     # close the output buffer
     ob_end_clean();
     # save the result
     $this->parsed = $parsed;
     return $parsed;
 }