本文整理汇总了PHP中formatOptionsForQuestion函数的典型用法代码示例。如果您正苦于以下问题:PHP formatOptionsForQuestion函数的具体用法?PHP formatOptionsForQuestion怎么用?PHP formatOptionsForQuestion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了formatOptionsForQuestion函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getAllQuestionsAccountType
function getAllQuestionsAccountType($account_post_val, $param)
{
global $QuestionService;
global $AccountTypeToGenderService;
// global $BOL_AvatarService_inst;
global $QUESTION_PRESENTATION_RANGE;
global $QUESTION_PRESENTATION_BIRTHDATE;
global $QUESTION_PRESENTATION_AGE;
global $QUESTION_PRESENTATION_DATE;
global $Userservice;
global $language;
$app = \Slim\Slim::getInstance();
$app->response->headers->set('Content-Type', 'application/json');
$app->response->setStatus(200);
//Lang Call Start
$hammu_lang_id = $app->request()->params("lang_id");
if (!empty($hammu_lang_id)) {
getCurrentLanguages($hammu_lang_id);
}
//Lang Call end
$fields = $param["fields"];
$accountType = $AccountTypeToGenderService->getAccountType($account_post_val);
$questionNames = array();
$questionNames[] = "sex";
foreach ($QuestionService->findSignUpQuestionsForAccountType($accountType) as $question) {
$questionNames[] = $question['name'];
}
$questionList = $QuestionService->findQuestionByNameList($questionNames);
$sectionNameList = array();
foreach ($questionList as $question) {
if (!in_array($question->sectionName, $sectionNameList)) {
$sectionNameList[] = $question->sectionName;
}
}
$sectionList = $QuestionService->findSectionBySectionNameList($sectionNameList);
usort($questionList, function ($a, $b) use($sectionList) {
$sectionNameA = $a->sectionName;
$sectionNameB = $b->sectionName;
if ($sectionNameA === $sectionNameB) {
return (int) $a->sortOrder < (int) $b->sortOrder ? -1 : 1;
}
if (!isset($sectionList[$sectionNameA]) || !isset($sectionList[$sectionNameB])) {
return 1;
}
return (int) $sectionList[$sectionNameA]->sortOrder < (int) $sectionList[$sectionNameB]->sortOrder ? -1 : 1;
});
$questionOptions = $QuestionService->findQuestionsValuesByQuestionNameList($questionNames);
$questions = $category = array();
foreach ($questionList as $question) {
if (in_array($question->name, $fields)) {
$custom = json_decode($question->custom, true);
$value = null;
switch ($question->presentation) {
case $QUESTION_PRESENTATION_RANGE:
$value = '18-33';
break;
case $QUESTION_PRESENTATION_BIRTHDATE:
case $QUESTION_PRESENTATION_AGE:
case $QUESTION_PRESENTATION_DATE:
$value = date('Y-m-d H:i:s', strtotime('-18 year'));
break;
}
if (!isset($category[$question->sectionName])) {
$category[$question->sectionName] = array('category' => $question->sectionName, 'label' => $QuestionService->getSectionLang($question->sectionName));
}
$questions[] = array('name' => $question->name, 'label' => $QuestionService->getQuestionLang($question->name), 'presentation' => $question->name == 'googlemap_location' ? $question->name : $question->presentation, 'options' => formatOptionsForQuestion($question->name, $questionOptions));
}
}
return $questions;
}
开发者ID:bhushansonar,项目名称:hammu,代码行数:70,代码来源:index_4_7_2015.php
示例2: getallquestions
function getallquestions($param)
{
global $QuestionService;
global $AccountTypeToGenderService;
global $BOL_AvatarService_inst;
global $QUESTION_PRESENTATION_RANGE;
global $QUESTION_PRESENTATION_BIRTHDATE;
global $QUESTION_PRESENTATION_AGE;
global $QUESTION_PRESENTATION_DATE;
global $Userservice;
$app = \Slim\Slim::getInstance();
$app->response->headers->set('Content-Type', 'application/json');
$app->response->setStatus(200);
$fields = $param["fields"];
$user_id = $param["user_id"];
if (empty($user_id)) {
$return_data = array("message" => "Please provide User id!", "status" => "false");
$app->response->setBody(json_encode($return_data));
}
$user = $Userservice->findUserById($user_id);
if (!empty($user)) {
$account = $user->getAccountType();
if ($account == "8cc28eaddb382d7c6a94aeea9ec029fb") {
// $sex = "lady";
$account_type = 2;
} else {
$account_type = 1;
//$sex = "gentleman";
}
$accountType = $AccountTypeToGenderService->getAccountType($account_type);
$questionNames = array();
$questionNames[] = "sex";
foreach ($QuestionService->findSignUpQuestionsForAccountType($accountType) as $question) {
$questionNames[] = $question['name'];
}
$questionList = $QuestionService->findQuestionByNameList($questionNames);
$sectionNameList = array();
foreach ($questionList as $question) {
if (!in_array($question->sectionName, $sectionNameList)) {
$sectionNameList[] = $question->sectionName;
}
}
$sectionList = $QuestionService->findSectionBySectionNameList($sectionNameList);
usort($questionList, function ($a, $b) use($sectionList) {
$sectionNameA = $a->sectionName;
$sectionNameB = $b->sectionName;
if ($sectionNameA === $sectionNameB) {
return (int) $a->sortOrder < (int) $b->sortOrder ? -1 : 1;
}
if (!isset($sectionList[$sectionNameA]) || !isset($sectionList[$sectionNameB])) {
return 1;
}
return (int) $sectionList[$sectionNameA]->sortOrder < (int) $sectionList[$sectionNameB]->sortOrder ? -1 : 1;
});
$questionOptions = $QuestionService->findQuestionsValuesByQuestionNameList($questionNames);
$questions = $category = array();
foreach ($questionList as $question) {
if (in_array($question->name, $fields)) {
$custom = json_decode($question->custom, true);
$value = null;
switch ($question->presentation) {
case $QUESTION_PRESENTATION_RANGE:
$value = '18-33';
break;
case $QUESTION_PRESENTATION_BIRTHDATE:
case $QUESTION_PRESENTATION_AGE:
case $QUESTION_PRESENTATION_DATE:
$value = date('Y-m-d H:i:s', strtotime('-18 year'));
break;
}
if (!isset($category[$question->sectionName])) {
$category[$question->sectionName] = array('category' => $question->sectionName, 'label' => $QuestionService->getSectionLang($question->sectionName));
}
$questions[] = array('name' => $question->name, 'label' => $QuestionService->getQuestionLang($question->name), 'presentation' => $question->name == 'googlemap_location' ? $question->name : $question->presentation, 'options' => formatOptionsForQuestion($question->name, $questionOptions), 'value' => $value, 'userSelectedValue' => renderQuestion($user_id, $question->name), 'userSelectedLabel' => renderQuestion($user_id, $question->name, true), 'required' => $question->required);
}
}
if (in_array('avatar', $fields)) {
$avatar = $BOL_AvatarService_inst->getAvatarUrl($user_id);
// $questions[] = array('name' => "avatar", "userSelectedValue" => $avatar);
$questions[] = array('name' => "avatar", 'label' => "Avatar", 'custom' => $custom, 'presentation' => "upload", 'options' => array(), 'value' => null, 'rawValue' => $value, 'userSelectedValue' => $avatar, 'userSelectedLabel' => "Avatar", 'required' => "0");
}
return $questions;
}
}
开发者ID:hardikamutech,项目名称:hammu,代码行数:84,代码来源:index_21_5_2015.php
注:本文中的formatOptionsForQuestion函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论