public function __construct($options = null) { parent::__construct($options); $moduleID = -1; $moduleName = ''; if (!empty($options['moduleID'])) { $moduleID = $options['moduleID']; $moduleName = Cible_FunctionsModules::getModuleNameByID($moduleID); } // input text for the title of the text module $categoryTitle = new Zend_Form_Element_Text('Title'); $categoryTitle->setLabel($this->getView()->getCibleText('form_category_title_label') . '*')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->_view->getCibleText('validation_message_empty_field'))))->setAttrib('class', 'stdTextInput'); $this->addElement($categoryTitle); $categoryDescription = new Zend_Form_Element_Text('WordingShowAllRecords'); $categoryDescription->setLabel($this->_view->getCibleText('form_category_view_all_label')); $this->addElement($categoryDescription); $views = Cible_FunctionsCategories::getCategoryViews($moduleID); foreach ($views as $view) { $pickerName = $view['MV_Name']; $controllerName = new Zend_Form_Element_Text("{$pickerName}_controllerName"); $controllerName->setLabel($this->getView()->getCibleText("form_select_option_view_{$moduleName}_{$pickerName}"))->setAttrib('onfocus', "openPagePicker('page-picker-{$pickerName}');"); $this->addElement($controllerName); $pagePicker = new Cible_Form_Element_PagePicker("{$pickerName}_pageID", array('associatedElement' => "{$pickerName}_controllerName", 'onclick' => "javascript:closePagePicker(\"page-picker-{$pickerName}\")")); $pagePicker->setLabel($this->_view->getCibleText('form_category_associated_page_label')); $pagePicker->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => "page-picker", 'id' => "page-picker-{$pickerName}")))); $this->addElement($pagePicker); } $module = new Zend_Form_Element_Hidden('ModuleID'); $module->setValue($moduleID)->removeDecorator('label')->removeDecorator('DtDdWrapper'); $this->addElement($module); }
public function editCategoriesAction() { if ($this->view->aclIsAllowed($this->view->current_module, 'edit')) { $id = $this->_getParam('ID'); $categoriesObject = new CategoriesObject(); $options = array('moduleID' => Cible_FunctionsModules::getModuleIDByName($this->view->current_module), 'cancelUrl' => "{$this->view->baseUrl()}/{$this->view->current_module}/index/list-categories/"); $form = new FormCategory($options); $this->view->assign('form', $form); if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { // save $categoriesObject->save($id, $formData, $this->_currentEditLanguage); $allViews = Cible_FunctionsCategories::getCategoryViews($this->_moduleID); $views = Cible_FunctionsCategories::getCategoryViews($this->_moduleID, $id); $reference_views = array(); foreach ($views as $view) { $reference_views[$view['MV_ID']] = $view; } $views = $reference_views; $this->view->dump($views); foreach ($allViews as $view) { $this->view->dump($view); $data = array('MCVP_ModuleID' => $this->_moduleID, 'MCVP_CategoryID' => $id, 'MCVP_ViewID' => $view['MV_ID'], 'MCVP_PageID' => $formData["{$view['MV_Name']}_pageID"]); if (!empty($formData["{$view['MV_Name']}_pageID"])) { if (isset($views[$view['MV_ID']]) && isset($views[$view['MV_ID']]['MCVP_ID'])) { $this->_db->update('ModuleCategoryViewPage', $data, "MCVP_ID = '{$views[$view['MV_ID']]['MCVP_ID']}'"); } else { $this->_db->insert('ModuleCategoryViewPage', $data); } } } $this->_redirect("{$this->view->current_module}/index/list-categories/"); } else { $formData = $this->_request->getPost(); $form->populate($formData); } } else { $data = $categoriesObject->populate($id, $this->_currentEditLanguage); $views = Cible_FunctionsCategories::getCategoryViews($this->_moduleID, $id); if ($views) { foreach ($views as $view) { if (!empty($view['MCVP_PageID'])) { $data["{$view['MV_Name']}_pageID"] = $view['MCVP_PageID']; $data["{$view['MV_Name']}_controllerName"] = $view['PI_PageIndex']; } } } $form->populate($data); } } }