本文整理汇总了PHP中eZSiteAccess::current方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSiteAccess::current方法的具体用法?PHP eZSiteAccess::current怎么用?PHP eZSiteAccess::current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSiteAccess
的用法示例。
在下文中一共展示了eZSiteAccess::current方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Executes multivatriate test secnarios
*
* @param int $nodeID
* @return int
*/
public function execute($nodeID)
{
$currentSiteAccess = eZSiteAccess::current();
$testScenario = ezpMultivariateTestScenario::fetchEnabledByNodeID($nodeID);
if ($testScenario instanceof ezpMultivariateTestScenario && in_array($currentSiteAccess['name'], eZINI::instance('content.ini')->variable('TestingSettings', 'EnabledForSiteAccessList'))) {
$node = $testScenario->getRandomNode();
if ($node instanceof eZContentObjectTreeNode) {
$nodeID = $node->attribute('node_id');
}
}
return $nodeID;
}
示例2: redirect
/**
* Handles redirection to the mobile optimized interface
*
*/
public function redirect()
{
$http = eZHTTPTool::instance();
$currentSiteAccess = eZSiteAccess::current();
if ($http->hasGetVariable('notmobile')) {
setcookie('eZMobileDeviceDetect', 1, time() + (int) eZINI::instance()->variable('SiteAccessSettings', 'MobileDeviceDetectCookieTimeout'), '/');
$http->redirect(eZSys::indexDir());
eZExecution::cleanExit();
}
if (!isset($_COOKIE['eZMobileDeviceDetect']) && !in_array($currentSiteAccess['name'], eZINI::instance()->variable('SiteAccessSettings', 'MobileSiteAccessList'))) {
$http->redirect(eZINI::instance()->variable('SiteAccessSettings', 'MobileSiteAccessURL'));
eZExecution::cleanExit();
}
}
示例3: requestInit
protected function requestInit()
{
if ($this->isInitialized) {
return;
}
eZExecution::setCleanExit(false);
$scriptStartTime = microtime(true);
$GLOBALS['eZRedirection'] = false;
$this->access = eZSiteAccess::current();
eZDebug::setScriptStart($scriptStartTime);
eZDebug::addTimingPoint("Script start");
$this->uri = eZURI::instance(eZSys::requestURI());
$GLOBALS['eZRequestedURI'] = $this->uri;
// Be able to do general events early in process
ezpEvent::getInstance()->notify('request/preinput', array($this->uri));
// Initialize module loading
$this->siteBasics['module-repositories'] = eZModule::activeModuleRepositories();
eZModule::setGlobalPathList($this->siteBasics['module-repositories']);
// make sure we get a new $ini instance now that it has been reset
$ini = eZINI::instance();
// start: eZCheckValidity
// pre check, setup wizard related so needs to be before session/db init
// TODO: Move validity check in the constructor? Setup is not meant to be launched at each (sub)request is it?
if ($ini->variable('SiteAccessSettings', 'CheckValidity') === 'true') {
$this->check = array('module' => 'setup', 'function' => 'init');
// Turn off some features that won't bee needed yet
$this->siteBasics['policy-check-omit-list'][] = 'setup';
$this->siteBasics['show-page-layout'] = $ini->variable('SetupSettings', 'PageLayout');
$this->siteBasics['validity-check-required'] = true;
$this->siteBasics['session-required'] = $this->siteBasics['user-object-required'] = false;
$this->siteBasics['db-required'] = $this->siteBasics['no-cache-adviced'] = $this->siteBasics['url-translator-allowed'] = false;
$this->siteBasics['site-design-override'] = $ini->variable('SetupSettings', 'OverrideSiteDesign');
$this->access = eZSiteAccess::change(array('name' => 'setup', 'type' => eZSiteAccess::TYPE_URI));
eZTranslatorManager::enableDynamicTranslations();
}
// stop: eZCheckValidity
if ($this->siteBasics['session-required']) {
// Check if this should be run in a cronjob
if ($ini->variable('Session', 'BasketCleanup') !== 'cronjob') {
eZSession::addCallback('destroy_pre', function (eZDBInterface $db, $key, $escapedKey) {
$basket = eZBasket::fetch($key);
if ($basket instanceof eZBasket) {
$basket->remove();
}
});
eZSession::addCallback('gc_pre', function (eZDBInterface $db, $time) {
eZBasket::cleanupExpired($time);
});
eZSession::addCallback('cleanup_pre', function (eZDBInterface $db) {
eZBasket::cleanup();
});
}
// addCallBack to update session id for shop basket on session regenerate
eZSession::addCallback('regenerate_post', function (eZDBInterface $db, $escNewKey, $escOldKey) {
$db->query("UPDATE ezbasket SET session_id='{$escNewKey}' WHERE session_id='{$escOldKey}'");
});
// TODO: Session starting should be made only once in the constructor
$this->sessionInit();
}
// if $this->siteBasics['db-required'], open a db connection and check that db is connected
if ($this->siteBasics['db-required'] && !eZDB::instance()->isConnected()) {
$this->warningList[] = array('error' => array('type' => 'kernel', 'number' => eZError::KERNEL_NO_DB_CONNECTION), 'text' => 'No database connection could be made, the system might not behave properly.');
}
// eZCheckUser: pre check, RequireUserLogin & FORCE_LOGIN related so needs to be after session init
if (!isset($this->check)) {
$this->check = eZUserLoginHandler::preCheck($this->siteBasics, $this->uri);
}
ezpEvent::getInstance()->notify('request/input', array($this->uri));
// Initialize with locale settings
// TODO: Move to constructor? Is it relevant to init the locale/charset for each (sub)requests?
$this->languageCode = eZLocale::instance()->httpLocaleCode();
$phpLocale = trim($ini->variable('RegionalSettings', 'SystemLocale'));
if ($phpLocale != '') {
setlocale(LC_ALL, explode(',', $phpLocale));
}
$this->httpCharset = eZTextCodec::httpCharset();
// TODO: are these parameters supposed to vary across potential sub-requests?
$this->site = array('title' => $ini->variable('SiteSettings', 'SiteName'), 'design' => $ini->variable('DesignSettings', 'SiteDesign'), 'http_equiv' => array('Content-Type' => 'text/html; charset=' . $this->httpCharset, 'Content-language' => $this->languageCode));
// Read role settings
$this->siteBasics['policy-check-omit-list'] = array_merge($this->siteBasics['policy-check-omit-list'], $ini->variable('RoleSettings', 'PolicyOmitList'));
$this->isInitialized = true;
}
示例4: redirect
/**
* Handles redirection to the mobile optimized interface
*
*/
public function redirect()
{
$http = eZHTTPTool::instance();
$currentSiteAccess = eZSiteAccess::current();
if ($http->hasGetVariable('notmobile')) {
setcookie('eZMobileDeviceDetect', 1, time() + (int) eZINI::instance()->variable('SiteAccessSettings', 'MobileDeviceDetectCookieTimeout'), '/');
$http->redirect(eZSys::indexDir());
eZExecution::cleanExit();
}
if (!isset($_COOKIE['eZMobileDeviceDetect']) && !in_array($currentSiteAccess['name'], eZINI::instance()->variable('SiteAccessSettings', 'MobileSiteAccessList'))) {
$currentUrl = eZSys::serverURL() . eZSys::requestURI();
$redirectUrl = eZINI::instance()->variable('SiteAccessSettings', 'MobileSiteAccessURL');
// Do not redirect if already on the redirect url
if (strpos($currentUrl, $redirectUrl) !== 0) {
// Default siteaccess name needs to be removed from the uri when redirecting
$uri = explode('/', ltrim(eZSys::requestURI(), '/'));
if (array_shift($uri) == $currentSiteAccess['name']) {
$http->redirect($redirectUrl . '/' . implode('/', $uri));
} else {
$http->redirect($redirectUrl . eZSys::requestURI());
}
}
eZExecution::cleanExit();
}
}
示例5: filter
public static function filter($module, $node, $tpl, $viewMode)
{
//Make it compatable with patches before 5.2 and 5.2(no patch) because a patch reverse
//Ref.https://github.com/ezsystems/ezpublish-legacy/commit/85ab7fb8374f31c5cba00450e71d27e456552878
if (!$module instanceof eZModule) {
$viewMode = $tpl;
$tpl = $node;
$node = $module;
$module = null;
}
//End of compatability fix
$ini = eZINI::instance('override.ini');
$conditions = $ini->groups();
$nodeID = $node->attribute('node_id');
$object = $node->attribute('object');
$classIdentifier = $object->attribute('class_identifier');
$overrideClass = null;
foreach ($conditions as $condition) {
if (isset($condition['Match'])) {
$matches = $condition['Match'];
// node condition
$matchNode = null;
if (isset($matches['node'])) {
if ($matches['node'] == $nodeID) {
$matchNode = true;
} else {
$matchNode = false;
}
}
// class_identifier condition
$matchClass = null;
if (isset($matches['class_identifier'])) {
if ($matches['class_identifier'] == $classIdentifier) {
$matchClass = true;
} else {
$matchClass = false;
}
}
// view mode condition
$matchViewmode = null;
if (isset($matches['viewmode'])) {
if ($matches['viewmode'] == $viewMode) {
$matchViewmode = true;
} else {
$matchViewmode = false;
}
}
$useIt = false;
// When viewmode is not set or viewmode matches
if (!isset($matchViewmode) || $matchViewmode === true) {
// When class_identifier is not set or class_identifier matches
if (!isset($matchClass) || $matchClass === true) {
// When node(id) is not set or node(id) matches
if (!isset($matchNode) || $matchNode === true) {
if (isset($condition['Class'])) {
$overrideClass = $condition['Class'];
break;
}
}
}
}
}
}
//Support Match[attribute_<attribute_identifier>]=<value> in override.ini
$object = $node->attribute('object');
$dataMap = $object->dataMap();
$ini = eZINI::instance('xoverride.ini');
$siteAccessesMatch = false;
if (!$ini->hasVariable('TemplateOverride', 'AvailableSiteAccess')) {
$siteAccessesMatch = true;
} else {
$siteAccesses = $ini->variable('TemplateOverride', 'AvailableSiteAccess');
$currentSiteAccessArray = eZSiteAccess::current();
$currentSiteAccess = $currentSiteAccessArray['name'];
if (is_array($siteAccesses) && (in_array($currentSiteAccess, $siteAccesses) or in_array('*', $siteAccesses))) {
$siteAccessesMatch = true;
}
}
if ($siteAccessesMatch) {
$supportedDatatype = $ini->variable('General', 'SupportedDatatype');
$keys = array();
foreach ($dataMap as $attributeId => $attribute) {
$dataType = $attribute->attribute('data_type_string');
if (in_array($dataType, $supportedDatatype)) {
$value = $attribute->attribute('content');
$keys[] = array('attribute_' . $attributeId, $value);
}
}
$res = eZTemplateDesignResource::instance();
$res->setKeys($keys);
if (!empty($overrideClass)) {
$overrideView = new $overrideClass();
$http = eZHTTPTool::instance();
eZDebug::writeNotice("Loading nodeview render {$overrideClass}, node id: {$nodeID}", __METHOD__);
$overrideView->initNodeview($module, $node, $tpl, $viewMode);
}
}
}
示例6: time
// This should be looked as a temporary fix as ideally all cache-blocks
// should be disabled by this view.
$cacheKey = 'styleeditorvisual-' + time();
$nodeResult['title_path'] = array(array('text' => 'Visual'), array('text' => $node->attribute('name')));
$httpCharset = eZTextCodec::httpCharset();
$locale = eZLocale::instance();
$languageCode = $locale->httpLocaleCode();
$title = $ini->variable('SiteSettings', 'SiteName');
$uri = eZURI::instance();
$GLOBALS['eZRequestedURI'] = $uri;
$site = array('title' => $title, 'uri' => $uri, 'design' => $ini->variable('DesignSettings', 'SiteDesign'), 'http_equiv' => array('Content-Type' => 'text/html; charset=' . $httpCharset, 'Content-language' => $languageCode));
$currentUser = eZUser::currentUser();
$tpl->setVariable('current_user', $currentUser);
$tpl->setVariable('ui_context', '');
$lastAccessURI = '/';
if ($http->hasSessionVariable('LastAccessesURI')) {
$lastAccessURI = $http->sessionVariable('LastAccessesURI');
}
$tpl->setVariable('last_access_uri', $lastAccessURI);
$tpl->setVariable('access_type', eZSiteAccess::current());
$tpl->setVariable('uri_string', $uri->uriString());
$tpl->setVariable('site', $site);
$tpl->setVariable('extra_cache_key', $cacheKey);
$tpl->setVariable('module_result', $nodeResult);
$tpl->setVariable('node', $node);
$tpl->setVariable('display_styleeditor_visualtoolbar', true);
$pagelayoutResult = $tpl->fetch('design:pagelayout.tpl');
eZDisplayResult($pagelayoutResult);
// Stop execution at this point, if we do not we'll have the
// pagelayout.tpl inside another pagelayout.tpl.
eZExecution::cleanExit();
示例7: isNodeInCurrentSiteaccess
private function isNodeInCurrentSiteaccess($node)
{
if (!$node instanceof eZContentObjectTreeNode) {
return true;
}
$currentSiteaccess = eZSiteAccess::current();
$pathPrefixExclude = eZINI::instance()->variable('SiteAccessSettings', 'PathPrefixExclude');
$aliasArray = explode('/', $node->attribute('url_alias'));
//eZDebug::writeError( var_export($aliasArray,1), __METHOD__ );
//eZDebug::writeError( $pathPrefixExclude, __METHOD__ );
foreach ($pathPrefixExclude as $ppe) {
if (strtolower($aliasArray[0]) == $ppe) {
return true;
}
}
$pathArray = $node->attribute('path_array');
$contentIni = eZINI::instance('content.ini');
$rootNodeArray = array('RootNode', 'UserRootNode', 'MediaRootNode');
foreach ($rootNodeArray as $rootNodeID) {
$rootNode = $contentIni->variable('NodeSettings', $rootNodeID);
if (in_array($rootNode, $pathArray)) {
return true;
}
}
eZDebug::writeError('Il nodo ' . $node->attribute('name') . ' non si trova nel Siteaccess ' . $currentSiteaccess, __METHOD__);
return false;
}
示例8: array
$cli = eZCLI::instance();
$script = eZScript::instance( array(
'description' => 'Create JSON configuration and fill SEO data for the given siteaccess',
'use-session' => false,
'use-modules' => true,
'use-extensions' => true
));
$script->startup();
$script->getOptions();
$script->initialize();
$date = new DateTime();
$cli->output($date->format("Y-m-d H:i:s").' - BEGIN');
// Get cluster identifier
$siteAccess = eZSiteAccess::current();
$clusterMapping = ClusterTool::getMappingSiteAccess($siteAccess);
if(!$clusterMapping)
{
$cli->output('Cannot find the cluster identifier for site access "'.$siteAccess['name'].'"');
$date = new DateTime();
$cli->output($date->format("Y-m-d H:i:s")." - END");
$script->shutdown(1);
}
$clusterIdentifier = key($clusterMapping);
// Get JSON config
if ( !SolrSafeOperatorHelper::featureIsActive('Seo') )
{
$script->shutdown(0);
}