Exemplo n.º 1
0
 /**
  * Return a list of all cache items in the system.
  *
  * @return array The list of cache items
  */
 static function fetchList()
 {
     static $cacheList = null;
     if ($cacheList === null) {
         $ini = eZINI::instance();
         $textToImageIni = eZINI::instance('texttoimage.ini');
         $cacheList = array(array('name' => ezpI18n::tr('kernel/cache', 'Content view cache'), 'id' => 'content', 'is-clustered' => true, 'tag' => array('content'), 'expiry-key' => 'content-view-cache', 'enabled' => $ini->variable('ContentSettings', 'ViewCaching') == 'enabled', 'path' => $ini->variable('ContentSettings', 'CacheDir'), 'function' => array('eZCache', 'clearContentCache')), array('name' => ezpI18n::tr('kernel/cache', 'Global INI cache'), 'id' => 'global_ini', 'tag' => array('ini'), 'enabled' => true, 'path' => 'var/cache/ini', 'function' => array('eZCache', 'clearGlobalINICache'), 'purge-function' => array('eZCache', 'clearGlobalINICache')), array('name' => ezpI18n::tr('kernel/cache', 'INI cache'), 'id' => 'ini', 'tag' => array('ini'), 'enabled' => true, 'path' => 'ini'), array('name' => ezpI18n::tr('kernel/cache', 'Codepage cache'), 'id' => 'codepage', 'tag' => array('codepage'), 'enabled' => true, 'path' => 'codepages'), array('name' => ezpI18n::tr('kernel/cache', 'Class identifier cache'), 'id' => 'classid', 'tag' => array('content'), 'expiry-key' => 'class-identifier-cache', 'enabled' => true, 'path' => false, 'is-clustered' => true, 'function' => array('eZCache', 'clearClassID'), 'purge-function' => array('eZCache', 'clearClassID')), array('name' => ezpI18n::tr('kernel/cache', 'Sort key cache'), 'id' => 'sortkey', 'tag' => array('content'), 'expiry-key' => 'sort-key-cache', 'enabled' => true, 'path' => false, 'function' => array('eZCache', 'clearSortKey'), 'purge-function' => array('eZCache', 'clearSortKey'), 'is-clustered' => true), array('name' => ezpI18n::tr('kernel/cache', 'URL alias cache'), 'id' => 'urlalias', 'is-clustered' => true, 'tag' => array('content'), 'enabled' => true, 'path' => 'wildcard'), array('name' => ezpI18n::tr('kernel/cache', 'Character transformation cache'), 'id' => 'chartrans', 'tag' => array('i18n'), 'enabled' => true, 'path' => 'trans'), array('name' => ezpI18n::tr('kernel/cache', 'Image alias'), 'id' => 'imagealias', 'tag' => array('image'), 'path' => false, 'enabled' => true, 'function' => array('eZCache', 'clearImageAlias'), 'purge-function' => array('eZCache', 'purgeImageAlias'), 'is-clustered' => true), array('name' => ezpI18n::tr('kernel/cache', 'Template cache'), 'id' => 'template', 'tag' => array('template'), 'enabled' => $ini->variable('TemplateSettings', 'TemplateCompile') == 'enabled', 'path' => 'template'), array('name' => ezpI18n::tr('kernel/cache', 'Template block cache'), 'id' => 'template-block', 'is-clustered' => true, 'tag' => array('template', 'content'), 'expiry-key' => 'global-template-block-cache', 'enabled' => $ini->variable('TemplateSettings', 'TemplateCache') == 'enabled', 'path' => 'template-block', 'function' => array('eZCache', 'clearTemplateBlockCache')), array('name' => ezpI18n::tr('kernel/cache', 'Template override cache'), 'id' => 'template-override', 'tag' => array('template'), 'enabled' => true, 'path' => 'override', 'function' => array('eZCache', 'clearTemplateOverrideCache')), array('name' => ezpI18n::tr('kernel/cache', 'Text to image cache'), 'id' => 'texttoimage', 'tag' => array('template'), 'enabled' => $textToImageIni->variable('ImageSettings', 'UseCache') == 'enabled', 'path' => $textToImageIni->variable('PathSettings', 'CacheDir'), 'function' => array('eZCache', 'clearTextToImageCache'), 'purge-function' => array('eZCache', 'purgeTextToImageCache'), 'is-clustered' => true), array('name' => ezpI18n::tr('kernel/cache', 'RSS cache'), 'id' => 'rss_cache', 'is-clustered' => true, 'tag' => array('content'), 'enabled' => true, 'path' => 'rss'), array('name' => ezpI18n::tr('kernel/cache', 'User info cache'), 'id' => 'user_info_cache', 'is-clustered' => true, 'tag' => array('user'), 'expiry-key' => 'user-info-cache', 'enabled' => true, 'path' => 'user-info', 'function' => array('eZCache', 'clearUserInfoCache')), array('name' => ezpI18n::tr('kernel/cache', 'Content tree menu (browser cache)'), 'id' => 'content_tree_menu', 'tag' => array('content'), 'path' => false, 'enabled' => true, 'function' => array('eZCache', 'clearContentTreeMenu'), 'purge-function' => array('eZCache', 'clearContentTreeMenu')), array('name' => ezpI18n::tr('kernel/cache', 'State limitations cache'), 'is-clustered' => true, 'id' => 'state_limitations', 'tag' => array('content'), 'expiry-key' => 'state-limitations', 'enabled' => true, 'path' => false, 'function' => array('eZCache', 'clearStateLimitations'), 'purge-function' => array('eZCache', 'clearStateLimitations')), array('name' => ezpI18n::tr('kernel/cache', 'Design base cache'), 'id' => 'design_base', 'tag' => array('template'), 'enabled' => $ini->variable('DesignSettings', 'DesignLocationCache') == 'enabled', 'path' => false, 'function' => array('eZCache', 'clearDesignBaseCache'), 'purge-function' => array('eZCache', 'clearDesignBaseCache')), array('name' => ezpI18n::tr('kernel/cache', 'Active extensions cache'), 'id' => 'active_extensions', 'tag' => array('ini'), 'expiry-key' => 'active-extensions-cache', 'enabled' => true, 'path' => false, 'function' => array('eZCache', 'clearActiveExtensions'), 'purge-function' => array('eZCache', 'clearActiveExtensions')), array('name' => ezpI18n::tr('kernel/cache', 'TS Translation cache'), 'id' => 'translation', 'tag' => array('i18n'), 'enabled' => true, 'expiry-key' => 'ts-translation-cache', 'path' => 'translation', 'function' => array('eZCache', 'clearTSTranslationCache')), array('name' => ezpI18n::tr('kernel/cache', 'SSL Zones cache'), 'id' => 'sslzones', 'tag' => array('ini'), 'enabled' => eZSSLZone::enabled(), 'path' => false, 'function' => array('eZSSLZone', 'clearCache'), 'purge-function' => array('eZSSLZone', 'clearCache')));
         // Append cache items defined (in ini) by extensions, see site.ini[Cache] for details
         foreach ($ini->variable('Cache', 'CacheItems') as $cacheItemKey) {
             $name = 'Cache_' . $cacheItemKey;
             if (!$ini->hasSection($name)) {
                 eZDebug::writeWarning("Missing site.ini section: '{$name}', skipping!", __METHOD__);
                 continue;
             }
             $cacheItem = array();
             if ($ini->hasVariable($name, 'name')) {
                 $cacheItem['name'] = $ini->variable($name, 'name');
             } else {
                 $cacheItem['name'] = ucwords($cacheItemKey);
             }
             if ($ini->hasVariable($name, 'id')) {
                 $cacheItem['id'] = $ini->variable($name, 'id');
             } else {
                 $cacheItem['id'] = $cacheItemKey;
             }
             if ($ini->hasVariable($name, 'isClustered')) {
                 $cacheItem['is-clustered'] = $ini->variable($name, 'isClustered');
             } else {
                 $cacheItem['is-clustered'] = false;
             }
             if ($ini->hasVariable($name, 'tags')) {
                 $cacheItem['tag'] = $ini->variable($name, 'tags');
             } else {
                 $cacheItem['tag'] = array();
             }
             if ($ini->hasVariable($name, 'expiryKey')) {
                 $cacheItem['expiry-key'] = $ini->variable($name, 'expiryKey');
             }
             if ($ini->hasVariable($name, 'enabled')) {
                 $cacheItem['enabled'] = $ini->variable($name, 'enabled');
             } else {
                 $cacheItem['enabled'] = true;
             }
             if ($ini->hasVariable($name, 'path')) {
                 $cacheItem['path'] = $ini->variable($name, 'path');
             } else {
                 $cacheItem['path'] = false;
             }
             if ($ini->hasVariable($name, 'class')) {
                 $cacheItem['function'] = array($ini->variable($name, 'class'), 'clearCache');
             }
             if ($ini->hasVariable($name, 'purgeClass')) {
                 $cacheItem['purge-function'] = array($ini->variable($name, 'purgeClass'), 'purgeCache');
             }
             $cacheList[] = $cacheItem;
         }
     }
     return $cacheList;
 }
Exemplo n.º 2
0
 /**
  * \static
  * Decide whether we should change access mode for this module view or not.
  * Called from index.php.
  */
 static function checkModuleView($module, $view)
 {
     if (!eZSSLZone::enabled()) {
         return;
     }
     $ini = eZINI::instance();
     $viewsModes = $ini->variable('SSLZoneSettings', 'ModuleViewAccessMode');
     $sslViews = array_keys($viewsModes, 'ssl');
     $keepModeViews = array_keys($viewsModes, 'keep');
     $sslPriority = eZSSLZone::viewIsInArray($module, $view, $sslViews);
     $keepModePriority = eZSSLZone::viewIsInArray($module, $view, $keepModeViews);
     if ($sslPriority && $keepModePriority && $sslPriority == $keepModePriority) {
         eZDebug::writeError("Configuration error: view {$module}/{$view} is defined both as 'ssl' and 'keep'", 'eZSSLZone');
         return;
     }
     /* If the view belongs to the list of views we should not change access mode for,
      * then do nothing.
      * (however, the view may do access mode switch itself later)
      */
     if ($keepModePriority > $sslPriority) {
         eZDebugSetting::writeDebug('kernel-ssl-zone', 'Keeping current access mode...');
         return;
     }
     /* Otherwise we look if the view is in the list of SSL views,
      * and if it is, we switch to SSL. Else, if it's not, we switch to plain HTTP.
      */
     $inSSL = $sslPriority > 0;
     eZDebugSetting::writeDebug('kernel-ssl-zone', isset($inSSL) ? $inSSL ? 'yes' : 'no' : 'dunno', 'Should we use SSL for this view?');
     // Change access mode if we need to.
     eZSSLZone::switchIfNeeded($inSSL);
 }