作者:SatiricMa
项目:addon
public function BuildCategorySiteMap($UrlCode, &$Urls)
{
$Category = CategoryModel::Categories($UrlCode);
if (!$Category) {
throw NotFoundException();
}
// Get the min/max dates for the sitemap.
$Row = Gdn::SQL()->Select('DateInserted', 'min', 'MinDate')->Select('DateInserted', 'max', 'MaxDate')->From('Discussion')->Where('CategoryID', $Category['CategoryID'])->Get()->FirstRow(DATASET_TYPE_ARRAY);
if ($Row) {
$From = strtotime('first day of this month 00:00:00', strtotime($Row['MaxDate']));
$To = strtotime('first day of this month 00:00:00', strtotime($Row['MinDate']));
if (!$From || !$To) {
$From = -1;
$To = 0;
}
} else {
$From = -1;
$To = 0;
}
$Now = time();
for ($i = $From; $i >= $To; $i = strtotime('-1 month', $i)) {
$Url = array('Loc' => Url('/categories/archives/' . rawurlencode($Category['UrlCode'] ? $Category['UrlCode'] : $Category['CategoryID']) . '/' . gmdate('Y-m', $i), TRUE), 'LastMod' => '', 'ChangeFreq' => '');
$LastMod = strtotime('last day of this month', $i);
if ($LastMod > $Now) {
$LastMod = $Now;
}
$Url['LastMod'] = gmdate('c', $LastMod);
$Urls[] = $Url;
}
// If there are no links then just link to the category.
if (count($Urls) === 0) {
$Url = array('Loc' => CategoryUrl($Category), 'LastMode' => '', 'ChangeFreq' => '');
$Urls[] = $Url;
}
}
作者:Nordic-
项目:vanilla-plugin
public function CategoriesController_Render_Before($Sender)
{
if (C('InfiniteScroll.DiscussionList', true) && $Sender->Category && $this->Enabled()) {
$this->PrepareDiscussionList($Sender);
$Sender->AddDefinition('InfiniteScroll.Url', CategoryUrl($Sender->Category, '', true));
$this->Resources($Sender);
}
}
作者:caidongyu
项目:vanill
<div class="Box BoxCategories">
<?php
echo panelHeading(t('Categories'));
?>
<ul class="PanelInfo PanelCategories">
<?php
echo '<li' . ($OnCategories ? ' class="Active"' : '') . '>' . anchor('<span class="Aside"><span class="Count">' . BigPlural($CountDiscussions, '%s discussion') . '</span></span> ' . t('All Categories'), '/categories', 'ItemLink') . '</li>';
$MaxDepth = c('Vanilla.Categories.MaxDisplayDepth');
foreach ($this->Data->result() as $Category) {
if ($Category->CategoryID < 0 || $MaxDepth > 0 && $Category->Depth > $MaxDepth) {
continue;
}
if ($Category->DisplayAs === 'Heading') {
$CssClass = 'Heading ' . $Category->CssClass;
} else {
$CssClass = 'Depth' . $Category->Depth . ($CategoryID == $Category->CategoryID ? ' Active' : '') . ' ' . $Category->CssClass;
}
echo '<li class="ClearFix ' . $CssClass . '">';
$CountText = '<span class="Aside"><span class="Count">' . BigPlural($Category->CountAllDiscussions, '%s discussion') . '</span></span>';
if ($Category->DisplayAs === 'Heading') {
echo $CountText . ' ' . htmlspecialchars($Category->Name);
} else {
echo anchor($CountText . ' ' . htmlspecialchars($Category->Name), CategoryUrl($Category), 'ItemLink');
}
echo "</li>\n";
}
?>
</ul>
</div>
<?php
}
作者:caidongyu
项目:vanill
function writeTableRow($Row, $Depth = 1)
{
$Children = $Row['Children'];
$WriteChildren = FALSE;
if (!empty($Children)) {
if ($Depth + 1 >= c('Vanilla.Categories.MaxDisplayDepth')) {
$WriteChildren = 'list';
} else {
$WriteChildren = 'rows';
}
}
$H = 'h' . ($Depth + 1);
?>
<tr class="<?php
echo CssClass($Row);
?>
">
<td class="CategoryName">
<div class="Wrap">
<?php
echo GetOptions($Row);
echo CategoryPhoto($Row);
echo "<{$H}>";
echo anchor(htmlspecialchars($Row['Name']), $Row['Url']);
Gdn::controller()->EventArguments['Category'] = $Row;
Gdn::controller()->fireEvent('AfterCategoryTitle');
echo "</{$H}>";
?>
<div class="CategoryDescription">
<?php
echo $Row['Description'];
?>
</div>
<?php
if ($WriteChildren === 'list') {
?>
<div class="ChildCategories">
<?php
echo wrap(t('Child Categories') . ': ', 'b');
echo CategoryString($Children, $Depth + 1);
?>
</div>
<?php
}
?>
</div>
</td>
<td class="BigCount CountDiscussions">
<div class="Wrap">
<?php
// echo "({$Row['CountDiscussions']})";
echo BigPlural($Row['CountAllDiscussions'], '%s discussion');
?>
</div>
</td>
<td class="BigCount CountComments">
<div class="Wrap">
<?php
// echo "({$Row['CountComments']})";
echo BigPlural($Row['CountAllComments'], '%s comment');
?>
</div>
</td>
<td class="BlockColumn LatestPost">
<div class="Block Wrap">
<?php
if ($Row['LastTitle']) {
?>
<?php
echo userPhoto($Row, array('Size' => 'Small', 'Px' => 'Last'));
echo anchor(SliceString(Gdn_Format::text($Row['LastTitle']), 100), $Row['LastUrl'], 'BlockTitle LatestPostTitle', array('title' => html_entity_decode($Row['LastTitle'])));
?>
<div class="Meta">
<?php
echo userAnchor($Row, 'UserLink MItem', 'Last');
?>
<span class="Bullet">•</span>
<?php
echo anchor(Gdn_Format::date($Row['LastDateInserted'], 'html'), $Row['LastUrl'], 'CommentDate MItem');
if (isset($Row['LastCategoryID'])) {
$LastCategory = CategoryModel::categories($Row['LastCategoryID']);
echo ' <span>', sprintf('in %s', anchor($LastCategory['Name'], CategoryUrl($LastCategory, '', '//'))), '</span>';
}
?>
</div>
<?php
}
?>
</div>
</td>
</tr>
<?php
if ($WriteChildren === 'rows') {
foreach ($Children as $ChildRow) {
WriteTableRow($ChildRow, $Depth + 1);
}
}
}
作者:caidongyu
项目:vanill
function writeDiscussion($Discussion, &$Sender, &$Session)
{
$CssClass = CssClass($Discussion);
$DiscussionUrl = $Discussion->Url;
$Category = CategoryModel::categories($Discussion->CategoryID);
if ($Session->UserID) {
$DiscussionUrl .= '#latest';
}
$Sender->EventArguments['DiscussionUrl'] =& $DiscussionUrl;
$Sender->EventArguments['Discussion'] =& $Discussion;
$Sender->EventArguments['CssClass'] =& $CssClass;
$First = UserBuilder($Discussion, 'First');
$Last = UserBuilder($Discussion, 'Last');
$Sender->EventArguments['FirstUser'] =& $First;
$Sender->EventArguments['LastUser'] =& $Last;
$Sender->fireEvent('BeforeDiscussionName');
$DiscussionName = $Discussion->Name;
if ($DiscussionName == '') {
$DiscussionName = t('Blank Discussion Topic');
}
$Sender->EventArguments['DiscussionName'] =& $DiscussionName;
static $FirstDiscussion = TRUE;
if (!$FirstDiscussion) {
$Sender->fireEvent('BetweenDiscussion');
} else {
$FirstDiscussion = FALSE;
}
$Discussion->CountPages = ceil($Discussion->CountComments / $Sender->CountCommentsPerPage);
?>
<li id="Discussion_<?php
echo $Discussion->DiscussionID;
?>
" class="<?php
echo $CssClass;
?>
">
<?php
if (!property_exists($Sender, 'CanEditDiscussions')) {
$Sender->CanEditDiscussions = val('PermsDiscussionsEdit', CategoryModel::categories($Discussion->CategoryID)) && c('Vanilla.AdminCheckboxes.Use');
}
$Sender->fireEvent('BeforeDiscussionContent');
// WriteOptions($Discussion, $Sender, $Session);
?>
<span class="Options">
<?php
echo OptionsList($Discussion);
echo BookmarkButton($Discussion);
?>
</span>
<div class="ItemContent Discussion">
<div class="Title">
<?php
echo AdminCheck($Discussion, array('', ' ')) . anchor($DiscussionName, $DiscussionUrl);
$Sender->fireEvent('AfterDiscussionTitle');
?>
</div>
<div class="Meta Meta-Discussion">
<?php
WriteTags($Discussion);
?>
<span class="MItem MCount ViewCount"><?php
printf(PluralTranslate($Discussion->CountViews, '%s view html', '%s views html', t('%s view'), t('%s views')), BigPlural($Discussion->CountViews, '%s view'));
?>
</span>
<span class="MItem MCount CommentCount"><?php
printf(PluralTranslate($Discussion->CountComments, '%s comment html', '%s comments html', t('%s comment'), t('%s comments')), BigPlural($Discussion->CountComments, '%s comment'));
?>
</span>
<span class="MItem MCount DiscussionScore Hidden"><?php
$Score = $Discussion->Score;
if ($Score == '') {
$Score = 0;
}
printf(Plural($Score, '%s point', '%s points', BigPlural($Score, '%s point')));
?>
</span>
<?php
echo NewComments($Discussion);
$Sender->fireEvent('AfterCountMeta');
if ($Discussion->LastCommentID != '') {
echo ' <span class="MItem LastCommentBy">' . sprintf(t('Most recent by %1$s'), userAnchor($Last)) . '</span> ';
echo ' <span class="MItem LastCommentDate">' . Gdn_Format::date($Discussion->LastDate, 'html') . '</span>';
} else {
echo ' <span class="MItem LastCommentBy">' . sprintf(t('Started by %1$s'), userAnchor($First)) . '</span> ';
echo ' <span class="MItem LastCommentDate">' . Gdn_Format::date($Discussion->FirstDate, 'html');
if ($Source = val('Source', $Discussion)) {
echo ' ' . sprintf(t('via %s'), t($Source . ' Source', $Source));
}
echo '</span> ';
}
if ($Sender->data('_ShowCategoryLink', true) && c('Vanilla.Categories.Use') && $Category) {
echo wrap(Anchor(htmlspecialchars($Discussion->Category), CategoryUrl($Discussion->CategoryUrlCode)), 'span', array('class' => 'MItem Category ' . $Category['CssClass']));
}
$Sender->fireEvent('DiscussionMeta');
?>
</div>
</div>
<?php
$Sender->fireEvent('AfterDiscussionContent');
//.........这里部分代码省略.........
作者:R-
项目:vanill
if ($ChildCategories != '') {
$ChildCategories .= ', ';
}
$ChildCategories .= anchor(Gdn_Format::text($Category->Name), CategoryUrl($Category));
} else {
if ($Category->DisplayAs === 'Heading') {
$CatList .= '<li id="Category_' . $CategoryID . '" class="CategoryHeading ' . $CssClass . '">
<div class="ItemContent Category"><div class="Options">' . getOptions($Category, $this) . '</div>' . Gdn_Format::text($Category->Name) . '</div>
</li>';
$Alt = FALSE;
} else {
$LastComment = UserBuilder($Category, 'Last');
$AltCss = $Alt ? ' Alt' : '';
$Alt = !$Alt;
$CatList .= '<li id="Category_' . $CategoryID . '" class="' . $CssClass . '">
<div class="ItemContent Category">' . '<div class="Options">' . getOptions($Category, $this) . '</div>' . CategoryPhoto($Category) . '<div class="TitleWrap">' . anchor(Gdn_Format::text($Category->Name), CategoryUrl($Category), 'Title') . '</div>
<div class="CategoryDescription">' . $Category->Description . '</div>
<div class="Meta">
<span class="MItem RSS">' . anchor(img('applications/dashboard/design/images/rss.gif', array('alt' => T('RSS Feed'))), '/categories/' . $Category->UrlCode . '/feed.rss', '', array('title' => T('RSS Feed'))) . '</span>
<span class="MItem DiscussionCount">' . sprintf(PluralTranslate($Category->CountDiscussions, '%s discussion html', '%s discussions html', t('%s discussion'), t('%s discussions')), BigPlural($Category->CountDiscussions, '%s discussion')) . '</span>
<span class="MItem CommentCount">' . sprintf(PluralTranslate($Category->CountComments, '%s comment html', '%s comments html', t('%s comment'), t('%s comments')), BigPlural($Category->CountComments, '%s comment')) . '</span>';
if ($Category->LastTitle != '') {
$CatList .= '<span class="MItem LastDiscussionTitle">' . sprintf(t('Most recent: %1$s by %2$s'), anchor(Gdn_Format::text(sliceString($Category->LastTitle, 40)), $Category->LastUrl), userAnchor($LastComment)) . '</span>' . '<span class="MItem LastCommentDate">' . Gdn_Format::date($Category->LastDateInserted) . '</span>';
}
// If this category is one level above the max display depth, and it
// has children, add a replacement string for them.
if ($MaxDisplayDepth > 0 && $Category->Depth == $MaxDisplayDepth - 1 && $Category->TreeRight - $Category->TreeLeft > 1) {
$CatList .= '{ChildCategories}';
}
$CatList .= '</div>
</div>
作者:remobject
项目:Garde
//.........这里部分代码省略.........
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();
}
}
作者:rnovin
项目:Garde
<h4><?php
echo T('Categories');
?>
</h4>
<ul class="PanelInfo PanelCategories">
<?php
echo '<li' . ($OnCategories ? ' class="Active"' : '') . '>' . Wrap(Anchor(Gdn_Format::Text(T('All Categories')), '/categories'), 'strong') . ' <span class="Aside"><span class="Count">' . BigPlural($CountDiscussions, '%s discussion') . '</span></span></li>';
$MaxDepth = C('Vanilla.Categories.MaxDisplayDepth');
$DoHeadings = C('Vanilla.Categories.DoHeadings');
foreach ($this->Data->Result() as $Category) {
if ($Category->CategoryID < 0 || $MaxDepth > 0 && $Category->Depth > $MaxDepth) {
continue;
}
if ($DoHeadings && $Category->Depth == 1) {
$CssClass = 'Heading';
} else {
$CssClass = 'Depth' . $Category->Depth . ($CategoryID == $Category->CategoryID ? ' Active' : '');
}
echo '<li class="ClearFix ' . $CssClass . '">';
if ($DoHeadings && $Category->Depth == 1) {
echo Gdn_Format::Text($Category->Name);
} else {
echo Wrap(Anchor(Gdn_Format::Text($Category->Name), CategoryUrl($Category)), 'strong') . ' <span class="Aside"><span class="Count">' . BigPlural($Category->CountAllDiscussions, '%s discussion') . '</span></span>';
}
echo "</li>\n";
}
?>
</ul>
</div>
<?php
}
作者:robhazke
项目:Garde
<div class="Meta DiscussionMeta">
<span class="MItem DateCreated">
<?php
echo Anchor(Gdn_Format::Date($Discussion->DateInserted, 'html'), $Discussion->Url, 'Permalink', array('rel' => 'nofollow'));
?>
</span>
<?php
// Include source if one was set
if ($Source = GetValue('Source', $Discussion)) {
echo ' ' . Wrap(sprintf(T('via %s'), T($Source . ' Source', $Source)), 'span', array('class' => 'MItem MItem-Source')) . ' ';
}
// Category
if (C('Vanilla.Categories.Use')) {
echo ' <span class="MItem Category">';
echo ' ' . T('in') . ' ';
echo Anchor($this->Data('Discussion.Category'), CategoryUrl($this->Data('Discussion.CategoryUrlCode')));
echo '</span> ';
}
$this->FireEvent('DiscussionInfo');
$this->FireEvent('AfterDiscussionMeta');
// DEPRECATED
?>
</div>
</div>
<?php
$this->FireEvent('BeforeDiscussionBody');
?>
<div class="Item-BodyWrap">
<div class="Item-Body">
<div class="Message">
<?php
作者:pp-wor
项目:forum-them
// (yes yes ugly)
if (!empty($Category->CssClass)) {
preg_match('/\\bfa-(fa-[\\w-]+)\\b/', $Category->CssClass, $categoryFaIcon);
}
if (isset($categoryFaIcon[1])) {
$faIcon = $categoryFaIcon[1];
} else {
$faIcon = "fa-align-justify";
}
$CatList .= '<li id="Category_' . $CategoryID . '" class="' . $CssClass . '">
<div class="row ItemContent Category">
<div class="col-md-7">
<div class="category-fa-icon-outer">
<i class="fa ' . $faIcon . ' category-fa-icon"></i>
</div>
' . CategoryPhoto($Category) . '<div class="TitleWrap">' . Anchor(Gdn_Format::Text($Category->Name), CategoryUrl($Category), 'Title') . '</div>
<div class="CategoryDescription">' . $Category->Description . '</div>';
// If this category is one level above the max display depth, and it
// has children, add a replacement string for them.
if ($MaxDisplayDepth > 0 && $Category->Depth == $MaxDisplayDepth - 1 && $Category->TreeRight - $Category->TreeLeft > 1) {
$CatList .= '{ChildCategories}';
}
$CatList .= '
</div>
<div class="col-md-5 text-right">
' . GetOptions($Category, $this) . '
<div class="Meta">';
$lastPostsInner = array();
if ($Category->LastTitle != '') {
$lastPostsInner[] = $lastPosts[$Category->CategoryID];
}
作者:vanill
项目:vanill
//.........这里部分代码省略.........
$categories = CategoryModel::getSubtree($CategoryIdentifier, false);
return $categories;
};
// Setup head
$this->Menu->highlightRoute('/discussions');
if ($this->Head) {
$this->addJsFile('discussions.js');
$this->Head->addRss(categoryUrl($Category) . '/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();
$DiscussionModel->setSort(Gdn::request()->get());
$DiscussionModel->setFilters(Gdn::request()->get());
$this->setData('Sort', $DiscussionModel->getSort());
$this->setData('Filters', $DiscussionModel->getFilters());
$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 = $DiscussionModel->getAnnouncements($Wheres, $Offset, $Limit);
$this->AnnounceData = $this->setData('Announcements', $AnnounceData);
$Wheres['d.CategoryID'] = $CategoryIDs;
// RSS should include announcements.
if ($this->SyndicationMethod !== SYNDICATION_NONE) {
$Wheres['Announce'] = 'all';
}
$this->DiscussionData = $this->setData('Discussions', $DiscussionModel->getWhereRecent($Wheres, $Limit, $Offset));
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$url = CategoryUrl($CategoryIdentifier);
$this->EventArguments['PagerType'] = 'Pager';
$this->fireEvent('BeforeBuildPager');
if (!$this->data('_PagerUrl')) {
$this->setData('_PagerUrl', $url . '/{Page}');
}
$queryString = DiscussionModel::getSortFilterQueryString($DiscussionModel->getSort(), $DiscussionModel->getFilters());
$this->setData('_PagerUrl', $this->data('_PagerUrl') . $queryString);
$this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
$this->Pager->ClientID = 'Pager';
$this->Pager->configure($Offset, $Limit, $CountDiscussions, $this->data('_PagerUrl'));
$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-' . val('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();
}
}
作者:jesusfsg0
项目:avArcad
}
if ($page > 5) {
$url = CategoryUrl($id, $cat_info['seo_url'], 2, $sortby);
echo '<a href="' . $url . '">2</a> ... ';
}
$low = $page - 4;
$high = $page + 8;
for ($i = 1; $i <= $total_pages; $i++) {
if ($i > $low && $i < $high) {
if ($page == $i) {
echo '<a href="#" class="onstate">' . $i . '</a> ';
} else {
$url = CategoryUrl($id, $cat_info['seo_url'], $i, $sortby);
echo '<a href="' . $url . '">' . $i . '</a> ';
}
}
}
if ($page < $total_pages - 8) {
$penultimate = $total_pages - 1;
$url = CategoryUrl($id, $cat_info['seo_url'], $penultimate, $sortby);
echo ' ... <a href="' . $url . '">' . $penultimate . '</a> ';
}
if ($page < $total_pages - 7) {
$url = CategoryUrl($id, $cat_info['seo_url'], $total_pages, $sortby);
echo '<a href="' . $url . '">' . $total_pages . '</a> ';
}
if ($page < $total_pages) {
$next = $page + 1;
$url = CategoryUrl($id, $cat_info['seo_url'], $next, $sortby);
echo '<a href="' . $url . '" rel="next">' . NEXT . ' »</a> ';
}
作者:nilse
项目:addon
//.........这里部分代码省略.........
return FALSE;
}
$Row = self::$Files[$Filename];
if (is_callable($Row)) {
// Use a callback to determine the translation.
$Row = call_user_func_array($Row, array(&$Get));
}
Trace($Get, 'New Get');
// Translate all of the get parameters into new parameters.
$Vars = array();
foreach ($Get as $Key => $Value) {
if (!isset($Row[$Key])) {
continue;
}
$Opts = (array) $Row[$Key];
if (isset($Opts['Filter'])) {
// Call the filter function to change the value.
$R = call_user_func($Opts['Filter'], $Value, $Opts[0]);
if (is_array($R)) {
if (isset($R[0])) {
// The filter can change the column name too.
$Opts[0] = $R[0];
$Value = $R[1];
} else {
// The filter can return return other variables too.
$Vars = array_merge($Vars, $R);
$Value = NULL;
}
} else {
$Value = $R;
}
}
if ($Value !== NULL) {
$Vars[$Opts[0]] = $Value;
}
}
Trace($Vars, 'Translated Arguments');
// Now let's see what kind of record we have.
// We'll check the various primary keys in order of importance.
$Result = FALSE;
if (isset($Vars['CommentID'])) {
Trace("Looking up comment {$Vars['CommentID']}.");
$CommentModel = new CommentModel();
// If a legacy slug is provided (assigned during a merge), attempt to lookup the comment using it
if (isset($Get['legacy']) && Gdn::Structure()->Table('Comment')->ColumnExists('ForeignID')) {
$Comment = $CommentModel->GetWhere(array('ForeignID' => $Get['legacy'] . '-' . $Vars['CommentID']))->FirstRow();
} else {
$Comment = $CommentModel->GetID($Vars['CommentID']);
}
if ($Comment) {
$Result = CommentUrl($Comment, '//');
}
} elseif (isset($Vars['DiscussionID'])) {
Trace("Looking up discussion {$Vars['DiscussionID']}.");
$DiscussionModel = new DiscussionModel();
$DiscussionID = $Vars['DiscussionID'];
$Discussion = FALSE;
if (is_numeric($DiscussionID)) {
// If a legacy slug is provided (assigned during a merge), attempt to lookup the discussion using it
if (isset($Get['legacy']) && Gdn::Structure()->Table('Discussion')->ColumnExists('ForeignID')) {
$Discussion = $DiscussionModel->GetWhere(array('ForeignID' => $Get['legacy'] . '-' . $DiscussionID))->FirstRow();
} else {
$Discussion = $DiscussionModel->GetID($Vars['DiscussionID']);
}
} else {
// This is a slug style discussion ID. Let's see if there is a UrlCode column in the discussion table.
$DiscussionModel->DefineSchema();
if ($DiscussionModel->Schema->FieldExists('Discussion', 'UrlCode')) {
$Discussion = $DiscussionModel->GetWhere(array('UrlCode' => $DiscussionID))->FirstRow();
}
}
if ($Discussion) {
$Result = DiscussionUrl($Discussion, self::PageNumber($Vars, 'Vanilla.Comments.PerPage'), '//');
}
} elseif (isset($Vars['UserID'])) {
Trace("Looking up user {$Vars['UserID']}.");
$User = Gdn::UserModel()->GetID($Vars['UserID']);
if ($User) {
$Result = Url(UserUrl($User), '//');
}
} elseif (isset($Vars['TagID'])) {
$Tag = TagModel::instance()->GetID($Vars['TagID']);
if ($Tag) {
$Result = TagUrl($Tag, self::PageNumber($Vars, 'Vanilla.Discussions.PerPage'), '//');
}
} elseif (isset($Vars['CategoryID'])) {
Trace("Looking up category {$Vars['CategoryID']}.");
// If a legacy slug is provided (assigned during a merge), attempt to lookup the category ID based on it
if (isset($Get['legacy']) && Gdn::Structure()->Table('Category')->ColumnExists('ForeignID')) {
$CategoryModel = new CategoryModel();
$Category = $CategoryModel->GetWhere(array('ForeignID' => $Get['legacy'] . '-' . $Vars['CategoryID']))->FirstRow();
} else {
$Category = CategoryModel::Categories($Vars['CategoryID']);
}
if ($Category) {
$Result = CategoryUrl($Category, self::PageNumber($Vars, 'Vanilla.Discussions.PerPage'), '//');
}
}
return $Result;
}
作者:edward-tsa
项目:vanilla4chin
echo T('Categories');
?>
</h4>
<ul class="PanelInfo PanelCategories">
<?php
echo '<li' . ($OnCategories ? ' class="Active"' : '') . '>' . Anchor(T('All Categories') . ' <span class="Aside"><span class="Count">' . BigPlural($CountDiscussions, '%s discussion') . '</span></span>', '/categories', 'ItemLink') . '</li>';
$MaxDepth = C('Vanilla.Categories.MaxDisplayDepth');
$DoHeadings = C('Vanilla.Categories.DoHeadings');
foreach ($this->Data->Result() as $Category) {
if ($Category->CategoryID < 0 || $MaxDepth > 0 && $Category->Depth > $MaxDepth) {
continue;
}
if ($DoHeadings && $Category->Depth == 1) {
$CssClass = 'Heading ' . $Category->CssClass;
} else {
$CssClass = 'Depth' . $Category->Depth . ($CategoryID == $Category->CategoryID ? ' Active' : '') . ' ' . $Category->CssClass;
}
echo '<li class="ClearFix ' . $CssClass . '">';
if ($DoHeadings && $Category->Depth == 1) {
echo htmlspecialchars($Category->Name) . ' <span class="Aside"><span class="Count Hidden">' . BigPlural($Category->CountAllDiscussions, '%s discussion') . '</span></span>';
} else {
$CountText = ' <span class="Aside"><span class="Count">' . BigPlural($Category->CountAllDiscussions, '%s discussion') . '</span></span>';
echo Anchor(htmlspecialchars($Category->Name) . $CountText, CategoryUrl($Category), 'ItemLink');
}
echo "</li>\n";
}
?>
</ul>
</div>
<?php
}
作者:robhazke
项目:Garde
echo T('Categories');
?>
</h4>
<ul class="PanelInfo PanelCategories">
<?php
echo '<li' . ($OnCategories ? ' class="Active"' : '') . '>' . Anchor(T('All Categories') . ' <span class="Aside"><span class="Count">' . BigPlural($CountDiscussions, '%s discussion') . '</span></span>', '/categories', 'ItemLink') . '</li>';
$MaxDepth = C('Vanilla.Categories.MaxDisplayDepth');
$DoHeadings = C('Vanilla.Categories.DoHeadings');
foreach ($this->Data->Result() as $Category) {
if ($Category->CategoryID < 0 || $MaxDepth > 0 && $Category->Depth > $MaxDepth) {
continue;
}
if ($DoHeadings && $Category->Depth == 1) {
$CssClass = 'Heading ' . $Category->CssClass;
} else {
$CssClass = 'Depth' . $Category->Depth . ($CategoryID == $Category->CategoryID ? ' Active' : '') . ' ' . $Category->CssClass;
}
echo '<li class="ClearFix ' . $CssClass . '">';
if ($DoHeadings && $Category->Depth == 1) {
echo Gdn_Format::Text($Category->Name) . ' <span class="Aside"><span class="Count Hidden">' . BigPlural($Category->CountAllDiscussions, '%s discussion') . '</span></span>';
} else {
$CountText = ' <span class="Aside"><span class="Count">' . BigPlural($Category->CountAllDiscussions, '%s discussion') . '</span></span>';
echo Anchor(Gdn_Format::Text($Category->Name) . $CountText, CategoryUrl($Category), 'ItemLink');
}
echo "</li>\n";
}
?>
</ul>
</div>
<?php
}
作者:elpu
项目:TgaForumBundl
if ($SearchTerm) {
echo MarkString($SearchTerm, $Row->Summary);
} else {
echo $Row->Summary;
}
?>
</div>
<div class="Item-Footer">
<?php
echo UserPhoto($Row, array('Size' => 'Small')) . ' ' . UserAnchor($Row);
?>
<span class="Meta"><span class="MItem">
<?php
echo Anchor(Gdn_Format::Date($Row->DateInserted, 'html'), $Row->Url);
if (isset($Row->CategoryID)) {
$Category = CategoryModel::Categories($Row->CategoryID);
if ($Category) {
$Url = CategoryUrl($Category);
echo ' in ' . Anchor($Category['Name'], $Url, 'Category');
}
}
?>
</span></span>
</span>
</div>
</li>
<?php
}
}
?>
</ul>
作者:dimassri
项目:vanill
//.........这里部分代码省略.........
}
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();
}
}
作者:caidongyu
项目:vanill
continue;
}
$this->Category = $Category;
$this->DiscussionData = $this->CategoryDiscussionData[$Category->CategoryID];
if ($this->DiscussionData->numRows() > 0) {
?>
<div class="CategoryBox Category-<?php
echo $Category->UrlCode;
?>
">
<?php
echo GetOptions($Category);
?>
<h2 class="H"><?php
echo anchor(htmlspecialchars($Category->Name), CategoryUrl($Category));
Gdn::controller()->EventArguments['Category'] = $Category;
Gdn::controller()->fireEvent('AfterCategoryTitle');
?>
</h2>
<ul class="DataList Discussions">
<?php
include $this->fetchViewLocation('discussions', 'discussions');
?>
</ul>
<?php
if ($this->DiscussionData->numRows() == $this->DiscussionsPerCategory) {
?>
<div class="MorePager">
作者:digiwi
项目:avarcad
<?php
defined('AVARCADE_') or die('');
$therow = 0;
$sql = mysql_query("SELECT * FROM ava_cats WHERE parent_id = 0 ORDER BY cat_order ASC");
while ($row = mysql_fetch_array($sql)) {
$cat_numb = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM ava_games WHERE (category_id = {$row['id']} OR category_parent = {$row['id']}) AND published=1"), 0);
if ($cat_numb > 0) {
$therow = $therow + 1;
$category = array('name' => $row['name']);
$category['url'] = CategoryUrl($row['id'], $row['seo_url'], 1, 'newest');
include '.' . $setting['template_url'] . '/' . $template['home_cat'];
if ($therow == $template['homepage_columns']) {
$therow = 0;
}
}
}
作者:digiwi
项目:avarcad
<?php
if (!isset($core_admin)) {
require_once '../../config.php';
include '../../includes/core.php';
include '../secure.php';
if ($login_status != 1) {
exit;
}
}
$query = mysql_query("SELECT * FROM ava_cats ORDER BY cat_order ASC");
while ($go = mysql_fetch_array($query)) {
$url = CategoryUrl($go['id'], $go['seo_url'], 1, 'newest');
$total_games = mysql_num_rows(mysql_query("SELECT * FROM ava_games WHERE category_id = {$go['id']}"));
echo '
<div id="category-' . $go['id'] . '" class="manage_item">
<div class="manage_column0">' . $go['id'] . '</div>
<div id="category-name-' . $go['id'] . '" class="cat_manage_column">';
if ($go['parent_id'] != 0) {
echo ' → ';
}
echo '<a href="' . $url . '" class="manage_link">' . $go['name'] . '</a></div>
<div class="manage_column3" id="delete-image-' . $go['id'] . '"><img src="images/delete.png" width="24" height="24" onclick="DeleteAsk(' . $go['id'] . ');"></div>
<div class="manage_column3" id="edit-image-' . $go['id'] . '"><img src="images/edit.png" width="24" height="24" onclick="EditCategory(' . $go['id'] . ', \'' . $go['name'] . '\');"></div>
<div class="manage_column_totalgames"><a href="?task=manage_games#page=1&cat=' . $go['id'] . '">' . $total_games . '</a></div>
<div class="order_column" id="order_column' . $go['id'] . '">';
if ($go['parent_id'] == 0) {
echo '<input type="text" onfocus="EditOrderDefault(' . $go['id'] . ')" onchange="EditOrderSubmit(' . $go['id'] . ');" class="category_order_text_box" value="' . intval($go['cat_order']) . '" name="order_box' . $go['id'] . '" id="order_box' . $go['id'] . '">';
}
echo '</div><div id="edit-category-' . $go['id'] . '" class="edit_game_container"></div>