Esempio n. 1
0
 /**
  * @see FormElement::renderInput()
  *
  * @param array $params
  * @return string
  */
 public function renderInput($params = null)
 {
     $html = parent::renderInput($params);
     $template = '
                     <div class="clearfix question_value_block" style="cursor:move;">
                             <span class="tag">
                                 <input type="hidden" value="{$value}">
                                 <span class="label" style="max-width:250px;overflow:hidden;">{$label}</span>
                                 <a title=' . json_encode(OW::getLanguage()->text('admin', 'remove_value')) . ' class="remove" href="javascript://"></a>
                             </span>
                     </div>';
     $template = UTIL_String::replaceVars($template, array('label' => '', 'value' => 0));
     $json = json_encode(array('tagFieldId' => $this->tag->getId(), 'dataFieldId' => $this->getId(), 'value' => $this->value, 'order' => array_keys($this->value), 'template' => $template));
     OW::getDocument()->addOnloadScript("\n            if ( !window.addInfiniteQuestionValues )\n            {\n                window.addInfiniteQuestionValues = {};\n            }\n\n            window.addInfiniteQuestionValues[" . json_encode($this->getId()) . "] = new infiniteQuestionValuesField(" . $json . "); ");
     return $html;
 }
Esempio n. 2
0
 protected function init($params = array())
 {
     $accountTypes = $this->questionService->findAllAccountTypes();
     $serviceLang = BOL_LanguageService::getInstance();
     $language = OW::getLanguage();
     $currentLanguageId = OW::getLanguage()->getCurrentId();
     $accounts = array();
     /* @var $value BOL_QuestionAccount */
     foreach ($accountTypes as $value) {
         $accounts[$value->name] = $this->questionService->getAccountTypeLang($value->name);
     }
     $sections = $this->questionService->findSortedSectionList();
     // need to hide sections select box
     if (empty($sections)) {
         $this->assign('no_sections', true);
     }
     $sectionsArray = array();
     /* @var $section BOL_QuestionSection */
     foreach ($sections as $section) {
         $sectionsArray[$section->name] = $language->text('base', 'questions_section_' . $section->name . '_label');
     }
     $event = new OW_Event('base.question.add_question_form.on_get_available_sections', $sectionsArray, $sectionsArray);
     OW::getEventManager()->trigger($event);
     $sectionsArray = $event->getData();
     $presentationList = array_keys($this->presentations2types);
     $presentations = array();
     $presentationsLabel = array();
     foreach ($presentationList as $item) {
         $presentations[$item] = $item;
         $presentationsLabel[$item] = $language->text('base', 'questions_question_presentation_' . $item . '_label');
     }
     $presentation = $presentationList[0];
     if (isset($_POST['qst_answer_type']) && isset($presentations[$_POST['qst_answer_type']])) {
         $presentation = $presentations[$_POST['qst_answer_type']];
     }
     $qstName = new TextField('qst_name');
     $qstName->setLabel($language->text('admin', 'questions_question_name_label'));
     //$qstName->addValidator(new StringValidator(0, 24000));
     $qstName->setRequired();
     $this->addElement($qstName);
     $qstName = new TextField('qst_description');
     $qstName->setLabel($language->text('admin', 'questions_question_description_label'));
     //$qstName->addValidator(new StringValidator(0, 24000));
     $this->addElement($qstName);
     if (count($accountTypes) > 1) {
         $qstAccountType = new CheckboxGroup('qst_account_type');
         $qstAccountType->setLabel($language->text('admin', 'questions_for_account_type_label'));
         $qstAccountType->setRequired();
         $qstAccountType->setDescription($language->text('admin', 'questions_for_account_type_description'));
         $qstAccountType->setOptions($accounts);
         $this->addElement($qstAccountType);
     }
     if (!empty($sectionsArray)) {
         $qstSection = new Selectbox('qst_section');
         $qstSection->setLabel($language->text('admin', 'questions_question_section_label'));
         $qstSection->setOptions($sectionsArray);
         $qstSection->setHasInvitation(false);
         $this->addElement($qstSection);
     }
     $qstAnswerType = new Selectbox('qst_answer_type');
     $qstAnswerType->setLabel($language->text('admin', 'questions_answer_type_label'));
     $qstAnswerType->addAttribute('class', $qstAnswerType->getName());
     $qstAnswerType->setOptions($presentationsLabel);
     $qstAnswerType->setRequired();
     $qstAnswerType->setHasInvitation(false);
     $qstAnswerType->setValue($presentation);
     $this->addElement($qstAnswerType);
     //        if ( $displayPossibleValues )
     //        {
     $qstPossibleValues = new addValueField('qst_possible_values');
     //$qstPossibleValues->addAttribute('class', $qstPossibleValues->getName());
     $qstPossibleValues->setLabel($language->text('admin', 'questions_possible_values_label'));
     $qstPossibleValues->setDescription($language->text('admin', 'questions_possible_values_description'));
     //$qstPossibleValues->setValue( array( '1' => 'aaa', '2' => 'bbbb', '4' => 'ccc' ) );
     $this->addElement($qstPossibleValues);
     //        }
     $configList = $this->questionConfigs;
     foreach ($configList as $config) {
         $className = $config->presentationClass;
         /* @var $qstConfig OW_FormElement */
         $qstConfig = OW::getClassInstance($className, $config->name);
         $qstConfig->setLabel($language->text('admin', 'questions_config_' . $config->name . '_label'));
         if (!empty($config->description)) {
             $qstConfig->setDescription($config->description);
         }
         $this->addElement($qstConfig);
     }
     $qstColumnCount = new Selectbox('qst_column_count');
     $qstColumnCount->addAttribute('class', $qstColumnCount->getName());
     $qstColumnCount->setLabel($language->text('admin', 'questions_columns_count_label'));
     $qstColumnCount->setOptions($this->qstColumnCountValues);
     $qstColumnCount->setValue(1);
     $this->addElement($qstColumnCount);
     $qstRequired = new CheckboxField('qst_required');
     $qstRequired->setLabel($language->text('admin', 'questions_required_label'));
     $qstRequired->setDescription($language->text('admin', 'questions_required_description'));
     $this->addElement($qstRequired);
     $qstOnSignUp = new CheckboxField('qst_on_sign_up');
     $qstOnSignUp->setLabel($language->text('admin', 'questions_on_sing_up_label'));
     $qstOnSignUp->setDescription($language->text('admin', 'questions_on_sing_up_description'));
     $this->addElement($qstOnSignUp);
     $qstOnEdit = new CheckboxField('qst_on_edit');
     $qstOnEdit->setLabel($language->text('admin', 'questions_on_edit_label'));
     $qstOnEdit->setDescription($language->text('admin', 'questions_on_edit_description'));
     $this->addElement($qstOnEdit);
     $qstOnView = new CheckboxField('qst_on_view');
     $qstOnView->setLabel($language->text('admin', 'questions_on_view_label'));
     $qstOnView->setDescription($language->text('admin', 'questions_on_view_description'));
     $this->addElement($qstOnView);
     $qstOnSearch = new CheckboxField('qst_on_search');
     $qstOnSearch->setLabel($language->text('admin', 'questions_on_search_label'));
     $qstOnSearch->setDescription($language->text('admin', 'questions_on_search_description'));
     $this->addElement($qstOnSearch);
     $qstSubmit = new Submit('qst_submit');
     $qstSubmit->setValue($language->text('admin', 'save_btn_label'));
     $qstSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $this->addElement($qstSubmit);
     $this->addElement($qstSubmit);
 }