예제 #1
0
 public function load($cacheUrl)
 {
     $ret = $this->_redis->get('url:' . $cacheUrl);
     if ($ret) {
         $ret = Kwf_Component_Data::kwfUnserialize(unserialize($ret));
     }
     return $ret;
 }
 public function unserialize($serialized)
 {
     foreach (unserialize($serialized) as $k => $i) {
         if ($k == '_component') {
             $i = Kwf_Component_Data::kwfUnserialize($i);
         }
         $this->{$k} = $i;
     }
 }
예제 #3
0
 public function testSerializeEn()
 {
     $c = $this->_root->getComponentById('root-en_directory_1');
     $s = $c->kwfSerialize();
     unset($c);
     Kwf_Component_Data_Root::reset();
     $c = Kwf_Component_Data::kwfUnserialize($s);
     $this->assertEquals($c->componentId, 'root-en_directory_1');
 }
예제 #4
0
 public static function __getProcessInputComponents($data)
 {
     $showInvisible = Kwf_Component_Data_Root::getShowInvisible();
     $cacheId = 'procI-' . $data->componentId;
     $success = false;
     if (!$showInvisible) {
         //don't cache in preview
         $cacheContents = Kwf_Cache_Simple::fetch($cacheId, $success);
         //cache is cleared in Kwf_Component_Events_ProcessInputCache
     }
     if (!$success) {
         $datas = array();
         foreach (self::_findProcessInputComponents($data) as $p) {
             $plugins = array();
             $c = $p;
             do {
                 foreach ($c->getPlugins('Kwf_Component_Plugin_Interface_SkipProcessInput') as $i) {
                     $plugins[] = array('pluginClass' => $i, 'componentId' => $c->componentId);
                 }
                 $isPage = $c->isPage;
                 $c = $c->parent;
             } while ($c && !$isPage);
             $datas[] = array('data' => $p, 'plugins' => $plugins);
         }
         if (!$showInvisible) {
             $cacheContents = array();
             foreach ($datas as $p) {
                 $cacheContents[] = array('data' => $p['data']->kwfSerialize(), 'plugins' => $p['plugins']);
             }
             Kwf_Cache_Simple::add($cacheId, $cacheContents);
         }
     } else {
         $datas = array();
         foreach ($cacheContents as $d) {
             $datas[] = array('data' => Kwf_Component_Data::kwfUnserialize($d['data']), 'plugins' => $d['plugins']);
         }
     }
     //ask SkipProcessInput plugins if it should be skipped
     //evaluated every time
     $process = array();
     foreach ($datas as $d) {
         foreach ($d['plugins'] as $p) {
             $plugin = Kwf_Component_Plugin_Abstract::getInstance($p['pluginClass'], $p['componentId']);
             $result = $plugin->skipProcessInput();
             if ($result === Kwf_Component_Plugin_Interface_SkipProcessInput::SKIP_SELF_AND_CHILDREN) {
                 continue 2;
             }
             if ($result === Kwf_Component_Plugin_Interface_SkipProcessInput::SKIP_SELF && $p['componentId'] == $d['data']->componentId) {
                 continue 2;
             }
         }
         $process[] = $d['data'];
     }
     return $process;
 }
예제 #5
0
 public function getPageByUrl($url, $acceptLanguage, &$exactMatch = true)
 {
     $parsedUrl = parse_url($url);
     if (!isset($parsedUrl['path'])) {
         return null;
     }
     if (!isset($parsedUrl['host'])) {
         throw new Kwf_Exception("Host is missing in url '{$url}'");
     }
     if (substr($parsedUrl['host'], 0, 4) == 'dev.') {
         $parsedUrl['host'] = 'www.' . substr($parsedUrl['host'], 4);
     }
     $cacheUrl = $parsedUrl['host'] . $parsedUrl['path'];
     $cacheId = 'url-' . $cacheUrl;
     if ($page = Kwf_Cache_Simple::fetch($cacheId)) {
         $exactMatch = true;
         $ret = Kwf_Component_Data::kwfUnserialize($page);
     } else {
         $path = $this->getComponent()->formatPath($parsedUrl);
         if (is_null($path)) {
             return null;
         }
         $baseUrl = Kwf_Setup::getBaseUrl();
         if ($baseUrl) {
             if (substr($path, 0, strlen($baseUrl)) != $baseUrl) {
                 return null;
             } else {
                 $path = substr($path, strlen($baseUrl));
             }
         }
         $path = trim($path, '/');
         $ret = $this->getComponent()->getPageByUrl($path, $acceptLanguage);
         if ($ret && rawurldecode($ret->url) == $parsedUrl['path']) {
             //nur cachen wenn kein redirect gemacht wird
             $exactMatch = true;
             if ($ret->isVisible()) {
                 Kwf_Cache_Simple::add($cacheId, $ret->kwfSerialize());
                 Kwf_Component_Cache::getInstance()->getModel('url')->import(Kwf_Model_Abstract::FORMAT_ARRAY, array(array('url' => $cacheUrl, 'page_id' => $ret->componentId, 'expanded_page_id' => $ret->getExpandedComponentId())), array('replace' => true, 'skipModelObserver' => true));
             }
         } else {
             $exactMatch = false;
         }
     }
     return $ret;
 }