| 1 | <?php |
| 2 | /** |
| 3 | * @copyright Copyright (C) 1999-2011 eZ Systems AS. All rights reserved. |
| 4 | * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 |
| 5 | * @version 2011.7 |
| 6 | * @package kernel |
| 7 | */ |
| 8 | |
| 9 | /** |
| 10 | * PHP 5.2 is our hard requirement |
| 11 | */ |
| 12 | if ( version_compare( PHP_VERSION, '5.2' ) < 0 ) |
| 13 | { |
| 14 | print( "<h1>Unsupported PHP version " . PHP_VERSION . "</h1>" ); |
| 15 | print( "<p>eZ Publish 4.x does not run with PHP version lower than 5.2.</p>". |
| 16 | "<p>For more information about supported software please visit ". |
| 17 | "<a href=\"http://ez.no/download/ez_publish\" >eZ Publish download page</a></p>" ); |
| 18 | exit; |
| 19 | } |
| 20 | |
| 21 | // Set a default time zone if none is given to avoid "It is not safe to rely |
| 22 | // on the system's timezone settings" warnings. The time zone can be overriden |
| 23 | // in config.php or php.ini. |
| 24 | if ( !ini_get( "date.timezone" ) ) |
| 25 | { |
| 26 | date_default_timezone_set( "UTC" ); |
| 27 | } |
| 28 | |
| 29 | require 'autoload.php'; |
| 30 | |
| 31 | ignore_user_abort( true ); |
| 32 | |
| 33 | $scriptStartTime = microtime( true ); |
| 34 | ob_start(); |
| 35 | |
| 36 | $use_external_css = true; |
| 37 | $show_page_layout = true; |
| 38 | $moduleRunRequired = true; |
| 39 | $policyCheckRequired = true; |
| 40 | $urlTranslatorAllowed = true; |
| 41 | $validityCheckRequired = false; |
| 42 | $userObjectRequired = true; |
| 43 | $sessionRequired = true; |
| 44 | $dbRequired = true; |
| 45 | $noCacheAdviced = false; |
| 46 | |
| 47 | $siteDesignOverride = false; |
| 48 | |
| 49 | // List of module names which will skip policy checking |
| 50 | $policyCheckOmitList = array(); |
| 51 | |
| 52 | // List of directories to search for modules |
| 53 | $moduleRepositories = array(); |
| 54 | |
| 55 | $siteBasics = array(); |
| 56 | $siteBasics['external-css'] =& $use_external_css; |
| 57 | $siteBasics['show-page-layout'] =& $show_page_layout; |
| 58 | $siteBasics['module-run-required'] =& $moduleRunRequired; |
| 59 | $siteBasics['policy-check-required'] =& $policyCheckRequired; |
| 60 | $siteBasics['policy-check-omit-list'] =& $policyCheckOmitList; |
| 61 | $siteBasics['url-translator-allowed'] =& $urlTranslatorAllowed; |
| 62 | $siteBasics['validity-check-required'] =& $validityCheckRequired; |
| 63 | $siteBasics['user-object-required'] =& $userObjectRequired; |
| 64 | $siteBasics['session-required'] =& $sessionRequired; |
| 65 | $siteBasics['db-required'] =& $dbRequired; |
| 66 | $siteBasics['no-cache-adviced'] =& $noCacheAdviced; |
| 67 | $siteBasics['site-design-override'] =& $siteDesignOverride; |
| 68 | |
| 69 | $siteBasics['module-repositories'] =& $moduleRepositories; |
| 70 | |
| 71 | $GLOBALS['eZSiteBasics'] =& $siteBasics; |
| 72 | |
| 73 | $GLOBALS['eZRedirection'] = false; |
| 74 | |
| 75 | error_reporting ( E_ALL | E_STRICT ); |
| 76 | |
| 77 | /*! |
| 78 | Reads settings from site.ini and passes them to eZDebug. |
| 79 | */ |
| 80 | function eZUpdateDebugSettings() |
| 81 | { |
| 82 | $ini = eZINI::instance(); |
| 83 | |
| 84 | $settings = array(); |
| 85 | list( $settings['debug-enabled'], $settings['debug-by-ip'], $settings['log-only'], $settings['debug-by-user'], $settings['debug-ip-list'], $logList, $settings['debug-user-list'] ) = |
| 86 | $ini->variableMulti( 'DebugSettings', |
| 87 | array( 'DebugOutput', 'DebugByIP', 'DebugLogOnly', 'DebugByUser', 'DebugIPList', 'AlwaysLog', 'DebugUserIDList' ), |
| 88 | array( 'enabled', 'enabled', 'disabled', 'enabled' ) ); |
| 89 | $logMap = array( 'notice' => eZDebug::LEVEL_NOTICE, |
| 90 | 'warning' => eZDebug::LEVEL_WARNING, |
| 91 | 'error' => eZDebug::LEVEL_ERROR, |
| 92 | 'debug' => eZDebug::LEVEL_DEBUG, |
| 93 | 'strict' => eZDebug::LEVEL_STRICT ); |
| 94 | $settings['always-log'] = array(); |
| 95 | foreach ( $logMap as $name => $level ) |
| 96 | { |
| 97 | $settings['always-log'][$level] = in_array( $name, $logList ); |
| 98 | } |
| 99 | eZDebug::updateSettings( $settings ); |
| 100 | } |
| 101 | |
| 102 | /*! |
| 103 | Reads settings from i18n.ini and passes them to eZTextCodec. |
| 104 | */ |
| 105 | function eZUpdateTextCodecSettings() |
| 106 | { |
| 107 | $ini = eZINI::instance( 'i18n.ini' ); |
| 108 | |
| 109 | list( $i18nSettings['internal-charset'], $i18nSettings['http-charset'], $i18nSettings['mbstring-extension'] ) = |
| 110 | $ini->variableMulti( 'CharacterSettings', array( 'Charset', 'HTTPCharset', 'MBStringExtension' ), array( false, false, 'enabled' ) ); |
| 111 | |
| 112 | eZTextCodec::updateSettings( $i18nSettings ); |
| 113 | } |
| 114 | |
| 115 | // Initialize text codec settings |
| 116 | eZUpdateTextCodecSettings(); |
| 117 | |
| 118 | // Initialize debug settings. |
| 119 | eZUpdateDebugSettings(); |
| 120 | |
| 121 | |
| 122 | // Set the different permissions/settings. |
| 123 | $ini = eZINI::instance(); |
| 124 | |
| 125 | // Set correct site timezone |
| 126 | $timezone = $ini->variable( "TimeZoneSettings", "TimeZone"); |
| 127 | if ( $timezone ) |
| 128 | { |
| 129 | date_default_timezone_set( $timezone ); |
| 130 | } |
| 131 | |
| 132 | |
| 133 | list( $iniFilePermission, $iniDirPermission ) = |
| 134 | $ini->variableMulti( 'FileSettings', array( 'StorageFilePermissions', 'StorageDirPermissions' ) ); |
| 135 | |
| 136 | $iniVarDirectory = eZSys::cacheDirectory() ; |
| 137 | |
| 138 | // OPTIMIZATION: |
| 139 | // Sets permission array as global variable, this avoids the eZCodePage include |
| 140 | $GLOBALS['EZCODEPAGEPERMISSIONS'] = array( 'file_permission' => octdec( $iniFilePermission ), |
| 141 | 'dir_permission' => octdec( $iniDirPermission ), |
| 142 | 'var_directory' => $iniVarDirectory ); |
| 143 | |
| 144 | // |
| 145 | $warningList = array(); |
| 146 | |
| 147 | /*! |
| 148 | Appends a new warning item to the warning list. |
| 149 | \a $parameters must contain a \c error and \c text key. |
| 150 | */ |
| 151 | function eZAppendWarningItem( $parameters = array() ) |
| 152 | { |
| 153 | global $warningList; |
| 154 | $parameters = array_merge( array( 'error' => false, |
| 155 | 'text' => false, |
| 156 | 'identifier' => false ), |
| 157 | $parameters ); |
| 158 | $error = $parameters['error']; |
| 159 | $text = $parameters['text']; |
| 160 | $identifier = $parameters['identifier']; |
| 161 | $warningList[] = array( 'error' => $error, |
| 162 | 'text' => $text, |
| 163 | 'identifier' => $identifier ); |
| 164 | } |
| 165 | |
| 166 | function eZDBCleanup() |
| 167 | { |
| 168 | if ( class_exists( 'eZDB' ) |
| 169 | and eZDB::hasInstance() ) |
| 170 | { |
| 171 | $db = eZDB::instance(); |
| 172 | $db->setIsSQLOutputEnabled( false ); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | function eZFatalError() |
| 177 | { |
| 178 | header("HTTP/1.1 500 Internal Server Error"); |
| 179 | print( "<b>Fatal error</b>: eZ Publish did not finish its request<br/>" ); |
| 180 | if ( ini_get('display_errors') == 1 ) |
| 181 | { |
| 182 | if ( eZDebug::isDebugEnabled() ) |
| 183 | print( "<p>The execution of eZ Publish was abruptly ended, the debug output is present below.</p>" ); |
| 184 | else |
| 185 | print( "<p>The execution of eZ Publish was abruptly ended, debug information can be found in the log files normally placed in var/log/* or by enabling 'DebugOutput'</p>" ); |
| 186 | } |
| 187 | else |
| 188 | { |
| 189 | print( "<p>The execution of eZ Publish was abruptly ended. Contact website owner with current url and what you did, and owner will be able to debug the issue further(by enabling 'display_errors' and optionally 'DebugOutput').</p>" ); |
| 190 | } |
| 191 | $templateResult = null; |
| 192 | eZDisplayResult( $templateResult ); |
| 193 | } |
| 194 | |
| 195 | eZExecution::addCleanupHandler( 'eZDBCleanup' ); |
| 196 | eZExecution::addFatalErrorHandler( 'eZFatalError' ); |
| 197 | |
| 198 | eZDebug::setScriptStart( $scriptStartTime ); |
| 199 | |
| 200 | // Enable this line to get eZINI debug output |
| 201 | // eZINI::setIsDebugEnabled( true ); |
| 202 | // Enable this line to turn off ini caching |
| 203 | // eZINI::setIsCacheEnabled( false); |
| 204 | |
| 205 | function eZDisplayDebug() |
| 206 | { |
| 207 | $ini = eZINI::instance(); |
| 208 | |
| 209 | if ( $ini->variable( 'DebugSettings', 'DebugOutput' ) != 'enabled' ) |
| 210 | return null; |
| 211 | |
| 212 | $type = $ini->variable( "DebugSettings", "Debug" ); |
| 213 | //eZDebug::setHandleType( eZDebug::HANDLE_NONE ); |
| 214 | if ( $type == "inline" or $type == "popup" ) |
| 215 | { |
| 216 | $as_html = true; |
| 217 | |
| 218 | if ( $ini->variable( "DebugSettings", "DebugToolbar" ) == 'enabled' && |
| 219 | $ini->variable( "SiteAccessSettings", "CheckValidity" ) !== 'true' && |
| 220 | $as_html == true && |
| 221 | !$GLOBALS['eZRedirection'] ) |
| 222 | |
| 223 | { |
| 224 | $tpl = eZTemplate::factory(); |
| 225 | $result = "<tr><td>" . $tpl->fetch( 'design:setup/debug_toolbar.tpl' ) . "</td></tr>"; |
| 226 | eZDebug::appendTopReport( "Debug toolbar", $result ); |
| 227 | } |
| 228 | |
| 229 | eZDebug::appendBottomReport( 'Template Usage Statistics', eZTemplatesStatisticsReporter::generateStatistics( $as_html ) ); |
| 230 | |
| 231 | return eZDebug::printReport( $type == "popup", $as_html, true ); |
| 232 | } |
| 233 | return null; |
| 234 | } |
| 235 | |
| 236 | /*! |
| 237 | \private |
| 238 | */ |
| 239 | function eZDisplayResult( $templateResult ) |
| 240 | { |
| 241 | if ( $templateResult !== null ) |
| 242 | { |
| 243 | $classname = eZINI::instance()->variable( "OutputSettings", "OutputFilterName" );//deprecated |
| 244 | if( !empty( $classname ) && class_exists( $classname ) ) |
| 245 | { |
| 246 | $templateResult = call_user_func( array ( $classname, 'filter' ), $templateResult ); |
| 247 | } |
| 248 | $templateResult = ezpEvent::getInstance()->filter('response/output', $templateResult ); |
| 249 | $debugMarker = '<!--DEBUG_REPORT-->'; |
| 250 | $pos = strpos( $templateResult, $debugMarker ); |
| 251 | if ( $pos !== false ) |
| 252 | { |
| 253 | $debugMarkerLength = strlen( $debugMarker ); |
| 254 | echo substr( $templateResult, 0, $pos ); |
| 255 | eZDisplayDebug(); |
| 256 | echo substr( $templateResult, $pos + $debugMarkerLength ); |
| 257 | } |
| 258 | else |
| 259 | { |
| 260 | echo $templateResult, eZDisplayDebug(); |
| 261 | } |
| 262 | } |
| 263 | else |
| 264 | { |
| 265 | eZDisplayDebug(); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | function fetchModule( $uri, $check, &$module, &$module_name, &$function_name, &$params ) |
| 270 | { |
| 271 | $module_name = $uri->element(); |
| 272 | if ( $check !== null and isset( $check["module"] ) ) |
| 273 | $module_name = $check["module"]; |
| 274 | |
| 275 | // Try to fetch the module object |
| 276 | $module = eZModule::exists( $module_name ); |
| 277 | if ( !( $module instanceof eZModule ) ) |
| 278 | { |
| 279 | return false; |
| 280 | } |
| 281 | |
| 282 | $uri->increase(); |
| 283 | $function_name = ""; |
| 284 | if ( !$module->singleFunction() ) |
| 285 | { |
| 286 | $function_name = $uri->element(); |
| 287 | $uri->increase(); |
| 288 | } |
| 289 | // Override it if required |
| 290 | if ( $check !== null and isset( $check["function"] ) ) |
| 291 | $function_name = $check["function"]; |
| 292 | |
| 293 | $params = $uri->elements( false ); |
| 294 | return true; |
| 295 | } |
| 296 | |
| 297 | $httpCharset = eZTextCodec::httpCharset(); |
| 298 | if ( $ini->variable( 'RegionalSettings', 'Debug' ) == 'enabled' ) |
| 299 | eZLocale::setIsDebugEnabled( true ); |
| 300 | |
| 301 | |
| 302 | eZDebug::setHandleType( eZDebug::HANDLE_FROM_PHP ); |
| 303 | |
| 304 | $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable( 'REQUEST_URI' ); |
| 305 | |
| 306 | // Initialize basic settings, such as vhless dirs and separators |
| 307 | |
| 308 | eZSys::init( 'index.php', $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) === 'true' ); |
| 309 | |
| 310 | eZDebug::addTimingPoint( "Script start" ); |
| 311 | |
| 312 | $uri = eZURI::instance( eZSys::requestURI() ); |
| 313 | $GLOBALS['eZRequestedURI'] = $uri; |
| 314 | |
| 315 | // Check for extension |
| 316 | eZExtension::activateExtensions( 'default' ); |
| 317 | // Extension check end |
| 318 | |
| 319 | $access = eZSiteAccess::match( $uri, |
| 320 | eZSys::hostname(), |
| 321 | eZSys::serverPort(), |
| 322 | eZSys::indexFile() ); |
| 323 | $access = eZSiteAccess::change( $access ); |
| 324 | eZDebugSetting::writeDebug( 'kernel-siteaccess', $access, 'current siteaccess' ); |
| 325 | |
| 326 | // Check for siteaccess extension |
| 327 | eZExtension::activateExtensions( 'access' ); |
| 328 | // Siteaccess extension check end |
| 329 | |
| 330 | // Now that all extensions are activated and siteaccess has been changed, reset |
| 331 | // all eZINI instances as they may not take into account siteaccess specific settings. |
| 332 | eZINI::resetAllInstances( false ); |
| 333 | |
| 334 | // Initialize module loading |
| 335 | $moduleRepositories = eZModule::activeModuleRepositories(); |
| 336 | eZModule::setGlobalPathList( $moduleRepositories ); |
| 337 | |
| 338 | // make sure we get a new $ini instance now that it has been reset |
| 339 | $ini = eZINI::instance(); |
| 340 | |
| 341 | // start: eZCheckValidity |
| 342 | // pre check, setup wizard related so needs to be before session/db init |
| 343 | if ( $ini->variable( 'SiteAccessSettings', 'CheckValidity' ) === 'true' ) |
| 344 | { |
| 345 | $check = array( 'module' => 'setup', |
| 346 | 'function' => 'init' ); |
| 347 | // Turn off some features that won't bee needed yet |
| 348 | $siteBasics['policy-check-omit-list'][] = 'setup'; |
| 349 | $siteBasics['show-page-layout'] = $ini->variable( 'SetupSettings', 'PageLayout' ); |
| 350 | $siteBasics['validity-check-required'] = true; |
| 351 | $siteBasics['session-required'] = $siteBasics['user-object-required'] = false; |
| 352 | $siteBasics['db-required'] = $siteBasics['no-cache-adviced'] = $siteBasics['url-translator-allowed'] = false; |
| 353 | $siteBasics['site-design-override'] = $ini->variable( 'SetupSettings', 'OverrideSiteDesign' ); |
| 354 | $access = array( 'name' => 'setup', |
| 355 | 'type' => eZSiteAccess::TYPE_URI ); |
| 356 | $access = eZSiteAccess::change( $access ); |
| 357 | eZTranslatorManager::enableDynamicTranslations(); |
| 358 | } |
| 359 | // stop: eZCheckValidity |
| 360 | |
| 361 | if ( $sessionRequired ) |
| 362 | { |
| 363 | // Check if this should be run in a cronjob |
| 364 | if ( $ini->variable( 'Session', 'BasketCleanup' ) !== 'cronjob' ) |
| 365 | { |
| 366 | // Functions for session to make sure baskets are cleaned up |
| 367 | function eZSessionBasketDestroy( $db, $key, $escapedKey ) |
| 368 | { |
| 369 | $basket = eZBasket::fetch( $key ); |
| 370 | if ( is_object( $basket ) ) |
| 371 | $basket->remove(); |
| 372 | } |
| 373 | |
| 374 | function eZSessionBasketGarbageCollector( $db, $time ) |
| 375 | { |
| 376 | eZBasket::cleanupExpired( $time ); |
| 377 | } |
| 378 | |
| 379 | function eZSessionBasketEmpty( $db ) |
| 380 | { |
| 381 | eZBasket::cleanup(); |
| 382 | } |
| 383 | |
| 384 | // Fill in hooks |
| 385 | eZSession::addCallback( 'destroy_pre', 'eZSessionBasketDestroy'); |
| 386 | eZSession::addCallback( 'gc_pre', 'eZSessionBasketGarbageCollector'); |
| 387 | eZSession::addCallback( 'cleanup_pre', 'eZSessionBasketCleanup'); |
| 388 | } |
| 389 | |
| 390 | // addCallBack to update session id for shop basket on session regenerate |
| 391 | function eZSessionBasketRegenerate( $db, $escNewKey, $escOldKey, $escUserID ) |
| 392 | { |
| 393 | $db->query( "UPDATE ezbasket SET session_id='$escNewKey' WHERE session_id='$escOldKey'" ); |
| 394 | } |
| 395 | |
| 396 | eZSession::addCallback( 'regenerate_post', 'eZSessionBasketRegenerate'); |
| 397 | |
| 398 | if ( $ini->variable( 'Session', 'ForceStart' ) === 'enabled' ) |
| 399 | eZSession::start(); |
| 400 | else |
| 401 | eZSession::lazyStart(); |
| 402 | |
| 403 | // let session specify if db is required |
| 404 | $dbRequired = eZSession::getHandlerInstance()->dbRequired(); |
| 405 | } |
| 406 | |
| 407 | // if $dbRequired, open a db connection and check that db is connected |
| 408 | if ( $dbRequired && !eZDB::instance()->isConnected() ) |
| 409 | { |
| 410 | $warningList[] = array( 'error' => array( 'type' => 'kernel', |
| 411 | 'number' => eZError::KERNEL_NO_DB_CONNECTION ), |
| 412 | 'text' => 'No database connection could be made, the system might not behave properly.' ); |
| 413 | } |
| 414 | |
| 415 | // eZCheckUser: pre check, RequireUserLogin & FORCE_LOGIN related so needs to be after session init |
| 416 | if ( !isset( $check ) ) |
| 417 | { |
| 418 | $check = eZUserLoginHandler::preCheck( $siteBasics, $uri ); |
| 419 | } |
| 420 | |
| 421 | /** |
| 422 | * Check for activating Debug by user ID (Final checking. The first was in eZDebug::updateSettings()) |
| 423 | * @uses eZUser::instance() So needs to be executed after eZSession::start()|lazyStart() |
| 424 | */ |
| 425 | eZDebug::checkDebugByUser(); |
| 426 | |
| 427 | |
| 428 | ezpEvent::getInstance()->notify( 'request/input', array( $uri ) ); |
| 429 | |
| 430 | // Initialize with locale settings |
| 431 | $locale = eZLocale::instance(); |
| 432 | $languageCode = $locale->httpLocaleCode(); |
| 433 | $phpLocale = trim( $ini->variable( 'RegionalSettings', 'SystemLocale' ) ); |
| 434 | if ( $phpLocale != '' ) |
| 435 | { |
| 436 | setlocale( LC_ALL, explode( ',', $phpLocale ) ); |
| 437 | } |
| 438 | |
| 439 | // send header information |
| 440 | $headerList = array( 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', |
| 441 | 'Last-Modified' => gmdate( 'D, d M Y H:i:s' ) . ' GMT', |
| 442 | 'Cache-Control' => 'no-cache, must-revalidate', |
| 443 | 'Pragma' => 'no-cache', |
| 444 | 'X-Powered-By' => 'eZ Publish', |
| 445 | 'Content-Type' => 'text/html; charset=' . $httpCharset, |
| 446 | 'Served-by' => $_SERVER["SERVER_NAME"], |
| 447 | 'Content-language' => $languageCode ); |
| 448 | |
| 449 | $site = array( 'title' => $ini->variable( 'SiteSettings', 'SiteName' ), |
| 450 | 'design' => $ini->variable( 'DesignSettings', 'SiteDesign' ), |
| 451 | 'http_equiv' => array( 'Content-Type' => 'text/html; charset=' . $httpCharset, |
| 452 | 'Content-language' => $languageCode ) ); |
| 453 | |
| 454 | |
| 455 | $headerOverrideArray = eZHTTPHeader::headerOverrideArray( $uri ); |
| 456 | |
| 457 | $headerList = array_merge( $headerList, $headerOverrideArray ); |
| 458 | |
| 459 | foreach( $headerList as $key => $value ) |
| 460 | { |
| 461 | header( $key . ': ' . $value ); |
| 462 | } |
| 463 | |
| 464 | // Read role settings |
| 465 | $globalPolicyCheckOmitList = $ini->variable( 'RoleSettings', 'PolicyOmitList' ); |
| 466 | $policyCheckOmitList = array_merge( $policyCheckOmitList, $globalPolicyCheckOmitList ); |
| 467 | $policyCheckViewMap = array(); |
| 468 | foreach ( $policyCheckOmitList as $omitItem ) |
| 469 | { |
| 470 | $items = explode( '/', $omitItem ); |
| 471 | if ( count( $items ) > 1 ) |
| 472 | { |
| 473 | $module = $items[0]; |
| 474 | $view = $items[1]; |
| 475 | if ( !isset( $policyCheckViewMap[$module] ) ) |
| 476 | $policyCheckViewMap[$module] = array(); |
| 477 | $policyCheckViewMap[$module][] = $view; |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | |
| 482 | // Start the module loop |
| 483 | while ( $moduleRunRequired ) |
| 484 | { |
| 485 | $objectHasMovedError = false; |
| 486 | $objectHasMovedURI = false; |
| 487 | $actualRequestedURI = $uri->uriString(); |
| 488 | |
| 489 | // Extract user specified parameters |
| 490 | $userParameters = $uri->userParameters(); |
| 491 | |
| 492 | // Generate a URI which also includes the user parameters |
| 493 | $completeRequestedURI = $uri->originalURIString(); |
| 494 | |
| 495 | //eZDebug::writeDebug( eZURLAliasML::translate( $uri ) ); |
| 496 | // Check for URL translation |
| 497 | if ( $urlTranslatorAllowed and |
| 498 | eZURLAliasML::urlTranslationEnabledByUri( $uri ) ) |
| 499 | { |
| 500 | $translateResult = eZURLAliasML::translate( $uri ); |
| 501 | |
| 502 | if ( !is_string( $translateResult ) ) |
| 503 | { |
| 504 | $useWildcardTranslation = $ini->variable( 'URLTranslator', 'WildcardTranslation' ) == 'enabled'; |
| 505 | if ( $useWildcardTranslation ) |
| 506 | { |
| 507 | $translateResult = eZURLWildcard::translate( $uri ); |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | // Check if the URL has moved |
| 512 | if ( is_string( $translateResult ) ) |
| 513 | { |
| 514 | $objectHasMovedURI = $translateResult; |
| 515 | foreach ( $userParameters as $name => $value ) |
| 516 | { |
| 517 | $objectHasMovedURI .= '/(' . $name . ')/' . $value; |
| 518 | } |
| 519 | |
| 520 | $objectHasMovedError = true; |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | if ( $uri->isEmpty() ) |
| 525 | { |
| 526 | $tmp_uri = new eZURI( $ini->variable( "SiteSettings", "IndexPage" ) ); |
| 527 | $moduleCheck = eZModule::accessAllowed( $tmp_uri ); |
| 528 | } |
| 529 | else |
| 530 | { |
| 531 | $moduleCheck = eZModule::accessAllowed( $uri ); |
| 532 | } |
| 533 | |
| 534 | if ( !$moduleCheck['result'] ) |
| 535 | { |
| 536 | if ( $ini->variable( "SiteSettings", "ErrorHandler" ) == "defaultpage" ) |
| 537 | { |
| 538 | $defaultPage = $ini->variable( "SiteSettings", "DefaultPage" ); |
| 539 | $uri->setURIString( $defaultPage ); |
| 540 | $moduleCheck['result'] = true; |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | $http = eZHTTPTool::instance(); |
| 545 | |
| 546 | $displayMissingModule = false; |
| 547 | $oldURI = $uri; |
| 548 | |
| 549 | if ( $uri->isEmpty() ) |
| 550 | { |
| 551 | if ( !fetchModule( $tmp_uri, $check, $module, $module_name, $function_name, $params ) ) |
| 552 | $displayMissingModule = true; |
| 553 | } |
| 554 | else if ( !fetchModule( $uri, $check, $module, $module_name, $function_name, $params ) ) |
| 555 | { |
| 556 | if ( $ini->variable( "SiteSettings", "ErrorHandler" ) == "defaultpage" ) |
| 557 | { |
| 558 | $tmp_uri = new eZURI( $ini->variable( "SiteSettings", "DefaultPage" ) ); |
| 559 | if ( !fetchModule( $tmp_uri, $check, $module, $module_name, $function_name, $params ) ) |
| 560 | $displayMissingModule = true; |
| 561 | } |
| 562 | else |
| 563 | $displayMissingModule = true; |
| 564 | } |
| 565 | |
| 566 | if ( !$displayMissingModule && |
| 567 | $moduleCheck['result'] && |
| 568 | $module instanceof eZModule ) |
| 569 | { |
| 570 | // Run the module/function |
| 571 | eZDebug::addTimingPoint( "Module start '" . $module->attribute( 'name' ) . "'" ); |
| 572 | |
| 573 | $moduleAccessAllowed = true; |
| 574 | $omitPolicyCheck = true; |
| 575 | $runModuleView = true; |
| 576 | |
| 577 | $availableViewsInModule = $module->attribute( 'views' ); |
| 578 | if ( !isset( $availableViewsInModule[$function_name] ) |
| 579 | && !$objectHasMovedError |
| 580 | && !isset( $module->Module['function']['script'] ) ) |
| 581 | { |
| 582 | $moduleResult = $module->handleError( eZError::KERNEL_MODULE_VIEW_NOT_FOUND, 'kernel' ); |
| 583 | $runModuleView = false; |
| 584 | $policyCheckRequired = false; |
| 585 | $omitPolicyCheck = true; |
| 586 | } |
| 587 | |
| 588 | if ( $policyCheckRequired ) |
| 589 | { |
| 590 | $omitPolicyCheck = false; |
| 591 | $moduleName = $module->attribute( 'name' ); |
| 592 | $viewName = $function_name; |
| 593 | if ( in_array( $moduleName, $policyCheckOmitList ) ) |
| 594 | $omitPolicyCheck = true; |
| 595 | else if ( isset( $policyCheckViewMap[$moduleName] ) and |
| 596 | in_array( $viewName, $policyCheckViewMap[$moduleName] ) ) |
| 597 | $omitPolicyCheck = true; |
| 598 | } |
| 599 | if ( !$omitPolicyCheck ) |
| 600 | { |
| 601 | $currentUser = eZUser::currentUser(); |
| 602 | $siteAccessResult = $currentUser->hasAccessTo( 'user', 'login' ); |
| 603 | |
| 604 | $hasAccessToSite = false; |
| 605 | if ( $siteAccessResult[ 'accessWord' ] == 'limited' ) |
| 606 | { |
| 607 | $policyChecked = false; |
| 608 | foreach ( array_keys( $siteAccessResult['policies'] ) as $key ) |
| 609 | { |
| 610 | $policy = $siteAccessResult['policies'][$key]; |
| 611 | if ( isset( $policy['SiteAccess'] ) ) |
| 612 | { |
| 613 | $policyChecked = true; |
| 614 | $crc32AccessName = eZSys::ezcrc32( $access[ 'name' ] ); |
| 615 | eZDebugSetting::writeDebug( 'kernel-siteaccess', $policy['SiteAccess'], $crc32AccessName ); |
| 616 | if ( in_array( $crc32AccessName, $policy['SiteAccess'] ) ) |
| 617 | { |
| 618 | $hasAccessToSite = true; |
| 619 | break; |
| 620 | } |
| 621 | } |
| 622 | if ( $hasAccessToSite ) |
| 623 | break; |
| 624 | } |
| 625 | if ( !$policyChecked ) |
| 626 | $hasAccessToSite = true; |
| 627 | } |
| 628 | else if ( $siteAccessResult[ 'accessWord' ] == 'yes' ) |
| 629 | { |
| 630 | eZDebugSetting::writeDebug( 'kernel-siteaccess', "access is yes" ); |
| 631 | $hasAccessToSite = true; |
| 632 | } |
| 633 | else if ( $siteAccessResult['accessWord'] == 'no' ) |
| 634 | { |
| 635 | $accessList = $siteAccessResult['accessList']; |
| 636 | } |
| 637 | |
| 638 | if ( $hasAccessToSite ) |
| 639 | { |
| 640 | $accessParams = array(); |
| 641 | $moduleAccessAllowed = $currentUser->hasAccessToView( $module, $function_name, $accessParams ); |
| 642 | if ( isset( $accessParams['accessList'] ) ) |
| 643 | { |
| 644 | $accessList = $accessParams['accessList']; |
| 645 | } |
| 646 | } |
| 647 | else |
| 648 | { |
| 649 | eZDebugSetting::writeDebug( 'kernel-siteaccess', $access, 'not able to get access to siteaccess' ); |
| 650 | $moduleAccessAllowed = false; |
| 651 | $requireUserLogin = ( $ini->variable( "SiteAccessSettings", "RequireUserLogin" ) == "true" ); |
| 652 | if ( $requireUserLogin ) |
| 653 | { |
| 654 | $module = eZModule::exists( 'user' ); |
| 655 | if ( $module instanceof eZModule ) |
| 656 | { |
| 657 | $moduleResult = $module->run( 'login', array(), |
| 658 | array( 'SiteAccessAllowed' => false, |
| 659 | 'SiteAccessName' => $access['name'] ) ); |
| 660 | $runModuleView = false; |
| 661 | } |
| 662 | } |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | $GLOBALS['eZRequestedModule'] = $module; |
| 667 | |
| 668 | if ( $runModuleView ) |
| 669 | { |
| 670 | if ( $objectHasMovedError == true ) |
| 671 | { |
| 672 | $moduleResult = $module->handleError( eZError::KERNEL_MOVED, 'kernel', array( 'new_location' => $objectHasMovedURI ) ); |
| 673 | } |
| 674 | else if ( !$moduleAccessAllowed ) |
| 675 | { |
| 676 | if ( isset( $availableViewsInModule[$function_name][ 'default_navigation_part' ] ) ) |
| 677 | { |
| 678 | $defaultNavigationPart = $availableViewsInModule[$function_name][ 'default_navigation_part' ]; |
| 679 | } |
| 680 | |
| 681 | if ( isset( $accessList ) ) |
| 682 | $moduleResult = $module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel', array( 'AccessList' => $accessList ) ); |
| 683 | else |
| 684 | $moduleResult = $module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' ); |
| 685 | |
| 686 | if ( isset( $defaultNavigationPart ) ) |
| 687 | { |
| 688 | $moduleResult['navigation_part'] = $defaultNavigationPart; |
| 689 | unset( $defaultNavigationPart ); |
| 690 | } |
| 691 | } |
| 692 | else |
| 693 | { |
| 694 | if ( !isset( $userParameters ) ) |
| 695 | { |
| 696 | $userParameters = false; |
| 697 | } |
| 698 | |
| 699 | // Check if we should switch access mode (http/https) for this module view. |
| 700 | eZSSLZone::checkModuleView( $module->attribute( 'name' ), $function_name ); |
| 701 | |
| 702 | $moduleResult = $module->run( $function_name, $params, false, $userParameters ); |
| 703 | |
| 704 | if ( $module->exitStatus() == eZModule::STATUS_FAILED and |
| 705 | $moduleResult == null ) |
| 706 | $moduleResult = $module->handleError( eZError::KERNEL_MODULE_VIEW_NOT_FOUND, 'kernel', array( 'module' => $module_name, |
| 707 | 'view' => $function_name ) ); |
| 708 | } |
| 709 | } |
| 710 | } |
| 711 | else if ( $moduleCheck['result'] ) |
| 712 | { |
| 713 | eZDebug::writeError( "Undefined module: $module_name", "index" ); |
| 714 | $module = new eZModule( "", "", $module_name ); |
| 715 | $GLOBALS['eZRequestedModule'] = $module; |
| 716 | $moduleResult = $module->handleError( eZError::KERNEL_MODULE_NOT_FOUND, 'kernel', array( 'module' => $module_name ) ); |
| 717 | } |
| 718 | else |
| 719 | { |
| 720 | if ( $moduleCheck['view_checked'] ) |
| 721 | eZDebug::writeError( "View '" . $moduleCheck['view'] . "' in module '" . $moduleCheck['module'] . "' is disabled", "index" ); |
| 722 | else |
| 723 | eZDebug::writeError( "Module '" . $moduleCheck['module'] . "' is disabled", "index" ); |
| 724 | $module = new eZModule( "", "", $moduleCheck['module'] ); |
| 725 | $GLOBALS['eZRequestedModule'] = $module; |
| 726 | $moduleResult = $module->handleError( eZError::KERNEL_MODULE_DISABLED, 'kernel', array( 'check' => $moduleCheck ) ); |
| 727 | } |
| 728 | $moduleRunRequired = false; |
| 729 | if ( $module->exitStatus() == eZModule::STATUS_RERUN ) |
| 730 | { |
| 731 | if ( isset( $moduleResult['rerun_uri'] ) ) |
| 732 | { |
| 733 | $uri = eZURI::instance( $moduleResult['rerun_uri'] ); |
| 734 | $moduleRunRequired = true; |
| 735 | } |
| 736 | else |
| 737 | eZDebug::writeError( 'No rerun URI specified, cannot continue', 'index.php' ); |
| 738 | } |
| 739 | |
| 740 | if ( is_array( $moduleResult ) ) |
| 741 | { |
| 742 | if ( isset( $moduleResult["pagelayout"] ) ) |
| 743 | { |
| 744 | $show_page_layout = $moduleResult["pagelayout"]; |
| 745 | $GLOBALS['eZCustomPageLayout'] = $moduleResult["pagelayout"]; |
| 746 | } |
| 747 | if ( isset( $moduleResult["external_css"] ) ) |
| 748 | $use_external_css = $moduleResult["external_css"]; |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | |
| 753 | /** |
| 754 | * Ouput an is_logged_in cookie when users are logged in for use by http cache soulutions. |
| 755 | * |
| 756 | * @deprecated As of 4.5, since 4.4 added lazy session support (init on use) |
| 757 | */ |
| 758 | if ( $ini->variable( "SiteAccessSettings", "CheckValidity" ) !== 'true' ) |
| 759 | { |
| 760 | $currentUser = eZUser::currentUser(); |
| 761 | |
| 762 | $wwwDir = eZSys::wwwDir(); |
| 763 | // On host based site accesses this can be empty, causing the cookie to be set for the current dir, |
| 764 | // but we want it to be set for the whole eZ publish site |
| 765 | $cookiePath = $wwwDir != '' ? $wwwDir : '/'; |
| 766 | |
| 767 | if ( $currentUser->isLoggedIn() ) |
| 768 | { |
| 769 | setcookie( 'is_logged_in', 'true', 0, $cookiePath ); |
| 770 | } |
| 771 | else if ( isset( $_COOKIE['is_logged_in'] ) ) |
| 772 | { |
| 773 | setcookie( 'is_logged_in', false, 0, $cookiePath ); |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | if ( $module->exitStatus() == eZModule::STATUS_REDIRECT ) |
| 778 | { |
| 779 | $GLOBALS['eZRedirection'] = true; |
| 780 | $ini = eZINI::instance(); |
| 781 | $automatic_redir = true; |
| 782 | |
| 783 | if ( $GLOBALS['eZDebugAllowed'] && ( $redirUri = $ini->variable( 'DebugSettings', 'DebugRedirection' ) ) != 'disabled' ) |
| 784 | { |
| 785 | if ( $redirUri == "enabled" ) |
| 786 | { |
| 787 | $automatic_redir = false; |
| 788 | } |
| 789 | else |
| 790 | { |
| 791 | $redirUris = $ini->variableArray( "DebugSettings", "DebugRedirection" ); |
| 792 | $uri = eZURI::instance( eZSys::requestURI() ); |
| 793 | $uri->toBeginning(); |
| 794 | foreach ( $redirUris as $redirUri ) |
| 795 | { |
| 796 | $redirUri = new eZURI( $redirUri ); |
| 797 | if ( $redirUri->matchBase( $uri ) ) |
| 798 | { |
| 799 | $automatic_redir = false; |
| 800 | break; |
| 801 | } |
| 802 | } |
| 803 | } |
| 804 | } |
| 805 | |
| 806 | $redirectURI = eZSys::indexDir(); |
| 807 | |
| 808 | $moduleRedirectUri = $module->redirectURI(); |
| 809 | $redirectStatus = $module->redirectStatus(); |
| 810 | $translatedModuleRedirectUri = $moduleRedirectUri; |
| 811 | if ( $ini->variable( 'URLTranslator', 'Translation' ) == 'enabled' && |
| 812 | eZURLAliasML::urlTranslationEnabledByUri( new eZURI( $moduleRedirectUri ) ) ) |
| 813 | { |
| 814 | if ( eZURLAliasML::translate( $translatedModuleRedirectUri, true ) ) |
| 815 | { |
| 816 | $moduleRedirectUri = $translatedModuleRedirectUri; |
| 817 | if ( strlen( $moduleRedirectUri ) > 0 and |
| 818 | $moduleRedirectUri[0] != '/' ) |
| 819 | $moduleRedirectUri = '/' . $moduleRedirectUri; |
| 820 | } |
| 821 | } |
| 822 | |
| 823 | if ( preg_match( '#^(\w+:)|^//#', $moduleRedirectUri ) ) |
| 824 | { |
| 825 | $redirectURI = $moduleRedirectUri; |
| 826 | } |
| 827 | else |
| 828 | { |
| 829 | $leftSlash = false; |
| 830 | $rightSlash = false; |
| 831 | if ( strlen( $redirectURI ) > 0 and |
| 832 | $redirectURI[strlen( $redirectURI ) - 1] == '/' ) |
| 833 | $leftSlash = true; |
| 834 | if ( strlen( $moduleRedirectUri ) > 0 and |
| 835 | $moduleRedirectUri[0] == '/' ) |
| 836 | $rightSlash = true; |
| 837 | |
| 838 | if ( !$leftSlash and !$rightSlash ) // Both are without a slash, so add one |
| 839 | $moduleRedirectUri = '/' . $moduleRedirectUri; |
| 840 | else if ( $leftSlash and $rightSlash ) // Both are with a slash, so we remove one |
| 841 | $moduleRedirectUri = substr( $moduleRedirectUri, 1 ); |
| 842 | $redirectURI .= $moduleRedirectUri; |
| 843 | } |
| 844 | |
| 845 | eZStaticCache::executeActions(); |
| 846 | |
| 847 | eZDB::checkTransactionCounter(); |
| 848 | |
| 849 | if ( $automatic_redir ) |
| 850 | { |
| 851 | eZHTTPTool::redirect( $redirectURI, array(), $redirectStatus ); |
| 852 | } |
| 853 | else |
| 854 | { |
| 855 | // Make sure any errors or warnings are reported |
| 856 | if ( $ini->variable( 'DebugSettings', 'DisplayDebugWarnings' ) == 'enabled' ) |
| 857 | { |
| 858 | if ( isset( $GLOBALS['eZDebugError'] ) and |
| 859 | $GLOBALS['eZDebugError'] ) |
| 860 | { |
| 861 | eZAppendWarningItem( array( 'error' => array( 'type' => 'error', |
| 862 | 'number' => 1, |
| 863 | 'count' => $GLOBALS['eZDebugErrorCount'] ), |
| 864 | 'identifier' => 'ezdebug-first-error', |
| 865 | 'text' => ezpI18n::tr( 'index.php', 'Some errors occurred, see debug for more information.' ) ) ); |
| 866 | } |
| 867 | |
| 868 | if ( isset( $GLOBALS['eZDebugWarning'] ) and |
| 869 | $GLOBALS['eZDebugWarning'] ) |
| 870 | { |
| 871 | eZAppendWarningItem( array( 'error' => array( 'type' => 'warning', |
| 872 | 'number' => 1, |
| 873 | 'count' => $GLOBALS['eZDebugWarningCount'] ), |
| 874 | 'identifier' => 'ezdebug-first-warning', |
| 875 | 'text' => ezpI18n::tr( 'index.php', 'Some general warnings occured, see debug for more information.' ) ) ); |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | $tpl = eZTemplate::factory(); |
| 880 | if ( empty( $warningList ) ) |
| 881 | $warningList = false; |
| 882 | |
| 883 | $tpl->setVariable( 'site', $site ); |
| 884 | $tpl->setVariable( 'warning_list', $warningList ); |
| 885 | $tpl->setVariable( 'redirect_uri', eZURI::encodeURL( $redirectURI ) ); |
| 886 | $templateResult = $tpl->fetch( 'design:redirect.tpl' ); |
| 887 | |
| 888 | eZDebug::addTimingPoint( "End" ); |
| 889 | |
| 890 | eZDisplayResult( $templateResult ); |
| 891 | } |
| 892 | |
| 893 | eZExecution::cleanExit(); |
| 894 | } |
| 895 | |
| 896 | // Store the last URI for access history for login redirection |
| 897 | // Only if user has session and only if there was no error or no redirects happen |
| 898 | if ( eZSession::hasStarted() && |
| 899 | $module->exitStatus() == eZModule::STATUS_OK ) |
| 900 | { |
| 901 | $currentURI = $completeRequestedURI; |
| 902 | if ( strlen( $currentURI ) > 0 and $currentURI[0] != '/' ) |
| 903 | $currentURI = '/' . $currentURI; |
| 904 | |
| 905 | $lastAccessedURI = ""; |
| 906 | $lastAccessedViewURI = ""; |
| 907 | |
| 908 | $http = eZHTTPTool::instance(); |
| 909 | |
| 910 | // Fetched stored session variables |
| 911 | if ( $http->hasSessionVariable( "LastAccessesURI" ) ) |
| 912 | { |
| 913 | $lastAccessedViewURI = $http->sessionVariable( "LastAccessesURI" ); |
| 914 | } |
| 915 | if ( $http->hasSessionVariable( "LastAccessedModifyingURI" ) ) |
| 916 | { |
| 917 | $lastAccessedURI = $http->sessionVariable( "LastAccessedModifyingURI" ); |
| 918 | } |
| 919 | |
| 920 | // Update last accessed view page |
| 921 | if ( $currentURI != $lastAccessedViewURI and |
| 922 | !in_array( $module->uiContextName(), array( 'edit', 'administration', 'browse', 'authentication' ) ) ) |
| 923 | { |
| 924 | $http->setSessionVariable( "LastAccessesURI", $currentURI ); |
| 925 | } |
| 926 | |
| 927 | // Update last accessed non-view page |
| 928 | if ( $currentURI != $lastAccessedURI ) |
| 929 | { |
| 930 | $http->setSessionVariable( "LastAccessedModifyingURI", $currentURI ); |
| 931 | } |
| 932 | } |
| 933 | |
| 934 | |
| 935 | eZDebug::addTimingPoint( "Module end '" . $module->attribute( 'name' ) . "'" ); |
| 936 | if ( !is_array( $moduleResult ) ) |
| 937 | { |
| 938 | eZDebug::writeError( 'Module did not return proper result: ' . $module->attribute( 'name' ), 'index.php' ); |
| 939 | $moduleResult = array(); |
| 940 | $moduleResult['content'] = false; |
| 941 | } |
| 942 | |
| 943 | if ( !isset( $moduleResult['ui_context'] ) ) |
| 944 | { |
| 945 | $moduleResult['ui_context'] = $module->uiContextName(); |
| 946 | } |
| 947 | $moduleResult['ui_component'] = $module->uiComponentName(); |
| 948 | |
| 949 | $templateResult = null; |
| 950 | |
| 951 | eZDebug::setUseExternalCSS( $use_external_css ); |
| 952 | if ( $show_page_layout ) |
| 953 | { |
| 954 | $tpl = eZTemplate::factory(); |
| 955 | if ( $tpl->hasVariable( 'node' ) ) |
| 956 | $tpl->unsetVariable( 'node' ); |
| 957 | |
| 958 | if ( !isset( $moduleResult['path'] ) ) |
| 959 | $moduleResult['path'] = false; |
| 960 | $moduleResult['uri'] = eZSys::requestURI(); |
| 961 | |
| 962 | $tpl->setVariable( "module_result", $moduleResult ); |
| 963 | |
| 964 | $meta = $ini->variable( 'SiteSettings', 'MetaDataArray' ); |
| 965 | |
| 966 | if ( !isset( $meta['description'] ) ) |
| 967 | { |
| 968 | $metaDescription = ""; |
| 969 | if ( isset( $moduleResult['path'] ) and |
| 970 | is_array( $moduleResult['path'] ) ) |
| 971 | { |
| 972 | foreach ( $moduleResult['path'] as $pathPart ) |
| 973 | { |
| 974 | if ( isset( $pathPart['text'] ) ) |
| 975 | $metaDescription .= $pathPart['text'] . " "; |
| 976 | } |
| 977 | } |
| 978 | $meta['description'] = $metaDescription; |
| 979 | } |
| 980 | |
| 981 | $site['uri'] = $oldURI; |
| 982 | $site['redirect'] = false; |
| 983 | $site['meta'] = $meta; |
| 984 | $site['version'] = eZPublishSDK::version(); |
| 985 | $site['page_title'] = $module->title(); |
| 986 | |
| 987 | $tpl->setVariable( "site", $site ); |
| 988 | |
| 989 | if ( $ini->variable( 'DebugSettings', 'DisplayDebugWarnings' ) == 'enabled' ) |
| 990 | { |
| 991 | // Make sure any errors or warnings are reported |
| 992 | if ( isset( $GLOBALS['eZDebugError'] ) and |
| 993 | $GLOBALS['eZDebugError'] ) |
| 994 | { |
| 995 | eZAppendWarningItem( array( 'error' => array( 'type' => 'error', |
| 996 | 'number' => 1 , |
| 997 | 'count' => $GLOBALS['eZDebugErrorCount'] ), |
| 998 | 'identifier' => 'ezdebug-first-error', |
| 999 | 'text' => ezpI18n::tr( 'index.php', 'Some errors occurred, see debug for more information.' ) ) ); |
| 1000 | } |
| 1001 | |
| 1002 | if ( isset( $GLOBALS['eZDebugWarning'] ) and |
| 1003 | $GLOBALS['eZDebugWarning'] ) |
| 1004 | { |
| 1005 | eZAppendWarningItem( array( 'error' => array( 'type' => 'warning', |
| 1006 | 'number' => 1, |
| 1007 | 'count' => $GLOBALS['eZDebugWarningCount'] ), |
| 1008 | 'identifier' => 'ezdebug-first-warning', |
| 1009 | 'text' => ezpI18n::tr( 'index.php', 'Some general warnings occured, see debug for more information.' ) ) ); |
| 1010 | } |
| 1011 | } |
| 1012 | |
| 1013 | if ( $userObjectRequired ) |
| 1014 | { |
| 1015 | $currentUser = eZUser::currentUser(); |
| 1016 | |
| 1017 | $tpl->setVariable( "current_user", $currentUser ); |
| 1018 | $tpl->setVariable( "anonymous_user_id", $ini->variable( 'UserSettings', 'AnonymousUserID' ) ); |
| 1019 | } |
| 1020 | else |
| 1021 | { |
| 1022 | $tpl->setVariable( "current_user", false ); |
| 1023 | $tpl->setVariable( "anonymous_user_id", false ); |
| 1024 | } |
| 1025 | |
| 1026 | $tpl->setVariable( "access_type", $access ); |
| 1027 | |
| 1028 | if ( empty( $warningList ) ) |
| 1029 | $warningList = false; |
| 1030 | |
| 1031 | $tpl->setVariable( 'warning_list', $warningList ); |
| 1032 | |
| 1033 | $resource = "design:"; |
| 1034 | if ( is_string( $show_page_layout ) ) |
| 1035 | { |
| 1036 | if ( strpos( $show_page_layout, ":" ) !== false ) |
| 1037 | { |
| 1038 | $resource = ""; |
| 1039 | } |
| 1040 | } |
| 1041 | else |
| 1042 | { |
| 1043 | $show_page_layout = "pagelayout.tpl"; |
| 1044 | } |
| 1045 | |
| 1046 | // Set the navigation part |
| 1047 | // Check for navigation part settings |
| 1048 | $navigationPartString = 'ezcontentnavigationpart'; |
| 1049 | if ( isset( $moduleResult['navigation_part'] ) ) |
| 1050 | { |
| 1051 | $navigationPartString = $moduleResult['navigation_part']; |
| 1052 | |
| 1053 | // Fetch the navigation part |
| 1054 | } |
| 1055 | $navigationPart = eZNavigationPart::fetchPartByIdentifier( $navigationPartString ); |
| 1056 | |
| 1057 | $tpl->setVariable( 'navigation_part', $navigationPart ); |
| 1058 | $tpl->setVariable( 'uri_string', $uri->uriString() ); |
| 1059 | if ( isset( $moduleResult['requested_uri_string'] ) ) |
| 1060 | { |
| 1061 | $tpl->setVariable( 'requested_uri_string', $moduleResult['requested_uri_string'] ); |
| 1062 | } |
| 1063 | else |
| 1064 | { |
| 1065 | $tpl->setVariable( 'requested_uri_string', $actualRequestedURI ); |
| 1066 | } |
| 1067 | |
| 1068 | // Set UI context and component |
| 1069 | $tpl->setVariable( 'ui_context', $moduleResult['ui_context'] ); |
| 1070 | $tpl->setVariable( 'ui_component', $moduleResult['ui_component'] ); |
| 1071 | |
| 1072 | $templateResult = $tpl->fetch( $resource . $show_page_layout ); |
| 1073 | } |
| 1074 | else |
| 1075 | { |
| 1076 | $templateResult = $moduleResult['content']; |
| 1077 | } |
| 1078 | |
| 1079 | |
| 1080 | eZDebug::addTimingPoint( "End" ); |
| 1081 | |
| 1082 | $out = ob_get_clean(); |
| 1083 | echo trim( $out ); |
| 1084 | |
| 1085 | eZDB::checkTransactionCounter(); |
| 1086 | |
| 1087 | eZDisplayResult( $templateResult ); |
| 1088 | |
| 1089 | eZExecution::cleanup(); |
| 1090 | eZExecution::setCleanExit(); |
| 1091 | |
| 1092 | ?> |
| 1093 | |