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;
 }
Пример #2
0
 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()
 {
     $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);
 }
 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);
 }
 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;
 }
Пример #6
0
 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;
 }
Пример #7
0
 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");
     }
 }
 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);
 }
Пример #9
0
 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'));
         }
     }
 }
Пример #10
0
 public final function getExtConfig($type = Kwf_Component_Abstract_ExtConfig_Abstract::TYPE_DEFAULT)
 {
     return Kwf_Component_Abstract_ExtConfig_Abstract::getInstance($this->_class)->getConfig($type);
 }
Пример #11
0
 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");
     }
 }