/**
  * Execution point for controller actions
  */
 public function run()
 {
     ob_start();
     $this->requestInit();
     // send header information
     foreach (eZHTTPHeader::headerOverrideArray($this->uri) + array('Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', 'Last-Modified' => gmdate('D, d M Y H:i:s') . ' GMT', 'Cache-Control' => 'no-cache, must-revalidate', 'Pragma' => 'no-cache', 'X-Powered-By' => 'eZ Publish', 'Content-Type' => 'text/html; charset=' . $this->httpCharset, 'Served-by' => $_SERVER["SERVER_NAME"], 'Content-language' => $this->languageCode) as $key => $value) {
         header($key . ': ' . $value);
     }
     try {
         $moduleResult = $this->dispatchLoop();
     } catch (Exception $e) {
         $this->shutdown();
         throw $e;
     }
     $ini = eZINI::instance();
     /**
      * Ouput an is_logged_in cookie when users are logged in for use by http cache solutions.
      *
      * @deprecated As of 4.5, since 4.4 added lazy session support (init on use)
      */
     if ($ini->variable("SiteAccessSettings", "CheckValidity") !== 'true') {
         $currentUser = eZUser::currentUser();
         $wwwDir = eZSys::wwwDir();
         // On host based site accesses this can be empty, causing the cookie to be set for the current dir,
         // but we want it to be set for the whole eZ publish site
         $cookiePath = $wwwDir != '' ? $wwwDir : '/';
         if ($currentUser->isLoggedIn()) {
             // Only set the cookie if it doesnt exist. This way we are not constantly sending the set request in the headers.
             if (!isset($_COOKIE['is_logged_in']) || $_COOKIE['is_logged_in'] !== 'true') {
                 setcookie('is_logged_in', 'true', 0, $cookiePath);
             }
         } else {
             if (isset($_COOKIE['is_logged_in'])) {
                 setcookie('is_logged_in', false, 0, $cookiePath);
             }
         }
     }
     if ($this->module->exitStatus() == eZModule::STATUS_REDIRECT) {
         $this->redirect();
     }
     // Store the last URI for access history for login redirection
     // Only if user has session and only if there was no error or no redirects happen
     if (eZSession::hasStarted() && $this->module->exitStatus() == eZModule::STATUS_OK) {
         $currentURI = $this->completeRequestedURI;
         if (strlen($currentURI) > 0 && $currentURI[0] !== '/') {
             $currentURI = '/' . $currentURI;
         }
         $lastAccessedURI = "";
         $lastAccessedViewURI = "";
         $http = eZHTTPTool::instance();
         // Fetched stored session variables
         if ($http->hasSessionVariable("LastAccessesURI")) {
             $lastAccessedViewURI = $http->sessionVariable("LastAccessesURI");
         }
         if ($http->hasSessionVariable("LastAccessedModifyingURI")) {
             $lastAccessedURI = $http->sessionVariable("LastAccessedModifyingURI");
         }
         // Update last accessed view page
         if ($currentURI != $lastAccessedViewURI && !in_array($this->module->uiContextName(), array('edit', 'administration', 'browse', 'authentication'))) {
             $http->setSessionVariable("LastAccessesURI", $currentURI);
         }
         // Update last accessed non-view page
         if ($currentURI != $lastAccessedURI) {
             $http->setSessionVariable("LastAccessedModifyingURI", $currentURI);
         }
     }
     eZDebug::addTimingPoint("Module end '" . $this->module->attribute('name') . "'");
     if (!is_array($moduleResult)) {
         eZDebug::writeError('Module did not return proper result: ' . $this->module->attribute('name'), 'index.php');
         $moduleResult = array();
         $moduleResult['content'] = false;
     }
     if (!isset($moduleResult['ui_context'])) {
         $moduleResult['ui_context'] = $this->module->uiContextName();
     }
     $moduleResult['ui_component'] = $this->module->uiComponentName();
     $moduleResult['is_mobile_device'] = $this->mobileDeviceDetect->isMobileDevice();
     $moduleResult['mobile_device_alias'] = $this->mobileDeviceDetect->getUserAgentAlias();
     $templateResult = null;
     eZDebug::setUseExternalCSS($this->siteBasics['external-css']);
     if ($this->siteBasics['show-page-layout']) {
         $tpl = eZTemplate::factory();
         if ($tpl->hasVariable('node')) {
             $tpl->unsetVariable('node');
         }
         if (!isset($moduleResult['path'])) {
             $moduleResult['path'] = false;
         }
         $moduleResult['uri'] = eZSys::requestURI();
         $tpl->setVariable("module_result", $moduleResult);
         $meta = $ini->variable('SiteSettings', 'MetaDataArray');
         if (!isset($meta['description'])) {
             $metaDescription = "";
             if (isset($moduleResult['path']) && is_array($moduleResult['path'])) {
                 foreach ($moduleResult['path'] as $pathPart) {
                     if (isset($pathPart['text'])) {
                         $metaDescription .= $pathPart['text'] . " ";
                     }
                 }
             }
             $meta['description'] = $metaDescription;
         }
         $this->site['uri'] = $this->oldURI;
         $this->site['redirect'] = false;
         $this->site['meta'] = $meta;
         $this->site['version'] = eZPublishSDK::version();
         $this->site['page_title'] = $this->module->title();
         $tpl->setVariable("site", $this->site);
         if ($ini->variable('DebugSettings', 'DisplayDebugWarnings') === 'enabled') {
             // Make sure any errors or warnings are reported
             if (isset($GLOBALS['eZDebugError']) && $GLOBALS['eZDebugError']) {
                 eZAppendWarningItem(array('error' => array('type' => 'error', 'number' => 1, 'count' => $GLOBALS['eZDebugErrorCount']), 'identifier' => 'ezdebug-first-error', 'text' => ezpI18n::tr('index.php', 'Some errors occurred, see debug for more information.')));
             }
             if (isset($GLOBALS['eZDebugWarning']) && $GLOBALS['eZDebugWarning']) {
                 eZAppendWarningItem(array('error' => array('type' => 'warning', 'number' => 1, 'count' => $GLOBALS['eZDebugWarningCount']), 'identifier' => 'ezdebug-first-warning', 'text' => ezpI18n::tr('index.php', 'Some general warnings occured, see debug for more information.')));
             }
         }
         if ($this->siteBasics['user-object-required']) {
             $currentUser = eZUser::currentUser();
             $tpl->setVariable("current_user", $currentUser);
             $tpl->setVariable("anonymous_user_id", $ini->variable('UserSettings', 'AnonymousUserID'));
         } else {
             $tpl->setVariable("current_user", false);
             $tpl->setVariable("anonymous_user_id", false);
         }
         $tpl->setVariable("access_type", $this->access);
         $tpl->setVariable('warning_list', !empty($this->warningList) ? $this->warningList : false);
         $resource = "design:";
         if (is_string($this->siteBasics['show-page-layout'])) {
             if (strpos($this->siteBasics['show-page-layout'], ":") !== false) {
                 $resource = "";
             }
         } else {
             $this->siteBasics['show-page-layout'] = "pagelayout.tpl";
         }
         // Set the navigation part
         // Check for navigation part settings
         $navigationPartString = 'ezcontentnavigationpart';
         if (isset($moduleResult['navigation_part'])) {
             $navigationPartString = $moduleResult['navigation_part'];
             // Fetch the navigation part
         }
         $navigationPart = eZNavigationPart::fetchPartByIdentifier($navigationPartString);
         $tpl->setVariable('navigation_part', $navigationPart);
         $tpl->setVariable('uri_string', $this->uri->uriString());
         if (isset($moduleResult['requested_uri_string'])) {
             $tpl->setVariable('requested_uri_string', $moduleResult['requested_uri_string']);
         } else {
             $tpl->setVariable('requested_uri_string', $this->actualRequestedURI);
         }
         // Set UI context and component
         $tpl->setVariable('ui_context', $moduleResult['ui_context']);
         $tpl->setVariable('ui_component', $moduleResult['ui_component']);
         $templateResult = $tpl->fetch($resource . $this->siteBasics['show-page-layout']);
     } else {
         $templateResult = $moduleResult['content'];
     }
     eZDebug::addTimingPoint("Script end");
     $content = trim(ob_get_clean());
     ob_start();
     eZDB::checkTransactionCounter();
     eZDisplayResult($templateResult);
     $content .= ob_get_clean();
     $this->shutdown();
     return new ezpKernelResult($content);
 }
Esempio n. 2
0
    if ($currentURI != $lastAccessedURI) {
        $http->setSessionVariable("LastAccessedModifyingURI", $currentURI);
    }
}
eZDebug::addTimingPoint("Module end '" . $module->attribute('name') . "'");
if (!is_array($moduleResult)) {
    eZDebug::writeError('Module did not return proper result: ' . $module->attribute('name'), 'index.php');
    $moduleResult = array();
    $moduleResult['content'] = false;
}
if (!isset($moduleResult['ui_context'])) {
    $moduleResult['ui_context'] = $module->uiContextName();
}
$moduleResult['ui_component'] = $module->uiComponentName();
$moduleResult['is_mobile_device'] = $mobileDeviceDetect->isMobileDevice();
$moduleResult['mobile_device_alias'] = $mobileDeviceDetect->getUserAgentAlias();
$templateResult = null;
eZDebug::setUseExternalCSS($use_external_css);
if ($show_page_layout) {
    $tpl = eZTemplate::factory();
    if ($tpl->hasVariable('node')) {
        $tpl->unsetVariable('node');
    }
    if (!isset($moduleResult['path'])) {
        $moduleResult['path'] = false;
    }
    $moduleResult['uri'] = eZSys::requestURI();
    $tpl->setVariable("module_result", $moduleResult);
    $meta = $ini->variable('SiteSettings', 'MetaDataArray');
    if (!isset($meta['description'])) {
        $metaDescription = "";