Пример #1
0
 public function getBySlugAction()
 {
     $flatpageRow = $this->_helper->getObjectOr404('cms/flatpage', array('id' => $this->_getParam('id'), 'is_published' => 1, 'published_at__lt' => new Zend_Db_Expr('NOW()')));
     Centurion_Signal::factory('pre_display_rte')->send($flatpageRow, array($flatpageRow));
     Centurion_Cache_TagManager::addTag($flatpageRow);
     return $this->renderToResponse($flatpageRow->flatpage_template->view_script, array('currentFlatpageRow' => $flatpageRow));
 }
Пример #2
0
 /**
  * Stop the cache
  *
  * @param  array   $tags             Tags array
  * @param  int     $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
  * @param  string  $forcedDatas      If not null, force written datas with this
  * @param  boolean $echoData         If set to true, datas are sent to the browser
  * @param  int     $priority         integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
  * @return void
  */
 public function _flush($data)
 {
     if ($this->_cancel) {
         return $data;
     }
     $this->_tags = Centurion_Cache_TagManager::end($this->_tags);
     return parent::_flush($data);
 }
Пример #3
0
 public function __destruct()
 {
     $cached = array($this->_checkedWord, $this->_checkedTag, $this->_checkedWordTag);
     $tags = array();
     $tags[] = Centurion_Cache_TagManager::getTagOf($this->_uidTable);
     $tags[] = Centurion_Cache_TagManager::getTagOf($this->_tagTable);
     $tags[] = Centurion_Cache_TagManager::getTagOf($this->_tagUidTable);
     if ($this->_languageTable !== null) {
         $tags[] = Centurion_Cache_TagManager::getTagOf($this->_languageTable);
     }
     self::getCache()->save($cached, 'Translation_Model_Translate_Adapter_Array_Cache', $tags);
 }
Пример #4
0
 public function _getRoute()
 {
     Centurion_Cache_TagManager::addTag($this);
     if (null === $this->_route) {
         $url = $this->url;
         $pt = Centurion_Db::getSingleton('core/navigation')->findOneByProxy($this);
         if (null !== $pt) {
             while (null !== ($pt = $pt->getParent()) && $pt !== null && null != ($proxy = $pt->getProxy())) {
                 if (isset($proxy->url)) {
                     $url = $proxy->url . $url;
                 } else {
                     if (isset($proxy->slug)) {
                         $url = '/' . $proxy->slug . $url;
                     }
                 }
             }
         }
         $this->_route = new Centurion_Controller_Router_Route_Static($url, array('controller' => 'flatpage', 'action' => 'get', 'module' => 'cms', 'id' => $this->pk));
     }
     return $this->_route;
 }
Пример #5
0
 public function tag($tags)
 {
     return Centurion_Cache_TagManager::addTag($tags);
 }
Пример #6
0
 public function getNavigationData($identity = null)
 {
     Centurion_Cache_TagManager::addTag($this);
     if (null !== $this->getProxy()) {
         Centurion_Cache_TagManager::addTag($this->getProxy());
     }
     if (!$this->isVisible($identity)) {
         return null;
     }
     $navigationData = array();
     $navigationData['id'] = $this->id;
     $navigationData['visible'] = $this->is_visible;
     $navigationData['label'] = $this->getLabel();
     $navigationData['class'] = $this->class;
     if (trim($navigationData['label']) == '') {
         return null;
     }
     $navigationData['permission'] = $this->getPermission();
     $navigationData += $this->getRouteData($identity);
     return $navigationData;
 }
Пример #7
0
 /**
  * Start the cache
  *
  * @param  string  $id       (optional) A cache id (if you set a value here, maybe you have to use Output frontend instead)
  * @param  boolean $doNotDie For unit testing only !
  * @return boolean True if the cache is hit (false else)
  */
 public function start($id = false, $doNotDie = false)
 {
     $this->_cancel = false;
     $lastMatchingRegexp = null;
     foreach ($this->_specificOptions['regexps'] as $regexp => $conf) {
         if (preg_match("`{$regexp}`", $_SERVER['REQUEST_URI'])) {
             $lastMatchingRegexp = $regexp;
         }
     }
     $this->_activeOptions = $this->_specificOptions['default_options'];
     if ($lastMatchingRegexp !== null) {
         $conf = $this->_specificOptions['regexps'][$lastMatchingRegexp];
         foreach ($conf as $key => $value) {
             $this->_activeOptions[$key] = $value;
         }
     }
     if (!$this->_activeOptions['cache']) {
         return false;
     }
     if (!$id) {
         $id = $this->_makeId();
         if (!$id) {
             return false;
         }
     }
     $array = $this->load($id);
     if ($array !== false) {
         $data = $array['data'];
         $headers = $array['headers'];
         $noDebug = false;
         if (!headers_sent()) {
             foreach ($headers as $key => $headerCouple) {
                 $name = $headerCouple[0];
                 $value = $headerCouple[1];
                 if ($name == 'Content-Type') {
                     $noDebug = true;
                 }
                 header("{$name}: {$value}");
             }
         }
         if (!$noDebug && $this->_specificOptions['debug_header']) {
             echo 'DEBUG HEADER : This is a cached page !';
         }
         echo $data;
         if (!$noDebug && $this->_specificOptions['debug_footer']) {
             $metadata = $this->getMetadatas($id);
             $dateCreated = new Zend_Date($metadata['mtime']);
             $dateExpire = new Zend_Date($metadata['expire']);
             echo '<!-- Page in cache since: ' . $dateCreated->toString(Zend_Date::DATETIME_LONG) . ' -->' . "\n";
             echo '<!-- Will expire at: ' . $dateExpire->toString(Zend_Date::DATETIME_LONG) . ' -->' . "\n";
             //echo '<!-- With tag: ' . print_r($metadata['tags'], true) . ' -->';
         }
         if ($doNotDie) {
             return true;
         }
         die;
     }
     ob_start(array($this, '_flush'));
     ob_implicit_flush(false);
     if (true === $this->_activeOptions['cache'] && (false !== $id || $this->_makeId())) {
         Centurion_Cache_TagManager::start(false !== $id ? $id : $this->_makeId(), $this, false);
     }
     return false;
 }
Пример #8
0
 public function addTag($tag)
 {
     Centurion_Cache_TagManager::addTag($tag);
     return $this;
 }
Пример #9
0
 /**
  * Stop the cache
  *
  * @param  array   $tags             Tags array
  * @param  int     $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
  * @param  string  $forcedDatas      If not null, force written datas with this
  * @param  boolean $echoData         If set to true, datas are sent to the browser
  * @param  int     $priority         integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
  * @return void
  */
 public function end($tags = array(), $specificLifetime = false, $forcedDatas = null, $echoData = true, $priority = 8)
 {
     parent::end(Centurion_Cache_TagManager::end($tags), $specificLifetime, $forcedDatas, $echoData, $priority);
 }
Пример #10
0
 protected function _setupCache($backendName)
 {
     $frontend = new Zend_Cache_Frontend_Class($this->_frontendOptions);
     $this->_cache = Zend_Cache::factory($frontend, $backendName, $this->_frontendOptions, $this->_backendOptions);
     $this->_cache->setTagsArray(array(Centurion_Cache_TagManager::getTagOf($this->_object)));
     return $this;
 }