protected function _build($options) { echo "\nsettings...\n"; if (!file_exists('build/component')) { mkdir('build/component'); } Kwf_Component_Settings::resetSettingsCache(); foreach (glob('build/component/*') as $f) { unlink($f); } $fileName = 'build/component/settings'; try { $data = Kwf_Component_Settings::_getSettingsCached(); } catch (Kwf_Trl_BuildFileMissingException $e) { $originatingException = $e->getSettingsNonStaticTrlException(); if ($originatingException) { throw $originatingException; } throw $e; } foreach ($data as $cmp => $settings) { self::_checkSettings($cmp, $settings); } file_put_contents($fileName, serialize($data)); $componentClasses = Kwc_Abstract::getComponentClasses(); echo "masterLayouts...\n"; Kwf_Component_MasterLayout_Abstract::_buildAll($componentClasses); echo "layouts...\n"; Kwf_Component_Layout_Abstract::_buildAll($componentClasses); }
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); } }
public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer) { $ret = parent::getTemplateVars($renderer); foreach ($ret['listItems'] as $k => $v) { $ret['listItems'][$k]['width'] = Kwf_Component_Layout_Abstract::getInstance($this->getData()->chained->componentClass)->getChildContentWidth($v['data']) . 'px'; } return $ret; }
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"); } }
public function getMasterLayoutContexts() { return Kwf_Component_Layout_Abstract::getInstance($this->getData()->componentClass)->getContexts($this->getData()); }
protected function _getConfig() { $componentList = array(); $componentIcons = array(); $supportedMasterLayoutContexts = array(); $categories = Kwc_Abstract::getSetting($this->_class, 'categories'); foreach ($categories as $k => $i) { $categories[$k] = Kwf_Registry::get('trl')->trlStaticExecute($i); $componentList[$categories[$k] . '>>'] = array(); } $components = $this->_getComponents(); uasort($components, array('Kwc_Paragraphs_ExtConfig', '_sortByPriority')); foreach ($components as $component) { if (!Kwc_Abstract::hasSetting($component, 'componentName')) { continue; } $name = Kwc_Abstract::getSetting($component, 'componentName'); $name = Kwf_Registry::get('trl')->trlStaticExecute($name); $icon = Kwc_Abstract::getSetting($component, 'componentIcon'); if ($icon) { $icon = new Kwf_Asset($icon); $icon = $icon->__toString(); } if ($name) { $cat = null; if (Kwc_Abstract::hasSetting($component, 'componentCategory')) { $cat = Kwc_Abstract::getSetting($component, 'componentCategory'); if (isset($categories[$cat])) { $cat = $categories[$cat]; } } if (!$cat) { $cat = 'none'; } if (substr($name, 0, strlen($cat) + 1) != $cat . '.') { $name = $cat . '.' . $name; } $this->_componentNameToArray($name, $component, $componentList); $componentIcons[$component] = $icon; $supportedMasterLayoutContexts[$component] = Kwf_Component_Layout_Abstract::getInstance($component)->getSupportedContexts(); } } //move content and none to top level $componentList = array_merge($componentList['content>>'], $componentList['none>>'], $componentList); unset($componentList['content>>']); unset($componentList['none>>']); //remove empty categories foreach ($componentList as $k => $i) { if (!$i) { unset($componentList[$k]); } } $config = $this->_getStandardConfig('kwc.paragraphs'); $config['showDeviceVisible'] = Kwc_Abstract::getSetting($this->_class, 'useMobileBreakpoints'); $config['components'] = $componentList; $config['componentIcons'] = $componentIcons; $config['supportedMasterLayoutContexts'] = $supportedMasterLayoutContexts; $config['needsComponentPanel'] = true; $config['generatorProperties'] = array(); foreach (Kwf_Component_Data_Root::getInstance()->getPlugins('Kwf_Component_PluginRoot_Interface_GeneratorProperty') as $plugin) { $prop = $plugin->getGeneratorProperty(Kwf_Component_Generator_Abstract::getInstance($this->_class, 'paragraphs')); if ($prop) { $config['generatorProperties'][] = $prop; } } return array('paragraphs' => $config); }
public function getContexts(Kwf_Component_Data $data) { if ($data->isPage || isset($data->box)) { $componentWithMaster = Kwf_Component_View_Helper_Master::getComponentsWithMasterTemplate($data); $last = array_pop($componentWithMaster); if ($last && $last['type'] == 'master') { $p = $last['data']; } else { $p = Kwf_Component_Data_Root::getInstance(); // for tests } return Kwf_Component_MasterLayout_Abstract::getInstance($p->componentClass)->getContexts($data); } else { $parent = $data->parent; if (!$parent) { //when above first master, in domain or root, we have no contexts return null; } return Kwf_Component_Layout_Abstract::getInstance($parent->componentClass)->getChildContexts($parent, $data); } }