本文整理汇总了PHP中eZURI::setURIString方法的典型用法代码示例。如果您正苦于以下问题:PHP eZURI::setURIString方法的具体用法?PHP eZURI::setURIString怎么用?PHP eZURI::setURIString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZURI
的用法示例。
在下文中一共展示了eZURI::setURIString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: match
//.........这里部分代码省略.........
case 'part':
{
$hasHostMatch = ( strpos($host, $matchHost) !== false );
} break;
default:
{
$hasHostMatch = false;
eZDebug::writeError( "Unknown host_uri host match: $matchHostMethod", "access" );
} break;
}
if ( $hasHostMatch )
{
if ( $matchURI !== '' )
{
$matchURIFolders = explode( '/', $matchURI );
$uri->increase( count( $matchURIFolders ) );
$uri->dropBase();
$access['uri_part'] = $matchURIFolders;
}
$access['name'] = $matchAccess;
$access['type'] = $type;
return $access;
}
}
}
} break;
case 'index':
{
$type = eZSiteAccess::TYPE_INDEX_FILE;
$match_type = $ini->variable( 'SiteAccessSettings', 'IndexMatchType' );
$match_item = $file;
if ( $match_type == 'element' )
{
$match_index = $ini->variable( 'SiteAccessSettings', 'IndexMatchElement' );
$match_pos = strpos( $match_item, '.php' );
if ( $match_pos !== false )
{
$match_item = substr( $match_item, 0, $match_pos );
$match_arr = explode( '_', $match_item );
$name = $match_arr[$match_index];
}
}
else if ( $match_type == 'text' )
{
$matcher_pre = $ini->variable( 'SiteAccessSettings', 'IndexMatchSubtextPre' );
$matcher_post = $ini->variable( 'SiteAccessSettings', 'IndexMatchSubtextPost' );
}
else if ( $match_type == 'regexp' )
{
$matcher = $ini->variable( 'SiteAccessSettings', 'IndexMatchRegexp' );
$match_num = $ini->variable( 'SiteAccessSettings', 'IndexMatchRegexpItem' );
}
else
continue;
} break;
default:
{
eZDebug::writeError( "Unknown access match: $matchprobe", "access" );
} break;
}
if ( $match_type == 'regexp' )
$name = self::matchRegexp( $match_item, $matcher, $match_num );
else if ( $match_type == 'text' )
$name = self::matchText( $match_item, $matcher_pre, $matcher_post );
if ( isset( $name ) && $name != '' )
{
$name = preg_replace( array( '/[^a-zA-Z0-9]+/', '/_+/', '/^_/', '/_$/' ),
array( '_', '_', '', '' ),
$name );
if ( in_array( $name, $siteAccessList ) )
{
if ( $type == eZSiteAccess::TYPE_URI )
{
if ( $match_type == 'element' )
{
$uri->increase( $match_index );
$uri->dropBase();
}
else if ( $match_type == 'regexp' )
{
$uri->setURIString( $match_item );
}
else if ( $match_type == 'text' )
{
$uri->setURIString( $match_item );
}
}
$access['type'] = $type;
$access['name'] = $name;
$access['uri_part'] = $uri_part;
return $access;
}
}
}
return $access;
}
示例2: dispatchLoop
/**
* Runs the dispatch loop
*/
protected function dispatchLoop()
{
$ini = eZINI::instance();
// Start the module loop
while ($this->siteBasics['module-run-required']) {
$objectHasMovedError = false;
$objectHasMovedURI = false;
$this->actualRequestedURI = $this->uri->uriString();
// Extract user specified parameters
$userParameters = $this->uri->userParameters();
// Generate a URI which also includes the user parameters
$this->completeRequestedURI = $this->uri->originalURIString();
// Check for URL translation
if ($this->siteBasics['url-translator-allowed'] && eZURLAliasML::urlTranslationEnabledByUri($this->uri)) {
$translateResult = eZURLAliasML::translate($this->uri);
if (!is_string($translateResult) && $ini->variable('URLTranslator', 'WildcardTranslation') === 'enabled') {
$translateResult = eZURLWildcard::translate($this->uri);
}
// Check if the URL has moved
if (is_string($translateResult)) {
$objectHasMovedURI = $translateResult;
foreach ($userParameters as $name => $value) {
$objectHasMovedURI .= '/(' . $name . ')/' . $value;
}
$objectHasMovedError = true;
}
}
if ($this->uri->isEmpty()) {
$tmp_uri = new eZURI($ini->variable("SiteSettings", "IndexPage"));
$moduleCheck = eZModule::accessAllowed($tmp_uri);
} else {
$moduleCheck = eZModule::accessAllowed($this->uri);
}
if (!$moduleCheck['result']) {
if ($ini->variable("SiteSettings", "ErrorHandler") == "defaultpage") {
$defaultPage = $ini->variable("SiteSettings", "DefaultPage");
$this->uri->setURIString($defaultPage);
$moduleCheck['result'] = true;
}
}
$displayMissingModule = false;
$this->oldURI = $this->uri;
if ($this->uri->isEmpty()) {
if (!fetchModule($tmp_uri, $this->check, $this->module, $moduleName, $functionName, $params)) {
$displayMissingModule = true;
}
} else {
if (!fetchModule($this->uri, $this->check, $this->module, $moduleName, $functionName, $params)) {
if ($ini->variable("SiteSettings", "ErrorHandler") == "defaultpage") {
$tmp_uri = new eZURI($ini->variable("SiteSettings", "DefaultPage"));
if (!fetchModule($tmp_uri, $this->check, $this->module, $moduleName, $functionName, $params)) {
$displayMissingModule = true;
}
} else {
$displayMissingModule = true;
}
}
}
if (!$displayMissingModule && $moduleCheck['result'] && $this->module instanceof eZModule) {
// Run the module/function
eZDebug::addTimingPoint("Module start '" . $this->module->attribute('name') . "'");
$moduleAccessAllowed = true;
$omitPolicyCheck = true;
$runModuleView = true;
$availableViewsInModule = $this->module->attribute('views');
if (!isset($availableViewsInModule[$functionName]) && !$objectHasMovedError && !isset($this->module->Module['function']['script'])) {
$moduleResult = $this->module->handleError(eZError::KERNEL_MODULE_VIEW_NOT_FOUND, 'kernel', array("check" => $moduleCheck));
$runModuleView = false;
$this->siteBasics['policy-check-required'] = false;
$omitPolicyCheck = true;
}
if ($this->siteBasics['policy-check-required']) {
$omitPolicyCheck = false;
$moduleName = $this->module->attribute('name');
if (in_array($moduleName, $this->siteBasics['policy-check-omit-list'])) {
$omitPolicyCheck = true;
} else {
$policyCheckViewMap = $this->getPolicyCheckViewMap($this->siteBasics['policy-check-omit-list']);
if (isset($policyCheckViewMap[$moduleName][$functionName])) {
$omitPolicyCheck = true;
}
}
}
if (!$omitPolicyCheck) {
$currentUser = eZUser::currentUser();
$siteAccessResult = $currentUser->hasAccessTo('user', 'login');
$hasAccessToSite = false;
if ($siteAccessResult['accessWord'] === 'limited') {
$policyChecked = false;
foreach (array_keys($siteAccessResult['policies']) as $key) {
$policy = $siteAccessResult['policies'][$key];
if (isset($policy['SiteAccess'])) {
$policyChecked = true;
$crc32AccessName = eZSys::ezcrc32($this->access['name']);
eZDebugSetting::writeDebug('kernel-siteaccess', $policy['SiteAccess'], $crc32AccessName);
if (in_array($crc32AccessName, $policy['SiteAccess'])) {
$hasAccessToSite = true;
//.........这里部分代码省略.........
示例3: translate
//.........这里部分代码省略.........
while ( !$urlTranslated && $iteration >= 0 )
{
foreach ( $wildcards as $wildcardNum => $wildcard )
{
if ( preg_match( $wildcard, $uriString ) )
{
eZDebugSetting::writeDebug( 'kernel-urltranslator', "matched with: '$wildcard'", __METHOD__ );
// get new $uriString from wildcard
self::translateWithCache( $wildcardNum, $uriString, $wildcardInfo, $wildcard );
eZDebugSetting::writeDebug( 'kernel-urltranslator', "new uri string: '$uriString'", __METHOD__ );
// optimization: don't try further translation if wildcard type is 'forward'
if ( $wildcardInfo['type'] == self::TYPE_FORWARD )
{
$urlTranslated = true;
break;
}
// try to tranlsate
if ( $urlTranslated = eZURLAliasML::translate( $uriString ) )
{
// success
eZDebugSetting::writeDebug( 'kernel-urltranslator', "uri is translated to '$uriString' with result '$urlTranslated'", __METHOD__ );
break;
}
eZDebugSetting::writeDebug( 'kernel-urltranslator', "uri is not translated, trying another wildcard", __METHOD__ );
// translation failed. Try to match new $uriString with another wildcard.
--$iteration;
continue 2;
}
}
// we here if non of the wildcards is matched
break;
}
// check translation result
// NOTE: 'eZURLAliasML::translate'(see above) can return 'true', 'false' or new url(in case of 'error/301').
// $urlTranslated can also be 'false' if no wildcard is matched.
if ( $urlTranslated )
{
// check wildcard type and set appropriate $result and $uriString
$wildcardType = $wildcardInfo['type'];
eZDebugSetting::writeDebug( 'kernel-urltranslator', "wildcard type: $wildcardType", __METHOD__ );
switch ( $wildcardType )
{
case self::TYPE_FORWARD:
{
// do redirect:
// => set $result to translated uri
// => set uri string to a MOVED PERMANENTLY HTTP code
$result = $uriString;
$uriString = 'error/301';
}
break;
default:
{
eZDebug::writeError( 'Invalid wildcard type.', __METHOD__ );
// no break, using eZURLWildcard::TYPE_DIRECT as fallback
}
case self::TYPE_DIRECT:
{
$result = $urlTranslated;
// $uriString already has correct value
break;
}
}
}
else
{
// we are here if:
// - input url is not matched with any wildcard;
// - url is matched with wildcard and:
// - points to module
// - invalide url
eZDebugSetting::writeDebug( 'kernel-urltranslator', "wildcard is not translated", __METHOD__ );
$result = false;
}
// set value back to $uri
if ( $uri instanceof eZURI )
{
$uri->setURIString( $uriString, false );
}
else
{
$uri = $uriString;
}
eZDebugSetting::writeDebug( 'kernel-urltranslator', "finished with url '$uriString' and result '$result'", __METHOD__ );
return $result;
}
示例4: match
//.........这里部分代码省略.........
case 'part':
$hasHostMatch = strpos($host, $matchHost) !== false;
break;
default:
$hasHostMatch = false;
eZDebug::writeError("Unknown host_uri host match: {$matchHostMethod}", "access");
break;
}
if ($hasHostMatch) {
if ($matchURI !== '') {
$matchURIFolders = explode('/', $matchURI);
$uri->increase(count($matchURIFolders));
$uri->dropBase();
$access['uri_part'] = $matchURIFolders;
}
$access['name'] = $matchAccess;
$access['type'] = $type;
return $access;
}
}
}
break;
case 'index':
$type = eZSiteAccess::TYPE_INDEX_FILE;
$match_type = $ini->variable('SiteAccessSettings', 'IndexMatchType');
$match_item = $file;
if ($match_type == 'element') {
$match_index = $ini->variable('SiteAccessSettings', 'IndexMatchElement');
$match_pos = strpos($match_item, '.php');
if ($match_pos !== false) {
$match_item = substr($match_item, 0, $match_pos);
$match_arr = explode('_', $match_item);
$name = $match_arr[$match_index];
}
} else {
if ($match_type == 'text') {
$matcher_pre = $ini->variable('SiteAccessSettings', 'IndexMatchSubtextPre');
$matcher_post = $ini->variable('SiteAccessSettings', 'IndexMatchSubtextPost');
} else {
if ($match_type == 'regexp') {
$matcher = $ini->variable('SiteAccessSettings', 'IndexMatchRegexp');
$match_num = $ini->variable('SiteAccessSettings', 'IndexMatchRegexpItem');
} else {
continue;
}
}
}
break;
default:
eZDebug::writeError("Unknown access match: {$matchprobe}", "access");
break;
}
if ($match_type == 'regexp') {
$name = self::matchRegexp($match_item, $matcher, $match_num);
} else {
if ($match_type == 'text') {
$name = self::matchText($match_item, $matcher_pre, $matcher_post);
}
}
if (isset($name) && $name != '') {
$nameClean = self::washName($name);
if (in_array($nameClean, $siteAccessList)) {
if ($nameClean !== $name) {
if (!$ini->hasVariable('SiteAccessSettings', 'NormalizeSANames') || $ini->variable('SiteAccessSettings', 'NormalizeSANames') == 'enabled') {
$name = $nameClean;
if ($ini->hasVariable('SiteAccessSettings', 'RedirectOnNormalize') && $ini->variable('SiteAccessSettings', 'RedirectOnNormalize') == 'enabled') {
header($_SERVER['SERVER_PROTOCOL'] . " 301 Moved Permanently");
header("Status: 301 Moved Permanently");
$uriSlice = $uri->URIArray;
array_shift($uriSlice);
$newUri = $name . '/' . implode('/', $uriSlice);
$location = eZSys::indexDir() . "/" . eZURI::encodeIRI($newUri);
header("Location: " . $location);
eZExecution::cleanExit();
}
}
}
if ($type == eZSiteAccess::TYPE_URI) {
if ($match_type == 'element') {
$uri->increase($match_index);
$uri->dropBase();
} else {
if ($match_type == 'regexp') {
$uri->setURIString($match_item);
} else {
if ($match_type == 'text') {
$uri->setURIString($match_item);
}
}
}
}
$access['type'] = $type;
$access['name'] = $name;
$access['uri_part'] = $uri_part;
return $access;
}
}
}
return $access;
}