当前位置: 首页>>代码示例>>PHP>>正文


PHP BOL_QuestionService::createQuestion方法代码示例

本文整理汇总了PHP中BOL_QuestionService::createQuestion方法的典型用法代码示例。如果您正苦于以下问题:PHP BOL_QuestionService::createQuestion方法的具体用法?PHP BOL_QuestionService::createQuestion怎么用?PHP BOL_QuestionService::createQuestion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BOL_QuestionService的用法示例。


在下文中一共展示了BOL_QuestionService::createQuestion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add


//.........这里部分代码省略.........
     $qstSubmitAdd = new Submit('qst_submit_and_add');
     $qstSubmitAdd->addAttribute('class', 'ow_button ow_ic_save');
     $qstSubmitAdd->setValue($language->text('admin', 'questions_save_and_new_label'));
     $addForm->addElement($qstSubmitAdd);
     if (OW::getSession()->isKeySet(self::ADD_QUESTION_SESSION_VAR)) {
         $addForm->setValues(OW::getSession()->get(self::ADD_QUESTION_SESSION_VAR));
         OW::getSession()->delete(self::ADD_QUESTION_SESSION_VAR);
     }
     if (OW_Request::getInstance()->isPost()) {
         if ((isset($_POST['qst_submit_and_add']) || isset($_POST['qst_submit'])) && $addForm->isValid($_POST)) {
             OW::getSession()->delete(self::ADD_QUESTION_SESSION_VAR);
             $data = $addForm->getValues();
             if (!isset($data['qst_section'])) {
                 $data['qst_section'] = null;
             } else {
                 $data['qst_section'] = htmlspecialchars(trim($data['qst_section']));
             }
             $presentations = BOL_QuestionService::getInstance()->getPresentations();
             // insert question
             $question = new BOL_Question();
             $question->name = md5(uniqid());
             $question->required = (int) $data['qst_required'];
             $question->onJoin = (int) $data['qst_on_sign_up'];
             $question->onEdit = (int) $data['qst_on_edit'];
             $question->onSearch = (int) $data['qst_on_search'];
             $question->onView = (int) $data['qst_on_view'];
             $question->presentation = htmlspecialchars($data['qst_answer_type']);
             $question->type = htmlspecialchars($presentations[trim($data['qst_answer_type'])]);
             if ((int) $data['qst_column_count'] > 1) {
                 $question->columnCount = (int) $data['qst_column_count'];
             }
             if (isset($data['qst_account_type'])) {
                 $question->accountTypeName = htmlspecialchars(trim($data['qst_account_type']));
                 if ($question->accountTypeName === BOL_QuestionService::ALL_ACCOUNT_TYPES) {
                     $question->accountTypeName = null;
                 }
             }
             if ($data['qst_section'] !== null) {
                 $section = $this->questionService->findSectionBySectionName(htmlspecialchars(trim($data['qst_section'])));
                 if (isset($section)) {
                     $question->sectionName = $section->name;
                 } else {
                     $question->sectionName = null;
                 }
             }
             $question->sortOrder = (int) BOL_QuestionService::getInstance()->findLastQuestionOrder($question->sectionName) + 1;
             // save question configs
             $configs = array();
             foreach ($presentationConfigList as $config) {
                 if (isset($data[$config->name])) {
                     $configs[$config->name] = $data[$config->name];
                 }
             }
             $question->custom = json_encode($configs);
             //$this->questionService->saveOrUpdateQuestion($question);
             //$this->questionService->setQuestionDescription($question->name, htmlspecialchars(trim($data['qst_description'])));
             //$this->questionService->setQuestionLabel($question->name, htmlspecialchars(trim($data['qst_name'])));
             $questionValues = array();
             //add question values
             if (isset($data['qst_possible_values']) && mb_strlen(trim($data['qst_possible_values'])) > 0 && in_array($question->type, array('select', 'multiselect'))) {
                 $questionValues = preg_split('/\\n/', trim($data['qst_possible_values']));
             }
             $this->questionService->createQuestion($question, htmlspecialchars(trim($data['qst_name'])), htmlspecialchars(trim($data['qst_description'])), $questionValues);
             OW::getFeedback()->info($language->text('admin', 'questions_add_question_message'));
             if (isset($_POST['qst_submit'])) {
                 $this->redirect(OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'index'));
             }
             $this->redirect(OW::getRequest()->getRequestUri());
         }
         $addForm->setValues($_POST);
         OW::getSession()->set(self::ADD_QUESTION_SESSION_VAR, $_POST);
         $this->redirect();
     }
     //        $types = array();
     //        foreach ( $this->questionService->getPresentations() as $presentation => $type )
     //        {
     //            if ( $type === 'select' )
     //            {
     //                $types[] = $presentation;
     //            }
     //        }
     $this->addForm($addForm);
     $fields = array();
     foreach ($addForm->getElements() as $element) {
         if (!$element instanceof HiddenField) {
             $fields[$element->getName()] = $element->getName();
         }
     }
     $this->assign('formData', $fields);
     //        $script = '
     //                    var addQuest = new addQuestion(' . json_encode($types) . ');
     //                    addQuest.displayPossibleValues();
     //                    ';
     //
     //        OW::getDocument()->addOnloadScript($script);
     //
     //        $jsDir = OW::getPluginManager()->getPlugin("admin")->getStaticJsUrl();
     //
     //        OW::getDocument()->addScript($jsDir . "questions.js");
 }
开发者ID:vazahat,项目名称:dudex,代码行数:101,代码来源:questions.php


注:本文中的BOL_QuestionService::createQuestion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。