public function toArray(SxModule_Pageform_Field_Meta $item, $type = 'both') { $fields = array('pffm_id' => $item->getId(), 'pffm_field_id' => $item->getFieldId(), 'pffm_place' => $item->getPlace()); $tslFields = array('pffm_tsl_id' => $item->getTsl()->getId(), 'pffm_tsl_meta_id' => $item->getTsl()->getMetaId(), 'pffm_tsl_language' => $item->getTsl()->getLanguage(), 'pffm_tsl_name' => $item->getTsl()->getName(), 'pffm_tsl_value' => $item->getTsl()->getValue(), 'pffm_tsl_date_created' => $item->getTsl()->getDateCreated(), 'pffm_tsl_date_updated' => $item->getTsl()->getDateUpdated()); if ($type == 'item') { return $fields; } elseif ($type == 'tsl') { return $tslFields; } else { return array_merge($fields, $tslFields); } }
public function addAction() { SxCms_Acl::requireAcl('pageform', 'pageform.add'); $system = new Zend_Session_Namespace('System'); $pageproxy = new SxCms_Page_Proxy(); $pages = $pageproxy->getAll(); $pagesWithFormProxy = new SxCms_Page_Pageform_Proxy(); $pageWithForm = array(); foreach ($pagesWithFormProxy->getAll(false) as $pwf) { $pageWithForm[] = $pwf->getPageid(); } $this->view->pageWithForm = $pageWithForm; $pageform = new SxModule_Pageform(); $pageform->setTsl(new SxModule_Pageform_Tsl()); $tsl = $pageform->getTsl(); $field = new SxModule_Pageform_Field(); $field->setTsl(new SxModule_Pageform_Field_Tsl()); $meta = new SxModule_Pageform_Field_Meta(); $pageform->addField($field); if ($this->getRequest()->isPost()) { $fields = $this->preprocessFields(); $pageform = $this->mapFieldsToObjects($fields); $tsl = $pageform->getTsl(); $validator = new SxModule_Pageform_Validator(); if ($validator->validate($pageform)) { $pageform->save(); $tsl->setPageformId($pageform->getId())->setLanguage($system->lng)->save(); foreach ($pageform->getPages() as $page) { $pages = new SxCms_Page_Pageform(); $pages->setPageid($page)->setPageformid($pageform->getId())->save(); } $f = 0; foreach ($pageform->getField() as $field) { $f++; $field->setPageformId($pageform->getId())->setPlace($f)->save(); $field->getTsl()->setFieldId($field->getId())->setPlace($f)->setLanguage($system->lng)->save(); $fm = 0; foreach ($field->getMeta() as $meta) { $fm++; $meta->setFieldId($field->getId())->setPlace($fm)->save(); $meta->getTsl()->setMetaId($meta->getId())->setLanguage($system->lng)->save(); } } $cache = Zend_Registry::get('cache'); $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('SxModule_Pageform_getAll', 'SxModule_Pageform_Field', 'SxModule_Pageform_Field_Tsl', 'SxModule_Pageform_Field_Meta', 'SxModule_Pageform_Field_Meta_Tsl', 'SxModule_Pageform_Status')); $flashMessenger = $this->_helper->getHelper('FlashMessenger'); $flashMessenger->addMessage($this->admin_tmx->_('itemcreated')); $this->_helper->redirector->gotoSimple('index', 'pageform'); } } $this->view->activePageformStatus = array(); $this->view->tsl = $tsl; $this->view->item = $pageform; $this->view->pages = $pages; $this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Pageform'); }