本文整理汇总了PHP中CTimeHelper::getLocaleDate方法的典型用法代码示例。如果您正苦于以下问题:PHP CTimeHelper::getLocaleDate方法的具体用法?PHP CTimeHelper::getLocaleDate怎么用?PHP CTimeHelper::getLocaleDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTimeHelper
的用法示例。
在下文中一共展示了CTimeHelper::getLocaleDate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isPast
/**
* Return true if the event is past
* A past event, is events that are has passed more than 24 hours from the last date
*/
public static function isPast($event)
{
$endDate = CTimeHelper::getLocaleDate($event->enddate);
$now = CTimeHelper::getLocaleDate();
$nowUnix = $now->toUnix();
$isPast = $endDate->toUnix() < $nowUnix;
return $isPast;
}
示例2: getEventChildsCount
/**
* Get event child count
*
* @param int $parent
* @return int total
*
* */
public function getEventChildsCount($parent)
{
$db = $this->getDBO();
$pastDate = CTimeHelper::getLocaleDate();
$query = 'SELECT COUNT(*)
FROM ' . $db->quoteName('#__community_events') . '
WHERE ' . $db->quoteName('parent') . '=' . $db->Quote($parent) . '
AND ' . $db->quoteName('enddate') . ' > ' . $db->Quote($pastDate->toSql(true)) . '
AND ' . $db->quoteName('published') . '=' . $db->Quote(1);
$db->setQuery($query);
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
return $db->loadResult();
}
示例3: save
/**
* Method to save the group
* @return false if create fail, return the group id if create is successful
**/
public function save(&$event)
{
// Check for request forgeries
JRequest::checkToken() or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN'));
$mainframe = JFactory::getApplication();
$document = JFactory::getDocument();
$viewType = $document->getType();
$viewName = JRequest::getCmd('view', $this->getName());
$view = $this->getView($viewName, '', $viewType);
if (JString::strtoupper(JRequest::getMethod()) != 'POST') {
$view->addWarning(JText::_('COM_COMMUNITY_PERMISSION_DENIED_WARNING'));
return false;
}
// Get my current data.
$my = CFactory::getUser();
$validated = true;
$model = $this->getModel('events');
$eventId = JRequest::getInt('eventid', '0');
$isNew = $eventId == '0' ? true : false;
$postData = JRequest::get('post');
//format startdate and eendate with time before we bind into event object
$this->_formatStartEndDate($postData);
// if( !empty($postData['coordinate']) )
// {
// $coord = explode( ',', $postData['coordinate'] );
// $postData['latitude'] = trim($coord[0]);
// $postData['longitude'] = trim($coord[1]);
// }
$event->load($eventId);
$event->bind($postData);
if (!array_key_exists('permission', $postData)) {
$event->permission = 0;
}
if (!array_key_exists('allowinvite', $postData)) {
$event->allowinvite = 0;
} elseif (isset($postData['endtime-ampm']) && $postData['endtime-ampm'] == 'AM' && $postData['endtime-hour'] == 12) {
$postData['endtime-hour'] = 00;
}
$inputFilter = CFactory::getInputFilter(true);
// Despite the bind, we would still need to capture RAW description
$event->description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);
$event->description = $inputFilter->clean($event->description);
// @rule: Test for emptyness
if (empty($event->title)) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_TITLE_ERROR'), 'error');
}
if (empty($event->location)) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_LOCATION_ERR0R'), 'error');
}
// @rule: Test if the event is exists
if ($model->isEventExist($event->title, $event->location, $event->startdate, $event->enddate, $eventId)) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_TAKEN_ERROR'), 'error');
}
// @rule: Description cannot be empty
/*if( empty( $event->description ) )
{
$validated = false;
$mainframe->enqueueMessage( JText::_('COM_COMMUNITY_EVENTS_TAKEN_ERROR'), 'error');
}*/
// @rule: Start date cannot be empty
if (empty($event->startdate)) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_STARTDATE_ERROR'), 'error');
}
// @rule: End date cannot be empty
if (empty($event->enddate)) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_ENDDATE_ERROR'), 'error');
}
// @rule: Number of ticket must at least be 0
if (Jstring::strlen($event->ticket) <= 0) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_TICKET_EMPTY_ERROR'), 'error');
}
require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'time.php';
if (CTimeHelper::timeIntervalDifference($event->startdate, $event->enddate) > 0) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_STARTDATE_GREATER_ERROR'), 'error');
}
// @rule: Event must not end in the past
$now = CTimeHelper::getLocaleDate();
if (CTimeHelper::timeIntervalDifference($now->toMySQL(true), $event->enddate) > 0) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_ENDDATE_GREATER_ERROR'), 'error');
}
if ($validated) {
// If show event timezone is disabled, we need to set the event offset to 0.
$config = CFactory::getConfig();
if (!$config->get('eventshowtimezone')) {
$event->offset = 0;
}
// Set the default thumbnail and avatar for the event just in case
// the user decides to skip this
//.........这里部分代码省略.........
示例4: getActiveEvent
public function getActiveEvent()
{
$db = $this->getDBO();
$CTimeHelper = new CTimeHelper();
$pastDate = $CTimeHelper->getLocaleDate();
$query = 'SELECT * FROM ' . $db->quoteName('#__community_events') . ' WHERE ' . $db->quoteName('published') . '=' . $db->Quote(1) . ' AND ' . $db->quoteName('enddate') . ' > ' . $db->Quote($pastDate->format('Y-m-d H:i:s', true, false));
$db->setQuery($query);
$result = $db->loadObjectList();
return $result;
}
示例5: save
//.........这里部分代码省略.........
// @rule: Test for emptyness
if (empty($event->title)) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_TITLE_ERROR'), 'error');
}
if (empty($event->location)) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_LOCATION_ERR0R'), 'error');
}
// @rule: Test if the event is exists
if ($model->isEventExist($event->title, $event->location, $event->startdate, $event->enddate, $eventId, $event->parent)) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_TAKEN_ERROR'), 'error');
}
// @rule: Start date cannot be empty
if (empty($event->startdate)) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_STARTDATE_ERROR'), 'error');
}
// @rule: End date cannot be empty
if (empty($event->enddate)) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_ENDDATE_ERROR'), 'error');
}
// @rule: Number of ticket must at least be 0
if (Jstring::strlen($event->ticket) <= 0) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_TICKET_EMPTY_ERROR'), 'error');
}
if (!is_numeric($event->ticket)) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_TICKET_INVALID_ERROR'), 'error');
}
$now = CTimeHelper::getLocaleDate();
require_once JPATH_COMPONENT . '/helpers/time.php';
if (CTimeHelper::timeIntervalDifference($event->startdate, $event->enddate) > 0) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_STARTDATE_GREATER_ERROR'), 'error');
}
// if all day event.
$isToday = false;
if ($postData['allday'] == '1') {
$isToday = date("Y-m-d", strtotime($event->enddate)) == date("Y-m-d", strtotime($now->toSql(true))) ? true : $isToday;
}
// @rule: Event must not end in the past
if (CTimeHelper::timeIntervalDifference($now->toSql(true), $event->enddate) > 0 && !$isToday && $isNew) {
$validated = false;
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_ENDDATE_GREATER_ERROR'), 'error');
}
$eventChild = array();
// check event recurrence limit.
if (!empty($event->repeat) && ($isNew || $postData['repeataction'] == 'future')) {
$repeatLimit = 'COMMUNITY_EVENT_RECURRING_LIMIT_' . strtoupper($event->repeat);
if (defined($repeatLimit)) {
$eventChild = $this->_generateRepeatList($event);
if (count($eventChild) > constant($repeatLimit)) {
$validated = false;
$mainframe->enqueueMessage(sprintf(JText::_('COM_COMMUNITY_EVENTS_REPEAT_LIMIT_ERROR'), constant($repeatLimit)), 'error');
}
}
}
if ($validated) {
// If show event timezone is disabled, we need to set the event offset to 0.
$config = CFactory::getConfig();
if (!$config->get('eventshowtimezone')) {
$event->offset = 0;
示例6: getEvents
//.........这里部分代码省略.........
if (!empty($advance['enddate'])) {
$endDate = CTimeHelper::getDate(strtotime($advance['enddate']));
$extraSQL .= ' AND a.' . $db->nameQuote('startdate') . ' <= ' . $db->Quote($endDate->toMySQL());
}
/* Begin : SEARCH WITHIN */
if (!empty($advance['radius']) && !empty($advance['fromlocation'])) {
$longitude = null;
$latitude = null;
CFactory::load('libraries', 'mapping');
$data = CMapping::getAddressData($advance['fromlocation']);
if ($data) {
if ($data->status == 'OK') {
$latitude = (double) $data->results[0]->geometry->location->lat;
$longitude = (double) $data->results[0]->geometry->location->lng;
}
}
$now = new JDate();
$lng_min = $longitude - $advance['radius'] / abs(cos(deg2rad($latitude)) * 69);
$lng_max = $longitude + $advance['radius'] / abs(cos(deg2rad($latitude)) * 69);
$lat_min = $latitude - $advance['radius'] / 69;
$lat_max = $latitude + $advance['radius'] / 69;
$extraSQL .= ' AND a.' . $db->nameQuote('longitude') . ' > ' . $db->quote($lng_min) . ' AND a.' . $db->nameQuote('longitude') . ' < ' . $db->quote($lng_max) . ' AND a.' . $db->nameQuote('latitude') . ' > ' . $db->quote($lat_min) . ' AND a.' . $db->nameQuote('latitude') . ' < ' . $db->quote($lat_max);
}
/* End : SEARCH WITHIN */
}
/* End : ADVANCE SEARCH */
$limitstart = $this->getState('limitstart');
$limit = $limit === null ? $this->getState('limit') : $limit;
if ($type != CEventHelper::ALL_TYPES) {
$extraSQL .= ' AND a.' . $db->nameQuote('type') . '=' . $db->Quote($type);
$extraSQL .= ' AND a.' . $db->nameQuote('contentid') . '=' . $contentid;
}
if ($type == CEventHelper::GROUP_TYPE || $type == CEventHelper::ALL_TYPES) {
// @rule: Respect group privacy
$join .= ' LEFT JOIN ' . $db->nameQuote('#__community_groups') . ' AS g';
$join .= ' ON g.' . $db->nameQuote('id') . ' = a.' . $db->nameQuote('contentid');
if ($type != CEventHelper::GROUP_TYPE) {
$extraSQL .= ' AND (g.' . $db->nameQuote('approvals') . ' = ' . $db->Quote('0') . ' OR g.' . $db->nameQuote('approvals') . ' IS NULL';
if (!empty($userId)) {
$extraSQL .= ' OR b.' . $db->nameQuote('memberid') . '=' . $db->Quote($userId);
}
$extraSQL .= ')';
}
}
$orderBy = '';
$total = 0;
switch ($sorting) {
case 'latest':
if (empty($orderBy)) {
$orderBy = ' ORDER BY a.' . $db->nameQuote('created') . ' DESC';
}
break;
case 'alphabetical':
if (empty($orderBy)) {
$orderBy = ' ORDER BY a.' . $db->nameQuote('title') . ' ASC';
}
break;
case 'startdate':
if (empty($orderBy)) {
$orderBy = ' ORDER BY a.startdate ASC';
}
break;
default:
$orderBy = ' ORDER BY a.' . $db->nameQuote('startdate') . ' ASC';
break;
}
$now = new JDate();
CFactory::load('helpers', 'time');
$pastDate = CTimeHelper::getLocaleDate();
if ($hideOldEvent) {
$extraSQL .= ' AND a.' . $db->nameQuote('enddate') . ' > ' . $db->Quote($pastDate->toMySQL(true));
}
if ($showOnlyOldEvent) {
$extraSQL .= ' AND a.' . $db->nameQuote('enddate') . ' < ' . $db->Quote($pastDate->toMySQL(true));
}
$limit = empty($limit) ? 0 : $limit;
$query = 'SELECT DISTINCT a.* FROM ' . $db->nameQuote('#__community_events') . ' AS a ' . $join . 'WHERE a.' . $db->nameQuote('published') . '=' . $db->Quote('1') . $extraSQL . $orderBy . ' LIMIT ' . $limitstart . ', ' . $limit;
$db->setQuery($query);
$result = $db->loadObjectList();
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
$query = 'SELECT COUNT(DISTINCT(a.`id`)) FROM ' . $db->nameQuote('#__community_events') . ' AS a ' . $join . 'WHERE a.' . $db->nameQuote('published') . '=' . $db->Quote('1') . $extraSQL;
$db->setQuery($query);
$this->total = $db->loadResult();
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
$query = 'SELECT COUNT(DISTINCT(a.' . $db->nameQuote('id') . ')) FROM ' . $db->nameQuote('#__community_events') . ' AS a ' . $join . 'WHERE a.' . $db->nameQuote('published') . '=' . $db->Quote('1') . ' ' . $extraSQL;
$db->setQuery($query);
$total = $db->loadResult();
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
if (empty($this->_pagination)) {
jimport('joomla.html.pagination');
$this->_pagination = new JPagination($total, $limitstart, $limit);
}
return $result;
}