Example #1
0
 public function show($elemId = '', $questionType = null, $langId = 1, $elemSeq = null)
 {
     $question = array();
     if ($elemId != '') {
         $question = $this->_selectQuestions($elemId, $langId);
         if (empty($question)) {
             $question = $this->_selectQuestions($elemId, Cible_Controller_Action::getDefaultEditLanguage());
         }
         $questionType = $question[0]['FQ_TypeID'];
         $className = 'Question' . $question[0]['FQT_TypeName'] . 'Object';
         $oQuestion = new $className();
         $html = '<li questiontype="text" elementtype="question"
             class="element element_question section_element_question_li"
             style="display: list-item;" id="element_' . $elemId . '">';
         $html .= $oQuestion->showQuestion($question, $elemId, $elemSeq, null, $langId);
         $html .= "</li>";
     } elseif ($questionType != null) {
         $oQuestTyp = new FormQuestionTypeObject();
         $types = $oQuestTyp->populate($questionType, $langId);
         $className = 'Question' . $types['FQT_TypeName'] . 'Object';
         $oQuestion = new $className();
         $html = $oQuestion->showQuestion($question, $elemId, $elemSeq, $types, $langId);
     }
     return $html;
 }
Example #2
0
 public function editAction()
 {
     // web page title
     $this->view->title = "Edition de formulaire";
     // Tests if the user has permissions
     if ($this->view->aclIsAllowed($this->_name, 'manage', true)) {
         // set variables needed for the process
         $formID = $this->_getParam('formID');
         $returnAction = $this->_getParam('return');
         $pageID = $this->_getParam('pageID');
         $blockID = $this->_getParam('blockID');
         $baseDir = $this->view->baseUrl();
         if (empty($formID) && !empty($blockID)) {
             $formID = Cible_FunctionsBlocks::getBlockParameter($blockID, '1');
         }
         // Define the url where to return
         if ($returnAction) {
             $returnUrl = "/form/index/{$returnAction}";
         } elseif ($pageID) {
             $returnUrl = "/page/index/index/ID/{$pageID}";
         } else {
             $returnUrl = "/form/index/list/";
         }
         //Add specific js file
         $this->view->headScript()->appendFile($this->view->locateFile('headerFormActions.js'));
         $this->view->headScript()->appendFile($this->view->locateFile('tiny_mce/tiny_mce.js'));
         $oNotifications = new FormNotificationObject();
         $recipients = $oNotifications->getAll(null, true, $formID);
         // Get data for the current form
         $oForm = new FormObject();
         $data = $oForm->populate($formID, $this->getCurrentEditLanguage());
         //Generate the form for the back button
         $formBack = new FormBackButton(array('baseDir' => $baseDir, 'cancelUrl' => "{$baseDir}{$returnUrl}", 'disableAction' => false));
         $formBack->removeElement('submitSave');
         $formBack->getElement('cancel')->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'li')), array(array('row' => 'HtmlTag'), array('tag' => 'ul', 'openOnly' => true, 'class' => 'actions-buttons'))))->setOrder(1);
         $this->view->formBack = $formBack;
         //Generate the form
         $form = new FormForm(array('baseDir' => $baseDir, 'cancelUrl' => "{$baseDir}{$returnUrl}", 'formID' => $formID, 'disableAction' => true, 'recipients' => $recipients));
         $this->view->form = $form;
         //Add question type data
         $oQuestion = new FormQuestionTypeObject();
         $questionData = $oQuestion->getAll($this->getCurrentEditLanguage());
         $this->view->questionType = $questionData;
         // action: If not post action (send modification)
         if (!$this->_request->isPost()) {
             //Populate the for with data from db
             $form->populate($data);
         } else {
             // Get data sent
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $languages = Cible_FunctionsGeneral::getAllLanguage();
                 var_dump($languages);
                 exit;
                 // and save value in db
                 $oForm->save($formID, $formData, $this->getCurrentEditLanguage());
                 $oForm->save($formID, $formData, $this->getCurrentEditLanguage());
                 $this->_redirect($returnUrl);
             }
         }
     }
 }