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


PHP UTIL_DateTime::getAge方法代码示例

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


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

示例1: __construct

 public function __construct($userId, $idList)
 {
     parent::__construct();
     if (!empty($userId) && !empty($idList)) {
         $this->user = BOL_UserService::getInstance()->findUserById($userId);
         $userService = BOL_UserService::getInstance();
         $avatars = BOL_AvatarService::getInstance()->getAvatarsUrlList($idList, 2);
         $sexValue = array();
         $list = array();
         foreach (BOL_QuestionValueDao::getInstance()->findQuestionValues('sex') as $sexDto) {
             $sexValue[$sexDto->value] = BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $sexDto->value);
         }
         $userData = BOL_QuestionService::getInstance()->getQuestionData($idList, array('sex', 'birthdate', 'googlemap_location'));
         foreach ($idList as $userId) {
             $list[$userId]['userUrl'] = $userService->getUserUrl($userId);
             $list[$userId]['displayName'] = $userService->getDisplayName($userId);
             $list[$userId]['avatarUrl'] = $avatars[$userId];
             $list[$userId]['activity'] = UTIL_DateTime::formatDate(BOL_UserService::getInstance()->findUserById($userId)->getActivityStamp());
             if (!empty($userData[$userId]['birthdate'])) {
                 $date = UTIL_DateTime::parseDate($userData[$userId]['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                 $list[$userId]['age'] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
             }
             if (!empty($userData[$userId]['sex'])) {
                 $list[$userId]['sex'] = $sexValue[$userData[$userId]['sex']];
             }
             if (!empty($userData[$userId]['googlemap_location'])) {
                 $list[$userId]['googlemap_location'] = $userData[$userId]['googlemap_location']['address'];
             }
         }
         $this->assign('userName', BOL_UserService::getInstance()->getDisplayName($this->user->id));
         $this->assign('list', $list);
     } else {
         $this->setVisible(FALSE);
     }
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:35,代码来源:notify.php

示例2: 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;
 }
开发者ID:tammyrocks,项目名称:birthdays,代码行数:29,代码来源:avatar_user_list.php

示例3: getInfoList

 protected function getInfoList($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 => $q) {
         $info = array();
         if (!empty($q['sex'])) {
             $info['sex'] = BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $q['sex']);
         }
         if (!empty($q['birthdate'])) {
             $date = UTIL_DateTime::parseDate($q['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
             $info['age'] = $age;
         }
         $fields[$uid] = $info;
     }
     return $fields;
 }
开发者ID:vazahat,项目名称:dudex,代码行数:27,代码来源:abstract_user_bridge.php

示例4: __construct

 public function __construct($users, $size, $layout)
 {
     parent::__construct();
     $questionService = BOL_QuestionService::getInstance();
     $userService = BOL_UserService::getInstance();
     $this->uniqId = uniqid('ucl_');
     $idList = $this->fetchIdList($users);
     $qList = $questionService->getQuestionData($idList, array('sex', 'birthdate'));
     $displayNames = $userService->getDisplayNamesForList($idList);
     $urls = $userService->getUserUrlsForList($idList);
     $tplData = array();
     foreach ($idList as $userId) {
         $tplData[$userId] = array();
         $tplData[$userId]['displayName'] = empty($displayNames[$userId]) ? null : $displayNames[$userId];
         $tplData[$userId]['url'] = empty($urls[$userId]) ? null : $urls[$userId];
         $tplData[$userId]['sex'] = empty($qList[$userId]['sex']) || in_array($layout, array(3, 4)) ? null : strtolower(BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $qList[$userId]['sex']));
         $tplData[$userId]['birthdate'] = null;
         if (!empty($qList[$userId]['birthdate']) && in_array($layout, array(1, 3))) {
             $date = UTIL_DateTime::parseDate($qList[$userId]['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
             $tplData[$userId]['birthdate'] = $age;
         }
         $avatar = BOL_AvatarService::getInstance()->getAvatarUrl($userId, 2);
         $tplData[$userId]['thumb'] = $avatar ? $avatar : BOL_AvatarService::getInstance()->getDefaultAvatarUrl(2);
     }
     $sizes = array('small' => 100, 'medium' => 150, 'big' => OW::getConfig()->getValue('base', 'avatar_big_size'));
     $this->assign('list', $tplData);
     $avatarSize = $sizes[$size];
     $this->assign('size', $size);
     $this->assign('uniqId', $this->uniqId);
     OW::getDocument()->addStyleDeclaration('.uc-avatar-size { width: ' . $avatarSize . 'px; height: ' . ($avatarSize + $avatarSize / 10) . 'px; }');
     OW::getDocument()->addStyleDeclaration('.uc-carousel-size { height: ' . ($avatarSize + 50) . 'px; }');
     OW::getDocument()->addStyleDeclaration('.uc-shape-waterWheel .uc-carousel { width: ' . ($avatarSize + 20) . 'px; }');
 }
开发者ID:vazahat,项目名称:dudex,代码行数:34,代码来源:users.php

示例5: getList

 public function getList($params)
 {
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $auth = array('photo.view' => $service->getAuthorizationActionStatus('photo', 'view'), 'base.search_users' => $service->getAuthorizationActionStatus('base', 'search_users'));
     $this->assign('auth', $auth);
     if ($auth["base.search_users"]["status"] != BOL_AuthorizationService::STATUS_AVAILABLE) {
         $this->assign("list", array());
         $this->assign("total", 0);
         return;
     }
     $_criteriaList = array_filter($params["criteriaList"]);
     $userId = OW::getUser()->getId();
     $userInfo = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array("sex"));
     $_criteriaList["sex"] = !empty($userInfo[$userId]["sex"]) ? $userInfo[$userId]["sex"] : null;
     $questionList = BOL_QuestionService::getInstance()->findQuestionByNameList(array_keys($_criteriaList));
     $criteriaList = array();
     foreach ($_criteriaList as $questionName => $questionValue) {
         if (empty($questionList[$questionName])) {
             continue;
         }
         $criteriaList[$questionName] = $this->convertQuestionValue($questionList[$questionName]->presentation, $questionValue);
     }
     $idList = OW::getEventManager()->call("usearch.get_user_id_list", array("criterias" => $criteriaList, "limit" => array($params["first"], $params["count"])));
     $idList = empty($idList) ? array() : $idList;
     //$idList = BOL_UserService::getInstance()->findUserIdListByQuestionValues($criteriaList, $params["first"], $params["count"]);
     $total = BOL_UserService::getInstance()->countUsersByQuestionValues($params["criteriaList"]);
     $userData = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, false, false, true, true);
     $questionsData = BOL_QuestionService::getInstance()->getQuestionData($idList, array("googlemap_location", "birthdate"));
     foreach ($questionsData as $userId => $data) {
         $date = UTIL_DateTime::parseDate($data['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
         $userData[$userId]["ages"] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         $userData[$userId]["location"] = empty($data["googlemap_location"]["address"]) ? null : $data["googlemap_location"]["address"];
     }
     $photoList = array();
     $avatarList = array();
     foreach ($idList as $userId) {
         $bigAvatar = SKADATE_BOL_Service::getInstance()->findAvatarByUserId($userId);
         $avatarList[$userId] = $bigAvatar ? SKADATE_BOL_Service::getInstance()->getAvatarUrl($userId, $bigAvatar->hash) : BOL_AvatarService::getInstance()->getAvatarUrl($userId, 2);
         $event = new OW_Event('photo.getMainAlbum', array('userId' => $userId));
         OW::getEventManager()->trigger($event);
         $album = $event->getData();
         $photos = !empty($album['photoList']) ? $album['photoList'] : array();
         foreach ($photos as $photo) {
             $photoList[$userId][] = array("src" => $photo["url"]["main"]);
         }
     }
     $bookmarksList = OW::getEventManager()->call("bookmarks.get_mark_list", array("userId" => OW::getUser()->getId(), "idList" => $idList));
     $bookmarksList = empty($bookmarksList) ? array() : $bookmarksList;
     $list = array();
     foreach ($idList as $userId) {
         $list[] = array("userId" => $userId, "photos" => empty($photoList[$userId]) ? array() : $photoList[$userId], "avatar" => $avatarList[$userId], "name" => empty($userData[$userId]["title"]) ? "" : $userData[$userId]["title"], "label" => $userData[$userId]["label"], "labelColor" => $userData[$userId]["labelColor"], "location" => empty($userData[$userId]["location"]) ? "" : $userData[$userId]["location"], "ages" => $userData[$userId]["ages"], "bookmarked" => !empty($bookmarksList[$userId]));
     }
     $this->assign("list", $list);
     $this->assign("total", $total);
     $allowSendMessage = OW::getPluginManager()->isPluginActive('mailbox');
     $this->assign("actions", array("bookmark" => OW::getPluginManager()->isPluginActive('bookmarks'), "message" => $allowSendMessage, "wink" => OW::getPluginManager()->isPluginActive('winks')));
     BOL_AuthorizationService::getInstance()->trackAction("base", "search_users");
     $mailboxModes = OW::getEventManager()->call('mailbox.get_active_mode_list');
     $this->assign("mailboxModes", empty($mailboxModes) ? array() : $mailboxModes);
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:60,代码来源:search.php

示例6: 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 => $q) {
         $fields[$uid] = array();
         $age = '';
         if (!empty($q['birthdate'])) {
             $date = UTIL_DateTime::parseDate($q['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         }
         if (!empty($q['sex'])) {
             $fields[$uid][] = array('label' => '', 'value' => BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $q['sex']) . ' ' . $age);
         }
         if (!empty($q['birthdate'])) {
             $dinfo = date_parse($q['birthdate']);
         }
     }
     return $fields;
 }
开发者ID:vazahat,项目名称:dudex,代码行数:29,代码来源:floatbox_user_list.php

示例7: getList

 public function getList(array $params)
 {
     OW::getDocument()->setHeading(OW::getLanguage()->text('bookmarks', 'list_headint_title'));
     $this->setTemplate(OW::getPluginManager()->getPlugin('bookmarks')->getCtrlViewDir() . 'list.html');
     $userId = OW::getUser()->getId();
     $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? $_GET['page'] : 1;
     $userOnPage = (int) OW::getConfig()->getValue('base', 'users_on_page');
     $first = ($page - 1) * $userOnPage;
     $list = $this->service->findBookmarksUserIdList($userId, $first, $userOnPage, $params['category']);
     $count = $this->service->findBookmarksCount($userId, $params['category']);
     $sexValue = array();
     $userDataList = array();
     $questionService = BOL_QuestionService::getInstance();
     $data = $questionService->getQuestionData($list, array('sex', 'googlemap_location', 'birthdate'));
     foreach (BOL_QuestionValueDao::getInstance()->findQuestionValues('sex') as $sexDto) {
         $sexValue[$sexDto->value] = $questionService->getQuestionValueLang('sex', $sexDto->value);
     }
     foreach ($data as $userId => $user) {
         if (isset($user['birthdate'])) {
             $date = UTIL_DateTime::parseDate($user['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         } else {
             $age = '';
         }
         $userDataList[$userId] = array('info_gender' => !empty($user['sex']) && !empty($sexValue[$user['sex']]) ? $sexValue[$user['sex']] : '' . ' ' . $age, 'location' => !empty($user['googlemap_location']) ? $user['googlemap_location']['address'] : '');
     }
     $this->addComponent('list', OW::getClassInstance('BASE_CMP_Users', $userDataList, array(), $count));
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:28,代码来源:list.php

示例8: 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;
 }
开发者ID:vazahat,项目名称:dudex,代码行数:57,代码来源:base_user_list.php

示例9: getList

 public function getList($params)
 {
     $sort = empty($params["sort"]) ? "newest" : $params["sort"];
     $matchList = OW::getEventManager()->call("matchmaking.get_list", array("userId" => OW::getUser()->getId(), "sort" => $sort, "first" => empty($params["first"]) ? 0 : $params["first"], "count" => empty($params["count"]) ? 0 : $params["count"]));
     $idList = array();
     $compatibilityList = array();
     foreach ($matchList as $item) {
         $idList[] = $item["id"];
         $compatibilityList[$item["id"]] = $item["compatibility"];
     }
     $userData = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, false, false, true, true);
     $questionsData = BOL_QuestionService::getInstance()->getQuestionData($idList, array("googlemap_location", "birthdate"));
     foreach ($questionsData as $userId => $data) {
         $date = UTIL_DateTime::parseDate($data['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
         $userData[$userId]["ages"] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         $userData[$userId]["location"] = empty($data["googlemap_location"]["address"]) ? null : $data["googlemap_location"]["address"];
     }
     $photoList = array();
     $avatarList = array();
     foreach ($idList as $userId) {
         $bigAvatar = SKADATE_BOL_Service::getInstance()->findAvatarByUserId($userId);
         $avatarList[$userId] = $bigAvatar ? SKADATE_BOL_Service::getInstance()->getAvatarUrl($userId, $bigAvatar->hash) : BOL_AvatarService::getInstance()->getAvatarUrl($userId, 2);
         $event = new OW_Event('photo.getMainAlbum', array('userId' => $userId));
         OW::getEventManager()->trigger($event);
         $album = $event->getData();
         $photos = !empty($album['photoList']) ? $album['photoList'] : array();
         $photoList[$userId] = array();
         foreach ($photos as $photo) {
             $photoList[$userId][] = array("src" => $photo["url"]["main"]);
         }
     }
     $bookmarksList = OW::getEventManager()->call("bookmarks.get_mark_list", array("userId" => OW::getUser()->getId(), "idList" => $idList));
     $bookmarksList = empty($bookmarksList) ? array() : $bookmarksList;
     $list = array();
     foreach ($idList as $userId) {
         $list[] = array("userId" => $userId, "photos" => $photoList[$userId], "avatar" => $avatarList[$userId], "name" => empty($userData[$userId]["title"]) ? "" : $userData[$userId]["title"], "label" => $userData[$userId]["label"], "labelColor" => $userData[$userId]["labelColor"], "compatibility" => $compatibilityList[$userId], "location" => empty($userData[$userId]["location"]) ? "" : $userData[$userId]["location"], "ages" => $userData[$userId]["ages"], "bookmarked" => !empty($bookmarksList[$userId]));
     }
     $this->assign("list", $list);
     $total = OW::getEventManager()->call("matchmaking.get_list_count", array("userId" => OW::getUser()->getId()));
     $this->assign("total", $total);
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $auth = array('photo.view' => $service->getAuthorizationActionStatus('photo', 'view'));
     $this->assign('auth', $auth);
     $allowSendMessage = OW::getPluginManager()->isPluginActive('mailbox');
     $this->assign("actions", array("bookmark" => OW::getPluginManager()->isPluginActive('bookmarks'), "message" => $allowSendMessage, "wink" => OW::getPluginManager()->isPluginActive('winks')));
     $mailboxModes = OW::getEventManager()->call('mailbox.get_active_mode_list');
     $this->assign("mailboxModes", empty($mailboxModes) ? array() : $mailboxModes);
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:48,代码来源:matches.php

示例10: getFields

 public function getFields($userIdList)
 {
     $lang = OW::getLanguage();
     $fields = array();
     $qs = array();
     $qBdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate', 'sex');
     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);
         }
         $fields[$uid][] = array('label' => ' ', 'value' => $this->guests[$uid]['last_visit']);
     }
     return $fields;
 }
开发者ID:hardikamutech,项目名称:hammu,代码行数:41,代码来源:users.php

示例11: 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'])) {
//.........这里部分代码省略.........
开发者ID:vBulleteen,项目名称:oxwall,代码行数:101,代码来源:user_service.php

示例12: 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];
 }
开发者ID:jorgemunoz8807,项目名称:havanabook,代码行数:92,代码来源:base_bridge.php

示例13: getFields

 public function getFields($userIdList)
 {
     $fields = array();
     foreach ($userIdList as $userId) {
         $fields[$userId] = '';
     }
     $qs = array();
     $qs[] = 'username';
     $questionName = OW::getConfig()->getValue('base', 'display_name_question');
     $qs[] = $questionName;
     $qBdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate');
     if ($qBdate->onView) {
         $qs[] = 'birthdate';
     }
     $qSex = BOL_QuestionService::getInstance()->findQuestionByName('sex');
     if ($qSex->onView) {
         $qs[] = 'sex';
     }
     $qLocation = BOL_QuestionService::getInstance()->findQuestionByName('googlemap_location');
     if ($qLocation) {
         if ($qLocation->onView) {
             $qs[] = 'googlemap_location';
         }
     }
     $questionList = BOL_QuestionService::getInstance()->getQuestionData($userIdList, $qs);
     foreach ($questionList as $userId => $question) {
         $userFields = array();
         $fields[$userId] = isset($question[$questionName]) ? "<b>" . $question[$questionName] . "</b>" : "<b>" . $question['username'] . "</b>";
         $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)) {
                 $userFields['sex'] = substr($sexValue, 0, -2);
                 $fields[$userId] .= "<br/>" . $userFields['sex'];
             }
         }
         if (!empty($question['birthdate'])) {
             $date = UTIL_DateTime::parseDate($question['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $userFields['age'] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
             $fields[$userId] .= "<br/>" . $userFields['age'];
         }
         if (!empty($question['googlemap_location'])) {
             $userFields['googlemap_location'] = !empty($question['googlemap_location']['address']) ? $question['googlemap_location']['address'] : '';
             $fields[$userId] .= "<br/>" . $userFields['googlemap_location'];
         }
     }
     return $fields;
 }
开发者ID:tammyrocks,项目名称:mailbox,代码行数:54,代码来源:conversation_service.php

示例14: getFieldsForEmail

 public function getFieldsForEmail($userId)
 {
     $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';
     }
     $qLocation = BOL_QuestionService::getInstance()->findQuestionByName('googlemap_location');
     if ($qLocation->onView) {
         $qs[] = 'googlemap_location';
     }
     $questionList = BOL_QuestionService::getInstance()->getQuestionData(array($userId), $qs);
     $question = $questionList[$userId];
     if (!empty($question['birthdate'])) {
         $date = UTIL_DateTime::parseDate($question['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
         $fields['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)) {
             $fields['sex'] = substr($sexValue, 0, -2);
         }
     }
     if (!empty($question['googlemap_location'])) {
         $fields['googlemap_location'] = $question['googlemap_location']['address'];
     }
     return $fields;
 }
开发者ID:bhushansonar,项目名称:hammu,代码行数:40,代码来源:service.php

示例15: prepareQuestionWhere

 /**
  * @param BOL_Question $question
  * @param $value
  * @param string $prefix
  * @return array|string
  */
 private function prepareQuestionWhere(BOL_Question $question, $value, $prefix = '')
 {
     $result = '';
     $prefix = $this->dbo->escapeString($prefix);
     switch ($question->presentation) {
         case BOL_QuestionService::QUESTION_PRESENTATION_URL:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
             if ($question->base) {
                 $result = ' `user`.`' . $this->dbo->escapeString($question->name) . '` LIKE \'' . $this->dbo->escapeString($value) . '%\'';
             } else {
                 $result = " LCASE(`" . $prefix . "`.`textValue`) LIKE '" . $this->dbo->escapeString(strtolower($value)) . "%'";
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
             if ($question->base) {
                 $result = ' `user`.`' . $this->dbo->escapeString($question->name) . '` = ' . (bool) $value;
             } else {
                 $result = " `" . $prefix . "`.`intValue` = " . (bool) $value;
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
             if ($question->base) {
                 $result = ' `user`.`' . $this->dbo->escapeString($question->name) . '` & ' . $value . ' ';
             } else {
                 $result = ' `' . $this->dbo->escapeString($prefix) . '`.`intValue` & ' . $value . ' ';
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
         case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
             $questionValues = BOL_QuestionService::getInstance()->findQuestionValues($question->name);
             if (!empty($questionValues)) {
                 $result = array();
                 foreach ($questionValues as $val) {
                     if ((bool) ($val->value & (int) $value)) {
                         $result[] = $val->value;
                     }
                 }
                 $value = $result;
             }
             if (isset($value) && is_array($value) && !empty($value)) {
                 if ($question->base) {
                     $result = ' `user`.`' . $this->dbo->escapeString($question->name) . '` IN ( ' . $this->dbo->mergeInClause($value) . ' ) ';
                 } else {
                     $result = ' `' . $this->dbo->escapeString($prefix) . '`.`intValue` IN ( ' . $this->dbo->mergeInClause($value) . ' ) ';
                 }
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
         case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
         case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
             $value = explode('-', $value);
             $value = array('from' => $value[0], 'to' => $value[1]);
             if (isset($value['from']) && isset($value['to'])) {
                 $maxDate = date('Y') - (int) $value['from'] . '-12-31';
                 $minDate = date('Y') - (int) $value['to'] . '-01-01';
                 if ($question->base) {
                     $result = " `user`.`" . $this->dbo->escapeString($question->name) . "` BETWEEN  '" . $this->dbo->escapeString($minDate) . "' AND '" . $this->dbo->escapeString($maxDate) . "'";
                 } else {
                     $result = " `" . $prefix . "`.`dateValue` BETWEEN  '" . $this->dbo->escapeString($minDate) . "' AND '" . $this->dbo->escapeString($maxDate) . "'";
                 }
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
             $date = UTIL_DateTime::parseDate($value, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $value = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
             if ($question->base) {
                 $result = " " . $value . " BETWEEN SUBSTRING(`user`.`" . $this->dbo->escapeString($question->name) . "`, 1, LOCATE('-', `user`.`" . $this->dbo->escapeString($question->name) . "`)-1 ) AND SUBSTRING(`user`.`" . $this->dbo->escapeString($question->name) . "`, LOCATE('-', `user`.`" . $this->dbo->escapeString($question->name) . "`)+1 ) ";
             } else {
                 $result = " " . $value . " BETWEEN SUBSTRING(`" . $prefix . "`.`textValue`, 1, LOCATE('-', `" . $prefix . "`.`textValue`)-1 ) AND SUBSTRING(`" . $prefix . "`.`textValue`, LOCATE('-', `" . $prefix . "`.`textValue`)+1 )  ";
             }
             break;
     }
     return $result;
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:81,代码来源:question_match_dao.php


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