本文整理汇总了PHP中eZURI::elements方法的典型用法代码示例。如果您正苦于以下问题:PHP eZURI::elements方法的具体用法?PHP eZURI::elements怎么用?PHP eZURI::elements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZURI
的用法示例。
在下文中一共展示了eZURI::elements方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Execution point for controller actions.
* Returns false if not supported
*
* @return ezpKernelResult
*/
public function run()
{
$db = eZDB::instance();
if ($db->isConnected()) {
$this->sessionInit();
} else {
return $this->exitWithInternalError(ezpI18n::tr('kernel/content/treemenu', 'Database is not connected'));
}
$moduleINI = eZINI::instance('module.ini');
$globalModuleRepositories = $moduleINI->variable('ModuleSettings', 'ModuleRepositories');
eZModule::setGlobalPathList($globalModuleRepositories);
$module = eZModule::exists('content');
if (!$module) {
return $this->exitWithInternalError(ezpI18n::tr('kernel/content/treemenu', '"content" module could not be found.'));
}
$function_name = 'treemenu';
$this->uri->increase();
$this->uri->increase();
$currentUser = eZUser::currentUser();
$siteAccessResult = $currentUser->hasAccessTo('user', 'login');
$hasAccessToSite = false;
if ($siteAccessResult['accessWord'] == 'limited') {
$policyChecked = false;
foreach ($siteAccessResult['policies'] as $policy) {
if (isset($policy['SiteAccess'])) {
$policyChecked = true;
$crc32AccessName = eZSys::ezcrc32($this->access['name']);
if (in_array($crc32AccessName, $policy['SiteAccess'])) {
$hasAccessToSite = true;
break;
}
}
if ($hasAccessToSite) {
break;
}
}
if (!$policyChecked) {
$hasAccessToSite = true;
}
} else {
if ($siteAccessResult['accessWord'] == 'yes') {
$hasAccessToSite = true;
}
}
if (!$hasAccessToSite) {
return $this->exitWithInternalError(ezpI18n::tr('kernel/content/treemenu', 'Insufficient permissions to display the treemenu.'), 403);
}
$GLOBALS['eZRequestedModule'] = $module;
$content = $module->run($function_name, $this->uri->elements(false), false, array('use-cache-headers' => $this->settings['use-cache-headers']));
$attributes = isset($content['lastModified']) ? array('lastModified' => $content['lastModified']) : array();
$this->shutdown();
return new ezpKernelResult($content['content'], $attributes);
}
示例2: match
//.........这里部分代码省略.........
{
$type = eZSiteAccess::TYPE_URI;
$match_type = $ini->variable( 'SiteAccessSettings', 'URIMatchType' );
if ( $match_type == 'map' )
{
if ( $ini->hasVariable( 'SiteAccessSettings', 'URIMatchMapItems' ) )
{
$match_item = $uri->element( 0 );
$matchMapItems = $ini->variableArray( 'SiteAccessSettings', 'URIMatchMapItems' );
foreach ( $matchMapItems as $matchMapItem )
{
$matchMapURI = $matchMapItem[0];
$matchMapAccess = $matchMapItem[1];
if ( $access['name'] == $matchMapAccess and in_array( $matchMapAccess, $siteAccessList ) )
{
$uri_part = array( $matchMapURI );
}
if ( $matchMapURI == $match_item and in_array( $matchMapAccess, $siteAccessList ) )
{
$uri->increase( 1 );
$uri->dropBase();
$access['name'] = $matchMapAccess;
$access['type'] = $type;
$access['uri_part'] = array( $matchMapURI );
return $access;
}
}
}
}
else if ( $match_type == 'element' )
{
$match_index = $ini->variable( 'SiteAccessSettings', 'URIMatchElement' );
$elements = $uri->elements( false );
$elements = array_slice( $elements, 0, $match_index );
$name = implode( '_', $elements );
$uri_part = $elements;
}
else if ( $match_type == 'text' )
{
$match_item = $uri->elements();
$matcher_pre = $ini->variable( 'SiteAccessSettings', 'URIMatchSubtextPre' );
$matcher_post = $ini->variable( 'SiteAccessSettings', 'URIMatchSubtextPost' );
}
else if ( $match_type == 'regexp' )
{
$match_item = $uri->elements();
$matcher = $ini->variable( 'SiteAccessSettings', 'URIMatchRegexp' );
$match_num = $ini->variable( 'SiteAccessSettings', 'URIMatchRegexpItem' );
}
else
continue;
} break;
case 'host':
{
$type = eZSiteAccess::TYPE_HTTP_HOST;
$match_type = $ini->variable( 'SiteAccessSettings', 'HostMatchType' );
$match_item = $host;
if ( $match_type == 'map' )
{
if ( $ini->hasVariable( 'SiteAccessSettings', 'HostMatchMapItems' ) )
{
$matchMapItems = $ini->variableArray( 'SiteAccessSettings', 'HostMatchMapItems' );
foreach ( $matchMapItems as $matchMapItem )
{
$matchMapHost = $matchMapItem[0];
示例3: translate
/**
* Transforms the URI if there exists an alias for it.
*
* @param eZURI|string $uri
* @return mixed The translated URI if the resource has moved, or true|false
* if translation was (un)successful
*/
public static function translate( &$uri )
{
$result = false;
// get uri string
$uriString = ( $uri instanceof eZURI ) ? $uri->elements() : $uri;
$uriString = eZURLAliasML::cleanURL( $uriString );
eZDebugSetting::writeDebug( 'kernel-urltranslator', "input uriString: '$uriString'", __METHOD__ );
if ( !$wildcards = self::wildcardsIndex() )
{
eZDebugSetting::writeDebug( 'kernel-urltranslator', "no match callbacks", __METHOD__ );
return false;
}
$ini = eZINI::instance();
$iteration = $ini->variable( 'URLTranslator', 'MaximumWildcardIterations' );
eZDebugSetting::writeDebug( 'kernel-urltranslator', "MaximumWildcardIterations: '$iteration'", __METHOD__ );
// translate
$urlTranslated = false;
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;
//.........这里部分代码省略.........
示例4: eZURI
$errorEmbedURL = $errorINI->variable( 'ErrorSettings', 'DefaultEmbedURL' );
if ( isset( $embedURLList[$errorNumber] ) )
$errorEmbedURL = $embedURLList[$errorNumber];
$uri = new eZURI( $errorEmbedURL );
$moduleName = $uri->element();
$embedModule = eZModule::exists( $moduleName );
if ( $module instanceof eZModule )
{
$uri->increase();
$viewName = false;
if ( !$embedModule->singleFunction() )
{
$viewName = $uri->element();
$uri->increase();
}
$embedParameters = $uri->elements( false );
$embedResult = $embedModule->run( $viewName, $embedParameters );
$embedContent = $embedResult['content'];
}
// write reason to debug
// $accessMessage = print_r($Params['ExtraParameters']['AccessList']['FunctionRequired'], true);
// Function required
if ( isset( $Params['ExtraParameters']['AccessList'] ) )
{
$accessMessage = "Function required:\n";
if ( is_array( $Params['ExtraParameters']['AccessList']['FunctionRequired'] ) )
{
foreach ( array_keys ( $Params['ExtraParameters']['AccessList']['FunctionRequired'] ) as $key )
{
$accessMessage .= " $key : " . $Params['ExtraParameters']['AccessList']['FunctionRequired'][$key] . "\n" ;
示例5: match
/**
* Goes trough the access matching rules and returns the access match.
* The returned match is an associative array with:
* name => string Name of the siteaccess (same as folder name)
* type => int The constant that represent the matching used
* uri_part => array(string) List of path elements that was used in start of url for the match
*
* @since 4.4
* @param eZURI $uri
* @param string $host
* @param string(numeric) $port
* @param string $file Example '/index.php'
* @return array
*/
public static function match(eZURI $uri, $host, $port = 80, $file = '/index.php')
{
eZDebugSetting::writeDebug('kernel-siteaccess', array('uri' => $uri, 'host' => $host, 'port' => $port, 'file' => $file), __METHOD__);
$ini = eZINI::instance();
if ($ini->hasVariable('SiteAccessSettings', 'StaticMatch')) {
$match = $ini->variable('SiteAccessSettings', 'StaticMatch');
if ($match != '') {
$access = array('name' => $match, 'type' => eZSiteAccess::TYPE_STATIC, 'uri_part' => array());
return $access;
}
}
list($siteAccessList, $order) = $ini->variableMulti('SiteAccessSettings', array('AvailableSiteAccessList', 'MatchOrder'));
$access = array('name' => $ini->variable('SiteSettings', 'DefaultAccess'), 'type' => eZSiteAccess::TYPE_DEFAULT, 'uri_part' => array());
if ($order == 'none') {
return $access;
}
$order = $ini->variableArray('SiteAccessSettings', 'MatchOrder');
// Change the default type to eZSiteAccess::TYPE_URI if we're using URI MatchOrder.
// This is to keep backward compatiblity with the ezurl operator. ezurl has since
// rev 4949 added default siteaccess to generated URLs, even when there is
// no siteaccess in the current URL.
if (in_array('uri', $order)) {
$access['type'] = eZSiteAccess::TYPE_URI;
}
foreach ($order as $matchprobe) {
$name = '';
$type = '';
$match_type = '';
$uri_part = array();
switch ($matchprobe) {
case 'servervar':
if ($serversiteaccess = eZSys::serverVariable($ini->variable('SiteAccessSettings', 'ServerVariableName'), true)) {
$access['name'] = $serversiteaccess;
$access['type'] = eZSiteAccess::TYPE_SERVER_VAR;
return $access;
} else {
continue;
}
break;
case 'port':
if ($ini->hasVariable('PortAccessSettings', $port)) {
$access['name'] = $ini->variable('PortAccessSettings', $port);
$access['type'] = eZSiteAccess::TYPE_PORT;
return $access;
} else {
continue;
}
break;
case 'uri':
$type = eZSiteAccess::TYPE_URI;
$match_type = $ini->variable('SiteAccessSettings', 'URIMatchType');
if ($match_type == 'map') {
if ($ini->hasVariable('SiteAccessSettings', 'URIMatchMapItems')) {
$match_item = $uri->element(0);
$matchMapItems = $ini->variableArray('SiteAccessSettings', 'URIMatchMapItems');
foreach ($matchMapItems as $matchMapItem) {
$matchMapURI = $matchMapItem[0];
$matchMapAccess = $matchMapItem[1];
if ($access['name'] == $matchMapAccess and in_array($matchMapAccess, $siteAccessList)) {
$uri_part = array($matchMapURI);
}
if ($matchMapURI == $match_item and in_array($matchMapAccess, $siteAccessList)) {
$uri->increase(1);
$uri->dropBase();
$access['name'] = $matchMapAccess;
$access['type'] = $type;
$access['uri_part'] = array($matchMapURI);
return $access;
}
}
}
} else {
if ($match_type == 'element') {
$match_index = $ini->variable('SiteAccessSettings', 'URIMatchElement');
$elements = $uri->elements(false);
$elements = array_slice($elements, 0, $match_index);
$name = implode('_', $elements);
$uri_part = $elements;
} else {
if ($match_type == 'text') {
$match_item = $uri->elements();
$matcher_pre = $ini->variable('SiteAccessSettings', 'URIMatchSubtextPre');
$matcher_post = $ini->variable('SiteAccessSettings', 'URIMatchSubtextPost');
} else {
if ($match_type == 'regexp') {
$match_item = $uri->elements();
//.........这里部分代码省略.........
示例6: fetchModule
/**
* @deprecated Since 5.0
* @param \eZURI $uri
* @param null|array $check
* @param null|\eZModule $module ByRef, will be set to a eZModule instace based on $moduleName
* @param string $moduleName
* @param string $functionName
* @param array $params
* @return bool
*/
function fetchModule(eZURI $uri, $check, &$module, &$moduleName, &$functionName, &$params)
{
$moduleName = $uri->element();
if ($check !== null && isset($check["module"])) {
$moduleName = $check["module"];
}
// Try to fetch the module object
$module = eZModule::exists($moduleName);
if (!$module instanceof eZModule) {
return false;
}
$uri->increase();
$functionName = "";
if (!$module->singleFunction()) {
$functionName = $uri->element();
$uri->increase();
}
// Override it if required
if ($check !== null && isset($check["function"])) {
$functionName = $check["function"];
}
$params = $uri->elements(false);
return true;
}