本文整理汇总了PHP中DiscussHelper::getDate方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussHelper::getDate方法的具体用法?PHP DiscussHelper::getDate怎么用?PHP DiscussHelper::getDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussHelper
的用法示例。
在下文中一共展示了DiscussHelper::getDate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
public function store($updateNulls = false)
{
if (empty($this->email) && $this->userid) {
$user = JFactory::getUser($this->userid);
$this->fullname = $user->email();
}
if (empty($this->fullname) && $this->userid) {
$profile = DiscussHelper::getTable('Profile');
$profile->load($this->userid);
$this->fullname = $profile->getName();
}
if (empty($this->member)) {
$this->member = $this->userid ? 1 : 0;
}
if (empty($this->interval)) {
$this->interval = 'instant';
}
if (empty($this->created)) {
$this->created = DiscussHelper::getDate()->toMySQL();
}
if (empty($this->sent_out)) {
$this->sent_out = DiscussHelper::getDate()->toMySQL();
}
return parent::store($updateNulls);
}
示例2: display
public function display($tpl = null)
{
// Initialise variables
$mainframe = JFactory::getApplication();
$tagId = JRequest::getVar('tagid', '');
$tag = JTable::getInstance('Tags', 'Discuss');
$tag->load($tagId);
$tag->title = JString::trim($tag->title);
$tag->alias = JString::trim($tag->alias);
$this->tag = $tag;
// Generate All tags for merging selections
$tagsModel = $this->getModel('Tags');
$tags = $tagsModel->getData(false);
$tagList = array();
array_push($tagList, JHTML::_('select.option', 0, 'Select tag', 'value', 'text', false));
if (!empty($tags)) {
foreach ($tags as $item) {
if ($item->id != $tagId) {
$tagList[] = JHtml::_('select.option', $item->id, $item->title);
}
}
}
// Set default values for new entries.
if (empty($tag->created)) {
$date = DiscussHelper::getDate();
$date->setOffSet($mainframe->getCfg('offset'));
$tag->created = $date->toFormat();
$tag->published = true;
}
$this->assignRef('tag', $tag);
$this->assignRef('tagList', $tagList);
parent::display($tpl);
}
示例3: addLikes
public static function addLikes($contentId, $type, $userId = null)
{
if (is_null($userId)) {
$userId = JFactory::getUser()->id;
}
$date = DiscussHelper::getDate();
$likes = DiscussHelper::getTable('Likes');
$params = array();
$params['type'] = $type;
$params['content_id'] = $contentId;
$params['created_by'] = $userId;
$params['created'] = $date->toMySQL();
$likes->bind($params);
// Check if the user already likes or not. if yes, then return the id.
$id = $likes->exists();
if ($id !== false) {
return $id;
}
$likes->store();
if ($type == 'post') {
// Now update the post
$db = DiscussHelper::getDBO();
$query = 'UPDATE `#__discuss_posts` SET `num_likes` = `num_likes` + 1';
$query .= ' WHERE `id` = ' . $db->Quote($contentId);
$db->setQuery($query);
$db->query();
}
return $likes->id;
}
示例4: process
function process()
{
$view = new EasyDiscussView();
$date = DiscussHelper::getDate();
$now = $date->toMySQL();
$modelSubscribe = $view->getModel('Subscribe');
$subscribers = $modelSubscribe->getSiteSubscribers($this->interval, $now);
$total = count($subscribers);
if (empty($total)) {
return false;
}
foreach ($subscribers as $subscriber) {
$notify = DiscussHelper::getNotification();
$data = array();
$rows = $modelSubscribe->getCreatedPostByInterval($subscriber->sent_out, $now);
$posts = array();
if ($rows) {
foreach ($rows as $row) {
$row['categorylink'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=categorie&layout=listings&category_id=' . $row['category_id'], false, true);
$row['link'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $row['id'], false, true);
$row['userlink'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=profile&id=' . $row['user_id'], false, true);
$category = DiscussHelper::getTable('Category');
$creator = DiscussHelper::getTable('Profile');
$category->load($row['category_id']);
$creator->load($row['user_id']);
$row['category'] = $category->getTitle();
$row['avatar'] = $creator->getAvatar();
$row['name'] = $creator->getName();
$row['date'] = DiscussDateHelper::toFormat($row['created'], '%b %e, %Y');
$row['message'] = DiscussHelper::parseContent($row['content']);
$posts[] = $row;
}
}
$data['post'] = $posts;
$data['total'] = count($data['post']);
$data['unsubscribeLink'] = DiscussHelper::getUnsubscribeLink($subscriber, true, true);
$subject = $date->toMySQL();
switch (strtoupper($this->interval)) {
case 'DAILY':
$subject = $date->toFormat('%F');
$data['interval'] = JText::_('today');
break;
case 'WEEKLY':
$subject = $date->toFormat('%V');
$data['interval'] = JText::_('this week');
break;
case 'MONTHLY':
$subject = $date->toFormat('%B');
$data['interval'] = JText::_('this month');
break;
}
if (!empty($data['post'])) {
$notify->addQueue($subscriber->email, JText::sprintf('COM_EASYDISCUSS_YOUR_' . $this->interval . '_SUBSCRIPTION', $subject), '', 'email.subscription.site.interval.php', $data);
}
$subscribe = DiscussHelper::getTable('Subscribe');
$subscribe->load($subscriber->id);
$subscribe->sent_out = $now;
$subscribe->store();
}
}
示例5: store
public function store($updateNulls = false)
{
if (empty($this->created) || $this->created == '0000-00-00 00:00:00') {
$this->created = DiscussHelper::getDate()->toMySQL();
}
return parent::store();
}
示例6: display
public function display($tmpl = null)
{
$config = DiscussHelper::getConfig();
$jConfig = DiscussHelper::getJConfig();
if (!$config->get('main_rss')) {
return;
}
$filteractive = JRequest::getString('filter', 'allposts');
$sort = JRequest::getString('sort', 'latest');
if ($filteractive == 'unanswered' && ($sort == 'active' || $sort == 'popular')) {
//reset the active to latest.
$sort = 'latest';
}
$doc = JFactory::getDocument();
$doc->link = JRoute::_('index.php?option=com_easydiscuss&view=index');
// Load up the tag
$tag = JRequest::getInt('id', 0);
$table = DiscussHelper::getTable('Tags');
$table->load($tag);
// Set the title of the document
$doc->setTitle($table->title);
$doc->setDescription(JText::sprintf('COM_EASYDISCUSS_DISCUSSIONS_TAGGED_IN', $table->title));
$postModel = $this->getModel('Posts');
$posts = $postModel->getTaggedPost($tag, $sort, $filteractive);
$pagination = $postModel->getPagination('0', $sort, $filteractive);
$jConfig = DiscussHelper::getJConfig();
$posts = DiscussHelper::formatPost($posts);
foreach ($posts as $row) {
// Assign to feed item
$title = $this->escape($row->title);
$title = html_entity_decode($title);
// load individual item creator class
$item = new JFeedItem();
$item->title = $title;
$item->link = JRoute::_('index.php?option=com_easydiscuss&view=post&id=' . $row->id);
$item->description = $row->content;
$item->date = DiscussHelper::getDate($row->created)->toMySQL();
if (!empty($row->tags)) {
$tagData = array();
foreach ($row->tags as $tag) {
$tagData[] = '<a href="' . JRoute::_('index.php?option=com_easydiscuss&view=tags&id=' . $tag->id) . '">' . $tag->title . '</a>';
}
$row->tags = implode(', ', $tagData);
} else {
$row->tags = '';
}
$item->category = $row->tags;
$item->author = $row->user->getName();
if ($jConfig->get('feed_email') != 'none') {
if ($jConfig->get('feed_email') == 'author') {
$item->authorEmail = $row->user->email;
} else {
$item->authorEmail = $jConfig->get('mailfrom');
}
}
$doc->addItem($item);
}
}
示例7: getHTML
public static function getHTML()
{
$captcha = DiscussHelper::getTable('Captcha');
$captcha->created = DiscussHelper::getDate()->toMySQL();
$captcha->store();
$theme = new DiscussThemes();
$theme->set('id', $captcha->id);
return $theme->fetch('form.captcha.php');
}
示例8: clear
/**
* Delete the outdated entries.
*/
function clear()
{
$db = DiscussHelper::getDBO();
$date = DiscussHelper::getDate();
$query = 'DELETE FROM `#__discuss_captcha` WHERE `created` <= DATE_SUB( ' . $db->Quote($date->toMySQL()) . ', INTERVAL 12 HOUR )';
$db->setQuery($query);
$db->query();
return true;
}
示例9: bind
/**
* Overrides parent's bind method to add our own logic.
*
* @param Array $data
**/
public function bind($data, $ignore = array())
{
parent::bind($data);
if (empty($this->created_time) || $this->created_time == '0000-00-00 00:00:00') {
$this->created_time = DiscussHelper::getDate()->toMySQL();
}
if (empty($this->created_user_id)) {
$this->created_user_id = JFactory::getUser()->id;
}
}
示例10: bind
/**
* Overrides parent's bind method to add our own logic.
*
* @param Array $data
**/
public function bind($data, $ignore = array())
{
parent::bind($data);
if (empty($this->created)) {
$this->created = DiscussHelper::getDate()->toMySQL();
}
if (empty($this->creator)) {
$this->creator = JFactory::getUser()->id;
}
}
示例11: log
/**
* Creates a new history record for the particular action.
*
* @access private
* @param string $command The current action
* @param int $userId The current actor
* @param string $title The title of the history or action.
* @return boolean True on success, false otherwise.
**/
public function log($command, $userId, $title, $content_id = 0)
{
$activity = DiscussHelper::getTable('History');
$activity->set('command', $command);
$activity->set('user_id', $userId);
$activity->set('title', $title);
$activity->set('created', DiscussHelper::getDate()->toMySQL());
$activity->set('content_id', $content_id);
return $activity->store();
}
示例12: store
/**
* Override parents implementation
**/
public function store($updateNulls = false)
{
if (is_null($this->created)) {
$this->created = DiscussHelper::getDate()->toMySQL();
}
// Set the state to new
if (is_null($this->state)) {
$this->state = DISCUSS_NOTIFICATION_NEW;
}
return parent::store($updateNulls);
}
示例13: updateView
public function updateView($userId, $url)
{
if (!$this->loadByUser($userId)) {
// Store a new record for the user.
$this->set('user_id', $userId);
}
$this->set('hash', $this->getHash($url));
$this->set('created', DiscussHelper::getDate()->toMySQL());
$this->set('ip', $_SERVER['REMOTE_ADDR']);
return $this->store();
}
示例14: pruneNotifications
/**
* Performs some maintenance here.
*
* @since 3.0
* @access public
*/
public function pruneNotifications()
{
$db = DiscussHelper::getDBO();
$date = DiscussHelper::getDate();
$config = DiscussHelper::getConfig();
$days = $config->get('notifications_history', 30);
$query = 'DELETE FROM ' . $db->nameQuote('#__discuss_notifications') . ' ' . 'WHERE ' . $db->nameQuote('created') . ' <= DATE_SUB( ' . $db->Quote($date->toMySQL()) . ' , INTERVAL ' . $days . ' DAY )';
$db->setQuery($query);
$db->query();
return true;
}
示例15: addFav
public function addFav($postId, $userId, $type = 'post')
{
$date = DiscussHelper::getDate();
$fav = DiscussHelper::getTable('Favourites');
$fav->created_by = $userId;
$fav->post_id = $postId;
$fav->type = $type;
$fav->created = $date->toMySQL();
if (!$fav->store()) {
return false;
}
return true;
}