Example #1
0
 public function clearBlockCache($pageId)
 {
     if ($this->_cache) {
         $bm = new Blockmanager();
         $this->_cache->remove($bm->hashPage($pageId));
         $this->_cache->remove(Model::factory('Page')->getCacheKey(array('codes')));
     }
 }
Example #2
0
 public function clearBlockCache(Db_Object $object)
 {
     if (!$this->_cache) {
         return;
     }
     $menuModel = Model::factory('Menu');
     $this->_cache->remove($menuModel->resetCachedMenuLinks($object->getId()));
     $blockManager = new Blockmanager();
     $blockManager->invalidateCacheBlockMenu($object->getId());
 }
Example #3
0
 /**
  * Use hard cache expiration time from main config for blocks cache
  * It will decrease the block cache lifetime
  * if the number of cache invalidation triggers is not enough
  * @param boolean $flag
  */
 public static function useHardCacheTime($flag)
 {
     self::$_useHardCacheLifetime = $flag;
 }
Example #4
0
 /**
  * Save default blockmap
  */
 public function defaultblockssaveAction()
 {
     $this->_checkCanEdit();
     $data = Request::post('blocks', 'raw', '');
     if (strlen($data)) {
         $data = json_decode($data, true);
     } else {
         $data = array();
     }
     $blockMapping = Model::factory('Blockmapping');
     $blockMapping->clearMap(0);
     if (!empty($data)) {
         foreach ($data as $place => $items) {
             $blockMapping->addBlocks(0, $place, Utils::fetchCol('id', $items));
         }
     }
     $blockManager = new Blockmanager();
     $blockManager->invalidateDefaultMap();
     Response::jsonSuccess();
 }
Example #5
0
 public function clearBlockCache(Db_Object $object)
 {
     $blockManager = new Blockmanager();
     $blockManager->invalidateCacheBlockId($object->getId());
 }
Example #6
0
 protected function _routeModule()
 {
     $vers = Request::get('vers', 'int', false);
     $showRevision = false;
     $pageCode = $this->_request->getPart(0);
     if (!strlen($pageCode)) {
         $pageCode = 'index';
     }
     $pageData = Model::factory('Page')->getCachedItemByField('code', $pageCode);
     if (empty($pageData)) {
         Response::redirect('/');
     }
     $cacheManager = new Cache_Manager();
     $cache = $cacheManager->get('data');
     $blockManager = false;
     if ($vers) {
         $user = User::getInstance();
         if ($user->isAuthorized() && $user->isAdmin()) {
             $pageData = array_merge($pageData, Model::factory('Vc')->getData('page', $pageData['id'], $vers));
             $showRevision = true;
         } else {
             $vers = false;
         }
     }
     if (!$vers && $cache) {
         Blockmanager::setDefaultCache($cache);
     }
     if ($pageData['published'] == false && !$showRevision) {
         Response::redirect('/');
     }
     $page = Page::getInstance();
     foreach ($pageData as $k => $v) {
         $page->{$k} = $v;
     }
     /**
      * Check if controller attached
      */
     if (strlen($page->func_code)) {
         $fModules = Config::factory(Config::File_Array, $this->_appConfig->get('frontend_modules'));
         if ($fModules->offsetExists($page->func_code)) {
             $controllerConfig = $fModules->get($page->func_code);
             $this->runController($controllerConfig['class'], $this->_request->getPart(1));
         }
     }
     if (!$vers && $cache) {
         Blockmanager::setDefaultCache($cache);
     }
     $blockManager = new Blockmanager();
     if ($page->show_blocks) {
         $blockManager->init($page->id, $page->default_blocks, $vers);
     }
     $this->showPage($page, $blockManager);
 }
Example #7
0
 /**
  * Run frontend application
  */
 protected function _runFrontend()
 {
     Blockmanager::useHardCacheTime($this->_config->get('blockmanager_use_hardcache_time'));
     if ($this->_config->get('maintenance')) {
         $tpl = new Template();
         $tpl->set('msg', Lang::lang()->get('MAINTENANCE'));
         echo $tpl->render($this->_config->get('templates') . 'public/error.php');
         self::close();
     }
     /*
      * Update "Users Online" statistics
      */
     if ($this->_config->get('usersOnline')) {
         $user = User::getInstance();
         if ($user->isAuthorized()) {
             Model::factory('Online')->addOnline(session_id(), $user->id);
         }
     }
     self::$_templates = $this->_config->get('templates') . 'public/';
     $page = Page::getInstance();
     $page->setTemplatesPath(self::$_templates);
     /*
      * Start routing
      */
     $router = new Frontend_Router();
     $router->route();
 }