/** * Output the HTML to the browser * * @access public * @return void */ public function sendOutput() { $this->_sendOutputSetUp('normal'); //--------------------------------------- // 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; } //----------------------------------------- // Sticky tabs //----------------------------------------- $this->member->setProperty('global_sticky_tabs', is_array($this->memberData['global_sticky_tabs']) ? $this->memberData['global_sticky_tabs'] : array()); //----------------------------------------- // Start function proper //----------------------------------------- if ($no_wrapper === FALSE) { //----------------------------------------- // Context sensitive stuff //----------------------------------------- if (!$this->cm_output) { $_file = IPS_APPLICATION_PATH . 'skin_cp/cp_skin_' . $clean_module . '_context_menu.php'; $_class = 'cp_skin_' . $clean_module . '_context_menu'; if (file_exists($_file)) { require $_file; $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}()); } else { if (ipsRegistry::$request['section'] != 'dashboard' && ipsRegistry::$request['do'] != 'index') { $this->cm_output = $this->global_template->no_context_menu(); } } } } } else { $this->cm_output = $this->global_template->no_context_menu(); } } //----------------------------------------- // Global Context Menu Stuff //----------------------------------------- $_file = IPS_ROOT_PATH . "skin_cp/cp_skin_global_context_menu.php"; if (file_exists($_file)) { require_once $_file; $global_context = new cp_skin_global_context_menu($this->registry); $global_context_output = $global_context->get(); } $html = str_replace('<%CONTENT%>', $this->html_main, $this->global_template->global_main_wrapper(IPS_DOC_CHAR_SET, $this->_css)); } else { $html = str_replace('<%CONTENT%>', $this->html_main, $this->global_template->global_main_wrapper_no_furniture(IPS_DOC_CHAR_SET, $this->_css)); } //------------------------------------------------ // 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(); } //------------------------------------------------ // Help? //------------------------------------------------ /*if ( isset( $this->html_help_title ) AND isset( $this->html_help_msg ) AND $this->html_help_title != '' ) { $help = $this->global_template->information_box( $this->html_help_title, $this->html_help_msg ) . "<br >"; }*/ //----------------------------------------- // Keith's help mode (tm) //----------------------------------------- if ($this->settings['acp_tutorial_mode']) { //-------------------------------------- // More Help? - *sigh* Keith //-------------------------------------- // Decided to use request instead of (e.g.) ipsRegistry::$current_application to make it easier for us to map. // We can change in the future if it's preferred $check_key = $this->request['app'] . '_' . $this->request['module'] . '_' . $this->request['section'] . '_' . $this->request['do'] . '_'; if ($this->request['groupHelpKey']) { $check_key .= $this->request['groupHelpKey']; } $help .= $this->global_template->help_box($check_key); } //----------------------------------------- // Figure out title... //----------------------------------------- $this->html_title = "IP.Board:"; if (ipsRegistry::$current_application) { $this->html_title .= " > " . ipsRegistry::$applications[ipsRegistry::$current_application]['app_title']; if (ipsRegistry::$current_module) { $this->html_title .= " > " . ipsRegistry::$modules_by_section[ipsRegistry::$current_application][ipsRegistry::$current_module]['sys_module_title']; } } if (count($this->extra_title)) { $this->html_title .= " > " . implode(' > ', $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("<%CONTEXT_MENU%>", $this->cm_output, $html); $html = str_replace("<%GLOBAL_CONTEXT_MENU%>", $global_context_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); $html = str_replace("<%HELP%>", isset($help) ? $help : '', $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'] . ' > ' . $data[1] : $data[1]; # Append last nav... $_last_nav = array('url' => $page_location, '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 = $_last_nav['nav'] ? $_last_nav['nav'] . ' > ' . $data[1] : $data[1]; # Append last nav... $_last_nav = array('url' => $page_location, '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(" > </li><li>", $navigation) . "</li>"), $html); } else { $html = str_replace("<%NAV%>", '', $html); } //----------------------------------------- // Last thing, the nav element... //----------------------------------------- $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(); $query_html .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>(" . count($__files) . ") Included Files</div><div class='row1' style='padding:6px'>\n"; foreach ($__files as $__f) { $query_html .= "<strong>{$__f}</strong><br />"; } $query_html .= '</div></div>'; } } $html = str_replace("<%QUERIES%>", $query_html, $html); //----------------------------------------- // Got BODY EXTRA? //----------------------------------------- if ($this->body_extra) { $html = str_replace("<body", "<body " . $this->body_extra, $html); } //----------------------------------------- // Lang Replace //----------------------------------------- $html = preg_replace("#{txt\\.(.+?)}#e", "\$this->lang->words['\\1']", $html); //----------------------------------------- // Emoticons fix //----------------------------------------- $html = str_replace("<#EMO_DIR#>", 'default', $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 //----------------------------------------- print $html; //----------------------------------------- // Memory usage //----------------------------------------- if (IPS_MEMORY_DEBUG_MODE and defined('IPS_MEMORY_START') and IN_DEV) { if (is_array(IPSDebug::$memory_debug)) { $memory .= "<br />\n<div align='center' style='margin-left:auto;margin-right:auto'><div class='tableborder' style='width:75%'>\n<div class='tableheaderalt'>MEMORY USAGE</div><div class='tablerow1' style='padding:6px'>\n"; $memory .= "<table cellpadding='4' cellspacing='0' border='0' width='100%'>\n"; $_c = 0; foreach (IPSDebug::$memory_debug as $usage) { $_col = $_c % 2 ? '#eee' : '#ddd'; $_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='background-color:{$_col}' align='left'>{$usage[0]}</td><td style='background-color:{$_col}' align='left'><strong>" . IPSLib::sizeFormat($usage[1]) . "</strong></td></tr>"; } $memory .= "</table></div></div></div>"; } $end = memory_get_usage(); $peak_end = memory_get_peak_usage(); $_used = $end - IPS_MEMORY_START; $peak_used = $peak_end - IPS_MEMORY_START; print $memory; print "Total Memory Used: " . IPSLib::sizeFormat($_used) . " (Peak:" . IPSText::sizeFormat($peak_used) . ")"; } $this->_IS_PRINTED = 1; exit; }