function Display($path = NULL, $args = NULL) { $path = any($path, $this->request["path"], "/"); $args = any($args, $this->request["args"], array()); if (!empty($this->components)) { try { $output = $this->components->Dispatch($path, $args, $this->request["type"]); } catch (Exception $e) { //print_pre($e); $output["content"] = $this->HandleException($e); } $this->session->quit(); $contegargs = any($this->cfg->servers["conteg"], array()); $sitecfg = ConfigManager::get("conteg"); if (is_array($sitecfg)) { $contegargs = array_merge($contegargs, $sitecfg); } if (is_array($this->sitecfg["conteg"])) { $contegargs = array_merge($contegargs, $this->sitecfg["conteg"]); } if (empty($contegargs["type"])) { $contegargs["type"] = any($this->request["contenttype"], $output["responsetype"]); } if (is_array($contegargs["policy"][$contegargs["type"]])) { $contegargs = array_merge($contegargs, $contegargs["policy"][$contegargs["type"]]); } if (empty($contegargs["modified"])) { // Set modified time to mtime of base directory if not set $contegargs["modified"] = filemtime($this->rootdir); } if (!empty($contegargs["alloworigin"])) { header('Access-Control-Allow-Origin: ' . $contegargs["alloworigin"]); } //header('Content-type: ' . any($output["type"], "text/html")); if ($output["type"] == "ajax" || $output["type"] == "jsonp") { print $this->tplmgr->PostProcess($output["content"], true); } else { print $this->tplmgr->PostProcess($output["content"]); $showprofiler = !empty($this->request["args"]["timing"]) || $output["type"] == "text/html" && array_get($this->cfg->servers, "profiler.display"); if ($showprofiler) { print Profiler::Display(); } } Profiler::StopTimer("WebApp::TimeToDisplay"); Profiler::StartTimer("WebApp::Display() - Conteg", 1); new Conteg($contegargs); Profiler::StopTimer("WebApp::Display() - Conteg"); if (Profiler::$log) { Profiler::Log(DependencyManager::$locations["tmp"], $this->components->pagecfg["pagename"]); } } }
function Display($path = NULL, $args = NULL) { $path = any($path, $this->request["path"], "/"); $args = any($args, $this->request["args"], array()); if (!empty($this->components)) { try { $output = $this->components->Dispatch($path, $args, $this->request["type"]); } catch (Exception $e) { //print_pre($e); $output["content"] = $this->HandleException($e); } $this->session->quit(); $headers = headers_list(); $isRedirect = false; $ctype = null; foreach ($headers as $header) { list($k, $v) = explode(": ", $header, 2); if ($k == "Location") { $isRedirect = true; } if ($k == "Content-Type") { $ctype = $v; } } if (!$isRedirect) { // Load settings from servers.ini $contegargs = isset($this->cfg->servers["conteg"]) ? $this->cfg->servers["conteg"] : array(); $contegargs["charset"] = "UTF-8"; // FIXME - shouldn't be hardcoded, but we should also replace Conteg... $contegargs["cache_control"]["macro"] = "public"; $contegargs["use_etags"] = true; // And also from site config $contegcfg = ConfigManager::get("conteg"); if (is_array($contegcfg)) { $contegargs = array_merge($contegargs, $contegcfg); } if (empty($contegargs["type"])) { $contegargs["type"] = any($ctype, $this->request["contenttype"], $output["responsetype"]); } // Merge type-specific policy settings from config if applicable if (isset($contegargs["policy"]) && is_array($contegargs["policy"][$contegargs["type"]])) { $contegargs = array_merge($contegargs, $contegargs["policy"][$contegargs["type"]]); } if (empty($contegargs["modified"])) { // Set modified time to mtime of base directory if not set $contegargs["modified"] = filemtime($this->rootdir); } if ($output["type"] == "ajax" || $output["type"] == "jsonp") { print $this->tplmgr->PostProcess($output["content"], true); } else { print $this->tplmgr->PostProcess($output["content"]); if (!empty($this->request["args"]["timing"])) { print Profiler::Display(); } } if ($output["http_status"]) { $contegargs["http_status"] = $output["http_status"]; } Profiler::StopTimer("WebApp::TimeToDisplay"); Profiler::StartTimer("WebApp::Display() - Conteg", 1); new Conteg($contegargs); Profiler::StopTimer("WebApp::Display() - Conteg"); } if (Profiler::$log) { Profiler::Log(DependencyManager::$locations["tmp"], $this->components->pagecfg["pagename"]); } } }