protected function _getSelect() { //$ret = parent::_getSelect(); what do we lose by not using that? if ($this->_getParam('filterComponentId')) { $filter = Kwf_Component_Data_Root::getInstance()->getComponentById($this->_getParam('filterComponentId')); if (!is_instance_of($filter->componentClass, 'Kwc_Directories_List_Component')) { $filter = $filter->getChildComponent('-list'); //TODO don't hardcode that here } $viewData = $filter->getChildComponent('-view'); //TODO don't hardcode that here } else { $viewData = $this->_component; } $view = $viewData->getComponent(); if ($view->hasSearchForm()) { $sf = $view->getSearchForm(); $params = $this->getRequest()->getParams(); $params[$sf->componentId . '-post'] = true; //post $params[$sf->componentId] = true; //submit $sf->getComponent()->processInput($params); //TODO don't do processInput here in _getSelect() } $ret = $view->getSelect(); return $ret; }
public function load($row, $postData = array()) { $ret = parent::load($row, $postData); $component = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($row->component_id, array('ignoreVisible' => true, 'limit' => 1)); if ($component) { //component can be non-existent if it's in a not selected card if (is_instance_of($component->componentClass, 'Kwc_Abstract_Image_Component')) { $contentWidth = null; $usesContentWidth = false; foreach (Kwc_Abstract::getSetting($component->componentClass, 'dimensions') as $dim) { if (isset($dim['width'])) { if ($dim['width'] == Kwc_Abstract_Image_Component::CONTENT_WIDTH) { $usesContentWidth = true; } else { if ($dim['width'] > $contentWidth) { $contentWidth = $dim['width']; } } } } if ($usesContentWidth) { $contentWidth = $component->getComponent()->getMaxContentWidth(); } } else { $contentWidth = $component->getComponent()->getContentWidth(); } $ret[$this->getFieldName()]['contentWidth'] = $contentWidth; } return $ret; }
public function testIt() { $gen = Kwc_Abstract::getSetting('Kwf_Component_ChildSettings_SingleStatic_Root', 'generators'); $c = $gen['empty']['component']; $this->assertTrue(is_instance_of($c, 'Kwc_Basic_None_Component')); $this->assertEquals(Kwc_Abstract::getSetting($c, 'componentName'), 'test123'); }
public function __construct($reference = null, $fieldname = null) { if (is_object($reference)) { $model = $reference; } else { if (class_exists($reference) && is_instance_of($reference, 'Zend_Db_Table_Abstract')) { $model = new $reference(); } else { $this->setReferenceName($reference); } } if (!$fieldname) { $fieldname = is_object($reference) ? get_class($reference) : $reference; } parent::__construct($fieldname); if (isset($model)) { if (!$model instanceof Kwf_Model_Interface) { $model = new Kwf_Model_Db(array('table' => $model)); } $this->setModel($model); } $this->fields = new Kwf_Collection_FormFields(); $this->setBorder(false); $this->setBaseCls('x2-plain'); $this->setXtype('multifields'); $this->setMinEntries(1); }
public static function getAllMaintenanceJobs() { static $ret; if (isset($ret)) { return $ret; } foreach (Kwc_Abstract::getComponentClasses() as $c) { if (is_instance_of($c, 'Kwf_Util_Maintenance_JobProviderInterface')) { $providerClasses[] = $c; } } foreach (Kwf_Model_Abstract::findAllInstances() as $model) { if ($model instanceof Kwf_Util_Maintenance_JobProviderInterface) { $providerClasses[] = get_class($model); } } $jobClasses = array(); foreach ($providerClasses as $c) { $jobClasses = array_merge($jobClasses, call_user_func(array($c, 'getMaintenanceJobs'))); } $jobClasses = array_unique($jobClasses); $ret = array(); foreach ($jobClasses as $i) { $ret[] = new $i(); } usort($ret, array('Kwf_Util_Maintenance_Dispatcher', '_compareJobsPriority')); return $ret; }
protected function _initFields() { parent::_initFields(); $showDirectoryClass = Kwc_Abstract::getSetting($this->getClass(), 'showDirectoryClass'); $hideDirectoryClasses = Kwc_Abstract::getSetting($this->getClass(), 'hideDirectoryClasses'); $cards = $this->add(new Kwf_Form_Container_Cards('source_component_id', trlKwf('Directory'))); $defaultCard = null; $categories = Kwf_Component_Data_Root::getInstance()->getComponentsByClass('Kwc_Directories_Category_Directory_Component'); foreach ($categories as $category) { $itemDirectory = $category->parent; if (is_instance_of($itemDirectory->componentClass, $showDirectoryClass)) { foreach ($hideDirectoryClasses as $c) { if (is_instance_of($itemDirectory->componentClass, $c)) { continue 2; } } $categoriesModel = $category->getComponent()->getChildModel(); $select = $categoriesModel->select()->whereEquals('component_id', $category->componentId); $values = array(); foreach ($categoriesModel->getRows($select) as $row) { $values[$row->id] = $row->name; } $card = $cards->add(); $card->setTitle($category->parent->getTitle()); $card->setName($category->componentId); if (!$defaultCard) { $defaultCard = $category->componentId; } $model = Kwf_Model_Abstract::getInstance('Kwc_Directories_Category_ShowCategories_Model'); $card->add(new Kwf_Form_Field_MultiCheckboxLegacy($model, trlKwf('Categories')))->setValues($values)->setReferences(array('columns' => array('component_id'), 'refColumns' => array('id')))->setColumnName('category_id'); } } $cards->setDefaultValue($defaultCard); }
private function _getParent() { $previous = null; $parent = $this->_data->parent; while ($parent && (!$parent->isPage || is_instance_of(Kwc_Abstract::getSetting($parent->componentClass, 'contentSender'), 'Kwf_Component_Abstract_ContentSender_Lightbox'))) { $previous = $parent; $parent = $parent->parent; } if ($parent instanceof Kwc_Basic_LinkTag_FirstChildPage_Data) { $parent = $parent->_getFirstChildPage(); if ($parent == $this->_data) { $parent = $parent->parent; while ($parent && $parent instanceof Kwc_Basic_LinkTag_FirstChildPage_Data) { $parent = $parent->parent; } } } if (!$parent) { $parent = $this->_data->getSubroot()->getChildPage(array('home' => true), array()); } //TODO: the proper solution would be to restructure List_Switch so that the page is our parent if (is_instance_of($parent->componentClass, 'Kwc_List_Switch_Component') && $previous) { $parent = $parent->getChildComponent('_' . $previous->id); } return $parent; }
public function onListItemChange(Kwf_Component_Event_Component_Abstract $event) { // get previous and next items and delete the cache for them $c = $event->component; if ($c->componentClass != $this->_class) { foreach ($c->getRecursiveChildComponents(array('componentClass' => $this->_class)) as $c) { $i = $c->parent->parent; if (is_instance_of($i->componentClass, 'Kwc_Basic_LinkTag_Component')) { $i = $i->parent; } $getChildren = array(); while ($i != $event->component) { if ($i->generator->getGeneratorFlag('table')) { //only relevant if child is *not* created by a table generator continue 2; } $getChildren[] = $i->generator->getIdSeparator() . $i->id; $i = $i->parent; } $result = call_user_func(array($this->_class, 'getPreviousAndNextImagePage'), $this->_class, $event->component, $getChildren, true); foreach ($result as $r) { if (!$r) { continue; } $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($this->_class, $r)); } } } }
public function alterBackendOrderForm(Kwc_Shop_AddToCartAbstract_FrontendForm $form) { $component = null; foreach (Kwc_Abstract::getComponentClasses() as $c) { if (is_instance_of($c, 'Kwc_Shop_Products_Directory_Component')) { $detailClasses = Kwc_Abstract::getChildComponentClasses($c, 'detail'); foreach ($detailClasses as $key => $class) { if (Kwc_Abstract::getChildComponentClass($class, 'addToCart') == $this->_class) { $component = $key; } } } } $m = Kwf_Model_Abstract::getInstance('Kwc_Shop_Products'); $s = $m->select(); $s->whereEquals('visible', 1); if ($component) { $s->whereEquals('component', $component); } $s->order('pos'); $data = array(); foreach ($m->getRows($s) as $product) { $data[] = array($product->current_price_id, $product->__toString() . ' (' . $product->current_price . ' €)'); } $form->prepend(new Kwf_Form_Field_Select('shop_product_price_id', trlKwfStatic('Product')))->setValues($data)->setAllowBlank(false); }
/** * @param Kwf_Component_Data $component data, which is a parent domain component * @return Kwc_Root_DomainRoot_Domain_Component */ public static function getDomainComponent(Kwf_Component_Data $component) { while ($component && !is_instance_of($component->componentClass, 'Kwc_Root_DomainRoot_Domain_Component')) { $component = $component->parent; } return $component; }
public function load($row) { $name = $this->_dataIndex; if (is_string($this->_parentTable) || !is_array($this->_parentTable)) { $tables = array($this->_parentTable); } else { $tables = $this->_parentTable; } foreach ($tables as $t) { if ((is_object($t) || class_exists($t)) && is_instance_of($t, 'Zend_Db_Table_Abstract')) { $row = $row->findParentRow($t, $this->_ruleKey); } else { $row = $row->getParentRow($t); } if (!$row) { return ''; } } if (!$this->_dataIndex) { return $row->__toString(); } if (!isset($row->{$name}) && !is_null($row->{$name})) { //scheiß php throw new Kwf_Exception("Index '{$name}' doesn't exist in row."); } return $row->{$name}; }
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++; } }
private function _graphData($class, $parent = '') { if (is_instance_of($class, 'Kwc_Paragraphs_Component')) { return; } static $processed = array(); $ret = ''; $last = $class . $parent; foreach (Kwc_Abstract::getSetting($class, 'generators') as $generatorKey => $generator) { $g = $this->_getGenerator($class, $generatorKey); $shape = $this->_getShape($g); foreach ($this->_getChildren($generator) as $child) { $color = $this->_getColor($child); $fontcolor = in_array($child, $processed) ? 'grey40' : 'black'; $classname = $this->_getClassName($child, $class); $label = ''; if ($g->getGeneratorFlag('table')) { $label = 'headlabel = "*"'; } $name = $child . $class; $node = "Node_{$name}"; $ret .= "{ {$name} [label=\"{$classname}\" shape={$shape} color={$color} fontcolor=\"{$fontcolor}\" fontsize=12] } \n"; $ret .= "{ {$node} [shape=point] }\n"; $ret .= "{ {$node} -> {$name} [arrowhead=none {$label}] }\n"; $ret .= "{ {$last} -> {$node} [arrowhead=none] rank=same }\n"; $ret .= "\n"; $last = $node; if (!in_array($child, $processed)) { $processed[] = $child; $ret .= $this->_graphData($child, $class); } } } return $ret; }
public function onRecursiveUrlChanged(Kwf_Component_Event_Page_RecursiveUrlChanged $event) { $component = $event->component->parent; while ($component && is_instance_of($component->componentClass, 'Kwc_Basic_LinkTag_FirstChildPage_Component')) { $this->_fireUrlChanged($component); $component = $component->parent; } }
public function getLinkTitle() { $parent = $this->parent; if (is_instance_of($parent->componentClass, 'Kwc_Basic_LinkTag_Component')) { return $this->parent->getComponent()->getLinkTitle(); } return parent::getLinkTitle(); }
private function _getImageEnlargeComponent() { $d = $this->getData(); while (!is_instance_of($d->componentClass, 'Kwc_Basic_ImageEnlarge_Trl_Component')) { $d = $d->parent; } return $d->getComponent(); }
private function _getForm() { $ret = $this->getData(); while ($ret && !is_instance_of($ret->componentClass, 'Kwc_Form_Dynamic_Component')) { $ret = $ret->parent; } $ret = $ret->getChildComponent('-form'); return $ret; }
public function load($row, array $info = array()) { $c = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($row->component_id, array('ignoreVisible' => true)); if ($c && is_instance_of($c->componentClass, 'Kwc_Abstract_Cards_Trl_Component')) { return $c->chained->getComponent()->getRow()->component; } else { return ''; } }
public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer) { $ret = parent::getTemplateVars($renderer); $c = $this->getData()->parent->chained->componentClass; if (!is_instance_of($c, 'Kwc_Shop_Cart_Checkout_Payment_None_Component')) { $ret['paymentTypeText'] = $this->getData()->trlStaticExecute(Kwc_Abstract::getSetting($c, 'componentName')); } return $ret; }
public function getGeneratorFlags() { $ret = parent::getGeneratorFlags(); if (is_instance_of($this->_class, 'Kwc_Root_TrlRoot_Chained_Component')) { $ret['trlBase'] = true; } $ret['chainedType'] = 'Trl'; return $ret; }
private function _process($class, $type) { $ret = ''; $width = 300; $height = 30; if ($type == 'root' || $type == 'component' || $type == 'plugin') { $ret .= '<ellipse cx="' . ($this->_x + $width / 2) . '" cy="' . ($this->_y + $height / 2) . '" rx="' . $width / 2 . '" ry="' . $height / 2 . '" />'; } else { if ($type == 'page') { $ret .= '<rect x="' . $this->_x . '" y="' . $this->_y . '" width="' . $width . '" height="' . $height . '" />'; } else { if ($type == 'box') { $ret .= '<rect x="' . $this->_x . '" y="' . $this->_y . '" width="' . $width . '" height="' . $height . '" />'; $ret .= '<ellipse cx="' . ($this->_x + $width / 2) . '" cy="' . ($this->_y + $height / 2) . '" rx="' . $width / 2 . '" ry="' . $height / 2 . '" />'; } } } $ret .= '<text x="' . ($this->_x + 10) . '" y="' . ($this->_y + 20) . '">' . $class . '</text>'; $this->_y += 40; $classes = array(); foreach (Kwc_Abstract::getSetting($class, 'generators') as $generator) { if (is_instance_of($generator['class'], 'Kwf_Component_Generator_Box_Interface')) { $type = 'box'; } else { if (is_instance_of($generator['class'], 'Kwf_Component_Generator_Page_Interface')) { $type = 'page'; } else { $type = 'component'; } } if (!is_array($generator['component'])) { $generator['component'] = array($generator['component']); } foreach ($generator['component'] as $c) { $classes[] = array('type' => $type, 'componentClass' => $c); } } $plugins = Kwc_Abstract::getSetting($class, 'plugins'); if (is_array($plugins)) { foreach ($plugins as $c) { $classes[] = array('type' => 'plugin', 'componentClass' => $c); } } $this->_x += 100; $this->_maxX = max($this->_maxX, $this->_x + $width); $this->_maxY = max($this->_maxY, $this->_y + $height); foreach ($classes as $i) { $class = $i['componentClass']; if ($class && !in_array($class, $this->_processed)) { $this->_processed[] = $class; $ret .= $this->_process($class, $i['type']); } } $this->_x -= 100; return $ret; }
public static function getSettings($masterComponentClass) { $ret = parent::getSettings($masterComponentClass); //child generator 1:1 übernehmen um die gleiche view zu haben (keine uebersetzte) $masterGen = Kwc_Abstract::getSetting($masterComponentClass, 'generators'); if (is_instance_of($masterGen['child']['component']['view'], 'Kwc_Directories_List_View_Component')) { $ret['generators']['child'] = $masterGen['child']; } return $ret; }
protected function _getItemDirectory() { $data = $this->getData(); while ($data = $data->parent) { if (is_instance_of($data->componentClass, 'Kwc_Directories_List_Component')) { return $data->getComponent()->getItemDirectory(); } } return null; }
public static function getItemDirectoryClasses($directoryClass) { $ret = array(); foreach (Kwc_Abstract::getComponentClasses() as $c) { if (is_instance_of($c, 'Kwc_Blog_Directory_Component')) { $ret[] = $c; } } return $ret; }
protected function _getParentContentData() { $category = Kwc_Abstract::getSetting($this->_getSetting('menuComponentClass'), 'level'); $categoryData = $this->getData()->parent->getChildComponent('-' . $category); $menu = $categoryData->getChildComponent('-' . $this->getData()->id); if (!is_instance_of($menu->componentClass, 'Kwc_Menu_Abstract_Component')) { throw new Kwf_Exception("got invalid menu component"); } return $menu; }
public function getListeners() { $ret = parent::getListeners(); foreach ($this->_getCreatingClasses($this->_class) as $c) { if (is_instance_of($c, 'Kwc_Basic_LinkTag_Trl_Component')) { $ret[] = array('class' => $c, 'event' => 'Kwf_Component_Event_Component_ContentChanged', 'callback' => 'onLinkTagContentChanged'); } } return $ret; }
protected function _initUserForm() { if (is_instance_of($this->getData()->parent->parent->componentClass, 'Kwc_User_Directory_Component')) { $detailClass = Kwc_Abstract::getChildComponentClass($this->getData()->parent->parent->componentClass, 'detail'); $forms = Kwc_Abstract::getSetting($this->getData()->parent->componentClass, 'forms'); $this->_form->addUserForms($detailClass, $forms); } else { $this->_form->add(new Kwc_User_Detail_General_Form('general', null)); } }
public function onRecursiveUrlChanged(Kwf_Component_Event_Page_RecursiveUrlChanged $event) { $component = $event->component->parent; while ($component && is_instance_of($component->componentClass, 'Kwc_Basic_LinkTag_FirstChildPage_Cc_Component')) { if ($component->componentClass == $this->_class) { $this->fireEvent(new Kwf_Component_Event_Page_UrlChanged($this->_class, $component)); } $component = $component->parent; } }
public function testIt() { $gen = Kwc_Abstract::getSetting('Kwf_Component_ChildSettings_Composite_Root', 'generators'); $c = $gen['child']['component']['child1']; $this->assertTrue(is_instance_of($c, 'Kwc_Basic_None_Component')); $this->assertEquals(Kwc_Abstract::getSetting($c, 'componentName'), 'child1name'); $c = $gen['child']['component']['child2']; $this->assertTrue(is_instance_of($c, 'Kwc_Basic_None_Component')); $this->assertEquals(Kwc_Abstract::getSetting($c, 'componentName'), 'child2name'); }
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; } foreach ($master->getRecursiveChildComponents(array('componentClass' => $this->_class)) as $c) { $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($this->_class, $c)); } }