本文整理汇总了PHP中Gdn_PagerFactory::getPager方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_PagerFactory::getPager方法的具体用法?PHP Gdn_PagerFactory::getPager怎么用?PHP Gdn_PagerFactory::getPager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_PagerFactory
的用法示例。
在下文中一共展示了Gdn_PagerFactory::getPager方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* List download stats.
*
* @param bool|false $Offset
*/
public function index($Offset = false)
{
$this->permission('Garden.Settings.Manage');
$this->addSideMenu('vstats');
$this->addJsFile('jquery.gardenmorepager.js');
$this->title('Vanilla Stats');
$this->Form->Method = 'get';
$Offset = is_numeric($Offset) ? $Offset : 0;
$Limit = 19;
$this->StatsData = array();
$Offset--;
$Year = date('Y');
$Month = date('m');
$BaseDate = Gdn_Format::toTimestamp($Year . '-' . str_pad($Month, 2, '0', STR_PAD_LEFT) . '-01 00:00:00');
for ($i = $Offset; $i <= $Limit; ++$i) {
$String = "-{$i} month";
$this->StatsData[] = $this->_getStats(date("Y-m-d 00:00:00", strtotime($String, $BaseDate)));
}
$TotalRecords = count($this->StatsData);
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->Pager = $PagerFactory->getPager('MorePager', $this);
$this->Pager->MoreCode = 'More';
$this->Pager->LessCode = 'Previous';
$this->Pager->ClientID = 'Pager';
$this->Pager->Wrapper = '<tr %1$s><td colspan="6">%2$s</td></tr>';
$this->Pager->configure($Offset, $Limit, $TotalRecords, 'vstats/index/%1$s/');
// Deliver json data if necessary
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
$this->setJson('LessRow', $this->Pager->toString('less'));
$this->setJson('MoreRow', $this->Pager->toString('more'));
}
$this->render();
}
示例2: index
/**
* List all update checks.
*
* @param bool|false $Offset
* @param string $SortField
*/
public function index($Offset = false, $SortField = '')
{
$this->permission('Garden.Settings.Manage');
$this->addSideMenu('updates');
$this->addJsFile('jquery.gardenmorepager.js');
$this->title('Remote Updates');
$this->Form->Method = 'get';
$Limit = 30;
$SortField = $SortField == 'CountComments' ? 'c.CountComments' : 'c.DateInserted';
// Input Validation
$Offset = is_numeric($Offset) ? $Offset : 0;
// What the actual model in my controller, guy?
$this->UpdateData = Gdn::sql()->query("\n select s.Location, s.RemoteIp, c.DateInserted, c.CountUsers, c.CountDiscussions, c.CountComments\n from GDN_UpdateCheckSource s\n join (select SourceID, max(UpdateCheckID) as UpdateCheckID from GDN_UpdateCheck group by SourceID) mc\n on s.SourceID = mc.SourceID\n join GDN_UpdateCheck c\n on mc.UpdateCheckID = c.UpdateCheckID\n order by {$SortField} desc\n limit {$Offset}, {$Limit}");
$TotalRecords = Gdn::sql()->select('SourceID', 'count', 'CountSources')->from('UpdateCheckSource')->get()->firstRow()->CountSources;
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->Pager = $PagerFactory->getPager('MorePager', $this);
$this->Pager->MoreCode = 'More';
$this->Pager->LessCode = 'Previous';
$this->Pager->ClientID = 'Pager';
$this->Pager->Wrapper = '<tr %1$s><td colspan="6">%2$s</td></tr>';
$this->Pager->configure($Offset, $Limit, $TotalRecords, 'updates/index/%1$s/' . urlencode($SortField));
// Deliver json data if necessary
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
$this->setJson('LessRow', $this->Pager->toString('less'));
$this->setJson('MoreRow', $this->Pager->toString('more'));
}
$this->render();
}
示例3: embed
//.........这里部分代码省略.........
$Limit = c('Garden.Embed.CommentsPerPage', 30);
}
$OffsetProvided = $Offset != '';
list($Offset, $Limit) = offsetLimit($Offset, $Limit);
$this->Offset = $Offset;
if (c('Vanilla.Comments.AutoOffset')) {
if ($ActualResponses <= $Limit) {
$this->Offset = 0;
}
if ($this->Offset == $ActualResponses) {
$this->Offset -= $Limit;
}
} elseif ($this->Offset == '') {
$this->Offset = 0;
}
if ($this->Offset < 0) {
$this->Offset = 0;
}
// Set the canonical url to have the proper page title.
$this->canonicalUrl(discussionUrl($Discussion, pageNumber($this->Offset, $Limit)));
// Load the comments.
$CurrentOrderBy = $this->CommentModel->orderBy();
if (stringBeginsWith(GetValueR('0.0', $CurrentOrderBy), 'c.DateInserted')) {
$this->CommentModel->orderBy('c.DateInserted ' . $SortComments);
// allow custom sort
}
$this->setData('Comments', $this->CommentModel->get($Discussion->DiscussionID, $Limit, $this->Offset), true);
if (count($this->CommentModel->where()) > 0) {
$ActualResponses = false;
}
$this->setData('_Count', $ActualResponses);
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->EventArguments['PagerType'] = 'MorePager';
$this->fireEvent('BeforeBuildPager');
$this->Pager = $PagerFactory->getPager($this->EventArguments['PagerType'], $this);
$this->Pager->ClientID = 'Pager';
$this->Pager->MoreCode = 'More Comments';
$this->Pager->configure($this->Offset, $Limit, $ActualResponses, 'discussion/embed/' . $Discussion->DiscussionID . '/' . Gdn_Format::url($Discussion->Name) . '/%1$s');
$this->Pager->CurrentRecords = $this->Comments->numRows();
$this->fireEvent('AfterBuildPager');
}
// Define the form for the comment input
$this->Form = Gdn::Factory('Form', 'Comment');
$this->Form->Action = url('/post/comment/');
$this->Form->addHidden('CommentID', '');
$this->Form->addHidden('Embedded', 'true');
// Tell the post controller that this is an embedded page (in case there are custom views it needs to pick up from a theme).
$this->Form->addHidden('DisplayNewCommentOnly', 'true');
// Only load/display the new comment after posting (don't load all new comments since the page last loaded).
// Grab the page title
if ($this->Request->get('title')) {
$this->Form->setValue('Name', $this->Request->get('title'));
}
// Set existing DiscussionID for comment form
if ($Discussion) {
$this->Form->addHidden('DiscussionID', $Discussion->DiscussionID);
}
foreach ($ForeignSource as $Key => $Val) {
// Drop the foreign source information into the form so it can be used if creating a discussion
$this->Form->addHidden($Key, $Val);
// Also drop it into the definitions so it can be picked up for stashing comments
$this->addDefinition($Key, $Val);
}
// Retrieve & apply the draft if there is one:
$Draft = false;
if (Gdn::session()->UserID && $Discussion) {
$DraftModel = new DraftModel();
$Draft = $DraftModel->get(Gdn::session()->UserID, 0, 1, $Discussion->DiscussionID)->firstRow();
$this->Form->addHidden('DraftID', $Draft ? $Draft->DraftID : '');
}
if ($Draft) {
$this->Form->setFormValue('Body', $Draft->Body);
} else {
// Look in the session stash for a comment
$StashComment = Gdn::session()->getPublicStash('CommentForForeignID_' . $ForeignSource['vanilla_identifier']);
if ($StashComment) {
$this->Form->setValue('Body', $StashComment);
$this->Form->setFormValue('Body', $StashComment);
}
}
// Deliver JSON data if necessary
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
if ($this->Discussion) {
$this->setJson('LessRow', $this->Pager->toString('less'));
$this->setJson('MoreRow', $this->Pager->toString('more'));
}
$this->View = 'comments';
}
// Ordering note for JS
if ($SortComments == 'desc') {
$this->addDefinition('PrependNewComments', '1');
}
// Report the discussion id so js can use it.
if ($Discussion) {
$this->addDefinition('DiscussionID', $Discussion->DiscussionID);
}
$this->fireEvent('BeforeDiscussionRender');
$this->render();
}
示例4: discussionsController_unresolved_create
/**
* Discussions filter: Unresolved.
*
* @return void
*/
public function discussionsController_unresolved_create($sender, $args)
{
$sender->permission('Plugins.Resolved.Manage');
$page = val(0, $args, 0);
// Determine offset from $Page
list($page, $limit) = offsetLimit($page, C('Vanilla.Discussions.PerPage', 30));
// Validate $Page
if (!is_numeric($page) || $page < 0) {
$page = 0;
}
$discussionModel = new DiscussionModel();
$wheres = array('d.Resolved' => '0');
// Hack in our wheregroup.
Gdn::sql()->beginWhereGroup()->whereNotIn('d.Type', array('page', 'Report', 'poll', 'SimplePage'))->orWhere('d.Type is null')->endWhereGroup();
$sender->DiscussionData = $discussionModel->Get($page, $limit, $wheres);
$sender->setData('Discussions', $sender->DiscussionData);
$countDiscussions = $discussionModel->GetCount($wheres);
$sender->setData('CountDiscussions', $countDiscussions);
$sender->Category = false;
$sender->setJson('Loading', $page . ' to ' . $limit);
// Build a pager
$pagerFactory = new Gdn_PagerFactory();
$sender->EventArguments['PagerType'] = 'Pager';
$sender->fireEvent('BeforeBuildBookmarkedPager');
$sender->Pager = $pagerFactory->getPager($sender->EventArguments['PagerType'], $sender);
$sender->Pager->ClientID = 'Pager';
$sender->Pager->configure($page, $limit, $countDiscussions, 'discussions/unresolved/%1$s');
if (!$sender->data('_PagerUrl')) {
$sender->setData('_PagerUrl', 'discussions/unresolved/{Page}');
}
$sender->setData('_Page', $page);
$sender->setData('_Limit', $limit);
$sender->fireEvent('AfterBuildBookmarkedPager');
// Deliver JSON data if necessary
if ($sender->deliveryType() != DELIVERY_TYPE_ALL) {
$sender->setJson('LessRow', $sender->Pager->toString('less'));
$sender->setJson('MoreRow', $sender->Pager->toString('more'));
$sender->View = 'discussions';
}
// Add modules
$sender->addModule('DiscussionFilterModule');
$sender->addModule('NewDiscussionModule');
$sender->addModule('CategoriesModule');
// Render default view
$sender->setData('Title', T('Unresolved'));
$sender->setData('Breadcrumbs', array(array('Name' => T('Unresolved'), 'Url' => '/discussions/unresolved')));
$sender->render('index');
}
示例5: profileController_discussions_create
/**
* Creates virtual 'Discussions' method in ProfileController.
*
* @since 2.0.0
* @package Vanilla
*
* @param ProfileController $Sender ProfileController.
*/
public function profileController_discussions_create($Sender, $UserReference = '', $Username = '', $Page = '', $UserID = '')
{
$Sender->editMode(false);
// Tell the ProfileController what tab to load
$Sender->getUserInfo($UserReference, $Username, $UserID);
$Sender->_setBreadcrumbs(t('Discussions'), userUrl($Sender->User, '', 'discussions'));
$Sender->setTabView('Discussions', 'Profile', 'Discussions', 'Vanilla');
$Sender->CountCommentsPerPage = c('Vanilla.Comments.PerPage', 30);
list($Offset, $Limit) = offsetLimit($Page, c('Vanilla.Discussions.PerPage', 30));
$DiscussionModel = new DiscussionModel();
$Discussions = $DiscussionModel->getByUser($Sender->User->UserID, $Limit, $Offset, false, Gdn::session()->UserID);
$CountDiscussions = $Offset + $DiscussionModel->LastDiscussionCount + 1;
$Sender->DiscussionData = $Sender->setData('Discussions', $Discussions);
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$Sender->Pager = $PagerFactory->getPager('MorePager', $Sender);
$Sender->Pager->MoreCode = 'More Discussions';
$Sender->Pager->LessCode = 'Newer Discussions';
$Sender->Pager->ClientID = 'Pager';
$Sender->Pager->configure($Offset, $Limit, $CountDiscussions, userUrl($Sender->User, '', 'discussions') . '?page={Page}');
// Deliver JSON data if necessary
if ($Sender->deliveryType() != DELIVERY_TYPE_ALL && $Offset > 0) {
$Sender->setJson('LessRow', $Sender->Pager->toString('less'));
$Sender->setJson('MoreRow', $Sender->Pager->toString('more'));
$Sender->View = 'discussions';
}
// Set the HandlerType back to normal on the profilecontroller so that it fetches it's own views
$Sender->HandlerType = HANDLER_TYPE_NORMAL;
// Do not show discussion options
$Sender->ShowOptions = false;
if ($Sender->Head) {
// These pages offer only duplicate content to search engines and are a bit slow.
$Sender->Head->addTag('meta', array('name' => 'robots', 'content' => 'noindex,noarchive'));
}
// Render the ProfileController
$Sender->render();
}
示例6: browse
/**
* Filter the list of addons.
*
* @param string $FilterToType AddonModel::$TypesPlural and 'plugins,applications'.
* @param string $Sort Order addons by popularity or recency.
* @param string $Page Which page to display.
*/
public function browse($FilterToType = '', $Sort = '', $Page = '')
{
// Create a virtual type called 'apps' as a stand-in for both plugins & applications.
if ($FilterToType == 'apps') {
$FilterToType = 'plugins,applications';
}
// Implement user prefs
$Session = Gdn::session();
if ($Session->isValid()) {
if ($FilterToType != '') {
$Session->setPreference('Addons.FilterType', $FilterToType);
}
//if ($VanillaVersion != '') {
$Session->setPreference('Addons.FilterVanilla', '2');
//}
if ($Sort != '') {
$Session->setPreference('Addons.Sort', $Sort);
}
$FilterToType = $Session->getPreference('Addons.FilterType', 'all');
$VanillaVersion = $Session->getPreference('Addons.FilterVanilla', '2');
$Sort = $Session->getPreference('Addons.Sort', 'recent');
}
$allowedFilters = AddonModel::$TypesPlural + ['plugins,applications' => true];
if (!array_key_exists($FilterToType, $allowedFilters)) {
$FilterToType = 'all';
}
if ($Sort != 'popular') {
$Sort = 'recent';
}
if (!in_array($VanillaVersion, array('1', '2'))) {
$VanillaVersion = '2';
}
$this->Version = $VanillaVersion;
$this->Sort = $Sort;
$this->FilterChecked = 'checked';
$this->addJsFile('jquery.gardenmorepager.js');
$this->addJsFile('browse.js');
list($Offset, $Limit) = offsetLimit($Page, c('Garden.Search.PerPage', 20));
$this->Filter = $FilterToType;
if ($this->Filter == 'themes') {
$Title = 'Browse Themes';
} elseif ($this->Filter == 'plugins,applications') {
$Title = 'Browse Plugins & Applications';
} else {
$Title = 'Browse Addons';
}
$this->setData('Title', $Title);
$Search = GetIncomingValue('Keywords', '');
$this->buildBrowseWheres($Search);
$SortField = $Sort == 'recent' ? 'DateUpdated' : 'CountDownloads';
$ResultSet = $this->AddonModel->getWhere(false, $SortField, 'desc', $Limit, $Offset);
$this->setData('Addons', $ResultSet);
$this->buildBrowseWheres($Search);
$NumResults = $this->AddonModel->getCount(false);
$this->setData('TotalAddons', $NumResults);
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$Pager = $PagerFactory->getPager('Pager', $this);
$Pager->MoreCode = '›';
$Pager->LessCode = '‹';
$Pager->ClientID = 'Pager';
$Pager->configure($Offset, $Limit, $NumResults, 'addon/browse/' . $FilterToType . '/' . $Sort . '/%1$s/?Keywords=' . urlencode($Search));
$this->setData('_Pager', $Pager);
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
$this->setJson('MoreRow', $Pager->toString('more'));
}
$this->addModule('AddonHelpModule');
$this->render();
}
示例7: index
/**
* Shows all uncleared messages within a conversation for the viewing user
*
* @since 2.0.0
* @access public
*
* @param int $ConversationID Unique ID of conversation to view.
* @param int $Offset Number to skip.
* @param int $Limit Number to show.
*/
public function index($ConversationID = false, $Offset = -1, $Limit = '')
{
$this->Offset = $Offset;
$Session = Gdn::session();
Gdn_Theme::section('Conversation');
// Figure out Conversation ID
if (!is_numeric($ConversationID) || $ConversationID < 0) {
$ConversationID = 0;
}
// Form setup for adding comments
$this->Form->setModel($this->ConversationMessageModel);
$this->Form->addHidden('ConversationID', $ConversationID);
// Check permissions on the recipients.
$InConversation = $this->ConversationModel->inConversation($ConversationID, Gdn::session()->UserID);
if (!$InConversation) {
// Conversation moderation must be enabled and they must have permission
if (!c('Conversations.Moderation.Allow', false)) {
throw permissionException();
}
$this->permission('Conversations.Moderation.Manage');
}
$this->Conversation = $this->ConversationModel->getID($ConversationID);
$this->Conversation->Participants = $this->ConversationModel->getRecipients($ConversationID);
$this->setData('Conversation', $this->Conversation);
// Bad conversation? Redirect
if ($this->Conversation === false) {
throw notFoundException('Conversation');
}
// Get limit
if ($Limit == '' || !is_numeric($Limit) || $Limit < 0) {
$Limit = Gdn::config('Conversations.Messages.PerPage', 50);
}
// Calculate counts
if (!is_numeric($this->Offset) || $this->Offset < 0) {
// Round down to the appropriate offset based on the user's read messages & messages per page
$CountReadMessages = $this->Conversation->CountMessages - $this->Conversation->CountNewMessages;
if ($CountReadMessages < 0) {
$CountReadMessages = 0;
}
if ($CountReadMessages > $this->Conversation->CountMessages) {
$CountReadMessages = $this->Conversation->CountMessages;
}
// (((67 comments / 10 perpage) = 6.7) rounded down = 6) * 10 perpage = offset 60;
$this->Offset = floor($CountReadMessages / $Limit) * $Limit;
// Send the hash link in.
if ($CountReadMessages > 1) {
$this->addDefinition('LocationHash', '#Item_' . $CountReadMessages);
}
}
// Fetch message data
$this->MessageData = $this->ConversationMessageModel->get($ConversationID, $Session->UserID, $this->Offset, $Limit);
$this->EventArguments['MessageData'] = $this->MessageData;
$this->fireEvent('beforeMessages');
$this->setData('Messages', $this->MessageData);
// Figure out who's participating.
$ParticipantTitle = ConversationModel::participantTitle($this->Conversation, true);
$this->Participants = $ParticipantTitle;
$this->title(strip_tags($this->Participants));
// $CountMessages = $this->ConversationMessageModel->getCount($ConversationID, $Session->UserID);
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->Pager = $PagerFactory->getPager('MorePager', $this);
$this->Pager->MoreCode = 'Newer Messages';
$this->Pager->LessCode = 'Older Messages';
$this->Pager->ClientID = 'Pager';
$this->Pager->configure($this->Offset, $Limit, $this->Conversation->CountMessages, 'messages/' . $ConversationID . '/%1$s/%2$s/');
// Mark the conversation as ready by this user.
$this->ConversationModel->markRead($ConversationID, $Session->UserID);
// Deliver json data if necessary
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
$this->setJson('LessRow', $this->Pager->toString('less'));
$this->setJson('MoreRow', $this->Pager->toString('more'));
$this->View = 'messages';
}
// Add modules.
$ClearHistoryModule = new ClearHistoryModule($this);
$ClearHistoryModule->conversationID($ConversationID);
$this->addModule($ClearHistoryModule);
$InThisConversationModule = new InThisConversationModule($this);
$InThisConversationModule->setData($this->Conversation->Participants);
$this->addModule($InThisConversationModule);
// Doesn't make sense for people who can't even start conversations to be adding people
if (checkPermission('Conversations.Conversations.Add')) {
$this->addModule('AddPeopleModule');
}
$Subject = $this->data('Conversation.Subject');
if (!$Subject) {
$Subject = t('Message');
}
$this->Data['Breadcrumbs'][] = array('Name' => $Subject, 'Url' => url('', '//'));
//.........这里部分代码省略.........
示例8: index
/**
* Default search functionality.
*
* @since 2.0.0
* @access public
* @param int $Page Page number.
*/
public function index($Page = '')
{
$this->addJsFile('search.js');
$this->title(t('Search'));
saveToConfig('Garden.Format.EmbedSize', '160x90', false);
Gdn_Theme::section('SearchResults');
list($Offset, $Limit) = offsetLimit($Page, c('Garden.Search.PerPage', 20));
$this->setData('_Limit', $Limit);
$Search = $this->Form->getFormValue('Search');
$Mode = $this->Form->getFormValue('Mode');
if ($Mode) {
$this->SearchModel->ForceSearchMode = $Mode;
}
try {
$ResultSet = $this->SearchModel->search($Search, $Offset, $Limit);
} catch (Gdn_UserException $Ex) {
$this->Form->addError($Ex);
$ResultSet = array();
} catch (Exception $Ex) {
LogException($Ex);
$this->Form->addError($Ex);
$ResultSet = array();
}
Gdn::userModel()->joinUsers($ResultSet, array('UserID'));
// Fix up the summaries.
$SearchTerms = explode(' ', Gdn_Format::text($Search));
foreach ($ResultSet as &$Row) {
$Row['Summary'] = searchExcerpt(htmlspecialchars(Gdn_Format::plainText($Row['Summary'], $Row['Format'])), $SearchTerms);
$Row['Summary'] = Emoji::instance()->translateToHtml($Row['Summary']);
$Row['Format'] = 'Html';
}
$this->setData('SearchResults', $ResultSet, true);
$this->setData('SearchTerm', Gdn_Format::text($Search), true);
if ($ResultSet) {
$NumResults = count($ResultSet);
} else {
$NumResults = 0;
}
if ($NumResults == $Offset + $Limit) {
$NumResults++;
}
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->Pager = $PagerFactory->getPager('MorePager', $this);
$this->Pager->MoreCode = 'More Results';
$this->Pager->LessCode = 'Previous Results';
$this->Pager->ClientID = 'Pager';
$this->Pager->configure($Offset, $Limit, $NumResults, 'dashboard/search/%1$s/%2$s/?Search=' . Gdn_Format::url($Search));
// if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
// $this->setJson('LessRow', $this->Pager->toString('less'));
// $this->setJson('MoreRow', $this->Pager->toString('more'));
// $this->View = 'results';
// }
$this->canonicalUrl(url('search', true));
$this->render();
}