本文整理汇总了PHP中DiscussHelper::getPagination方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussHelper::getPagination方法的具体用法?PHP DiscussHelper::getPagination怎么用?PHP DiscussHelper::getPagination使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussHelper
的用法示例。
在下文中一共展示了DiscussHelper::getPagination方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPagination
/**
* Method to get a pagination object for the posts
*
* @access public
* @return integer
*/
public function getPagination($parent_id = 0, $sort = 'latest', $filter = '', $category = '', $featuredOnly = 'all')
{
$this->_parent = $parent_id;
// Lets load the content if it doesn't already exist
if (empty($this->_pagination)) {
$this->_pagination = DiscussHelper::getPagination($this->getTotal($sort, $filter, $category, $featuredOnly), $this->getState('limitstart'), $this->getState('limit'));
}
return $this->_pagination;
}
示例2: getConversations
/**
* Retrieves a list of conversations for a particular node
*
* @since 3.0
* @access public
* @param int The current user id of the viewer
*/
public function getConversations($userId, $options = array())
{
$db = DiscussHelper::getDBO();
$query = 'SELECT a.*,b.' . $db->nameQuote('message') . ',c.' . $db->nameQuote('isread') . 'FROM ' . $db->nameQuote('#__discuss_conversations') . ' AS a ' . 'INNER JOIN ' . $db->nameQuote('#__discuss_conversations_message') . ' AS b ' . 'ON a.' . $db->nameQuote('id') . ' = b.' . $db->nameQuote('conversation_id') . ' ' . 'INNER JOIN ' . $db->nameQuote('#__discuss_conversations_message_maps') . ' AS c ' . 'ON c.' . $db->nameQuote('message_id') . ' = b.' . $db->nameQuote('id') . ' ' . 'WHERE c.' . $db->nameQuote('user_id') . ' = ' . $db->Quote($userId);
// @rule: Process any additional filters here.
if (isset($options['archives']) && $options['archives']) {
$query .= ' AND c.' . $db->nameQuote('state') . ' = ' . $db->Quote(DISCUSS_CONVERSATION_ARCHIVED);
} else {
$query .= ' AND c.' . $db->nameQuote('state') . ' = ' . $db->Quote(DISCUSS_CONVERSATION_PUBLISHED);
}
// @rule: Respect filter options
if (isset($options['filter'])) {
switch ($options['filter']) {
case 'unread':
$query .= ' AND c.' . $db->nameQuote('isread') . '=' . $db->Quote(DISCUSS_CONVERSATION_UNREAD);
break;
}
}
$query .= ' GROUP BY b.' . $db->nameQuote('conversation_id');
$sorting = isset($options['sorting']) ? $options['sorting'] : 'latest';
switch ($sorting) {
case 'latest':
default:
$query .= ' ORDER BY a.' . $db->nameQuote('lastreplied') . ' DESC';
break;
}
// If limit is provided, only show certain number of items.
if (isset($options['limit'])) {
$limit = $options['limit'];
$query .= ' LIMIT 0,' . $limit;
} else {
$limitstart = $this->getState('limitstart');
$limit = $this->getState('limit');
$paginationQuery = str_ireplace('SELECT a.*,b.' . $db->nameQuote('message') . ',c.' . $db->nameQuote('isread'), 'SELECT COUNT(1) AS count FROM ( SELECT a.* ', $query);
$paginationQuery .= ') AS x';
$db->setQuery($paginationQuery);
$total = $db->loadResult();
$this->_pagination = DiscussHelper::getPagination($total, $limitstart, $limit);
$query .= ' LIMIT ' . $limitstart . ' , ' . $limit;
}
$db->setQuery($query);
$rows = $db->loadObjectList();
if (!$rows) {
return $rows;
}
foreach ($rows as $row) {
$conversation = DiscussHelper::getTable('Conversation');
$conversation->bind($row);
$conversations[] = $conversation;
}
return $conversations;
}
示例3: getRepliesFromUser
/**
* Retrieve replies from a specific user
**/
public function getRepliesFromUser($userId, $ordering = '')
{
$db = DiscussHelper::getDBO();
$date = DiscussHelper::getDate();
$limitstart = $this->getState('limitstart');
$limit = $this->getState('limit');
$query = 'SELECT DATEDIFF(' . $db->Quote($date->toMySQL()) . ', b.`created`) as `noofdays`, ';
$query .= ' DATEDIFF(' . $db->Quote($date->toMySQL()) . ', b.`created`) as `daydiff`, TIMEDIFF(' . $db->Quote($date->toMySQL()) . ', b.`created`) as `timediff`,';
$query .= ' b.`id`, b.`title`, b.`alias`, b.`created`, b.`modified`, b.`replied`,b.`legacy`,';
$query .= ' b.`content`, b.`category_id`, b.`published`, b.`ordering`, b.`vote`, a.`hits`, b.`islock`,';
$query .= ' b.`featured`, b.`isresolve`, b.`isreport`, b.`user_id`, b.`parent_id`,';
$query .= ' b.`user_type`, b.`poster_name`, b.`poster_email`, b.`num_likes`,';
$query .= ' b.`num_negvote`, b.`sum_totalvote`, b.`answered`,';
$query .= ' b.`post_status`, b.`post_type`, pt.`title` AS `post_type_title`,pt.`suffix` AS `post_type_suffix`,';
$query .= ' count(a.id) as `num_replies`,';
$query .= ' c.`title` as `category`, b.`password`';
$query .= ' FROM ' . $db->nameQuote('#__discuss_posts') . ' AS a ';
$query .= ' INNER JOIN ' . $db->nameQuote('#__discuss_posts') . ' AS b ';
$query .= ' ON a.' . $db->nameQuote('parent_id') . ' = b.' . $db->nameQuote('id');
$query .= ' LEFT JOIN ' . $db->nameQuote('#__discuss_category') . ' AS c';
$query .= ' ON c.' . $db->nameQuote('id') . ' = b.' . $db->nameQuote('category_id');
$query .= ' LEFT JOIN ' . $db->nameQuote('#__discuss_post_types') . ' AS pt';
$query .= ' ON b.`post_type` = pt.' . $db->nameQuote('alias');
$query .= ' WHERE a.' . $db->nameQuote('user_id') . ' = ' . $db->Quote($userId);
$query .= ' AND a.' . $db->nameQuote('published') . ' = ' . $db->Quote(1);
$query .= ' AND a.`parent_id` != ' . $db->Quote('0');
$query .= ' AND b.' . $db->nameQuote('published') . ' = ' . $db->Quote(1);
$query .= ' AND b.`parent_id` = ' . $db->Quote('0');
$query .= ' GROUP BY b.`id`';
if (!empty($ordering)) {
if ($ordering == 'latest') {
$query .= ' ORDER BY a.`created` DESC';
}
}
$this->_total = $this->_getListCount($query);
$this->_pagination = DiscussHelper::getPagination($this->_total, $limitstart, $limit);
$this->_data = $this->_getList($query, $limitstart, $limit);
return $this->_data;
}
示例4: getPagination
/**
* Method to get a pagination object for the categories
*
* @access public
* @return integer
*/
function getPagination()
{
// Lets load the content if it doesn't already exist
if (empty($this->_pagination)) {
$this->_pagination = DiscussHelper::getPagination($this->getTotal(), $this->getState('limitstart'), $this->getState('limit'));
}
return $this->_pagination;
}