本文整理汇总了PHP中BOL_QuestionService::saveOrUpdateSection方法的典型用法代码示例。如果您正苦于以下问题:PHP BOL_QuestionService::saveOrUpdateSection方法的具体用法?PHP BOL_QuestionService::saveOrUpdateSection怎么用?PHP BOL_QuestionService::saveOrUpdateSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BOL_QuestionService
的用法示例。
在下文中一共展示了BOL_QuestionService::saveOrUpdateSection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajaxResponder
//.........这里部分代码省略.........
case 'onSearch':
if (!$disableActionList['disable_on_search']) {
$questionDto->onSearch = $onSearch;
}
break;
case 'onView':
if (!$disableActionList['disable_on_view']) {
$questionDto->onView = $onView;
}
break;
default:
if (!$disableActionList['disable_required']) {
$questionDto->required = $required;
}
if (!$disableActionList['disable_on_join']) {
$questionDto->onJoin = $onJoin;
}
if (!$disableActionList['disable_on_edit']) {
$questionDto->onEdit = $onEdit;
}
if (!$disableActionList['disable_on_view']) {
$questionDto->onView = $onView;
}
if (!$disableActionList['disable_on_search']) {
$questionDto->onSearch = $onSearch;
}
break;
}
}
$this->questionService->saveOrUpdateQuestion($questionDto);
echo json_encode(json_encode(array('result' => true)));
break;
case 'questionAccountTypes':
$question = $_POST['question'];
$data = $_POST['data'];
if (empty($question) || empty($data)) {
echo json_encode(array('result' => false));
exit;
}
$questionDto = $this->questionService->findQuestionByName($question);
if (!empty($questionDto)) {
$disableActionList = BOL_QuestionService::getInstance()->getQuestionDisableActionList($questionDto);
if (!$disableActionList['disable_account_type']) {
$add = array();
$delete = array();
foreach ($data as $accountType => $value) {
if ($value === "true") {
$add[] = $accountType;
} else {
$delete[] = $accountType;
}
}
if (!empty($delete)) {
BOL_QuestionService::getInstance()->deleteQuestionToAccountType($questionDto->name, $delete);
}
if (!empty($add)) {
BOL_QuestionService::getInstance()->addQuestionToAccountType($questionDto->name, $add);
}
}
}
echo json_encode(json_encode(array('result' => true)));
break;
case 'addSection':
if (empty($_POST['section_name'])) {
echo json_encode(array('result' => false, 'message' => ''));
exit;
}
$sectionName = $_POST['section_name'];
$questionSection = new BOL_QuestionSection();
$questionSection->name = md5(uniqid());
$questionSection->sortOrder = $this->questionService->findLastSectionOrder() + 1;
$this->questionService->saveOrUpdateSection($questionSection);
BOL_LanguageService::getInstance()->addOrUpdateValue(OW::getLanguage()->getCurrentId(), 'base', 'questions_section_' . $questionSection->name . '_label', htmlspecialchars($sectionName));
if (OW::getDbo()->getAffectedRows() > 0) {
echo json_encode(array('result' => true, 'message' => OW::getLanguage()->text('admin', 'questions_section_was_added')));
}
break;
case 'addQuestion':
/* @var $form ADMIN_CLASS_AddQuestionForm */
$form = OW::getClassInstance('ADMIN_CLASS_AddQuestionForm', 'qst_add_form', '');
$form->process();
break;
case 'editQuestion':
if (empty($_POST['questionId'])) {
echo json_encode(array('result' => false, 'errors' => array(), 'message' => OW::getLanguage()->text('admin', 'questions_not_found')));
exit;
}
$question = BOL_QuestionService::getInstance()->findQuestionById($_POST['questionId']);
if (empty($question) || !$question instanceof BOL_Question) {
echo json_encode(array('result' => false, 'errors' => array(), 'message' => OW::getLanguage()->text('admin', 'questions_not_found')));
exit;
}
$form = OW::getClassInstance('ADMIN_CLASS_EditQuestionForm', 'qst_edit_form', '');
$form->loadQuestionData($question);
$form->process();
break;
default:
}
exit;
}
示例2: index
public function index($params = array())
{
$this->addContentMenu();
$accountType = null;
if (isset($_GET['accountType'])) {
OW::getSession()->set(self::SESSION_VAR_ACCIUNT_TYPE, trim($_GET['accountType']));
}
if (OW::getSession()->get(self::SESSION_VAR_ACCIUNT_TYPE)) {
$accountType = OW::getSession()->get(self::SESSION_VAR_ACCIUNT_TYPE);
}
$serviceLang = BOL_LanguageService::getInstance();
$language = OW::getLanguage();
$currentLanguageId = OW::getLanguage()->getCurrentId();
// get available account types from DB
$accountTypes = $this->questionService->findAllAccountTypesWithQuestionsCount();
/* @var $value BOL_QuestionAccount */
foreach ($accountTypes as $key => $value) {
$accounts[$value['name']] = $language->text('base', 'questions_account_type_' . $value['name']);
}
$accountsKeys = array_keys($accounts);
$accountType = !isset($accountType) || !in_array($accountType, $accountsKeys) ? $accountsKeys[0] : $accountType;
// -- Select account type form --
$accountTypeSelectForm = new Form('qst_account_type_select_form');
$accountTypeSelectForm->setMethod(Form::METHOD_GET);
$qstAccountType = new Selectbox('accountType');
$qstAccountType->addAttribute('id', 'qst_account_type_select');
$qstAccountType->setLabel($language->text('admin', 'questions_account_type_label'));
$qstAccountType->setOptions($accounts);
$qstAccountType->setValue($accountType);
$qstAccountType->setHasInvitation(false);
$accountTypeSelectForm->addElement($qstAccountType);
$this->addForm($accountTypeSelectForm);
$script = '
$("#qst_account_type_select").change( function(){
$(this).parents("form:eq(0)").submit();
} );
';
OW::getDocument()->addOnloadScript($script);
$this->assign('accountTypes', $accountTypes);
$this->assign('editAccountTypeUrl', OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'editAccountType'));
$addSectionForm = new Form('qst_add_section_form');
$qstSectionName = new TextField('section_name');
$qstSectionName->addAttribute('class', 'ow_text');
$qstSectionName->addAttribute('style', 'width: auto;');
$qstSectionName->setRequired();
$qstSectionName->setLabel($language->text('admin', 'questions_new_section_label'));
$addSectionForm->addElement($qstSectionName);
if (OW::getRequest()->isPost() && isset($_POST['section_name'])) {
if ($addSectionForm->isValid($_POST)) {
$data = $addSectionForm->getValues();
$questionSection = new BOL_QuestionSection();
$questionSection->name = md5(uniqid());
$questionSection->sortOrder = $this->questionService->findLastSectionOrder() + 1;
$this->questionService->saveOrUpdateSection($questionSection);
$this->questionService->updateQuestionsEditStamp();
$serviceLang->addValue($currentLanguageId, 'base', 'questions_section_' . $questionSection->name . '_label', htmlspecialchars($data['section_name']));
if (OW::getDbo()->getAffectedRows() > 0) {
OW::getFeedback()->info($language->text('admin', 'questions_section_was_added'));
}
$this->redirect(OW::getRequest()->getRequestUri());
}
}
$this->addForm($addSectionForm);
// -- Get all section, questions and question values --
$questions = $this->questionService->findAllQuestionsWithSectionForAccountType($accountType);
$section = null;
$questionArray = array();
$questionNameList = array();
$sectionDeleteUrlList = array();
$parentList = array();
foreach ($questions as $sort => $question) {
if ($section !== $question['sectionName']) {
$section = $question['sectionName'];
$sectionDeleteUrlList[$section] = OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'deleteSection', array("sectionName" => $section));
$questionArray[$section] = array();
}
if (isset($questions[$sort]['id'])) {
$questionArray[$section][$sort] = $questions[$sort];
$questionArray[$section][$sort]['questionEditUrl'] = OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'edit', array("questionId" => $questions[$sort]['id']));
$questionArray[$section][$sort]['questionDeleteUrl'] = OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'deleteQuestion', array("questionId" => $questions[$sort]['id']));
if (!empty($question['parent'])) {
$parent = $this->questionService->findQuestionByName($question['parent']);
if (!empty($parent)) {
$questionArray[$section][$sort]['parentUrl'] = OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'edit', array("questionId" => $parent->id));
$questionArray[$section][$sort]['parentLabel'] = $this->questionService->getQuestionLang($parent->name);
$parentList[$question['parent']][] = array('name' => $question['name'], 'editUrl' => $questionArray[$section][$sort]['questionEditUrl']);
} else {
$questionArray[$section][$sort]['parent'] = '';
}
}
$questionNameList[] = $questions[$sort]['name'];
}
}
foreach ($questions as $sort => $question) {
$text = $language->text('admin', 'questions_delete_question_confirmation');
if (array_key_exists($question['name'], $parentList)) {
$questionStringList = array();
foreach ($parentList[$question['name']] as $child) {
$questionStringList[] = BOL_QuestionService::getInstance()->getQuestionLang($child['name']);
}
//.........这里部分代码省略.........