本文整理匯總了PHP中CBLib\Application\Application::Date方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::Date方法的具體用法?PHP Application::Date怎麽用?PHP Application::Date使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CBLib\Application\Application
的用法示例。
在下文中一共展示了Application::Date方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: cbFormatDate
/**
* Offsets date-time if time is present and $serverTimeOffset 1, then formats to CB's configured date-time format.
*
* @param int|string $date In "Y-m-d H:i:s" format, or int : unix timestamp
* @param boolean $serverTimeOffset False: don't offset, true: offset if time also in $date
* @param bool|string $showTime False don't show time even if time is present in string, timeago: show jquery timeago
* @param null|string $dateFormatOverride Format override for date display
* @param null|string $timeFormatOverride Format override for time display
* @param null|string|int $offsetOverride Offset override for time display
* @return null|string
*/
function cbFormatDate($date, $serverTimeOffset = true, $showTime = true, $dateFormatOverride = null, $timeFormatOverride = null, $offsetOverride = null)
{
global $_CB_framework, $ueConfig;
if ($date == '' || $date == '0000-00-00 00:00:00' || $date == '0000-00-00') {
return null;
}
$dateTime = Application::Date($date, $serverTimeOffset ? $offsetOverride ? $offsetOverride : null : 'UTC');
if ($showTime === 'timeago' || $showTime === 'exacttimeago') {
static $JS_loaded = 0;
if (!$JS_loaded++) {
$js = "\$.fn.cbtimeago.defaults.strings.future = '" . addslashes(CBTxt::T('TIMEAGO_FUTURE', 'in %s')) . "';" . "\$.fn.cbtimeago.defaults.strings.past = '" . addslashes(CBTxt::T('TIMEAGO_PAST', '%s ago')) . "';" . "\$.fn.cbtimeago.defaults.strings.seconds = '" . addslashes(CBTxt::T('TIMEAGO_LESS_THAN_A_MINUTE', 'less than a minute')) . "';" . "\$.fn.cbtimeago.defaults.strings.minute = '" . addslashes(CBTxt::T('TIMEAGO_ABOUT_A_MINUTE', 'about a minute')) . "';" . "\$.fn.cbtimeago.defaults.strings.minutes = '" . addslashes(CBTxt::T('TIMEAGO_N_MINUTES', '%d minutes')) . "';" . "\$.fn.cbtimeago.defaults.strings.hour = '" . addslashes(CBTxt::T('TIMEAGO_ABOUTE_ONE_HOUR', 'about an hour')) . "';" . "\$.fn.cbtimeago.defaults.strings.hours = '" . addslashes(CBTxt::T('TIMEAGO_ABOUT_N_HOURS', 'about %d hours')) . "';" . "\$.fn.cbtimeago.defaults.strings.day = '" . addslashes(CBTxt::T('TIMEAGO_A_DAY', 'a day')) . "';" . "\$.fn.cbtimeago.defaults.strings.days = '" . addslashes(CBTxt::T('TIMEAGO_N_DAYS', '%d days')) . "';" . "\$.fn.cbtimeago.defaults.strings.month = '" . addslashes(CBTxt::T('TIMEAGO_ABOUT_A_MONTH', 'about a month')) . "';" . "\$.fn.cbtimeago.defaults.strings.months = '" . addslashes(CBTxt::T('TIMEAGO_N_MONTHS', '%d months')) . "';" . "\$.fn.cbtimeago.defaults.strings.year = '" . addslashes(CBTxt::T('TIMEAGO_ABOUT A_YEAR', 'about a year')) . "';" . "\$.fn.cbtimeago.defaults.strings.years = '" . addslashes(CBTxt::T('TIMEAGO_N_YEARS', '%d years')) . "';" . "\$( '.cbDateTimeago' ).cbtimeago();";
$_CB_framework->outputCbJQuery($js, 'cbtimeago');
}
$attributes = null;
if ($showTime === 'exacttimeago') {
$attributes .= ' data-cbtimeago-hideago="true"';
}
return '<span class="cbDateTimeago"' . $attributes . ' title="' . htmlspecialchars($dateTime->format('c')) . '"></span>';
} else {
if ($dateFormatOverride || $timeFormatOverride || !$showTime) {
$format = $dateFormatOverride !== null ? $dateFormatOverride : (CBTxt::T('UE_DATE_FORMAT', '') != '' ? CBTxt::T('UE_DATE_FORMAT', '') : $ueConfig['date_format']);
if ($showTime) {
$format .= $timeFormatOverride !== null ? $timeFormatOverride : (CBTxt::T('UE_TIME_FORMAT', '') != '' ? CBTxt::T('UE_TIME_FORMAT', '') : ' ' . (isset($ueConfig['time_format']) ? $ueConfig['time_format'] : 'H:i:s'));
}
} else {
$format = null;
}
return $dateTime->format($format);
}
}
示例2: showEventEdit
/**
* prepare frontend event edit render
*
* @param int $id
* @param UserTable $user
*/
private function showEventEdit( $id, $user )
{
global $_CB_framework;
$row = CBGroupJiveEvents::getEvent( (int) $id );
$isModerator = CBGroupJive::isModerator( $user->get( 'id' ) );
$groupId = $this->input( 'group', null, GetterInterface::INT );
if ( $groupId === null ) {
$group = $row->group();
} else {
$group = CBGroupJive::getGroup( $groupId );
}
$returnUrl = $_CB_framework->pluginClassUrl( $this->_gjPlugin->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) );
if ( ! CBGroupJive::canAccessGroup( $group, $user ) ) {
cbRedirect( $returnUrl, CBTxt::T( 'Group does not exist.' ), 'error' );
} elseif ( ! $isModerator ) {
if ( ( ! $row->get( 'id' ) ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'events' ) ) ) {
cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to schedule an event in this group.' ), 'error' );
} elseif ( $row->get( 'id' ) && ( $user->get( 'id' ) != $row->get( 'user_id' ) ) && ( CBGroupJive::getGroupStatus( $user, $group ) < 2 ) ) {
cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to edit this event.' ), 'error' );
}
}
CBGroupJive::getTemplate( 'event_edit', true, true, $this->element );
$input = array();
$publishedTooltip = cbTooltip( null, CBTxt::T( 'Select publish state of this event. Unpublished events will not be visible to the public.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );
$input['published'] = moscomprofilerHTML::yesnoSelectList( 'published', 'class="form-control"' . $publishedTooltip, (int) $this->input( 'post/published', $row->get( 'published', 1 ), GetterInterface::INT ) );
$titleTooltup = cbTooltip( null, CBTxt::T( 'Input the event title. This is the title that will distinguish this event from others. Suggested to input something to uniquely identify your event.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );
$input['title'] = '<input type="text" id="title" name="title" value="' . htmlspecialchars( $this->input( 'post/title', $row->get( 'title' ), GetterInterface::STRING ) ) . '" class="form-control required" size="35"' . $titleTooltup . ' />';
$event = $_CB_framework->displayCmsEditor( 'event', $this->input( 'post/event', $row->get( 'event' ), GetterInterface::HTML ), '100%', null, 40, 10, false );
$input['event'] = cbTooltip( null, CBTxt::T( 'Input a detailed description about this event.' ), null, null, null, $event, null, 'style="display:block;"' );
$locationTooltup = cbTooltip( null, CBTxt::T( 'Input the location for this event (e.g. My House, The Park, Restaurant Name, etc..).' ), null, null, null, null, null, 'data-hascbtooltip="true"' );
$input['location'] = '<input type="text" id="location" name="location" value="' . htmlspecialchars( $this->input( 'post/location', $row->get( 'location' ), GetterInterface::STRING ) ) . '" class="form-control required" size="35"' . $locationTooltup . ' />';
$addressTooltup = cbTooltip( null, CBTxt::T( 'Optionally input the address for this event or click the map button to attempt to find your current location.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );
$input['address'] = '<input type="text" id="address" name="address" value="' . htmlspecialchars( $this->input( 'post/address', $row->get( 'address' ), GetterInterface::STRING ) ) . '" class="form-control" size="45"' . $addressTooltup . ' />';
$calendars = new cbCalendars( 1 );
$minYear = (int) Application::Date( ( $row->get( 'id' ) ? $row->get( 'start' ) : 'now' ), 'UTC' )->format( 'Y' );
$startTooltup = cbTooltip( null, CBTxt::T( 'Select the date and time this event starts.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );
$input['start'] = $calendars->cbAddCalendar( 'start', null, true, $this->input( 'post/start', $row->get( 'start' ), GetterInterface::STRING ), false, true, $minYear, ( $minYear + 30 ), $startTooltup );
$endTooltup = cbTooltip( null, CBTxt::T( 'Optionally select the end date and time for this event.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );
$input['end'] = $calendars->cbAddCalendar( 'end', null, false, $this->input( 'post/end', $row->get( 'end' ), GetterInterface::STRING ), false, true, $minYear, ( $minYear + 30 ), $endTooltup );
$limitTooltip = cbTooltip( null, CBTxt::T( 'Optionally input a guest limit for this event.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );
$input['limit'] = '<input type="text" id="limit" name="limit" value="' . (int) $this->input( 'post/limit', $row->get( 'limit' ), GetterInterface::INT ) . '" class="digits form-control" size="6"' . $limitTooltip . ' />';
$ownerTooltip = cbTooltip( null, CBTxt::T( 'Input the event owner id. Event owner determines the creator of the event specified as User ID.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );
$input['user_id'] = '<input type="text" id="user_id" name="user_id" value="' . (int) $this->input( 'post/user_id', $this->input( 'user', $row->get( 'user_id', $user->get( 'id' ) ), GetterInterface::INT ), GetterInterface::INT ) . '" class="digits required form-control" size="6"' . $ownerTooltip . ' />';
HTML_groupjiveEventEdit::showEventEdit( $row, $input, $group, $user, $this );
}
示例3: sendMessage
/**
* send group message
*
* @param int $id
* @param UserTable $user
*/
private function sendMessage( $id, $user )
{
global $_CB_framework, $_CB_database;
$row = CBGroupJive::getGroup( $id );
$returnUrl = $_CB_framework->pluginClassUrl( $this->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $row->get( 'id' ) ) );
if ( CBGroupJive::canAccessGroup( $row, $user ) ) {
if ( ! CBGroupJive::isModerator( $user->get( 'id' ) ) ) {
if ( ! $this->params->get( 'groups_message', 0 ) ) {
cbRedirect( $returnUrl, CBTxt::T( 'You do not have access to messaging in this group.' ), 'error' );
} elseif ( ( $row->get( 'published' ) == -1 ) || ( CBGroupJive::getGroupStatus( $user, $row ) < 3 ) ) {
cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to messaging in this group.' ), 'error' );
} elseif ( $row->params()->get( 'messaged' ) ) {
$seconds = (int) $this->params->get( 'groups_message_delay', 60 );
if ( $seconds ) {
$diff = Application::Date( 'now', 'UTC' )->diff( $row->get( 'messaged' ) );
if ( ( $diff === false ) || ( $diff->s < $seconds ) ) {
cbRedirect( $returnUrl, CBTxt::T( 'You can not send a message to this group at this time. Please wait awhile and try again.' ), 'error' );
}
}
}
}
} else {
CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'Group does not exist.' ), 'error' );
}
$message = $this->input( 'post/message', null, GetterInterface::STRING );
if ( ! $message ) {
$_CB_framework->enqueueMessage( CBTxt::T( 'GROUP_MESSAGE_FAILED_TO_SEND', 'Group message failed to send! Error: [error]', array( '[error]' => CBTxt::T( 'Message not specified!' ) ) ), 'error' );
$this->showGroupMessage( $id, $user );
return;
}
$query = 'SELECT cb.*, j.*'
. "\n FROM " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS u"
. "\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
. ' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = u.' . $_CB_database->NameQuote( 'user_id' )
. "\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j"
. ' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
. "\n WHERE u." . $_CB_database->NameQuote( 'user_id' ) . " != " . (int) $user->get( 'id' )
. "\n AND u." . $_CB_database->NameQuote( 'group' ) . " = " . (int) $row->get( 'id' )
. "\n AND cb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
. "\n AND cb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1"
. "\n AND j." . $_CB_database->NameQuote( 'block' ) . " = 0"
. "\n AND u." . $_CB_database->NameQuote( 'status' ) . " > 0";
$_CB_database->setQuery( $query );
$users = $_CB_database->loadObjectList( null, '\CB\Database\Table\UserTable', array( $_CB_database ) );
if ( ! $users ) {
CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'This group has no users to message.' ) );
} else {
foreach ( $users as $usr ) {
CBGroupJive::sendNotification( $this->params->get( 'groups_message_type', 2 ), $user, $usr, CBTxt::T( 'Group message' ), CBTxt::T( 'GROUP_MESSAGE', 'Group [group] has sent the following message.<p>[message]</p>', array( '[message]' => $message ) ), $row );
}
}
$row->params()->set( 'messaged', Application::Database()->getUtcDateTime() );
$row->set( 'params', $row->params()->asJson() );
if ( $row->getError() || ( ! $row->store() ) ) {
$_CB_framework->enqueueMessage( CBTxt::T( 'GROUP_FAILED_TO_SAVE', 'Group failed to save! Error: [error]', array( '[error]' => $row->getError() ) ), 'error' );
$this->showGroupMessage( $id, $user );
return;
}
CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'Group messaged successfully!' ) );
}
示例4: getUTCDateDiff
/**
* compares two dates and returns the difference object or false if failed
*
* @param string|int $from
* @param string|int $to
* @param string|int $offset
* @param string $formatFrom
* @return DateInterval|boolean
* @deprecated 2.0 use Application::Date( $from, $offset, $formatFrom )->diff( $to )
*/
public static function getUTCDateDiff($from = 'now', $to = null, $offset = null, $formatFrom = null)
{
return Application::Date($from, $offset, $formatFrom)->diff($to);
}
示例5: post
/**
* get or set the kunena post object
*
* @param \KunenaForumMessage|null $post
* @return \KunenaForumMessage|null
*/
public function post( $post = null )
{
if ( $post !== null ) {
$this->_post = $post;
$data = array();
foreach ( $this->_post as $k => $v ) {
switch ( $k ) {
case 'userid':
$k = 'user_id';
break;
case 'catid':
$k = 'category';
break;
case 'time':
$k = 'date';
$v = Application::Date( $v, 'UTC' )->format( 'Y-m-d H:i:s' );
break;
case 'hold':
$k = 'published';
$v = ( $v == 0 ? 1 : 0 );
break;
}
$data[$k] = $v;
}
parent::bind( $data );
}
return $this->_post;
}
示例6: canResend
/**
* @return bool
*/
public function canResend()
{
global $_PLUGINS;
if ( $this->accepted() ) {
return false;
}
if ( ( ! $this->invited() ) || Application::Cms()->getClientId() ) {
return true;
}
static $params = null;
if ( ! $params ) {
$plugin = $_PLUGINS->getLoadedPlugin( 'user', 'cbgroupjive' );
$params = $_PLUGINS->getPluginParams( $plugin );
}
$days = (int) $params->get( 'groups_invites_resend', 7 );
if ( ! $days ) {
return false;
}
$diff = Application::Date( 'now', 'UTC' )->diff( $this->get( 'invited' ) );
if ( ( $diff === false ) || ( $diff->days < $days ) ) {
return false;
}
return true;
}
示例7: status
/**
* @return int
*/
public function status()
{
static $cache = array();
$id = $this->get( 'id' );
if ( ! isset( $cache[$id] ) ) {
$start = Application::Date( $this->get( 'start' ), 'UTC' )->getTimestamp();
$now = Application::Date( 'now', 'UTC' )->getTimestamp();
$status = 0;
if ( $start < $now ) {
$status = 1;
if ( $this->get( 'end' ) && ( Application::Date( $this->get( 'end' ), 'UTC' )->getTimestamp() > $now ) ) {
$status = 2;
}
}
$cache[$id] = $status;
}
return $cache[$id];
}
示例8: showGroup
//.........這裏部分代碼省略.........
. '<span class="gjButton gjButtonPending btn btn-xs btn-warning disabled">' . CBTxt::T( 'Pending Approval' ) . '</span>'
. '</span>';
}
}
if ( $isModerator || $isOwner || $menu || ( $userStatus >= 1) ) {
$menuItems = '<ul class="gjGroupMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">';
if ( $isModerator || $isOwner ) {
$menuItems .= '<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'edit', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>';
if ( ( $row->get( 'published' ) == -1 ) && $plugin->params->get( 'groups_create_approval', 0 ) ) {
if ( $isModerator ) {
$menuItems .= '<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>';
}
} elseif ( $row->get( 'published' ) == 1 ) {
$menuItems .= '<li class="gjGroupMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to unpublish this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'unpublish', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>';
} else {
$menuItems .= '<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>';
}
}
if ( $plugin->params->get( 'notifications', 1 ) && ( $isModerator || ( ( $row->get( 'published' ) == 1 ) && ( $isOwner || ( $userStatus >= 1 ) ) ) ) ) {
$menuItems .= '<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'notifications', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-envelope"></span> ' . CBTxt::T( 'Notifications' ) . '</a></li>';
}
if ( $isModerator || ( ( $row->get( 'published' ) == 1 ) && $plugin->params->get( 'groups_message', 0 ) && ( $isOwner || ( $userStatus >= 3 ) ) ) ) {
$delay = false;
if ( ( ! $isModerator ) && $row->params()->get( 'messaged' ) && $plugin->params->get( 'groups_message_delay', 60 ) ) {
$seconds = (int) $plugin->params->get( 'groups_message_delay', 60 );
if ( $seconds ) {
$diff = Application::Date( 'now', 'UTC' )->diff( $row->get( 'messaged' ) );
if ( ( $diff === false ) || ( $diff->s < $seconds ) ) {
$delay = true;
}
}
}
if ( ! $delay ) {
$menuItems .= '<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'message', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-comment"></span> ' . CBTxt::T( 'Message' ) . '</a></li>';
}
}
if ( ( ! $isOwner ) && ( $userStatus >= 1 ) ) {
$menuItems .= '<li class="gjGroupMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to leave this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'leave', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-minus-circle"></span> ' . CBTxt::T( 'Leave' ) . '</a></li>';
}
if ( $menu ) {
$menuItems .= '<li class="gjGroupMenuItem">' . implode( '</li><li class="gjGroupMenuItem">', $menu ) . '</li>';
}
if ( $isModerator || $isOwner ) {
$menuItems .= '<li class="gjGroupMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'delete', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>';
}
$menuItems .= '</ul>';
$menuAttr = cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' );
$return .= ' <span class="gjPageHeaderCanvasButton">'
. '<div class="gjGroupMenu btn-group">'
. '<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>'
. '</div>'