/** Executes the needed operator(s). Checks operator names, and calls the appropriate functions. */ function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters) { switch ($operatorName) { case 'eZDebug': $operatorValue = $this->eZdebug($operatorValue, $namedParameters['debuglvl'], $namedParameters['label']); break; case 'objDebug': $operatorValue = $this->objdebug($operatorValue, $namedParameters['show_values'] == 'show', $namedParameters['level']); break; case 'objInspect': require_once 'kernel/common/template.php'; $tpl = templateInit(); $tpl->setVariable('counter', self::$inspectcounter); $exts = eZExtension::activeExtensions(); $wstransport = ''; if (in_array('ezjscore', $exts)) { $wstransport = 'ezjscore'; } else { if (in_array('ggwebservices', $exts)) { $wstransport = 'ggwebservices'; } } $tpl->setVariable('transport', $wstransport); if (class_exists('ezPOInspector')) { $tpl->setVariable('value', json_encode(ezPOInspector::objInspect($operatorValue))); $tpl->setVariable('error', false); } else { $tpl->setVariable('value', null); $tpl->setVariable('error', "Cannot inspect value: extension ezpersistentobject_inspector most likely missing"); } $tpl->setVariable('sort_attributes', $namedParameters['sort_attributes']); $tpl->setVariable('send_to_debug', $namedParameters['send_to_debug']); $operatorValue = $tpl->fetch('design:ezdebug/objinspect.tpl'); if ($namedParameters['send_to_debug']) { // send div to debug output via a debug msg $tpl = templateInit(); $tpl->setVariable('counter', self::$inspectcounter); eZDebug::writeDebug($tpl->fetch('design:ezdebug/objinspectdebugoutput.tpl'), 'objInspect ' . self::$inspectcounter); } self::$inspectcounter++; break; case 'addTimingPoint': eZDebug::addTimingPoint($namedParameters['label']); $operatorValue = ''; break; case 'numQueries': $operatorValue = $this->numqueries($namedParameters['cluster']); break; case 'getDefinedVars': $operatorValue = $this->getDefinedVars($tpl, $namedParameters['namespace'], $rootNamespace, $currentNamespace); break; } }
function parseIntoTree($tpl, &$textElements, &$treeRoot, $rootNamespace, $relatedResource, $relatedTemplateName) { $outerElseTags = array('else' => array('if', 'elseif'), 'section-else' => array('section')); $currentRoot =& $treeRoot; if ($tpl->ShowDetails) { eZDebug::addTimingPoint("Parse pass 3 (build tree)"); } $tagStack = array(); foreach ($textElements as $elementKey => $element) { $elementPlacement = $element['placement']; $startLine = $elementPlacement['start']['line']; $startColumn = $elementPlacement['start']['column']; $startPosition = $elementPlacement['start']['position']; $stopLine = $elementPlacement['stop']['line']; $stopColumn = $elementPlacement['stop']['column']; $stopPosition = $elementPlacement['stop']['position']; $templateFile = $elementPlacement['templatefile']; $placement = array(array($startLine, $startColumn, $startPosition), array($stopLine, $stopColumn, $stopPosition), $templateFile); switch ($element["type"]) { case eZTemplate::ELEMENT_TEXT: unset($node); $node = array(eZTemplate::NODE_TEXT, false, $element['text'], $placement); $this->appendChild($currentRoot, $node); break; case eZTemplate::ELEMENT_VARIABLE: $text = $element["text"]; $text_len = strlen($text); $var_data = $this->ElementParser->parseVariableTag($tpl, $relatedTemplateName, $text, 0, $var_end, $text_len, $rootNamespace); unset($node); $node = array(eZTemplate::NODE_VARIABLE, false, $var_data, $placement); $this->appendChild($currentRoot, $node); if ($var_end < $text_len) { $placement = $element['placement']; $startLine = $placement['start']['line']; $startColumn = $placement['start']['column']; $subText = substr($text, 0, $var_end); $this->gotoEndPosition($subText, $startLine, $startColumn, $currentLine, $currentColumn); $tpl->error("", "parser error @ {$relatedTemplateName}:{$currentLine}" . "[{$currentColumn}]" . "\n" . "Extra characters found in expression, they will be ignored.\n" . substr($text, $var_end, $text_len - $var_end) . "' (" . substr($text, 0, $var_end) . ")", $placement); } break; case eZTemplate::ELEMENT_SINGLE_TAG: case eZTemplate::ELEMENT_NORMAL_TAG: case eZTemplate::ELEMENT_END_TAG: $text = $element["text"]; $text_len = strlen($text); $type = $element["type"]; $ident_pos = $this->ElementParser->identifierEndPosition($tpl, $text, 0, $text_len); $tag = substr($text, 0, $ident_pos - 0); $attr_pos = $ident_pos; unset($args); $args = array(); // special handling for some functions having complex syntax if ($type == eZTemplate::ELEMENT_NORMAL_TAG && in_array($tag, array('if', 'elseif', 'while', 'for', 'foreach', 'def', 'undef', 'set', 'let', 'default', 'set-block', 'append-block', 'section'))) { $attr_pos = $this->ElementParser->whitespaceEndPos($tpl, $text, $attr_pos, $text_len); if ($tag == 'if' || $tag == 'elseif') { $this->parseUnnamedCondition($tag, $args, $tpl, $text, $text_len, $attr_pos, $relatedTemplateName, $startLine, $startColumn, $rootNamespace); } elseif ($tag == 'while') { $this->parseWhileFunction($args, $tpl, $text, $text_len, $attr_pos, $relatedTemplateName, $startLine, $startColumn, $rootNamespace); } elseif ($tag == 'for') { $this->parseForFunction($args, $tpl, $text, $text_len, $attr_pos, $relatedTemplateName, $startLine, $startColumn, $rootNamespace); } elseif ($tag == 'foreach') { $this->parseForeachFunction($args, $tpl, $text, $text_len, $attr_pos, $relatedTemplateName, $startLine, $startColumn, $rootNamespace); } elseif ($tag == 'def' || $tag == 'undef') { $this->parseDefFunction($tag, $args, $tpl, $text, $text_len, $attr_pos, $relatedTemplateName, $startLine, $startColumn, $rootNamespace); } elseif ($tag == 'set' || $tag == 'let' || $tag == 'default') { $this->parseSetFunction($tag, $args, $tpl, $text, $text_len, $attr_pos, $relatedTemplateName, $startLine, $startColumn, $rootNamespace); } elseif ($tag == 'set-block' || $tag == 'append-block') { $this->parseBlockFunction($tag, $args, $tpl, $text, $text_len, $attr_pos, $relatedTemplateName, $startLine, $startColumn, $rootNamespace); } elseif ($tag == 'section') { $this->parseSectionFunction($tag, $args, $tpl, $text, $text_len, $attr_pos, $relatedTemplateName, $startLine, $startColumn, $rootNamespace); } } elseif ($type == eZTemplate::ELEMENT_END_TAG && $tag == 'do') { $this->parseDoFunction($args, $tpl, $text, $text_len, $attr_pos, $relatedTemplateName, $startLine, $startColumn, $rootNamespace); } // other functions having simplier syntax are parsed below $lastPosition = false; while ($attr_pos < $text_len) { if ($lastPosition !== false and $lastPosition == $attr_pos) { break; } $lastPosition = $attr_pos; $attr_pos_start = $this->ElementParser->whitespaceEndPos($tpl, $text, $attr_pos, $text_len); if ($attr_pos_start == $attr_pos and $attr_pos_start < $text_len) { $placement = $element['placement']; $startLine = $placement['start']['line']; $startColumn = $placement['start']['column']; $subText = substr($text, 0, $attr_pos); $this->gotoEndPosition($subText, $startLine, $startColumn, $currentLine, $currentColumn); $tpl->error("", "parser error @ {$relatedTemplateName}:{$currentLine}" . "[{$currentColumn}]" . "\n" . "Extra characters found, should have been a whitespace or the end of the expression\n" . "Characters: '" . substr($text, $attr_pos) . "'"); break; } $attr_pos = $attr_pos_start; $attr_name_pos = $this->ElementParser->identifierEndPosition($tpl, $text, $attr_pos, $text_len); $attr_name = substr($text, $attr_pos, $attr_name_pos - $attr_pos); /* Skip whitespace between here and the next one */ $equal_sign_pos = $this->ElementParser->whitespaceEndPos($tpl, $text, $attr_name_pos, $text_len); if ($equal_sign_pos < $text_len && $text[$equal_sign_pos] == '=') { $attr_name_pos = $equal_sign_pos; } if ($attr_name_pos >= $text_len or $text[$attr_name_pos] != '=' and preg_match("/[ \t\r\n]/", $text[$attr_name_pos])) { unset($var_data); $var_data = array(); $var_data[] = array(eZTemplate::TYPE_NUMERIC, true, false); $args[$attr_name] = $var_data; $attr_pos = $attr_name_pos; continue; } if ($text[$attr_name_pos] != "=") { $placement = $element['placement']; $startLine = $placement['start']['line']; $startColumn = $placement['start']['column']; $subText = substr($text, 0, $attr_name_pos); $this->gotoEndPosition($subText, $startLine, $startColumn, $currentLine, $currentColumn); $tpl->error("", "parser error @ {$relatedTemplateName}:{$currentLine}" . "[{$currentColumn}]\n" . "Invalid parameter characters in function '{$tag}': '" . substr($text, $attr_name_pos) . "'"); break; } ++$attr_name_pos; unset($var_data); $var_data = $this->ElementParser->parseVariableTag($tpl, $relatedTemplateName, $text, $attr_name_pos, $var_end, $text_len, $rootNamespace); $args[$attr_name] = $var_data; $attr_pos = $var_end; } if ($type == eZTemplate::ELEMENT_END_TAG and count($args) > 0) { if ($tag != 'do') { $placement = $element['placement']; $startLine = $placement['start']['line']; $startColumn = $placement['start']['column']; $tpl->error("", "parser error @ {$relatedTemplateName}:{$startLine}" . "[{$startColumn}]" . "\n" . "End tag \"{$tag}\" cannot have attributes\n{$tpl->LDelim}/" . $text . $tpl->RDelim, $element['placement']); $args = array(); } } if ($type == eZTemplate::ELEMENT_NORMAL_TAG) { $ignoreCurrentTag = false; if (in_array($tag, array_keys($outerElseTags))) { unset($oldTag); unset($oldTagName); $oldTag = end($tagStack); $oldTagName = $oldTag["Tag"]; $ignoreCurrentTag = true; if (in_array($oldTagName, $outerElseTags[$tag])) { $ignoreCurrentTag = false; } else { // checking for 'if' in stack $tagBackStack = $tagStack; $lastIfKey = false; foreach ($tagBackStack as $prevTagKey => $prevTag) { if (in_array($prevTag['Tag'], $outerElseTags[$tag])) { $lastIfKey = $prevTagKey; } } if ($lastIfKey !== false) { // checking for later tags (search for closing tag) $laterElements = array_slice($textElements, $elementKey + 1); $laterStack = array(); foreach ($laterElements as $laterElement) { if ($laterElement['type'] == eZTemplate::ELEMENT_NORMAL_TAG) { if (!in_array($laterElement['name'], array_keys($outerElseTags))) { $laterStack[] = $laterElement['name']; } else { if ($laterStack === array()) { break; // double else (current else will be ignored) } } } elseif ($laterElement['type'] == eZTemplate::ELEMENT_END_TAG) { if ($laterStack !== array()) { if (array_pop($laterStack) !== $laterElement['name']) { break; // later tags mismatch (current else will be ignored) } } else { if ($laterElement['name'] == $oldTagName) { break; // previous tag correctly closed (current else will be ignored) } elseif (in_array($laterElement['name'], $outerElseTags[$tag])) { $ignoreCurrentTag = false; break; // 'if' tag correctly closed (inner tags must be closed too) } } } } } $place = $element['placement']; $startLine = $place['start']['line']; $startColumn = $place['start']['column']; if ($ignoreCurrentTag) { $tpl->error("", "parser error @ {$relatedTemplateName}:{$startLine}" . "[{$startColumn}]" . "\n" . "Unterminated tag \"{$oldTagName}\" does not match tag \"{$tag}\". \"{$tag}\" will be ignored.", $element['placement']); } else { unset($currentRoot); $lastIfKey++; $currentRoot =& $tagStack[$lastIfKey]["Root"]; $autoTerminatedTags = array_slice($tagStack, $lastIfKey); $autoTerminatedTagNames = array(); foreach ($autoTerminatedTags as $autoTerminatedTag) { $autoTerminatedTagNames[] = $autoTerminatedTag["Tag"]; } $tagStack = array_slice($tagStack, 0, $lastIfKey); $tpl->error("", "parser error @ {$relatedTemplateName}:{$startLine}" . "[{$startColumn}]" . "\n" . "Unterminated tag \"" . implode("\", \"", $autoTerminatedTagNames) . "\" does not match tag \"{$tag}\" and will be autoterminated.", $element['placement']); unset($autoTerminatedTags); unset($autoTerminatedTagNames); } unset($lastIfKey); } } if (!$ignoreCurrentTag) { unset($node); $node = array(eZTemplate::NODE_FUNCTION, false, $tag, $args, $placement); $this->appendChild($currentRoot, $node); $has_children = true; if (isset($tpl->FunctionAttributes[$tag])) { if (is_array($tpl->FunctionAttributes[$tag])) { $tpl->loadAndRegisterFunctions($tpl->FunctionAttributes[$tag]); } $has_children = $tpl->FunctionAttributes[$tag]; } else { if (isset($tpl->Functions[$tag])) { if (is_array($tpl->Functions[$tag])) { $tpl->loadAndRegisterFunctions($tpl->Functions[$tag]); } $has_children = $tpl->hasChildren($tpl->Functions[$tag], $tag); } } if ($has_children) { $tagStack[] = array("Root" => &$currentRoot, "Tag" => $tag); unset($currentRoot); $currentRoot =& $node; } } } else { if ($type == eZTemplate::ELEMENT_END_TAG) { $has_children = true; if (isset($tpl->FunctionAttributes[$tag])) { if (is_array($tpl->FunctionAttributes[$tag])) { $tpl->loadAndRegisterFunctions($tpl->FunctionAttributes[$tag]); } $has_children = $tpl->FunctionAttributes[$tag]; } else { if (isset($tpl->Functions[$tag])) { if (is_array($tpl->Functions[$tag])) { $tpl->loadAndRegisterFunctions($tpl->Functions[$tag]); } $has_children = $tpl->hasChildren($tpl->Functions[$tag], $tag); } } if (!$has_children) { $placement = $element['placement']; $startLine = $placement['start']['line']; $startColumn = $placement['start']['column']; $tpl->error("", "parser error @ {$relatedTemplateName}:{$startLine}" . "[{$startColumn}]" . "\n" . "End tag \"{$tag}\" for function which does not accept children, ignoring tag", $element['placement']); } else { unset($oldTag); unset($oldTagName); $oldTag = array_pop($tagStack); $oldTagName = $oldTag["Tag"]; unset($currentRoot); $currentRoot =& $oldTag["Root"]; if ($oldTagName != $tag) { $placement = $element['placement']; $startLine = $placement['start']['line']; $startColumn = $placement['start']['column']; $tpl->error("", "parser error @ {$relatedTemplateName}:{$startLine}" . "[{$startColumn}]" . "\n" . "Unterminated tag \"{$oldTagName}\" does not match tag \"{$tag}\"", $element['placement']); } // a dirty hack to pass arguments specified in {/do} to the corresponding function. if ($tag == 'do') { $doOpenTag =& $currentRoot[1][count($currentRoot[1]) - 1]; $doOpenTag[3] =& $args; } } } else { unset($node); $node = array(eZTemplate::NODE_FUNCTION, false, $tag, $args, $placement); $this->appendChild($currentRoot, $node); } } unset($tag); break; } } if ($tpl->ShowDetails) { eZDebug::addTimingPoint("Parse pass 3 done"); } }
* @package ezmbpaex */ $mbpaexIni = eZINI::instance('mbpaex.ini'); // Fetch the user to use in the process $updateChildrenUser = $mbpaexIni->variable('mbpaexSettings', 'UpdateChildrenUser'); // Default to admin if user is not found in the ini if (!trim($updateChildrenUser)) { $updateChildrenUser = '******'; } $user = eZUser::fetchByName($updateChildrenUser); eZUser::setCurrentlyLoggedInUser($user, $user->attribute('contentobject_id')); if ($user->isLoggedIn()) { $cli->output("eZPaEx: Update children process start"); ini_set('max_execution_time', 0); ini_set('memory_limit', '-1'); eZDebug::addTimingPoint('Fetch update pending list'); // Get list of paex objects marked to updatechildren $pendingList = eZPaEx::fetchUpdateChildrenPendingList(); $pendingListCount = count($pendingList); if (!$pendingListCount) { $cli->output("No pending update subtrees found"); } else { $cli->output("Found " . $pendingListCount . " ezpaex objects with pending updatechildren"); $pendingIdList = array(); foreach ($pendingList as $pendingObject) { $pendingIdList[] = $pendingObject->attribute('contentobject_id'); } // Fetch array of nodes corresponding to objects in the pendingIDList to sort them by depth $nodeArray = eZContentObjectTreeNode::findMainNodeArray($pendingIdList, false); // Make an array of objects ids with its deph based on the corresponding node $objectDepthList = array();
* @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. * @package ezmbpaex */ $cli->output("eZPaEx: Send expiry notifications process start"); ini_set('max_execution_time', 0); ini_set('memory_limit', '-1'); eZDebug::addTimingPoint('Fetch notification pending list'); $paexPendingList = eZPaEx::fetchExpiryNotificationPendingList(); $paexPendingListCount = count($paexPendingList); if (!$paexPendingListCount) { $cli->output("No pending update notifications found"); } else { $cli->output("Found " . $paexPendingListCount . " objects pending notification, send notifications:"); $totalNotificationsSent = 0; eZDebug::addTimingPoint('Send notifications'); foreach ($paexPendingList as $paexObject) { $userID = $paexObject->attribute('contentobject_id'); $userObject = eZUser::fetch($userID); if ($userObject instanceof eZUser && $userObject->isEnabled()) { if (!$paexObject->sendExpiryNotification($userObject)) { $cli->output("Error sending notification. UserID: " . $userID); } else { $cli->output("Notification sent ok. UserID: " . $userID); $paexObject->setExpiryNotificationSent(); $totalNotificationsSent++; } } else { $cli->output("Error user_object disabled or not found. UserID: " . $userID); } }
function process($tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace) { switch ($functionName) { case $this->TimingPointName: $children = $functionChildren; $parameters = $functionParameters; $id = false; if (isset($parameters["id"])) { $id = $tpl->elementValue($parameters["id"], $rootNamespace, $currentNamespace, $functionPlacement); } $startDescription = "debug-timing-point START: {$id}"; eZDebug::addTimingPoint($startDescription); if (is_array($children)) { foreach (array_keys($children) as $childKey) { $child =& $children[$childKey]; $tpl->processNode($child, $textElements, $rootNamespace, $currentNamespace); } } $endDescription = "debug-timing-point END: {$id}"; eZDebug::addTimingPoint($endDescription); break; case $this->AccumulatorName: $children = $functionChildren; $parameters = $functionParameters; $id = false; if (isset($parameters["id"])) { $id = $tpl->elementValue($parameters["id"], $rootNamespace, $currentNamespace, $functionPlacement); } $name = false; if (isset($parameters["name"])) { $name = $tpl->elementValue($parameters["name"], $rootNamespace, $currentNamespace, $functionPlacement); } // Assign a name (as $functionName) which will be used in the debug output. $name = ($name === false and $id === false) ? $functionName : $name; // To uniquely identify this accumulator. $id = $id === false ? uniqID($functionName . '_') : $id; eZDebug::accumulatorStart($id, 'Debug-Accumulator', $name); if (is_array($children)) { foreach (array_keys($children) as $childKey) { $child =& $children[$childKey]; $tpl->processNode($child, $textElements, $rootNamespace, $currentNamespace); } } eZDebug::accumulatorStop($id); break; case $this->LogName: $parameters = $functionParameters; if (isset($parameters['var'])) { $var = $tpl->elementValue($parameters['var'], $rootNamespace, $currentNamespace, $functionPlacement); } if (isset($parameters['msg'])) { $msg = $tpl->elementValue($parameters['msg'], $rootNamespace, $currentNamespace, $functionPlacement); } if (isset($var) && isset($msg)) { eZDebug::writeDebug($var, $msg); } elseif (isset($msg)) { eZDebug::writeDebug($msg); } elseif (isset($var)) { eZDebug::writeDebug($var); } break; case $this->TraceName: $children = $functionChildren; $id = false; // If we have XDebug we start the trace, execute children and stop it // if not we just execute the children as normal if (extension_loaded('xdebug')) { $parameters = $functionParameters; if (isset($parameters["id"])) { $id = $tpl->elementValue($parameters["id"], $rootNamespace, $currentNamespace, $functionPlacement); } if (!$id) { $id = 'template-debug'; } // If we already have a file, make sure it is truncated if (file_exists($id . '.xt')) { $fd = fopen($id, '.xt', 'w'); fclose($fd); } xdebug_start_trace($id); if (is_array($children)) { foreach (array_keys($children) as $childKey) { $child =& $children[$childKey]; $tpl->processNode($child, $textElements, $rootNamespace, $currentNamespace); } } xdebug_stop_trace(); } elseif (is_array($children)) { foreach (array_keys($children) as $childKey) { $child =& $children[$childKey]; $tpl->processNode($child, $textElements, $rootNamespace, $currentNamespace); } } break; } }
$scriptFile = $scriptDirectory . '/' . $cronScript; if (file_exists($scriptFile)) { break; } } if (file_exists($scriptFile)) { if ($index > 0) { $cli->output(); } if (!$isQuiet) { $startTime = new eZDateTime(); $cli->output('Running ' . $cli->stylize('emphasize', $scriptFile) . ' at: ' . $startTime->toString(true)); } eZDebug::addTimingPoint("Script {$scriptFile} starting"); eZRunCronjobs::runScript($cli, $scriptFile); eZDebug::addTimingPoint("Script {$scriptFile} done"); ++$index; // The transaction check $transactionCounterCheck = eZDB::checkTransactionCounter(); if (isset($transactionCounterCheck['error'])) { $cli->error($transactionCounterCheck['error']); } if (!$isQuiet) { $endTime = new eZDateTime(); $cli->output('Completing ' . $cli->stylize('emphasize', $scriptFile) . ' at: ' . $endTime->toString(true)); $elapsedTime = new eZTime($endTime->timeStamp() - $startTime->timeStamp()); $cli->output('Elapsed time: ' . sprintf('%02d:%02d:%02d', $elapsedTime->hour(), $elapsedTime->minute(), $elapsedTime->second())); } } } $script->shutdown();
/** * Adds the timing point if the condition $conditionName is enabled. * * @param string $conditionName Name of the condition * @param string $label Optional label */ static function addTimingPoint( $conditionName, $label = "" ) { if ( !eZDebugSetting::isConditionTrue( $conditionName, eZDebug::LEVEL_TIMING_POINT ) ) return false; eZDebug::addTimingPoint( eZDebugSetting::changeLabel( $conditionName, $label ) ); }
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; }
$show_page_layout = "pagelayout.tpl"; } // Set the navigation part // Check for navigation part settings $navigationPartString = 'ezcontentnavigationpart'; if (isset($moduleResult['navigation_part'])) { $navigationPartString = $moduleResult['navigation_part']; // Fetch the navigation part } $navigationPart = eZNavigationPart::fetchPartByIdentifier($navigationPartString); $tpl->setVariable('navigation_part', $navigationPart); $tpl->setVariable('uri_string', $uri->uriString()); if (isset($moduleResult['requested_uri_string'])) { $tpl->setVariable('requested_uri_string', $moduleResult['requested_uri_string']); } else { $tpl->setVariable('requested_uri_string', $actualRequestedURI); } // Set UI context and component $tpl->setVariable('ui_context', $moduleResult['ui_context']); $tpl->setVariable('ui_component', $moduleResult['ui_component']); $templateResult = $tpl->fetch($resource . $show_page_layout); } else { $templateResult = $moduleResult['content']; } eZDebug::addTimingPoint("Script end"); $out = ob_get_clean(); echo trim($out); eZDB::checkTransactionCounter(); eZDisplayResult($templateResult); eZExecution::cleanup(); eZExecution::setCleanExit();
function fetch($template = false, $extraParameters = false, $returnResourceData = false) { $this->resetErrorLog(); // Reset fetch list when a new fetch is started $this->TemplateFetchList = array(); eZDebug::accumulatorStart('template_total'); eZDebug::accumulatorStart('template_load', 'template_total', 'Template load'); $root = null; if (is_string($template)) { $resourceData = $this->loadURIRoot($template, true, $extraParameters); if ($resourceData and $resourceData['root-node'] !== null) { $root =& $resourceData['root-node']; } } eZDebug::accumulatorStop('template_load'); if ($resourceData['locales'] && !empty($resourceData['locales'])) { $savedLocale = setlocale(LC_CTYPE, null); setlocale(LC_CTYPE, $resourceData['locales']); } $text = ""; if ($root !== null or $resourceData['compiled-template']) { if ($this->ShowDetails) { eZDebug::addTimingPoint("Process"); } eZDebug::accumulatorStart('template_processing', 'template_total', 'Template processing'); $templateCompilationUsed = false; if ($resourceData['compiled-template']) { $textElements = array(); if ($this->executeCompiledTemplate($resourceData, $textElements, "", "", $extraParameters)) { $text = implode('', $textElements); $templateCompilationUsed = true; } } if (!$templateCompilationUsed) { if (eZTemplate::isDebugEnabled()) { $fname = $resourceData['template-filename']; eZDebug::writeDebug("FETCH START URI: {$template}, {$fname}"); } $this->process($root, $text, "", ""); if (eZTemplate::isDebugEnabled()) { eZDebug::writeDebug("FETCH END URI: {$template}, {$fname}"); } } eZDebug::accumulatorStop('template_processing'); if ($this->ShowDetails) { eZDebug::addTimingPoint("Process done"); } } eZDebug::accumulatorStop('template_total'); if ($resourceData['locales'] && !empty($resourceData['locales'])) { setlocale(LC_CTYPE, $savedLocale); } if ($returnResourceData) { $resourceData['result_text'] = $text; return $resourceData; } return $text; }
} // Set the navigation part // Check for navigation part settings $navigationPartString = 'ezcontentnavigationpart'; if (isset($moduleResult['navigation_part'])) { $navigationPartString = $moduleResult['navigation_part']; // Fetch the navigation part } $navigationPart = eZNavigationPart::fetchPartByIdentifier($navigationPartString); $tpl->setVariable('navigation_part', $navigationPart); $tpl->setVariable('uri_string', $uri->uriString()); if (isset($moduleResult['requested_uri_string'])) { $tpl->setVariable('requested_uri_string', $moduleResult['requested_uri_string']); } else { $tpl->setVariable('requested_uri_string', $actualRequestedURI); } // Set UI context and component $tpl->setVariable('ui_context', $moduleResult['ui_context']); $tpl->setVariable('ui_component', $moduleResult['ui_component']); $templateResult = $tpl->fetch($resource . $show_page_layout); } } else { $templateResult = $moduleResult['content']; } eZDebug::addTimingPoint("End"); $out = ob_get_clean(); echo trim($out); eZDB::checkTransactionCounter(); eZDisplayResult($templateResult); eZExecution::cleanup(); eZExecution::setCleanExit();