Ejemplo n.º 1
0
 public static function getModule($module)
 {
     $cfg = erConfigClassLhConfig::getInstance();
     self::$moduleCacheEnabled = $cfg->getSetting('site', 'modulecompile');
     // Because each siteaccess can have different extension cache key has to have this
     $siteAccess = erLhcoreClassSystem::instance()->SiteAccess;
     if (self::$cacheInstance === null) {
         self::$cacheInstance = CSCacheAPC::getMem();
     }
     if (self::$moduleCacheEnabled === true) {
         if (($cacheModules = self::$cacheInstance->restore('moduleFunctionsCache_' . $module . '_' . $siteAccess . '_version_' . self::$cacheVersionSite)) !== false) {
             return $cacheModules;
         }
         $cacheWriter = new erLhcoreClassCacheStorage('cache/cacheconfig/');
         if (($cacheModules = $cacheWriter->restore('moduleFunctionsCache_' . $module . '_' . $siteAccess)) == false) {
             $cacheModules = array();
         }
         if (count($cacheModules) > 0) {
             self::$cacheInstance->store('moduleFunctionsCache_' . $module . '_' . $siteAccess . '_version_' . self::$cacheVersionSite, $cacheModules);
             return $cacheModules;
         }
     }
     $extensions = $cfg->getOverrideValue('site', 'extensions');
     $ViewListCompiled = array();
     // Is it core module
     if (file_exists('modules/lh' . $module . '/module.php')) {
         include 'modules/lh' . $module . '/module.php';
         foreach ($ViewList as $view => $params) {
             $ViewList[$view]['script_path'] = 'modules/lh' . $module . '/' . $view . '.php';
         }
         $ViewListCompiled = array_merge($ViewListCompiled, $ViewList);
     }
     // Is it extension module
     foreach ($extensions as $extension) {
         if (file_exists('extension/' . $extension . '/modules/lh' . $module . '/module.php')) {
             include 'extension/' . $extension . '/modules/lh' . $module . '/module.php';
             foreach ($ViewList as $view => $params) {
                 $ViewList[$view]['script_path'] = 'extension/' . $extension . '/modules/lh' . $module . '/' . $view . '.php';
             }
             $ViewListCompiled = array_merge($ViewListCompiled, $ViewList);
         }
     }
     if (count($ViewListCompiled) > 0) {
         if (self::$moduleCacheEnabled === true) {
             $cacheWriter->store('moduleFunctionsCache_' . $module . '_' . $siteAccess, $ViewListCompiled);
             self::$cacheInstance->store('moduleFunctionsCache_' . $module . '_' . $siteAccess . '_version_' . self::$cacheVersionSite, $ViewListCompiled);
         }
         return $ViewListCompiled;
     }
     // Module does not exists
     return false;
 }