Пример #1
0
 /**
  * Build the section zone for displaying.
  * Add any element found in database (text, questions or page break).
  *
  * @access private
  * @param  int     $formId The current form to be managed.
  * @param  int     $langId The language id.
  *
  * @return string $html The html code.
  */
 public function show($formId = '', $langId = null)
 {
     if (!empty($formId)) {
         $sections = $this->_selectSections($formId, $langId);
         $oElements = new FormElementObject();
         foreach ($sections as $index => $section) {
             //Find elements related to this section
             $elements = $oElements->getElements($section['FS_ID'], $langId, true);
             //push it into the the section array
             $sections[$index]['elements'] = $elements;
         }
     }
     //return the data
     return $sections;
 }
Пример #2
0
 /**
  * Delete sections and related data.
  *      If the process is called from the form each section will
  *      be processed and linked data will be deleted too.
  *
  * @access private
  * @param  int     $id  Id of the form or of the section itself.
  * @param  boolean $all Set the process to use.
  *
  * @return boolean
  */
 public function deleteAll($id, $all = false)
 {
     $deleted = true;
     $oElem = new FormElementObject();
     // If the method is called with wrong parameters
     if (!$all && empty($id)) {
         throw new Exception('Erreur de paramètres');
     }
     // If deletion is called by form deletion
     if ($all) {
         //Select all the section
         $sections = $this->_selectData($id);
         if (count($sections) > 0) {
             //Call elements in section to delete them too
             foreach ($sections as $section) {
                 $delElem = $oElem->deleteAll($section['FS_ID'], $all);
                 if ($delElem) {
                     $deleted = true;
                     $this->delete($section['FS_ID']);
                 } else {
                     $deleted = false;
                     break;
                 }
             }
         }
         // If deletion is done for only a defined section
     } else {
         // call the elements to be deleted
         $deleted = $oElem->deleteAll($id, true);
         if ($deleted) {
             $this->delete($id);
         }
     }
     return $deleted;
 }