コード例 #1
0
 public function cacheCleanGlobalAction()
 {
     HCMS_Cache::getInstance()->getObjectCache(Application_Model_TranslateMapper::getInstance())->clean();
     HCMS_Cache::getInstance()->getCoreCache()->clean();
     $this->_log("All caches cleaned explicitly.", Zend_Log::INFO);
     $this->_helper->json(array("success" => true));
 }
コード例 #2
0
ファイル: Cache.php プロジェクト: bokultis/kardiomedika
 /**
  * get instance
  *
  *
  * @return HCMS_Cache
  */
 public static function getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
コード例 #3
0
ファイル: Db.php プロジェクト: bokultis/kardiomedika
 /**
  * Load translation data
  *
  * @param  string|array  $data
  * @param  string        $locale  Locale/Language to add data for, identical with locale identifier,
  *                                see Zend_Locale for more information
  * @param  array         $options OPTIONAL Options to use
  * @return array
  */
 protected function _loadTranslationData($data, $locale, array $options = array())
 {
     if (isset($options['section'])) {
         self::$_section = $options['section'];
     }
     /* @var $translateCache Application_Model_TranslateMapper */
     $translateCache = HCMS_Cache::getInstance()->getObjectCache(Application_Model_TranslateMapper::getInstance());
     //read data from cache object
     $data = $translateCache->__call("load", array($locale, self::$_section));
     $options = array_merge($this->_options, $options);
     if (isset($this->_options['clear']) && $this->_options['clear'] === true || !isset($this->_translate[$locale])) {
         $this->_translate[$locale] = array();
     }
     $this->_translate[$locale] = array_merge($this->_translate[$locale], $data);
 }
コード例 #4
0
ファイル: RenderPage.php プロジェクト: bokultis/kardiomedika
 /**
  * Stores content as view script in cache and renders it
  * 
  * @param Cms_Model_Page $page
  */
 protected function _renderPageAsView(Cms_Model_Page $page)
 {
     $cacheId = HCMS_Controller_Action_Cms_Page::CMS_PAGE_CACHE_PRE . $page->get_id();
     $resources = Zend_Controller_Front::getInstance()->getParam("bootstrap")->getOption('resources');
     $cacheDir = $resources['cachemanager']['core']['backend']['options']['cache_dir'];
     $cacheFileName = 'zend_cache---' . $cacheId;
     // Create Zend_Cache_Core object
     $cache = HCMS_Cache::getInstance()->getCoreCache();
     // If no cache available for this content page
     if (!$cache->test($cacheId)) {
         $cache->save((string) $page->get_content(), $cacheId);
         //forcing raw string :(
         file_put_contents($cacheDir . "/" . $cacheFileName, $page->get_content());
     }
     $this->view->addScriptPath($cacheDir);
     return $this->view->render($cacheFileName);
 }
コード例 #5
0
ファイル: Bootstrap.php プロジェクト: bokultis/kardiomedika
 /**
  * Set caching
  *
  * @return void
  */
 public function _initCache()
 {
     if (!Zend_Registry::isRegistered('cachemanager')) {
         return false;
     }
     $cache = HCMS_Cache::getInstance()->getCoreCache();
     //set cache for table metadata
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     //set cache for locale
     Zend_Locale::setCache($cache);
     //set cache for translate
     Zend_Translate::setCache($cache);
     //plugin loader cache
     $classFileIncCache = APPLICATION_PATH . '/../cache/file/pluginLoaderCache.php';
     if (file_exists($classFileIncCache)) {
         include_once $classFileIncCache;
     }
     Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
 }
コード例 #6
0
 public function activateAction()
 {
     //Get theme name
     $theme = $this->_getParam('theme');
     // Update database
     $mapper = Application_Model_ApplicationMapper::getInstance();
     $appSettings = $mapper->fetchAll();
     $settings = $appSettings[0]->get_settings();
     $settings['theme'] = $theme;
     $app = new Application_Model_Application();
     $app->set_settings($settings);
     $app->set_id(1);
     $mapper->save($app);
     //Create symlinks
     //$this->_createSymlinks($theme);
     //Delete cache
     HCMS_Cache::getInstance()->getObjectCache(Application_Model_TranslateMapper::getInstance())->clean();
     HCMS_Cache::getInstance()->getCoreCache()->clean();
     //Return json
     $this->_helper->json(array('message' => $this->translate("Theme is activated"), 'success' => true));
 }
コード例 #7
0
ファイル: RouteMapper.php プロジェクト: bokultis/kardiomedika
 /**
  * Invalidate routes cache
  * 
  */
 public function cleanCache()
 {
     HCMS_Cache::getInstance()->getCoreCache()->remove(self::$_cacheId);
 }
コード例 #8
0
 /**
  * Add new translation key
  * 
  * @param array $translation
  * @param string $locale
  * @return int|false
  */
 public function addTranslation($translation, $locale)
 {
     if (!$this->isLangAvailable($locale)) {
         return false;
     }
     if (!isset($translation['language_id'])) {
         $translation['language_id'] = self::$_languages[$locale]['id'];
     }
     //clean cache
     HCMS_Cache::getInstance()->getObjectCache(Application_Model_TranslateMapper::getInstance())->clean();
     return $this->_dbTable->insert($translation);
 }
コード例 #9
0
 /**
  * Invalidate app cache
  *
  * @param int $applicationId
  */
 public function cleanCache($applicationId)
 {
     $this->_initLogger();
     $this->_log("App cache cleaned", Zend_Log::INFO);
     HCMS_Cache::getInstance()->getCoreCache()->remove($this->_getCacheId($applicationId));
 }
コード例 #10
0
 /**
  * Get Zend Navigation items
  * 
  * @param array $criteria
  * @return array
  */
 public function fetchZendNavigationArray($criteria = array(), $order = array(), $useCache = false)
 {
     if ($useCache) {
         //$this->_initLogger();
         $cacheId = $this->_getCacheId($criteria, $order);
         $cache = HCMS_Cache::getInstance()->getCoreCache();
         if (($result = $cache->load($cacheId)) !== FALSE) {
             //$this->_log("Zend navigation loaded from cache", Zend_Log::WARN);
             return $result;
         }
     }
     $items = $this->fetchAll($criteria, $order);
     if (!is_array($items)) {
         return array();
     }
     /**
      * Tree structure is plain array where key is item ID from db table.
      * Every key has data like assocc array with all item data + array child_nodes where are ID's of all child nodes of item
      * There is only one string key called 'root', it points to ID of root of the tree, if it is 0 then there is no tree.
      * This representation of tree is good because it is filled with one pass by reading db and it can be processed recursively
      */
     $tree = array('root' => 0, 0 => array('child_nodes' => array()));
     /*@var $item Cms_Model_MenuItem */
     foreach ($items as $item) {
         // if there is no parent node of current node then it is out of order, we can only skip it
         if (!isset($tree[$item->get_parent_id()])) {
             continue;
         }
         // add current node in the list of parent's children
         $tree[$item->get_parent_id()]['child_nodes'][] = $item->get_id();
         // add current note in tree
         $tree[$item->get_id()]['entity'] = $item;
         // make empty children list for current node
         $tree[$item->get_id()]['child_nodes'] = array();
     }
     $links = $this->_generatePagesTree($tree, 0);
     //store cache
     if ($useCache) {
         //$this->_log("Zend navigation saved in cache", Zend_Log::WARN);
         $cache->save($links, $cacheId, array(self::$_cacheTag));
     }
     return $links;
 }
コード例 #11
0
ファイル: GAMapper.php プロジェクト: bokultis/kardiomedika
 /**
  * get cache object
  * 
  * @return Zend_Cache_Core
  */
 private function _getCacheObject()
 {
     return HCMS_Cache::getInstance()->getCustomCache('core', array('frontend' => array('name' => 'Core', 'options' => array('lifetime' => 86400, 'automatic_serialization' => true))));
 }