public function preDispatch(Zend_Controller_Request_Abstract $request) { // Kiem tra neu chua dang nhap thi bo qua $identity = Digitalus_Auth::getIdentity(); if (!$identity) { return; } //////////////////////////////////////// // $this->_cache = ZendX_Cache_Manager::getInstance(); $this->_cache = Digitalus_Cache_Manager::getInstance(); // La la cac phuong thuc khac get() no se khong lay tu content tu cache ra if (!$request->isGet()) { self::$doNotCache = true; return; } $module = $request->getModuleName(); $controller = $request->getControllerName(); $action = $request->getActionName(); $path = $request->getPathInfo(); // co loi o day , xem link de biet cach sua $this->_key = md5($path); $this->_keyTags = array($module, "{$module}_{$controller}", "{$module}_{$controller}_{$action}"); if (false !== ($data = $this->getCache())) { $response = $this->getResponse(); $response->setBody($data['default']); $response->sendResponse(); exit; } }
public function RenderAdminMainMenu() { $this->userModel = new Model_User(); $this->currentUser = $this->userModel->getCurrentUser(); $cache = Digitalus_Cache_Manager::getInstance(); $key = 'admin_main_menu_' . $this->currentUser->role; // Lay du lieu tu cache ra if (($html = $cache->loadCache($key)) != false) { return $html; } $objMenus = new Model_Menus(); $rsRootLevel = $objMenus->fetchAll('parent = 0 AND active = 1', 'order ASC'); $html = null; foreach ($rsRootLevel as $rowRootLevel) { $sub_menu_html = null; $rsNextLevel = $rowRootLevel->findDependentRowset($rowRootLevel->getTableClass(), null, $rowRootLevel->select()->where('active = 1')->order('order ASC')); if (count($rsNextLevel) > 0) { $sub_menu_html = self::RenderAdminMenu($rsNextLevel, 0); } if (is_null($sub_menu_html) && empty($rowRootLevel->admin_menu_link)) { continue; } $href = 'javascript:void(0);'; if (!empty($rowRootLevel->admin_menu_link)) { $href = $rowRootLevel->admin_menu_link; } $html .= "<li><a href='{$href}' class='menulink'>{$rowRootLevel->name}</a>{$sub_menu_html}</li>"; } if (!is_null($html)) { $html = "<div id='main_menu'><ul class='menu' id='menu'>{$html}</ul></div>"; } // Luu du lieu vao cache $cache->saveCache($html, $key); return $html; }
public static function getInstance() { if (self::$_instance === null) { self::$_instance = new self(); } return self::$_instance; }
function init() { $this->_errors = Digitalus_View_Error::getInstance(); $this->_message = Digitalus_View_Message::getInstance(); $this->_cacheManager = Digitalus_Cache_Manager::getInstance(); $this->view->currentModuleUrl = $this->_currentModuleUrl = $this->_request->getBaseUrl() . '/' . $this->_request->getModuleName(); $this->view->currentControllerUrl = $this->_currentControllerUrl = $this->_currentModuleUrl . '/' . $this->_request->getControllerName(); $this->view->currentActionUrl = $this->_currentActionUrl = $this->_currentControllerUrl . '/' . $this->_request->getActionName(); //set Helper // $this->view->addHelperPath('Isc/View/Helper', 'Isc_View_Helper'); // $this->view->addHelperPath('Isc/View/Helper/IscFrom', 'Isc_View_Helper_IscFrom'); }
public function RenderAdminFooter() { // $this->userModel = new Model_User(); // $this->currentUser = $this->userModel->getCurrentUser(); $cache = Digitalus_Cache_Manager::getInstance(); $key = 'admin_footer'; if (($data = $cache->loadCache($key)) != false) { return $data; } $this->view->addScriptPath(BASE_TEMPLATES); $data = $this->view->render('footer.phtml'); $cache->saveCache($data, $key); return $data; }
public function RenderAdminMainMenu() { $userModel = new Model_User(); $currentUser = $userModel->getCurrentUser(); $cache = Digitalus_Cache_Manager::getInstance(); $key = 'admin_main_menu_' . $currentUser->user_id; if (($data = $cache->loadCache($key)) != false) { return $data; } $this->view->addScriptPath(BASE_TEMPLATES); $data = $this->view->render('main_menu.phtml'); $cache->saveCache($data, $key); return $data; }
public function RenderListIcons($dir, $name) { $cache = Digitalus_Cache_Manager::getInstance(); $key = "{$dir}/{$name}"; if (($data = $cache->loadCache($key)) != false) { return $data; } $arr_files = Digitalus_Filesystem_File::getFilesByType($dir, array('png', 'jpg', 'gif')); $dir = Digitalus_Toolbox_String::stripLeading(BASE_PATH, $dir); $data = " <input type='radio' value='' name='{$name}'/> Empty "; foreach ($arr_files as $icon_file) { $data .= " <span><input type='radio' value='{$icon_file}' name='admin_menu_img'/> "; $data .= "<img src='{$dir}/{$icon_file}' alt='{$icon_file}'/></span> "; } $cache->saveCache($data, $key); return $data; }
/** * Initialize the cache * * @return Zend_Cache_Core */ protected function _initCache() { // Cache options $frontendOptions = array('lifetime' => 1800, 'automatic_serialization' => true); $backendOptions = array('lifetime' => 3600, 'cache_dir' => BASE_PATH . '/cache/'); // Get a Zend_Cache_Core object $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); Zend_Registry::set('cache', $cache); Digitalus_Cache_Manager::setCacheObject($cache); // Return it, so that it can be stored by the bootstrap return $cache; }
public function removeDataFormCache($key) { $cache = Digitalus_Cache_Manager::getInstance(); if ($key == $this->_name) { $cache->removeCache(array($key)); } else { $cache->removeCache($key); } }