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; } }
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); } }
<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 }
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); } } }
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'); ?> </li> <?php }
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>
/** * Show all discussions in a particular category. * * @since 2.0.0 * @access public * * @param string $CategoryIdentifier Unique category slug or ID. * @param int $Offset Number of discussions to skip. */ public function Index($CategoryIdentifier = '', $Page = '0') { if ($CategoryIdentifier == '') { // Figure out which category layout to choose (Defined on "Homepage" settings page). $Layout = C('Vanilla.Categories.Layout'); switch ($Layout) { case 'mixed': $this->View = 'discussions'; $this->Discussions(); break; case 'table': $this->Table(); break; default: $this->View = 'all'; $this->All(); break; } 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(); } }
<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 }
<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
// (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]; }
/** * Show all discussions in a particular category. * * @since 2.0.0 * @access public * * @param string $CategoryIdentifier Unique category slug or ID. * @param int $Offset Number of discussions to skip. */ public function index($CategoryIdentifier = '', $Page = '0') { // Figure out which category layout to choose (Defined on "Homepage" settings page). $Layout = c('Vanilla.Categories.Layout'); if ($CategoryIdentifier == '') { switch ($Layout) { case 'mixed': $this->View = 'discussions'; $this->discussions(); break; case 'table': $this->table(); break; default: $this->View = 'all'; $this->all('', CategoryModel::getRootDisplayAs()); break; } return; } else { $Category = CategoryModel::categories($CategoryIdentifier); if (empty($Category)) { throw notFoundException(); } $Category = (object) $Category; Gdn_Theme::section($Category->CssClass); // Load the breadcrumbs. $this->setData('Breadcrumbs', CategoryModel::getAncestors(val('CategoryID', $Category))); $this->setData('Category', $Category, true); $this->title(htmlspecialchars(val('Name', $Category, ''))); $this->description(val('Description', $Category), true); switch ($Category->DisplayAs) { case 'Flat': case 'Heading': case 'Categories': $stopHeadings = val('Depth', $Category) > CategoryModel::instance()->getNavDepth(); CategoryModel::instance()->setStopHeadingsCalculation($stopHeadings); if ($this->SyndicationMethod != SYNDICATION_NONE) { // RSS can't show a category list so just tell it to expand all categories. saveToConfig('Vanilla.ExpandCategories', true, false); } else { // This category is an overview style category and displays as a category list. switch ($Layout) { case 'mixed': $this->View = 'discussions'; $this->discussions($CategoryIdentifier); break; case 'table': $this->table($CategoryIdentifier, $Category->DisplayAs); break; default: $this->View = 'all'; $this->All($CategoryIdentifier, $Category->DisplayAs); break; } return; } break; } 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; } $this->setData('CategoryTree', $this->getCategoryTree($CategoryIdentifier, val('DisplayAs', $Category))); // Add a backwards-compatibility shim for the old categories. $this->categoriesCompatibilityCallback = function () use($CategoryIdentifier) { $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(); } }
} 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> '; }
public function FilenameRedirect($Filename, $Get) { Trace(array('Filename' => $Filename, 'Get' => $Get), 'Testing'); $Filename = strtolower($Filename); array_change_key_case($Get); if (!isset(self::$Files[$Filename])) { 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; }
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 }
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 }
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>
/** * Show all discussions in a particular category. * * @since 2.0.0 * @access public * * @param string $CategoryIdentifier Unique category slug or ID. * @param int $Offset Number of discussions to skip. */ public function index($CategoryIdentifier = '', $Page = '0') { // Figure out which category layout to choose (Defined on "Homepage" settings page). $Layout = c('Vanilla.Categories.Layout'); if ($CategoryIdentifier == '') { switch ($Layout) { case 'mixed': $this->View = 'discussions'; $this->Discussions(); break; case 'table': $this->table(); break; default: $this->View = 'all'; $this->All(); break; } return; } else { $Category = CategoryModel::categories($CategoryIdentifier); if (empty($Category)) { // Try lowercasing before outright failing $LowerCategoryIdentifier = strtolower($CategoryIdentifier); if ($LowerCategoryIdentifier != $CategoryIdentifier) { $Category = CategoryModel::categories($LowerCategoryIdentifier); if ($Category) { redirect("/categories/{$LowerCategoryIdentifier}", 301); } } throw notFoundException(); } $Category = (object) $Category; Gdn_Theme::section($Category->CssClass); // Load the breadcrumbs. $this->setData('Breadcrumbs', CategoryModel::GetAncestors(val('CategoryID', $Category))); $this->setData('Category', $Category, true); $this->title(htmlspecialchars(val('Name', $Category, ''))); $this->Description(val('Description', $Category), true); if ($Category->DisplayAs == 'Categories') { if (val('Depth', $Category) > c('Vanilla.Categories.NavDepth', 0)) { // Headings don't make sense if we've cascaded down one level. saveToConfig('Vanilla.Categories.DoHeadings', false, false); } trace($this->deliveryMethod(), 'delivery method'); trace($this->deliveryType(), 'delivery type'); trace($this->SyndicationMethod, 'syndication'); if ($this->SyndicationMethod != SYNDICATION_NONE) { // RSS can't show a category list so just tell it to expand all categories. saveToConfig('Vanilla.ExpandCategories', true, false); } else { // This category is an overview style category and displays as a category list. switch ($Layout) { case 'mixed': $this->View = 'discussions'; $this->Discussions($CategoryIdentifier); break; case 'table': $this->table($CategoryIdentifier); break; default: $this->View = 'all'; $this->All($CategoryIdentifier); break; } return; } } 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(); } }
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">
<?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; } } }
<?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>
$seo_url = create_seoname($_POST['name'], $_POST['id'], 'category'); if ($_POST['parent_id'] != 0) { $parent = mysql_fetch_array(mysql_query("SELECT cat_order FROM ava_cats WHERE id = {$_POST['parent_id']}")); $cat_order = intval($parent['cat_order']) . '.1'; $update_cat_order = "cat_order = '{$cat_order}',"; } else { $update_cat_order = ''; } mysql_query("UPDATE ava_cats SET name='{$name}', {$update_cat_order} description = '{$description}', keywords = '{$_POST['keywords']}', seo_url = '{$seo_url}', parent_id = {$_POST['parent_id']} WHERE id='{$_POST['id']}'"); mysql_query("UPDATE ava_games SET category_parent = {$_POST['parent_id']} WHERE category_id = {$_POST['id']}"); } else { if ($_POST['parent_id'] == 0) { $cat_order = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM ava_cats WHERE parent_id = 0"), 0) + 1; } else { $parent = mysql_fetch_array(mysql_query("SELECT cat_order FROM ava_cats WHERE id = {$_POST['parent_id']}")); $cat_order = intval($parent['cat_order']) . '.1'; } $seo_url = create_seoname($_POST['name'], 0, 'category'); mysql_query("INSERT INTO ava_cats (name, cat_order, description, keywords, seo_url, parent_id)\n\tVALUES ('{$name}', {$cat_order}, '{$description}', '{$_POST['keywords']}', '{$seo_url}', {$_POST['parent_id']})") or die('There was a MySql error when adding the category: ' . mysql_error()); $newid = mysql_insert_id(); $url = CategoryUrl($newid, $seo_url, 1, 'newest'); echo '<div id="category-' . $newid . '" class="manage_item_new"><div class="manage_column0">' . $newid . '</div><div id="category-name-' . $newid . '" class="manage_column"><a href="' . $url . '" class="manage_link">' . $_POST['name'] . '</a></div><div class="manage_column3" id="delete-image-' . $newid . '"><img src="images/delete.png" width="24" height="24" onclick="DeleteAsk(' . $newid . ');"></div><div class="manage_column3" id="edit-image-' . $newid . '"><img src="images/edit.png" width="24" height="24" onclick="EditCategory(' . $newid . ', '; echo "'" . $_POST['name'] . "'"; echo ');"></div> <div class="manage_column_totalgames"><a href="?task=manage_games#page=1&cat=' . $newid . '">0</a></div> <div class="order_column"><input type="text" onfocus="EditOrderDefault(' . $newid . ')" onchange="EditOrderSubmit(' . $newid . ');" class="category_order_text_box" value="' . $cat_order . '" name="order_box' . $newid . '" id="order_box' . $newid . '"></div> <div id="edit-category-' . $newid . '" class="edit_game_container"></div></div>'; }
/** * Pre-process content into a uniform format for output * * @param Array $content By reference */ protected function processContent(&$content) { foreach ($content as &$item) { $contentType = val('RecordType', $item); $userID = val('InsertUserID', $item); $itemProperties = array(); $itemFields = array('DiscussionID', 'DateInserted', 'DateUpdated', 'Body', 'Format', 'RecordType', 'Url', 'CategoryID', 'CategoryName', 'CategoryUrl'); switch (strtolower($contentType)) { case 'comment': $itemFields = array_merge($itemFields, array('CommentID')); // Comment specific $itemProperties['Name'] = sprintf(t('Re: %s'), valr('Discussion.Name', $item, val('Name', $item))); $url = CommentUrl($item); break; case 'discussion': $itemFields = array_merge($itemFields, array('Name', 'Type')); $url = DiscussionUrl($item); break; } $item['Url'] = $url; if ($categoryId = val('CategoryID', $item)) { $category = CategoryModel::categories($categoryId); $item['CategoryName'] = val('Name', $category); $item['CategoryUrl'] = CategoryUrl($category); } $itemFields = array_fill_keys($itemFields, true); $filteredItem = array_intersect_key($item, $itemFields); $itemProperties = array_merge($itemProperties, $filteredItem); $item = $itemProperties; // Attach User $userFields = array('UserID', 'Name', 'Title', 'Location', 'PhotoUrl', 'RankName', 'Url', 'Roles', 'RoleNames'); $user = Gdn::userModel()->getID($userID); $roleModel = new RoleModel(); $roles = $roleModel->GetByUserID($userID)->resultArray(); $roleNames = ''; foreach ($roles as $role) { $roleNames[] = val('Name', $role); } // check $rankName = null; if (class_exists('RankModel')) { $rankName = val('Name', RankModel::Ranks(val('RankID', $user)), null); } $userProperties = array('Url' => url(userUrl($user), true), 'PhotoUrl' => UserPhotoUrl($user), 'RankName' => $rankName, 'RoleNames' => $roleNames, 'CssClass' => val('_CssClass', $user)); $user = (array) $user; $userFields = array_fill_keys($userFields, true); $filteredUser = array_intersect_key($user, $userFields); $userProperties = array_merge($filteredUser, $userProperties); $item['Author'] = $userProperties; } }
function getDiscussionOptions($Discussion = null) { $Options = array(); $Sender = Gdn::controller(); $Session = Gdn::session(); if ($Discussion == null) { $Discussion = $Sender->data('Discussion'); } $CategoryID = val('CategoryID', $Discussion); if (!$CategoryID && property_exists($Sender, 'Discussion')) { $CategoryID = val('CategoryID', $Sender->Discussion); } $PermissionCategoryID = val('PermissionCategoryID', $Discussion, val('PermissionCategoryID', $Discussion)); // Build the $Options array based on current user's permission. // Can the user edit the discussion? $CanEdit = DiscussionModel::canEdit($Discussion, $TimeLeft); if ($CanEdit) { if ($TimeLeft) { $TimeLeft = ' (' . Gdn_Format::Seconds($TimeLeft) . ')'; } $Options['EditDiscussion'] = array('Label' => t('Edit') . $TimeLeft, 'Url' => '/post/editdiscussion/' . $Discussion->DiscussionID); } // Can the user announce? if ($Session->checkPermission('Vanilla.Discussions.Announce', TRUE, 'Category', $PermissionCategoryID)) { $Options['AnnounceDiscussion'] = array('Label' => t('Announce'), 'Url' => '/discussion/announce?discussionid=' . $Discussion->DiscussionID . '&Target=' . urlencode($Sender->SelfUrl . '#Head'), 'Class' => 'AnnounceDiscussion Popup'); } // Can the user sink? if ($Session->checkPermission('Vanilla.Discussions.Sink', TRUE, 'Category', $PermissionCategoryID)) { $NewSink = (int) (!$Discussion->Sink); $Options['SinkDiscussion'] = array('Label' => t($Discussion->Sink ? 'Unsink' : 'Sink'), 'Url' => "/discussion/sink?discussionid={$Discussion->DiscussionID}&sink={$NewSink}", 'Class' => 'SinkDiscussion Hijack'); } // Can the user close? if ($Session->checkPermission('Vanilla.Discussions.Close', TRUE, 'Category', $PermissionCategoryID)) { $NewClosed = (int) (!$Discussion->Closed); $Options['CloseDiscussion'] = array('Label' => t($Discussion->Closed ? 'Reopen' : 'Close'), 'Url' => "/discussion/close?discussionid={$Discussion->DiscussionID}&close={$NewClosed}", 'Class' => 'CloseDiscussion Hijack'); } if ($CanEdit && valr('Attributes.ForeignUrl', $Discussion)) { $Options['RefetchPage'] = array('Label' => t('Refetch Page'), 'Url' => '/discussion/refetchpageinfo.json?discussionid=' . $Discussion->DiscussionID, 'Class' => 'RefetchPage Hijack'); } // Can the user move? if ($CanEdit && $Session->checkPermission('Garden.Moderation.Manage')) { $Options['MoveDiscussion'] = array('Label' => t('Move'), 'Url' => '/moderation/confirmdiscussionmoves?discussionid=' . $Discussion->DiscussionID, 'Class' => 'MoveDiscussion Popup'); } // Can the user delete? if ($Session->checkPermission('Vanilla.Discussions.Delete', TRUE, 'Category', $PermissionCategoryID)) { $Category = CategoryModel::categories($CategoryID); $Options['DeleteDiscussion'] = array('Label' => t('Delete Discussion'), 'Url' => '/discussion/delete?discussionid=' . $Discussion->DiscussionID . '&target=' . urlencode(CategoryUrl($Category)), 'Class' => 'DeleteDiscussion Popup'); } // DEPRECATED (as of 2.1) $Sender->EventArguments['Type'] = 'Discussion'; // Allow plugins to add options. $Sender->EventArguments['DiscussionOptions'] =& $Options; $Sender->EventArguments['Discussion'] = $Discussion; $Sender->fireEvent('DiscussionOptions'); return $Options; }
<?php defined('AVARCADE_') or die(''); foreach ($sort_options as $key => $sort_name) { $url = CategoryUrl($cat_info['id'], $cat_info['seo_url'], 1, $key); echo '<p class="sub_button"><a href="' . $url . '">' . $sort_name . '</a></p>'; if ($key != 'namedesc') { echo ''; } }
public static function CategoryUrl($Category, $Page = '', $WithDomain = TRUE) { if (function_exists('CategoryUrl')) { return CategoryUrl($Category, $Page, $WithDomain); } if (is_string($Category)) { $Category = CategoryModel::Categories($Category); } $Category = (array) $Category; $Result = '/categories/' . rawurlencode($Category['UrlCode']); if ($Page && $Page > 1) { $Result .= '/p' . $Page; } return Url($Result, $WithDomain); }
<tbody> <?php $Alt = FALSE; foreach ($this->MessageData->result() as $Message) { $Message = $this->MessageModel->DefineLocation($Message); $Alt = $Alt ? FALSE : TRUE; ?> <tr id="<?php echo $Message->MessageID; echo $Alt ? '" class="Alt' : ''; ?> "> <td class="Info nowrap"><?php printf(t('%1$s on %2$s'), arrayValue($Message->AssetTarget, $this->_GetAssetData(), 'Custom Location'), arrayValue($Message->Location, $this->_GetLocationData(), 'Custom Page')); if (val('CategoryID', $Message) && ($Category = CategoryModel::categories($Message->CategoryID))) { echo '<div>' . anchor($Category['Name'], CategoryUrl($Category)); if (val('IncludeSubcategories', $Message)) { echo ' ' . t('and subcategories'); } echo '</div>'; } ?> <div> <strong><?php echo $Message->Enabled == '1' ? t('Enabled') : t('Disabled'); ?> </strong> <?php echo anchor(t('Edit'), '/dashboard/message/edit/' . $Message->MessageID, 'EditMessage SmallButton'); echo anchor(t('Delete'), '/dashboard/message/delete/' . $Message->MessageID . '/' . $Session->TransientKey(), 'DeleteMessage SmallButton'); ?>
echo Anchor(Gdn_Format::Date($Discussion->DateInserted, 'html'), $Discussion->Url, 'Permalink', array('rel' => 'nofollow')); ?> </span> <?php echo DateUpdated($Discussion, array('<span class="MItem">', '</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(htmlspecialchars($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
function GetDiscussionOptions($Discussion = NULL) { $Options = array(); $Sender = Gdn::Controller(); $Session = Gdn::Session(); if ($Discussion == NULL) { $Discussion = $Sender->Data('Discussion'); } $CategoryID = GetValue('CategoryID', $Discussion); if (!$CategoryID && property_exists($Sender, 'Discussion')) { $CategoryID = GetValue('CategoryID', $Sender->Discussion); } $PermissionCategoryID = GetValue('PermissionCategoryID', $Discussion, GetValue('PermissionCategoryID', $Discussion)); // Determine if we still have time to edit $EditContentTimeout = C('Garden.EditContentTimeout', -1); $CanEdit = $EditContentTimeout == -1 || strtotime($Discussion->DateInserted) + $EditContentTimeout > time(); $CanEdit = $CanEdit && $Session->UserID == $Discussion->InsertUserID || $Session->CheckPermission('Vanilla.Discussions.Edit', TRUE, 'Category', $PermissionCategoryID); $TimeLeft = ''; if ($CanEdit && $EditContentTimeout > 0 && !$Session->CheckPermission('Vanilla.Discussions.Edit', TRUE, 'Category', $PermissionCategoryID)) { $TimeLeft = strtotime($Discussion->DateInserted) + $EditContentTimeout - time(); $TimeLeft = $TimeLeft > 0 ? ' (' . Gdn_Format::Seconds($TimeLeft) . ')' : ''; } // Build the $Options array based on current user's permission. // Can the user edit the discussion? if ($CanEdit) { $Options['EditDiscussion'] = array('Label' => T('Edit') . ' ' . $TimeLeft, 'Url' => '/vanilla/post/editdiscussion/' . $Discussion->DiscussionID); } // Can the user announce? if ($Session->CheckPermission('Vanilla.Discussions.Announce', TRUE, 'Category', $PermissionCategoryID)) { $Options['AnnounceDiscussion'] = array('Label' => T('Announce...'), 'Url' => 'vanilla/discussion/announce?discussionid=' . $Discussion->DiscussionID . '&Target=' . urlencode($Sender->SelfUrl . '#Head'), 'Class' => 'Popup'); } // Can the user sink? if ($Session->CheckPermission('Vanilla.Discussions.Sink', TRUE, 'Category', $PermissionCategoryID)) { $NewSink = (int) (!$Discussion->Sink); $Options['SinkDiscussion'] = array('Label' => T($Discussion->Sink ? 'Unsink' : 'Sink'), 'Url' => "/discussion/sink?discussionid={$Discussion->DiscussionID}&sink={$NewSink}", 'Class' => 'Hijack'); } // Can the user close? if ($Session->CheckPermission('Vanilla.Discussions.Close', TRUE, 'Category', $PermissionCategoryID)) { $NewClosed = (int) (!$Discussion->Closed); $Options['CloseDiscussion'] = array('Label' => T($Discussion->Closed ? 'Reopen' : 'Close'), 'Url' => "/discussion/close?discussionid={$Discussion->DiscussionID}&close={$NewClosed}", 'Class' => 'Hijack'); } if ($CanEdit && GetValueR('Attributes.ForeignUrl', $Discussion)) { $Options['RefetchPage'] = array('Label' => T('Refetch Page'), 'Url' => '/discussion/refetchpageinfo.json?discussionid=' . $Discussion->DiscussionID, 'Class' => 'Hijack'); } // Can the user delete? if ($Session->CheckPermission('Vanilla.Discussions.Delete', TRUE, 'Category', $PermissionCategoryID)) { $Category = CategoryModel::Categories($CategoryID); $Options['DeleteDiscussion'] = array('Label' => T('Delete Discussion'), 'Url' => '/discussion/delete?discussionid=' . $Discussion->DiscussionID . '&target=' . urlencode(CategoryUrl($Category)), 'Class' => 'Popup'); } // DEPRECATED (as of 2.1) $Sender->EventArguments['Type'] = 'Discussion'; // Allow plugins to add options. $Sender->EventArguments['DiscussionOptions'] =& $Options; $Sender->EventArguments['Discussion'] = $Discussion; $Sender->FireEvent('DiscussionOptions'); return $Options; }
/** * * * @since 2.0.18 * @access public * @param array $Data Dataset. */ protected static function CalculateData(&$Data) { foreach ($Data as &$Category) { $Category['CountAllDiscussions'] = $Category['CountDiscussions']; $Category['CountAllComments'] = $Category['CountComments']; $Category['Url'] = CategoryUrl($Category, FALSE, '//'); $Category['ChildIDs'] = array(); if (!GetValue('CssClass', $Category)) { $Category['CssClass'] = 'Category-' . $Category['UrlCode']; } } $Keys = array_reverse(array_keys($Data)); foreach ($Keys as $Key) { $Cat = $Data[$Key]; $ParentID = $Cat['ParentCategoryID']; if (isset($Data[$ParentID]) && $ParentID != $Key) { $Data[$ParentID]['CountAllDiscussions'] += $Cat['CountAllDiscussions']; $Data[$ParentID]['CountAllComments'] += $Cat['CountAllComments']; array_unshift($Data[$ParentID]['ChildIDs'], $Key); } } }
if ($ChildCategories != '') { $ChildCategories .= ', '; } $ChildCategories .= Anchor(Gdn_Format::Text($Category->Name), CategoryUrl($Category)); } else { if ($DoHeadings && $Category->Depth == 1) { $CatList .= '<li id="Category_' . $CategoryID . '" class="CategoryHeading ' . $CssClass . '"> <div class="ItemContent Category">' . GetOptions($Category, $this) . 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">' . GetOptions($Category, $this) . '<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'), '/categories/' . $Category->UrlCode . '/feed.rss') . '</span> <span class="MItem DiscussionCount">' . sprintf(Plural(number_format($Category->CountAllDiscussions), '%s discussion', '%s discussions'), $Category->CountDiscussions) . '</span> <span class="MItem CommentCount">' . sprintf(Plural(number_format($Category->CountAllComments), '%s comment', '%s comments'), $Category->CountComments) . '</span>'; if ($Category->LastTitle != '') { $CatList .= '<span class="MItem LastDiscussionTitle">' . sprintf(T('Most recent: %1$s by %2$s'), Anchor(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>