Example #1
0
 public function menuXmlAction()
 {
     //echo "<!-- start ts " . calcTS() . "-->";
     header("Cache-Control: public");
     header("Pragma: public");
     $cache = Zend_Registry::get('cache');
     $cacheKey = "menu-" . Menu::getCurrentlySelectedActivityGroup() . "-" . Menu::getCurrentUserRole();
     $cacheKey = str_replace('-', '_', $cacheKey);
     $cacheKey = str_replace('/', '_', $cacheKey);
     if ($cache->test($cacheKey . "_hash")) {
         $hash = $cache->load($cacheKey . "_hash");
         $lastModified = $cache->load($cacheKey . "_lastModified");
         $headers = getallheaders();
         if (isset($headers['If-None-Match']) && preg_match('/' . $hash . '/', $headers['If-None-Match'])) {
             header("Last-Modified: " . $lastModified);
             header('HTTP/1.1 304 Not Modified');
             exit;
         }
     }
     $menuXml = "";
     if (false && $cache->test($cacheKey)) {
         $menuXml = $cache->load($cacheKey);
     } else {
         $menuXml = Menu::generateCurrentMenu();
         $hash = md5($menuXml);
         $lastModified = gmdate("D, d M Y H:i:s") . " GMT";
         $objConfig = new ConfigItem();
         $objConfig->configId = 'enableCache';
         $objConfig->populate();
         if ($objConfig->value) {
             $cache->save($hash, $cacheKey . "_hash", array('tagMenu'));
             $cache->save($lastModified, $cacheKey . "_lastModified", array('tagMenu'));
             $cache->save($menuXml, $cacheKey, array('tagMenu'));
         }
         header("ETag: " . $hash);
         header("Last-Modified: " . $lastModified);
         header("Content-length: " . mb_strlen($menuXml));
     }
     $this->view->menuXml = $menuXml;
     header('Content-Type: application/xml;');
     $this->render('menuXml');
     //echo "<!-- second ts " . calcTS() . "-->";
 }
Example #2
0
 protected function _renderToolbar($phtml = "toolbar")
 {
     header("Cache-Control: public");
     header("Pragma: public");
     $cache = Zend_Registry::get('cache');
     $className = get_class($this);
     $className = str_replace('Controller', '', $className);
     $keyPref = substr(strtolower(preg_replace('/([A-Z]{1})/', '_\\1', $className)), 1);
     $cacheKey = $keyPref . "-toolbar-" . Menu::getCurrentlySelectedActivityGroup() . "-" . Menu::getCurrentUserRole();
     $cacheKey = str_replace('-', '_', $cacheKey);
     $cacheKey = str_replace('/', '_', $cacheKey);
     if ($cache->test($cacheKey . "_hash")) {
         $hash = $cache->load($cacheKey . "_hash");
         $lastModified = $cache->load($cacheKey . "_lastModified");
         $headers = getallheaders();
         if (isset($headers['If-None-Match']) && ereg($hash, $headers['If-None-Match'])) {
             header("Last-Modified: " . $lastModified);
             header('HTTP/1.1 304 Not Modified');
             exit;
         }
     }
     if ($cache->test($cacheKey)) {
         $items = $cache->load($cacheKey);
     } else {
         $items = $this->render($phtml);
         $hash = md5($items);
         $lastModified = gmdate("D, d M Y H:i:s") . " GMT";
         $objConfig = new ConfigItem();
         $objConfig->configId = 'enableCache';
         $objConfig->populate();
         if ($objConfig->value) {
             $cache->save($hash, $cacheKey . "_hash", array('tagToolbar'));
             $cache->save($lastModified, $cacheKey . "_lastModified", array('tagToolbar'));
             $cache->save($items, $cacheKey, array('tagToolbar'));
         }
         header("ETag: " . $hash);
         header("Last-Modified: " . $lastModified);
         header("Content-length: " . mb_strlen($items));
     }
     header("Content-type: text/xml");
     return $items;
 }
 public function toolbarAction()
 {
     header("Cache-Control: public");
     header("Pragma: public");
     $cache = Zend_Registry::get('cache');
     $cacheKey = "toolbar-" . Menu::getCurrentlySelectedActivityGroup() . "-" . Menu::getCurrentUserRole();
     $cacheKey = str_replace('-', '_', $cacheKey);
     $cacheKey = str_replace('/', '_', $cacheKey);
     if ($cache->test($cacheKey . "_hash")) {
         $hash = $cache->load($cacheKey . "_hash");
         $lastModified = $cache->load($cacheKey . "_lastModified");
         $headers = getallheaders();
         if (isset($headers['If-None-Match']) && ereg($hash, $headers['If-None-Match'])) {
             header("Last-Modified: " . $lastModified);
             header('HTTP/1.1 304 Not Modified');
             exit;
         }
     }
     if ($cache->test($cacheKey)) {
         $items = $cache->load($cacheKey);
     } else {
         $items = $this->render('toolbar');
         $hash = md5($items);
         $lastModified = gmdate("D, d M Y H:i:s") . " GMT";
         $objConfig = new ConfigItem();
         $objConfig->configId = 'enableCache';
         $objConfig->populate();
         if ($objConfig->value) {
             $cache->save($hash, $cacheKey . "_hash", array('tagToolbar'));
             $cache->save($lastModified, $cacheKey . "_lastModified", array('tagToolbar'));
             $cache->save($items, $cacheKey, array('tagToolbar'));
         }
         header("ETag: " . $hash);
         header("Last-Modified: " . $lastModified);
         header("Content-length: " . mb_strlen($items));
     }
     if (stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) {
         header("Content-type: application/xhtml+xml");
     } else {
         header("Content-type: text/xml");
     }
     return $items;
 }