Esempio n. 1
0
 public function editAction()
 {
     $this->view->title = "Modification d'une galerie";
     // Tests if the user has permissions
     if ($this->view->aclIsAllowed($this->view->current_module, 'manage', true)) {
         // variables
         $this->view->assign('isXmlHttpRequest', $this->_isXmlHttpRequest);
         $this->view->assign('success', false);
         $textID = $this->_getParam('textID');
         $baseDir = $this->view->baseUrl();
         $oText = new FormTextObject();
         $textData = $oText->populate($textID, Zend_Registry::get("currentEditLanguage"));
         if (!$textData) {
             if ($this->_request->isPost()) {
                 $this->view->assign('success', true);
             }
             $this->view->assign('deleted', true);
             $this->view->assign('textID', $textID);
         } else {
             $this->view->assign('deleted', false);
             $config = Zend_Registry::get('config')->toArray();
             if ($this->_request->isPost()) {
                 $formData = $this->_request->getPost();
             }
             // generate the form form/index/edit/formID/1
             $returnUrl = "{$baseDir}/form/index/list/";
             $form = new FormTextzoneForm(array('baseDir' => $baseDir, 'cancelUrl' => '', 'textID' => $textID));
             if ($this->_request->isPost()) {
                 $formData = $this->_request->getPost();
                 if ($form->isValid($formData)) {
                     $oText->save($textID, $formData, $this->getCurrentEditLanguage());
                     if ($this->_isXmlHttpRequest) {
                         $this->view->assign('success', true);
                         $this->view->assign('textID', $textID);
                         $this->view->assign('text', $form->getValue('FTI_Text'));
                     } else {
                         $this->_redirect($returnUrl);
                     }
                 } else {
                     $this->view->form = $form;
                 }
             } else {
                 $form->populate($textData);
                 $this->view->form = $form;
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * Get all elements linked to a specific section
  *
  * @param int  $sectionId Id of the queried section.
  * @param int  $langId    Id of the current language.
  * @param bool $all       If true then loading elements not creating a new one
  *
  * @return string $html  The html format to display current element in section
  */
 public function getElements($sectionId, $langId, $all = false)
 {
     $html = '';
     $elements = $this->_selectelements($sectionId, true);
     $oQuestion = new FormQuestionObject();
     $oText = new FormTextObject();
     //Get associated data according to the type
     foreach ($elements as $index => $element) {
         //if Question
         if ($element['FE_TypeID'] == '2') {
             $question = $oQuestion->show($element[$this->_dataId], null, $langId, $element['FE_Seq']);
             // Include data into the element
             $elements[$index]['questions'] = $question;
             // or if text zone
         } elseif ($element['FE_TypeID'] == '1') {
             $textZone = $oText->getTexts($element['FE_ID'], $langId);
             // Include data into the element
             $elements[$index]['textzone'] = $textZone;
         }
     }
     return $elements;
 }
Esempio n. 3
0
 /**
  * Delete elements and linked data.
  *      If the process is called from the section each element will
  *      be processed and linked data will be deleted too.
  *
  * @param int     $id  Id of the section or the element itself.
  * @param boolean $all Set the process to use.
  *
  * @return boolean
  */
 public function deleteAll($id, $all = false)
 {
     $deleted = true;
     $oQuestion = new FormQuestionObject();
     $oText = new FormTextObject();
     // If the method is called with wrong parameters
     // If the method is called with wrong parameters
     if (!$all && empty($id)) {
         throw new Exception('Erreur de paramètres');
     }
     // If deletion is called by section deletion
     if ($all) {
         //Select all the elements of the section
         $elements = $this->_selectElements($id, $all);
         if (count($elements) > 0) {
             //Call elements in section to delete them too
             foreach ($elements as $element) {
                 if ($element['FE_TypeID'] == '2') {
                     $delElem = $oQuestion->deleteAll($element[$this->_dataId], $all);
                 } elseif ($element['FE_TypeID'] == '1') {
                     $delElem = $oText->deleteAll($element[$this->_dataId], $all);
                 }
                 if ($delElem) {
                     $this->delete($element[$this->_dataId]);
                 } else {
                     $deleted = false;
                     break;
                 }
             }
         }
         // If deletion is done for only a defined section
     } else {
         // call the elements to be deleted
         $element = $this->_selectElements($id);
         if (count($element) && $element[0]['FE_TypeID'] == '2') {
             $deleted = $oQuestion->deleteAll($id, true);
         } elseif (count($element) && $element[0]['FE_TypeID'] == '1') {
             $deleted = $oText->deleteAll($element[0][$this->_dataId], true);
         }
         if ($deleted) {
             $this->delete($id);
         }
     }
     return $deleted;
 }
Esempio n. 4
0
 public function showAction()
 {
     $id = $this->_getParam('id');
     $type = $this->_getParam('type');
     $langId = $this->_registry->currentEditLanguage;
     if ($type == 'textZone') {
         $item = new FormTextObject();
         $html = $item->show($id);
     } elseif ($type == 'question') {
         $questionType = $this->_getParam('questionType');
         $item = new FormQuestionObject();
         $html = $item->show($id, $questionType, $langId);
     }
     $data = array('html' => utf8_encode($html));
     echo json_encode($data);
     exit;
 }