Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 protected function _initSettings()
 {
     $masterComponentClass = Kwc_Abstract::getSetting($this->_class, 'masterComponentClass');
     $masterMenuComponentClass = Kwc_Abstract::getSetting($masterComponentClass, 'menuComponentClass');
     $trlMenuComponentClass = Kwc_Chained_Abstract_Component::getChainedComponentClass($masterMenuComponentClass, 'Trl');
     $this->_menuComponentClass = $trlMenuComponentClass;
 }
Exemplo n.º 3
0
 public static function getSettings($masterComponentClass = null)
 {
     $ret = parent::getSettings($masterComponentClass);
     $ret = Kwc_Chained_Abstract_Component::getChainedSettings($ret, $masterComponentClass, 'Cc');
     $ret['flags']['chainedType'] = 'Cc';
     return $ret;
 }
Exemplo n.º 4
0
 public function onMasterContentChanged(Kwf_Component_Event_Component_ContentChanged $event)
 {
     parent::onMasterContentChanged($event);
     $components = Kwc_Chained_Abstract_Component::getAllChainedByMaster($event->component, 'Trl');
     foreach ($components as $component) {
         $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($component->componentClass, $component));
     }
 }
Exemplo n.º 5
0
 public static function getSettings($masterComponentClass)
 {
     $ret = parent::getSettings();
     $copySettings = array('editComponents');
     $copyFlags = array('subroot');
     $ret = Kwc_Chained_Abstract_Component::getChainedSettings($ret, $masterComponentClass, 'Trl', $copySettings, $copyFlags);
     $ret['flags']['chainedType'] = 'Trl';
     return $ret;
 }
Exemplo n.º 6
0
 public function onGeneratorRowUpdate(Kwf_Component_Event_Component_RowUpdated $event)
 {
     $chained = Kwc_Chained_Abstract_Component::getAllChainedByMaster($event->component, 'Trl', array('ignoreVisible' => true));
     foreach ($chained as $i) {
         if ($i->componentClass != $this->_class) {
             throw new Kwf_Exception('getAllChainedByMaster returned incorrect component');
         }
         $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($this->_class, $i));
     }
 }
Exemplo n.º 7
0
 public function onMasterRowDelete(Kwf_Events_Event_Row_Abstract $event)
 {
     $chainedType = 'Trl';
     foreach (Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($event->row->component_id) as $c) {
         $chained = Kwc_Chained_Abstract_Component::getAllChainedByMaster($c, $chainedType);
         foreach ($chained as $c) {
             $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($this->_class, $c));
             $this->fireEvent(new Kwf_Component_Event_Component_HasContentChanged($this->_class, $c));
         }
     }
 }
Exemplo n.º 8
0
 public static function getSettings($masterComponentClass)
 {
     $ret = parent::getSettings();
     $copySettings = array('editComponents', 'masterTemplate', 'resetMaster');
     $copyFlags = array('subroot');
     $ret = Kwc_Chained_Abstract_Component::getChainedSettings($ret, $masterComponentClass, 'Trl', $copySettings, $copyFlags);
     $ret['flags']['hasHome'] = true;
     $ret['flags']['chainedType'] = 'Trl';
     $ret['flags']['hasBaseProperties'] = true;
     $ret['baseProperties'] = array('language');
     return $ret;
 }
Exemplo n.º 9
0
 public function onPageAddedRemoved(Kwf_Component_Event_Component_Abstract $ev)
 {
     $master = $ev->component;
     if (is_instance_of($master->componentClass, 'Kwc_Chained_Trl_Component')) {
         $master = $master->chained;
     }
     $masterCc = Kwc_Abstract::getSetting($this->_class, 'masterComponentClass');
     foreach (Kwc_Chained_Abstract_Component::getAllChainedByMaster($master, 'Trl') as $page) {
         foreach ($page->getRecursiveChildComponents(array('componentClass' => $masterCc)) as $c) {
             //for child component, because this trl is MasterAsChild
             $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($masterCc, $c));
         }
     }
 }
Exemplo n.º 10
0
 public function onMasterRowUpdate(Kwf_Events_Event_Row_Abstract $event)
 {
     parent::onMasterRowUpdate($event);
     if ($event->isDirty('visible')) {
         //trl doesn't have own visible, master visible is used
         $chainedType = 'Trl';
         foreach (Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($event->row->component_id) as $c) {
             $chained = Kwc_Chained_Abstract_Component::getAllChainedByMaster($c, $chainedType);
             foreach ($chained as $c) {
                 $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($this->_class, $c));
             }
         }
     }
 }
Exemplo n.º 11
0
 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;
 }
Exemplo n.º 12
0
 protected function _getSelect()
 {
     $ret = parent::_getSelect();
     $componentId = $this->_getParam('componentId');
     $component = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($componentId, array('ignoreVisible' => true));
     if (isset($component->parent->chained)) {
         $component = $component->parent->chained;
     }
     $dbIds = array($component->dbId);
     foreach (Kwc_Chained_Abstract_Component::getAllChainedByMaster($component, 'Trl') as $c) {
         $dbIds[] = $c->dbId;
     }
     $ret->whereEquals('component_id', $dbIds);
     return $ret;
 }
Exemplo n.º 13
0
 private function _fireUrlChanged($component, $eventClass)
 {
     $master = $component;
     if (is_instance_of($master->componentClass, 'Kwc_Chained_Trl_Component')) {
         $master = $master->chained;
     }
     $components = Kwc_Chained_Abstract_Component::getAllChainedByMaster($master, 'Trl');
     $components[] = $master;
     foreach ($components as $c) {
         $s = array('componentClass' => $this->_class);
         foreach ($c->getRecursiveChildComponents($s) as $c) {
             $this->fireEvent(new $eventClass($this->_class, $c));
         }
     }
 }
Exemplo n.º 14
0
 public function onMasterImageChanged(Kwc_Abstract_Image_ImageChangedEvent $event)
 {
     $chained = Kwc_Chained_Abstract_Component::getAllChainedByMaster($event->component, 'Trl');
     foreach ($chained as $c) {
         $components = $c->getRecursiveChildComponents(array('componentClass' => $this->_class));
         foreach ($components as $component) {
             $imageData = $component->getComponent()->getImageData();
             $dim = $component->getComponent()->getImageDimensions();
             $typeBase = $component->getComponent()->getBaseType();
             $steps = Kwf_Media_Image::getResponsiveWidthSteps($dim, $imageData['file']);
             foreach ($steps as $step) {
                 $this->fireEvent(new Kwf_Events_Event_Media_Changed($this->_class, $component, str_replace('{width}', $step, $typeBase)));
             }
             $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($this->_class, $component));
         }
     }
 }
Exemplo n.º 15
0
 public function onMasterOwnRowUpdate(Kwf_Events_Event_Row_Abstract $event)
 {
     parent::onMasterOwnRowUpdate($event);
     $cmps = Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($event->row->component_id, array('ignoreVisible' => true));
     foreach ($cmps as $c) {
         $chainedType = 'Trl';
         $select = array('ignoreVisible' => true);
         $chained = Kwc_Chained_Abstract_Component::getAllChainedByMaster($c, $chainedType, $select);
         foreach ($chained as $i) {
             if ($i->componentClass != $this->_class) {
                 continue;
             }
             //like in parent::onMasterOwnRowUpdate
             if ($i->getComponent()->getRow()->own_download) {
                 continue;
             }
             $this->fireEvent(new Kwf_Component_Event_Page_UrlChanged($this->_class, $i));
         }
     }
 }
Exemplo n.º 16
0
 public function onMasterOwnRowUpdate(Kwf_Events_Event_Row_Abstract $event)
 {
     $cmps = Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($event->row->component_id, array('ignoreVisible' => true));
     foreach ($cmps as $c) {
         $chainedType = 'Trl';
         $select = array('ignoreVisible' => true);
         $chained = Kwc_Chained_Abstract_Component::getAllChainedByMaster($c, $chainedType, $select);
         foreach ($chained as $i) {
             if ($i->componentClass != $this->_class) {
                 continue;
             }
             if (Kwc_Abstract::hasSetting($this->_class, 'throwContentChangedOnOwnMasterModelUpdate')) {
                 $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($this->_class, $i));
             }
             if (Kwc_Abstract::hasSetting($this->_class, 'throwHasContentChangedOnMasterRowColumnsUpdate')) {
                 $cols = Kwc_Abstract::getSetting($this->_class, 'throwHasContentChangedOnMasterRowColumnsUpdate');
                 if ($event->isDirty($cols)) {
                     $this->fireEvent(new Kwf_Component_Event_Component_HasContentChanged($this->_class, $i));
                 }
             }
         }
     }
 }
Exemplo n.º 17
0
 public function testAllChainedByMaster()
 {
     $chained = Kwc_Chained_Abstract_Component::getAllChainedByMaster($this->_root->getChildComponent('_dir'), 'Trl');
     $this->assertEquals(1, count($chained));
 }
Exemplo n.º 18
0
 protected function _getComponentsFromMasterRow($row, $select)
 {
     $chainedType = 'Trl';
     $ret = array();
     foreach ($this->_getMasterComponentsFromMasterRow($row, array('ignoreVisible' => true)) as $c) {
         $chained = Kwc_Chained_Abstract_Component::getAllChainedByMaster($c, $chainedType, $select);
         foreach ($chained as $i) {
             if ($i->generator !== $this->_getGenerator()) {
                 //can happen if two components use same model
                 continue;
             }
         }
         $ret = array_merge($ret, $chained);
     }
     return $ret;
 }
Exemplo n.º 19
0
 public static function getChainedByMaster($masterData, $chainedData, $select = array())
 {
     return Kwc_Chained_Abstract_Component::_getChainedByMaster($masterData, $chainedData, 'Cc', $select);
 }
Exemplo n.º 20
0
 public function onMasterMediaChanged(Kwf_Events_Event_Media_Changed $event)
 {
     foreach (Kwc_Chained_Abstract_Component::getAllChainedByMaster($event->component, 'Trl') as $c) {
         $this->fireEvent(new Kwf_Events_Event_Media_Changed($this->_class, $c, $event->type));
     }
 }
Exemplo n.º 21
0
 public function getChildData($parentDatas, $select = array())
 {
     Kwf_Benchmark::count('GenChained::getChildData');
     $ret = array();
     if (is_array($select)) {
         $select = new Kwf_Component_Select($select);
     }
     $chainedType = $this->getGeneratorFlag('chainedType');
     $slaveData = $select->getPart(Kwf_Component_Select::WHERE_CHILD_OF);
     while ($slaveData) {
         if (Kwc_Abstract::getFlag($slaveData->componentClass, 'chainedType') == $chainedType) {
             break;
         }
         $slaveData = $slaveData->parent;
     }
     $parentDataSelect = new Kwf_Component_Select();
     $parentDataSelect->copyParts(array('ignoreVisible'), $select);
     $parentDatas = is_array($parentDatas) ? $parentDatas : array($parentDatas);
     foreach ($parentDatas as $parentData) {
         foreach ($this->_getChainedChildComponents($parentData, $select) as $component) {
             $pData = array();
             if (!$parentData) {
                 if (!$slaveData) {
                     $pData = Kwc_Chained_Abstract_Component::getAllChainedByMaster($component->parent, $chainedType, $parentDataSelect);
                 } else {
                     $chainedComponent = Kwc_Chained_Abstract_Component::getChainedByMaster($component->parent, $slaveData, $chainedType, $parentDataSelect);
                     if ($chainedComponent) {
                         $pData = array($chainedComponent);
                     }
                 }
             } else {
                 $pData = array($parentData);
             }
             foreach ($pData as $d) {
                 $data = $this->_createData($d, $component, $select);
                 if ($data) {
                     $ret[] = $data;
                 }
             }
         }
     }
     return $ret;
 }
Exemplo n.º 22
0
 public function onMasterChildRowDelete(Kwc_Directories_List_EventItemDeleted $event)
 {
     foreach (Kwc_Chained_Abstract_Component::getAllChainedByMaster($event->subroot, 'Trl', array()) as $sr) {
         $this->fireEvent(new Kwc_Directories_List_EventItemDeleted($this->_class, $event->itemId, $sr));
     }
 }