本文整理汇总了PHP中BOL_QuestionService::findAllQuestionsWithSectionForAccountType方法的典型用法代码示例。如果您正苦于以下问题:PHP BOL_QuestionService::findAllQuestionsWithSectionForAccountType方法的具体用法?PHP BOL_QuestionService::findAllQuestionsWithSectionForAccountType怎么用?PHP BOL_QuestionService::findAllQuestionsWithSectionForAccountType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BOL_QuestionService
的用法示例。
在下文中一共展示了BOL_QuestionService::findAllQuestionsWithSectionForAccountType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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']);
}
//.........这里部分代码省略.........