/**
  * Initialize compiler
  *
  * @param string $lexer_class  class name
  * @param string $parser_class class name
  * @param hiweb_tpl $smurty       global instance
  */
 public function __construct($lexer_class, $parser_class, $smurty)
 {
     $this->smurty = $smurty;
     parent::__construct();
     // get required plugins
     $this->lexer_class = $lexer_class;
     $this->parser_class = $parser_class;
 }
 /**
  * Method to compile a hiweb_tpl template
  *
  * @param  Smurty_Internal_Template $template template object to compile
  * @param  bool                     $nocache  true is shall be compiled in nocache mode
  *
  * @return bool             true if compiling succeeded, false if it failed
  */
 public function compileTemplate(Smurty_Internal_Template $template, $nocache = false)
 {
     if (empty($template->properties['nocache_hash'])) {
         $template->properties['nocache_hash'] = $this->nocache_hash;
     } else {
         $this->nocache_hash = $template->properties['nocache_hash'];
     }
     // flag for nochache sections
     $this->nocache = $nocache;
     $this->tag_nocache = false;
     // save template object in compiler class
     $this->template = $template;
     // reset has nocache code flag
     $this->template->has_nocache_code = false;
     $save_source = $this->template->source;
     // template header code
     $template_header = '';
     if (!$this->suppressHeader) {
         $template_header .= "<?php /* hiweb_tpl version " . hiweb_tpl::HIWEB_TPL_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
         $template_header .= "         compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
     }
     if (empty($this->template->source->components)) {
         $this->sources = array($template->source);
     } else {
         // we have array of inheritance templates by extends: resource
         $this->sources = array_reverse($template->source->components);
     }
     $loop = 0;
     // the $this->sources array can get additional elements while compiling by the {extends} tag
     while ($this->template->source = array_shift($this->sources)) {
         $this->smurty->_current_file = $this->template->source->filepath;
         if ($this->smurty->debugging) {
             Smurty_Internal_Debug::start_compile($this->template);
         }
         $no_sources = count($this->sources);
         if ($loop || $no_sources) {
             $this->template->properties['file_dependency'][$this->template->source->uid] = array($this->template->source->filepath, $this->template->source->timestamp, $this->template->source->type);
         }
         $loop++;
         if ($no_sources) {
             $this->inheritance_child = true;
         } else {
             $this->inheritance_child = false;
         }
         do {
             $_compiled_code = '';
             // flag for aborting current and start recompile
             $this->abort_and_recompile = false;
             // get template source
             $_content = $this->template->source->content;
             if ($_content != '') {
                 // run prefilter if required
                 if ((isset($this->smurty->autoload_filters['pre']) || isset($this->smurty->registered_filters['pre'])) && !$this->suppressFilter) {
                     $_content = Smurty_Internal_Filter_Handler::runFilter('pre', $_content, $template);
                 }
                 // call compiler
                 $_compiled_code = $this->doCompile($_content);
             }
         } while ($this->abort_and_recompile);
         if ($this->smurty->debugging) {
             Smurty_Internal_Debug::end_compile($this->template);
         }
     }
     // restore source
     $this->template->source = $save_source;
     unset($save_source);
     $this->smurty->_current_file = $this->template->source->filepath;
     // free memory
     unset($this->parser->root_buffer, $this->parser->current_buffer, $this->parser, $this->lex, $this->template);
     self::$_tag_objects = array();
     // return compiled code to template object
     $merged_code = '';
     if (!$this->suppressMergedTemplates && !empty($this->merged_templates)) {
         foreach ($this->merged_templates as $code) {
             $merged_code .= $code;
         }
     }
     // run postfilter if required on compiled template code
     if ((isset($this->smurty->autoload_filters['post']) || isset($this->smurty->registered_filters['post'])) && !$this->suppressFilter && $_compiled_code != '') {
         $_compiled_code = Smurty_Internal_Filter_Handler::runFilter('post', $_compiled_code, $template);
     }
     if ($this->suppressTemplatePropertyHeader) {
         $code = $_compiled_code . $merged_code;
     } else {
         $code = $template_header . $template->createTemplateCodeFrame($_compiled_code) . $merged_code;
     }
     // unset content because template inheritance could have replace source with parent code
     unset($template->source->content);
     return $code;
 }