本文整理汇总了PHP中PagerModule::Current方法的典型用法代码示例。如果您正苦于以下问题:PHP PagerModule::Current方法的具体用法?PHP PagerModule::Current怎么用?PHP PagerModule::Current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PagerModule
的用法示例。
在下文中一共展示了PagerModule::Current方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: archives
/**
*
*
* @param $Category
* @param $Month
* @param bool $Page
* @throws Exception
* @throws Gdn_UserException
*/
public function archives($Category, $Month, $Page = false)
{
$Category = CategoryModel::categories($Category);
if (!$Category) {
throw notFoundException('Category');
}
if (!$Category['PermsDiscussionsView']) {
throw permissionException();
}
$Timestamp = strtotime($Month);
if (!$Timestamp) {
throw new Gdn_UserException("The archive month is not a valid date.");
}
$this->setData('Category', $Category);
// Round the month to the first day.
$From = gmdate('Y-m-01', $Timestamp);
$To = gmdate('Y-m-01', strtotime('+1 month', strtotime($From)));
// Grab the discussions.
list($Offset, $Limit) = offsetLimit($Page, c('Vanilla.Discussions.PerPage', 30));
$Where = array('CategoryID' => $Category['CategoryID'], 'Announce' => 'all', 'DateInserted >=' => $From, 'DateInserted <' => $To);
saveToConfig('Vanilla.Discussions.SortField', 'd.DateInserted', false);
$DiscussionModel = new DiscussionModel();
$DiscussionModel->setSort(Gdn::request()->get());
$DiscussionModel->setFilters(Gdn::request()->get());
$this->setData('Sort', $DiscussionModel->getSort());
$this->setData('Filters', $DiscussionModel->getFilters());
$Discussions = $DiscussionModel->getWhereRecent($Where, $Limit, $Offset);
$this->DiscussionData = $this->setData('Discussions', $Discussions);
$this->setData('_CurrentRecords', count($Discussions));
$this->setData('_Limit', $Limit);
$Canonical = '/categories/archives/' . rawurlencode($Category['UrlCode']) . '/' . gmdate('Y-m', $Timestamp);
$Page = PageNumber($Offset, $Limit, true, false);
$this->canonicalUrl(url($Canonical . ($Page ? '?page=' . $Page : ''), true));
PagerModule::Current()->configure($Offset, $Limit, false, $Canonical . '?page={Page}');
// PagerModule::Current()->Offset = $Offset;
// PagerModule::Current()->Url = '/categories/archives'.rawurlencode($Category['UrlCode']).'?page={Page}';
Gdn_Theme::section(val('CssClass', $Category));
Gdn_Theme::section('DiscussionList');
$this->title(htmlspecialchars(val('Name', $Category, '')));
$this->Description(sprintf(t("Archives for %s"), gmdate('F Y', strtotime($From))), true);
$this->addJsFile('discussions.js');
$this->Head->addTag('meta', array('name' => 'robots', 'content' => 'noindex'));
$this->ControllerName = 'DiscussionsController';
$this->CssClass = 'Discussions';
$this->render();
}
示例2: index
/**
* Default all discussions view: chronological by most recent comment.
*
* @since 2.0.0
* @access public
*
* @param int $Page Multiplied by PerPage option to determine offset.
*/
public function index($Page = false)
{
// Figure out which discussions layout to choose (Defined on "Homepage" settings page).
$Layout = c('Vanilla.Discussions.Layout');
switch ($Layout) {
case 'table':
if ($this->SyndicationMethod == SYNDICATION_NONE) {
$this->View = 'table';
}
break;
default:
// $this->View = 'index';
break;
}
Gdn_Theme::section('DiscussionList');
// Check for the feed keyword.
if ($Page === 'feed' && $this->SyndicationMethod != SYNDICATION_NONE) {
$Page = 'p1';
}
// Determine offset from $Page
list($Offset, $Limit) = offsetLimit($Page, c('Vanilla.Discussions.PerPage', 30), true);
$Page = PageNumber($Offset, $Limit);
// Allow page manipulation
$this->EventArguments['Page'] =& $Page;
$this->EventArguments['Offset'] =& $Offset;
$this->EventArguments['Limit'] =& $Limit;
$this->fireEvent('AfterPageCalculation');
// Set canonical URL
$this->canonicalUrl(url(ConcatSep('/', 'discussions', PageNumber($Offset, $Limit, true, false)), true));
// We want to limit the number of pages on large databases because requesting a super-high page can kill the db.
$MaxPages = c('Vanilla.Discussions.MaxPages');
if ($MaxPages && $Page > $MaxPages) {
throw notFoundException();
}
// Setup head.
if (!$this->data('Title')) {
$Title = c('Garden.HomepageTitle');
$DefaultControllerRoute = val('Destination', Gdn::router()->GetRoute('DefaultController'));
if ($Title && $DefaultControllerRoute == 'discussions') {
$this->title($Title, '');
} else {
$this->title(t('Recent Discussions'));
}
}
if (!$this->Description()) {
$this->Description(c('Garden.Description', null));
}
if ($this->Head) {
$this->Head->AddRss(url('/discussions/feed.rss', true), $this->Head->title());
}
// Add modules
$this->addModule('DiscussionFilterModule');
$this->addModule('NewDiscussionModule');
$this->addModule('CategoriesModule');
$this->addModule('BookmarkedModule');
$this->setData('Breadcrumbs', array(array('Name' => t('Recent Discussions'), 'Url' => '/discussions')));
// Set criteria & get discussions data
$this->setData('Category', false, true);
$DiscussionModel = new DiscussionModel();
// Check for individual categories.
$categoryIDs = $this->getCategoryIDs();
$where = array();
if ($categoryIDs) {
$where['d.CategoryID'] = CategoryModel::filterCategoryPermissions($categoryIDs);
} else {
$DiscussionModel->Watching = true;
}
// Get Discussion Count
$CountDiscussions = $DiscussionModel->getCount($where);
if ($MaxPages) {
$CountDiscussions = min($MaxPages * $Limit, $CountDiscussions);
}
$this->setData('CountDiscussions', $CountDiscussions);
// Get Announcements
$this->AnnounceData = $Offset == 0 ? $DiscussionModel->GetAnnouncements($where) : false;
$this->setData('Announcements', $this->AnnounceData !== false ? $this->AnnounceData : array(), true);
// Get Discussions
$this->DiscussionData = $DiscussionModel->getWhere($where, $Offset, $Limit);
$this->setData('Discussions', $this->DiscussionData, true);
$this->setJson('Loading', $Offset . ' to ' . $Limit);
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->EventArguments['PagerType'] = 'Pager';
$this->fireEvent('BeforeBuildPager');
if (!$this->data('_PagerUrl')) {
$this->setData('_PagerUrl', 'discussions/{Page}');
}
$this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
$this->Pager->ClientID = 'Pager';
$this->Pager->configure($Offset, $Limit, $this->data('CountDiscussions'), $this->data('_PagerUrl'));
PagerModule::Current($this->Pager);
$this->setData('_Page', $Page);
//.........这里部分代码省略.........
示例3: Index
//.........这里部分代码省略.........
}
} else {
if ($this->Offset == '') {
$this->Offset = 0;
}
}
if ($this->Offset < 0) {
$this->Offset = 0;
}
$LatestItem = $this->Discussion->CountCommentWatch;
if ($LatestItem === NULL) {
$LatestItem = 0;
} elseif ($LatestItem < $this->Discussion->CountComments) {
$LatestItem += 1;
}
$this->SetData('_LatestItem', $LatestItem);
// Set the canonical url to have the proper page title.
$this->CanonicalUrl(DiscussionUrl($this->Discussion, PageNumber($this->Offset, $Limit, 0, FALSE)));
// Url(ConcatSep('/', 'discussion/'.$this->Discussion->DiscussionID.'/'. Gdn_Format::Url($this->Discussion->Name), PageNumber($this->Offset, $Limit, TRUE, Gdn::Session()->UserID != 0)), TRUE), Gdn::Session()->UserID == 0);
// Load the comments
$this->SetData('Comments', $this->CommentModel->Get($DiscussionID, $Limit, $this->Offset));
$PageNumber = PageNumber($this->Offset, $Limit);
$this->SetData('Page', $PageNumber);
$this->_SetOpenGraph();
include_once PATH_LIBRARY . '/vendors/simplehtmldom/simple_html_dom.php';
if ($PageNumber == 1) {
$this->Description(SliceParagraph(Gdn_Format::PlainText($this->Discussion->Body, $this->Discussion->Format), 160));
// Add images to head for open graph
$Dom = str_get_html(Gdn_Format::To($this->Discussion->Body, $this->Discussion->Format));
} else {
$this->Data['Title'] .= sprintf(T(' - Page %s'), PageNumber($this->Offset, $Limit));
$FirstComment = $this->Data('Comments')->FirstRow();
$FirstBody = GetValue('Body', $FirstComment);
$FirstFormat = GetValue('Format', $FirstComment);
$this->Description(SliceParagraph(Gdn_Format::PlainText($FirstBody, $FirstFormat), 160));
// Add images to head for open graph
$Dom = str_get_html(Gdn_Format::To($FirstBody, $FirstFormat));
}
if ($Dom) {
foreach ($Dom->find('img') as $img) {
if (isset($img->src)) {
$this->Image($img->src);
}
}
}
// Make sure to set the user's discussion watch records
$this->CommentModel->SetWatch($this->Discussion, $Limit, $this->Offset, $this->Discussion->CountComments);
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->EventArguments['PagerType'] = 'Pager';
$this->FireEvent('BeforeBuildPager');
$this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
$this->Pager->ClientID = 'Pager';
$this->Pager->Configure($this->Offset, $Limit, $ActualResponses, array('DiscussionUrl'));
$this->Pager->Record = $this->Discussion;
PagerModule::Current($this->Pager);
$this->FireEvent('AfterBuildPager');
// Define the form for the comment input
$this->Form = Gdn::Factory('Form', 'Comment');
$this->Form->Action = Url('/vanilla/post/comment/');
$this->DiscussionID = $this->Discussion->DiscussionID;
$this->Form->AddHidden('DiscussionID', $this->DiscussionID);
$this->Form->AddHidden('CommentID', '');
// Look in the session stash for a comment
$StashComment = $Session->Stash('CommentForDiscussionID_' . $this->Discussion->DiscussionID, '', FALSE);
if ($StashComment) {
$this->Form->SetFormValue('Body', $StashComment);
}
// Retrieve & apply the draft if there is one:
if (Gdn::Session()->UserID) {
$DraftModel = new DraftModel();
$Draft = $DraftModel->Get($Session->UserID, 0, 1, $this->Discussion->DiscussionID)->FirstRow();
$this->Form->AddHidden('DraftID', $Draft ? $Draft->DraftID : '');
if ($Draft && !$this->Form->IsPostBack()) {
$this->Form->SetValue('Body', $Draft->Body);
$this->Form->SetValue('Format', $Draft->Format);
}
}
// 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 = 'comments';
}
// Inform moderator of checked comments in this discussion
$CheckedComments = $Session->GetAttribute('CheckedComments', array());
if (count($CheckedComments) > 0) {
ModerationController::InformCheckedComments($this);
}
// Add modules
$this->AddModule('DiscussionFilterModule');
$this->AddModule('NewDiscussionModule');
$this->AddModule('CategoriesModule');
$this->AddModule('BookmarkedModule');
$this->CanEditComments = Gdn::Session()->CheckPermission('Vanilla.Comments.Edit', TRUE, 'Category', 'any') && C('Vanilla.AdminCheckboxes.Use');
// Report the discussion id so js can use it.
$this->AddDefinition('DiscussionID', $DiscussionID);
$this->FireEvent('BeforeDiscussionRender');
$this->Render();
}
示例4: Index
//.........这里部分代码省略.........
return;
} else {
Gdn_Theme::Section('DiscussionList');
// Figure out which discussions layout to choose (Defined on "Homepage" settings page).
$Layout = C('Vanilla.Discussions.Layout');
switch ($Layout) {
case 'table':
if ($this->SyndicationMethod == SYNDICATION_NONE) {
$this->View = 'table';
}
break;
default:
// $this->View = 'index';
break;
}
$Category = CategoryModel::Categories($CategoryIdentifier);
if (empty($Category)) {
if ($CategoryIdentifier) {
throw NotFoundException();
}
}
$Category = (object) $Category;
Gdn_Theme::Section($Category->CssClass);
// Load the breadcrumbs.
$this->SetData('Breadcrumbs', CategoryModel::GetAncestors(GetValue('CategoryID', $Category)));
$this->SetData('Category', $Category, TRUE);
// Load the subtree.
if (C('Vanilla.ExpandCategories')) {
$Categories = CategoryModel::GetSubtree($CategoryIdentifier);
} else {
$Categories = array($Category);
}
$this->SetData('Categories', $Categories);
// Setup head
$this->AddCssFile('vanilla.css');
$this->Menu->HighlightRoute('/discussions');
if ($this->Head) {
$this->AddJsFile('discussions.js');
$this->AddJsFile('bookmark.js');
$this->AddJsFile('options.js');
$this->Head->AddRss($this->SelfUrl . '/feed.rss', $this->Head->Title());
}
$this->Title(GetValue('Name', $Category, ''));
$this->Description(GetValue('Description', $Category), TRUE);
// Set CategoryID
$CategoryID = GetValue('CategoryID', $Category);
$this->SetData('CategoryID', $CategoryID, TRUE);
// Add modules
$this->AddModule('NewDiscussionModule');
$this->AddModule('DiscussionFilterModule');
$this->AddModule('CategoriesModule');
$this->AddModule('BookmarkedModule');
// Get a DiscussionModel
$DiscussionModel = new DiscussionModel();
$CategoryIDs = ConsolidateArrayValuesByKey($this->Data('Categories'), 'CategoryID');
$Wheres = array('d.CategoryID' => $CategoryIDs);
$this->SetData('_ShowCategoryLink', count($CategoryIDs) > 1);
// Check permission
$this->Permission('Vanilla.Discussions.View', TRUE, 'Category', GetValue('PermissionCategoryID', $Category));
// Set discussion meta data.
$this->EventArguments['PerPage'] = C('Vanilla.Discussions.PerPage', 30);
$this->FireEvent('BeforeGetDiscussions');
list($Offset, $Limit) = OffsetLimit($Page, $this->EventArguments['PerPage']);
if (!is_numeric($Offset) || $Offset < 0) {
$Offset = 0;
}
$CountDiscussions = $DiscussionModel->GetCount($Wheres);
$this->SetData('CountDiscussions', $CountDiscussions);
$this->SetData('_Limit', $Limit);
// We don't wan't child categories in announcements.
$Wheres['d.CategoryID'] = $CategoryID;
$AnnounceData = $Offset == 0 ? $DiscussionModel->GetAnnouncements($Wheres) : new Gdn_DataSet();
$this->SetData('AnnounceData', $AnnounceData, TRUE);
$Wheres['d.CategoryID'] = $CategoryIDs;
$this->DiscussionData = $this->SetData('Discussions', $DiscussionModel->GetWhere($Wheres, $Offset, $Limit));
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->Pager = $PagerFactory->GetPager('Pager', $this);
$this->Pager->ClientID = 'Pager';
$this->Pager->Configure($Offset, $Limit, $CountDiscussions, array('CategoryUrl'));
$this->Pager->Record = $Category;
PagerModule::Current($this->Pager);
$this->SetData('_Page', $Page);
// Set the canonical Url.
$this->CanonicalUrl(CategoryUrl($Category, PageNumber($Offset, $Limit)));
// Change the controller name so that it knows to grab the discussion views
$this->ControllerName = 'DiscussionsController';
// Pick up the discussions class
$this->CssClass = 'Discussions';
// 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 = 'discussions';
}
// Render default view.
$this->FireEvent('BeforeCategoriesRender');
$this->Render();
}
}
示例5: index
//.........这里部分代码省略.........
}
Gdn_Theme::section('DiscussionList');
// Figure out which discussions layout to choose (Defined on "Homepage" settings page).
$Layout = c('Vanilla.Discussions.Layout');
switch ($Layout) {
case 'table':
if ($this->SyndicationMethod == SYNDICATION_NONE) {
$this->View = 'table';
}
break;
default:
// $this->View = 'index';
break;
}
// Load the subtree.
$Categories = CategoryModel::GetSubtree($CategoryIdentifier, false);
$this->setData('Categories', $Categories);
// Setup head
$this->Menu->highlightRoute('/discussions');
if ($this->Head) {
$this->addJsFile('discussions.js');
$this->Head->AddRss($this->SelfUrl . '/feed.rss', $this->Head->title());
}
// Set CategoryID
$CategoryID = val('CategoryID', $Category);
$this->setData('CategoryID', $CategoryID, true);
// Add modules
$this->addModule('NewDiscussionModule');
$this->addModule('DiscussionFilterModule');
$this->addModule('CategoriesModule');
$this->addModule('BookmarkedModule');
// Get a DiscussionModel
$DiscussionModel = new DiscussionModel();
$CategoryIDs = array($CategoryID);
if (c('Vanilla.ExpandCategories')) {
$CategoryIDs = array_merge($CategoryIDs, array_column($this->data('Categories'), 'CategoryID'));
}
$Wheres = array('d.CategoryID' => $CategoryIDs);
$this->setData('_ShowCategoryLink', count($CategoryIDs) > 1);
// Check permission
$this->permission('Vanilla.Discussions.View', true, 'Category', val('PermissionCategoryID', $Category));
// Set discussion meta data.
$this->EventArguments['PerPage'] = c('Vanilla.Discussions.PerPage', 30);
$this->fireEvent('BeforeGetDiscussions');
list($Offset, $Limit) = offsetLimit($Page, $this->EventArguments['PerPage']);
if (!is_numeric($Offset) || $Offset < 0) {
$Offset = 0;
}
$Page = PageNumber($Offset, $Limit);
// Allow page manipulation
$this->EventArguments['Page'] =& $Page;
$this->EventArguments['Offset'] =& $Offset;
$this->EventArguments['Limit'] =& $Limit;
$this->fireEvent('AfterPageCalculation');
// We want to limit the number of pages on large databases because requesting a super-high page can kill the db.
$MaxPages = c('Vanilla.Categories.MaxPages');
if ($MaxPages && $Page > $MaxPages) {
throw notFoundException();
}
$CountDiscussions = $DiscussionModel->getCount($Wheres);
if ($MaxPages && $MaxPages * $Limit < $CountDiscussions) {
$CountDiscussions = $MaxPages * $Limit;
}
$this->setData('CountDiscussions', $CountDiscussions);
$this->setData('_Limit', $Limit);
// We don't wan't child categories in announcements.
$Wheres['d.CategoryID'] = $CategoryID;
$AnnounceData = $Offset == 0 ? $DiscussionModel->GetAnnouncements($Wheres) : new Gdn_DataSet();
$this->setData('AnnounceData', $AnnounceData, true);
$Wheres['d.CategoryID'] = $CategoryIDs;
$this->DiscussionData = $this->setData('Discussions', $DiscussionModel->getWhere($Wheres, $Offset, $Limit));
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->EventArguments['PagerType'] = 'Pager';
$this->fireEvent('BeforeBuildPager');
$this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
$this->Pager->ClientID = 'Pager';
$this->Pager->configure($Offset, $Limit, $CountDiscussions, array('CategoryUrl'));
$this->Pager->Record = $Category;
PagerModule::Current($this->Pager);
$this->setData('_Page', $Page);
$this->setData('_Limit', $Limit);
$this->fireEvent('AfterBuildPager');
// Set the canonical Url.
$this->canonicalUrl(CategoryUrl($Category, PageNumber($Offset, $Limit)));
// Change the controller name so that it knows to grab the discussion views
$this->ControllerName = 'DiscussionsController';
// Pick up the discussions class
$this->CssClass = 'Discussions Category-' . GetValue('UrlCode', $Category);
// 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 = 'discussions';
}
// Render default view.
$this->fireEvent('BeforeCategoriesRender');
$this->render();
}
}