本文整理汇总了PHP中CategoryUrl函数的典型用法代码示例。如果您正苦于以下问题:PHP CategoryUrl函数的具体用法?PHP CategoryUrl怎么用?PHP CategoryUrl使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CategoryUrl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: BuildCategorySiteMap
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;
}
}
示例2: CategoriesController_Render_Before
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);
}
}
示例3: panelHeading
<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
}
示例4: writeTableRow
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);
}
}
}
示例5: writeDiscussion
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');
//.........这里部分代码省略.........
示例6: anchor
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>
示例7: 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();
}
}
示例8: T
<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
}
示例9: Anchor
<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
示例10: preg_match
// (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];
}
示例11: index
//.........这里部分代码省略.........
$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();
}
}
示例12: CategoryUrl
}
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> ';
}
示例13: FilenameRedirect
//.........这里部分代码省略.........
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;
}
示例14: T
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
}
示例15: T
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
}