function initDataProvider($connection = false)
{
    global $CONFIG, $DB_CONNECTOR, $CM;
    if (!empty($CONFIG["gl_datprov"])) {
        if (!defined("DB_PREFIX")) {
            define("DB_PREFIX", $CONFIG["gl_db_prefix"]);
        }
        $DB_CONNECTOR = new DBManager($CONFIG["gl_db_user"], $CONFIG["gl_db_pass"], $CONFIG["gl_db_host"], $CONFIG["gl_db_name"], $CONFIG["gl_db_prefix"]);
        if (!empty($CONFIG["gl_db_ext"])) {
            DBManager::$Extension = $CONFIG["gl_db_ext"];
        }
        if ($DB_CONNECTOR->InitConnection()) {
            $connection = true;
        }
    }
    if (!defined("DB_CONNECTION")) {
        define("DB_CONNECTION", $connection);
    }
    if ($connection) {
        loadDatabaseConfig(false, $CONFIG["gl_db_prefix"]);
        if (!isset($CONFIG["gl_caen"])) {
            $CONFIG["gl_caen"] = 1;
        }
        if (!isServerSetup() && !is("IN_API") && CacheManager::CachingAvailable($CONFIG["gl_caen"]) !== false) {
            $gttl = min($CONFIG["poll_frequency_clients"], $CONFIG["poll_frequency_tracking"]) * 2;
            $sttl = !empty($CONFIG["gl_st_upin"]) ? $CONFIG["gl_st_upin"] : 3600;
            $CM = new CacheManager(md5(SUBSITEHOST . $CONFIG["gl_lzid"] . $CONFIG["gl_db_prefix"] . $CONFIG["gl_db_pass"] . $CONFIG["gl_db_user"] . $CONFIG["gl_db_name"]), $gttl, array(111 => array("VISITOR", 512), 112 => array("EVENTS", 128), 113 => array("INTERNAL", 256, $gttl * 2), 114 => array("GROUPS", 256, $gttl * 2), 115 => array("FILTERS", 128, $gttl * 2), 116 => array("DBCNF", 128, $gttl * 2), 117 => array("STATS", 1, $sttl), 118 => array("DUT", 1)));
            $CM->Read();
        }
        loadDatabaseConfig(true, $CONFIG["gl_db_prefix"]);
    }
    return $connection;
}
 /**
  * This method has side effects, so it is not the constructor.
  *
  * @param ClassFinderInterface $finder
  * @param CacheManager $cacheManager
  *
  * @return self
  *
  * @throws \Exception
  */
 static function create($finder, $cacheManager)
 {
     /** @var self $loader */
     $loader = new static($finder);
     $cacheManager->observeCachePrefix($loader);
     return $loader;
 }
Esempio n. 3
0
 /**
  * @covers Xoops\Core\Cache\CacheManager::getCache
  */
 public function testGetCache()
 {
     $pool1 = $this->object->getCache('default');
     $this->assertInstanceOf('Xoops\\Core\\Cache\\Access', $pool1);
     $pool2 = $this->object->getCache('nosuchpooldefinition');
     $this->assertInstanceOf('Xoops\\Core\\Cache\\Access', $pool2);
     $this->assertSame($pool1, $pool2);
 }
 private function createReaction($id)
 {
     $key = "ReactionObject-{$id}";
     if ($this->cacheMgr->isCached($key)) {
         return $this->cacheMgr->load($key);
     } else {
         $object = new Reaction($id);
         $this->cacheMgr->save($key, $object, 3600);
         return $object;
     }
 }
 /**
  * This method has side effects, so it is not the constructor.
  *
  * @param ClassFinderInterface $finder
  * @param CacheManager $cacheManager
  *
  * @return self
  *
  * @throws \Exception
  */
 static function create($finder, $cacheManager)
 {
     /** @var self $loader */
     $loader = new static($finder);
     if (!$loader->checkRequirements()) {
         $class = get_class($loader);
         throw new CacheNotSupportedException("Unable to use {$class}, because the respetive PHP extension is not enabled.");
     }
     $cacheManager->observeCachePrefix($loader);
     return $loader;
 }
Esempio n. 6
0
 /**
  * Test locales.
  */
 function execute()
 {
     // Flush the file cache just to be certain we're using
     // the most recent stuff
     import('cache.CacheManager');
     $cacheManager =& CacheManager::getManager();
     $cacheManager->flush('locale');
     // Load plugins so that their locale data is included too
     $plugins = array();
     foreach (PluginRegistry::getCategories() as $category) {
         echo "Loading plugin category \"{$category}\"...\n";
         $morePlugins = PluginRegistry::loadCategory($category);
         if (is_array($morePlugins)) {
             $plugins += $morePlugins;
         }
     }
     foreach (Locale::getAllLocales() as $locale => $name) {
         if (!empty($this->locales) && !in_array($locale, $this->locales)) {
             continue;
         }
         if ($locale != MASTER_LOCALE) {
             echo "Testing locale \"{$name}\" ({$locale}) against reference locale " . MASTER_LOCALE . ".\n";
             $this->testLocale($locale, MASTER_LOCALE, $plugins);
             $this->testEmails($locale, MASTER_LOCALE);
         }
     }
 }
Esempio n. 7
0
 /**
  * @return DataStore
  */
 private static function get_fs_cache()
 {
     if (self::$fs_cache === null) {
         self::$fs_cache = DataStoreFactory::get_filesystem_store(__CLASS__);
     }
     return self::$fs_cache;
 }
Esempio n. 8
0
 /**
  * Public function that creates a single instance
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Esempio n. 9
0
 public function uninstall()
 {
     $this->drop_tables();
     ConfigManager::delete('web', 'config');
     CacheManager::invalidate('module', 'web');
     WebService::get_keywords_manager()->delete_module_relations();
 }
Esempio n. 10
0
 /**
  * Clear the data cache files (needed because of direct tinkering
  * with settings tables)
  * @return boolean
  */
 function clearDataCache()
 {
     $cacheManager = CacheManager::getManager();
     $cacheManager->flush(null, CACHE_TYPE_FILE);
     $cacheManager->flush(null, CACHE_TYPE_OBJECT);
     return true;
 }
 /**
  * Get schema SQL of required cache framework tables.
  *
  * This method needs ext_localconf and ext_tables loaded!
  *
  * @return string Cache framework SQL
  */
 public function getCachingFrameworkRequiredDatabaseSchema()
 {
     // Use new to circumvent the singleton pattern of CacheManager
     $cacheManager = new CacheManager();
     $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
     // Cache manager needs cache factory. cache factory injects itself to manager in __construct()
     new CacheFactory('production', $cacheManager);
     $tableDefinitions = '';
     foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] as $cacheName => $_) {
         $backend = $cacheManager->getCache($cacheName)->getBackend();
         if (method_exists($backend, 'getTableDefinitions')) {
             $tableDefinitions .= LF . $backend->getTableDefinitions();
         }
     }
     return $tableDefinitions;
 }
 /**
  * Get the HTML contents for this block.
  * @param $templateMgr object
  * @return $string
  */
 function getContents(&$templateMgr)
 {
     $journal =& Request::getJournal();
     $cacheManager =& CacheManager::getManager();
     $cache =& $cacheManager->getFileCache('keywords_' . AppLocale::getLocale(), $journal->getId(), array(&$this, '_cacheMiss'));
     // If the cache is older than a couple of days, regenerate it
     if (time() - $cache->getCacheTime() > 60 * 60 * 24 * KEYWORD_BLOCK_CACHE_DAYS) {
         $cache->flush();
     }
     $keywords =& $cache->getContents();
     if (empty($keywords)) {
         return '';
     }
     // Get the max occurrences for all keywords
     $maxOccurs = array_shift(array_values($keywords));
     // Now sort the array alphabetically
     ksort($keywords);
     $page = Request::getRequestedPage();
     $op = Request::getRequestedOp();
     $templateMgr->assign_by_ref('cloudKeywords', $keywords);
     $templateMgr->assign_by_ref('maxOccurs', $maxOccurs);
     if ($page == 'index' && $op == 'index' || $page == 'issue' || $page == 'search') {
         return parent::getContents($templateMgr);
     } else {
         return '';
     }
 }
 function actionView()
 {
     header('Content-type: application/json');
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     //		if(Yii::app()->user->isGuest){
     //			IjoyPlusServiceUtils::exportServiceError(Constants::SEESION_IS_EXPIRED);
     //			return ;
     //		}
     $thread_id = Yii::app()->request->getParam("thread_id");
     if (!isset($thread_id) || is_null($thread_id)) {
         IjoyPlusServiceUtils::exportServiceError(Constants::PARAM_IS_INVALID);
         return;
     }
     $comment = CacheManager::getCommentCache($thread_id);
     if ($comment === null) {
         IjoyPlusServiceUtils::exportEntity(array('comment' => array()));
     } else {
         $temp = IjoyPlusServiceUtils::transferComments($comment);
         $comments = Comment::model()->getCommentReplies($thread_id, 10, 0);
         $commentTemps = array();
         if (isset($comments) && is_array($comments)) {
             foreach ($comments as $comment) {
                 $commentTemps[] = IjoyPlusServiceUtils::transferComments($comment);
             }
         }
         $temp->replies = $commentTemps;
         IjoyPlusServiceUtils::exportEntity(array('comment' => $temp));
     }
 }
Esempio n. 14
0
 public static function exportProgramEntity($program)
 {
     $prod = array();
     switch (CacheManager::getTopParentType($program->d_type)) {
         case Constants::PROGRAM_TYPE_TV:
             $prod['tv'] = ProgramUtil::genTV($program, true);
             break;
         case Constants::PROGRAM_ANIMATION:
             $prod['tv'] = ProgramUtil::genTV($program, true);
             break;
         case Constants::PROGRAM_TYPE_SHOW:
             $prod['show'] = ProgramUtil::genTV($program, false);
             break;
         case Constants::PROGRAM_TYPE_MOVIE:
             $prod['movie'] = ProgramUtil::genTV($program, true);
             break;
         case Constants::PROGRAM_TYPE_VIDEO:
             $prod['video'] = ProgramUtil::genMovie($program);
             break;
         case Constants::PROGRAM_TYPE_RECORD:
             $prod['show'] = ProgramUtil::genTV($program, false);
             break;
     }
     return $prod;
 }
 /**
  * Clear the data cache.
  */
 function clearDataCache($args, &$request)
 {
     $this->validate();
     import('lib.pkp.classes.cache.CacheManager');
     $cacheManager =& CacheManager::getManager($request);
     $cacheManager->flush();
     $request->redirect('admin');
 }
 /**
  * Get galley objects cache.
  * @return GenericCache
  */
 function &_getGalleyCache()
 {
     if (!isset($this->galleyCache)) {
         $cacheManager =& CacheManager::getManager();
         $this->galleyCache =& $cacheManager->getObjectCache('galley', 0, array(&$this, '_galleyCacheMiss'));
     }
     return $this->galleyCache;
 }
Esempio n. 17
0
 /**
  * Get the submission cache.
  * @return Cache
  */
 function _getCache()
 {
     if (!isset($this->cache)) {
         $cacheManager = CacheManager::getManager();
         $this->cache = $cacheManager->getObjectCache('submissions', 0, array(&$this, '_cacheMiss'));
     }
     return $this->cache;
 }
Esempio n. 18
0
 function &_getCache()
 {
     if (!isset($this->cache)) {
         $cacheManager =& CacheManager::getManager();
         $this->cache =& $cacheManager->getObjectCache('monographs', 0, array(&$this, '_cacheMiss'));
     }
     return $this->cache;
 }
Esempio n. 19
0
 /**
  * Get supp file objects cache.
  * @return GenericCache
  */
 function &_getSuppFileCache()
 {
     if (!isset($this->suppFileCache)) {
         $cacheManager =& CacheManager::getManager();
         $this->suppFileCache =& $cacheManager->getObjectCache('suppfile', 0, array(&$this, '_suppFileCacheMiss'));
     }
     return $this->suppFileCache;
 }
 function &_getArticlesInSectionsCache()
 {
     if (!isset($this->articlesInSectionsCache)) {
         $cacheManager =& CacheManager::getManager();
         $this->articlesInSectionsCache =& $cacheManager->getObjectCache('articlesInSections', 0, array(&$this, '_articlesInSectionsCacheMiss'));
     }
     return $this->articlesInSectionsCache;
 }
 function &_getCache()
 {
     $settingCache =& Registry::get('siteSettingCache', true, null);
     if ($settingCache === null) {
         $cacheManager =& CacheManager::getManager();
         $settingCache = $cacheManager->getFileCache('siteSettings', 'site', array($this, '_cacheMiss'));
     }
     return $settingCache;
 }
 function &_getCache()
 {
     static $settingCache;
     if (!isset($settingCache)) {
         import('cache.CacheManager');
         $cacheManager =& CacheManager::getManager();
         $settingCache = $cacheManager->getCache('siteSettings', 'site', array($this, '_cacheMiss'));
     }
     return $settingCache;
 }
 protected function setUp()
 {
     $this->cacheManager = CacheManager::getManager();
     $this->cacheMisses = 0;
     if (!is_writable($this->cacheManager->getFileCachePath())) {
         $this->markTestSkipped('File cache path not writable.');
     } else {
         parent::setUp();
         $this->cacheManager->flush();
     }
 }
Esempio n. 24
0
 /**
  * Get an issue cache by cache ID.
  * @param $cacheId string
  * @return GenericCache
  */
 function _getCache($cacheId)
 {
     if (!isset($this->caches)) {
         $this->caches = array();
     }
     if (!isset($this->caches[$cacheId])) {
         $cacheManager = CacheManager::getManager();
         $this->caches[$cacheId] = $cacheManager->getObjectCache('issues', $cacheId, array($this, '_cacheMiss'));
     }
     return $this->caches[$cacheId];
 }
Esempio n. 25
0
 /**
  * Clear the data cache.
  * @param $args array
  * @param $request PKPRequest
  */
 function clearDataCache($args, $request)
 {
     // Clear the CacheManager's caches
     $cacheManager = CacheManager::getManager();
     $cacheManager->flush();
     // Clear ADODB's cache
     $userDao = DAORegistry::getDAO('UserDAO');
     // As good as any
     $userDao->flushCache();
     $request->redirect(null, 'admin');
 }
Esempio n. 26
0
 /**
  * List of current organisations.
  *
  * @return array
  */
 public function __invoke()
 {
     $language = $this->translator->getLocale();
     $cacheName = 'organisations_list_' . $language;
     $list = $this->cache->getItem($cacheName);
     if (!$list) {
         $emptyResults = $this->resultsManager->get('EmptySet');
         $sectors = ['arc', 'lib', 'mus'];
         try {
             foreach ($sectors as $sector) {
                 $list[$sector] = [];
                 $results = $this->resultsManager->get('Solr');
                 $params = $results->getParams();
                 $params->addFacet('building', 'Building', false);
                 $params->addFilter('sector_str_mv:0/' . $sector . '/');
                 $params->setLimit(0);
                 $params->setFacetPrefix('0');
                 $params->setFacetLimit('-1');
                 $collection = $results->getFacetList()['building']['list'];
                 foreach ($collection as $item) {
                     $link = $emptyResults->getUrlQuery()->addFacet('building', $item['value']);
                     $displayText = $item['displayText'];
                     if ($displayText == $item['value']) {
                         $displayText = $this->facetHelper->formatDisplayText($displayText)->getDisplayString();
                     }
                     $list[$sector][] = ['name' => $displayText, 'link' => $link];
                 }
                 usort($list[$sector], function ($a, $b) {
                     return strtolower($a['name']) > strtolower($b['name']);
                 });
             }
             $this->cache->setItem($cacheName, $list);
         } catch (\VuFindSearch\Backend\Exception\BackendException $e) {
             foreach ($sectors as $sector) {
                 $list[$sector] = [];
             }
             $this->logError('Error creating organisations list: ' . $e->getMessage());
         }
     }
     return $list;
 }
 function &_getCache($conferenceId)
 {
     static $settingCache;
     if (!isset($settingCache)) {
         $settingCache = array();
     }
     if (!isset($settingCache[$conferenceId])) {
         $cacheManager =& CacheManager::getManager();
         $settingCache[$conferenceId] = $cacheManager->getCache('conferenceSettings', $conferenceId, array($this, '_cacheMiss'));
     }
     return $settingCache[$conferenceId];
 }
 /**
  * Load the application config
  * @return Config
  */
 protected function loadConfig()
 {
     $config = null;
     if (CacheManager::resourceExists(self::CONFIG_RESOURCE_NAME, CacheManager::APPLICATION_SCOPE)) {
         $config = CacheManager::loadResource(self::CONFIG_RESOURCE_NAME, CacheManager::APPLICATION_SCOPE);
     } else {
         $config = ConfigLoader::load(CONFIG_FILE);
         CacheManager::saveResource(self::CONFIG_RESOURCE_NAME, $config, CacheManager::APPLICATION_SCOPE);
     }
     PiconApplication::get()->getConfigLoadListener()->onConfigLoaded($config);
     return $config;
 }
Esempio n. 29
0
 function &_getCache($journalId)
 {
     static $settingCache;
     if (!isset($settingCache)) {
         $settingCache = array();
     }
     if (!isset($settingCache[$journalId])) {
         $cacheManager =& CacheManager::getManager();
         $settingCache[$journalId] =& $cacheManager->getFileCache('journalSettings', $journalId, array($this, '_cacheMiss'));
     }
     return $settingCache[$journalId];
 }
Esempio n. 30
0
 public function createComments()
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         if ($this->save()) {
             $program = CacheManager::getProgramVOByID($this->content_id);
             Program::model()->incCommentCount($this->content_id);
             if ($program !== null) {
                 //	      	var_dump(($program->name));
                 $dynamic = new Dynamic();
                 $dynamic->author_id = $this->author_id;
                 $dynamic->content_id = $program->id;
                 $dynamic->status = Constants::OBJECT_APPROVAL;
                 $dynamic->create_date = new CDbExpression('NOW()');
                 $dynamic->content_desc = $this->comments;
                 $dynamic->content_type = $program->pro_type;
                 $dynamic->content_name = $program->name;
                 $dynamic->dynamic_type = Constants::DYNAMIC_TYPE_COMMENTS;
                 $dynamic->content_pic_url = $program->poster;
                 $dynamic->save();
                 $recommendOwnerId = Dynamic::model()->getRecommendOwnsForProd($this->content_id);
                 if (isset($recommendOwnerId) && is_array($recommendOwnerId)) {
                     foreach ($recommendOwnerId as $id) {
                         if ($id['author_id'] !== Yii::app()->user->id) {
                             // add notify msg
                             $msg = new NotifyMsg();
                             $msg->author_id = $id['author_id'];
                             $msg->nofity_user_id = Yii::app()->user->id;
                             $msg->notify_user_name = Yii::app()->user->getState("nickname");
                             $msg->notify_user_pic_url = Yii::app()->user->getState("pic_url");
                             $msg->content_id = $program->id;
                             $msg->content_info = $program->name;
                             $msg->content_type = $program->pro_type;
                             $msg->created_date = new CDbExpression('NOW()');
                             $msg->status = Constants::OBJECT_APPROVAL;
                             $msg->notify_type = Constants::NOTIFY_TYPE_COMMENT;
                             $msg->content_desc = $this->comments;
                             $msg->save();
                         }
                     }
                 }
             }
             $transaction->commit();
             return true;
         } else {
             $transaction->commit();
             return false;
         }
     } catch (Exception $e) {
         $transaction->rollback();
         return false;
     }
 }