private function _getContentChild() { $model = $this->getOwnModel(); $masterChild = $this->getData()->chained->getComponent()->getContentChild(); $c = Kwc_Chained_Trl_Component::getChainedByMaster($masterChild, $this->getData()); $page = $this->getData(); while ($c && (!$c->hasContent() || $this->_getSetting('hasVisible') && $c->parent->getComponent()->getRow() && !$c->parent->getComponent()->getRow()->visible)) { while ($page && !$page->inherits) { $page = $page->parent; if ($page instanceof Kwf_Component_Data_Root) { break; } } if (!isset($page->chained)) { $c = null; break; } $masterChild = $page->chained->getChildComponent('-' . $this->getData()->id)->getChildComponent(array('generator' => 'child')); $c = Kwc_Chained_Trl_Component::getChainedByMaster($masterChild, $this->getData()); if ($page instanceof Kwf_Component_Data_Root) { break; } $page = $page->parent; } return $c; }
public final function getLinkedData() { if (!isset($this->_data)) { $masterLinkData = $this->chained->getLinkedData(array('ignoreVisible' => true)); if (!$masterLinkData) { $this->_data = false; } if ($masterLinkData) { if (is_null($this->_type)) { throw new Kwf_Exception("_type may not be null"); } if ($this->_type == 'Trl') { $linkComponent = Kwc_Chained_Trl_Component::getChainedByMaster($masterLinkData, $this); } else { if ($this->_type == 'Cc') { $linkComponent = Kwc_Chained_Cc_Component::getChainedByMaster($masterLinkData, $this); } } if (!$linkComponent) { $this->_data = false; //kann offline sein } else { $this->_data = $linkComponent; } } } $m = Kwc_Abstract::createModel($this->chained->componentClass); $result = $m->fetchColumnsByPrimaryId(array('anchor'), $this->chained->dbId); if ($result['anchor']) { $this->_anchor = $result['anchor']; } return $this->_data; }
public function getTemplateVars() { $ret = parent::getTemplateVars(); $menu = array(); $masterMenu = $this->getData()->chained->getComponent()->getMenuData(null, array('ignoreVisible' => true)); foreach ($masterMenu as $m) { $component = Kwc_Chained_Trl_Component::getChainedByMaster($m['data'], $this->getData()); if ($component) { $m['submenu'] = array(); $masterSubMenu = $this->getData()->chained->getComponent()->getMenuData($m['data'], array('ignoreVisible' => true), 'Kwc_Menu_Expanded_EditableItems_Component'); foreach ($masterSubMenu as $sm) { $sComponent = Kwc_Chained_Trl_Component::getChainedByMaster($sm['data'], $this->getData()); if ($sComponent) { $sm['data'] = $sComponent; $sm['text'] = $sComponent->name; $m['submenu'][] = $sm; } } $this->_attachEditableToMenuData($m['submenu']); $m['data'] = $component; $m['text'] = $component->name; $menu[] = $m; } } $ret['menu'] = $menu; return $ret; }
public final function getLinkedData() { if (!isset($this->_data)) { $masterLinkData = $this->chained->getLinkedData(array('ignoreVisible' => true)); if (!$masterLinkData) { $this->_data = false; } if ($masterLinkData) { if (is_null($this->_type)) { throw new Kwf_Exception("_type may not be null"); } if ($this->_type == 'Trl') { $linkComponent = Kwc_Chained_Trl_Component::getChainedByMaster($masterLinkData, $this); } else { if ($this->_type == 'Cc') { $linkComponent = Kwc_Chained_Cc_Component::getChainedByMaster($masterLinkData, $this); } } if (!$linkComponent) { $this->_data = false; //kann offline sein } else { $this->_data = $linkComponent; } } } return $this->_data; }
public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer) { $ret = parent::getTemplateVars($renderer); $ret['link1'] = Kwc_Chained_Trl_Component::getChainedByMaster($ret['link1'], $this->getData()); $ret['link4'] = Kwc_Chained_Trl_Component::getChainedByMaster($ret['link4'], $this->getData()); $ret['link5'] = Kwc_Chained_Trl_Component::getChainedByMaster($ret['link5'], $this->getData()); return $ret; }
public function getTemplateVars() { $ret = parent::getTemplateVars(); $ret['link1'] = Kwc_Chained_Trl_Component::getChainedByMaster($ret['link1'], $this->getData()); $ret['link4'] = Kwc_Chained_Trl_Component::getChainedByMaster($ret['link4'], $this->getData()); $ret['link5'] = Kwc_Chained_Trl_Component::getChainedByMaster($ret['link5'], $this->getData()); return $ret; }
public function attachEditableToMenuData(&$menuData) { foreach ($menuData as $k => &$m) { if (isset($m['editable']) && $m['editable']) { $m['editable'] = Kwc_Chained_Trl_Component::getChainedByMaster($m['editable'], $this->getData()); } } }
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); } }
protected function _createData($parentData, $row, $select) { $ret = parent::_createData($parentData, $row, $select); $ret->targetPage = Kwc_Chained_Trl_Component::getChainedByMaster($row->targetPage, $parentData, array('ignoreVisible' => $select->getPart(Kwf_Component_Select::IGNORE_VISIBLE))); if (!$ret->targetPage) { return null; } return $ret; }
private function _getChainedId($masterId, $select = array()) { $root = Kwf_Component_Data_Root::getInstance(); $masterData = $root->getComponentById($masterId); $chainedData = $root->getComponentById('root-en'); $component = Kwc_Chained_Trl_Component::getChainedByMaster($masterData, $chainedData, $select); if ($component) { return $component->componentId; } return null; }
public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer) { $ret = parent::getTemplateVars($renderer); foreach ($ret['links'] as $k => $i) { $chained = Kwc_Chained_Trl_Component::getChainedByMaster($i['component'], $this->getData()); if ($chained) { $ret['links'][$k]['component'] = $chained; } else { unset($ret['links'][$k]); } } return $ret; }
public function getMenuData() { $menu = array(); $masterMenu = $this->getData()->chained->getComponent()->getMenuData(null, array('ignoreVisible' => true)); foreach ($masterMenu as $m) { $component = Kwc_Chained_Trl_Component::getChainedByMaster($m['data'], $this->getData()); if ($component) { $m['data'] = $component; $m['text'] = '{name}'; $menu[] = $m; } } $this->_attachEditableToMenuData($menu); return $menu; }
public function onPageRemovedAdded(Kwf_Component_Event_Component_AbstractFlag $event) { if (!isset($event->component->chained)) { return; } $masterDatas = Kwc_Basic_LinkTag_Intern_Events::getComponentsForTarget(Kwc_Abstract::getSetting($this->_class, 'masterComponentClass'), array((string) $event->component->chained->dbId), false); foreach ($masterDatas as $c) { $c = Kwc_Chained_Trl_Component::getChainedByMaster($c, $event->component); if ($c) { $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($this->_class, $c)); if ($c->isPage) { $this->fireEvent(new Kwf_Component_Event_Page_UrlChanged($this->_class, $c)); } } } }
public function getLanguages($showCurrent, $fallbackToHome) { $ret = array(); foreach ($this->_getLanguages() as $l) { if (!$showCurrent) { if ($this->getData()->getLanguage() == $l->getLanguage()) { continue; } } $masterPage = $this->getData()->getPage(); if (isset($masterPage->chained)) { $masterPage = $masterPage->chained; //TODO: nicht sauber } $page = null; if ($masterPage) { if (is_instance_of($l->componentClass, 'Kwc_Root_TrlRoot_Chained_Component')) { $page = Kwc_Chained_Trl_Component::getChainedByMaster($masterPage, $l); } else { if (is_instance_of($l->componentClass, 'Kwc_Root_TrlRoot_Master_Component')) { $page = $masterPage; } } $p = $page; while ($p && $page) { //TODO dafür müsste es eine bessere methode geben if (isset($p->row) && isset($p->row->visible) && !$p->row->visible) { $page = null; } $p = $p->parent; } } $home = $l->getChildPage(array('home' => true)); if ($home) { if (!$fallbackToHome && !$page) { continue; } $ret[] = array('language' => $l->id, 'home' => $home, 'page' => $page ? $page : $home, 'flag' => $l->getChildComponent('-flag'), 'name' => $l->name, 'current' => $this->getData()->getLanguage() == $l->getLanguage()); } } if ($showCurrent && $fallbackToHome && count($ret) == 1) { $ret = array(); } return $ret; }
public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer) { $ret = parent::getTemplateVars($renderer); foreach ($ret['menu'] as $k => $m) { $ret['menu'][$k]['submenu'] = array(); $masterSubMenu = $this->getData()->chained->getComponent()->getMenuData($m['data']->chained, array('ignoreVisible' => true), 'Kwc_Menu_Expanded_EditableItems_Component'); foreach ($masterSubMenu as $sm) { $sComponent = Kwc_Chained_Trl_Component::getChainedByMaster($sm['data'], $this->getData()); if ($sComponent) { $sm['data'] = $sComponent; $sm['text'] = $sComponent->name; $ret['menu'][$k]['submenu'][] = $sm; } } $this->_attachEditableToMenuData($ret['menu'][$k]['submenu']); } return $ret; }
public function getMenuData() { $menu = array(); $masterMenu = $this->getData()->chained->getComponent()->getMenuData(null, array('ignoreVisible' => true)); $i = 0; foreach ($masterMenu as $m) { $component = Kwc_Chained_Trl_Component::getChainedByMaster($m['data'], $this->getData()); if ($component) { if ($i == 0 && strpos($m['class'], 'first') === false) { $m['class'] .= ' first'; } $m['data'] = $component; $m['text'] = '{name}'; $menu[] = $m; $i++; } } if (isset($menu[count($menu) - 1]) && !$menu[count($menu) - 1]['last']) { $menu[count($menu) - 1]['last'] = true; $menu[count($menu) - 1]['class'] .= ' last'; } $this->_attachEditableToMenuData($menu); return $menu; }
public function getRows($where = null, $order = null, $limit = null, $start = null) { if (!is_object($where)) { $select = $this->select(); if ($where) { $select->where($where); } if ($order) { $select->order($order); } if ($limit || $start) { $select->limit($limit, $start); } } else { $select = $where; } $root = $this->getRoot(); $where = $select->getPart(Kwf_Model_Select::WHERE_EQUALS); $parts = $select->getPart(Kwf_Model_Select::WHERE_NULL); if ($select->hasPart(Kwf_Model_Select::WHERE_EXPRESSION)) { // Suchfeld return array(); // TODO: fix, didn't work before neither $model = Kwf_Model_Abstract::getInstance('Kwc_Root_Category_GeneratorModel'); $rowset = array(); $languages = null; $searchSelect = array('ignoreVisible' => true); foreach ($model->getRows($select) as $row) { $component = $root->getComponentById($row->id, $searchSelect); if (!$component) { continue; } if (is_null($languages)) { $c = $component; while ($c && !Kwc_Abstract::getFlag($c->componentClass, 'hasLanguage')) { $c = $c->parent; } if ($c) { $languagesModel = $c->parent->getComponent()->getChildModel(); foreach ($languagesModel->getRows() as $language) { $data = $root->getComponentById($language->component_id, $searchSelect); if ($data) { $languages[] = $data; } } } else { $languages = array(); } } $rowset[] = $component; foreach ($languages as $language) { $rowset[] = Kwc_Chained_Trl_Component::getChainedByMaster($component, $language, $searchSelect); } } if ($languages) { $model = Kwf_Model_Abstract::getInstance('Kwc_Root_Category_Trl_GeneratorModel'); $s = clone $select; $s->unsetPart('order'); foreach ($model->getRows($s) as $row) { $rowset[] = $root->getComponentById($row->component_id, $searchSelect); } } } else { if ($parts && in_array('parent_id', $parts)) { $rowset = array($root); } else { if (isset($where['parent_id'])) { $page = $root->getComponentById($where['parent_id'], array('ignoreVisible' => true)); if (!$page) { throw new Kwf_Exception("Can't find page with id '{$where['parent_id']}'"); } $rowset = $this->_getPages($page); $rowset = array_values($rowset); } else { if (isset($where['componentId'])) { $rowset = array(Kwf_Component_Data_Root::getInstance()->getComponentById($where['componentId'], array('ignoreVisible' => true))); } else { throw new Kwf_Exception('Cannot return all pages'); } } } } return new $this->_rowsetClass(array('dataKeys' => $rowset, 'rowClass' => $this->_rowClass, 'model' => $this)); }
protected function _attachEditableToMenuData(&$menuData, $menuComponent = null) { $component = $this->getData()->chained->getComponent()->getParentContentData(); $component = Kwc_Chained_Trl_Component::getChainedByMaster($component, $this->getData()); parent::_attachEditableToMenuData($menuData, $component); }