本文整理汇总了PHP中eZURI::element方法的典型用法代码示例。如果您正苦于以下问题:PHP eZURI::element方法的具体用法?PHP eZURI::element怎么用?PHP eZURI::element使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZURI
的用法示例。
在下文中一共展示了eZURI::element方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modify
function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement )
{
$uri = new eZURI( $namedParameters[ 'uri' ] );
$moduleName = $uri->element( 0 );
$moduleList = eZINI::instance( 'module.ini' )->variable( 'ModuleSettings', 'ModuleList' );
if ( in_array( $moduleName, $moduleList, true ) )
$check = eZModule::accessAllowed( $uri );
$operatorValue = isset( $check['result'] ) ? $check['result'] : false;
}
示例2: 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 ) )
//.........这里部分代码省略.........
示例3: urlTranslationEnabledByUri
public static function urlTranslationEnabledByUri(eZURI $uri)
{
if ($uri->isEmpty()) {
return false;
}
$ini = eZINI::instance();
if ($ini->variable('URLTranslator', 'Translation') === 'enabled') {
if ($ini->variable('URLTranslator', 'TranslatableSystemUrls') === 'disabled') {
$moduleName = $uri->element(0);
$moduleINI = eZINI::instance('module.ini');
$moduleList = $moduleINI->variable('ModuleSettings', 'ModuleList');
if (in_array($moduleName, $moduleList, true)) {
return false;
}
}
return true;
}
return false;
}
示例4: accessAllowed
/**
* Checks if access is allowed to a module/view based on site.ini[SiteAccessRules]Rules[] settings
*
* @since 4.4
* @param eZURI $uri
* @return array An associative array with:
* 'result' => bool Indicates if access is allowed
* 'module' => string Module name
* 'view' => string View name
* 'view_checked' => bool Indicates if view access has been checked
*/
public static function accessAllowed(eZURI $uri)
{
$moduleName = $uri->element();
$viewName = $uri->element(1);
$check = array('result' => true, 'module' => $moduleName, 'view' => $viewName, 'view_checked' => false);
$ini = eZINI::instance();
$access = true;
$currentAccess = true;
if (!$ini->hasGroup('SiteAccessRules')) {
return $check;
}
$items = $ini->variableArray('SiteAccessRules', 'Rules');
foreach ($items as $item) {
$name = strtolower($item[0]);
if (isset($item[1])) {
$value = $item[1];
} else {
$value = null;
}
switch ($name) {
case 'access':
$currentAccess = $value == 'enable';
break;
case 'moduleall':
$access = $currentAccess;
break;
case 'module':
if (preg_match("#([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)#", $value, $matches)) {
if ($matches[1] == $moduleName and $matches[2] == $viewName) {
$check['view_checked'] = true;
$access = $currentAccess;
}
} else {
if ($value == $moduleName) {
$access = $currentAccess;
$check['view_checked'] = false;
}
}
break;
default:
eZDebug::writeError("Unknown access rule: {$name}={$value}", 'Access');
break;
}
}
$check['result'] = $access;
return $check;
}
示例5: array
$errorRerunURL = $errorINI->variable( 'ErrorSettings', 'DefaultRerunURL' );
if ( isset( $rerunURLList[$errorNumber] ) )
$errorRerunURL = $rerunURLList[$errorNumber];
$Result = array();
$Result['content'] = false;
$Result['rerun_uri'] = $errorRerunURL;
$module->setExitStatus( eZModule::STATUS_RERUN );
return $Result;
}
else if ( $errorHandlerType == 'embed' )
{
$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'];
}
示例6: 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();
//.........这里部分代码省略.........
示例7: 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;
}