/** * 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 data associated to the element according to the type //if Question foreach ($elements as $element) { if ($element['FE_TypeID'] == '2') { $html .= $oQuestion->show($element[$this->_dataId], null, $langId, $element['FE_Seq']); } elseif ($element['FE_TypeID'] == '1') { $html .= $oText->show($element['FE_ID'], $langId, $element['FE_Seq']); } // Include data into the element } return $html; }
/** * 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; }
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; }