Exemple #1
0
 public function getListeners()
 {
     $ret = parent::getListeners();
     $ret[] = array('class' => null, 'event' => 'Kwf_Component_Event_Page_ParentChanged', 'callback' => 'onPageParentChanged');
     foreach (Kwc_Abstract::getComponentClasses() as $class) {
         $classWithoutPoint = $class;
         if (($pos = strpos($class, '.')) !== false) {
             $classWithoutPoint = substr($class, 0, $pos);
         }
         if (Kwc_Abstract::getFlag($class, 'hasAlternativeComponent') && in_array($this->_class, call_user_func(array($classWithoutPoint, 'getAlternativeComponents'), $class))) {
             $ret[] = array('class' => $class, 'event' => 'Kwf_Component_Event_Component_HasContentChanged', 'callback' => 'onParentHasContentChanged');
             $ret[] = array('class' => $class, 'event' => 'Kwf_Component_Event_Component_RecursiveHasContentChanged', 'callback' => 'onParentRecursiveHasContentChanged');
         }
         foreach (Kwc_Abstract::getSetting($class, 'generators') as $generator) {
             if ($generator['class'] == 'Kwf_Component_Generator_Box_StaticSelect' && is_array($generator['component']) && in_array($this->_class, $generator['component'])) {
                 foreach ($generator['component'] as $componentClass) {
                     if ($componentClass == $this->_class) {
                         continue;
                     }
                     $ret[] = array('class' => $componentClass, 'event' => 'Kwf_Component_Event_Component_HasContentChanged', 'callback' => 'onParentHasContentChanged');
                     $ret[] = array('class' => $componentClass, 'event' => 'Kwf_Component_Event_Component_RecursiveHasContentChanged', 'callback' => 'onParentRecursiveHasContentChanged');
                 }
             }
         }
     }
     return $ret;
 }
 protected function _getTitle()
 {
     if (trim($this->_getRow()->title)) {
         return $this->_getRow()->title;
     }
     //if no title is configured get from next subroot/root
     $c = $this->getData()->parent;
     while ($c) {
         if ($c->inherits && Kwc_Abstract::getFlag($c->componentClass, 'subroot') || $c->componentId == 'root') {
             $title = $c->getChildComponent(array('id' => '-' . $this->getData()->id, 'componentClass' => $this->getData()->componentClass));
             if ($title) {
                 $title = $title->getComponent()->_getRow()->title;
             }
             if ($title) {
                 $ret = $this->getData()->getTitle();
                 //append own title
                 if ($ret) {
                     $ret .= ' - ';
                 }
                 return $ret . $title;
             }
         }
         $c = $c->parent;
     }
     return parent::_getTitle();
 }
 public static function getAllChainedByMasterFromChainedStart($componentClass, $master, $chainedType, $parentDataSelect = array())
 {
     if (Kwc_Abstract::getFlag($componentClass, 'chainedType') != $chainedType) {
         return array();
     }
     $ret = array();
     foreach (Kwf_Component_Data_Root::getInstance()->getComponentsByClass($componentClass, $parentDataSelect) as $chainedStart) {
         //if additional subroots are above trl subroot (eg. domains)
         if ($sr = $chainedStart->parent->getSubroot()) {
             $masterSr = $master;
             while (Kwc_Abstract::getFlag($masterSr->componentClass, 'chainedType') != $chainedType) {
                 $masterSr = $masterSr->parent;
                 if (!$masterSr) {
                     continue 2;
                 }
             }
             if ($masterSr->parent && $sr != $masterSr->parent->getSubroot()) {
                 continue;
             }
         }
         $i = Kwc_Chained_Abstract_Component::getChainedByMasterAndType($master, $chainedStart, $chainedType, $parentDataSelect);
         if ($i) {
             $ret[] = $i;
         }
     }
     return $ret;
 }
 /**
  * Returns Zend_Search_Lucene instance for given subroot
  *
  * every subroot has it's own instance
  *
  * @param Kwf_Component_Data for this index
  * @return Zend_Search_Lucene_Interface
  */
 public static function getInstance(Kwf_Component_Data $subroot)
 {
     while ($subroot) {
         if (Kwc_Abstract::getFlag($subroot->componentClass, 'subroot')) {
             break;
         }
         $subroot = $subroot->parent;
     }
     if (!$subroot) {
         $subroot = Kwf_Component_Data_Root::getInstance();
     }
     static $instance = array();
     if (!isset($instance[$subroot->componentId])) {
         $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive();
         $analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_ShortWords(2));
         //$stopWords = explode(' ', 'der dir das einer eine ein und oder doch ist sind an in vor nicht wir ihr sie es ich');
         //$analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_StopWords($stopWords));
         Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
         Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
         Zend_Search_Lucene_Storage_Directory_Filesystem::setDefaultFilePermissions(0666);
         $path = 'cache/fulltext';
         $path .= '/' . $subroot->componentId;
         try {
             $instance[$subroot->componentId] = Zend_Search_Lucene::open($path);
         } catch (Zend_Search_Lucene_Exception $e) {
             $instance[$subroot->componentId] = Zend_Search_Lucene::create($path);
         }
     }
     return $instance[$subroot->componentId];
 }
 protected function _onOwnRowUpdate(Kwf_Component_Data $c, Kwf_Events_Event_Row_Abstract $event)
 {
     parent::_onOwnRowUpdate($c, $event);
     if (Kwc_Abstract::getFlag($c->parent->componentClass, 'subroot') || $c->parent instanceof Kwf_Component_Data_Root) {
         $this->fireEvent(new Kwf_Component_Event_Component_RecursiveContentChanged($this->_class, $c));
     }
 }
Exemple #6
0
 private function _getAllLanguages()
 {
     $config = Zend_Registry::get('config');
     $langs = array();
     if ($config->webCodeLanguage) {
         $langs[] = $config->webCodeLanguage;
     }
     if ($config->languages) {
         foreach ($config->languages as $lang => $name) {
             $langs[] = $lang;
         }
     }
     if (Kwf_Component_Data_Root::getComponentClass()) {
         foreach (Kwc_Abstract::getComponentClasses() as $c) {
             if (Kwc_Abstract::getFlag($c, 'hasAvailableLanguages')) {
                 foreach (call_user_func(array($c, 'getAvailableLanguages'), $c) as $i) {
                     if (!in_array($i, $langs)) {
                         $langs[] = $i;
                     }
                 }
             }
         }
     }
     $langs = array_unique($langs);
     return $langs;
 }
 public static function duplicated(Kwf_Component_Data $source, Kwf_Component_Data $new)
 {
     $chained = Kwf_Component_Data_Root::getInstance()->getComponentsByClass('Kwc_Root_TrlRoot_Chained_Component', array('ignoreVisible' => true));
     //bySameClass wenn fkt nicht mehr static (todo oben erledigt)
     $sourceChained = array();
     foreach ($chained as $c) {
         $subRootAboveTrl = $c;
         //eg. domain
         while ($subRootAboveTrl = $subRootAboveTrl->parent) {
             if (Kwc_Abstract::getFlag($subRootAboveTrl->componentClass, 'subroot')) {
                 break;
             }
         }
         if (!$subRootAboveTrl) {
             $subRootAboveTrl = Kwf_Component_Data_Root::getInstance();
         }
         $d = $source;
         while ($d = $d->parent) {
             if ($d->componentId == $subRootAboveTrl->componentId) {
                 $sourceChained[$c->getLanguage()] = $c;
             }
         }
     }
     $targetChained = array();
     foreach ($chained as $c) {
         $subRootAboveTrl = $c;
         //eg. domain
         while ($subRootAboveTrl = $subRootAboveTrl->parent) {
             if (Kwc_Abstract::getFlag($subRootAboveTrl->componentClass, 'subroot')) {
                 break;
             }
         }
         if (!$subRootAboveTrl) {
             $subRootAboveTrl = Kwf_Component_Data_Root::getInstance();
         }
         $d = $new;
         while ($d = $d->parent) {
             if ($d->componentId == $subRootAboveTrl->componentId) {
                 if (isset($sourceChained[$c->getLanguage()])) {
                     //only if there is a source language
                     $targetChained[] = array('targetChained' => $c, 'sourceChained' => $sourceChained[$c->getLanguage()]);
                 }
             }
         }
     }
     foreach ($targetChained as $c) {
         $sourceChained = Kwc_Chained_Trl_Component::getChainedByMaster($source, $c['sourceChained'], array('ignoreVisible' => true));
         $newChained = Kwc_Chained_Trl_Component::getChainedByMaster($new, $c['targetChained'], array('ignoreVisible' => true));
         if (!$sourceChained || $source->componentId == $sourceChained->componentId) {
             continue;
             //wenn sourceChained nicht gefunden handelt es sich zB um ein MasterAsChild - was ignoriert werden muss
         }
         if (!$newChained) {
             throw new Kwf_Exception("can't find chained components");
         }
         Kwc_Admin::getInstance($newChained->componentClass)->duplicate($sourceChained, $newChained);
     }
 }
 public static function getMetaTagsForData($data)
 {
     $ret = array();
     if (Kwf_Config::getValue('application.kwf.name') == 'Koala Framework') {
         $ret['generator'] = 'Koala Web Framework CMS';
     }
     if ($data->getPage()) {
         if (Kwc_Abstract::getFlag($data->getPage()->componentClass, 'metaTags')) {
             foreach ($data->getPage()->getComponent()->getMetaTags() as $name => $content) {
                 if (!isset($ret[$name])) {
                     $ret[$name] = '';
                 }
                 //TODO: for eg noindex,nofollow other separator
                 $ret[$name] .= ' ' . $content;
             }
         }
         if (Kwc_Abstract::getFlag($data->getPage()->componentClass, 'noIndex')) {
             if (isset($ret['robots'])) {
                 $ret['robots'] .= ',';
             } else {
                 $ret['robots'] = '';
             }
             $ret['robots'] .= 'noindex';
         }
     }
     foreach ($ret as &$i) {
         $i = trim($i);
     }
     unset($i);
     // verify-v1
     if (isset($_SERVER['HTTP_HOST'])) {
         $host = $_SERVER['HTTP_HOST'];
     } else {
         $host = Kwf_Config::getValue('server.domain');
     }
     $hostParts = explode('.', $host);
     if (count($hostParts) < 2) {
         $configDomain = $host;
     } else {
         $shortParts = array('com', 'co', 'gv', 'or');
         if (count($hostParts) > 2 & in_array($hostParts[count($hostParts) - 2], $shortParts)) {
             $hostParts[count($hostParts) - 2] = $hostParts[count($hostParts) - 3] . $hostParts[count($hostParts) - 2];
         }
         $configDomain = $hostParts[count($hostParts) - 2] . $hostParts[count($hostParts) - 1];
         // zB 'com'
     }
     $configVerify = Kwf_Config::getValueArray('verifyV1');
     if ($configVerify && isset($configVerify[$configDomain])) {
         $ret['verify-v1'] = $configVerify[$configDomain];
     }
     $configVerify = Kwf_Config::getValueArray('googleSiteVerification');
     if ($configVerify && isset($configVerify[$configDomain])) {
         $ret['google-site-verification'] = $configVerify[$configDomain];
     }
     return $ret;
 }
 public function getListeners()
 {
     $ret = array();
     foreach (Kwc_Abstract::getComponentClasses() as $c) {
         if (Kwc_Abstract::getFlag($c, 'requestHttps')) {
             $ret[] = array('class' => $c, 'event' => 'Kwf_Component_Event_Component_Added', 'callback' => 'onComponentAdded');
         }
     }
     return $ret;
 }
 public function getListeners()
 {
     $ret = parent::getListeners();
     foreach (Kwc_Abstract::getComponentClasses() as $c) {
         if (Kwc_Abstract::getFlag($c, 'assetsPackage')) {
             $ret[] = array('class' => $c, 'event' => 'Kwf_Component_Event_Component_Added', 'callback' => 'onComponentAddedRemoved');
             $ret[] = array('class' => $c, 'event' => 'Kwf_Component_Event_Component_Removed', 'callback' => 'onComponentAddedRemoved');
         }
     }
     return $ret;
 }
 private static function _findFormFields($data)
 {
     $ret = array();
     foreach ($data->getChildComponents(array('page' => false, 'pseudoPage' => false)) as $c) {
         if (Kwc_Abstract::getFlag($c->componentClass, 'formField')) {
             $ret[] = $c;
         }
         $ret = array_merge($ret, self::_findFormFields($c));
     }
     return $ret;
 }
 public function getFulltextContentForPage(Kwf_Component_Data $page, array $fulltextComponents = array())
 {
     if (Kwc_Abstract::getFlag($page->componentClass, 'skipFulltext')) {
         return null;
     }
     $c = $page;
     while ($c = $c->parent) {
         if (Kwc_Abstract::getFlag($c->componentClass, 'skipFulltextRecursive')) {
             return null;
         }
     }
     if (!$fulltextComponents) {
         $fulltextComponents = $this->getFulltextComponents($page);
     }
     $ret = array();
     //whole content, for preview in search result
     $ret['content'] = '';
     //normal content with boost=1 goes here
     $ret['normalContent'] = '';
     $row = Kwf_Component_PagesMetaModel::getInstance()->getRow($page->componentId);
     if ($row && $row->changed_date) {
         $ret['lastModified'] = new Kwf_DateTime($row->changed_date);
     }
     $t = $page->getTitle();
     if (substr($t, -3) == ' - ') {
         $t = substr($t, 0, -3);
     }
     $ret['title'] = $t;
     foreach ($fulltextComponents as $c) {
         if (!method_exists($c->getComponent(), 'getFulltextContent')) {
             continue;
         }
         $content = $c->getComponent()->getFulltextContent();
         unset($c);
         foreach ($content as $field => $text) {
             if (!$text) {
                 continue;
             }
             if (isset($ret[$field])) {
                 if (is_string($ret[$field])) {
                     $ret[$field] = $ret[$field] . ' ' . $text;
                 }
             } else {
                 $ret[$field] = $text;
             }
         }
     }
     if (!$ret['content']) {
         //echo " [no content]";
         $ret = null;
     }
     return $ret;
 }
 public function getRows($where = null, $order = null, $limit = null, $start = null)
 {
     if (!is_object($where) || $where instanceof Kwf_Model_Select_Expr_Interface) {
         $select = $this->select($where, $order, $limit, $start);
     } else {
         $select = $where;
     }
     $dataKeys = array();
     $whereEquals = $select->getPart(Kwf_Model_Select::WHERE_EQUALS);
     if (isset($whereEquals['parent_component_id'])) {
         $whereId = null;
         if (isset($whereEquals['id'])) {
             $whereId = $whereEquals['id'];
         }
         $childPagesComponentSelect = array();
         $childPagesComponentSelect['showInMenu'] = true;
         if ($whereId || isset($whereEquals['ignore_visible']) && $whereEquals['ignore_visible'] || $select->getPart(Kwf_Component_Select::IGNORE_VISIBLE)) {
             $childPagesComponentSelect[Kwf_Component_Select::IGNORE_VISIBLE] = true;
         }
         $component = Kwf_Component_Data_Root::getInstance()->getComponentById($whereEquals['parent_component_id'], array(Kwf_Component_Select::IGNORE_VISIBLE => true));
         while ($component) {
             $component = $component->parent;
             if ($component->isPage) {
                 break;
             }
             if (!$component->parent) {
                 break;
             }
             if (Kwc_Abstract::getFlag($component->componentClass, 'menuCategory')) {
                 break;
             }
         }
         $pages = $component->getChildPages($childPagesComponentSelect);
         $i = 0;
         foreach ($pages as $page) {
             $j = 0;
             foreach ($page->getChildPages($childPagesComponentSelect) as $childPage) {
                 if (isset($whereEquals['filename']) && $childPage->filename != $whereEquals['filename']) {
                     continue;
                 }
                 $id = $this->_getIdForPage($childPage);
                 if (!$whereId || $id == $whereId) {
                     $this->_data[$id] = array('id' => $id, 'pos' => $j++, 'target_page_id' => $childPage->componentId, 'name' => $childPage->name, 'filename' => $childPage->filename, 'parent_pos' => $i, 'parent_name' => $page->name);
                     $dataKeys[] = $id;
                 }
             }
             $i++;
         }
     } else {
         throw new Kwf_Exception_NotYetImplemented();
     }
     return new $this->_rowsetClass(array('dataKeys' => $dataKeys, 'model' => $this));
 }
Exemple #14
0
 protected function _build()
 {
     if (!file_exists('build/trl')) {
         mkdir('build/trl');
     }
     foreach (glob('build/trl/*') as $f) {
         unlink($f);
     }
     $config = Zend_Registry::get('config');
     $langs = array();
     if ($config->webCodeLanguage) {
         $langs[] = $config->webCodeLanguage;
     }
     if ($config->languages) {
         foreach ($config->languages as $lang => $name) {
             $langs[] = $lang;
         }
     }
     try {
         if (Kwf_Component_Data_Root::getComponentClass()) {
             foreach (Kwc_Abstract::getComponentClasses() as $c) {
                 if (Kwc_Abstract::getFlag($c, 'hasAvailableLanguages')) {
                     foreach (call_user_func(array($c, 'getAvailableLanguages'), $c) as $i) {
                         if (!in_array($i, $langs)) {
                             $langs[] = $i;
                         }
                     }
                 }
             }
         }
     } catch (Kwf_Trl_BuildFileMissingException $e) {
         $originatingException = $e->getSettingsNonStaticTrlException();
         if ($originatingException) {
             throw $originatingException;
         }
         throw $e;
     }
     foreach ($langs as $l) {
         if ($l != $config->webCodeLanguage) {
             $c = $this->_loadTrlArray(Kwf_Trl::SOURCE_WEB, $l, true);
             file_put_contents(Kwf_Trl::generateBuildFileName(Kwf_Trl::SOURCE_WEB, $l, true), serialize($c));
             $c = $this->_loadTrlArray(Kwf_Trl::SOURCE_WEB, $l, false);
             file_put_contents(Kwf_Trl::generateBuildFileName(Kwf_Trl::SOURCE_WEB, $l, false), serialize($c));
         }
         if ($l != 'en') {
             $c = $this->_loadTrlArray(Kwf_Trl::SOURCE_KWF, $l, true);
             file_put_contents(Kwf_Trl::generateBuildFileName(Kwf_Trl::SOURCE_KWF, $l, true), serialize($c));
             $c = $this->_loadTrlArray(Kwf_Trl::SOURCE_KWF, $l, false);
             file_put_contents(Kwf_Trl::generateBuildFileName(Kwf_Trl::SOURCE_KWF, $l, false), serialize($c));
         }
     }
 }
 public final function getConfig($type)
 {
     if ($type == self::TYPE_SHARED) {
         if (Kwc_Abstract::getFlag($this->_class, 'sharedDataClass')) {
             return $this->_getConfig();
         }
     } else {
         if (!Kwc_Abstract::getFlag($this->_class, 'sharedDataClass')) {
             return $this->_getConfig();
         }
     }
     return array();
 }
 private static function _getParentsWithHasHomeFlagComponentClasses($cls)
 {
     $ret = array();
     foreach (Kwc_Abstract::getComponentClasses() as $c) {
         if (in_array($cls, Kwc_Abstract::getChildComponentClasses($c))) {
             if (Kwc_Abstract::getFlag($c, 'hasHome')) {
                 $ret[] = $c;
             }
             $ret = array_merge($ret, self::_getParentsWithHasHomeFlagComponentClasses($c));
         }
     }
     return $ret;
 }
 public function getListeners()
 {
     $ret = array();
     $processInputClasses = array();
     foreach (Kwc_Abstract::getComponentClasses() as $c) {
         if (Kwc_Abstract::getFlag($c, 'processInput')) {
             $processInputClasses[] = $c;
         }
     }
     $ret[] = array('class' => $processInputClasses, 'event' => 'Kwf_Component_Event_Component_Added', 'callback' => 'onComponentAddedOrRemoved');
     $ret[] = array('class' => $processInputClasses, 'event' => 'Kwf_Component_Event_Component_Removed', 'callback' => 'onComponentAddedOrRemoved');
     return $ret;
 }
 public static function getAllChainedByMasterFromChainedStart($componentClass, $master, $chainedType, $parentDataSelect)
 {
     if (Kwc_Abstract::getFlag($componentClass, 'chainedType') != $chainedType) {
         return array();
     }
     $ret = array();
     foreach (Kwf_Component_Data_Root::getInstance()->getComponentsByClass($componentClass, $parentDataSelect) as $chainedStart) {
         $i = Kwc_Chained_Abstract_Component::getChainedByMaster($master, $chainedStart, $chainedType, $parentDataSelect);
         if ($i) {
             $ret[] = $i;
         }
     }
     return $ret;
 }
 public static function getComponentsWithMasterTemplate($component)
 {
     $ret = array();
     $ret[] = array('type' => 'component', 'data' => $component);
     while ($component) {
         if (Kwc_Abstract::getTemplateFile($component->componentClass, 'Master') || Kwc_Abstract::hasSetting($component->componentClass, 'masterTemplate')) {
             $ret[] = array('type' => 'master', 'data' => $component);
         }
         if (Kwc_Abstract::getFlag($component->componentClass, 'resetMaster')) {
             break;
         }
         $component = $component->parent;
     }
     return $ret;
 }
 private function _getFrontendPackages()
 {
     $ret = array();
     $ret[] = Kwf_Assets_Package_ComponentFrontend::getInstance();
     $packageNames = array();
     foreach (Kwc_Abstract::getComponentClasses() as $cls) {
         if (Kwc_Abstract::getFlag($cls, 'assetsPackage')) {
             $packageName = Kwc_Abstract::getFlag($cls, 'assetsPackage');
             if ($packageName != 'Default' && !in_array($packageName, $packageNames)) {
                 $packageNames[] = $packageName;
                 $ret[] = Kwf_Assets_Package_ComponentPackage::getInstance($packageName);
             }
         }
     }
     return $ret;
 }
 public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer)
 {
     $ret = parent::getTemplateVars($renderer);
     $ret['headline1'] = $this->_getRow()->headline1;
     $ret['headline2'] = $this->_getRow()->headline2;
     $ret['headline1'] = str_replace('[-]', '&shy;', $ret['headline1']);
     $ret['headline2'] = str_replace('[-]', '&shy;', $ret['headline2']);
     $headlines = $this->_getSetting('headlines');
     if ($this->getRow()->headline_type && isset($headlines[$this->getRow()->headline_type])) {
         $ret['headlineType'] = $headlines[$this->getRow()->headline_type];
     } else {
         $ret['headlineType'] = reset($headlines);
     }
     $ret['showAnchor'] = Kwc_Abstract::getFlag($this->getData()->componentClass, 'hasAnchors');
     return $ret;
 }
Exemple #22
0
 public function onComponentAddedOrRemoved(Kwf_Component_Event_Component_AbstractFlag $ev)
 {
     if (!Kwc_Abstract::getFlag($ev->class, 'hasFulltext')) {
         //changed component doesn't have fulltext; ignore
         return;
     }
     $m = Kwc_FulltextSearch_MetaModel::getInstance();
     if ($page = $ev->component->getPage()) {
         $row = $m->getRow(array('equals' => array('page_id' => $page->componentId)));
         if (!$row) {
             $row = $m->createRow();
             $row->page_id = $page->componentId;
         }
         $row->changed_date = date('Y-m-d H:i:s');
         $row->save();
     }
 }
 protected function _getSubrootTitle()
 {
     $c = $this->getData()->parent;
     while ($c) {
         if ($c->inherits && Kwc_Abstract::getFlag($c->componentClass, 'subroot') || $c->componentId == 'root') {
             $title = $c->getChildComponent(array('id' => '-' . $this->getData()->id, 'componentClass' => $this->getData()->componentClass));
             if ($title) {
                 $title = $title->getComponent()->_getRow()->title;
                 if ($title) {
                     return $title;
                 }
             }
         }
         $c = $c->parent;
     }
     return null;
 }
 private function _deleteCache($event)
 {
     $page = $event->component->getParentPageOrRoot()->getParentPageOrRoot();
     $d = $page;
     while ($d) {
         if (Kwc_Abstract::getFlag($d->componentClass, 'subroot') || $d->componentId == 'root') {
             Kwf_Cache_Simple::delete('kwcMenuMobile-root-' . $d->componentId);
             break;
         } else {
             if ($d->isPage) {
                 Kwf_Cache_Simple::delete('kwcMenuMobile-' . $d->componentId);
                 break;
             }
         }
         $d = $d->parent;
     }
 }
 protected function _getMetaTags()
 {
     $ret = parent::_getMetaTags();
     $row = $this->_getRow();
     if ($row->description) {
         $ret['description'] = $row->description;
     }
     if ($row->og_title) {
         $ret['og:title'] = $row->og_title;
     }
     if ($row->og_description) {
         $ret['og:description'] = $row->og_description;
     }
     $ret['og:url'] = $this->getData()->getPage()->getAbsoluteUrl();
     $masterRow = $this->getData()->chained->getComponent()->getRow();
     if ($masterRow->noindex) {
         if (isset($ret['robots']) && strpos($ret['robots'], 'noindex') === false) {
             $ret['robots'] .= ',noindex';
         } else {
             $ret['robots'] = 'noindex';
         }
     }
     $c = $this->getData()->parent;
     while ($c) {
         if ($c->inherits && Kwc_Abstract::getFlag($c->componentClass, 'subroot') || $c->componentId == 'root') {
             $metaTags = $c->getChildComponent(array('id' => '-' . $this->getData()->id, 'componentClass' => $this->getData()->componentClass));
             if ($metaTags && is_instance_of($metaTags->componentClass, 'Kwc_Box_MetaTagsContent_Trl_Component')) {
                 $row = $metaTags->getComponent()->getRow();
                 if (!isset($ret['og:title']) && $row->og_title) {
                     $title = $this->getData()->getTitle();
                     //append own title
                     if ($title) {
                         $title .= ' - ';
                     }
                     $ret['og:title'] = $title . $row->og_title;
                 }
                 if (!isset($ret['og:site_name']) && $row->og_site_name) {
                     $ret['og:site_name'] = $row->og_site_name;
                 }
             }
         }
         $c = $c->parent;
     }
     return $ret;
 }
 public function render($componentId, $config)
 {
     $targetComponent = $this->_getComponentById($config['targetComponentId']);
     $targetPage = $targetComponent->getPage();
     if (!$targetPage) {
         return '';
     }
     if (!$targetPage->url) {
         return '';
     }
     $componentLinkModifiers = array();
     if (!isset($config['skipComponentLinkModifiers']) || !$config['skipComponentLinkModifiers']) {
         if (Kwc_Abstract::getFlag($targetPage->componentClass, 'hasComponentLinkModifiers')) {
             $componentLinkModifiers = $targetPage->getComponent()->getComponentLinkModifiers();
         }
     }
     return serialize(array($targetPage->url, $targetPage->rel, $targetPage->name, $targetPage->getLinkDataAttributes(), $componentLinkModifiers));
 }
 public function getPagePropertiesForm($config)
 {
     $c = $config['component'];
     if ($config['mode'] == 'add' || $c->isPage) {
         //pages can have their own title
         return new Kwc_Box_TitleEditable_Form(null, $this->_class);
     } else {
         if (Kwc_Abstract::getFlag($c->componentClass, 'subroot') || $c->componentId == 'root') {
             //subroots/root can have title for child pages
             $ret = new Kwc_Box_TitleEditable_Form(null, $this->_class);
             $ret->fields['title']->setHelpText(null);
             $ret->fields['title']->setComment(trlKwf('for child pages'));
             return $ret;
         }
     }
     //others have no title
     return null;
 }
 public function getContents($language)
 {
     $appIds = array();
     foreach (Kwf_Component_Abstract::getComponentClasses() as $class) {
         if (!Kwc_Abstract::getFlag($class, 'hasBaseProperties')) {
             continue;
         }
         $subRoots = Kwf_Component_Data_Root::getInstance()->getComponentsByClass($class);
         foreach ($subRoots as $subRoot) {
             if ($appId = $subRoot->getBaseProperty('fbAppData.appId')) {
                 $appIds[$subRoot->componentId] = $appId;
             }
         }
     }
     if (empty($appIds)) {
         throw new Kwf_Exception('No Facebook App ID found');
     }
     return "Kwf.FacebookAppIds = " . json_encode($appIds) . ";\n";
 }
 public function addResources(Kwf_Acl $acl)
 {
     $menuConfig = array('icon' => new Kwf_Asset('group.png'));
     $components = Kwf_Component_Data_Root::getInstance()->getComponentsByClass(Kwc_Abstract::getSetting($this->_class, 'subscribeToNewsletterClass'), array('ignoreVisible' => true));
     foreach ($components as $c) {
         $menuConfig['text'] = $this->_getMenuConfigText($c);
         if (count($components) > 1) {
             $subRoot = $c;
             while ($subRoot = $subRoot->parent) {
                 if (Kwc_Abstract::getFlag($subRoot->componentClass, 'subroot')) {
                     break;
                 }
             }
             if ($subRoot) {
                 $menuConfig['text'] .= ' (' . $subRoot->name . ')';
             }
         }
         $acl->add(new Kwc_Newsletter_Subscribe_Resource($this->_class . $c->dbId, $menuConfig, Kwc_Admin::getInstance($this->_class)->getControllerUrl('Recipients') . '?newsletterComponentId=' . $c->dbId, $this->_class, $c), $this->_getParentResource($acl, 'subscribe'));
     }
 }
Exemple #30
0
 public static function getChildPageByPath($component, $path)
 {
     if ($path == '') {
         $ret = $component->getChildPage(array('home' => true), array());
     } else {
         foreach (Kwc_Abstract::getComponentClasses() as $c) {
             if (Kwc_Abstract::getFlag($c, 'shortcutUrl')) {
                 $ret = call_user_func(array($c, 'getDataByShortcutUrl'), $c, $path);
                 if ($ret) {
                     return $ret;
                 }
             }
         }
         $ret = $component->getChildPageByPath($path);
     }
     if ($ret && !$ret->isPage && Kwf_Component_Abstract::getFlag($ret->componentClass, 'hasHome')) {
         $ret = $ret->getChildPage(array('home' => true), array());
     }
     return $ret;
 }