本文整理汇总了PHP中UTIL_DateTime::formatSimpleDate方法的典型用法代码示例。如果您正苦于以下问题:PHP UTIL_DateTime::formatSimpleDate方法的具体用法?PHP UTIL_DateTime::formatSimpleDate怎么用?PHP UTIL_DateTime::formatSimpleDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTIL_DateTime
的用法示例。
在下文中一共展示了UTIL_DateTime::formatSimpleDate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Default action
*/
public function index()
{
$language = OW::getLanguage();
$giftsService = VIRTUALGIFTS_BOL_VirtualGiftsService::getInstance();
$page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
$perPage = $giftsService->getGiftsPerPageConfig();
$gifts = $giftsService->findUserReceivedGifts(OW::getUser()->getId(), $page, $perPage, false);
$toolbars = array();
if ($gifts) {
$users = array();
foreach ($gifts as $gift) {
if (!in_array($gift['dto']->senderId, $users)) {
array_push($users, $gift['dto']->senderId);
}
}
$avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($users);
$this->assign('avatars', $avatars);
foreach ($gifts as $gift) {
$giftId = $gift['dto']->id;
$senderId = $gift['dto']->senderId;
$toolbars[$giftId][] = array('class' => 'ow_icon_control ow_ic_user', 'href' => isset($avatars[$senderId]['url']) ? $avatars[$senderId]['url'] : null, 'label' => isset($avatars[$senderId]['title']) ? $avatars[$senderId]['title'] : null);
if ($gift['dto']->private) {
$toolbars[$giftId][] = array('title' => $language->text('virtualgifts', 'private_gift_note'), 'label' => $language->text('virtualgifts', 'private_gift'));
}
$toolbars[$giftId][] = array('label' => UTIL_DateTime::formatSimpleDate($gift['dto']->sendTimestamp));
}
}
$this->assign('gifts', $gifts);
$this->assign('toolbars', $toolbars);
$total = $giftsService->countUserReceivedGifts(OW::getUser()->getId(), false);
$pages = (int) ceil($total / $perPage);
$paging = new BASE_CMP_Paging($page, $pages, 10);
$this->assign('paging', $paging->render());
$this->setPageHeading(OW::getLanguage()->text('virtualgifts', 'my_gifts'));
$this->setPageHeadingIconClass('ow_ic_heart');
OW::getDocument()->setTitle($language->text('virtualgifts', 'meta_title_my_gifts'));
OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'base', 'dashboard');
$url = OW::getPluginManager()->getPlugin('virtualgifts')->getStaticCssUrl() . 'style.css';
OW::getDocument()->addStyleSheet($url);
}
示例2: generatePhotoList
public function generatePhotoList($photos)
{
$unique = uniqid(time(), true);
if ($photos) {
foreach ($photos as $key => $photo) {
$entityIdList[] = $photo->id;
$photos[$key]->title = UTIL_HtmlTag::autoLink($photos[$key]->title);
$photos[$key]->unique = $unique;
$photos[$key]->addDatetime = UTIL_DateTime::formatSimpleDate($photos[$key]->addDatetime, true);
}
}
return array('status' => 'success', 'data' => array('photoList' => $photos, 'unique' => $unique));
}
示例3: getListingDataWithToolbar
/**
* Prepares data for ipc listing with toolbar.
*
* @param array<EVENT_BOL_Event> $events
* @return array
*/
public function getListingDataWithToolbar(array $events, $toolbarList = array())
{
$resultArray = $this->getListingData($events);
$userService = BOL_UserService::getInstance();
$idArray = array();
/* @var $event EVENT_BOL_Event */
foreach ($events as $event) {
$idArray[] = $event->getUserId();
}
$usernames = $userService->getDisplayNamesForList($idArray);
$urls = $userService->getUserUrlsForList($idArray);
$language = OW::getLanguage();
/* @var $eventItem EVENT_BOL_Event */
foreach ($events as $eventItem) {
$resultArray[$eventItem->getId()]['toolbar'][] = array('label' => $usernames[$eventItem->getUserId()], 'href' => $urls[$eventItem->getUserId()], 'class' => 'ow_icon_control ow_ic_user');
$resultArray[$eventItem->getId()]['toolbar'][] = array('label' => UTIL_DateTime::formatSimpleDate($eventItem->getStartTimeStamp(), $eventItem->getStartTimeDisable()), 'class' => 'ow_ipc_date');
if (!empty($toolbarList[$eventItem->getId()])) {
$resultArray[$eventItem->getId()]['toolbar'] = array_merge($resultArray[$eventItem->getId()]['toolbar'], $toolbarList[$eventItem->getId()]);
}
/* if( !empty($isInviteList) )
{
$resultArray[$eventItem->getId()]['toolbar'][] = array('label' => $language->text('event', 'ignore_request'),'href' => 'event.invite_acept');
$resultArray[$eventItem->getId()]['toolbar'][] = array('label' => $language->text('event', 'accept_request'),'href' => 'event.invite_decline');
}*/
}
//printVar($resultArray);
return $resultArray;
}
示例4: formatDate
public static function formatDate(array $params, $smarty)
{
$timeStamp = (int) $params['timestamp'];
$onlyDate = null;
if (!$timeStamp) {
return '_INVALID_TS_';
}
if (!(bool) OW::getConfig()->getValue('base', 'site_use_relative_time')) {
return UTIL_DateTime::formatSimpleDate($timeStamp, $onlyDate);
}
$language = OW::getLanguage();
$militaryTime = (bool) OW::getConfig()->getValue('base', 'military_time');
$currentTs = time();
$isCurrentDay = date('j', $timeStamp) === date('j', $currentTs);
$isCurrentMonth = date('n', $timeStamp) === date('n', $currentTs);
$isCurrentYear = date('Y', $timeStamp) === date('Y', $currentTs);
$isTomorrow = date('j', $timeStamp) - date('j', $currentTs) === 1;
$isYesterday = date('j', $currentTs) - date('j', $timeStamp) === 1;
if ($isCurrentMonth && $isCurrentYear) {
if ($isCurrentDay) {
if ($onlyDate) {
return $language->text('base', 'date_time_today');
}
$seconds = $currentTs - $timeStamp;
$past = $seconds >= 0;
$seconds = abs($seconds);
switch (true) {
case $seconds < 60:
return $language->text('base', 'date_time_within_one_minute');
case $seconds < 120:
return $past ? $language->text('base', 'date_time_one_minute_ago') : $language->text('membership', 'date_time_in_one_minute');
case $seconds < 3600:
$data = array('minutes' => floor($seconds / 60));
return $past ? $language->text('base', 'date_time_minutes_ago', $data) : $language->text('membership', 'date_time_in_minutes', $data);
case $seconds < 7200:
return $past ? $language->text('base', 'date_time_one_hour_ago') : $language->text('membership', 'date_time_in_one_hour');
default:
$data = array('hours' => floor($seconds / 3600));
return $past ? $language->text('base', 'date_time_hours_ago', $data) : $language->text('membership', 'date_time_in_hours', $data);
}
} else {
if ($isYesterday) {
if ($onlyDate) {
return $language->text('base', 'date_time_yesterday');
}
return $language->text('base', 'date_time_yesterday') . ', ' . ($militaryTime ? strftime("%H:%M", $timeStamp) : strftime("%I:%M%p", $timeStamp));
} else {
if ($isTomorrow) {
if ($onlyDate) {
return $language->text('membership', 'date_time_tomorrow');
}
return $language->text('membership', 'date_time_tomorrow') . ', ' . ($militaryTime ? strftime("%H:%M", $timeStamp) : strftime("%I:%M%p", $timeStamp));
}
}
}
}
if ($onlyDate === null) {
$onlyDate = true;
}
return UTIL_DateTime::formatSimpleDate($timeStamp, $onlyDate);
}
示例5: view
/**
* View event controller
*
* @param array $params
*/
public function view($params)
{
$event = $this->getEventForParams($params);
$cmpId = UTIL_HtmlTag::generateAutoId('cmp');
$this->assign('contId', $cmpId);
if (!OW::getUser()->isAuthorized('event', 'view_event') && $event->getUserId() != OW::getUser()->getId()) {
$status = BOL_AuthorizationService::getInstance()->getActionStatus('event', 'view_event');
throw new AuthorizationException($status['msg']);
}
if ($event->status != 1 && !OW::getUser()->isAuthorized('event') && $event->getUserId() != OW::getUser()->getId()) {
throw new Redirect403Exception();
}
// guest gan't view private events
if ((int) $event->getWhoCanView() === EVENT_BOL_EventService::CAN_VIEW_INVITATION_ONLY && !OW::getUser()->isAuthenticated()) {
$this->redirect(OW::getRouter()->urlForRoute('event.private_event', array('eventId' => $event->getId())));
}
$eventInvite = $this->eventService->findEventInvite($event->getId(), OW::getUser()->getId());
$eventUser = $this->eventService->findEventUser($event->getId(), OW::getUser()->getId());
// check if user can view event
if ((int) $event->getWhoCanView() === EVENT_BOL_EventService::CAN_VIEW_INVITATION_ONLY && $eventUser === null && $eventInvite === null && !OW::getUser()->isAuthorized('event')) {
$this->redirect(OW::getRouter()->urlForRoute('event.private_event', array('eventId' => $event->getId())));
}
$buttons = array();
$toolbar = array();
if (OW::getUser()->isAuthorized('event') || OW::getUser()->getId() == $event->getUserId()) {
$buttons = array('edit' => array('url' => OW::getRouter()->urlForRoute('event.edit', array('eventId' => $event->getId())), 'label' => OW::getLanguage()->text('event', 'edit_button_label')), 'delete' => array('url' => OW::getRouter()->urlForRoute('event.delete', array('eventId' => $event->getId())), 'label' => OW::getLanguage()->text('event', 'delete_button_label'), 'confirmMessage' => OW::getLanguage()->text('event', 'delete_confirm_message')));
}
$this->assign('editArray', $buttons);
OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'event', 'main_menu_item');
$moderationStatus = '';
if ($event->status == 2) {
$moderationStatus = " <span class='ow_remark ow_small'>(" . OW::getLanguage()->text('event', 'moderation_status_pending_approval') . ")</span>";
}
$this->setPageHeading($event->getTitle() . $moderationStatus);
$this->setPageTitle(OW::getLanguage()->text('event', 'event_view_page_heading', array('event_title' => $event->getTitle())));
$this->setPageHeadingIconClass('ow_ic_calendar');
OW::getDocument()->setDescription(UTIL_String::truncate(strip_tags($event->getDescription()), 200, '...'));
$infoArray = array('id' => $event->getId(), 'image' => $event->getImage() ? $this->eventService->generateImageUrl($event->getImage(), false) : null, 'date' => UTIL_DateTime::formatSimpleDate($event->getStartTimeStamp(), $event->getStartTimeDisable()), 'endDate' => $event->getEndTimeStamp() === null || !$event->getEndDateFlag() ? null : UTIL_DateTime::formatSimpleDate($event->getEndTimeDisable() ? strtotime("-1 day", $event->getEndTimeStamp()) : $event->getEndTimeStamp(), $event->getEndTimeDisable()), 'location' => $event->getLocation(), 'desc' => UTIL_HtmlTag::autoLink($event->getDescription()), 'title' => $event->getTitle(), 'creatorName' => BOL_UserService::getInstance()->getDisplayName($event->getUserId()), 'creatorLink' => BOL_UserService::getInstance()->getUserUrl($event->getUserId()), 'moderationStatus' => $event->status);
$this->assign('info', $infoArray);
// event attend form
if (OW::getUser()->isAuthenticated() && $event->getEndTimeStamp() > time()) {
if ($eventUser !== null) {
$this->assign('currentStatus', OW::getLanguage()->text('event', 'user_status_label_' . $eventUser->getStatus()));
}
$this->addForm(new AttendForm($event->getId(), $cmpId));
$onloadJs = "\n var \$context = \$('#" . $cmpId . "');\n \$('#event_attend_yes_btn').click(\n function(){\n \$('input[name=attend_status]', \$context).val(" . EVENT_BOL_EventService::USER_STATUS_YES . ");\n }\n );\n \$('#event_attend_maybe_btn').click(\n function(){\n \$('input[name=attend_status]', \$context).val(" . EVENT_BOL_EventService::USER_STATUS_MAYBE . ");\n }\n );\n \$('#event_attend_no_btn').click(\n function(){\n \$('input[name=attend_status]', \$context).val(" . EVENT_BOL_EventService::USER_STATUS_NO . ");\n }\n );\n\n \$('.current_status a', \$context).click(\n function(){\n \$('.attend_buttons .buttons', \$context).fadeIn(500);\n }\n );\n ";
OW::getDocument()->addOnloadScript($onloadJs);
} else {
$this->assign('no_attend_form', true);
}
if ($event->status == EVENT_BOL_EventService::MODERATION_STATUS_ACTIVE && ($event->getEndTimeStamp() > time() && ((int) $event->getUserId() === OW::getUser()->getId() || (int) $event->getWhoCanInvite() === EVENT_BOL_EventService::CAN_INVITE_PARTICIPANT && $eventUser !== null))) {
$params = array($event->id);
$this->assign('inviteLink', true);
OW::getDocument()->addOnloadScript("\n var eventFloatBox;\n \$('#inviteLink', \$('#" . $cmpId . "')).click(\n function(){\n eventFloatBox = OW.ajaxFloatBox('EVENT_CMP_InviteUserListSelect', " . json_encode($params) . ", {width:600, iconClass: 'ow_ic_user', title: " . json_encode(OW::getLanguage()->text('event', 'friends_invite_button_label')) . "});\n }\n );\n OW.bind('base.avatar_user_list_select',\n function(list){\n eventFloatBox.close();\n \$.ajax({\n type: 'POST',\n url: " . json_encode(OW::getRouter()->urlFor('EVENT_CTRL_Base', 'inviteResponder')) . ",\n data: 'eventId=" . json_encode($event->getId()) . "&userIdList='+JSON.stringify(list),\n dataType: 'json',\n success : function(data){\n if( data.messageType == 'error' ){\n OW.error(data.message);\n }\n else{\n OW.info(data.message);\n }\n },\n error : function( XMLHttpRequest, textStatus, errorThrown ){\n OW.error(textStatus);\n }\n });\n }\n );\n ");
}
if ($event->status == EVENT_BOL_EventService::MODERATION_STATUS_ACTIVE) {
$cmntParams = new BASE_CommentsParams('event', 'event');
$cmntParams->setEntityId($event->getId());
$cmntParams->setOwnerId($event->getUserId());
$this->addComponent('comments', new BASE_CMP_Comments($cmntParams));
}
$this->addComponent('userListCmp', new EVENT_CMP_EventUsers($event->getId()));
$event = new BASE_CLASS_EventCollector(EVENT_BOL_EventService::EVENT_COLLECT_TOOLBAR, array("event" => $event));
OW::getEventManager()->trigger($event);
$this->assign("toolbar", $event->getData());
}
示例6: userGifts
public function userGifts(array $params)
{
if (empty($params['userName']) || !($user = BOL_UserService::getInstance()->findByUsername($params['userName']))) {
throw new Redirect404Exception();
}
$giftService = VIRTUALGIFTS_BOL_VirtualGiftsService::getInstance();
$perPage = $giftService->getGiftsPerPageConfig();
$page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
$gifts = $giftService->findUserReceivedGifts($user->id, $page, $perPage, true);
$toolbars = array();
if ($gifts) {
$users = array();
foreach ($gifts as $gift) {
if (!in_array($gift['dto']->senderId, $users)) {
array_push($users, $gift['dto']->senderId);
}
}
$avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($users);
$this->assign('avatars', $avatars);
foreach ($gifts as $gift) {
$giftId = $gift['dto']->id;
$toolbars[$giftId][] = array('label' => UTIL_DateTime::formatSimpleDate($gift['dto']->sendTimestamp));
}
}
$this->assign('gifts', $gifts);
$this->assign('toolbars', $toolbars);
$total = $giftService->countUserReceivedGifts($user->id, true);
// Paging
$pages = (int) ceil($total / $perPage);
$paging = new BASE_CMP_Paging($page, $pages, 10);
$this->assign('paging', $paging->render());
$displayName = BOL_UserService::getInstance()->getDisplayName($user->id);
$this->setPageHeading(OW::getLanguage()->text('virtualgifts', 'user_gifts', array('user' => $displayName)));
$this->setPageHeadingIconClass('ow_ic_heart');
OW::getDocument()->setTitle(OW::getLanguage()->text('virtualgifts', 'meta_title_user_gifts', array('recipient' => $displayName)));
OW::getDocument()->setDescription(OW::getLanguage()->text('virtualgifts', 'meta_description_user_gifts', array('recipient' => $displayName)));
OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'base', 'dashboard');
$url = OW::getPluginManager()->getPlugin('virtualgifts')->getStaticCssUrl() . 'style.css';
OW::getDocument()->addStyleSheet($url);
}
示例7: smarty_modifier_simple_date
/**
* Smarty simple date modifier.
*
* @author Sardar Madumarov <madumarov@gmail.com>
* @package ow.ow_smarty.plugin
* @since 1.0
*/
function smarty_modifier_simple_date($timeStamp, $dateOnly = false)
{
return UTIL_DateTime::formatSimpleDate($timeStamp, $dateOnly);
}