コード例 #1
0
 /**
  * Performs a redirection
  */
 protected function redirect()
 {
     $GLOBALS['eZRedirection'] = true;
     $ini = eZINI::instance();
     $automaticRedirect = true;
     if ($GLOBALS['eZDebugAllowed'] && ($redirUri = $ini->variable('DebugSettings', 'DebugRedirection')) !== 'disabled') {
         if ($redirUri == "enabled") {
             $automaticRedirect = false;
         } else {
             $uri = eZURI::instance(eZSys::requestURI());
             $uri->toBeginning();
             foreach ($ini->variableArray("DebugSettings", "DebugRedirection") as $redirUri) {
                 $redirUri = new eZURI($redirUri);
                 if ($redirUri->matchBase($uri)) {
                     $automaticRedirect = false;
                     break;
                 }
             }
         }
     }
     $redirectURI = eZSys::indexDir();
     $moduleRedirectUri = $this->module->redirectURI();
     if ($ini->variable('URLTranslator', 'Translation') === 'enabled' && eZURLAliasML::urlTranslationEnabledByUri(new eZURI($moduleRedirectUri))) {
         $translatedModuleRedirectUri = $moduleRedirectUri;
         if (eZURLAliasML::translate($translatedModuleRedirectUri, true)) {
             $moduleRedirectUri = $translatedModuleRedirectUri;
             if (strlen($moduleRedirectUri) > 0 && $moduleRedirectUri[0] !== '/') {
                 $moduleRedirectUri = '/' . $moduleRedirectUri;
             }
         }
     }
     if (preg_match('#^(\\w+:)|^//#', $moduleRedirectUri)) {
         $redirectURI = $moduleRedirectUri;
     } else {
         $leftSlash = strlen($redirectURI) > 0 && $redirectURI[strlen($redirectURI) - 1] === '/';
         $rightSlash = strlen($moduleRedirectUri) > 0 && $moduleRedirectUri[0] === '/';
         if (!$leftSlash && !$rightSlash) {
             // Both are without a slash, so add one
             $moduleRedirectUri = '/' . $moduleRedirectUri;
         } else {
             if ($leftSlash && $rightSlash) {
                 // Both are with a slash, so we remove one
                 $moduleRedirectUri = substr($moduleRedirectUri, 1);
             }
         }
         $redirectURI .= $moduleRedirectUri;
     }
     eZStaticCache::executeActions();
     eZDB::checkTransactionCounter();
     if ($automaticRedirect) {
         eZHTTPTool::redirect($redirectURI, array(), $this->module->redirectStatus());
     } else {
         // Make sure any errors or warnings are reported
         if ($ini->variable('DebugSettings', 'DisplayDebugWarnings') === 'enabled') {
             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.')));
             }
         }
         $tpl = eZTemplate::factory();
         $tpl->setVariable('site', $this->site);
         $tpl->setVariable('warning_list', !empty($this->warningList) ? $this->warningList : false);
         $tpl->setVariable('redirect_uri', eZURI::encodeURL($redirectURI));
         $templateResult = $tpl->fetch('design:redirect.tpl');
         eZDebug::addTimingPoint("Script end");
         eZDisplayResult($templateResult);
     }
     eZExecution::cleanExit();
 }
コード例 #2
0
 /**
  * Forwards the current execution to another module/view with the existing
  * parameters.
  *
  * @param eZModule $module The eZModule object the request will be forwarded to
  * @param string $functionName The function to run in that module
  * @param array $parameters
  *        An array of parameters that will be added to the request. These
  *        will be merged with the existing parameters
  * @return array The forwarded module/view result
  */
 function forward($module, $functionName, $parameters = false)
 {
     $Return = null;
     if ($module && $functionName) {
         $viewName = self::currentView();
         if ($parameters === false) {
             $parameters = array();
         }
         $parameters = array_merge($parameters, $this->OriginalViewParameters);
         $unorderedParameters = $this->OriginalUnorderedParameters;
         $userParameters = $this->UserParameters;
         $Return = $module->run($functionName, $parameters, $unorderedParameters, $userParameters);
         // override default navigation part
         if ($Return['is_default_navigation_part'] === true) {
             if ($this->singleFunction()) {
                 $function = $this->Module["function"];
             } else {
                 $function = $this->Functions[$functionName];
             }
             if (isset($function['default_navigation_part'])) {
                 $Return['navigation_part'] = $function['default_navigation_part'];
             }
         }
         $this->RedirectURI = $module->redirectURI();
         $this->setExitStatus($module->exitStatus());
     }
     return $Return;
 }
コード例 #3
0
ファイル: index.php プロジェクト: legende91/ez
         $automatic_redir = false;
     } else {
         $redirUris = $ini->variableArray("DebugSettings", "DebugRedirection");
         $uri = eZURI::instance(eZSys::requestURI());
         $uri->toBeginning();
         foreach ($redirUris as $redirUri) {
             $redirUri = new eZURI($redirUri);
             if ($redirUri->matchBase($uri)) {
                 $automatic_redir = false;
                 break;
             }
         }
     }
 }
 $redirectURI = eZSys::indexDir();
 $moduleRedirectUri = $module->redirectURI();
 $redirectStatus = $module->redirectStatus();
 $translatedModuleRedirectUri = $moduleRedirectUri;
 if ($ini->variable('URLTranslator', 'Translation') == 'enabled' && eZURLAliasML::urlTranslationEnabledByUri(new eZURI($moduleRedirectUri))) {
     if (eZURLAliasML::translate($translatedModuleRedirectUri, true)) {
         $moduleRedirectUri = $translatedModuleRedirectUri;
         if (strlen($moduleRedirectUri) > 0 and $moduleRedirectUri[0] != '/') {
             $moduleRedirectUri = '/' . $moduleRedirectUri;
         }
     }
 }
 if (preg_match('#^(\\w+:)|^//#', $moduleRedirectUri)) {
     $redirectURI = $moduleRedirectUri;
 } else {
     $leftSlash = false;
     $rightSlash = false;