Esempio n. 1
0
 /** Index action */
 public function indexAction()
 {
     $this->requireAdminPrivileges();
     $this->view->pageTitle = 'BatchMake Module Configuration';
     $config = $this->ModuleComponent->KWBatchmake->loadConfigProperties(null, false);
     $form = new Batchmake_Form_Admin();
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         if ($form->isValid($data)) {
             $values = $form->getValues();
             foreach ($values as $key => $value) {
                 if ($key !== MIDAS_BATCHMAKE_CSRF_TOKEN && !is_null($value)) {
                     $config[MIDAS_BATCHMAKE_GLOBAL_CONFIG_NAME][$this->moduleName . '.' . $key] = $value;
                 }
             }
             UtilityComponent::createInitFile(MIDAS_BATCHMAKE_MODULE_LOCAL_CONFIG, $config);
         }
         $form->populate($data);
     } else {
         $elements = $form->getElements();
         foreach ($elements as $element) {
             $batchMakeConfig = $this->ModuleComponent->KWBatchmake->filterBatchmakeConfigProperties($config);
             $defaultConfig = $this->createDefaultConfig($batchMakeConfig);
             $name = $element->getName();
             if ($name !== MIDAS_BATCHMAKE_CSRF_TOKEN && $name !== MIDAS_BATCHMAKE_SUBMIT_CONFIG) {
                 $value = $defaultConfig[$name];
                 if (!is_null($value)) {
                     $form->setDefault($name, $value);
                 }
             }
         }
     }
     $this->view->form = $form;
     session_start();
 }