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; } }
public static function changeAccess(array $access) { eZSiteAccess::load($access); unset($GLOBALS['eZContentObjectDefaultLanguage']); eZContentLanguage::expireCache(); eZContentObject::clearCache(); }
/** * Get instance siteaccess specific site.ini * * @param string $sa * @return void */ protected function getSiteAccessIni() { if ($this->destinationSiteAccessIni === null) { $this->destinationSiteAccessIni = eZSiteAccess::getIni($this->destinationSiteAccess, 'site.ini'); } return $this->destinationSiteAccessIni; }
/** * Checks if the installation is valid and returns a module redirect if required. * If CheckValidity in SiteAccessSettings is false then no check is done. * * @deprecated As of 4.4, moved to index.php for now * @param array $siteBasics * @param eZURI $uri */ function eZCheckValidity( array &$siteBasics, eZURI $uri ) { eZDebug::writeStrict( 'Function eZCheckValidity() has been deprecated in 4.4', 'Deprecation' ); $ini = eZINI::instance(); $checkValidity = ( $ini->variable( "SiteAccessSettings", "CheckValidity" ) == "true" ); $check = null; if ( $checkValidity ) { $check = array( "module" => "setup", 'function' => 'init' ); // Turn off some features that won't bee needed yet // $siteBasics['policy-check-required'] = false; $siteBasics['policy-check-omit-list'][] = 'setup'; $siteBasics['url-translator-allowed'] = false; $siteBasics['show-page-layout'] = $ini->variable( 'SetupSettings', 'PageLayout' ); $siteBasics['validity-check-required'] = true; $siteBasics['user-object-required'] = false; $siteBasics['session-required'] = false; $siteBasics['db-required'] = false; $siteBasics['no-cache-adviced'] = false; $siteBasics['site-design-override'] = $ini->variable( 'SetupSettings', 'OverrideSiteDesign' ); $access = array( 'name' => 'setup', 'type' => eZSiteAccess::TYPE_URI ); $access = eZSiteAccess::change( $access ); eZTranslatorManager::enableDynamicTranslations(); } return $check; }
/** * Test findPathToSiteAccess */ public function testFindPathToSiteAccess() { $ini = eZINI::instance(); $siteAccessList = $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'); $ini->setVariable('SiteAccessSettings', 'AvailableSiteAccessList', array('eng')); $path = eZSiteAccess::findPathToSiteAccess('plain'); self::assertFalse($path); $ini->setVariable('SiteAccessSettings', 'AvailableSiteAccessList', array('plain')); $path = eZSiteAccess::findPathToSiteAccess('plain'); self::assertEquals('settings/siteaccess/plain', $path); $ini->setVariable('SiteAccessSettings', 'AvailableSiteAccessList', $siteAccessList); }
/** * 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; }
public function __construct(array $settings = array()) { $this->settings = $settings + array('use-cache-headers' => true, 'max-age' => 86400, 'siteaccess' => null, 'use-exceptions' => false); unset($settings); require_once __DIR__ . '/treemenu_functions.php'; $this->setUseExceptions($this->settings['use-exceptions']); header('X-Powered-By: ' . eZPublishSDK::EDITION . ' (index_treemenu)'); if ($this->settings['use-cache-headers'] === true) { define('MAX_AGE', $this->settings['max-age']); if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + MAX_AGE) . ' GMT'); header('Cache-Control: max-age=' . MAX_AGE); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) . ' GMT'); header('Pragma: '); exit; } } // Tweaks ini filetime checks if not defined! // This makes ini system not check modified time so // that index_treemenu.php can assume that index.php does // this regular enough, set in config.php to override. if (!defined('EZP_INI_FILEMTIME_CHECK')) { define('EZP_INI_FILEMTIME_CHECK', false); } eZExecution::addFatalErrorHandler(function () { header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error'); }); eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP); // Trick to get eZSys working with a script other than index.php (while index.php still used in generated URLs): $_SERVER['SCRIPT_FILENAME'] = str_replace('/index_treemenu.php', '/index.php', $_SERVER['SCRIPT_FILENAME']); $_SERVER['PHP_SELF'] = str_replace('/index_treemenu.php', '/index.php', $_SERVER['PHP_SELF']); $ini = eZINI::instance(); $timezone = $ini->variable('TimeZoneSettings', 'TimeZone'); if ($timezone) { putenv("TZ={$timezone}"); } // init uri code $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable('REQUEST_URI'); eZSys::init('index.php', $ini->variable('SiteAccessSettings', 'ForceVirtualHost') === 'true'); $this->uri = eZURI::instance(eZSys::requestURI()); $GLOBALS['eZRequestedURI'] = $this->uri; // Check for extension eZExtension::activateExtensions('default'); // load siteaccess // Use injected siteaccess if available or match it internally. $this->access = isset($this->settings['siteaccess']) ? $this->settings['siteaccess'] : eZSiteAccess::match($this->uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile()); eZSiteAccess::change($this->access); // Check for new extension loaded by siteaccess eZExtension::activateExtensions('access'); }
/** * Test for eZContentObject::versions(), fetching all of them * @dataProvider providerForTestMatchHostUri */ public function testMatchHostUri( $uri, $name, $type, $uriPart ) { $this->assertEquals( array( "name" => $name, "type" => $type, "uri_part" => $uriPart, ), eZSiteAccess::match( new eZURI( $uri ), "www.example.com" ) ); }
/** * 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(); } }
public function getSettings() { // Copied from settings/view $rootDir = 'settings'; $iniFiles = eZDir::recursiveFindRelative($rootDir, '', '.ini'); // find all .ini files in active extensions // Note: is this the same algorithm used by ezini? mmm... foreach (eZINI::globalOverrideDirs() as $iniDataSet) { $iniPath = $iniDataSet[1] ? $iniDataSet[0] : 'settings/' . $iniDataSet[0]; $iniFiles = array_merge($iniFiles, eZDir::recursiveFindRelative($iniPath, '', '.ini')); $iniFiles = array_merge($iniFiles, eZDir::recursiveFindRelative($iniPath, '', '.ini.append.php')); } // extract all .ini files without path $iniFiles = preg_replace('%.*/%', '', $iniFiles); // remove *.ini[.append.php] from file name $iniFiles = preg_replace('%\\.ini.*%', '.ini', $iniFiles); $iniFiles = array_unique($iniFiles); sort($iniFiles); $siteIni = null; foreach ($iniFiles as $key => $ini) { if ($this->currentSiteAccess != '' && $GLOBALS['eZCurrentAccess']['name'] !== $this->currentSiteAccess) { // create a site ini instance using $useLocalOverrides if ($siteIni === null) { $siteIni = eZSiteAccess::getIni($this->currentSiteAccess, 'site.ini'); } // load settings file with $useLocalOverrides = true $iniFile = new eZINI($ini, 'settings', null, false, true, false, false, false); $iniFile->setOverrideDirs($siteIni->overrideDirs(false)); $iniFile->load(); } else { $iniFile = new eZINI($ini); } $iniFiles[$ini] = $iniFile->groups(); unset($iniFiles[$key]); } return $iniFiles; }
/** * Parses command line arguments and kicks off the processing if required * arguments are passed. */ public function process() { try { $this->input->process(); } catch ( ezcConsoleOptionException $e ) { if ( $this->helpOption->value === true ) { $this->cliHelp(); return; } echo $e->getMessage() . "\n"; return; } if ( $this->helpOption->value === true ) { $this->cliHelp(); return; } if ( $this->siteAccessOption->value ) { $access = array( 'name' => $this->siteAccessOption->value, 'type' => eZSiteAccess::TYPE_STATIC ); eZSiteAccess::change( $access ); } $this->_process( $this->dryRunOption->value, $this->subtreeNodeOption->value, $this->actionOption->value ); }
// The file settings/override/site.ini.append.php is updated like this: // - take the existing list of extensions from site.ini.append.php (to preserve their order) // - remove from the list the extensions that the user unchecked in the admin interface // - add to the list the extensions checked by the user in the admin interface, but to the end of the list $intersection = array_intersect( $selectedExtensions, $selectedExtensionArray ); $difference = array_diff( $selectedExtensionArray, $selectedExtensions ); $toSave = array_merge( $intersection, $difference ); $toSave = array_unique( $toSave ); // open settings/override/site.ini.append[.php] for writing $writeSiteINI = eZINI::instance( 'site.ini.append', 'settings/override', null, null, false, true ); $writeSiteINI->setVariable( "ExtensionSettings", "ActiveExtensions", $toSave ); $writeSiteINI->save( 'site.ini.append', '.php', false, false ); eZCache::clearByTag( 'ini' ); eZSiteAccess::reInitialise(); $ini = eZINI::instance( 'module.ini' ); $currentModules = $ini->variable( 'ModuleSettings', 'ModuleList' ); if ( $currentModules != $oldModules ) { // ensure that evaluated policy wildcards in the user info cache // will be up to date with the currently activated modules eZCache::clearByID( 'user_info_cache' ); } updateAutoload( $tpl ); } // open site.ini for reading (need to do it again to take into account the changes made to site.ini after clicking "Apply changes" button above $siteINI = eZINI::instance();
/** * Creates an array of corresponding language switcher links and logical names. * * This mapping is set up in site.ini.[RegionalSettings].TranslationSA. * The purpose of this method is to assist creation of language switcher * links into the available translation siteaccesses on the system. * * This is used by the language_switcher template operator. * * @param string $url * @return void */ public static function setupTranslationSAList($url = null) { $ini = eZINI::instance(); if (!$ini->hasVariable('RegionalSettings', 'TranslationSA')) { return array(); } $ret = array(); $translationSiteAccesses = $ini->variable('RegionalSettings', 'TranslationSA'); foreach ($translationSiteAccesses as $siteAccessName => $translationName) { $switchLanguageLink = "/switchlanguage/to/{$siteAccessName}/"; if ($url !== null && (is_string($url) || is_numeric($url))) { $switchLanguageLink .= $url; } $ret[$siteAccessName] = array('url' => $switchLanguageLink, 'text' => $translationName, 'locale' => eZSiteAccess::getIni($siteAccessName)->variable('RegionalSettings', 'ContentObjectLocale')); } return $ret; }
/** * @param array $settings * @param null $responseWriterClass Name of the ezpRestHttpResponseWriter implementation to use during request */ public function __construct(array $settings = array(), $responseWriterClass = null) { $this->responseWriterClass = $responseWriterClass; if (isset($settings['injected-settings'])) { $injectedSettings = array(); foreach ($settings['injected-settings'] as $keySetting => $injectedSetting) { list($file, $section, $setting) = explode('/', $keySetting); $injectedSettings[$file][$section][$setting] = $injectedSetting; } // Those settings override anything else in local .ini files and their overrides eZINI::injectSettings($injectedSettings); } if (isset($settings['injected-merge-settings'])) { $injectedSettings = array(); foreach ($settings['injected-merge-settings'] as $keySetting => $injectedSetting) { list($file, $section, $setting) = explode('/', $keySetting); $injectedSettings[$file][$section][$setting] = $injectedSetting; } // Those settings override anything else in local .ini files and their overrides eZINI::injectMergeSettings($injectedSettings); } $this->settings = $settings + array('use-cache-headers' => true, 'max-age' => 86400, 'siteaccess' => null, 'use-exceptions' => false); unset($settings, $injectedSettings, $file, $section, $setting, $keySetting, $injectedSetting); // lazy loaded database driver include __DIR__ . '/lazy.php'; $this->setUseExceptions($this->settings['use-exceptions']); // Tweaks ini filetime checks if not defined! // This makes ini system not check modified time so // that index_treemenu.php can assume that index.php does // this regular enough, set in config.php to override. if (!defined('EZP_INI_FILEMTIME_CHECK')) { define('EZP_INI_FILEMTIME_CHECK', false); } eZExecution::addFatalErrorHandler(function () { if (!headers_sent()) { header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error'); } }); eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP); // Trick to get eZSys working with a script other than index.php (while index.php still used in generated URLs): $_SERVER['SCRIPT_FILENAME'] = str_replace('/index_rest.php', '/index.php', $_SERVER['SCRIPT_FILENAME']); $_SERVER['PHP_SELF'] = str_replace('/index_rest.php', '/index.php', $_SERVER['PHP_SELF']); $ini = eZINI::instance(); $timezone = $ini->variable('TimeZoneSettings', 'TimeZone'); if ($timezone) { putenv("TZ={$timezone}"); } eZDebug::setHandleType(eZDebug::HANDLE_NONE); $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable('REQUEST_URI'); $ini = eZINI::instance(); eZSys::init('index_rest.php', $ini->variable('SiteAccessSettings', 'ForceVirtualHost') == 'true'); $uri = eZURI::instance(eZSys::requestURI()); $GLOBALS['eZRequestedURI'] = $uri; // load extensions eZExtension::activateExtensions('default'); require_once __DIR__ . '/restkernel_functions.php'; // set siteaccess from X-Siteaccess header if given and exists if (isset($_SERVER['HTTP_X_SITEACCESS']) && eZSiteAccess::exists($_SERVER['HTTP_X_SITEACCESS'])) { $access = array('name' => $_SERVER['HTTP_X_SITEACCESS'], 'type' => eZSiteAccess::TYPE_STATIC); } else { $access = eZSiteAccess::match($uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile()); } eZSiteAccess::change($access); // load siteaccess extensions eZExtension::activateExtensions('access'); // Now that all extensions are activated and siteaccess has been changed, reset // all eZINI instances as they may not take into account siteaccess specific settings. eZINI::resetAllInstances(false); if (ezpRestDebug::isDebugEnabled()) { $debug = ezpRestDebug::getInstance(); $debug->updateDebugSettings(); } }
$contentObject = $node->attribute('object'); $nodeResult = eZNodeviewfunctions::generateNodeViewData($tpl, $node, $contentObject, $languageCode, 'full', 0); // Generate a unique cache key for use in cache-blocks in pagelayout.tpl. // This should be looked as a temporary fix as ideally all cache-blocks // should be disabled by this view. $cacheKey = "timeline-" + time(); $nodeResult["title_path"] = array(array("text" => "Timeline Preview"), array("text" => $node->attribute('name'))); $httpCharset = eZTextCodec::httpCharset(); $locale = eZLocale::instance(); $languageCode = $locale->httpLocaleCode(); $nodeResult['content_info']['persistent_variable']['extra_template_list'] = array('timeline.tpl'); $nodeResult['content_info']['persistent_variable']['pagestyle_css_classes'] = array('yui-skin-sam', 'yui-skin-ezflow'); $site = array('title' => $ini->variable('SiteSettings', 'SiteName'), 'design' => $ini->variable('DesignSettings', 'SiteDesign'), 'uri' => eZURI::instance(eZSys::requestURI()), 'http_equiv' => array('Content-Type' => 'text/html; charset=' . $httpCharset, 'Content-language' => $languageCode)); $currentUser = eZUser::currentUser(); $tpl->setVariable("current_user", $currentUser); $tpl->setVariable('ui_context', ""); $uri = eZURI::instance(eZSys::requestURI()); $GLOBALS['eZRequestedURI'] = $uri; $access = eZSiteAccess::match($uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile()); $tpl->setVariable('access_type', $access); $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_timeline_sider", 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();
/** * Sets the current site. * * From eZ Publish. * * @param string $site Eg. 'plain_site_user' * @todo remove or move in another class? */ public function setCurrentSite($site) { eZWebDAVContentBackend::appendLogEntry(__FUNCTION__ . '1:' . $site); $access = array('name' => $site, 'type' => eZSiteAccess::TYPE_STATIC); $access = eZSiteAccess::change($access); eZWebDAVContentBackend::appendLogEntry(__FUNCTION__ . '2:' . $site); eZDebugSetting::writeDebug('kernel-siteaccess', $access, 'current siteaccess'); // Clear/flush global database instance. $nullVar = null; eZDB::setInstance($nullVar); }
function setCurrentSite( $site ) { $access = array( 'name' => $site, 'type' => eZSiteAccess::TYPE_STATIC ); $access = eZSiteAccess::change( $access ); eZDebugSetting::writeDebug( 'kernel-siteaccess', $access, 'current siteaccess' ); // Clear/flush global database instance. $nullVar = null; eZDB::setInstance( $nullVar ); }
/** * Get ini file for a specific siteaccess (not incl extesnions or overrides) * use {@link eZSiteAccess::getIni()} instead if you want to have full ini env. * * @param string $siteAccess * @param string $iniFile * @return eZINI */ static function getSiteAccessIni($siteAccess, $iniFile) { $saPath = eZSiteAccess::findPathToSiteAccess($siteAccess); return self::fetchFromFile("{$saPath}/{$iniFile}"); }
/** * Get the Sitemap's root node */ $rootNode = eZContentObjectTreeNode::fetch($sitemapRootNodeID, $siteaccess['locale']); /** * Test for content object fetch (above) failure to return a valid object. * Alert the user and terminate execution of script */ if (!is_object($rootNode)) { $cli->output("Invalid SitemapRootNodeID in configuration block GeneralSettings; OR SitemapRootNodeID does not not have language translation for current siteaccess language.\n"); return; } /** * Change siteaccess */ eZSiteAccess::change(array("name" => $siteaccess["siteaccess"], "type" => eZSiteAccess::TYPE_URI)); /** * Fetch the content tree nodes (children) of the above root node (in a given locale) */ $nodeArray[] = $rootNode->subTree(array('Language' => $siteaccess['siteaccessLanguages'], 'ClassFilterType' => $classFilterType, 'ClassFilterArray' => $classFilterArray)); } // BC: End foreach( $siteaccesses as $siteaccess ) /** * Prepare new xml document */ $xmlRoot = "urlset"; $xmlNode = "url"; /** * Define XML Child Nodes */ $xmlSubNodes = array('loc', 'lastmod', 'changefreq', 'priority');
$valueArray[] = "[{$param}]={$key}"; } else { $valueArray[] = "={$key}"; } } $value = implode($separator, $valueArray); return $value; } function getVariable($block, $settingName, $iniFile, $path) { $ini = new eZINI($iniFile, $path, null, null, null, true, true); $result = $ini->hasVariable($block, $settingName) ? $ini->variable($block, $settingName) : false; $result = parseArrayToStr($result, '<br>'); return $result; } $ini = eZSiteAccess::getIni($siteAccess, $iniFile); $value = $settingName != '' ? $ini->variable($block, $settingName) : ''; // Do modifications to the value before it's sent to the template if (is_array($value) || $value and !isset($settingType)) { $settingType = $ini->settingType($value); if ($settingType == 'array') { $value = parseArrayToStr($value, "\n"); } } // Init value from ini (default\override\extensions\siteaccess) $values = array(); $values['default'] = getVariable($block, $settingName, $iniFile, 'settings/'); $values['siteaccess'] = getVariable($block, $settingName, $iniFile, "settings/siteaccess/{$siteAccess}"); $values['override'] = getVariable($block, $settingName, $iniFile, "settings/override/"); // Get values from extensions $ini = eZINI::instance();
function removeRelatedCache($siteAccess) { // Delete compiled template $ini = eZINI::instance(); $iniPath = eZSiteAccess::findPathToSiteAccess($siteAccess); $siteINI = eZINI::instance('site.ini.append', $iniPath); if ($siteINI->hasVariable('FileSettings', 'CacheDir')) { $cacheDir = $siteINI->variable('FileSettings', 'CacheDir'); if ($cacheDir[0] == "/") { $cacheDir = eZDir::path(array($cacheDir)); } else { if ($siteINI->hasVariable('FileSettings', 'VarDir')) { $varDir = $siteINI->variable('FileSettings', 'VarDir'); $cacheDir = eZDir::path(array($varDir, $cacheDir)); } } } else { if ($siteINI->hasVariable('FileSettings', 'VarDir')) { $varDir = $siteINI->variable('FileSettings', 'VarDir'); $cacheDir = $ini->variable('FileSettings', 'CacheDir'); $cacheDir = eZDir::path(array($varDir, $cacheDir)); } else { $cacheDir = eZSys::cacheDirectory(); } } $compiledTemplateDir = $cacheDir . "/template/compiled"; eZDir::unlinkWildcard($compiledTemplateDir . "/", "*pagelayout*.*"); eZCache::clearByTag('template-block'); // Expire content view cache eZContentCacheManager::clearAllContentCache(); }
$Module->redirectToView('view', array('full', $node->attribute('parent_node_id'))); } else { $Module->redirectToView('view', array('sitemap', 2)); } } return; } $contentObject->setAttribute('current_version', $EditVersion); $ini = eZINI::instance(); $siteaccess = false; if ($Module->hasActionParameter('SiteAccess')) { $siteaccess = $Module->actionParameter('SiteAccess'); } // Find ContentObjectLocale for all site accesses in RelatedSiteAccessList foreach ($ini->variable('SiteAccessSettings', 'RelatedSiteAccessList') as $relatedSA) { $relatedSALocale = eZSiteAccess::getIni($relatedSA, 'site.ini')->variable('RegionalSettings', 'ContentObjectLocale'); $siteaccessLocaleMap[$relatedSA] = $relatedSALocale; if (!$siteaccess && $LanguageCode && $LanguageCode === $relatedSALocale) { $siteaccess = $relatedSA; } } if (!$siteaccess) { $siteaccess = $ini->variable('SiteSettings', 'DefaultAccess'); } // Try to find a version that has the language we want, by going backwards in the version history // Also, gether unique list of translations in all versions up until this one $foundTranslationList = array(); $viewVersion = $EditVersion; $viewVersionObject = false; foreach (array_reverse($contentObject->versions(false)) as $versionHash) { $viewVersion = $versionHash['version'];
private function setSiteAccess( $accessName ) { eZSiteAccess::change( array( 'name' => $accessName, 'type' => eZSiteAccess::TYPE_URI, 'uri_part' => array( $accessName ) ) ); }
/** * A helper method used to create directory parts array * * @param string $dir * @param string $siteAccess * @return array */ private function buildCacheDirPart( $dir, $siteAccess ) { return array( 'dir' => $dir, 'access_name' => $siteAccess, 'site_url' => eZSiteAccess::getIni( $siteAccess, 'site.ini' )->variable( 'SiteSettings', 'SiteURL' ) ); }
/** * Get an array of all the current templates and overrides for them. * The current siteaccess is used if none is specified. * * @static * @return array */ static function overrideArray($siteAccess = false) { if ($siteAccess === false and self::$overrideArrayCache !== null) { return self::$overrideArrayCache; } $bases = eZTemplateDesignResource::allDesignBases($siteAccess); // fetch the override array from a specific siteacces if ($siteAccess) { $overrideINI = eZSiteAccess::getIni($siteAccess, 'override.ini'); } else { $overrideINI = eZINI::instance('override.ini'); } $designStartPath = eZTemplateDesignResource::designStartPath(); // Generate match cache for all templates // Build arrays of available files, start with standard design and end with most prefered design $matchFileArray = array(); $reverseBases = array_reverse($bases); foreach ($reverseBases as $base) { $templateResource = $base . '/templates'; $sourceFileArray = eZDir::recursiveFindRelative($templateResource, "", "tpl"); foreach ($sourceFileArray as $source) { $matchFileArray[$source]['base_dir'] = $templateResource; $matchFileArray[$source]['template'] = $source; } } // Load override templates $overrideSettingGroups = $overrideINI->groups(); if (isset($GLOBALS['eZDesignOverrides'])) { $overrideSettingGroups = array_merge($overrideSettingGroups, $GLOBALS['eZDesignOverrides']); } foreach ($overrideSettingGroups as $overrideName => $overrideSetting) { if (!isset($overrideSetting['Source'])) { continue; } $overrideSource = "/" . $overrideSetting['Source']; $overrideMatchFile = $overrideSetting['MatchFile']; // Find the matching file in the available resources $triedFiles = array(); $fileInfo = eZTemplateDesignResource::fileMatch($bases, 'override/templates', $overrideMatchFile, $triedFiles); $resourceInUse = is_array($fileInfo) ? $fileInfo['resource'] : false; $overrideMatchFilePath = is_array($fileInfo) ? $fileInfo['path'] : false; // if the override template is not found // then we probably shouldn't use it // there should be added a check around the following code // if ( $overrideMatchFilePath ) // { $customMatchArray = array(); $customMatchArray['conditions'] = isset($overrideSetting['Match']) ? $overrideSetting['Match'] : null; $customMatchArray['match_file'] = $overrideMatchFilePath; $customMatchArray['override_name'] = $overrideName; $matchFileArray[$overrideSource]['custom_match'][] = $customMatchArray; // } // if overriding a non-existing template // then we use the override template as main template // this code should probably be removed // because we should not allow an override if the main template is missing if ($resourceInUse && !isset($matchFileArray[$overrideSource]['base_dir'])) { $matchFileArray[$overrideSource]['base_dir'] = $resourceInUse; $matchFileArray[$overrideSource]['template'] = $overrideSource; } if (!$overrideMatchFilePath) { eZDebug::writeError("Custom match file: path '{$overrideMatchFile}' not found in any resource. Check the template settings in settings/override.ini", __METHOD__); eZDebug::writeError(implode(', ', $triedFiles), __METHOD__ . ' tried files'); } } if ($siteAccess === false) { self::$overrideArrayCache = $matchFileArray; } return $matchFileArray; }
function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters ) { switch ( $operatorName ) { // note: these functions are not cache-block safe // as in: if called inside a cache-block then they will not be called when cache is used. case 'ezpagedata_set': case 'ezpagedata_append': { self::setPersistentVariable( $namedParameters['key'], $namedParameters['value'], $tpl, $operatorName === 'ezpagedata_append' ); }break; case 'ezpagedata': { $currentNodeId = 0; $pageData = array(); $parameters = $namedParameters['params']; // Get module_result for later use if ( $tpl->hasVariable('module_result') ) { $moduleResult = $tpl->variable('module_result'); } else { $moduleResult = array(); } if ( isset( $moduleResult['content_info'] ) ) { $contentInfo = $moduleResult['content_info']; } else { $contentInfo = array(); } // Get persistent_variable if ( isset( $contentInfo['persistent_variable'] ) && is_array( $contentInfo['persistent_variable'] ) ) { $pageData['persistent_variable'] = $contentInfo['persistent_variable']; } else { $pageData['persistent_variable'] = self::getPersistentVariable(); if ( $pageData['persistent_variable'] === null ) { $pageData['persistent_variable'] = array(); } } // Merge parameters with persistent_variable $parameters = array_merge( $parameters, $pageData['persistent_variable'] ); // Figgure out current node id if ( isset( $parameters['current_node_id'] ) ) { $currentNodeId = (int) $parameters['current_node_id']; // Allow parameters to set current path if ( isset( $parameters['set_current_node_path'] ) && $parameters['set_current_node_path'] ) { if ( $setPath = self::getNodePath( $currentNodeId ) ) { $moduleResult['path'] = $setPath['path']; $moduleResult['title_path'] = $setPath['title_path']; $tpl->setVariable( 'module_result', $moduleResult ); } else { eZDebug::writeWarning( "Could not fetch 'current_node_id'", 'eZPageData::getNodePath()' ); } } } else if ( $tpl->hasVariable('current_node_id') ) { $currentNodeId = (int) $tpl->variable('current_node_id'); } else if ( isset( $moduleResult['node_id'] ) ) { $currentNodeId = (int) $moduleResult['node_id']; } else if ( isset( $moduleResult['path'][count( $moduleResult['path'] ) - 1]['node_id'] ) ) { $currentNodeId = (int) $moduleResult['path'][count( $moduleResult['path'] ) - 1]['node_id']; } // Init variables and return values $ini = eZINI::instance( 'site.ini' ); $menuIni = eZINI::instance( 'menu.ini' ); $contentIni = eZINI::instance( 'content.ini' ); $uiContext = $tpl->variable('ui_context'); $uriString = $tpl->variable('uri_string'); $pageData['main_node_id'] = isset( $contentInfo['main_node_id'] ) ? $contentInfo['main_node_id'] : $currentNodeId; $pageData['show_path'] = 'path'; $pageData['website_toolbar'] = false; $pageData['node_id'] = $currentNodeId; $pageData['is_edit'] = false; $pageData['page_root_depth'] = 0; $pageData['page_depth'] = count( $moduleResult['path'] ); $pageData['root_node'] = (int) $contentIni->variable( 'NodeSettings', 'RootNode' ); $pageData['canonical_url'] = false; $pageData['canonical_language_url'] = false; // is_edit if not on user/edit and not on content/action when // you get info collector warning about missing attributes if ( $uiContext === 'edit' && strpos( $uriString, 'user/edit' ) === false && ( empty( $contentInfo ) || strpos( $uriString, 'content/action' ) === false ) ) { $pageData['is_edit'] = true; } if ( isset( $contentInfo['viewmode'] ) ) { $viewMode = $contentInfo['viewmode']; } else { $viewMode = ''; } // canonical url, to let search engines know about main location on content with multiple locations if ( isset( $parameters['canonical_url'] ) ) { $pageData['canonical_url'] = $parameters['canonical_url']; } elseif ( isset( $contentInfo['main_node_url_alias'] ) && $contentInfo['main_node_url_alias'] ) { $pageData['canonical_url'] = $contentInfo['main_node_url_alias']; } elseif ( isset( $contentInfo['current_language'] ) && $contentInfo['current_language'] !== $ini->variable( 'RegionalSettings', 'ContentObjectLocale' ) ) { $siteaccess = eZSiteAccess::saNameByLanguage( $contentInfo['current_language'] ); if ( $siteaccess !== null ) { $lang = eZContentLanguage::fetchByLocale( $ini->variable( 'RegionalSettings', 'ContentObjectLocale' ) ); if ( ( $contentInfo['language_mask'] & $lang->attribute('id') ) < 1 ) { $handlerOptions = new ezpExtensionOptions(); $handlerOptions->iniFile = 'site.ini'; $handlerOptions->iniSection = 'RegionalSettings'; $handlerOptions->iniVariable = 'LanguageSwitcherClass'; $handlerOptions->handlerParams = array( array( 'Parameters' => array( 'sa', $currentNodeId ), 'UserParameters' => array() ) ); $langSwitch = eZExtension::getHandlerClass( $handlerOptions ); $langSwitch->setDestinationSiteAccess( $siteaccess ); $langSwitch->process(); $pageData['canonical_language_url'] = $langSwitch->destinationUrl(); } } } /* RootNodeDepth is a setting for letting you have a very simple multisite, single database and singe siteaccess setup. The content of the menues will be the same on all system pages like user/login, content/edit and so on, and also when you surf bellow the defined page_root_depth. The sites will also share siteaccess and thus also the same ez publish design and templates. You can however custimize the design with css using the class on div#page html output: subtree_level_x_node_id_y class Note: It is recommended to turn it of by setting it to 0 for normal sites! Example having 2 or more 'sub-sites' with RootNodeDepth=2: root (menu shows sub sites as menu choices like it will on system pages) - sub site 1 (menu show content of this sub site) - sub site 2 (-- " --) - sub site 3 (-- " --) - sub site 4 (-- " --) - sub site 5 (-- " --) */ if ( $currentNodeId && isset( $moduleResult['path'][0]['node_id'] ) && $moduleResult['path'][0]['node_id'] == '2' && $ini->hasVariable( 'SiteSettings', 'RootNodeDepth' ) && $ini->variable( 'SiteSettings', 'RootNodeDepth' ) !== '0' ) { $pageData['page_root_depth'] = $ini->variable( 'SiteSettings', 'RootNodeDepth' ) -1; if ( isset( $moduleResult['path'][ $pageData['page_root_depth'] ]['node_id'] )) { $pageData['root_node'] = $moduleResult['path'][$pageData['page_root_depth'] ]['node_id']; } } // Get class identifier for easier access in tempaltes $pageData['class_identifier'] = ''; if ( isset( $contentInfo['class_identifier'] ) ) { $pageData['class_identifier'] = $contentInfo['class_identifier']; } // Use custom path template. bool|string ( default: path ) if ( isset( $parameters['show_path'] ) ) { $pageData['show_path'] = $parameters['show_path'] === true ? 'path' : $parameters['show_path']; } else if ( $viewMode === 'sitemap' || $viewMode === 'tagcloud' ) { $pageData['show_path'] = false; } // See if we should show website toolbar. bool ( default: false ) if ( isset( $parameters['website_toolbar'] ) ) { $pageData['website_toolbar'] = $parameters['website_toolbar']; } else if ( $viewMode === 'sitemap' || $viewMode === 'tagcloud' || strpos( $uriString, 'content/versionview' ) === 0 ) { $pageData['website_toolbar'] = false; } else if ( $tpl->hasVariable('current_user') ) { $currentUser = $tpl->variable('current_user'); $pageData['website_toolbar'] = ( $currentNodeId && $currentUser->attribute('is_logged_in') ); } // Init default menu settings $pageData['top_menu'] = $menuIni->variable('SelectedMenu', 'TopMenu'); $pageData['left_menu'] = $menuIni->variable('SelectedMenu', 'LeftMenu'); $pageData['current_menu'] = $menuIni->variable('SelectedMenu', 'CurrentMenu'); $pageData['extra_menu'] = 'extra_info'; $pageData['extra_menu_node_id'] = $currentNodeId; $pageData['extra_menu_subitems'] = 0; $pageData['extra_menu_class_list'] = array( 'infobox' ); // BC: Setting to hide left and extra menu by class identifier if ( $menuIni->hasVariable('MenuSettings', 'HideLeftMenuClasses') ) { $hideMenuClasses = in_array( $pageData['class_identifier'], $menuIni->variable('MenuSettings', 'HideLeftMenuClasses') ); } else { $hideMenuClasses = false; } // Use custom top menu template. bool|string ( default: from menu.ini[SelectedMenu]TopMenu ) if ( isset( $parameters['top_menu'] ) && $parameters['top_menu'] !== true ) { $pageData['top_menu'] = $parameters['top_menu']; } // Use custom left menu template. bool|string ( default: from menu.ini[SelectedMenu]LeftMenu ) if ( isset( $parameters['left_menu'] ) ) { if ( $parameters['left_menu'] !== true ) $pageData['left_menu'] = $parameters['left_menu']; } else if ( $hideMenuClasses ) { $pageData['left_menu'] = false; } // Use custom extra menu template. bool|string (default: extra_info) if ( isset( $parameters['extra_menu'] ) ) { if ( $parameters['extra_menu'] !== true ) $pageData['extra_menu'] = $parameters['extra_menu']; } else if ( $hideMenuClasses ) { $pageData['extra_menu'] = false; } // Use custom node id. int|array (default: current node id) if ( isset( $parameters['extra_menu_node_id'] ) ) { $pageData['extra_menu_node_id'] = $parameters['extra_menu_node_id']; } // Use custom extra menu identifier list. false|array (default: infobox) if ( isset( $parameters['extra_menu_class_list'] ) ) { $pageData['extra_menu_class_list'] = $parameters['extra_menu_class_list']; } else if ( $menuIni->hasVariable('MenuContentSettings', 'ExtraIdentifierList') ) { $pageData['extra_menu_class_list'] = $menuIni->variable('MenuContentSettings', 'ExtraIdentifierList'); } if ( $menuIni->variable( 'MenuSettings', 'AlwaysAvailable' ) === 'false' ) { // A set of cases where left/extra menu's are hidden unless set by parameters if ( $pageData['is_edit'] || strpos( $uriString, 'content/versionview' ) === 0 ) { if ( !isset( $parameters['left_menu'] ) ) $pageData['left_menu'] = false; if ( !isset( $parameters['extra_menu'] ) ) $pageData['extra_menu'] = false; } else if ( !$currentNodeId || $uiContext === 'browse' ) { if ( !isset( $parameters['left_menu'] ) ) $pageData['left_menu'] = false; if ( !isset( $parameters['extra_menu'] ) ) $pageData['extra_menu'] = false; } } // Count extra menu objects if all extra menu settings are present if ( isset( $parameters['extra_menu_subitems'] ) ) { $pageData['extra_menu_subitems'] = $parameters['extra_menu_subitems']; if ( !$pageData['extra_menu_subitems'] ) $pageData['extra_menu'] = false; } else if ( $pageData['extra_menu'] && $pageData['extra_menu_class_list'] && $pageData['extra_menu_node_id'] ) { if ( $menuIni->variable( 'MenuContentSettings', 'ExtraMenuSubitemsCheck' ) === 'enabled' ) { $pageData['extra_menu_subitems'] = eZContentObjectTreeNode::subTreeCountByNodeID( array( 'Depth' => 1, 'DepthOperator' => 'eq', 'ClassFilterType' => 'include', 'ClassFilterArray' => $pageData['extra_menu_class_list'] ), $pageData['extra_menu_node_id'] ); if ( !$pageData['extra_menu_subitems'] ) $pageData['extra_menu'] = false; } } // Init path parameters $pageData['path_array'] = array(); $pageData['path_id_array'] = array(); $pageData['path_normalized'] = ''; // Creating menu css classes for div#page $pageData['css_classes'] = ''; // Add section css class for div#page if ( isset( $moduleResult['section_id'] )) { $pageData['css_classes'] .= ' section_id_' . $moduleResult['section_id']; } // Generate relative path array as well full path id array and path css classes for div#page $path = ( isset( $moduleResult['path'] ) && is_array( $moduleResult['path'] ) ) ? $moduleResult['path'] : array(); foreach ( $path as $key => $item ) { if ( $key >= $pageData['page_root_depth']) { $pageData['path_array'][] = $item; } if ( isset( $item['node_id'] ) ) { $pageData['path_normalized'] .= ' subtree_level_' . $key . '_node_id_' . $item['node_id']; $pageData['path_id_array'][] = $item['node_id']; } } $pageData['css_classes'] .= $pageData['path_normalized']; if ( isset( $pageData['persistent_variable']['pagestyle_css_classes'] ) && is_array( $pageData['persistent_variable']['pagestyle_css_classes'] ) ) { $pageData['css_classes'] .= ' ' . implode( ' ', $pageData['persistent_variable']['pagestyle_css_classes'] ); } $pageData['inner_column_size'] = 8; if ( $pageData['left_menu'] && $pageData['extra_menu'] ) $pageData['inner_column_size'] = 6; if ( !$pageData['left_menu'] && !$pageData['extra_menu'] ) $pageData['inner_column_size'] = 12; $pageData['outer_column_size'] = 4; if ( $pageData['left_menu'] && $pageData['extra_menu'] ) $pageData['outer_column_size'] = 3; $operatorValue = $pageData; } break; } }
// if eZINI::instance() is called twice instance will be fetched from GLOBAL variable. // Without reference there will be a inconsistency with GLOBAL instance and stored ini file. $iniTemp = eZINI::create( $settingFile . '.append.php', $path, null, null, null ); $iniTemp->removeSetting( $block, $setting ); $iniTemp->save(); } } } if ( $http->hasPostVariable( 'ChangeINIFile' ) or ( $Params['SiteAccess'] and $Params['INIFile'] ) ) { if ( $GLOBALS['eZCurrentAccess']['name'] !== $currentSiteAccess ) { // create a site ini instance using $useLocalOverrides $siteIni = eZSiteAccess::getIni( $currentSiteAccess, 'site.ini' ); // load settings file with $useLocalOverrides = true & $addArrayDefinition = true $ini = new eZINI( /*$fileName =*/ $settingFile, /*$rootDir =*/ 'settings', /*$useTextCodec =*/ null, /*$useCache =*/ false, /*$useLocalOverrides =*/ true, /*$directAccess =*/ false, /*$addArrayDefinition =*/ true, /*$load =*/ false ); $ini->setOverrideDirs( $siteIni->overrideDirs( false ) ); $ini->load(); } else {
static function generateObjectViewCache($objectID) { // Generate the view cache $ini = eZINI::instance(); $object = eZContentObject::fetch($objectID); $user = eZUser::currentUser(); eZDebug::accumulatorStart('generate_cache', '', 'Generating view cache'); if ($ini->variable('ContentSettings', 'PreViewCache') == 'enabled') { $preCacheSiteaccessArray = $ini->variable('ContentSettings', 'PreCacheSiteaccessArray'); $currentSiteAccess = $GLOBALS['eZCurrentAccess']; // This is the default view parameters for content/view $viewParameters = array('offset' => false, 'year' => false, 'month' => false, 'day' => false, 'namefilter' => false); if (is_array($preCacheSiteaccessArray) && count($preCacheSiteaccessArray) > 0) { foreach ($preCacheSiteaccessArray as $changeToSiteAccess) { $newSiteAccess = $currentSiteAccess; $newSiteAccess['name'] = $changeToSiteAccess; unset($newSiteAccess['uri_part']); //eZSiteAccess::load() will take care of setting correct one eZSiteAccess::load($newSiteAccess); $tpl = eZTemplate::factory(); // Get the sitedesign and cached view preferences for this siteaccess $siteini = eZINI::instance('site.ini'); $cachedViewPreferences = $siteini->variable('ContentSettings', 'CachedViewPreferences'); $language = false; // Needs to be specified if you want to generate the cache for a specific language $viewMode = 'full'; $assignedNodes = $object->assignedNodes(); foreach ($assignedNodes as $node) { // We want to generate the cache for the specified user $previewCacheUsers = $ini->variable('ContentSettings', 'PreviewCacheUsers'); foreach ($previewCacheUsers as $previewCacheUserID) { // If the text is 'anon' we need to fetch the Anonymous user ID. if ($previewCacheUserID === 'anonymous') { $previewCacheUserID = $siteini->variable("UserSettings", "AnonymousUserID"); $previewCacheUser = eZUser::fetch($previewCacheUserID); } else { if ($previewCacheUserID === 'current') { $previewCacheUser = $user; } else { $previewCacheUser = eZUser::fetch($previewCacheUserID); } } if (!$previewCacheUser) { continue; } // Before we generate the view cache we must change the currently logged in user to $previewCacheUser // If not the templates might read in wrong personalized data (preferences etc.) eZUser::setCurrentlyLoggedInUser($previewCacheUser, $previewCacheUser->attribute('contentobject_id'), eZUser::NO_SESSION_REGENERATE); // Cache the current node $cacheFileArray = eZNodeviewfunctions::generateViewCacheFile($previewCacheUser, $node->attribute('node_id'), false, false, $language, $viewMode, $viewParameters, $cachedViewPreferences); $tmpRes = eZNodeviewfunctions::generateNodeView($tpl, $node, $node->attribute('object'), $language, $viewMode, false, $cacheFileArray['cache_dir'], $cacheFileArray['cache_path'], true, $viewParameters); // Cache the parent node $parentNode = $node->attribute('parent'); $objectID = $parentNode->attribute('contentobject_id'); // if parent objectID is null or is 0 we should not create cache. if ($objectID) { $cacheFileArray = eZNodeviewfunctions::generateViewCacheFile($previewCacheUser, $parentNode->attribute('node_id'), 0, false, $language, $viewMode, $viewParameters, $cachedViewPreferences); $tmpRes = eZNodeviewfunctions::generateNodeView($tpl, $parentNode, $parentNode->attribute('object'), $language, $viewMode, 0, $cacheFileArray['cache_dir'], $cacheFileArray['cache_path'], true, $viewParameters); } } } } // Restore the old user as the current one eZUser::setCurrentlyLoggedInUser($user, $user->attribute('contentobject_id'), eZUser::NO_SESSION_REGENERATE); // restore siteaccess eZSiteAccess::load($currentSiteAccess); } } if ($ini->variable('ContentSettings', 'StaticCache') == 'enabled') { $nodes = array(); $ini = eZINI::instance(); $useURLAlias =& $GLOBALS['eZContentObjectTreeNodeUseURLAlias']; $pathPrefix = $ini->variable('SiteAccessSettings', 'PathPrefix'); // get staticCacheHandler instance $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler'); $options = new ezpExtensionOptions($optionArray); $staticCacheHandler = eZExtension::getHandlerClass($options); if (!isset($useURLAlias)) { $useURLAlias = $ini->variable('URLTranslator', 'Translation') == 'enabled'; } eZContentCacheManager::nodeListForObject($object, true, self::CLEAR_DEFAULT, $nodes, $handledObjectList); // If no nodes returns it means that ClearCacheMethod = self::CLEAR_NO_CACHE if (count($nodes)) { foreach ($nodes as $nodeID) { if ($useURLAlias) { $oNode = eZContentObjectTreeNode::fetch($nodeID, false, true); if (!isset($oNode)) { continue; } $urlAlias = $oNode->urlAlias(); if ($pathPrefix != '') { $tempAlias = substr($pathPrefix, strlen($pathPrefix) - 1) == '/' ? $urlAlias . '/' : $urlAlias; if (strncmp($tempAlias, $pathPrefix, strlen($tempAlias)) == 0) { $urlAlias = substr($tempAlias, strlen($pathPrefix)); } } } else { $urlAlias = 'content/view/full/' . $nodeID; } $staticCacheHandler->cacheURL('/' . $urlAlias, $nodeID); } $staticCacheHandler->generateAlwaysUpdatedCache(); } } eZDebug::accumulatorStop('generate_cache'); }
// init uri code $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable( 'REQUEST_URI' ); eZSys::init( 'index.php', $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) === 'true' ); $uri = eZURI::instance( eZSys::requestURI() ); $GLOBALS['eZRequestedURI'] = $uri; // Check for extension eZExtension::activateExtensions( 'default' ); // load siteaccess $access = eZSiteAccess::match( $uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile() ); $access = eZSiteAccess::change( $access ); $GLOBALS['eZCurrentAccess'] = $access; // Check for new extension loaded by siteaccess eZExtension::activateExtensions( 'access' ); $db = eZDB::instance(); if ( $db->isConnected() ) { eZSession::start(); } else { exitWithInternalError(); return; }
} $siteAccessList = $ini->variable('SiteAccessSettings', 'RelatedSiteAccessList'); $siteAccess = false; // Fetch siteaccess settings for the selected override // Default to first defined siteacces if none are selected if ($http->hasSessionVariable('eZTemplateAdminCurrentSiteAccess')) { $siteAccess = $http->sessionVariable('eZTemplateAdminCurrentSiteAccess'); } if (!in_array($siteAccess, $siteAccessList)) { $siteAccess = $siteAccessList[0]; } if ($http->hasPostVariable('SelectCurrentSiteAccessButton')) { $http->setSessionVariable('eZTemplateAdminCurrentSiteAccess', $siteAccess); } // Get path to specified site access. $pathToSiteAccess = eZSiteAccess::findPathToSiteAccess($siteAccess); $menuINI = eZINI::instance("menu.ini", "", null, null, true); $menuINI->prependOverrideDir($pathToSiteAccess, true, 'siteaccess'); $menuINI->loadCache(); /*$iniPath = "settings/siteaccess/$siteAccess"; $menuINI = eZINI::instance( 'menu.ini.append.php', $iniPath, null, false, null, true );*/ if ($module->isCurrentAction('Store')) { $menuType = $http->postVariable('MenuType'); $menuINI->setVariable('SelectedMenu', 'CurrentMenu', $menuType); $menuINI->setVariable('SelectedMenu', 'TopMenu', $menuINI->variable($menuType, "TopMenu")); $menuINI->setVariable('SelectedMenu', 'LeftMenu', $menuINI->variable($menuType, "LeftMenu")); $menuINI->save("menu.ini.append.php", false, false, false, $pathToSiteAccess, true); // Delete compiled template $iniPath = $pathToSiteAccess; $siteINI = eZINI::instance('site.ini.append', $iniPath); if ($siteINI->hasVariable('FileSettings', 'CacheDir')) {