library/core/class.thememanager.php
public function AvailableThemes($Force = FALSE) {
      if (is_null($this->ThemeCache) || $Force) {
      
         $this->ThemeCache = array();
         
         // Check cache freshness
         foreach ($this->SearchPaths() as $SearchPath => $Trash) {
            unset($SearchPathCache);
            
            // Check Cache
            $SearchPathCacheKey = 'Garden.Themes.PathCache.'.$SearchPath;
            if ($this->Apc) {
               $SearchPathCache = apc_fetch($SearchPathCacheKey);
            } else {
               $SearchPathCache = Gdn::Cache()->Get($SearchPathCacheKey, array(Gdn_Cache::FEATURE_NOPREFIX => TRUE));
            }
            
            $CacheHit = ($SearchPathCache !== Gdn_Cache::CACHEOP_FAILURE);
            if ($CacheHit && is_array($SearchPathCache)) {
               $CacheIntegrityCheck = (sizeof(array_intersect(array_keys($SearchPathCache), array('CacheIntegrityHash', 'ThemeInfo'))) == 2);
               if (!$CacheIntegrityCheck) {
                  $SearchPathCache = array(
                     'CacheIntegrityHash'    => NULL,
                     'ThemeInfo'             => array()
                  );
               }
            }
            
            $CacheThemeInfo = &$SearchPathCache['ThemeInfo'];
            if (!is_array($CacheThemeInfo))
               $CacheThemeInfo = array();
            
            $PathListing = scandir($SearchPath, 0);
            sort($PathListing);
            
            $PathIntegrityHash = md5(serialize($PathListing));
            if (GetValue('CacheIntegrityHash',$SearchPathCache) != $PathIntegrityHash) {
               // Trace('Need to re-index theme cache');
               // Need to re-index this folder
               $PathIntegrityHash = $this->IndexSearchPath($SearchPath, $CacheThemeInfo, $PathListing);
               if ($PathIntegrityHash === FALSE)
                  continue;
               
               $SearchPathCache['CacheIntegrityHash'] = $PathIntegrityHash;
               if ($this->Apc) {
                  apc_store($SearchPathCacheKey, $SearchPathCache);
               } else {
                  Gdn::Cache()->Store($SearchPathCacheKey, $SearchPathCache, array(Gdn_Cache::FEATURE_NOPREFIX => TRUE));
               }
            }
            
            $this->ThemeCache = array_merge($this->ThemeCache, $CacheThemeInfo);
         }
      }
            
      return $this->ThemeCache;
   }
public function AvailableThemes($Force = FALSE) {
      if (is_null($this->ThemeCache) || $Force) {
      
         $this->ThemeCache = array();
         
         // Check cache freshness
         foreach ($this->SearchPaths() as $SearchPath => $Trash) {
            unset($SearchPathCache);
            
            // Check Cache
            $SearchPathCacheKey = 'Garden.Themes.PathCache.'.$SearchPath;
            if ($this->Apc) {
               $SearchPathCache = apc_fetch($SearchPathCacheKey);
            } else {
               $SearchPathCache = Gdn::Cache()->Get($SearchPathCacheKey, array(Gdn_Cache::FEATURE_NOPREFIX => TRUE));
            }
            
            $CacheHit = ($SearchPathCache !== Gdn_Cache::CACHEOP_FAILURE);
            if ($CacheHit && is_array($SearchPathCache)) {
               $CacheIntegrityCheck = (sizeof(array_intersect(array_keys($SearchPathCache), array('CacheIntegrityHash', 'ThemeInfo'))) == 2);
               if (!$CacheIntegrityCheck) {
                  $SearchPathCache = array(
                     'CacheIntegrityHash'    => NULL,
                     'ThemeInfo'             => array()
                  );
               }
            }
            
            $CacheThemeInfo = &$SearchPathCache['ThemeInfo'];
            if (!is_array($CacheThemeInfo))
               $CacheThemeInfo = array();
            
            $PathListing = scandir($SearchPath, 0);
            sort($PathListing);
            
            $PathIntegrityHash = md5(serialize($PathListing));
            if (GetValue('CacheIntegrityHash',$SearchPathCache) != $PathIntegrityHash) {
               // Trace('Need to re-index theme cache');
               // Need to re-index this folder
               $PathIntegrityHash = $this->IndexSearchPath($SearchPath, $CacheThemeInfo, $PathListing);
               if ($PathIntegrityHash === FALSE)
                  continue;
               
               $SearchPathCache['CacheIntegrityHash'] = $PathIntegrityHash;
               if ($this->Apc) {
                  apc_store($SearchPathCacheKey, $SearchPathCache);
               } else {
                  Gdn::Cache()->Store($SearchPathCacheKey, $SearchPathCache, array(Gdn_Cache::FEATURE_NOPREFIX => TRUE));
               }
            }
            
            $this->ThemeCache = array_merge($this->ThemeCache, $CacheThemeInfo);
         }
      }
            
      return $this->ThemeCache;
   }
public function AvailableThemes ( $ Force = FALSE ) { if ( is_null ( $ this -> ThemeCache ) || $ Force ) { $ this -> ThemeCache = array ( ) ; // Check cache freshness foreach ( $ this -> SearchPaths ( ) as $ SearchPath => $ Trash ) { unset ( $ SearchPathCache ) ; // Check Cache $ SearchPathCacheKey = 'Garden.Themes.PathCache.' . $ SearchPath ; if ( $ this -> Apc ) { $ SearchPathCache = apc_fetch ( $ SearchPathCacheKey ) ; } else { $ SearchPathCache = Gdn :: Cache ( ) -> Get ( $ SearchPathCacheKey , array ( Gdn_Cache :: FEATURE_NOPREFIX => TRUE ) ) ; } $ CacheHit = ( $ SearchPathCache !== Gdn_Cache :: CACHEOP_FAILURE ) ; if ( $ CacheHit && is_array ( $ SearchPathCache ) ) { $ CacheIntegrityCheck = ( sizeof ( array_intersect ( array_keys ( $ SearchPathCache ) , array ( 'CacheIntegrityHash' , 'ThemeInfo' ) ) ) == 2 ) ; if ( ! $ CacheIntegrityCheck ) { $ SearchPathCache = array ( 'CacheIntegrityHash' => NULL , 'ThemeInfo' => array ( ) ) ; } } $ CacheThemeInfo = & $ SearchPathCache [ 'ThemeInfo' ] ; if ( ! is_array ( $ CacheThemeInfo ) ) $ CacheThemeInfo = array ( ) ; $ PathListing = scandir ( $ SearchPath , 0 ) ; sort ( $ PathListing ) ; $ PathIntegrityHash = md5 ( serialize ( $ PathListing ) ) ; if ( GetValue ( 'CacheIntegrityHash' , $ SearchPathCache ) != $ PathIntegrityHash ) { // Trace('Need to re-index theme cache'); // Need to re-index this folder $ PathIntegrityHash = $ this -> IndexSearchPath ( $ SearchPath , $ CacheThemeInfo , $ PathListing ) ; if ( $ PathIntegrityHash === FALSE ) continue ; $ SearchPathCache [ 'CacheIntegrityHash' ] = $ PathIntegrityHash ; if ( $ this -> Apc ) { apc_store ( $ SearchPathCacheKey , $ SearchPathCache ) ; } else { Gdn :: Cache ( ) -> Store ( $ SearchPathCacheKey , $ SearchPathCache , array ( Gdn_Cache :: FEATURE_NOPREFIX => TRUE ) ) ; } } $ this -> ThemeCache = array_merge ( $ this -> ThemeCache , $ CacheThemeInfo ) ; } } return $ this -> ThemeCache ; }
Looks through the themes directory for valid themes and returns them as
an associative array of "Theme Name" => "Theme Info Array". It also adds
a "Folder" definition to the Theme Info Array for each.
Looks through the themes directory for valid themes and returns them as an associative array of Theme Name = > Theme Info Array . It also adds a Folder definition to the Theme Info Array for each .