예제 #1
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));
     }
 }
예제 #2
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));
     }
 }
예제 #3
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));
         }
     }
 }
예제 #4
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));
             }
         }
     }
 }
예제 #5
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));
         }
     }
 }
예제 #6
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));
         }
     }
 }
예제 #7
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;
 }
예제 #8
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));
         }
     }
 }
예제 #9
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));
         }
     }
 }
예제 #10
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));
                 }
             }
         }
     }
 }
예제 #11
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;
 }
예제 #12
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));
     }
 }
예제 #13
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));
     }
 }
예제 #14
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;
 }
예제 #15
0
 public function testAllChainedByMaster()
 {
     $chained = Kwc_Chained_Abstract_Component::getAllChainedByMaster($this->_root->getChildComponent('_dir'), 'Trl');
     $this->assertEquals(1, count($chained));
 }