Ejemplo n.º 1
0
 /**
  * Display the template as HTML/XML.  Sets the header and displays any buffered warnings/echoed text.
  */
 protected function _display($supress_output)
 {
     if (!$supress_output && array_key_exists('HTTP_HOST', $_SERVER)) {
         $headers = $this->template->getHeaders();
         if (!is_array($headers)) {
             $headers = array($headers);
         }
         foreach ($headers as $header) {
             header($header);
         }
     }
     $classes = array();
     if ($this->template instanceof I2CE_TemplateMeister) {
         $class = get_class($this->template);
         while ($class && $class != 'I2CE_Fuzzy') {
             $classes[] = $class;
             $class = get_parent_class($class);
         }
         $num = count($classes);
     }
     I2CE_ModuleFactory::callHooks('pre_page_prepare_display', $this);
     for ($i = $num - 1; $i >= 0; $i--) {
         I2CE_ModuleFactory::callHooks('pre_page_prepare_display_' . $classes[$i], $this);
     }
     if ($this->template instanceof I2CE_TemplateMeister) {
         $this->template->prepareDisplay();
     }
     for ($i = $num - 1; $i >= 0; $i--) {
         I2CE_ModuleFactory::callHooks('post_page_prepare_display_' . $classes[$i], $this);
     }
     I2CE_ModuleFactory::callHooks('post_page_prepare_display', $this);
     if ($this->template instanceof I2CE_Template) {
         $this->template->checkRolesTasksAndPermissions();
     }
     I2CE_ModuleFactory::callHooks('final_page_prepare_display', $this);
     if (!$supress_output) {
         $display = '';
         if ($this->template instanceof I2CE_TemplateMeister) {
             $display = $this->template->getDisplay();
         }
         $buffer = '';
         if (ob_get_level() == I2CE::$ob_level + 1) {
             $buffer = ob_get_clean();
         }
         echo $display;
         flush();
         if ($buffer) {
             I2CE::raiseError("The page " . $_SERVER['PHP_SELF'] . " has errors");
             $buffer = str_replace(array('<br/>', '<br />'), "\n", $buffer);
             $buffer = htmlentities($buffer, ENT_COMPAT, 'UTF-8', false);
             echo "<span class='buffered_errors'><pre>{$buffer}</pre></span>";
         }
     }
 }