public function getCardForms() { $ret = array(); $title = Kwf_Trl::getInstance()->trlStaticExecute(Kwc_Abstract::getSetting($this->_class, 'componentName')); $title = str_replace('.', ' ', $title); $ret['form'] = array('form' => Kwc_Abstract_Form::createComponentForm($this->_class, 'child'), 'title' => $title); return $ret; }
public function getCardForms() { $ret = array(); $news = Kwf_Component_Data_Root::getInstance()->getComponentsByClass('Kwc_Events_Directory_Component'); foreach ($news as $new) { $form = Kwc_Abstract_Form::createComponentForm($this->_class, 'child'); $form->fields['event_id']->setBaseParams(array('eventsComponentId' => $new->dbId)); $form->fields['event_id']->setFieldLabel($new->getPage()->name); $ret[$new->dbId] = array('form' => $form, 'title' => $new->getTitle()); } return $ret; }
public function getCardForms() { $ret = array(); $blogs = Kwf_Component_Data_Root::getInstance()->getComponentsByClass('Kwc_Blog_Directory_Component', array('ignoreVisible' => true)); foreach ($blogs as $blog) { $form = Kwc_Abstract_Form::createComponentForm($this->_class, 'child'); $form->fields['blog_post_id']->setBaseParams(array('blogComponentId' => $blog->dbId)); $form->fields['blog_post_id']->setFieldLabel($blog->getPage()->name); $form->fields['blog_post_id']->setData(new Kwc_Basic_LinkTag_BlogPost_BlogPostIdData()); $ret[$blog->dbId] = array('form' => $form, 'title' => count($blogs) > 1 ? $blog->getTitle() : trlKwf('Blog')); } return $ret; }
public function preDispatch() { $t = microtime(true); if (!isset($this->_form)) { if (isset($this->_formName)) { $this->_form = new $this->_formName(null, $this->_getParam('class')); } else { $this->_form = Kwc_Abstract_Form::createComponentForm($this->_getParam('class'), 'component'); } } Kwf_Benchmark::subCheckpoint('create component form', microtime(true) - $t); $this->_form->setBodyStyle('padding: 10px'); $this->_form->setId($this->_getParam('componentId')); parent::preDispatch(); }
public function getCardForms() { $ret = array(); $news = Kwf_Component_Data_Root::getInstance()->getComponentsByClass('Kwc_News_Directory_Component', array('ignoreVisible' => true)); foreach ($news as $new) { if (is_instance_of($new->componentClass, 'Kwc_Events_Directory_Component')) { continue; } $form = Kwc_Abstract_Form::createComponentForm($this->_class, 'child'); $form->fields['news_id']->setBaseParams(array('newsComponentId' => $new->dbId)); $form->fields['news_id']->setFieldLabel($new->getPage()->name); $form->fields['news_id']->setData(new Kwc_Basic_LinkTag_News_NewsIdData()); $ret[$new->dbId] = array('form' => $form, 'title' => count($news) > 1 ? $new->getTitle() : trlKwf('News')); } return $ret; }
protected function _createChildComponentForm($id, $name = null) { if (substr($id, 0, 1) != '-' && substr($id, 0, 1) != '_') { throw new Kwf_Exception("'-' or '_' is missing in id"); } if (!$name) { $name = substr($id, 1); } $idTemplate = '{0}' . $id; $childComponentClass = null; $detailClass = $this->getClass(); foreach (Kwc_Abstract::getSetting($detailClass, 'generators') as $generatorKey => $generatorData) { $generator = Kwf_Component_Generator_Abstract::getInstance($detailClass, $generatorKey); if ($generator->getIdSeparator() != substr($id, 0, 1)) { continue; } $childComponentClass = $generator->getComponentByKey(substr($id, 1)); if ($childComponentClass) { break; } } if (!$childComponentClass) { throw new Kwf_Exception("No child component with id '{$id}' for '{$detailClass}' found."); } $form = Kwc_Abstract_Form::createComponentForm($childComponentClass, $name); if (!$form) { return null; } $detailGen = Kwf_Component_Generator_Abstract::getInstance($this->getDirectoryClass(), 'detail'); if ($detailGen->hasSetting('dbIdShortcut')) { $dbIdShortcut = $detailGen->getSetting('dbIdShortcut'); $form->setIdTemplate($dbIdShortcut . $idTemplate); } else { if (!$detailGen->getModel()->hasColumn('component_id')) { throw new Kwf_Exception("Model '" . get_class($detailGen->getModel()) . "' doesn't have component_id column"); } $form->setIdTemplate('{component_id}' . $detailGen->getIdSeparator() . $idTemplate); } return $form; }