/** * Test scenario for issue #13186: UserParameters works differently in 4.0 compared to 3.10 * * @result $eZURI->userParameters() returns an empty array * @expected $eZURI->userParameters() should return array( "ole" => "a", "dull" => "boy" ). * * @link http://issues.ez.no/13186 */ public function testUserParameters() { $expectedParams = array("ole" => "a", "dull" => "boy"); $eZURI = eZURI::instance(); $userParams = $eZURI->userParameters(); $this->assertEquals($expectedParams, $userParams); }
public function testInstanceRepeatCallsWithDifferentUri() { $docstring = "Calling eZURI::instance( \$uri ) with different \$uri" . " each time should return seperate instances of eZURI" . " when \$uri is not equal eZSys::requestURI(). No caching" . " in \$_GLOBALS should be done."; $uri1 = "/i/have/(no)/imageination"; $uri2 = "/lorem/ipsum/dolor/(sit)/amet"; $ezuri = eZURI::instance(); $ezuri1 = eZURI::instance($uri1); $ezuri2 = eZURI::instance($uri2); $this->assertNotSame($ezuri, $ezuri1, $docstring); $this->assertNotSame($ezuri, $ezuri2, $docstring); $this->assertNotSame($ezuri1, $ezuri2, $docstring); }
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'); }
$tpl->setVariable('content_type_name', ucfirst(rtrim($contentType, 's'))); $tpl->setVariable('compatibility_mode', $ezoeIni->variable('EditorSettings', 'CompatibilityMode')); $tpl->setVariable('tag_name', $tagName); $xmlTagAliasList = $ezoeIni->variable('EditorSettings', 'XmlTagNameAlias'); if (isset($xmlTagAliasList[$tagName])) { $tpl->setVariable('tag_name_alias', $xmlTagAliasList[$tagName]); } else { $tpl->setVariable('tag_name_alias', $tagName); } $tpl->setVariable('view_list', json_encode(array('embed' => $viewList, 'embed-inline' => $viewListInline))); $tpl->setVariable('class_list', json_encode(array('embed' => $classList, 'embed-inline' => $classListInline))); $tpl->setVariable('attribute_defaults', json_encode(array('embed' => $attributeDefaults, 'embed-inline' => $attributeDefaultsInline))); $tpl->setVariable('custom_attributes', $customAttributes); $tpl->setVariable('size_list', $sizeTypeArray); $defaultSize = $contentIni->variable('ImageSettings', 'DefaultEmbedAlias'); $tpl->setVariable('default_size', $defaultSize); if ($contentIni->hasVariable('ImageSettings', 'DefaultCropAlias')) { $tpl->setVariable('default_crop_size', $contentIni->variable('ImageSettings', 'DefaultCropAlias')); } else { $tpl->setVariable('default_crop_size', $defaultSize); } $tpl->setVariable('custom_attribute_style_map', json_encode($ezoeIni->variable('EditorSettings', 'CustomAttributeStyleMap'))); $tpl->setVariable('persistent_variable', array()); $tpl->setVariable('original_uri_string', eZURI::instance()->originalURIString()); $Result = array(); $Result['content'] = $tpl->fetch('design:ezoe/tag_embed_' . $contentType . '.tpl'); $Result['pagelayout'] = 'design:ezoe/popup_pagelayout.tpl'; $Result['persistent_variable'] = $tpl->variable('persistent_variable'); return $Result; //eZExecution::cleanExit(); //$GLOBALS['show_page_layout'] = false;
/** * @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(); } }
/** * Test scenario for issue #18449 : Can't print search results in MSIE * Main problem is to be able to get the query string out of eZURI * @link http://issues.ez.no/18449 * @group issue18449 * @group ezuri_regression */ public function testQueryString() { self::assertEquals($this->queryString, eZURI::instance()->attribute("query_string")); }
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; }
/** * Tests an identified error until eZ Publish 4.2: * a cascaded translation (uri => translation1 => translation2) will fail * with a fatal error if the two matching wildcards are located in different * cache files * * Test outline: * 1. Create a wildcard of DIRECT type that translates A to B * 2. Create more than 100 dummy wildcards * 3. Create a wildcard of DIRECT type that translates B to C * * Expected: the test fails at #3 with a fatal error "Cannot redeclare ezurlwilcardcachedtranslate" */ public function testDoubleTranslation() { self::createWildcard("testDoubleTranslation1/*", 'testDoubleTranslation2/{1}', eZURLWildcard::TYPE_DIRECT); // create more than 100 wildcards for ($i = 0; $i <= 100; $i++) { self::createWildcard("testDoubleTranslationDummy{$i}/*", '/', eZURLWildcard::TYPE_DIRECT); } self::createWildcard("testDoubleTranslation2/*", 'testDoubleTranslation3/{1}', eZURLWildcard::TYPE_DIRECT); $uri = eZURI::instance('testDoubleTranslation1/foobar'); // will fail $this->assertFalse(eZURLWildcard::translate($uri)); }
/** * @return bool */ public function htmlBuildFullResult() { /* @type $dataMap eZContentObjectAttribute[] */ /* @type $publisherNode eZContentObjectTreeNode */ $article_parameters = $this->_params['UserParameters']; $dataMap = $this->node->dataMap(); $taxonomies = $dataMap["serialized_taxonomies"]->content(); $publisherPath = $taxonomies["publisher_folder"][0]; $publisherFolder = $this->applicationLocalized()->getPublisherFolderFromPath( $publisherPath ); $this->initChannelInformations(); $this->pushChannelResult(); if(isset($article_parameters['language'])) { $this->node->setCurrentLanguage($article_parameters['language']); } $this->pushResult('article_parameters', $article_parameters); $this->pushResult('node' , $this->node); $this->pushResult('features' , $this->resultHandler->features); $this->pushResult('publisher' , $publisherFolder); // get all languages avalaible for the node /* @type $dataMap eZContentObjectAttribute[] */ $languages = array(); $dataMap = $this->node->dataMap(); $serial = $dataMap['serialized_taxonomies']->content(); if( isset($serial['language']) && $publisherFolder instanceof PublisherFolder ) { $publisherLanguages = $publisherFolder->getLanguages(); $languageList = $serial['language']; $languageTranslations = FacetFilteringTool::getTaxonomyTranslation('language'); // get locales and iso of languages node $availableLanguages = array(); foreach( array_keys($this->node->object()->allLanguages()) as $locale ) { if ( is_array($publisherLanguages) && in_array($locale, $publisherLanguages) ) { $key = LocaleTool::languageISO639Code($locale); $availableLanguages[$key] = $locale; } } // compare iso with the ez tag for get the name foreach($languageList as $languageItem) { if(isset($availableLanguages[$languageItem])) { $languages[] = array( 'locale' => $availableLanguages[$languageItem], 'name' => $languageTranslations[$languageItem] ); } } } $uri = eZURI::instance(); $uriParams = $uri->UserParameters(); if(isset($uriParams['language'])) $uriLang = $uriParams['language']; if($uriLang){ $this->node->setCurrentLanguage($uriLang); $this->pushResult('current_language', $uriLang); $this->pushResult('node', $this->node); } elseif(in_array($publisherLanguages[0], $availableLanguages)){ if($this->node->currentLanguage() != $publisherLanguages[0]){ $this->node->setCurrentLanguage($publisherLanguages[0]); $this->pushResult('current_language', $publisherLanguages[0]); $this->pushResult('node', $this->node); } } else{ $this->pushResult('current_language' , $this->node->currentLanguage()); $this->pushResult('node', $this->node); } $this->pushResult('languages', $languages); if( SolrSafeOperatorHelper::featureIsActive( 'GoogleAnalytics' ) ) $this->pushResult( 'gtm_variables', $this->getGTMTags( $this->node ) ); $this->pushResult('related_publishers', $this->getRelatedPublishers()); $this->pushResult('related_content', $this->getRelatedContent($this->node)); $this->pushResult('related_content_taxonomy', $this->getCustomParameter('RelatedContentTaxonomy')); return true; }
$resultParameters = BCImageAlias::instance($executionOptions)->createByNodeSubtree($node, $parameters['subtree-params']); } else { /** * Perform create content requests */ $resultParameters = BCImageAlias::instance($executionOptions)->createByObject($node->attribute('object'), $parameters['subtree-params']); } if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'content/browse') === false) { $redirectUrl = $_SERVER['HTTP_REFERER']; } elseif ($node->hasAttribute('url_alias') && $node->attribute('url_alias') != '') { $redirectUrl = $node->attribute('url_alias'); $redirectUrlInstance = eZURI::instance($redirectUrl); $redirectUrlInstance->transformURI($redirectUrl, false, 'full'); } else { $redirectUrl = '/content/view/full/' . $node->attribute('node_id'); $redirectUrlInstance = eZURI::instance($redirectUrl); $redirectUrlInstance->transformURI($redirectUrl, false, 'full'); } if ($parameters['redirect'] != 'default') { //echo $redirectUrl; die(); $http->redirect($redirectUrl); } else { return redirectToContentBrowseModuleView(false, $Module); } } } /** * Pass module view default template parameters * * @param array $parameters Array of parameters. Optional * @param object $module Object of eZModule. Required
private function generateViewParametersString($preSeparator = '', $postSeparator = '') { // taking view parameters and generate a string with them $eZURI = eZURI::instance(eZSys::requestURI()); $viewParametersString = ''; foreach ($eZURI->UserArray as $paramName => $paramValue) { $viewParametersString .= $preSeparator . $paramName . $postSeparator . $paramValue; } return $viewParametersString; }
} $tpl = templateInit(); $ini = eZINI::instance(); $http = eZHTTPTool::instance(); $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 = '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);
public static function view_parameters_php() { $uri = eZURI::instance(); $param = $uri->userParameters(); return $param; }
function modify($tpl, $operatorName, $operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters) { $ini = eZINI::instance('xrowmetadata.ini'); $page_limit = $ini->variable('EditorInputSettings', 'MaxPageLimit'); $uri = eZURI::instance(eZSys::requestURI()); $viewParameters = $uri->UserParameters(); if (count($viewParameters) == 0) { $page_offset = 0; } else { $page_offset = $viewParameters['offset']; } switch ($operatorName) { case 'metadata': if (isset($namedParameters['node_id'])) { $node = eZContentObjectTreeNode::fetch($namedParameters['node_id']); if ($node instanceof eZContentObjectTreeNode) { $cur_parent = $node->fetchParent(); $obj_name = $node->getName(); $obj_count = $node->subTreeCount(array('IgnoreVisibility' => true)); $localbusiness_count = $node->subTreeCount(array('IgnoreVisibility' => true, 'ClassFilterType' => 'include', 'ClassFilterArray' => array('localbusiness'))); $path_array_temp = array_reverse(explode('/', $node->pathWithNames())); $obj_path = implode(' | ', $path_array_temp); $obj_parentname = $cur_parent->Name; $page_count = ceil($localbusiness_count / $page_limit); $page_nr = $page_offset / $page_limit + 1; $page_count_value = ezpI18n::tr('kernel/classes/datatypes', 'page') . " " . $page_nr . "/" . $page_count; $operatorValue = xrowMetaDataFunctions::fetchByObject($node->attribute('object')); if ($operatorValue !== false) { if (isset($operatorValue->title)) { $search_title = $operatorValue->title; $placeholder_title_array = self::getPlaceholders($search_title); if (count($placeholder_title_array) !== 0) { foreach ($placeholder_title_array as $placeholder_title) { switch ($placeholder_title) { case "count": $meta_title = str_replace("[count]", $obj_count, $search_title); continue; case "name": $meta_title = str_replace("[name]", $obj_name, $search_title); continue; case "path": $meta_title = str_replace("[path]", $obj_path, $search_title); continue; case "parentname": $meta_title = str_replace("[parentname]", $obj_parentname, $search_title); continue; case "count:localbusiness": $meta_title = str_replace("[count:localbusiness]", $localbusiness_count, $search_title); continue; case "pagecount": $meta_title = str_replace("[pagecount]", $page_count_value, $search_title); continue; } $search_title = $meta_title; } $operatorValue->title = $search_title; unset($search_title); } } if (isset($operatorValue->description)) { $search_description = $operatorValue->description; $placeholder_title_description = self::getPlaceholders($search_description); if (count($placeholder_title_description) !== 0) { foreach ($placeholder_title_description as $placeholder_description) { switch ($placeholder_description) { case "count": $meta_description = str_replace("[count]", $obj_count, $search_description); continue; case "name": $meta_description = str_replace("[name]", $obj_name, $search_description); continue; case "path": $meta_description = str_replace("[path]", $obj_path, $search_description); continue; case "parentname": $meta_description = str_replace("[parentname]", $obj_parentname, $search_description); continue; case "count:localbusiness": $meta_description = str_replace("[count:localbusiness]", $localbusiness_count, $search_description); continue; case "pagecount": $meta_description = str_replace("[pagecount]", $page_count_value, $search_description); continue; } $search_description = $meta_description; } $operatorValue->description = $search_description; unset($search_description); } } } } else { $operatorValue = false; } } else { $operatorValue = false; } break; } }
/** * Register extensions "the YMC way". * * * @return void * @access public * @author ymc-dabe * @see eZExtension::activateExtensions() * @link http://issues.ez.no/IssueView.php?Id=2709 */ public function registerExtensions($virtual_siteaccess = false) { if (!$this->attribute('is_enabled')) { eZDebug::writeError("The ymcExtensionLoader is disabled, but " . __METHOD__ . " has just been called (which really shouldn't be done)!", __METHOD__); } $siteaccess = self::getCurrentSiteaccess(); $isBasicLoad = true; $is_virtual_load = false; $cache_hit = false; $defaultActiveExtensions = self::$alwaysEnabledExtensions; if (!in_array('ymcextensionloader', $defaultActiveExtensions)) { $defaultActiveExtensions[] = 'ymcextensionloader'; } if ($this->standardLoadingCompleted === true and $virtual_siteaccess !== false and $siteaccess !== $virtual_siteaccess) { if ($this->virtualLoadingCompleted === true) { eZDebug::writeError("Unnecessary call to 'ymcExtensionLoader::registerExtensions('.{$virtual_siteaccess}.')'!", __METHOD__); return; } $siteaccess = $virtual_siteaccess; self::setInternalSiteaccess($siteaccess); eZDebug::accumulatorStart('OpenVolanoExtensionLoader_VirtualSiteaccess', 'OpenVolano: Enhanced Extension Loader', "After virtual siteaccess '{$siteaccess}' initialised "); $isBasicLoad = false; $is_virtual_load = true; $this->rebuildIniOverrideArray($siteaccess, $isBasicLoad); } else { if (null !== $siteaccess) { if ($this->standardLoadingCompleted === true) { eZDebug::writeError("Unnecessary call to " . __METHOD__ . "!", __METHOD__); return; } $isBasicLoad = false; eZDebug::accumulatorStart('OpenVolanoExtensionLoader_Siteaccess', 'OpenVolano: Enhanced Extension Loader', "After siteaccess '{$siteaccess}' initialised "); } else { if (self::$earlyLoadingCompleted === true) { eZDebug::writeWarning("Force registering additional extensions - please keep in mind, that it is not possible to unload extensions", __METHOD__); } eZDebug::accumulatorStart('OpenVolanoExtensionLoader_Basic', 'OpenVolano: Enhanced Extension Loader', 'Pre siteaccess initialised'); } } $ini = eZINI::instance(); $allExtensionsRegistered = false; if ($isBasicLoad) { self::$globalCacheDirectory = eZSys::cacheDirectory(); $cacheFileName = 'basic'; $cache_var_name = 'ymcExtensionLoaderRegisterExtensionBasicLoadInformation'; } else { if ($is_virtual_load) { $cacheFileName = 'siteaccess-' . $this->attribute('non_virtual_siteaccess') . '-virtualsiteaccess-' . $siteaccess; $cache_var_name = 'ymcExtensionLoaderRegisterExtensionVirtualSiteaccessLoadInformation'; } else { $cacheFileName = 'siteaccess-' . $siteaccess; $cache_var_name = 'ymcExtensionLoaderRegisterExtensionSiteaccessLoadInformation'; } } $write_cache = false; $can_write_cache = true; $cacheDir = eZSys::cacheDirectory() . '/openvolano/extensions'; if (!is_writable($cacheDir)) { if (!eZDir::mkdir($cacheDir, 0777, true)) { $can_write_cache = false; eZDebug::writeError("Couldn't create cache directory '{$cacheDir}', perhaps wrong permissions", __METHOD__); } } $cacheFilePath = $cacheDir . '/' . $cacheFileName; if (!file_exists($cacheFilePath)) { $write_cache = $can_write_cache; if ($isBasicLoad) { eZDebug::writeNotice("No cache found for loading basic set of extensions", __METHOD__); } else { eZDebug::writeNotice("No cache found for loading per siteaccess set of extensions for siteaccess '{$siteaccess}'", __METHOD__); } } else { include $cacheFilePath; if (!isset(${$cache_var_name})) { eZDebug::writeWarning("Cache '{$cache_var_name}' in file '{$cacheFilePath}' not found. Trying to force rewrite of this cache file...", __METHOD__); $write_cache = $can_write_cache; } else { eZDebug::writeNotice("Cache hit: {$cacheFilePath}", __METHOD__); $defaultActiveExtensions = ${$cache_var_name}; $cache_hit = true; unset($cache_var_name); } } $additional_lookups = 0; //Loop registering of extensions until all are loaded while (!$allExtensionsRegistered) { //First we asume we do not need to check for new extensions $allExtensionsRegistered = true; //these extensions are always active $activeExtensions = $defaultActiveExtensions; //Get all active extension $activeExtensions = array_unique(array_merge($activeExtensions, eZExtension::activeExtensions())); foreach ($activeExtensions as $activeExtension) { //only activate an extension if it has not been registered, yet if (!in_array($activeExtension, $this->registeredExtensions)) { $this->registeredExtensions[] = $activeExtension; $fullExtensionPath = eZExtension::baseDirectory() . '/' . $activeExtension; if (!file_exists($fullExtensionPath)) { eZDebug::writeWarning("Extension '{$activeExtension}' does not exist, looked for directory '{$fullExtensionPath}'", __METHOD__); } else { $fullExtensionAutoloadPath = $fullExtensionPath . '/autoload'; if ($activeExtension !== 'ymcextensionloader' and !in_array($activeExtension, self::$noAutoloadExtensions) and file_exists($fullExtensionAutoloadPath)) { //add the new extension's autoload-dir to the eZ compontents autoload system (if needed) ezcBase::addClassRepository($fullExtensionPath, $fullExtensionAutoloadPath); } //We are about to activate a new extension which might need to load one ore more other extension (if we do not have a cached info about this) $allExtensionsRegistered = $cache_hit; } } } $this->rebuildIniOverrideArray($siteaccess, $isBasicLoad); if (!$allExtensionsRegistered) { $additional_lookups++; } } if (!$cache_hit) { if ($isBasicLoad) { eZDebug::writeNotice("Loaded all basic extensions in {$additional_lookups} additional lookups...", __METHOD__); } else { if ($is_virtual_load) { eZDebug::writeNotice("Loaded all virtual siteaccess extensions in {$additional_lookups} additional lookups...", __METHOD__); } else { eZDebug::writeNotice("Loaded all siteaccess extensions in {$additional_lookups} additional lookups...", __METHOD__); } } } if ($write_cache) { if ($isBasicLoad) { eZDebug::writeNotice("Storing basic extension load information into cache file '{$cacheFilePath}'...", __METHOD__); } else { if ($is_virtual_load) { eZDebug::writeNotice("Storing virtual siteaccess extension load information into cache file '{$cacheFilePath}'...", __METHOD__); } else { eZDebug::writeNotice("Storing siteaccess extension load information into cache file '{$cacheFilePath}'...", __METHOD__); } } $php = new eZPHPCreator($cacheDir, $cacheFileName); $php->addRawVariable($cache_var_name, $this->registeredExtensions); $php->store(); } if ($is_virtual_load) { $this->virtualLoadingCompleted = true; eZDebug::accumulatorStop('OpenVolanoExtensionLoader_VirtualSiteaccess'); } else { if (!$isBasicLoad) { $this->standardLoadingCompleted = true; $this->non_virtual_siteaccess_name = $siteaccess; eZDebug::accumulatorStop('OpenVolanoExtensionLoader_Siteaccess'); } else { self::$earlyLoadingCompleted = true; eZDebug::accumulatorStop('OpenVolanoExtensionLoader_Basic'); } } //Use the following line to take a look into the ini-hierarchy... //ymc_pr($GLOBALS["eZINIOverrideDirList"], $siteaccess.'|'.self::getCurrentSiteaccess()); if (!$is_virtual_load and !$isBasicLoad and $ini->hasVariable('SiteAccessSettings', 'VirtualSiteaccessSystem') and $ini->variable('SiteAccessSettings', 'VirtualSiteaccessSystem') !== 'disabled') { $allowLoadingOfPreviouslyKnownSiteaccesses = false; if ($ini->hasVariable('SiteAccessSettings', 'VirtualSiteaccessSystem') and $ini->variable('VirtualSiteaccessSettings', 'AllowLoadingOfPerviouslyKnowSiteaccesses') === 'enabled') { $allowLoadingOfPreviouslyKnownSiteaccesses = true; } if (isset($GLOBALS['eZURIRequestInstance']) and is_object($GLOBALS['eZURIRequestInstance'])) { $uri = eZURI::instance(); $elements = $uri->elements(false); if (count($elements) > 0 and $elements[0] != '') { $goInVirtualSiteaccessMode = true; if ($ini->hasVariable('VirtualSiteaccessSettings', 'SkipLoadingForUri') and is_array($ini->variable('VirtualSiteaccessSettings', 'SkipLoadingForUri')) and count($ini->variable('VirtualSiteaccessSettings', 'SkipLoadingForUri')) > 0) { $uri_string = $uri->elements(true); foreach ($ini->variable('VirtualSiteaccessSettings', 'SkipLoadingForUri') as $ignoreUriForVirtualSiteaccess) { if (strpos($uri_string, $ignoreUriForVirtualSiteaccess) === 0) { $goInVirtualSiteaccessMode = false; break; } } unset($uri_string); } } else { $goInVirtualSiteaccessMode = false; } if ($goInVirtualSiteaccessMode) { $matchIndex = 1; $name = $elements[0]; //by ymc-dabe //Code taken from /access.php line 241-249 of eZ publish v4.1.3 //KEEP IT IN SYNC! //start $name = preg_replace(array('/[^a-zA-Z0-9]+/', '/_+/', '/^_/', '/_$/'), array('_', '_', '', ''), $name); //by ymc-dabe //Code taken from /access.php line 241-249 of eZ publush v4.1.3 //KEEP IT IN SYNC! //end if ($allowLoadingOfPreviouslyKnownSiteaccesses or !in_array($name, $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) { eZSys::addAccessPath($name); $uri->increase($matchIndex); $uri->dropBase(); $this->registerExtensions($name); //die if virtual siteaccess is not found if (!in_array($name, $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) { header($_SERVER['SERVER_PROTOCOL'] . " 400 Bad Request"); header("Status: 400 Bad Request"); eZExecution::cleanExit(); } } unset($name); } } else { if (isset($GLOBALS['ymcEnhancedExtensionLoaderVirtualSiteaccess']) and $GLOBALS['ymcEnhancedExtensionLoaderVirtualSiteaccess'] != '') { $virtualSiteaccessName = $GLOBALS['ymcEnhancedExtensionLoaderVirtualSiteaccess']; if ($allowLoadingOfPreviouslyKnownSiteaccesses or !in_array($virtualSiteaccessName, $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) { eZSys::addAccessPath($virtualSiteaccessName); $this->registerExtensions($virtualSiteaccessName); if (!in_array($virtualSiteaccessName, $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) { fputs(STDERR, "\n----------\nError: Invalid siteaccess '{$virtualSiteaccessName}'!\n----------\n\n"); eZExecution::cleanExit(); } } unset($virtualSiteaccessName); } } } else { if ($this->standardLoadingCompleted === true) { $this->virtualLoadingCompleted = true; } } if ($this->standardLoadingCompleted === true) { $this->loadingCompleted = true; if ($this->originalNonVirtualSiteaccessName === false) { $this->originalNonVirtualSiteaccessName = $this->attribute('non_virtual_siteaccess'); if ($this->originalVirtualSiteaccessName === false and $siteaccess != $this->attribute('non_virtual_siteaccess')) { $this->originalVirtualSiteaccessName = $siteaccess; } } } }
/** * Generate cache key array based on current user roles, requested url, layout * * @param $userKeys Array * @return array */ public function getCacheKeysArray($userKeys) { if (!is_array($userKeys)) { $userKeys = array($userKeys); } $user = eZUser::currentUser(); $limitedAssignmentValueList = $user->limitValueList(); $roleList = $user->roleIDList(); $discountList = eZUserDiscountRule::fetchIDListByUserID($user->attribute('contentobject_id')); $currentSiteAccess = isset($GLOBALS['eZCurrentAccess']['name']) ? $GLOBALS['eZCurrentAccess']['name'] : false; $res = eZTemplateDesignResource::instance(); $keys = $res->keys(); $layout = isset($keys['layout']) ? $keys['layout'] : false; $uri = eZURI::instance(eZSys::requestURI()); $actualRequestedURI = $uri->uriString(); $userParameters = $uri->userParameters(); $cacheKeysArray = array('spdf2png', $currentSiteAccess, $layout, $actualRequestedURI, implode('.', $userParameters), implode('.', $roleList), implode('.', $limitedAssignmentValueList), implode('.', $discountList), implode('.', $userKeys)); return $cacheKeysArray; }
/** * Tests an identified error until eZ Publish 4.2: * a cascaded translation (uri => translation1 => translation2) will fail * with a fatal error if the two matching wildcards are located in different * cache files * * Test outline: * 1. Create a wildcard of DIRECT type that translates A to B * 2. Create more than 100 dummy wildcards * 3. Create a wildcard of DIRECT type that translates B to C * * Expected: the test fails at #3 with a fatal error "Cannot redeclare ezurlwilcardcachedtranslate" **/ public function testDoubleTranslation() { // 1. Remove all existing wildcards self::removeAllWildcards(); self::createWildcard("testDoubleTranslation1/*", 'testDoubleTranslation2/{1}', eZURLWildcard::TYPE_DIRECT); // create more than 100 wildcards for ($i = 0; $i <= 100; $i++) { self::createWildcard("testDoubleTranslationDummy{$i}/*", '/', eZURLWildcard::TYPE_DIRECT); } self::createWildcard("testDoubleTranslation2/*", 'testDoubleTranslation3/{1}', eZURLWildcard::TYPE_DIRECT); $uri = eZURI::instance('testDoubleTranslation1/foobar'); // will fail $ret = eZURLWildcard::translate($uri); }
public function htmlBuildResult() { $lessFiles = SolrSafeOperatorHelper::getLessFiles( ($this->app) ? $this->app->applicationObject()->attribute('identifier') : $this->applicationName(), $this->app ); $this->tpl()->setVariable( 'applicationLessFiles', $lessFiles ); if ( !$this->app ) return; if ( $this->app->isFull ) { if ( $this->app->node && $this->app->node instanceof eZContentObjectTreeNode ) { $dataMap = $this->app->node->dataMap(); if($dataMap["serialized_taxonomies"]){ $taxonomies = $dataMap["serialized_taxonomies"]->content(); $publisherPath = $taxonomies["publisher_folder"][0]; $publisherFolder = $this->app->applicationLocalized()->getPublisherFolderFromPath($publisherPath); if (isset($taxonomies['language']) && $publisherFolder instanceof PublisherFolder) { $publisherLanguages = $publisherFolder->getLanguages(); $languageList = $taxonomies['language']; //$languageTranslations = FacetFilteringTool::getTaxonomyTranslation('language'); $availableLanguages = array(); foreach (array_keys($this->app->node->object()->allLanguages()) as $locale) { if (is_array($publisherLanguages) && in_array($locale, $publisherLanguages)) { $key = LocaleTool::languageISO639Code($locale); $availableLanguages[$key] = $locale; } } } $uri = eZURI::instance(); $uriParams = $uri->UserParameters(); if(isset($uriParams['language'])) $uriLang = $uriParams['language']; if ($uriLang) { $this->app->node->setCurrentLanguage($uriLang); } if (in_array($publisherLanguages[0], $availableLanguages)){ if ($this->app->node->currentLanguage() != $publisherLanguages[0]) { $this->app->node->setCurrentLanguage($publisherLanguages[0]); } } } } if ( SolrSafeOperatorHelper::featureIsActive( "SocialSharing" ) && SolrSafeOperatorHelper::feature( "SocialSharing", "EntryExit" ) ) { $this->pushResult( "socialInfos", $this->app->getSocialInfos() ); } if ( $this->app->node instanceof eZContentObjectTreeNode ) $this->pushResult( "current_node", $this->app->node ); } else if ( $this->app->isSeo ) { $goToSpeciality = null; if ( is_null( $this->app->seoParams["speciality"] ) && $this->app->seoParams["noSpeciality"] ) { $goToSpeciality = "all/speciality"; } $this->pushResult( "seoMetas", $this->app->getSeoMetas() ); $this->pushResult( "doSpecialityRedirect", $goToSpeciality ); } }
// 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' ); $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
public function customClassAttributeHTTPAction($http, $action, $classAttribute) { $object = false; preg_match("#^(.*)_([0-9]+)\$#", $action, $matches); if (count($matches) === 3) { $action = $matches[1]; $object = eZContentObject::fetch($matches[2]); } $skipUserIDs = $classAttribute->attribute(self::$definition['skip_user_ids']['field']); $skipUserIDs = explode(',', $skipUserIDs); switch ($action) { case 'browse_user': $ini = eZINI::instance(); $id = $classAttribute->attribute('id'); $uri = eZURI::instance(eZSys::requestURI()); $userClass = eZContentClass::fetch($ini->variable('UserSettings', 'UserClassID')); if ($userClass instanceof eZContentClass === false) { break; } $browseParameters = array('action_name' => 'AddRelatedObjectToDataType', 'browse_custom_action' => array('name' => 'CustomActionButton[' . $id . '_add_user]', 'value' => 'add_user'), 'persistent_data' => array('ContentClassHasInput' => 0), 'from_page' => $uri->originalURIString(), 'start_node' => 5, 'class_array' => array($userClass->attribute('identifier'))); $module = null; $browseURL = eZContentBrowse::browse($browseParameters, $module); eZURI::transformURI($browseURL); $http->redirect($browseURL); break; case 'add_user': if ($http->hasPostVariable('SelectedObjectIDArray') && $http->hasPostVariable('BrowseCancelButton') === false) { $selectedObjectIDs = $http->postVariable('SelectedObjectIDArray'); $selectedObjectID = $selectedObjectIDs[0]; } if (in_array($selectedObjectID, $skipUserIDs) === false) { $skipUserIDs[] = $selectedObjectID; $classAttribute->setAttribute(self::$definition['skip_user_ids']['field'], implode(',', $skipUserIDs)); } break; case 'remove_skip_user': if ($object instanceof eZContentObject) { foreach ($skipUserIDs as $key => $userID) { if ($userID == $object->attribute('id')) { unset($skipUserIDs[$key]); break; } } $classAttribute->setAttribute(self::$definition['skip_user_ids']['field'], implode(',', $skipUserIDs)); } break; } }