/** * @param string $clusterIdentifier * @param string $systemCategory * @return string */ static public function fetchByClusterAndSystem( $clusterIdentifier, $systemCategory ) { $sl = CacheTool::dailyValue( 'systemLocale' ); if( $sl === false || is_null( $sl ) ) { $db = MMDB::instance(); $sls = self::fetchByClusterIdentifier( $clusterIdentifier ); $cachedValues = array(); foreach( $sls as $sl ) { $referenceQuery = "SELECT code FROM bo_reference WHERE id = " . $sl->attribute( 'system_reference_id' ); $ref = $db->arrayQuery( sprintf( $referenceQuery, $sl->attribute( 'system_reference_id' ) ) ); if( count( $ref ) > 0 ) { $cachedValues[$ref[0]['code']] = $sl->attribute( 'value' ); } } CacheTool::dailyValue( 'systemLocale', $cachedValues ); $sl = CacheTool::dailyValue( 'systemLocale' ); } return $sl[$systemCategory]; }
/** * @param string $identifier * @return string[] */ static protected function getFilteredTaxonomyWithIDs( $identifier ) { if ( $identifier == "") { return array(); } $filteredTaxonomy = CacheTool::dailyValue('filteredTaxonomyWithIDs'); if( is_array($filteredTaxonomy) && isset($filteredTaxonomy[$identifier]) ) { return $filteredTaxonomy[$identifier]; } // no cache value found; if( !is_array($filteredTaxonomy) ) { $filteredTaxonomy = array(); } $temp = self::filteredTaxonomy ( $identifier ); $temp2 = array(); foreach ( $temp as $taxonomy ) { $temp2[$taxonomy['code']] = array('id' => $taxonomy['id'], 'label' => $taxonomy['label']); } $filteredTaxonomy[$identifier] = $temp2; CacheTool::dailyValue( 'filteredTaxonomyWithIDs', $filteredTaxonomy ); return $filteredTaxonomy[$identifier]; }
/** * @return int[] */ public function rootNodeIds() { // fake apps like application library or my-selection if( $this->getApplicationId() == 0 ) return null; $contentListRootNodeIds = CacheTool::dailyValue('contentListRootNodeIds'); if( is_array($contentListRootNodeIds) && isset($contentListRootNodeIds[$this->applicationName()]) ) return $contentListRootNodeIds[$this->applicationName()]; // no cache value found; if( !is_array($contentListRootNodeIds) ) $contentListRootNodeIds = array(); $contentListRootNodeIds[$this->applicationName()] = $this->applicationLocalized->publisherNodeIds(); CacheTool::dailyValue( 'contentListRootNodeIds', $contentListRootNodeIds ); return $contentListRootNodeIds[$this->applicationName()]; }
/** * @return array */ public static function version_json() { $cacheManifest = CacheTool::dailyValue(self::MOBILE_MANIFEST_NAME); if(is_null($cacheManifest)) $cacheManifest = array(); $allAppIds = CountryApplicationLibrary::fetchAuthorizedApplicationIds(); $applicationIds = array('my-selection', 'application-library', 'register', 'global-search', 'contactus-fr', 'sendtocolleague', 'mobile-app-settings'); foreach ( $allAppIds as $appId ) { if ( $appId == 0 ) continue; $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByApplication($appId); if ( !($applicationLocalized instanceof ApplicationLocalized) ) continue; if ( (bool) $applicationLocalized->applicationObject->attribute('application_library') ) { $applicationIds[] = $applicationLocalized->applicationObject->attribute('identifier'); } } $newApps = array_diff($applicationIds, array_keys($cacheManifest)); if(count($newApps)) { // fill the cacheManifest with new entry foreach($newApps as $newApp) { $cacheManifest[$newApp] = array("js" => array_flip(self::getJavascript($newApp, 'all')), "css" => array_flip(self::getCSS($newApp)) ); } // save new applications in cache CacheTool::dailyValue(self::MOBILE_MANIFEST_NAME, $cacheManifest); } $js = array(); $css = array(); foreach($applicationIds as $id) { $js = array_merge($js, $cacheManifest[$id]["js"]); $css = array_merge($css, $cacheManifest[$id]["css"]); } return array_unique(array_merge($js, $css)); }
/** * @return array[] */ static function getMapping() { if ( !empty($_mapping) ) { return self::$_mapping; } $mapping = CacheTool::dailyValue('userSpeMapping'); if ( $mapping === false || is_null($mapping) ) { $conditionList = ClusterTool::clusterOverride( array( 'is_available' => '1' ) ); foreach ($conditionList as $condition) { $mapping = self::fetchObjectList(self::definition(), null, $condition, false); if ( is_array($mapping) && count($mapping) > 0 ) { break; } } $mapping = self::flattenMapping($mapping); self::$_mapping = $mapping; CacheTool::dailyValue('userSpeMapping', $mapping); } else { self::$_mapping = $mapping; } return $mapping; }
/** * Stores an item in the cache * * The item will be serialized using serialize() before storage. * * @param string $key Cache key to use * @param mixed $value Value of store in cache **/ protected function storeCacheValue( $key, $value ) { $value = serialize( $value ); CacheTool::dailyValue( $this->cacheKey( $key ), $value ); }