Example #1
0
 /**
  * @return array names of plugins that have been loaded
  */
 public function loadTrackerPlugins()
 {
     $cache = new PersistentCache('PluginsTracker');
     if ($cache->has()) {
         $pluginsTracker = $cache->get();
     } else {
         $this->unloadPlugins();
         $this->loadActivatedPlugins();
         $pluginsTracker = array();
         foreach ($this->loadedPlugins as $pluginName => $plugin) {
             if ($this->isTrackerPlugin($plugin)) {
                 $pluginsTracker[] = $pluginName;
             }
         }
         if (!empty($pluginsTracker)) {
             $cache->set($pluginsTracker);
         }
     }
     $this->unloadPlugins();
     if (empty($pluginsTracker)) {
         return array();
     }
     $pluginsTracker = array_diff($pluginsTracker, Tracker::getPluginsNotToLoad());
     $this->doNotLoadAlwaysActivatedPlugins();
     $this->loadPlugins($pluginsTracker);
     return $pluginsTracker;
 }
Example #2
0
 public function findMultipleComponents($directoryWithinPlugin, $expectedSubclass)
 {
     $this->cache->setCacheKey('Plugin' . $this->pluginName . $directoryWithinPlugin . $expectedSubclass);
     if ($this->cache->has()) {
         $components = $this->cache->get();
         if ($this->includeComponents($components)) {
             return $components;
         } else {
             // problem including one cached file, refresh cache
         }
     }
     $components = $this->doFindMultipleComponents($directoryWithinPlugin, $expectedSubclass);
     $this->cache->set($components);
     return $components;
 }
 /**
  * @return CacheFile
  */
 private static function getStorage()
 {
     if (is_null(self::$storage)) {
         self::$storage = new CacheFile('tracker', 43200);
         self::$storage->addOnDeleteCallback(function () {
             PersistentCache::_reset();
         });
     }
     return self::$storage;
 }
Example #4
0
 private static function getCachedDimensionFileChanges()
 {
     $persistentCache = new PersistentCache('AllDimensionModifyTime');
     if ($persistentCache->has()) {
         return $persistentCache->get();
     }
     return array();
 }
Example #5
0
 private function loadAvailableLanguages()
 {
     if (!is_null($this->availableLanguageNames)) {
         return;
     }
     $cache = new PersistentCache('availableLanguages');
     if ($cache->has()) {
         $languagesInfo = $cache->get();
     } else {
         $filenames = $this->getAvailableLanguages();
         $languagesInfo = array();
         foreach ($filenames as $filename) {
             $data = file_get_contents(PIWIK_INCLUDE_PATH . "/lang/{$filename}.json");
             $translations = json_decode($data, true);
             $languagesInfo[] = array('code' => $filename, 'name' => $translations['General']['OriginalLanguageName'], 'english_name' => $translations['General']['EnglishLanguageName']);
         }
         $cache->set($languagesInfo);
     }
     $this->availableLanguageNames = $languagesInfo;
 }