本文整理汇总了PHP中DiscussionModel::removeSort方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussionModel::removeSort方法的具体用法?PHP DiscussionModel::removeSort怎么用?PHP DiscussionModel::removeSort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussionModel
的用法示例。
在下文中一共展示了DiscussionModel::removeSort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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)
{
$this->allowJSONP(true);
// 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');
// Remove score sort
DiscussionModel::removeSort('top');
// 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();
$DiscussionModel->setSort(Gdn::request()->get());
$DiscussionModel->setFilters(Gdn::request()->get());
$this->setData('Sort', $DiscussionModel->getSort());
$this->setData('Filters', $DiscussionModel->getFilters());
// 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);
// RSS should include announcements.
if ($this->SyndicationMethod !== SYNDICATION_NONE) {
$Where['Announce'] = 'all';
}
// Get Discussions
$this->DiscussionData = $DiscussionModel->getWhereRecent($where, $Limit, $Offset);
$this->setData('Discussions', $this->DiscussionData, true);
$this->setJson('Loading', $Offset . ' to ' . $Limit);
// Build a pager
//.........这里部分代码省略.........