/** * Save the provided library's data to the on disk location. * * @param string $CacheName name of cache library * @return void */ public static function saveCache($CacheName) { if ($CacheName != 'locale') { return; } if (!array_key_exists($CacheName, self::$Caches)) { return false; } $UseCache = Gdn::cache()->type() == Gdn_Cache::CACHE_TYPE_MEMORY && Gdn::cache()->activeEnabled(); if ($UseCache) { $CacheKey = sprintf(Gdn_LibraryMap::CACHE_CACHE_NAME_FORMAT, $CacheName); $Stored = Gdn::cache()->store($CacheKey, self::$Caches[$CacheName]['cache']); } else { $FileName = self::$Caches[$CacheName]['ondisk']; $CacheContents = ""; foreach (self::$Caches[$CacheName]['cache'] as $SectionTitle => $SectionData) { $CacheContents .= "[{$SectionTitle}]\n"; foreach ($SectionData as $StoreKey => $StoreValue) { $CacheContents .= "{$StoreKey} = \"{$StoreValue}\"\n"; } } try { // Fix slashes to get around parse_ini_file issue that drops off \ when loading network file. $CacheContents = str_replace("\\", "/", $CacheContents); Gdn_FileSystem::saveFile(PATH_CACHE . DS . $FileName, $CacheContents, LOCK_EX); } catch (Exception $e) { } } }
/** * * * @return bool */ public function shutdown() { if (!val('dirty', $this->mapInfo)) { return false; } if (!val('save', $this->mapInfo)) { return false; } if (!sizeof($this->map)) { return false; } $MapName = val('name', $this->mapInfo); $FileName = val('ondisk', $this->mapInfo); $MapContents = ''; foreach ($this->map as $SplitTopic => $TopicFiles) { $MapContents .= "[{$SplitTopic}]\n"; foreach ($TopicFiles as $ClassName => $Location) { $Location = $this->fixBackSlash($Location); $MapContents .= "{$ClassName} = \"{$Location}\"\n"; } } try { Gdn_FileSystem::saveFile($FileName, $MapContents, LOCK_EX); $this->mapInfo['dirty'] = false; } catch (Exception $e) { return false; } return true; }