Example #1
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;
 }
Example #2
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;
 }
Example #3
0
 public function __construct()
 {
     parent::__construct();
     $this->_currentElmId = $this->_increments['0']['AUTO_INCREMENT'];
     $this->_currentQstId = $this->_increments['1']['AUTO_INCREMENT'];
 }
Example #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;
 }