本文整理汇总了PHP中eZURI::encodeURL方法的典型用法代码示例。如果您正苦于以下问题:PHP eZURI::encodeURL方法的具体用法?PHP eZURI::encodeURL怎么用?PHP eZURI::encodeURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZURI
的用法示例。
在下文中一共展示了eZURI::encodeURL方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modify
function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
{
switch ($operatorName) {
case 'ngurl':
if (empty($namedParameters['siteaccess'])) {
return;
}
$ini = eZSiteAccess::getIni($namedParameters['siteaccess'], 'site.ini');
$destinationLocale = $ini->variable('RegionalSettings', 'ContentObjectLocale');
$siteLanguageList = $ini->variable('RegionalSettings', 'SiteLanguageList');
$nodeID = eZURLAliasML::fetchNodeIDByPath($operatorValue);
$destinationElement = eZURLAliasML::fetchByAction('eznode', $nodeID, $destinationLocale, false);
if (empty($destinationElement) || !isset($destinationElement[0]) && !$destinationElement[0] instanceof eZURLAliasML) {
if ($this->isModuleUrl($operatorValue) || $this->isCurrentLocaleAvailable($siteLanguageList)) {
$destinationUrl = $operatorValue;
} else {
$destinationUrl = '';
}
} else {
$destinationUrl = $destinationElement[0]->getPath($destinationLocale, $siteLanguageList);
}
$siteaccessUrlMapping = eZINI::instance('nglanguageswitcher.ini')->variable('LanguageSwitcher', 'SiteAccessUrlMapping');
$destinationUrl = eZURI::encodeURL($destinationUrl);
$operatorValue = rtrim($siteaccessUrlMapping[$namedParameters['siteaccess']], '/') . '/' . ltrim($destinationUrl, '/');
break;
}
}
示例2: redirect
/**
* 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();
}
示例3: eZAppendWarningItem
// Make sure any errors or warnings are reported
if ($ini->variable('DebugSettings', 'DisplayDebugWarnings') == 'enabled') {
if (isset($GLOBALS['eZDebugError']) and $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']) and $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();
if (empty($warningList)) {
$warningList = false;
}
$tpl->setVariable('site', $site);
$tpl->setVariable('warning_list', $warningList);
$tpl->setVariable('redirect_uri', eZURI::encodeURL($redirectURI));
$templateResult = $tpl->fetch('design:redirect.tpl');
eZDebug::addTimingPoint("Script end");
eZDisplayResult($templateResult);
}
eZExecution::cleanExit();
}
// 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() && $module->exitStatus() == eZModule::STATUS_OK) {
$currentURI = $completeRequestedURI;
if (strlen($currentURI) > 0 and $currentURI[0] != '/') {
$currentURI = '/' . $currentURI;
}
$lastAccessedURI = "";
$lastAccessedViewURI = "";
示例4: redirect
/**
* Performs an HTTP redirect.
*
* @param string $path The path to redirect to
* @param array $parameters See createRedirectUrl(). Defaults to empty array.
* @param bool $status The HTTP status code as a string (code + text, e.g. "302 Found"). Defaults to false.
* @param bool $encodeURL Encodes the URL.
* This should normally be true, but may be set to false to avoid double encoding when redirect() is called twice.
* Defaults to true
* @param bool $returnRedirectObject If true, will return an ezpKernelRedirect object.
*
* @return null|ezpKernelRedirect
*/
static function redirect($path, $parameters = array(), $status = false, $encodeURL = true, $returnRedirectObject = false)
{
$url = eZHTTPTool::createRedirectUrl($path, $parameters);
if (strlen($status) > 0) {
header($_SERVER['SERVER_PROTOCOL'] . " " . $status);
eZHTTPTool::headerVariable("Status", $status);
}
if ($encodeURL) {
$url = eZURI::encodeURL($url);
}
eZHTTPTool::headerVariable('Location', $url);
/* Fix for redirecting using workflows and apache 2 */
$escapedUrl = htmlspecialchars($url);
$content = <<<EOT
<HTML><HEAD>
<META HTTP-EQUIV="Refresh" Content="0;URL={$escapedUrl}">
<META HTTP-EQUIV="Location" Content="{$escapedUrl}">
</HEAD><BODY></BODY></HTML>
EOT;
if ($returnRedirectObject) {
return new ezpKernelRedirect($url, $status ?: null, $content);
}
echo $content;
}