Ejemplo n.º 1
0
 public function componentToString(Kwf_Component_Data $data)
 {
     if (!$data->getLinkedData()) {
         return '';
     }
     return $data->getLinkedData()->name;
 }
Ejemplo n.º 2
0
 protected function _fireMediaChanged(Kwf_Component_Data $c)
 {
     $imageData = $c->getComponent()->getImageDataOrEmptyImageData();
     $this->fireEvent(new Kwc_Abstract_Image_ImageChangedEvent($this->_class, $c));
     if ($imageData) {
         $types = array();
         $typeBase = $c->getComponent()->getBaseType();
         // Kwc_Abstract_Image_Component->getBaseImageUrl is cached in Kwf_Media and uses therefore the base type
         $types[] = $typeBase;
         $dim = $c->getComponent()->getImageDimensions();
         if (isset($imageData['dimensions'])) {
             $steps = Kwf_Media_Image::getResponsiveWidthSteps($dim, $imageData['dimensions']);
         } else {
             if (isset($imageData['file'])) {
                 $steps = Kwf_Media_Image::getResponsiveWidthSteps($dim, $imageData['file']);
             } else {
                 throw new Kwf_Exception("Can't detect responsiveWidthSteps as image dimensions are unknown");
             }
         }
         foreach ($steps as $step) {
             $types[] = str_replace('{width}', $step, $typeBase);
         }
         $this->fireEvent(new Kwf_Events_Event_Media_Changed($this->_class, $c, $types));
     }
     $this->fireEvent(new Kwf_Component_Event_Component_ContentWidthChanged($this->_class, $c));
     $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($this->_class, $c));
 }
Ejemplo n.º 3
0
 /**
  * Returns if the given component requests https
  *
  * Return value is cached.
  */
 public static function doesComponentRequestHttps(Kwf_Component_Data $data)
 {
     $showInvisible = Kwf_Component_Data_Root::getShowInvisible();
     $foundRequestHttps = false;
     if (!$showInvisible) {
         //don't cache in preview
         $cacheId = 'reqHttps-' . $data->componentId;
         $foundRequestHttps = Kwf_Cache_Simple::fetch($cacheId);
     }
     if ($foundRequestHttps === false) {
         $foundRequestHttps = 0;
         //don't use false, false means not-cached
         if (Kwf_Component_Abstract::getFlag($data->componentClass, 'requestHttps')) {
             $foundRequestHttps = true;
         }
         if (!$foundRequestHttps && $data->getRecursiveChildComponents(array('page' => false, 'flags' => array('requestHttps' => true)))) {
             $foundRequestHttps = true;
         }
         if (!$showInvisible) {
             //don't cache in preview
             Kwf_Cache_Simple::add($cacheId, $foundRequestHttps);
         }
     }
     return $foundRequestHttps;
 }
Ejemplo n.º 4
0
 public static function getListHtml(Kwf_Component_Renderer_Abstract $renderer, Kwf_Component_Data $c, $level, $levels, $className)
 {
     $ret = '';
     $level++;
     $select = new Kwf_Component_Select();
     $select->whereShowInMenu(true);
     $ret .= '<ul class="' . self::getBemClass($className, 'sitemapListLevel' . $level) . '">' . "\n";
     $count = 1;
     foreach ($c->getChildPages($select) as $child) {
         $ret .= '<li class="' . self::getBemClass($className, 'sitemapListItemLevel' . $level);
         if ($count % 3 === 0) {
             $ret .= ' ' . self::getBemClass($className, '--third');
         }
         if ($count % 2 === 0) {
             $ret .= ' ' . self::getBemClass($className, '--second');
         }
         if (!$child->getChildPages($select)) {
             $ret .= ' ' . self::getBemClass($className, '--noChild');
         }
         $ret .= '">';
         $helper = new Kwf_Component_View_Helper_ComponentLink();
         $helper->setRenderer($renderer);
         $ret .= $helper->componentLink($child);
         $ret .= "\n";
         if ($level < $levels) {
             $ret .= self::getListHtml($renderer, $child, $level, $levels, $className);
         }
         $ret .= "</li>\n";
         $count++;
     }
     $ret .= "</ul>\n";
     return $ret;
 }
Ejemplo n.º 5
0
 public static function getListHtml(Kwf_Component_Renderer_Abstract $renderer, Kwf_Component_Data $c, $level, $levels)
 {
     $ret = '';
     $level++;
     $select = new Kwf_Component_Select();
     $select->whereShowInMenu(true);
     $ret .= "<ul>\n";
     foreach ($c->getChildPages($select) as $child) {
         $noChild = '';
         if (!$child->getChildPages($select)) {
             $noChild = 'noChild';
         }
         $ret .= '<li class="' . $noChild . '">';
         $helper = new Kwf_Component_View_Helper_ComponentLink();
         $helper->setRenderer($renderer);
         $ret .= $helper->componentLink($child);
         $ret .= "\n";
         if ($level < $levels) {
             $ret .= self::getListHtml($renderer, $child, $level, $levels);
         }
         $ret .= "</li>\n";
     }
     $ret .= "</ul>\n";
     return $ret;
 }
Ejemplo n.º 6
0
 public function componentToString(Kwf_Component_Data $data)
 {
     $row = $data->getComponent()->getRow();
     if ($row->source_type == 'files') {
         if ($row->getParentRow('FileMp4')) {
             return $row->getParentRow('FileMp4')->filename . '.' . $row->getParentRow('FileMp4')->extension;
         } else {
             if ($row->getParentRow('FileOgg')) {
                 return $row->getParentRow('FileOgg')->filename . '.' . $row->getParentRow('FileOgg')->extension;
             } else {
                 if ($row->getParentRow('FileWebm')) {
                     return $row->getParentRow('FileWebm')->filename . '.' . $row->getParentRow('FileWebm')->extension;
                 }
             }
         }
     } else {
         if ($row->mp4_url) {
             return $row->mp4_url;
         }
         if ($row->ogg_url) {
             return $row->ogg_url;
         }
         if ($row->webm_url) {
             return $row->webm_url;
         }
     }
     return '';
 }
Ejemplo n.º 7
0
 public function getContentWidth(Kwf_Component_Data $data)
 {
     if (!$this->_hasSetting('contentWidth')) {
         throw new Kwf_Exception("contentWidth has to be set for {$data->componentClass} (getting width for {$data->componentId})");
     }
     $ret = $this->_getSetting('contentWidth');
     if (!$this->_hasSetting('contentWidthBoxSubtract')) {
         return $ret;
     }
     $boxes = array();
     foreach ($data->getChildBoxes() as $box) {
         $boxes[$box->box] = $box;
     }
     if ($this->_hasSetting('contentWidthBoxSubtract')) {
         foreach ($this->_getSetting('contentWidthBoxSubtract') as $box => $width) {
             if (!isset($boxes[$box])) {
                 continue;
             }
             $c = $boxes[$box];
             if ($c && $c->hasContent()) {
                 $ret -= $width;
             }
         }
     }
     return $ret;
 }
Ejemplo n.º 8
0
 public function component(Kwf_Component_Data $component = null)
 {
     if (!$component) {
         return '';
     }
     $viewCacheSettings = $component->getComponent()->getViewCacheSettings();
     return $this->_getRenderPlaceholder($component->componentId, array(), null, $viewCacheSettings['enabled']);
 }
Ejemplo n.º 9
0
 public function componentToString(Kwf_Component_Data $data)
 {
     $upload = $data->getComponent()->getRow()->getParentRow('FileMedia');
     if (!$upload) {
         return '';
     }
     return $upload->filename . '.' . $upload->extension;
 }
Ejemplo n.º 10
0
 public static function getDefaultOptValue(Kwf_Component_Data $data)
 {
     $ret = $data->getBaseProperty('statistics.defaultOptValue');
     if ($ret != self::OPT_IN && $ret != self::OPT_OUT) {
         throw new Kwf_Exception('statistics.defaultOptValue must be ' . self::OPT_IN . ' or ' . self::OPT_OUT);
     }
     return $ret;
 }
Ejemplo n.º 11
0
 public function componentToString(Kwf_Component_Data $data)
 {
     $row = $data->getComponent()->getRow();
     $data = Kwf_Component_Data_Root::getInstance()->getComponentByDbId('blog_' . $row->blog_post_id, array('subroot' => $data));
     if (!$data) {
         return '';
     }
     return $data->name;
 }
Ejemplo n.º 12
0
 public function componentToString(Kwf_Component_Data $data)
 {
     $row = $data->getComponent()->getRow();
     $fRow = $row->getParentRow(Kwc_Abstract::getSetting($data->componentClass, 'uploadModelRule'));
     if (!$fRow) {
         return str_replace('.', ' ', Kwf_Trl::getInstance()->trlStaticExecute(Kwc_Abstract::getSetting($data->componentClass, 'componentName')));
     }
     return $fRow->filename . '.' . $fRow->extension;
 }
Ejemplo n.º 13
0
 public function componentToString(Kwf_Component_Data $data)
 {
     $row = $data->getComponent()->getRow();
     $field = $this->_prefix . '_id';
     $data = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($this->_prefixPlural . '_' . $row->{$field}, array('subroot' => $data));
     if (!$data) {
         return '';
     }
     return $data->name;
 }
Ejemplo n.º 14
0
 public function componentToString(Kwf_Component_Data $data)
 {
     $r = $data->getComponent()->getRow();
     if ($r->own_download) {
         $r = $data->getChildComponent('-download')->getComponent()->getRow();
     } else {
         $r = $data->chained->getComponent()->getRow();
     }
     if (!empty($r->filename)) {
         return $r->filename;
     }
     return '';
 }
Ejemplo n.º 15
0
 private function _getSitemap(Kwf_Component_Data $page)
 {
     $sites = array();
     if (is_instance_of($page->componentClass, 'Kwc_Mail_Redirect_Component') || is_instance_of($page->componentClass, 'Kwc_Advanced_Amazon_Nodes_ProductsDirectory_Component')) {
         return $sites;
     }
     if ($page->url) {
         $sites[] = 'http://' . Kwf_Registry::get('config')->server->domain . $page->url;
     }
     foreach ($page->getChildPseudoPages(array(), array('pseudoPage' => false)) as $childPage) {
         $sites = array_merge($sites, $this->_getSitemap($childPage));
     }
     return $sites;
 }
Ejemplo n.º 16
0
 public function __get($var)
 {
     if ($var == 'url') {
         $row = $this->_getLinkRow();
         if (!$row || !$row->mail) {
             return '';
         }
         return Kwc_Basic_LinkTag_Mail_Data::createHref($row);
     } else {
         if ($var == 'url_mail_html') {
             $row = $this->_getLinkRow();
             if (!$row || !$row->mail) {
                 return '';
             }
             return Kwc_Basic_LinkTag_Mail_Data::createHref($row, false);
         } else {
             if ($var == 'url_mail_txt') {
                 $row = $this->_getLinkRow();
                 return !$row || !$row->mail ? '' : $row->mail;
             } else {
                 if ($var == 'rel') {
                     return '';
                 } else {
                     return parent::__get($var);
                 }
             }
         }
     }
 }
Ejemplo n.º 17
0
 protected function _getResourceText(Kwf_Component_Data $c)
 {
     if (Kwc_Abstract::hasSetting($this->_class, 'componentNameShort')) {
         $name = Kwc_Abstract::getSetting($this->_class, 'componentNameShort');
     } else {
         $name = Kwc_Abstract::getSetting($this->_class, 'componentName');
     }
     $t = $c->getTitle();
     if (!$t) {
         $t = $name;
     }
     if ($domain = $c->getParentByClass('Kwc_Root_DomainRoot_Domain_Component')) {
         $t .= " ({$domain->name})";
     }
     return $t;
 }
Ejemplo n.º 18
0
 public function save(Kwf_Component_Data $component, $content, $renderer, $type, $value, $tag, $lifetime)
 {
     $microtime = $this->_getMicrotime();
     // MySQL
     $data = array('component_id' => (string) $component->componentId, 'db_id' => (string) $component->dbId, 'page_db_id' => (string) $component->getPageOrRoot()->dbId, 'expanded_component_id' => (string) $component->getExpandedComponentId(), 'component_class' => $component->componentClass, 'renderer' => $renderer, 'type' => $type, 'value' => (string) $value, 'tag' => (string) $tag, 'microtime' => $microtime, 'expire' => is_null($lifetime) ? null : time() + $lifetime, 'deleted' => false, 'content' => $content);
     $options = array('buffer' => true, 'replace' => true, 'skipModelObserver' => true);
     $this->getModel('cache')->import(Kwf_Model_Abstract::FORMAT_ARRAY, array($data), $options);
     // APC
     $cacheId = $this->_getCacheId($component->componentId, $renderer, $type, $value);
     $ttl = null;
     if ($lifetime) {
         $ttl = $lifetime;
     }
     Kwf_Component_Cache_Memory::getInstance()->save($content, $cacheId, $ttl, $microtime);
     return true;
 }
Ejemplo n.º 19
0
 public function __get($var)
 {
     if ($var == 'url') {
         $m = Kwc_Abstract::createModel($this->componentClass);
         $row = $m->getRow($this->dbId);
         if (!$row || !$row->own_download) {
             //not own_download but still output thru own url to be ablte to call own isValidMediaOutput
             $row = $this->chained->getComponent()->getRow();
             if (!$row) {
                 return null;
             }
             $fRow = $row->getParentRow('File');
             if (!$fRow) {
                 return null;
             }
             $filename = $row->filename;
             if (!$filename) {
                 $filename = $fRow->filename;
             }
             $filename .= '.' . $fRow->extension;
             return Kwf_Media::getUrl($this->componentClass, $this->componentId, 'default', $filename);
         }
         return $this->getChildComponent('-download')->url;
     } else {
         return parent::__get($var);
     }
 }
Ejemplo n.º 20
0
 public function __get($var)
 {
     if ($var == 'url' || $var == 'rel') {
         return $this->getChildComponent('_video')->{$var};
     } else {
         return parent::__get($var);
     }
 }
Ejemplo n.º 21
0
 public function getLinkTitle()
 {
     $parent = $this->parent;
     if (is_instance_of($parent->componentClass, 'Kwc_Basic_LinkTag_Component')) {
         return $this->parent->getComponent()->getLinkTitle();
     }
     return parent::getLinkTitle();
 }
Ejemplo n.º 22
0
 protected function _fireMediaChanged(Kwf_Component_Data $c)
 {
     $imageData = $c->getComponent()->getImageDataOrEmptyImageData();
     $this->fireEvent(new Kwc_Abstract_Image_ImageChangedEvent($this->_class, $c));
     if ($imageData) {
         $typeBase = $c->getComponent()->getBaseType();
         // Kwc_Abstract_Image_Component->getBaseImageUrl is cached in Kwf_Media and uses therefore the base type
         $this->fireEvent(new Kwf_Events_Event_Media_Changed($this->_class, $c, $typeBase));
         $dim = $c->getComponent()->getImageDimensions();
         $steps = Kwf_Media_Image::getResponsiveWidthSteps($dim, $imageData['file']);
         foreach ($steps as $step) {
             $this->fireEvent(new Kwf_Events_Event_Media_Changed($this->_class, $c, str_replace('{width}', $step, $typeBase)));
         }
     }
     $this->fireEvent(new Kwf_Component_Event_Component_ContentWidthChanged($this->_class, $c));
     $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($this->_class, $c));
 }
Ejemplo n.º 23
0
 public function getFulltextComponents(Kwf_Component_Data $component)
 {
     $fulltextComponents = $component->getRecursiveChildComponents(array('flag' => 'hasFulltext', 'inherit' => false, 'page' => false));
     if (Kwc_Abstract::getFlag($component->componentClass, 'hasFulltext')) {
         $fulltextComponents[] = $component;
     }
     foreach ($fulltextComponents as $c) {
         if (!method_exists($c->getComponent(), 'getFulltextComponents')) {
             continue;
         }
         //components can return other components that should be included in fulltext content
         foreach ($c->getComponent()->getFulltextComponents() as $c) {
             $fulltextComponents = array_merge($fulltextComponents, $this->getFulltextComponents($component));
         }
     }
     return $fulltextComponents;
 }
Ejemplo n.º 24
0
 public function load($cacheUrl)
 {
     $ret = $this->_redis->get('url:' . $cacheUrl);
     if ($ret) {
         $ret = Kwf_Component_Data::kwfUnserialize(unserialize($ret));
     }
     return $ret;
 }
Ejemplo n.º 25
0
 public function __get($var)
 {
     if ($var == 'filename') {
         return null;
     } else {
         return parent::__get($var);
     }
 }
Ejemplo n.º 26
0
 public function __get($var)
 {
     if ($var == 'url') {
         $url = $this->getComponent()->getRow()->url;
         return $url ? $url : '';
     } else {
         return parent::__get($var);
     }
 }
Ejemplo n.º 27
0
 public function unserialize($serialized)
 {
     foreach (unserialize($serialized) as $k => $i) {
         if ($k == '_component') {
             $i = Kwf_Component_Data::kwfUnserialize($i);
         }
         $this->{$k} = $i;
     }
 }
Ejemplo n.º 28
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');
 }
Ejemplo n.º 29
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;
 }
Ejemplo n.º 30
0
 public function getFulltextComponents(Kwf_Component_Data $component)
 {
     if (isset($component->generator->unique) && $component->generator->unique && isset($component->generator->inherit) && $component->generator->inherit) {
         return array();
     }
     $ret = array();
     if (Kwc_Abstract::getFlag($component->componentClass, 'hasFulltext')) {
         $ret[] = $component;
     }
     $components = $component->getRecursiveChildComponents(array('flag' => 'hasFulltext', 'page' => false));
     foreach ($components as $cmp) {
         $checkCmp = $cmp;
         $needsToBeIndexed = true;
         while ($checkCmp->inherits == false) {
             if (isset($checkCmp->generator)) {
                 $generator = $checkCmp->generator;
                 if (isset($generator->inherit) && $generator->inherit && isset($generator->unique) && $generator->unique) {
                     $needsToBeIndexed = false;
                     break;
                 }
             }
             if (Kwc_Abstract::getFlag($checkCmp->componentClass, 'skipFulltextRecursive')) {
                 $needsToBeIndexed = false;
                 break;
             }
             $checkCmp = $checkCmp->parent;
         }
         if ($needsToBeIndexed) {
             $ret[] = $cmp;
         }
     }
     foreach ($ret as $c) {
         if (!method_exists($c->getComponent(), 'getFulltextComponents')) {
             continue;
         }
         //components can return other components that should be included in fulltext content
         foreach ($c->getComponent()->getFulltextComponents() as $c) {
             $ret = array_merge($ret, $this->getFulltextComponents($c));
         }
     }
     return $ret;
 }