Esempio n. 1
0
 /**
  * Output the HTML to the browser
  *
  * @param	bool	Return finished output instead of printing
  * @return	@e void
  */
 public function sendOutput($return = false)
 {
     $this->_sendOutputSetUp('normal');
     //-----------------------------------------
     // Hang on, is IP.SEO still installed?
     //-----------------------------------------
     if (IPSLib::appIsInstalled('ipseo') and !in_array(ipsRegistry::$request['section'], array('upgrade', 'applications'))) {
         $this->silentRedirect($this->settings['_base_url'] . 'app=core&module=seo&section=upgrade');
     }
     //---------------------------------------
     // INIT
     //-----------------------------------------
     $clean_module = IPSText::alphanumericalClean(ipsRegistry::$current_module);
     $navigation = array();
     $_seen_nav = array();
     $_last_nav = '';
     $no_wrapper = FALSE;
     //-----------------------------------------
     // Inline pop-up?
     //-----------------------------------------
     if (ipsRegistry::$request['_popup']) {
         $this->printPopupWindow();
         exit;
     }
     //-----------------------------------------
     // Debug?
     //-----------------------------------------
     if ($this->DB->obj['debug']) {
         flush();
         print "<html><head><title>SQL Debugger</title><body bgcolor='white'><style type='text/css'> TABLE, TD, TR, BODY { font-family: verdana,arial, sans-serif;color:black;font-size:11px }</style>";
         print "<h1 align='center'>SQL Total Time: {$this->DB->sql_time} for {$this->DB->query_cnt} queries</h1><br />" . $this->DB->debug_html;
         print "<br /><div align='center'><strong>Total SQL Time: {$this->DB->sql_time}</div></body></html>";
         exit;
     }
     //-----------------------------------------
     // Context sensitive stuff
     //-----------------------------------------
     if (!$this->cm_output) {
         $_file = IPSLib::getAppDir(IPS_APP_COMPONENT) . '/skin_cp/cp_skin_' . $clean_module . '_context_menu.php';
         if (is_file($_file)) {
             $_class = IPSLib::loadLibrary($_file, 'cp_skin_' . $clean_module . '_context_menu', IPS_APP_COMPONENT);
             $context_menu = new $_class($this->registry);
             $cm_function_full = ipsRegistry::$request['do'] ? 'context_menu__' . $clean_module . '__' . ipsRegistry::$request['section'] . '__' . ipsRegistry::$request['do'] : 'context_menu__' . $clean_module . '__' . ipsRegistry::$request['section'];
             $cm_function = 'context_menu__' . $clean_module . '__' . ipsRegistry::$request['section'];
             $cm_module = 'context_menu__' . $clean_module;
             if (method_exists($_class, $cm_function_full)) {
                 $this->cm_output = $context_menu->__wrap($context_menu->{$cm_function_full}());
             } else {
                 if (method_exists($_class, $cm_function)) {
                     $this->cm_output = $context_menu->__wrap($context_menu->{$cm_function}());
                 } else {
                     if (method_exists($_class, $cm_module)) {
                         $this->cm_output = $context_menu->__wrap($context_menu->{$cm_module}());
                     }
                 }
             }
         }
     }
     /**
      * Add in bookmarkables
      */
     require_once IPS_ROOT_PATH . 'sources/classes/admin/bookmarks.php';
     $bookmarks = new classes_admin_bookmarks();
     $_bookmarkData = array('url' => $bookmarks->cleanUrl($this->settings['query_string_safe']), 'can' => $this->_canBookmark ? 'true' : 'false', 'has' => $bookmarks->hasBookmarked($this->settings['query_string_safe']) ? 'true' : 'false', 'jsn' => $bookmarks->asJson());
     //-----------------------------------------
     // Get tab order
     //-----------------------------------------
     $applications = ipsRegistry::$applications;
     $mainTabs = $this->registry->output->getMainTabKeys();
     $otherTabs = $this->registry->output->getOtherTabKeys();
     $mainTabData = $this->registry->output->getTabDataFromKeys($mainTabs);
     $otherTabData = $this->registry->output->getTabDataFromKeys($otherTabs);
     $gbl_sub_menu = $this->_buildGlobalSubMenu();
     $html = str_replace('<%CONTENT%>', $this->html_main, $this->global_template->global_main_wrapper(IPS_DOC_CHAR_SET, $this->_css, $gbl_sub_menu, $mainTabData, $otherTabData, $_bookmarkData));
     //------------------------------------------------
     // Message in a bottle?
     //------------------------------------------------
     $message = '';
     if ($this->global_error) {
         $message = $this->global_template->global_error_message();
     }
     if ($this->global_message) {
         $message .= $message ? '<br />' . $this->global_template->global_message() : $this->global_template->global_message();
     }
     //-----------------------------------------
     // Figure out title...
     //-----------------------------------------
     $this->html_title = "IP.Board:";
     if (ipsRegistry::$current_application) {
         $this->html_title .= " " . IPSLIb::getAppTitle(ipsRegistry::$current_application);
         if (ipsRegistry::$current_module) {
             $this->html_title .= " &gt; " . (isset($this->lang->words['module__' . ipsRegistry::$current_application . '_' . ipsRegistry::$current_module]) ? $this->lang->words['module__' . ipsRegistry::$current_application . '_' . ipsRegistry::$current_module] : ipsRegistry::$modules_by_section[ipsRegistry::$current_application][ipsRegistry::$current_module]['sys_module_title']);
         }
     }
     if (count($this->extra_title)) {
         $this->html_title .= " &gt; " . implode(' &gt; ', $this->extra_title);
     }
     //-----------------------------------------
     // Got app menu cache?
     //-----------------------------------------
     if (!is_array(ipsRegistry::cache()->getCache('app_menu_cache')) or !count(ipsRegistry::cache()->getCache('app_menu_cache'))) {
         $this->cache->rebuildCache('app_menu_cache', 'global');
     }
     //-----------------------------------------
     // Other tags...
     //-----------------------------------------
     // Can set the second one to none to hide left menu when no context nav is available
     $html = str_replace("<%DISPLAY_SUB_MENU%>", $this->cm_output ? '' : 'none', $html);
     $html = str_replace("<%TITLE%>", $this->html_title, $html);
     $html = str_replace("<%SUBMENU%>", $this->_buildSubMenu(), $html);
     # Must be called first
     $html = str_replace("<%MENU%>", $this->_buildMenu(), $html);
     $html = str_replace("<%SIDEBAR_EXTRA%>", $this->sidebar_extra, $html);
     $html = str_replace("<%CONTEXT_MENU%>", $this->cm_output, $html);
     $html = str_replace("<%SECTIONCONTENT%>", $this->html, $html);
     # This has to be called after the menu has been set so that query_string is set correctly
     $html = str_replace("<%MSG%>", $message, $html);
     //-----------------------------------------
     // Fix up navigation
     //-----------------------------------------
     if (count($this->core_nav)) {
         foreach ($this->core_nav as $data) {
             if (isset($_seen_nav[$data[1]])) {
                 continue;
             } else {
                 $_seen_nav[$data[1]] = 1;
             }
             $_nav = isset($_last_nav['nav']) ? $_last_nav['nav'] . ' &gt; ' . $data[1] : $data[1];
             # Append last nav...
             $_last_nav = array('url' => $data[0], 'title' => $data[1], 'nav' => $_nav);
             if ($data[0]) {
                 $navigation[] = "<a href='" . $data[0] . "'>" . $data[1] . "</a>";
             } else {
                 $navigation[] = $data[1];
             }
         }
     }
     if (count($this->extra_nav)) {
         foreach ($this->extra_nav as $data) {
             if (isset($_seen_nav[$data[1]])) {
                 continue;
             } else {
                 $_seen_nav[$data[1]] = 1;
             }
             $_nav = isset($_last_nav['nav']) ? $_last_nav['nav'] . ' &gt; ' . $data[1] : $data[1];
             # Append last nav...
             $_last_nav = array('url' => $data[0], 'title' => $data[1], 'nav' => $_nav);
             if ($data[0]) {
                 $navigation[] = "<a href='" . $data[0] . "'>" . $data[1] . "</a>";
             } else {
                 $navigation[] = $data[1];
             }
         }
     }
     //------------------------------------------------
     // Navigation?
     //------------------------------------------------
     if (count($navigation) > 0) {
         $html = str_replace("<%NAV%>", $this->global_template->wrap_nav("<li>" . implode("&nbsp; &gt; &nbsp;</li><li>", $navigation) . "</li>"), $html);
     } else {
         $html = str_replace("<%NAV%>", '', $html);
     }
     //-----------------------------------------
     // Last thing, the nav element...
     //-----------------------------------------
     if (isset($_last_nav['title'])) {
         $html = str_replace("<%PAGE_NAV%>", $_last_nav['title'], $html);
     }
     $query_html = "";
     //-----------------------------------------
     // Show SQL queries
     //-----------------------------------------
     if (IN_DEV and count($this->DB->obj['cached_queries'])) {
         $queries = "";
         foreach ($this->DB->obj['cached_queries'] as $q) {
             $queries .= "<div style='padding:6px; border-bottom:1px solid #000'>" . htmlspecialchars($q) . '</div>';
         }
         $query_html .= $this->global_template->global_query_output($queries);
         /* Included Files */
         if (function_exists('get_included_files')) {
             $__files = get_included_files();
             $files = '';
             foreach ($__files as $__f) {
                 $files .= "<strong>{$__f}</strong><br />";
             }
             $query_html .= $this->global_template->global_if_output(count($__files), $files);
         }
     }
     //-----------------------------------------
     // Memory usage
     //-----------------------------------------
     if (IPS_MEMORY_DEBUG_MODE and defined('IPS_MEMORY_START') and IN_DEV) {
         if (is_array(IPSDebug::$memory_debug)) {
             $memory = '';
             $_c = 0;
             foreach (IPSDebug::$memory_debug as $usage) {
                 $_c++;
                 if ($usage[1] > 500 * 1024) {
                     $_col = "color:#D00000";
                 } else {
                     if ($usage[1] < 10 * 1024) {
                         $_col = "color:darkgreen";
                     } else {
                         if ($usage[1] < 100 * 1024) {
                             $_col = "color:darkorange";
                         }
                     }
                 }
                 $memory .= "<tr><td width='60%' style='{$_col}' align='left'>{$usage[0]}</td><td style='{$_col}' align='left'><strong>" . IPSLib::sizeFormat($usage[1]) . "</strong></td></tr>";
             }
         }
         $_used = memory_get_usage() - IPS_MEMORY_START;
         $peak_used = memory_get_peak_usage() - IPS_MEMORY_START;
         $query_html .= $this->global_template->global_memory_output($memory, IPSLib::sizeFormat($_used), IPSLib::sizeFormat($peak_used));
     }
     $html = str_replace("<%QUERIES%>", $query_html, $html);
     //-----------------------------------------
     // Got BODY EXTRA?
     //-----------------------------------------
     if ($this->body_extra) {
         $html = str_replace("<body", "<body " . $this->body_extra, $html);
     }
     //-----------------------------------------
     // Emoticons fix
     //-----------------------------------------
     $html = str_replace("<#EMO_DIR#>", 'default', $html);
     /* Remove any public side hooks */
     $html = preg_replace('#<!--hook\\.([^\\>]+?)-->#', '', $html);
     //-----------------------------------------
     // Gzip?
     //-----------------------------------------
     if (IPB_ACP_USE_GZIP) {
         $buffer = "";
         if (count(ob_list_handlers())) {
             $buffer = ob_get_contents();
             ob_end_clean();
         }
         ob_start('ob_gzhandler');
         print $buffer;
     }
     @header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     @header("Cache-Control: no-cache, must-revalidate");
     @header("Pragma: no-cache");
     @header("Content-type: text/html; charset=" . IPS_DOC_CHAR_SET);
     //-----------------------------------------
     // OUTPUT
     //-----------------------------------------
     if ($return) {
         $this->_IS_PRINTED = 1;
         return $html;
     }
     print $html;
     $this->_IS_PRINTED = 1;
     exit;
 }