protected function _initFields() { parent::_initFields(); $userEditForm = $this->fields->add(new $this->_userDataFormName('user')); $userEditForm->setIdTemplate('{0}'); $root = Kwf_Component_Data_Root::getInstance(); if ($root) { $userDirectory = $root->getComponentByClass('Kwc_User_Directory_Component'); } if ($root && isset($userDirectory) && $userDirectory) { $detailClass = Kwc_Abstract::getChildComponentClass($userDirectory->componentClass, 'detail'); $userEditForm->addUserForms($detailClass, array('general')); $userEditForm->fields['firstname']->setAllowBlank(true); $userEditForm->fields['lastname']->setAllowBlank(true); } else { $this->fields->add(new Kwc_User_Detail_General_Form('general', null))->setIdTemplate('{0}'); } $config = Zend_Registry::get('config'); $authedUser = Kwf_Registry::get('userModel')->getAuthedUser(); if (isset($authedUser->language) && $config->languages) { $data = array(); foreach ($config->languages as $key => $value) { $data[$key] = $value; } $this->fields->add(new Kwf_Form_Field_Select('language', trlKwf('Language')))->setValues($data); } }
protected function _delete() { $componentClass = $this->getTable()->getComponentClass(); $class = Kwc_Abstract::getChildComponentClass($componentClass, 'child'); $admin = Kwc_Admin::getInstance($class); $admin->delete($this->component_id . '-' . $this->id); }
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); }
protected function _delete() { $class = Kwc_Abstract::getChildComponentClass($this->getTable()->getComponentClass(), null, $this->component); $admin = Kwc_Admin::getInstance($class); if ($admin) { $admin->delete($this->component_id . '-child'); } }
protected function _initColumns() { $c = Kwc_Abstract::getChildComponentClass($this->_getParam('class'), 'child'); foreach (Kwc_Admin::getInstance($c)->gridColumns() as $i) { $this->_columns->add($i); } $this->_columns->add(new Kwf_Grid_Column_Visible()); }
public function getListeners() { $ret = parent::getListeners(); $childImage = Kwc_Abstract::getChildComponentClass($this->_class, 'image'); $ret[] = array('class' => $childImage, 'event' => 'Kwf_Component_Event_Component_HasContentChanged', 'callback' => 'onOwnImageHasContentChanged'); $ret[] = array('class' => Kwc_Abstract::getSetting($this->_class, 'masterComponentClass'), 'event' => 'Kwf_Events_Event_Media_Changed', 'callback' => 'onMasterMediaChanged'); return $ret; }
public static function getItemDirectoryClasses($directoryClass) { $ret = array(); $class = self::_getParentItemDirectoryClasses($directoryClass, 0); foreach ($class as $c) { $ret[] = Kwc_Abstract::getChildComponentClass($c, 'products'); } return $ret; }
protected function _beforeDelete() { parent::_beforeDelete(); // Dranhängende Komponente löschen $generators = Kwf_Component_Data_Root::getInstance()->getPageGenerators(); foreach ($generators as $generator) { $class = Kwc_Abstract::getChildComponentClass($generator->getClass(), null, $this->component); Kwc_Admin::getInstance($class)->delete($this->id); } }
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)); } }
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 _initFields() { $this->_form->setModel(Kwf_Model_Abstract::getInstance(Kwc_Abstract::getSetting(Kwf_Component_Data_Root::getInstance()->getComponentByDbId($this->_getParam('componentId'))->parent->componentClass, 'childModel'))->getReferencedModel('Order')); $this->_form->add(new Kwf_Form_Field_ComboBoxText('origin', trlKwf('Origin')))->setValues(array(trlKwf('Internet'), trlKwf('Phone'), trlKwf('Folder'), trlKwf('Fair')))->setShowNoSelection(true); $cc = Kwc_Abstract::getChildComponentClasses($this->_getParam('class'), 'payment'); $payments = array(); foreach ($cc as $k => $c) { $payments[$k] = Kwc_Abstract::getSetting($c, 'componentName'); } if (count($payments) > 1) { $this->_form->add(new Kwf_Form_Field_Select('payment', trlKwf('Payment')))->setValues($payments)->setAllowBlank(false); } $cols = $this->_form->add(new Kwf_Form_Container_Columns()); $col = $cols->add(); $col->add(new Kwf_Form_Field_ShowField('order_number', trlKwf('Order Nr'))); $col = $cols->add(); $col->add(new Kwf_Form_Field_ShowField('customer_number', trlKwf('Customer Nr'))); if (Kwc_Abstract::getSetting($this->_getParam('class'), 'generateInvoices')) { $this->_form->add(new Kwf_Form_Field_ShowField('invoice_number', trlKwf('Invoice Nr'))); $this->_form->add(new Kwf_Form_Field_DateField('invoice_date', trlKwf('Invoice Date'))); } $this->_form->add(new Kwf_Form_Field_DateField('payed', trlKwf('Payed'))); $this->_form->add(new Kwf_Form_Field_ShowField('shipped', trlKwf('Shipped')))->setTpl('{value:localizedDate}'); $this->_form->add(new Kwf_Form_Field_Checkbox('canceled', trlKwf('Canceled'))); $fs = $this->_form->add(new Kwf_Form_Container_FieldSet(trlKwf('Customer'))); $formComponent = Kwc_Abstract::getChildComponentClass($this->_getParam('class'), 'child', 'form'); $formClass = Kwc_Admin::getComponentClass($formComponent, 'FrontendForm'); $customerForm = new $formClass('form', $formComponent); $customerForm->setIdTemplate('{0}'); $customerForm->setModel($this->_form->getModel()); $fs->add($customerForm); unset($customerForm->fields['payment']); foreach ($customerForm->fields as $f) { if ($f->getHideFieldInBackend()) { $customerForm->fields->remove($f); } } $customerForm->fields['email']->setAllowBlank(true); $customerForm->setAllowEmptyCart(true); foreach (Kwc_Abstract::getComponentClasses() as $c) { $g = Kwc_Abstract::getSetting($c, 'generators'); if (isset($g['checkout']) && $g['checkout']['component'] == $this->_getParam('class')) { foreach (Kwc_Abstract::getSetting($c, 'plugins') as $p) { if (is_instance_of($p, 'Kwc_Shop_Cart_Plugins_Interface')) { $p = new $p(); $p->alterBackendOrderForm($this->_form); } } } } }
public function getListeners() { $ret = parent::getListeners(); foreach (Kwc_Abstract::getComponentClasses() as $class) { if (is_instance_of($class, 'Kwc_Basic_ImageEnlarge_Trl_Component') && $this->_canCreateUsIndirectly($class)) { $imageClass = Kwc_Abstract::getChildComponentClass($class, 'image'); $ret[] = array('class' => $imageClass, 'event' => 'Kwc_Abstract_Image_ImageChangedEvent', 'callback' => 'onImageChanged'); $ret[] = array('class' => $imageClass, 'event' => 'Kwf_Component_Event_ComponentClass_ContentChanged', 'callback' => 'onClassContentChanged'); $masterComponentClass = Kwc_Abstract::getSetting($class, 'masterComponentClass'); $ret[] = array('class' => $masterComponentClass, 'event' => 'Kwc_Abstract_Image_ImageChangedEvent', 'callback' => 'onMasterImageChanged'); $ret[] = array('class' => $masterComponentClass, 'event' => 'Kwf_Component_Event_ComponentClass_ContentChanged', 'callback' => 'onClassContentChanged'); $ret[] = array('class' => $class, 'event' => 'Kwf_Component_Event_Component_ContentChanged', 'callback' => 'onImageContentChanged'); $ret[] = array('class' => $class, 'event' => 'Kwf_Component_Event_ComponentClass_ContentChanged', 'callback' => 'onClassContentChanged'); } } return $ret; }
public function getListeners() { $ret = array(); foreach (Kwc_Abstract::getComponentClasses() as $class) { if (in_array('Kwc_Directories_List_Component', Kwc_Abstract::getParentClasses($class)) || in_array('Kwc_Directories_List_Trl_Component', Kwc_Abstract::getParentClasses($class))) { if (Kwc_Abstract::hasChildComponentClass($class, 'feed') && $this->_class == Kwc_Abstract::getChildComponentClass($class, 'feed')) { $directoryClasses = call_user_func(array(strpos($class, '.') ? substr($class, 0, strpos($class, '.')) : $class, 'getItemDirectoryClasses'), $class); foreach ($directoryClasses as $directoryClass) { $ret[] = array('class' => $directoryClass, 'event' => 'Kwc_Directories_List_EventItemInserted', 'callback' => 'onDirectoryUpdate'); $ret[] = array('class' => $directoryClass, 'event' => 'Kwc_Directories_List_EventItemDeleted', 'callback' => 'onDirectoryUpdate'); $ret[] = array('class' => $directoryClass, 'event' => 'Kwc_Directories_List_EventItemUpdated', 'callback' => 'onDirectoryUpdate'); $ret[] = array('class' => $directoryClass, 'event' => 'Kwc_Directories_List_EventItemsUpdated', 'callback' => 'onDirectoryUpdate'); } } } } return $ret; }
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)); } } }
private function _fireTagEvent($event, $directory, $itemId = null) { $cacheId = 'kwc-dirlistview-isdata-' . $this->_class; $dirIs = Kwf_Cache_SimpleStatic::fetch($cacheId); if ($dirIs === false) { $dirIs = array('data' => false, 'string' => false); foreach (Kwc_Abstract::getComponentClasses() as $class) { if (in_array('Kwc_Directories_List_Component', Kwc_Abstract::getParentClasses($class)) || in_array('Kwc_Directories_List_Trl_Component', Kwc_Abstract::getParentClasses($class))) { if (Kwc_Abstract::hasChildComponentClass($class, 'child', 'view') && $this->_class == Kwc_Abstract::getChildComponentClass($class, 'child', 'view')) { $isData = call_user_func(array(strpos($class, '.') ? substr($class, 0, strpos($class, '.')) : $class, 'getItemDirectoryIsData'), $class); if ($isData) { $dirIs['data'] = true; } else { $dirIs['string'] = true; } } } } Kwf_Cache_SimpleStatic::add($cacheId, $dirIs); } $event = "Kwf_Component_Event_ComponentClass_Tag_{$event}"; if ($itemId) { if ($dirIs['data']) { $this->fireEvent(new $event($this->_class, $directory->componentId, $itemId)); } if ($dirIs['string']) { $this->fireEvent(new $event($this->_class, $directory->componentClass, $itemId)); } } else { if ($dirIs['data']) { $this->fireEvent(new $event($this->_class, $directory->componentId)); } if ($dirIs['string']) { $this->fireEvent(new $event($this->_class, $directory->componentClass)); } } }
protected function startElement($parser, $element, $attributes) { $finalHTML = $this->_finalHTML; if ($element == 'SPAN') { if (isset($attributes['STYLE'])) { $style = $attributes['STYLE']; } else { $style = ''; } if (preg_match('# *font-weight *: *bold *; *#', $style, $matches)) { array_push($this->_stack, 'strong'); $this->_finalHTML .= '<strong>'; } elseif (preg_match('# *font-style *: *italic *; *#', $style, $matches)) { array_push($this->_stack, 'em'); $this->_finalHTML .= '<em>'; } elseif (preg_match('# *text-decoration *: *underline *; *#', $style, $matches)) { array_push($this->_stack, 'u'); $this->_finalHTML .= '<u>'; } elseif (preg_match('# *color *: *[0-9A-Za-z]* *#', $style, $matches) && $this->_enableColor) { array_push($this->_stack, 'span'); $this->_finalHTML .= '<span style="' . $style . '">'; } elseif (preg_match('# *background-color *: *[0-9A-Za-z]* *#', $style, $matches) && $this->_enableColor) { array_push($this->_stack, 'span'); $this->_finalHTML .= '<span style="' . $style . '">'; } else { $allowedClasses = array(); foreach ($this->_getMasterStyles() as $s) { if ($s['tagName'] == strtolower($element)) { $allowedClasses[] = $s['className']; } } if ($this->_enableCursorSpan && isset($attributes['CLASS']) && $attributes['CLASS'] == '_mce_type-bookmark') { array_push($this->_stack, 'span'); $this->_finalHTML .= '<span class="' . $attributes['CLASS'] . '"'; if (isset($attributes['STYLE'])) { $this->_finalHTML .= ' style="' . $attributes['STYLE'] . '"'; } if (isset($attributes['ID'])) { $this->_finalHTML .= ' id="' . $attributes['ID'] . '"'; } $this->_finalHTML .= '>'; } else { if ($this->_enableStyles && isset($attributes['CLASS']) && (preg_match('#^style[0-9]+$#', $attributes['CLASS']) || in_array($attributes['CLASS'], $allowedClasses))) { array_push($this->_stack, 'span'); $this->_finalHTML .= '<span class="' . $attributes['CLASS'] . '">'; } else { array_push($this->_stack, false); } } } } elseif ($element == 'BODY' || $element == 'O:P') { array_push($this->_stack, false); //do nothing } elseif ($element == 'SCRIPT') { array_push($this->_stack, false); $this->_deleteContent++; } else { if ($element == 'IMG') { $src = $attributes['SRC']; $id = preg_quote($this->_dbId); if (preg_match('#/media/([^/]+)/(' . $id . '-i[0-9]+)#', $src, $m)) { //"/media/$class/$id/$type/$checksum/$filename.$extension$random" $class = Kwc_Abstract::getChildComponentClass($this->_model->getComponentClass(), 'child', 'image'); $imageRow = Kwc_Abstract::createModel($class)->getRow($m[2]); if (isset($attributes['WIDTH']) && $imageRow) { $imageRow->width = $attributes['WIDTH']; } if (isset($attributes['HEIGHT']) && $imageRow) { $imageRow->height = $attributes['HEIGHT']; } if (isset($attributes['STYLE']) && $imageRow) { if (preg_match('#[^a-zA-Z\\-]*width: *([0-9]+)px#', $attributes['STYLE'], $m)) { $imageRow->width = $m[1]; } if (preg_match('#[^a-zA-Z\\-]*height: *([0-9]+)px#', $attributes['STYLE'], $m)) { $imageRow->height = $m[1]; } } if ($imageRow) { $imageRow->save(); $attributes['WIDTH'] = $imageRow->width; $attributes['HEIGHT'] = $imageRow->height; if (isset($attributes['STYLE'])) { unset($attributes['STYLE']); } } } } if ($this->_enableTagsWhitelist && !in_array(strtolower($element), array_keys($this->_tagsWhitelist))) { //ignore this tag array_push($this->_stack, false); } else { $this->_finalHTML .= '<' . strtolower($element); foreach ($attributes as $key => $value) { if (in_array(strtolower($key), $this->_tagsWhitelist[strtolower($element)])) { $allowedClasses = array(); foreach ($this->_getMasterStyles() as $s) { if ($s['tagName'] == strtolower($element)) { $allowedClasses[] = $s['className']; } } if ($key != 'CLASS' || (preg_match('#^style[0-9]+$#', $value) || in_array($value, $allowedClasses))) { $this->_finalHTML .= ' ' . strtolower($key) . '="' . $value . '"'; } } } if ($element == 'BR' || $element == 'IMG') { $this->_finalHTML .= ' /'; array_push($this->_stack, false); } else { array_push($this->_stack, strtolower($element)); } $this->_finalHTML .= '>'; } } if ($this->_deleteContent) { $this->_finalHTML = $finalHTML; } }
public function delete($componentId) { $detail = Kwc_Abstract::getChildComponentClass($this->_class, 'detail'); Kwc_Admin::getInstance($detail)->delete($componentId); }
protected function _getPluginParentComponents() { $detail = Kwc_Abstract::getChildComponentClass($this->_class, 'detail'); return array($detail, $this->_class); }
protected function _getAdditionalSumRows($total) { $ret = array(); $payments = Kwc_Abstract::getChildComponentClasses(Kwc_Abstract::getChildComponentClass($this->getModel()->getCartComponentClass(), 'checkout'), 'payment'); if (isset($payments[$this->payment])) { $rows = Kwc_Shop_Cart_Checkout_Payment_Abstract_OrderData::getInstance($payments[$this->payment])->getAdditionalSumRows($this); foreach ($rows as $r) { $total += $r['amount']; } $ret = array_merge($ret, $rows); } foreach ($this->getModel()->getShopCartPlugins() as $p) { $rows = $p->getAdditionalSumRows($this, $total); foreach ($rows as $r) { $total += $r['amount']; } $ret = array_merge($ret, $rows); } return $ret; }
public function getListeners() { $ret = array(); $ret[] = array('class' => Kwc_Abstract::getChildComponentClass($this->_class, 'child'), 'event' => 'Kwf_Component_Event_Component_HasContentChanged', 'callback' => 'onChildHasContentChange'); return $ret; }
public static function getItemDirectoryClasses($directoryClass) { $class = self::_getParentItemDirectoryClasses($directoryClass, 2); return array(Kwc_Abstract::getChildComponentClass($class, 'category')); }
protected function _getRecipientSources() { $mailClass = Kwc_Abstract::getChildComponentClass($this->_class, 'mail'); return Kwc_Abstract::getSetting($mailClass, 'recipientSources'); }
public static function getEditConfigs($componentClass, Kwf_Component_Generator_Abstract $gen, $idTemplate = null, $componentIdSuffix = '') { $ret = array('componentConfigs' => array(), 'contentEditComponents' => array()); if (is_null($idTemplate)) { if ($gen->hasSetting('dbIdShortcut')) { $idTemplate = $gen->getSetting('dbIdShortcut') . '{0}'; } else { $idTemplate = '{componentId}' . $gen->getIdSeparator() . '{0}'; } } $cfg = Kwc_Admin::getInstance($componentClass)->getExtConfig(); foreach ($cfg as $k => $c) { $suffix = $componentIdSuffix; if (isset($c['componentIdSuffix'])) { $suffix .= $c['componentIdSuffix']; unset($c['componentIdSuffix']); } $ret['componentConfigs'][$componentClass . '-' . $k] = $c; $ret['contentEditComponents'][] = array('componentClass' => $componentClass, 'type' => $k, 'idTemplate' => $idTemplate, 'idSeparator' => $gen->getIdSeparator(), 'componentIdSuffix' => $suffix, 'title' => $c['title'], 'icon' => $c['icon']); } foreach ($gen->getGeneratorPlugins() as $plugin) { $cls = get_class($plugin); $cfg = Kwc_Admin::getInstance($cls)->getExtConfig(); foreach ($cfg as $k => $c) { $suffix = $componentIdSuffix; if (isset($c['componentIdSuffix'])) { $suffix .= $c['componentIdSuffix']; unset($c['componentIdSuffix']); } $ret['componentConfigs'][$cls . '-' . $k] = $c; $ret['contentEditComponents'][] = array('componentClass' => $cls, 'type' => $k, 'idTemplate' => $idTemplate, 'componentIdSuffix' => $suffix); } } if (Kwc_Abstract::hasSetting($componentClass, 'editComponents')) { $editComponents = Kwc_Abstract::getSetting($componentClass, 'editComponents'); foreach ($editComponents as $c) { $childGen = Kwf_Component_Generator_Abstract::getInstances($componentClass, array('componentKey' => $c)); if (!$childGen) { throw new Kwf_Exception("editComponents '{$c}' doesn't exist in '{$componentClass}'"); } $childGen = $childGen[0]; $cls = Kwc_Abstract::getChildComponentClass($componentClass, null, $c); $edit = self::getEditConfigs($cls, $childGen, $idTemplate, $componentIdSuffix . $childGen->getIdSeparator() . $c); $ret['componentConfigs'] = array_merge($ret['componentConfigs'], $edit['componentConfigs']); $ret['contentEditComponents'] = array_merge($ret['contentEditComponents'], $edit['contentEditComponents']); } } return $ret; }