Ejemplo n.º 1
0
 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;
     }
     $parentData = null;
     $itemDirectory = $this->getItemDirectory();
     if (is_string($itemDirectory)) {
         $itemDirectoryClass = $itemDirectory;
     } else {
         $itemDirectoryClass = $itemDirectory->componentClass;
         $parentData = $itemDirectory;
     }
     $gen = Kwf_Component_Generator_Abstract::getInstance($itemDirectoryClass, 'detail');
     $rowset = $gen->getChildData($parentData, $select);
     $rowset = array_values($rowset);
     return new $this->_rowsetClass(array('dataKeys' => $rowset, 'rowClass' => $this->_rowClass, 'model' => $this));
 }
Ejemplo n.º 2
0
 protected function _getRssEntries()
 {
     $select = $this->_getSelect();
     if (!$select) {
         return array();
     }
     $select->limit(10);
     if (!$select->hasPart('group')) {
         $select->group('id');
     }
     $itemDirectory = $this->getData()->parent->getComponent()->getItemDirectory();
     if (is_string($itemDirectory)) {
         $c = Kwc_Abstract::getComponentClassByParentClass($itemDirectory);
         $generator = Kwf_Component_Generator_Abstract::getInstance($c, 'detail');
         $items = $generator->getChildData(null, $select);
         //TODO: callModifyItemData aufrufen
     } else {
         $items = $itemDirectory->getChildComponents($select);
         foreach ($items as $item) {
             $itemDirectory->getComponent()->callModifyItemData($item);
         }
     }
     $ret = array();
     foreach ($items as $item) {
         $ret[] = $this->_getRssEntryByItem($item);
     }
     return $ret;
 }
Ejemplo n.º 3
0
 public function duplicate($source, $target, Zend_ProgressBar $progressBar = null)
 {
     Kwf_Component_LogDuplicateModel::getInstance()->import(Kwf_Model_Abstract::FORMAT_ARRAY, array(array('source_component_id' => $source->dbId, 'target_component_id' => $target->dbId)));
     if (($model = $source->getComponent()->getOwnModel()) && $source->dbId != $target->dbId) {
         $row = $model->getRow($source->dbId);
         if ($row) {
             $targetRow = $model->getRow($target->dbId);
             if ($targetRow) {
                 $targetRow->delete();
             }
             $newRow = $row->duplicate(array('component_id' => $target->dbId));
         }
     }
     $s = array('ignoreVisible' => true);
     foreach ($source->getChildComponents($s) as $c) {
         if ($c->generator->hasSetting('inherit') && $c->generator->getSetting('inherit') && $c->generator->hasSetting('unique') && $c->generator->getSetting('unique') && $source->componentId != $c->parent->componentId) {
             continue;
         } else {
             if (!$c->generator->hasSetting('inherit') && !Kwf_Component_Generator_Abstract::hasInstance($target->componentClass, $c->generator->getGeneratorKey())) {
                 continue;
             } else {
                 if ($c->generator->getGeneratorFlag('pageGenerator')) {
                     continue;
                 }
             }
         }
         $c->generator->duplicateChild($c, $target, $progressBar);
     }
 }
 public function load($row, array $info = array())
 {
     $gen = Kwf_Component_Generator_Abstract::getInstance($this->_componentClass, $this->_generatorKey);
     $edit = Kwf_Component_Abstract_ExtConfig_Abstract::getEditConfigs($this->_getComponentClassByRow($row), $gen, '{componentId}-{0}', '');
     $this->_componentConfigs = array_merge($this->_componentConfigs, $edit['componentConfigs']);
     $ret = $edit['contentEditComponents'];
     $g = Kwc_Abstract::getSetting($this->_componentClass, 'generators');
     if (isset($g['detail']['dbIdShortcut'])) {
         $dbId = $g['detail']['dbIdShortcut'] . $row->id;
     } else {
         $dbId = $row->component_id . $gen->getIdSeparator() . $row->id;
     }
     $components = Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($dbId, array('ignoreVisible' => true));
     if (isset($components[0])) {
         foreach (Kwf_Controller_Action_Component_PagesController::getSharedComponents($components[0]) as $cls => $cmp) {
             $cfg = Kwc_Admin::getInstance($cls)->getExtConfig(Kwf_Component_Abstract_ExtConfig_Abstract::TYPE_SHARED);
             foreach ($cfg as $k => $c) {
                 if (!isset($this->_componentConfigs[$cls . '-' . $k])) {
                     $this->_componentConfigs[$cls . '-' . $k] = $c;
                 }
                 $ret[] = array('componentClass' => $cls, 'type' => $k, 'idTemplate' => '{componentId}-{0}', 'componentIdSuffix' => '');
             }
         }
     }
     return $ret;
 }
Ejemplo n.º 5
0
 public function duplicate($source, $target, Zend_ProgressBar $progressBar = null)
 {
     $contexts = Kwf_Component_Layout_Abstract::getInstance($target->componentClass)->getContexts($target);
     $supportedContexts = Kwf_Component_Layout_Abstract::getInstance($target->componentClass)->getSupportedContexts();
     if ($contexts && $supportedContexts) {
         foreach ($contexts as $context) {
             if (!in_array($context, $supportedContexts)) {
                 throw new Kwf_Component_Exception_IncompatibleContexts("Duplicating component in incompatible context");
             }
         }
     }
     Kwf_Component_LogDuplicateModel::getInstance()->import(Kwf_Model_Abstract::FORMAT_ARRAY, array(array('source_component_id' => $source->dbId, 'target_component_id' => $target->dbId)));
     if ($source->getComponent()->getOwnModel() && $source->dbId != $target->dbId) {
         $this->_duplicateOwnRow($source, $target);
     }
     $s = array('ignoreVisible' => true);
     foreach ($source->getChildComponents($s) as $c) {
         if ($c->generator->hasSetting('inherit') && $c->generator->getSetting('inherit') && $c->generator->hasSetting('unique') && $c->generator->getSetting('unique') && $source->componentId != $c->parent->componentId) {
             continue;
         } else {
             if (!$c->generator->hasSetting('inherit') && !Kwf_Component_Generator_Abstract::hasInstance($target->componentClass, $c->generator->getGeneratorKey())) {
                 continue;
             } else {
                 if ($c->generator->getGeneratorFlag('pageGenerator')) {
                     continue;
                 }
             }
         }
         $c->generator->duplicateChild($c, $target, $progressBar);
     }
 }
Ejemplo n.º 6
0
 public function onDirectoryUpdate(Kwc_Directories_List_EventItemAbstract $event)
 {
     $datas = Kwf_Component_Generator_Abstract::getInstance($event->class, 'detail')->getChildData(null, array('id' => $event->itemId));
     if (isset($datas[0])) {
         $directory = $datas[0]->parent;
         $this->fireEvent(new Kwf_Component_Event_ComponentClass_Tag_ContentChanged($this->_class, $directory->componentId));
     }
 }
Ejemplo n.º 7
0
 public function testGeneratorInstancesByChildComponentClass()
 {
     $s = array('componentClass' => 'Kwf_Component_Generator_GetRecursiveChildComponentsWithAlternativeComponent_TestComponent2_Component');
     $g = Kwf_Component_Generator_Abstract::getInstances('Kwf_Component_Generator_GetRecursiveChildComponentsWithAlternativeComponent_Root', $s);
     $this->assertEquals(1, count($g));
     $g = array_values($g);
     $this->assertEquals('Kwf_Component_Generator_GetRecursiveChildComponentsWithAlternativeComponent_Root', $g[0]->getClass());
     $this->assertEquals('test1', $g[0]->getGeneratorKey());
 }
 private function _assertGeneratorsCount($select, $count, $component = 'Kwf_Component_Generator_Components_Multiple')
 {
     $select = new Kwf_Component_Select($select);
     $initailSelect = clone $select;
     $generators = Kwf_Component_Generator_Abstract::getInstances($component, $select);
     $this->assertEquals($count, count($generators));
     $this->assertEquals($initailSelect, $select);
     //check if select was modified
 }
Ejemplo n.º 9
0
 private function _getSubrootFromItemId($dirCls, $itemId)
 {
     $gen = Kwf_Component_Generator_Abstract::getInstance($dirCls, 'detail');
     $datas = $gen->getChildData(null, array('id' => $itemId, 'ignoreVisible' => true));
     if (!isset($datas[0])) {
         return null;
     }
     return $datas[0]->getSubroot();
 }
Ejemplo n.º 10
0
 public function getListeners()
 {
     $ret = array();
     $generator = Kwf_Component_Generator_Abstract::getInstance($this->_class, 'detail');
     $ret[] = array('class' => get_class($generator->getModel()), 'event' => 'Kwf_Events_Event_Row_Updated', 'callback' => 'onChildRowUpdate');
     $ret[] = array('class' => get_class($generator->getModel()), 'event' => 'Kwf_Events_Event_Row_Inserted', 'callback' => 'onChildRowInsert');
     $ret[] = array('class' => get_class($generator->getModel()), 'event' => 'Kwf_Events_Event_Row_Deleted', 'callback' => 'onChildRowDelete');
     $ret[] = array('class' => get_class($generator->getModel()), 'event' => 'Kwf_Events_Event_Model_Updated', 'callback' => 'onChildModelUpdated');
     return $ret;
 }
Ejemplo n.º 11
0
 public function testGetComponentByClass()
 {
     $components = Kwf_Component_Data_Root::getInstance()->getComponentsByClass('Kwf_Component_Generator_Recursive_Root');
     $this->assertEquals(1, count($components));
     $components = Kwf_Component_Data_Root::getInstance()->getComponentsBySameClass('Kwf_Component_Generator_Recursive_Root');
     $this->assertEquals(1, count($components));
     $generator = Kwf_Component_Generator_Abstract::getInstance('Kwf_Component_Generator_Recursive_Root', 'static');
     $this->assertEquals(1, count($generator->getChildData(null, array('componentClass' => 'Kwf_Component_Generator_Recursive_Static'))));
     $this->assertNotNull($this->_root->getComponentByClass('Kwf_Component_Generator_Recursive_Static'));
 }
 protected function _getConfig()
 {
     $detail = Kwc_Abstract::getChildComponentClass($this->_class, 'child');
     $gen = Kwf_Component_Generator_Abstract::getInstance($this->_class, 'child');
     $edit = Kwf_Component_Abstract_ExtConfig_Abstract::getEditConfigs($detail, $gen);
     $config = $this->_getStandardConfig('kwc.list.listEditButton', 'ListEditButton');
     $config['componentConfigs'] = $edit['componentConfigs'];
     $config['contentEditComponents'] = $edit['contentEditComponents'];
     $config['needsComponentPanel'] = true;
     return array('list' => $config);
 }
Ejemplo n.º 13
0
 public function testInheritedGenerators()
 {
     $page = $this->_root->getComponentById('1');
     $this->assertNotNull($page);
     $gen = Kwf_Component_Generator_Abstract::getInstances($page);
     $this->assertEquals(count($gen), 2);
     $page = $this->_root->getChildComponent('_static');
     $this->assertNotNull($page);
     $gen = Kwf_Component_Generator_Abstract::getInstances($page);
     $this->assertEquals(count($gen), 1);
     //aus performancegründen hier nur einer, page generator wird durch spezial-code in Generator::getInstances nicht zurückgegeben
 }
Ejemplo n.º 14
0
 protected function _getConfig()
 {
     $detail = Kwc_Abstract::getChildComponentClass($this->_class, 'child');
     $gen = Kwf_Component_Generator_Abstract::getInstance($this->_class, 'child');
     $edit = Kwf_Component_Abstract_ExtConfig_Abstract::getEditConfigs($detail, $gen);
     $config = $this->_getStandardConfig('kwc.list.list');
     $config['componentConfigs'] = $edit['componentConfigs'];
     $config['contentEditComponents'] = $edit['contentEditComponents'];
     $config['useInsertAdd'] = true;
     $config['listTitle'] = null;
     $config['editForms'] = array();
     return array('list' => $config);
 }
Ejemplo n.º 15
0
 public function testPlugin()
 {
     $components = $this->_root->getChildComponents(array('componentClasses' => array('Kwf_Component_Generator_Plugin_Static')));
     $this->assertEquals(1, count($components));
     $components = $this->_root->getRecursiveChildComponents(array('componentClasses' => array('Kwf_Component_Generator_Plugin_Static')));
     $this->assertEquals(1, count($components));
     $generators = Kwf_Component_Generator_Abstract::getInstances('Kwf_Component_Generator_Plugin_Static', array('componentClasses' => array('Kwf_Component_Plugin_Password_LoginForm_Component')));
     $this->assertEquals(1, count($generators));
     $components = $this->_root->getRecursiveChildComponents(array('componentClasses' => array('Kwf_Component_Plugin_Password_LoginForm_Component')));
     $this->assertEquals(1, count($components));
     $components = $this->_root->getRecursiveChildComponents(array('page' => false, 'flags' => array('processInput' => true)));
     $this->assertEquals(1, count($components));
 }
Ejemplo n.º 16
0
 /**
  * Recursively duplicate components
  *
  * You need to call afterDuplicate afterwards!
  */
 public static function duplicate(Kwf_Component_Data $source, Kwf_Component_Data $parentTarget, Zend_ProgressBar $progressBar = null)
 {
     $new = $source->generator->duplicateChild($source, $parentTarget, $progressBar);
     if (!$new) {
         throw new Kwf_Exception("Failed duplicating '{$source->componentId}'");
     }
     Kwf_Component_Generator_Abstract::clearInstances();
     Kwf_Component_Data_Root::reset();
     //TODO: schöner wär ein flag bei den komponenten ob es diese fkt im admin
     //gibt und dann für alle admins aufrufen
     //ändern sobald es für mehrere benötigt wird
     Kwc_Root_TrlRoot_Chained_Admin::duplicated($source, $new);
     return $new;
 }
Ejemplo n.º 17
0
 private static function _getAllPossiblePageComponentClasses()
 {
     $ret = array();
     foreach (Kwc_Abstract::getComponentClasses() as $class) {
         foreach (Kwf_Component_Generator_Abstract::getInstances($class, array('pseudoPage' => true)) as $g) {
             foreach ($g->getChildComponentClasses() as $c) {
                 if (!in_array($c, $ret)) {
                     $ret[] = $c;
                 }
             }
         }
     }
     return $ret;
 }
Ejemplo n.º 18
0
 private static function _validateHasNotChildWithStaticHome($cls, array &$validated = array())
 {
     if (isset($validated[$cls])) {
         return;
     }
     $validated[$cls] = true;
     foreach (Kwf_Component_Generator_Abstract::getOwnInstances($cls) as $g) {
         if ($g instanceof Kwf_Component_Generator_Page_StaticHome) {
             throw new Kwf_Exception("'{$cls}' must not have StaticHome, either remove StaticHome, remove category generator or disable hasHome for Category/Generator");
         }
     }
     foreach (Kwc_Abstract::getChildComponentClasses($cls) as $c) {
         self::_validateHasNotChildWithStaticHome($c, $validated);
     }
 }
Ejemplo n.º 19
0
 public function testStatic()
 {
     $c = $this->_root->getComponentById('root-child');
     $this->assertNotNull($c);
     $this->assertEquals('root-child', $c->componentId);
     $generators = Kwf_Component_Generator_Abstract::getInstances($this->_root->componentClass);
     $this->assertEquals(count($generators), 1);
     $generators = Kwf_Component_Generator_Abstract::getInstances($this->_root->componentClass, array('ignoreVisible' => false));
     $this->assertEquals(count($generators), 1);
     $generators = Kwf_Component_Generator_Abstract::getInstances($this->_root->componentClass, array('ignoreVisible' => true));
     $this->assertEquals(count($generators), 1);
     $c = $this->_root->getComponentById('root-child', array('ignoreVisible' => false));
     $this->assertNotNull($c);
     $c = $this->_root->getComponentById('root-child', array('ignoreVisible' => true));
     $this->assertNotNull($c);
 }
Ejemplo n.º 20
0
 protected function _initColumns()
 {
     $this->_columns->add(new Kwf_Grid_Column_Visible());
     $this->_columns->add(new Kwf_Grid_Column('component_class'))->setData(new Kwf_Data_Kwc_ComponentClass($this->_getParam('class')));
     $this->_columns->add(new Kwf_Grid_Column('component_name'))->setData(new Kwf_Data_Kwc_ComponentName($this->_getParam('class')));
     $this->_columns->add(new Kwf_Grid_Column('component_icon'))->setData(new Kwf_Data_Kwc_ComponentIcon($this->_getParam('class')));
     $this->_columns->add(new Kwf_Grid_Column('preview'))->setData(new Kwf_Data_Kwc_Frontend($this->_getParam('class')))->setRenderer('component');
     $this->_columns->add(new Kwf_Grid_Column('device_visible'))->setEditor(new Kwf_Form_Field_TextField());
     foreach (Kwf_Component_Data_Root::getInstance()->getPlugins('Kwf_Component_PluginRoot_Interface_GeneratorProperty') as $plugin) {
         $params = $plugin->getGeneratorProperty(Kwf_Component_Generator_Abstract::getInstance($this->_getParam('class'), 'paragraphs'));
         if ($params) {
             $editor = new Kwf_Form_Field_Select();
             $editor->setValues($params['values'])->setListWidth(200);
             $this->_columns->add(new Kwf_Grid_Column($params['name']))->setEditor($editor)->setData(new Kwf_Component_PluginRoot_GeneratorProperty_Data($plugin));
         }
     }
     $this->_columns->add(new Kwf_Grid_Column('edit_components'))->setData(new Kwf_Data_Kwc_EditComponents($this->_getParam('class')));
 }
Ejemplo n.º 21
0
 public function getListeners()
 {
     $ret = parent::getListeners();
     // master model
     $masterComponentClass = Kwc_Abstract::getSetting($this->_class, 'masterComponentClass');
     $ret[] = array('class' => $masterComponentClass, 'event' => 'Kwc_Directories_List_EventItemUpdated', 'callback' => 'onMasterChildRowUpdate');
     $ret[] = array('class' => $masterComponentClass, 'event' => 'Kwc_Directories_List_EventItemInserted', 'callback' => 'onMasterChildRowInsert');
     $ret[] = array('class' => $masterComponentClass, 'event' => 'Kwc_Directories_List_EventItemDeleted', 'callback' => 'onMasterChildRowDelete');
     $ret[] = array('class' => $masterComponentClass, 'event' => 'Kwc_Directories_List_EventItemsUpdated', 'callback' => 'onMasterChildModelUpdated');
     // trl model (optional)
     $generator = Kwf_Component_Generator_Abstract::getInstance($this->_class, 'detail');
     if ($generator->getModel()) {
         $ret[] = array('class' => get_class($generator->getModel()), 'event' => 'Kwf_Events_Event_Row_Updated', 'callback' => 'onChildRowUpdate');
         $ret[] = array('class' => get_class($generator->getModel()), 'event' => 'Kwf_Events_Event_Row_Inserted', 'callback' => 'onChildRowInsert');
         $ret[] = array('class' => get_class($generator->getModel()), 'event' => 'Kwf_Events_Event_Row_Deleted', 'callback' => 'onChildRowDelete');
         $ret[] = array('class' => get_class($generator->getModel()), 'event' => 'Kwf_Events_Event_Model_Updated', 'callback' => 'onChildModelUpdated');
     }
     return $ret;
 }
Ejemplo n.º 22
0
 protected function _getMultiFields()
 {
     $multifields = new Kwf_Form_Field_MultiFields('Children');
     $multifields->setMinEntries(0);
     $multifields->setPosition(true);
     if (Kwc_Abstract::getSetting($this->getClass(), 'hasVisible')) {
         $multifields->fields->add(new Kwf_Form_Field_Checkbox('visible', trlKwf('Visible')));
     }
     foreach (Kwf_Component_Data_Root::getInstance()->getPlugins('Kwf_Component_PluginRoot_Interface_GeneratorProperty') as $plugin) {
         $params = $plugin->getGeneratorProperty(Kwf_Component_Generator_Abstract::getInstance($this->getClass(), 'child'));
         if ($params) {
             $multifields->fields->add(new Kwf_Form_Field_Select($params['name'], $params['label']))->setValues($params['values'])->setDefaultValue($params['defaultValue'])->setData(new Kwf_Component_PluginRoot_GeneratorProperty_Data($plugin, $this));
         }
     }
     $form = Kwc_Abstract_Form::createChildComponentForm($this->getClass(), 'child');
     $form->setIdTemplate('{component_id}-{id}');
     $multifields->fields->add($form);
     return $multifields;
 }
Ejemplo n.º 23
0
 protected function _initColumns()
 {
     parent::_initColumns();
     $this->_columns->add(new Kwf_Grid_Column_Visible());
     if ($this->_showChildComponentGridColumns) {
         $c = Kwc_Abstract::getChildComponentClass($this->_getParam('class'), 'child');
         foreach (Kwc_Admin::getInstance($c)->gridColumns() as $i) {
             $this->_columns->add($i);
         }
     }
     foreach (Kwf_Component_Data_Root::getInstance()->getPlugins('Kwf_Component_PluginRoot_Interface_GeneratorProperty') as $plugin) {
         $params = $plugin->getGeneratorProperty(Kwf_Component_Generator_Abstract::getInstance($this->_getParam('class'), 'child'));
         if ($params) {
             $editor = new Kwf_Form_Field_Select();
             $editor->setValues($params['values'])->setListWidth(200);
             $this->_columns->add(new Kwf_Grid_Column($params['name'], $params['label']))->setEditor($editor)->setShowDataIndex($params['name'] . '_text')->setData(new Kwf_Component_PluginRoot_GeneratorProperty_Data($plugin));
             $this->_columns->add(new Kwf_Grid_Column($params['name'] . '_text'))->setData(new Kwf_Component_PluginRoot_GeneratorProperty_DataText($plugin));
         }
     }
 }
Ejemplo n.º 24
0
 public function onRowUpdate(Kwf_Events_Event_Row_Updated $event)
 {
     foreach ($this->_getComponentsByRow($event->row) as $c) {
         if ($c->componentClass == $this->_class) {
             $generator = Kwf_Component_Generator_Abstract::getInstance($this->_class, 'child');
             $child = $c->getChildComponent(array('id' => $generator->getIdSeparator() . $event->row->{$generator->getIdColumn()}, 'ignoreVisible' => true));
             $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($this->_class, $c));
             if (Kwc_Abstract::getSetting($this->_class, 'hasVisible') && $event->isDirty('visible')) {
                 $this->fireEvent(new Kwf_Component_Event_Component_HasContentChanged($this->_class, $c));
                 if ($event->row->visible) {
                     $this->fireEvent(new Kwc_Abstract_List_EventItemInserted($this->_class, $child));
                 } else {
                     $this->fireEvent(new Kwc_Abstract_List_EventItemDeleted($this->_class, $child));
                 }
             } else {
                 $this->fireEvent(new Kwc_Abstract_List_EventItemUpdated($this->_class, $child));
             }
         }
     }
 }
Ejemplo n.º 25
0
 private static function _getSubscribersFromComponent($componentClass)
 {
     $subscribers = array();
     $eventsClass = Kwc_Admin::getComponentClass($componentClass, 'Events');
     $subscribers[] = Kwf_Component_Abstract_Events::getInstance($eventsClass, array('componentClass' => $componentClass));
     foreach (Kwc_Abstract::getSetting($componentClass, 'generators') as $generatorKey => $null) {
         $generator = current(Kwf_Component_Generator_Abstract::getInstances($componentClass, array('generator' => $generatorKey)));
         $eventsClass = $generator->getEventsClass();
         if ($eventsClass) {
             $subscribers[] = Kwf_Component_Generator_Events::getInstance($eventsClass, array('componentClass' => $componentClass, 'generatorKey' => $generatorKey));
         }
     }
     if (Kwc_Abstract::hasSetting($componentClass, 'menuConfig')) {
         $mc = Kwf_Component_Abstract_MenuConfig_Abstract::getInstance($componentClass);
         $eventsClass = $mc->getEventsClass();
         if ($eventsClass) {
             $subscribers[] = Kwf_Component_Abstract_MenuConfig_Events::getInstance($eventsClass, array('componentClass' => $componentClass));
         }
     }
     return $subscribers;
 }
Ejemplo n.º 26
0
 public function getListeners()
 {
     $ret = parent::getListeners();
     foreach (Kwc_Abstract::getComponentClasses() as $componentClass) {
         $generators = Kwf_Component_Generator_Abstract::getInstances($componentClass, array('box' => true));
         foreach ($generators as $g) {
             foreach ($g->getChildComponentClasses() as $c) {
                 //TODO: only listen to boxes that use if (hasContent(..)) in master template
                 //      (once this is implemented (Recursive)MasterContentChanged must be fired on (Recursive)ContentWidthChanged)
                 if ($g->hasSetting('unique') && $g->getSetting('unique')) {
                     $ret[] = array('class' => $c, 'event' => 'Kwf_Component_Event_Component_HasContentChanged', 'callback' => 'onUniqueBoxHasContentChanged');
                 } else {
                     $ret[] = array('class' => $c, 'event' => 'Kwf_Component_Event_Component_HasContentChanged', 'callback' => 'onBoxHasContentChanged');
                 }
                 $ret[] = array('class' => $c, 'event' => 'Kwf_Component_Event_Component_RecursiveHasContentChanged', 'callback' => 'onBoxRecursiveHasContentChanged');
             }
         }
     }
     $ret[] = array('event' => 'Kwf_Component_Event_Component_RecursiveAdded', 'callback' => 'onRecursiveAdded');
     return $ret;
 }
Ejemplo n.º 27
0
 public static function useAlternativeComponent($componentClass, $parentData, $generator)
 {
     $c = $parentData;
     while (!$c->inherits) {
         $c = $c->parent;
     }
     $c = $c->parent;
     if (!$c) {
         return false;
     }
     while (!$c->inherits) {
         $c = $c->parent;
     }
     $instances = Kwf_Component_Generator_Abstract::getInstances($c, array('inherit' => true));
     if (in_array($generator, $instances, true)) {
         //wir wurden geerbt weils über uns ein parentData mit dem gleichen generator gibt
         return 'inherit';
     } else {
         return false;
     }
 }
Ejemplo n.º 28
0
 protected function _createChildComponentForm($id, $name = null)
 {
     if (substr($id, 0, 1) != '-' && substr($id, 0, 1) != '_') {
         throw new Kwf_Exception("'-' or '_' is missing in id");
     }
     if (!$name) {
         $name = substr($id, 1);
     }
     $idTemplate = '{0}' . $id;
     $childComponentClass = null;
     $detailClass = $this->getClass();
     foreach (Kwc_Abstract::getSetting($detailClass, 'generators') as $generatorKey => $generatorData) {
         $generator = Kwf_Component_Generator_Abstract::getInstance($detailClass, $generatorKey);
         if ($generator->getIdSeparator() != substr($id, 0, 1)) {
             continue;
         }
         $childComponentClass = $generator->getComponentByKey(substr($id, 1));
         if ($childComponentClass) {
             break;
         }
     }
     if (!$childComponentClass) {
         throw new Kwf_Exception("No child component with id '{$id}' for '{$detailClass}' found.");
     }
     $form = Kwc_Abstract_Form::createComponentForm($childComponentClass, $name);
     if (!$form) {
         return null;
     }
     $detailGen = Kwf_Component_Generator_Abstract::getInstance($this->getDirectoryClass(), 'detail');
     if ($detailGen->hasSetting('dbIdShortcut')) {
         $dbIdShortcut = $detailGen->getSetting('dbIdShortcut');
         $form->setIdTemplate($dbIdShortcut . $idTemplate);
     } else {
         if (!$detailGen->getModel()->hasColumn('component_id')) {
             throw new Kwf_Exception("Model '" . get_class($detailGen->getModel()) . "' doesn't have component_id column");
         }
         $form->setIdTemplate('{component_id}' . $detailGen->getIdSeparator() . $idTemplate);
     }
     return $form;
 }
 public function _initFields()
 {
     $class = $this->_getParam('class');
     $this->_form->setModel(Kwc_Abstract::createChildModel($class));
     $gen = Kwf_Component_Generator_Abstract::getInstance($this->_getParam('class'), 'detail');
     $detailClasses = Kwc_Abstract::getChildComponentClasses($class, 'detail');
     $forms = array();
     foreach ($detailClasses as $key => $detailClass) {
         $formClass = Kwc_Admin::getComponentClass($detailClass, 'Form');
         $form = new $formClass($key, $detailClass, $class);
         $form->setIdTemplate('{0}');
         $form->setCreateMissingRow(true);
         $form->setModel($this->_form->getModel());
         $forms[$key] = $form;
     }
     if (count($forms) == 1) {
         $this->_form->add(reset($forms));
     } else {
         $cards = $this->_form->add(new Kwf_Form_Container_Cards('component', trlKwf('Type')))->setComboBox(new Kwf_Form_Field_Hidden('component'));
         $cards->getCombobox()->setWidth(250)->setListWidth(250)->setAllowBlank(false)->setData(new Kwc_Directories_Item_Directory_Trl_FormController_ComponentData('component'));
         foreach ($forms as $key => $form) {
             $card = $cards->add();
             $card->add($form);
             $card->setTitle(Kwf_Trl::getInstance()->trlStaticExecute(Kwc_Abstract::getSetting($form->getClass(), 'componentName')));
             $card->setName($key);
             $card->setNamePrefix($key);
         }
         $cards->getCombobox()->getData()->cards = $cards->fields;
     }
     $classes = Kwc_Abstract::getChildComponentClasses($class);
     foreach ($classes as $class) {
         $formName = Kwc_Admin::getComponentClass($class, 'ItemEditForm');
         if ($formName) {
             $this->_form->add(new $formName('detail', $class, $this->_getParam('componentId')));
         }
     }
 }
 protected function _getConfig()
 {
     $gen = Kwf_Component_Generator_Abstract::getInstance($this->_class, 'detail');
     $generators = Kwc_Abstract::getSetting($this->_class, 'generators');
     $idTemplate = null;
     if (isset($generators['detail']['dbIdShortcut'])) {
         $idTemplate = $generators['detail']['dbIdShortcut'] . '{0}';
     }
     $componentPlugins = array();
     foreach ($this->_getAdmin()->getPluginAdmins() as $a) {
         $plugin = $a->getPluginExtConfig();
         if ($plugin) {
             $componentPlugins[] = $plugin;
         }
     }
     $config = $this->_getStandardConfig('kwc.directories.item.directory');
     $detailClasses = Kwc_Abstract::getChildComponentClasses($this->_class, 'detail');
     $componentConfigs = array();
     $contentEditComponents = array();
     foreach ($detailClasses as $type => $detailClass) {
         $edit = Kwf_Component_Abstract_ExtConfig_Abstract::getEditConfigs($detailClass, $gen, $idTemplate, '');
         $componentConfigs = array_merge($componentConfigs, $edit['componentConfigs']);
         foreach ($edit['contentEditComponents'] as $ec) {
             $ec['component'] = $type;
             $contentEditComponents[] = $ec;
         }
     }
     $config['componentConfigs'] = $componentConfigs;
     $config['contentEditComponents'] = $contentEditComponents;
     $config['componentPlugins'] = $componentPlugins;
     $config['needsComponentPanel'] = true;
     $config['countDetailClasses'] = count($detailClasses);
     $config['idSeparator'] = $gen->getIdSeparator();
     $config['multiFileUpload'] = Kwc_Abstract::getSetting($this->_class, 'multiFileUpload');
     return array('items' => $config);
 }