/** * getForm * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ private function getForm($intActionType = null) { $this->core->logger->debug('global->controllers->ElementController->getForm(' . $intActionType . ')'); try { $strFormId = $this->objRequest->getParam("formId"); $intTemplateId = $this->objRequest->getParam("templateId"); /** * if there is now formId, try to load form template */ if ($strFormId == '') { if ($intTemplateId != '') { /** * get files */ $this->getModelTemplates(); $objTemplateData = $this->objModelTemplates->loadTemplateById($intTemplateId); if (count($objTemplateData) == 1) { $objTemplate = $objTemplateData->current(); /** * set form id from template */ $strFormId = $objTemplate->genericFormId; } else { throw new Exception('Not able to create a form, because there is no form id!'); } } else { throw new Exception('Not able to create a form, because there is no form id!'); } } $intFormVersion = $this->objRequest->getParam("formVersion") != '' ? $this->objRequest->getParam("formVersion") : null; $intElementId = $this->objRequest->getParam("id") != '' ? $this->objRequest->getParam("id") : null; $objFormHandler = FormHandler::getInstance(); $objFormHandler->setFormId($strFormId); $objFormHandler->setTemplateId($intTemplateId); $objFormHandler->setFormVersion($intFormVersion); $objFormHandler->setActionType($intActionType); $objFormHandler->setLanguageId($this->getItemLanguageId($intActionType)); $objFormHandler->setFormLanguageId($this->core->intZooluLanguageId); $objFormHandler->setElementId($intElementId); $this->objForm = $objFormHandler->getGenericForm(); /** * set element default & specific form values */ $this->objForm->Setup()->setCreatorId($this->objRequest->getParam("creator") != '' ? $this->objRequest->getParam("creator") : Zend_Auth::getInstance()->getIdentity()->id); $this->objForm->Setup()->setStatusId($this->objRequest->getParam("idStatus") != '' ? $this->objRequest->getParam("idStatus") : $this->core->sysConfig->form->status->default); $this->objForm->Setup()->setRootLevelId($this->objRequest->getParam("rootLevelId") != '' ? $this->objRequest->getParam("rootLevelId") : null); $this->objForm->Setup()->setRootLevelGroupId($this->objRequest->getParam("rootLevelGroupId") != '' ? $this->objRequest->getParam("rootLevelGroupId") : 0); $this->objForm->Setup()->setParentId($this->objRequest->getParam("parentFolderId") != '' ? $this->objRequest->getParam("parentFolderId") : null); $this->objForm->Setup()->setIsStartElement($this->objRequest->getParam("isStartGlobal") != '' ? $this->objRequest->getParam("isStartGlobal") : 0); $this->objForm->Setup()->setPublishDate($this->objRequest->getParam("publishDate") != '' ? $this->objRequest->getParam("publishDate") : date('Y-m-d H:i:s')); $this->objForm->Setup()->setShowInNavigation($this->objRequest->getParam("showInNavigation") != '' ? $this->objRequest->getParam("showInNavigation") : 0); $this->objForm->Setup()->setLanguageFallbackId($this->objRequest->getParam("languageFallback") != '' ? $this->objRequest->getParam("languageFallback") : 0); $this->objForm->Setup()->setElementTypeId($this->objRequest->getParam("elementTypeId") != '' ? $this->objRequest->getParam("elementTypeId") : $this->core->sysConfig->global_types->product->id); $this->objForm->Setup()->setParentTypeId($this->objRequest->getParam("parentTypeId") != '' ? $this->objRequest->getParam("parentTypeId") : ($this->objRequest->getParam("parentFolderId") != '' ? $this->core->sysConfig->parent_types->folder : $this->core->sysConfig->parent_types->rootlevel)); $this->objForm->Setup()->setModelSubPath('global/models/'); $this->objForm->Setup()->setElementLinkId($this->objRequest->getParam("linkId", -1)); /** * add currlevel hidden field */ $this->objForm->addElement('hidden', 'currLevel', array('value' => $this->objRequest->getParam("currLevel"), 'decorators' => array('Hidden'), 'ignore' => true)); /** * add elementTye hidden field (folder, element, ...) */ $this->objForm->addElement('hidden', 'elementType', array('value' => $this->objRequest->getParam("elementType"), 'decorators' => array('Hidden'), 'ignore' => true)); } catch (Exception $exc) { $this->core->logger->err($exc); exit; } }
/** * addAction * @author Cornelius Hansjakob <*****@*****.**> * @version 1.0 */ public function addAction() { $this->core->logger->debug('core->controllers->FolderController->addAction()'); $this->getForm($this->core->sysConfig->generic->actions->add); $this->addFolderSpecificFormElements(); /** * set action */ $this->objForm->setAction('/zoolu/core/folder/add'); if ($this->objRequest->isPost() && $this->objRequest->isXmlHttpRequest()) { $arrFormData = $this->objRequest->getPost(); $this->objForm->Setup()->setFieldValues($arrFormData); /** * prepare form (add fields and region to the Zend_Form) */ $this->objForm->prepareForm(); if ($this->objForm->isValid($arrFormData)) { /** * set action */ $this->objForm->setAction('/zoolu/core/folder/edit'); $intFolderId = $this->objForm->saveFormData(); $this->objForm->Setup()->setElementId($intFolderId); $this->objForm->getElement('id')->setValue($intFolderId); $this->objForm->Setup()->setActionType($this->core->sysConfig->generic->actions->edit); $this->view->assign('blnShowFormAlert', true); /** * add defautl start page */ if (array_key_exists("rootLevelTypeId", $arrFormData) && $arrFormData["rootLevelTypeId"] == $this->core->sysConfig->root_level_types->portals) { $intTemplateId = $this->core->sysConfig->page_types->page->startpage_templateId; $this->getModelTemplates(); $objTemplateData = $this->objModelTemplates->loadTemplateById($intTemplateId); if (count($objTemplateData) == 1) { $objTemplate = $objTemplateData->current(); /** * set form id from template */ $strFormId = $objTemplate->genericFormId; $intFormVersion = $objTemplate->version; $intFormTypeId = $objTemplate->formTypeId; } else { throw new Exception('Not able to create a generic data object, because there is no form id!'); } $objGenericData = new GenericData(); $objGenericData->Setup()->setFormId($strFormId); $objGenericData->Setup()->setFormVersion($intFormVersion); $objGenericData->Setup()->setFormTypeId($intFormTypeId); $objGenericData->Setup()->setTemplateId($intTemplateId); $objGenericData->Setup()->setActionType($this->core->sysConfig->generic->actions->add); $objGenericData->Setup()->setLanguageId($this->objRequest->getParam("languageId", $this->core->sysConfig->languages->default->id)); $objGenericData->Setup()->setFormLanguageId(Zend_Auth::getInstance()->getIdentity()->languageId); $objGenericData->Setup()->setParentId($intFolderId); $objGenericData->Setup()->setRootLevelId($this->objForm->Setup()->getRootLevelId()); $objGenericData->Setup()->setElementTypeId($this->core->sysConfig->page_types->page->id); $objGenericData->Setup()->setCreatorId($this->objForm->Setup()->getCreatorId()); $objGenericData->Setup()->setStatusId($this->objForm->Setup()->getStatusId()); $objGenericData->Setup()->setShowInNavigation($this->objForm->Setup()->getShowInNavigation()); $objGenericData->Setup()->setModelSubPath('cms/models/'); $objGenericData->addStartPage($this->objForm->Setup()->getCoreField('title')->getValue()); $this->view->assign('selectNavigationItemNow', true); $this->view->assign('itemId', 'folder' . $intFolderId); } } else { $this->view->assign('blnShowFormAlert', false); } } else { /** * prepare form (add fields and region to the Zend_Form) */ $this->objForm->prepareForm(); } /** * get form title */ $this->view->formtitle = $this->objForm->Setup()->getFormTitle(); /** * output of metainformation to hidden div */ $this->setViewMetaInfos(); $this->view->form = $this->objForm; $this->renderScript('folder/form.phtml'); }