本文整理汇总了PHP中UTIL_DateTime::formatBirthdate方法的典型用法代码示例。如果您正苦于以下问题:PHP UTIL_DateTime::formatBirthdate方法的具体用法?PHP UTIL_DateTime::formatBirthdate怎么用?PHP UTIL_DateTime::formatBirthdate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTIL_DateTime
的用法示例。
在下文中一共展示了UTIL_DateTime::formatBirthdate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onNewsfeedItemRender
public function onNewsfeedItemRender(OW_Event $event)
{
$params = $event->getParams();
$content = $event->getData();
if (!empty($params['action']['entityType']) && !empty($params['action']['pluginKey']) && $params['action']['entityType'] == 'birthday' && $params['action']['pluginKey'] == 'birthdays') {
$html = '<div class="ow_user_list_data"></div>';
if (!empty($content['birthdate']) && !empty($content['userData'])) {
$date = UTIL_DateTime::parseDate($content['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$birthdate = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
if ($date['month'] == intval(date('m'))) {
if (intval(date('d')) + 1 == intval($date['day'])) {
$birthdate = '<span class="ow_green" style="font-weight: bold; text-transform: uppercase;">' . OW::getLanguage()->text('base', 'date_time_tomorrow') . '</a>';
} else {
if (intval(date('d')) == intval($date['day'])) {
$birthdate = '<span class="ow_green" style="font-weight: bold; text-transform: uppercase;">' . OW::getLanguage()->text('base', 'date_time_today') . '</span>';
}
}
}
$html = '<div class="ow_user_list_data">
<a href="' . $content['userData']["url"] . '">' . $content['userData']["title"] . '</a><br><span style="font-weight:normal;" class="ow_small">' . OW::getLanguage()->text('birthdays', 'birthday') . ' ' . $birthdate . '</span>
</div>';
}
$content['content'] .= $html;
$content['content'] = '<div class="clearfix">' . $content['content'] . '</div>';
$event->setData($content);
}
}
示例2: onNewsfeedItemRender
public function onNewsfeedItemRender(OW_Event $event)
{
$params = $event->getParams();
$content = $event->getData();
if (!empty($params['action']['entityType']) && !empty($params['action']['pluginKey']) && $params['action']['entityType'] == 'birthday' && $params['action']['pluginKey'] == 'birthdays') {
$html = '<div class="ow_user_list_data"></div>';
if (!empty($content['birthdate']) && !empty($content['userData'])) {
$date = UTIL_DateTime::parseDate($content['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$birthdate = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
if ($date['month'] == intval(date('m'))) {
if (intval(date('d')) + 1 == intval($date['day'])) {
$birthdate = '<span class="ow_green" style="font-weight: bold; text-transform: uppercase;">' . OW::getLanguage()->text('base', 'date_time_tomorrow') . '</a>';
} else {
if (intval(date('d')) == intval($date['day'])) {
$birthdate = '<span class="ow_green" style="font-weight: bold; text-transform: uppercase;">' . OW::getLanguage()->text('base', 'date_time_today') . '</span>';
}
}
}
$html = '<div class="ow_user_list_data">
<a href="' . $content['userData']["url"] . '">' . $content['userData']["title"] . '</a><br><span style="font-weight:normal;" class="ow_small">' . OW::getLanguage()->text('birthdays', 'birthday') . ' ' . $birthdate . '</span>
</div>';
}
$userId = $params['action']['entityId'];
$usersData = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId));
$content['content'] = '<div class="ow_user_list_picture">' . OW::getThemeManager()->processDecorator('avatar_item', $usersData[$userId]) . '</div>';
$content['content'] .= $html;
$content['content'] = '<div class="clearfix">' . $content['content'] . '</div>';
$content['view'] = array('iconClass' => 'ow_ic_birthday');
$event->setData($content);
}
}
示例3: getAvatarInfo
public function getAvatarInfo($idList)
{
$data = parent::getAvatarInfo($idList);
$birthdays = BOL_QuestionService::getInstance()->getQuestionData($idList, array('birthdate'));
foreach ($data as $userId => $item) {
$yearOld = '';
if (!empty($birthdays[$userId]['birthdate'])) {
switch ($this->key) {
case 'birthdays_today':
$date = UTIL_DateTime::parseDate($birthdays[$userId]['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$yearOld = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']) . " " . OW::getLanguage()->text('base', 'questions_age_year_old');
break;
case 'birthdays_this_week':
$date = UTIL_DateTime::parseDate($birthdays[$userId]['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$yearOld = OW::getLanguage()->text('birthdays', 'birthday') . ' ' . UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']) . " ";
break;
}
}
if (!empty($data[$userId]['title'])) {
$data[$userId]['attrs'] = ' data-birthday="' . (!empty($yearOld) ? $yearOld : '') . '"';
} else {
if (!empty($yearOld)) {
$data[$userId]['attrs'] = ' data-birthday="' . $yearOld . '"';
}
}
}
OW::getDocument()->addOnloadScript("\n \$('*[title]', \$('.birthdays_avatar_list') ).each( function(i, o){\n \$(o).off('mouseenter');\n \$(o).on('mouseenter', function(){ \n var title = \$(this).attr('title');\n var birthday = \$(this).data('birthday');\n \n if ( !birthday )\n {\n OW.showTip(\$(this), {timeout:200});\n }\n else if ( !title && birthday )\n {\n birthday = '<span class=\"ow_small\" style=\"font-weight:normal;\">' + birthday + '</span>';\n \n OW.showTip(\$(this), {timeout:200, show:birthday});\n }\n else\n {\n birthday = '<br><span class=\"ow_small\" style=\"font-weight:normal;\">' + birthday + '</span>';\n \n OW.showTip(\$(this), {timeout:200, show:title + birthday});\n }\n });\n \$(o).off('mouseleave');\n \$(o).on('mouseleave', function(){ OW.hideTip(\$(this)); });\n });");
return $data;
}
示例4: getFields
public function getFields($userIdList)
{
$fields = array();
$qs = array();
$qBdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate');
if ($qBdate->onView) {
$qs[] = 'birthdate';
}
$qSex = BOL_QuestionService::getInstance()->findQuestionByName('sex');
if ($qSex->onView) {
$qs[] = 'sex';
}
$questionList = BOL_QuestionService::getInstance()->getQuestionData($userIdList, $qs);
foreach ($questionList as $uid => $question) {
$fields[$uid] = array();
$age = '';
if (!empty($question['birthdate'])) {
$date = UTIL_DateTime::parseDate($question['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
}
$sexValue = '';
if (!empty($question['sex'])) {
$sex = $question['sex'];
for ($i = 0; $i < 31; $i++) {
$val = pow(2, $i);
if ((int) $sex & $val) {
$sexValue .= BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $val) . ', ';
}
}
if (!empty($sexValue)) {
$sexValue = substr($sexValue, 0, -2);
}
}
if (!empty($sexValue) && !empty($age)) {
$fields[$uid][] = array('label' => '', 'value' => $sexValue . ' ' . $age);
}
if (!empty($question['birthdate'])) {
$dinfo = date_parse($question['birthdate']);
if ($this->listKey == 'birthdays') {
$birthdate = '';
if (intval(date('d')) + 1 == intval($dinfo['day'])) {
$questionList[$uid]['birthday'] = OW::getLanguage()->text('base', 'date_time_tomorrow');
$birthdate = '<a href="#" class="ow_lbutton ow_green">' . $questionList[$uid]['birthday'] . '</a>';
} else {
if (intval(date('d')) == intval($dinfo['day'])) {
$questionList[$uid]['birthday'] = OW::getLanguage()->text('base', 'date_time_today');
$birthdate = '<a href="#" class="ow_lbutton ow_green">' . $questionList[$uid]['birthday'] . '</a>';
} else {
$birthdate = UTIL_DateTime::formatBirthdate($dinfo['year'], $dinfo['month'], $dinfo['day']);
}
}
$fields[$uid][] = array('label' => 'Birthday: ', 'value' => $birthdate);
}
}
}
return $fields;
}
示例5: __construct
public function __construct(BASE_CLASS_WidgetParameter $params)
{
parent::__construct();
$service = BIRTHDAYS_BOL_Service::getInstance();
$user = BOL_UserService::getInstance()->findUserById($params->additionalParamList['entityId']);
if ($user === null) {
$this->setVisible(false);
return;
}
$eventParams = array('action' => 'birthdays_view_my_birthdays', 'ownerId' => $user->getId(), 'viewerId' => OW::getUser()->getId());
try {
OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
} catch (RedirectException $e) {
$this->setVisible(false);
return;
}
$result = $service->findListByBirthdayPeriod(date('Y-m-d'), date('Y-m-d', strtotime('+7 day')), 0, 1, array($user->getId()));
$isComingSoon = !empty($result);
$this->assign('ballonGreenSrc', OW::getPluginManager()->getPlugin('birthdays')->getStaticUrl() . 'img/' . 'ballon-lime-green.png');
$data = BOL_QuestionService::getInstance()->getQuestionData(array($user->getId()), array('birthdate'));
if (!$isComingSoon && !$params->customizeMode || !array_key_exists('birthdate', $data[$user->getId()])) {
$this->setVisible(false);
return;
}
$birtdate = $data[$user->getId()]['birthdate'];
$dateInfo = UTIL_DateTime::parseDate($birtdate, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$label = '';
if ($dateInfo['day'] == date('d')) {
$label = '<span class="ow_lbutton ow_green">' . OW::getLanguage()->text('base', 'date_time_today') . '</span>';
} else {
if ($dateInfo['day'] == date('d') + 1) {
$label = '<span class="ow_lbutton ow_green">' . OW::getLanguage()->text('base', 'date_time_tomorrow') . '</span>';
} else {
$label = '<span class="ow_small">' . UTIL_DateTime::formatBirthdate($dateInfo['year'], $dateInfo['month'], $dateInfo['day']) . '</span>';
}
}
$this->assign('label', $label);
}
示例6: renderQuestion
function renderQuestion($userId, $questionName, $label = false)
{
global $QuestionService;
global $language;
global $getConfig;
global $QUESTION_PRESENTATION_SELECT;
global $QUESTION_PRESENTATION_RADIO;
global $QUESTION_PRESENTATION_MULTICHECKBOX;
global $QUESTION_PRESENTATION_URL;
global $QUESTION_PRESENTATION_TEXT;
global $QUESTION_PRESENTATION_TEXTAREA;
global $QUESTION_PRESENTATION_DATE;
global $QUESTION_VALUE_TYPE_DATETIME;
global $QUESTION_VALUE_TYPE_SELECT;
global $QUESTION_PRESENTATION_BIRTHDATE;
global $QUESTION_PRESENTATION_AGE;
global $QUESTION_PRESENTATION_RANGE;
global $MYSQL_DATETIME_DATE_FORMAT;
$questionData = $QuestionService->getQuestionData(array($userId), array($questionName));
if (!isset($questionData[$userId][$questionName])) {
return null;
}
$question = $QuestionService->findQuestionByName($questionName);
switch ($question->presentation) {
case $QUESTION_PRESENTATION_DATE:
$format = $getConfig->getValue('base', 'date_field_format');
$value = 0;
switch ($question->type) {
case $QUESTION_VALUE_TYPE_DATETIME:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], $MYSQL_DATETIME_DATE_FORMAT);
$value = $date;
break;
case $QUESTION_VALUE_TYPE_SELECT:
$value = (int) $questionData[$userId][$question->name];
break;
}
if ($format === 'dmy') {
$questionData[$userId][$question->name] = date("d/m/Y", $value);
} else {
$questionData[$userId][$question->name] = date("m/d/Y", $value);
}
break;
case $QUESTION_PRESENTATION_BIRTHDATE:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], $MYSQL_DATETIME_DATE_FORMAT);
$questionData[$userId][$question->name] = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
break;
case $QUESTION_PRESENTATION_AGE:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], $MYSQL_DATETIME_DATE_FORMAT);
$questionData[$userId][$question->name] = date("Y/m/d", strtotime($date['year'] . "/" . $date['month'] . "/" . $date['day']));
break;
case $QUESTION_PRESENTATION_RANGE:
$range = explode('-', $questionData[$userId][$question->name]);
$questionData[$userId][$question->name] = $language->text('base', 'form_element_from') . " " . $range[0] . " " . $language->text('base', 'form_element_to') . " " . $range[1];
break;
case $QUESTION_PRESENTATION_SELECT:
case $QUESTION_PRESENTATION_RADIO:
case $QUESTION_PRESENTATION_MULTICHECKBOX:
$value = "";
$multicheckboxValue = (int) $questionData[$userId][$question->name];
$questionValues = $QuestionService->findQuestionValues($question->name);
foreach ($questionValues as $val) {
/* @var $val BOL_QuestionValue */
if ((int) $val->value & $multicheckboxValue) {
if ($label == false) {
if (strlen($value) > 0) {
$value .= ',';
}
$value .= $val->value;
//$language->text('base', 'questions_question_' . $question->name . '_value_' . ($val->value));
} else {
if (strlen($value) > 0) {
$value .= ',';
// $value .= '@@';
}
// $QuestionService = $QuestionService;
$value .= $QuestionService->getQuestionValueLang($question->name, $val->value);
//$language->text('base', 'questions_question_' . $question->name . '_value_' . ($val->value));
}
}
}
if (strlen($value) > 0) {
$questionData[$userId][$question->name] = $value;
}
break;
case $QUESTION_PRESENTATION_URL:
case $QUESTION_PRESENTATION_TEXT:
case $QUESTION_PRESENTATION_TEXTAREA:
// googlemap_location shortcut
if ($question->name == "googlemap_location" && !empty($questionData[$userId][$question->name]) && is_array($questionData[$userId][$question->name])) {
$mapData = $questionData[$userId][$question->name];
$value = trim($mapData["address"]);
} else {
$value = trim($questionData[$userId][$question->name]);
}
if (strlen($value) > 0) {
$questionData[$userId][$question->name] = UTIL_HtmlTag::autoLink(nl2br($value));
}
break;
default:
$questionData[$userId][$question->name] = null;
//.........这里部分代码省略.........
示例7: getUserViewQuestions
public function getUserViewQuestions($userId, $adminMode = false, $questionNames = array(), $sectionNames = null)
{
$questionService = BOL_QuestionService::getInstance();
$user = BOL_UserService::getInstance()->findUserById($userId);
$accountType = $user->accountType;
$language = OW::getLanguage();
if (empty($questionNames)) {
if ($adminMode) {
$questions = $questionService->findAllQuestionsForAccountType($accountType);
} else {
$questions = $questionService->findViewQuestionsForAccountType($accountType);
}
} else {
$questions = $questionService->findQuestionByNameList($questionNames);
foreach ($questions as &$q) {
$q = (array) $q;
}
}
$section = null;
$questionArray = array();
$questionNameList = array();
foreach ($questions as $sort => $question) {
if (!empty($sectionNames) && !in_array($question['sectionName'], $sectionNames)) {
continue;
}
if ($section !== $question['sectionName']) {
$section = $question['sectionName'];
}
$questions[$sort]['hidden'] = false;
if (!$questions[$sort]['onView']) {
$questions[$sort]['hidden'] = true;
}
$questionArray[$section][$sort] = $questions[$sort];
$questionNameList[] = $questions[$sort]['name'];
}
$questionData = $questionService->getQuestionData(array($userId), $questionNameList);
$questionLabelList = array();
// add form fields
foreach ($questionArray as $sectionKey => $section) {
foreach ($section as $questionKey => $question) {
$event = new OW_Event('base.questions_field_get_label', array('presentation' => $question['presentation'], 'fieldName' => $question['name'], 'configs' => $question['custom'], 'type' => 'view'));
OW::getEventManager()->trigger($event);
$label = $event->getData();
$questionLabelList[$question['name']] = !empty($label) ? $label : BOL_QuestionService::getInstance()->getQuestionLang($question['name']);
$event = new OW_Event('base.questions_field_get_value', array('presentation' => $question['presentation'], 'fieldName' => $question['name'], 'value' => empty($questionData[$userId][$question['name']]) ? null : $questionData[$userId][$question['name']], 'questionInfo' => $question, 'userId' => $userId));
OW::getEventManager()->trigger($event);
$eventValue = $event->getData();
if (!empty($eventValue)) {
$questionData[$userId][$question['name']] = $eventValue;
continue;
}
if (!empty($questionData[$userId][$question['name']])) {
switch ($question['presentation']) {
case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
if ((int) $questionData[$userId][$question['name']] === 1) {
$questionData[$userId][$question['name']] = OW::getLanguage()->text('base', 'yes');
} else {
unset($questionArray[$sectionKey][$questionKey]);
}
break;
case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
$format = OW::getConfig()->getValue('base', 'date_field_format');
$value = 0;
switch ($question['type']) {
case BOL_QuestionService::QUESTION_VALUE_TYPE_DATETIME:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question['name']], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
if (isset($date)) {
$format = OW::getConfig()->getValue('base', 'date_field_format');
$value = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
}
break;
case BOL_QuestionService::QUESTION_VALUE_TYPE_SELECT:
$value = (int) $questionData[$userId][$question['name']];
break;
}
if ($format === 'dmy') {
$questionData[$userId][$question['name']] = date("d/m/Y", $value);
} else {
$questionData[$userId][$question['name']] = date("m/d/Y", $value);
}
break;
case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question['name']], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$questionData[$userId][$question['name']] = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
break;
case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question['name']], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$questionData[$userId][$question['name']] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']) . " " . $language->text('base', 'questions_age_year_old');
break;
case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
$range = explode('-', $questionData[$userId][$question['name']]);
$questionData[$userId][$question['name']] = $language->text('base', 'form_element_from') . " " . $range[0] . " " . $language->text('base', 'form_element_to') . " " . $range[1];
break;
case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
$value = "";
$multicheckboxValue = (int) $questionData[$userId][$question['name']];
$parentName = $question['name'];
if (!empty($question['parent'])) {
//.........这里部分代码省略.........
示例8: renderQuestion
private function renderQuestion($userId, $questionName)
{
$language = OW::getLanguage();
$questionData = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array($questionName));
if (!isset($questionData[$userId][$questionName])) {
return null;
}
$question = BOL_QuestionService::getInstance()->findQuestionByName($questionName);
switch ($question->presentation) {
/*case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
if ( (int) $questionData[$userId][$question->name] === 1 )
{
$questionData[$userId][$question['name']] = $language->text('base', 'questions_checkbox_value_true');
}
else
{
$questionData[$userId][$question['name']] = $language->text('base', 'questions_checkbox_value_false');
}
break;*/
case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
$format = OW::getConfig()->getValue('base', 'date_field_format');
$value = 0;
switch ($question->type) {
case BOL_QuestionService::QUESTION_VALUE_TYPE_DATETIME:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
if (isset($date)) {
$format = OW::getConfig()->getValue('base', 'date_field_format');
$value = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
}
break;
case BOL_QuestionService::QUESTION_VALUE_TYPE_SELECT:
$value = (int) $questionData[$userId][$question->name];
break;
}
if ($format === 'dmy') {
$questionData[$userId][$question->name] = date("d/m/Y", $value);
} else {
$questionData[$userId][$question->name] = date("m/d/Y", $value);
}
break;
case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$questionData[$userId][$question->name] = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
break;
case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$questionData[$userId][$question->name] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']) . " " . $language->text('base', 'questions_age_year_old');
break;
case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
$range = explode('-', $questionData[$userId][$question->name]);
$questionData[$userId][$question->name] = $language->text('base', 'form_element_from') . " " . $range[0] . " " . $language->text('base', 'form_element_to') . " " . $range[1];
break;
case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
$value = "";
$multicheckboxValue = (int) $questionData[$userId][$question->name];
$questionValues = BOL_QuestionService::getInstance()->findQuestionValues($question->name);
foreach ($questionValues as $val) {
/* @var $val BOL_QuestionValue */
if ((int) $val->value & $multicheckboxValue) {
if (strlen($value) > 0) {
$value .= ', ';
}
$value .= $language->text('base', 'questions_question_' . $question->name . '_value_' . $val->value);
}
}
if (strlen($value) > 0) {
$questionData[$userId][$question->name] = $value;
}
break;
case BOL_QuestionService::QUESTION_PRESENTATION_URL:
case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
// googlemap_location shortcut
if ($question->name == "googlemap_location" && !empty($questionData[$userId][$question->name]) && is_array($questionData[$userId][$question->name])) {
$mapData = $questionData[$userId][$question->name];
$value = trim($mapData["address"]);
} else {
$value = trim($questionData[$userId][$question->name]);
}
if (strlen($value) > 0) {
$questionData[$userId][$question->name] = UTIL_HtmlTag::autoLink(nl2br($value));
}
break;
default:
$questionData[$userId][$question->name] = null;
}
return $questionData[$userId][$question->name];
}
示例9: getQuestionValueForUserList
public function getQuestionValueForUserList(BOL_Question $question, $value)
{
$stringValue = "";
switch ($question->presentation) {
case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
if ((int) $value === 1) {
$stringValue = OW::getLanguage()->text('base', 'yes');
}
break;
case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
$format = OW::getConfig()->getValue('base', 'date_field_format');
$value = 0;
switch ($question->type) {
case BOL_QuestionService::QUESTION_VALUE_TYPE_DATETIME:
$date = UTIL_DateTime::parseDate($value, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
if (isset($date)) {
$stringValue = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
}
break;
case BOL_QuestionService::QUESTION_VALUE_TYPE_SELECT:
$stringValue = (int) $value;
break;
}
if ($format === 'dmy') {
$stringValue = date("d/m/Y", $value);
} else {
$stringValue = date("m/d/Y", $value);
}
break;
case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
$date = UTIL_DateTime::parseDate($value, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$stringValue = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
break;
case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
$date = UTIL_DateTime::parseDate($alue, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$stringValue = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']) . " " . $language->text('base', 'questions_age_year_old');
break;
case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
$range = explode('-', $value);
$stringValue = $language->text('base', 'form_element_from') . " " . $range[0] . " " . $language->text('base', 'form_element_to') . " " . $range[1];
break;
case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
$multicheckboxValue = (int) $value;
$parentName = $question->name;
if (!empty($question->parent)) {
$parent = BOL_QuestionService::getInstance()->findQuestionByName($question->parent);
if (!empty($parent)) {
$parentName = $parent->name;
}
}
$questionValues = BOL_QuestionService::getInstance()->findQuestionValues($parentName);
foreach ($questionValues as $val) {
/* @var $val BOL_QuestionValue */
if ((int) $val->value & $multicheckboxValue) {
$stringValue .= BOL_QuestionService::getInstance()->getQuestionValueLang($val->questionName, $val->value) . ', ';
}
}
if (!empty($stringValue)) {
$stringValue = mb_substr($stringValue, 0, -2);
}
break;
case BOL_QuestionService::QUESTION_PRESENTATION_URL:
case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
if (!is_string($value)) {
break;
}
$value = trim($value);
if (strlen($value) > 0) {
$stringValue = UTIL_HtmlTag::autoLink(nl2br($value));
}
break;
}
return $stringValue;
}
示例10: getUserInfo
private function getUserInfo($userId, $question, $value)
{
$questionName = $question['name'];
$event = new OW_Event('base.questions_field_get_label', array('presentation' => $question['presentation'], 'fieldName' => $questionName, 'configs' => $question['custom'], 'type' => 'view'));
OW::getEventManager()->trigger($event);
$eventData = $event->getData();
$questionLabel = !empty($eventData) ? $eventData : BOL_QuestionService::getInstance()->getQuestionLang($questionName);
$event = new OW_Event('base.questions_field_get_value', array('presentation' => $question['presentation'], 'fieldName' => $questionName, 'value' => $value, 'questionInfo' => $question, 'userId' => $userId));
OW::getEventManager()->trigger($event);
$eventValue = $event->getData();
$questionValue = '';
if (!empty($eventValue)) {
$questionValue = $eventValue;
} else {
switch ($question['presentation']) {
case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
$questionValue = OW::getLanguage()->text('base', (int) $value === 1 ? 'yes' : 'no');
break;
case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
$value = null;
switch ($question['type']) {
case BOL_QuestionService::QUESTION_VALUE_TYPE_DATETIME:
$date = UTIL_DateTime::parseDate($value, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
if (isset($date)) {
$value = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
}
break;
case BOL_QuestionService::QUESTION_VALUE_TYPE_SELECT:
$value = (int) $value;
break;
}
$questionValue = date(OW::getConfig()->getValue('base', 'date_field_format') === 'dmy' ? 'd/m/Y' : 'm/d/Y', $value);
break;
case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
$date = UTIL_DateTime::parseDate($value, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$questionValue = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
break;
case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
$date = UTIL_DateTime::parseDate($value, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$questionValue = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']) . " " . OW::getLanguage()->text('base', 'questions_age_year_old');
break;
case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
$range = explode('-', $value);
$questionValue = OW::getLanguage()->text('base', 'form_element_from') . " " . $range[0] . " " . OW::getLanguage()->text('base', 'form_element_to') . " " . $range[1];
break;
case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
$multicheckboxValue = (int) $value;
$parentName = $question['name'];
if (!empty($question['parent'])) {
$parent = BOL_QuestionService::getInstance()->findQuestionByName($question['parent']);
if (!empty($parent)) {
$parentName = $parent->name;
}
}
static $values = array();
if (!isset($values[$parentName])) {
$values[$parentName] = BOL_QuestionService::getInstance()->findQuestionValues($parentName);
}
$_value = array();
foreach ($values[$parentName] as $val) {
if ((int) $val->value & $multicheckboxValue) {
$_value[] = BOL_QuestionService::getInstance()->getQuestionValueLang($val->questionName, $val->value);
}
}
$questionValue = $_value;
break;
default:
$questionValue = strip_tags(trim((string) $value));
break;
}
}
return array('label' => $questionLabel, 'value' => $questionValue);
}
示例11: getUserListFields
public function getUserListFields(OW_Event $e)
{
$params = $e->getParams();
$list = !empty($params['list']) ? $params['list'] : null;
$userIdList = !empty($params['userIdList']) ? $params['userIdList'] : null;
if (empty($userIdList)) {
return;
}
$fieldsList = array();
$qBirthdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate');
if ($qBirthdate->onView) {
$fieldsList[] = 'birthdate';
}
$qSex = BOL_QuestionService::getInstance()->findQuestionByName('sex');
if ($qSex->onView) {
$fieldsList[] = 'sex';
}
$questionList = BOL_QuestionService::getInstance()->findQuestionByNameList($fieldsList);
$qData = BOL_QuestionService::getInstance()->getQuestionData($userIdList, $fieldsList);
$data = $e->getData();
foreach ($userIdList as $userId) {
$questionsData = $qData[$userId];
$age = '';
if (!empty($questionsData['birthdate'])) {
$date = UTIL_DateTime::parseDate($questionsData['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
}
$sexValue = '';
if (!empty($questionsData['sex'])) {
$sexValue = BOL_QuestionService::getInstance()->getQuestionValueForUserList($questionList['sex'], $questionsData['sex']);
}
if (!empty($sexValue) && !empty($age)) {
$data[$userId][] = $sexValue . ' ' . $age;
}
switch ($list) {
case "birthdays":
if (!empty($questionsData['birthdate']) && $list == 'birthdays') {
$dinfo = date_parse($questionsData['birthdate']);
$birthdate = '';
if (intval(date('d')) + 1 == intval($dinfo['day'])) {
$birthday = OW::getLanguage()->text('base', 'date_time_tomorrow');
$birthdate = '<a href="#" class="ow_lbutton ow_green">' . $birthday . '</a>';
} else {
if (intval(date('d')) == intval($dinfo['day'])) {
$birthday = OW::getLanguage()->text('base', 'date_time_today');
$birthdate = '<a href="#" class="ow_lbutton ow_green">' . $birthday . '</a>';
} else {
$birthdate = UTIL_DateTime::formatBirthdate($dinfo['year'], $dinfo['month'], $dinfo['day']);
}
}
$data[$userId][] = OW::getLanguage()->text('birthdays', 'birthday') . ":" . $birthdate;
}
break;
}
}
$e->setData($data);
}