protected function loadTemplate()
 {
     $builder = new HTML_Custom_Builder($this->_sub_view_manager);
     $this->resolveTemplateSource();
     if ($this->template === null) {
         throw new Data_Insufficient_Exception('template');
     }
     $this->_root = Template_Loader::load($this->template, $builder);
     $this->_index = new HTML_Indexer($this->_root, 'eid', false);
 }
Ejemplo n.º 2
0
 protected function _initialize()
 {
     if ($this->template === null) {
         throw new Data_Insufficient_Exception('template');
     }
     $this->_sub_view_manager = new View_Manager();
     if ($this->_view_manager->head !== null) {
         $this->_sub_view_manager->assignHead($this->_view_manager->head);
     }
     if ($this->_view_manager->body !== null) {
         $this->_sub_view_manager->assignBody($this->_view_manager->body);
     }
     $builder = new HTML_Custom_Builder($this->_sub_view_manager);
     $this->_root = Template_Loader::load($this->template, $builder);
     $this->_sub_view_manager->initialize();
 }
 public static function render($template, $vm_or_builder = null, $renderer = null)
 {
     if ($vm_or_builder === null) {
         if (self::$vm === null) {
             self::$vm = new View_Manager();
         }
         if (self::$builder === null) {
             self::$builder = new HTML_Custom_Builder(self::$vm);
         }
         $view_manager = self::$vm;
         $builder = self::$builder;
     } elseif ($vm_or_builder instanceof HTML_Custom_Builder) {
         $view_manager = $vm_or_builder->vm;
         $builder = $vm_or_builder;
     } elseif ($vm_or_builder instanceof View_Manager) {
         $view_manager = $vm_or_builder;
         $builder = new HTML_Custom_Builder($view_manager);
     } else {
         throw new Invalid_Argument_Type_Exception('vm_or_builder', $vm_or_builder);
     }
     if ($renderer === null) {
         $renderer = self::getRenderer();
     }
     try {
         $head = Template_Loader::load($template . '.head', $builder);
     } catch (File_Not_Found_Exception $e) {
         if ($hyppos = strpos($template, '-')) {
             try {
                 $head = Template_Loader::load(substr($template, 0, $hyppos + 1) . 'default.head', $builder);
             } catch (File_Not_Found_Exception $e) {
                 try {
                     $head = Template_Loader::load('default.head', $builder);
                 } catch (File_Not_Found_Exception $e) {
                     throw new Template_Not_Found_Exception("Header doesn't exist for template file: {$template}");
                 }
             }
         } else {
             try {
                 $head = Template_Loader::load('default.head', $builder);
             } catch (File_Not_Found_Exception $e) {
                 throw new Template_Not_Found_Exception("Header doesn't exist for template file: {$template}");
             }
         }
     }
     try {
         $body = Template_Loader::load($template, $builder);
     } catch (File_Not_Found_Exception $e) {
         throw new Template_Not_Found_Exception("Template file doesn't exist: {$template}");
     }
     $view_manager->assignHead($head);
     $view_manager->assignBody($body);
     $view_manager->initialize();
     $view_manager->handleInput();
     $view_manager->resolve();
     $view_manager->handleRedirections();
     $renderer->render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
     $renderer->renderNL('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">');
     $renderer->renderNL();
     $view_manager->head->render($renderer);
     $pconf = new Project_Config();
     try {
         $prefix = $pconf->html_prefix;
     } catch (No_Such_Variable_Exception $e) {
         $prefix = "\t";
     }
     $renderer->prefix = $prefix;
     $view_manager->body->render($renderer);
     $renderer->renderNL('</html>');
 }
 protected function createMailBodyHTML()
 {
     $mail_template = $this->_mvo->getMailTemplateSource();
     $vm = new View_Manager();
     $builder = new HTML_Custom_Builder($vm);
     $mail_root = Template_Loader::load($mail_template, $builder);
     $mail_index = new HTML_Indexer($mail_root, 'eid', false);
     $this->_mvo->updateMailBodyTemplate($mail_root, $mail_index, $this->_fields);
     $renderer = new Text_Renderer();
     $mail_root->render($renderer);
     return $renderer->text;
 }