protected function _initColumns() { parent::_initColumns(); $this->_columns->add(new Kwf_Grid_Column('id')); //shows editDialog $this->_columns->add(new Kwf_Grid_Column_Button('properties', ' ', 20))->setButtonIcon('/assets/silkicons/newspaper.png')->setTooltip(trlKwf('Properties')); if (is_instance_of(Kwc_Abstract::getSetting($this->_getParam('class'), 'extConfig'), 'Kwc_Directories_Item_Directory_ExtConfigEditButtons')) { $extConfigType = 'extConfig'; } else { if (is_instance_of(Kwc_Abstract::getSetting($this->_getParam('class'), 'extConfigControllerIndex'), 'Kwc_Directories_Item_Directory_ExtConfigEditButtons')) { $extConfigType = 'extConfigControllerIndex'; } } $extConfig = Kwf_Component_Abstract_ExtConfig_Abstract::getInstance($this->_getParam('class'), $extConfigType)->getConfig(Kwf_Component_Abstract_ExtConfig_Abstract::TYPE_DEFAULT); $extConfig = $extConfig['items']; if (count($extConfig['countDetailClasses']) > 1 && !$this->_getModel()->hasColumn('component')) { throw new Kwf_Exception('If you have more than one detail-component your table has to have a column named "component"'); } $i = 0; foreach ($extConfig['contentEditComponents'] as $ec) { $name = Kwf_Trl::getInstance()->trlStaticExecute(Kwc_Abstract::getSetting($ec['componentClass'], 'componentName')); $icon = Kwc_Abstract::getSetting($ec['componentClass'], 'componentIcon'); $icon = new Kwf_Asset($icon); $this->_columns->add(new Kwc_Directories_Item_Directory_Trl_ControllerEditButton('edit_' . $i, ' ', 20))->setColumnType('editContent')->setEditComponentClass($ec['componentClass'])->setEditComponent($ec['component'])->setEditType($ec['type'])->setEditIdTemplate($ec['idTemplate'])->setEditComponentIdSuffix($ec['componentIdSuffix'])->setButtonIcon($icon->toString(array('arrow')))->setTooltip(trlKwf('Edit {0}', $name)); $i++; } }
protected function _getConfig($childComponentKey = 'child') { $classes = Kwc_Abstract::getChildComponentClasses($this->_class, 'child'); $ret = array(); foreach ($classes as $id => $cls) { $c = Kwf_Component_Abstract_ExtConfig_Abstract::getInstance($cls)->getConfig(Kwf_Component_Abstract_ExtConfig_Abstract::TYPE_DEFAULT); foreach ($c as $k => $i) { if (!isset($i['componentIdSuffix'])) { $i['componentIdSuffix'] = ''; } $i['componentIdSuffix'] = '-' . $id . $i['componentIdSuffix']; $ret[$id . '-' . $k] = $i; } } return $ret; }
public function getTemplateVars() { $ret = parent::getTemplateVars(); $cfg = Kwf_Component_Abstract_ExtConfig_Abstract::getInstance($this->getData()->componentClass); $ret['config'] = array('controllerUrl' => $cfg->getControllerUrl('View'), 'viewUrl' => $this->getData()->url, 'componentId' => $this->getData()->componentId, 'searchFormComponentId' => $this->_getSearchForm() ? $this->_getSearchForm()->componentId : null, 'placeholder' => array('noEntriesFound' => $this->_getPlaceholder('noEntriesFound')), 'loadMoreBufferPx' => $this->_getSetting('loadMoreBufferPx'), 'loadDetailAjax' => $this->_getSetting('loadDetailAjax')); $itemDir = $this->getData()->parent->getComponent()->getItemDirectory(); if (is_string($itemDir)) { $ret['config']['directoryViewComponentId'] = false; $ret['config']['directoryComponentId'] = false; $ret['config']['directoryComponentClass'] = $itemDir; } else { $ret['config']['directoryViewComponentId'] = $itemDir->getChildComponent('-view')->componentId; $ret['config']['directoryComponentId'] = $itemDir->componentId; $ret['config']['directoryComponentClass'] = $itemDir->componentClass; } $paging = $this->getData()->getChildComponent('-paging'); if (isset($paging)) { $ret['config']['initialPageSize'] = Kwc_Abstract::getSetting($paging->componentClass, 'pagesize'); } return $ret; }
public function jsonAddParagraphAction() { $class = $this->_getParam('component'); if (array_search($class, $this->_components)) { $row = $this->_model->createRow(); $this->_preforeAddParagraph($row); $generators = Kwc_Abstract::getSetting($this->_getParam('class'), 'generators'); $classes = $generators['paragraphs']['component']; $row->component = array_search($class, $classes); if (is_null($row->visible)) { $row->visible = 0; } if (is_null($row->device_visible)) { $row->device_visible = 'all'; } $row->pos = $this->_getParam('pos'); $row->save(); $id = $row->id; $where['component_id = ?'] = $this->_getParam('componentId'); // Hack für weiterleiten auf Edit-Seite $name = Kwc_Abstract::getSetting($this->_getParam('class'), 'componentName'); $name = str_replace('.', ' -> ', $name); $this->view->id = $row->id; //wird des braucht? $this->view->componentClass = $classes[$row->component]; //wird des braucht? $this->view->componentName = $name; $this->view->componentConfigs = array(); $this->view->editComponents = array(); $extConfig = Kwf_Component_Abstract_ExtConfig_Abstract::getInstance($classes[$row->component]); $this->view->openConfigKey = $extConfig->getEditAfterCreateConfigKey(); $cfg = $extConfig->getConfig(Kwf_Component_Abstract_ExtConfig_Abstract::TYPE_DEFAULT); foreach ($cfg as $k => $i) { $this->view->componentConfigs[$classes[$row->component] . '-' . $k] = $i; $this->view->editComponents[] = array('componentClass' => $classes[$row->component], 'type' => $k); } } else { throw new Kwf_Exception("Component {$class} not found"); } }
public function indexAction() { //nicht: parent::indexAction(); if (Kwc_Abstract::hasSetting($this->_getParam('class'), 'extConfigControllerIndex')) { $type = 'extConfigControllerIndex'; } else { //für Abwärtskompatibilität $type = 'extConfig'; } $config = Kwf_Component_Abstract_ExtConfig_Abstract::getInstance($this->_getParam('class'), $type)->getConfig(Kwf_Component_Abstract_ExtConfig_Abstract::TYPE_DEFAULT); if (!$config) { throw new Kwf_Exception("Not ExtConfig avaliable for this component"); } reset($config); $firstConfig = current($config); if (count($config) > 1 || isset($firstConfig['needsComponentPanel']) && $firstConfig['needsComponentPanel']) { $this->view->xtype = 'kwf.component'; $this->view->mainComponentClass = $this->_getParam('class'); $this->view->baseParams = array('id' => $this->_getParam('componentId')); $this->view->componentConfigs = array(); $this->view->mainEditComponents = array(); foreach ($config as $k => $c) { $this->view->componentConfigs[$this->_getParam('class') . '-' . $k] = $c; $this->view->mainEditComponents[] = array('componentClass' => $this->_getParam('class'), 'type' => $k); } $this->view->mainType = $this->view->mainEditComponents[0]['type']; } else { if (isset($firstConfig['title'])) { unset($firstConfig['title']); } $this->view->assign($firstConfig); if ($this->_getParam('componentId')) { $this->view->baseParams = array('componentId' => $this->_getParam('componentId')); } } }
public final function getExtConfig($type = Kwf_Component_Abstract_ExtConfig_Abstract::TYPE_DEFAULT) { return Kwf_Component_Abstract_ExtConfig_Abstract::getInstance($this->_class)->getConfig($type); }
public function jsonAddParagraphAction() { $class = $this->_getParam('component'); if (array_search($class, $this->_components)) { $paragraphsData = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($this->_getParam('componentId'), array('ignoreVisible' => true, 'limit' => 1)); $supportedMasterLayoutContexts = Kwf_Component_Layout_Abstract::getInstance($class)->getSupportedContexts(); if ($supportedMasterLayoutContexts !== false) { $masterLayoutContexts = $paragraphsData->getComponent()->getMasterLayoutContexts(); foreach ($masterLayoutContexts as $ctx) { if (!in_array($ctx, $supportedMasterLayoutContexts)) { throw new Kwf_Exception("Supported Content Spans doesn't match"); //button is hidden in JS } } } $ev = new Kwf_Component_Event_Component_FilterAddComponentClass($class, $paragraphsData); Kwf_Events_Dispatcher::fireEvent($ev); if ($ev->deny) { throw new Kwf_Exception("Adding '{$class}' is denied for {$paragraphsData->componentId} by plugin"); } $row = $this->_model->createRow(); $this->_preforeAddParagraph($row); $generators = Kwc_Abstract::getSetting($this->_getParam('class'), 'generators'); $classes = $generators['paragraphs']['component']; $row->component = array_search($class, $classes); if (is_null($row->visible)) { $row->visible = 0; } if (is_null($row->device_visible)) { $row->device_visible = 'all'; } $row->pos = $this->_getParam('pos'); $row->save(); $id = $row->id; $where['component_id = ?'] = $this->_getParam('componentId'); // Hack für weiterleiten auf Edit-Seite $name = Kwc_Abstract::getSetting($this->_getParam('class'), 'componentName'); $name = str_replace('.', ' -> ', $name); $this->view->id = $row->id; //wird des braucht? $this->view->componentClass = $classes[$row->component]; //wird des braucht? $this->view->componentName = $name; $this->view->componentConfigs = array(); $this->view->editComponents = array(); $extConfig = Kwf_Component_Abstract_ExtConfig_Abstract::getInstance($classes[$row->component]); $this->view->openConfigKey = $extConfig->getEditAfterCreateConfigKey(); $cfg = $extConfig->getConfig(Kwf_Component_Abstract_ExtConfig_Abstract::TYPE_DEFAULT); foreach ($cfg as $k => $i) { $this->view->componentConfigs[$classes[$row->component] . '-' . $k] = $i; $this->view->editComponents[] = array('componentClass' => $classes[$row->component], 'type' => $k); } } else { throw new Kwf_Exception("Component {$class} not found"); } }