当前位置: 首页>>代码示例>>PHP>>正文


PHP CategoryModel::GetAncestors方法代码示例

本文整理汇总了PHP中CategoryModel::GetAncestors方法的典型用法代码示例。如果您正苦于以下问题:PHP CategoryModel::GetAncestors方法的具体用法?PHP CategoryModel::GetAncestors怎么用?PHP CategoryModel::GetAncestors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CategoryModel的用法示例。


在下文中一共展示了CategoryModel::GetAncestors方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Index

 /**
  * Default single discussion display.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $DiscussionID Unique discussion ID
  * @param string $DiscussionStub URL-safe title slug
  * @param int $Page The current page of comments
  */
 public function Index($DiscussionID = '', $DiscussionStub = '', $Page = '')
 {
     // Setup head
     $Session = Gdn::Session();
     $this->AddJsFile('jquery.autogrow.js');
     $this->AddJsFile('discussion.js');
     $this->AddJsFile('autosave.js');
     Gdn_Theme::Section('Discussion');
     // Load the discussion record
     $DiscussionID = is_numeric($DiscussionID) && $DiscussionID > 0 ? $DiscussionID : 0;
     if (!array_key_exists('Discussion', $this->Data)) {
         $this->SetData('Discussion', $this->DiscussionModel->GetID($DiscussionID), TRUE);
     }
     if (!is_object($this->Discussion)) {
         throw new Exception(sprintf(T('%s Not Found'), T('Discussion')), 404);
     }
     // Define the query offset & limit.
     $Limit = C('Vanilla.Comments.PerPage', 30);
     $OffsetProvided = $Page != '';
     list($Offset, $Limit) = OffsetLimit($Page, $Limit);
     // Check permissions
     $this->Permission('Vanilla.Discussions.View', TRUE, 'Category', $this->Discussion->PermissionCategoryID);
     $this->SetData('CategoryID', $this->CategoryID = $this->Discussion->CategoryID, TRUE);
     $this->SetData('Breadcrumbs', CategoryModel::GetAncestors($this->CategoryID));
     $Category = CategoryModel::Categories($this->Discussion->CategoryID);
     if ($CategoryCssClass = GetValue('CssClass', $Category)) {
         Gdn_Theme::Section($CategoryCssClass);
     }
     // Setup
     $this->Title($this->Discussion->Name);
     // Actual number of comments, excluding the discussion itself.
     $ActualResponses = $this->Discussion->CountComments;
     $this->Offset = $Offset;
     if (C('Vanilla.Comments.AutoOffset')) {
         //         if ($this->Discussion->CountCommentWatch > 1 && $OffsetProvided == '')
         //            $this->AddDefinition('ScrollTo', 'a[name=Item_'.$this->Discussion->CountCommentWatch.']');
         if (!is_numeric($this->Offset) || $this->Offset < 0 || !$OffsetProvided) {
             // Round down to the appropriate offset based on the user's read comments & comments per page
             $CountCommentWatch = $this->Discussion->CountCommentWatch > 0 ? $this->Discussion->CountCommentWatch : 0;
             if ($CountCommentWatch > $ActualResponses) {
                 $CountCommentWatch = $ActualResponses;
             }
             // (((67 comments / 10 perpage) = 6.7) rounded down = 6) * 10 perpage = offset 60;
             $this->Offset = floor($CountCommentWatch / $Limit) * $Limit;
         }
         if ($ActualResponses <= $Limit) {
             $this->Offset = 0;
         }
         if ($this->Offset == $ActualResponses) {
             $this->Offset -= $Limit;
         }
     } else {
         if ($this->Offset == '') {
             $this->Offset = 0;
         }
     }
     if ($this->Offset < 0) {
         $this->Offset = 0;
     }
     $LatestItem = $this->Discussion->CountCommentWatch;
     if ($LatestItem === NULL) {
         $LatestItem = 0;
     } elseif ($LatestItem < $this->Discussion->CountComments) {
         $LatestItem += 1;
     }
     $this->SetData('_LatestItem', $LatestItem);
     // Set the canonical url to have the proper page title.
     $this->CanonicalUrl(DiscussionUrl($this->Discussion, PageNumber($this->Offset, $Limit, 0, FALSE)));
     //      Url(ConcatSep('/', 'discussion/'.$this->Discussion->DiscussionID.'/'. Gdn_Format::Url($this->Discussion->Name), PageNumber($this->Offset, $Limit, TRUE, Gdn::Session()->UserID != 0)), TRUE), Gdn::Session()->UserID == 0);
     // Load the comments
     $this->SetData('Comments', $this->CommentModel->Get($DiscussionID, $Limit, $this->Offset));
     $PageNumber = PageNumber($this->Offset, $Limit);
     $this->SetData('Page', $PageNumber);
     $this->_SetOpenGraph();
     include_once PATH_LIBRARY . '/vendors/simplehtmldom/simple_html_dom.php';
     if ($PageNumber == 1) {
         $this->Description(SliceParagraph(Gdn_Format::PlainText($this->Discussion->Body, $this->Discussion->Format), 160));
         // Add images to head for open graph
         $Dom = str_get_html(Gdn_Format::To($this->Discussion->Body, $this->Discussion->Format));
     } else {
         $this->Data['Title'] .= sprintf(T(' - Page %s'), PageNumber($this->Offset, $Limit));
         $FirstComment = $this->Data('Comments')->FirstRow();
         $FirstBody = GetValue('Body', $FirstComment);
         $FirstFormat = GetValue('Format', $FirstComment);
         $this->Description(SliceParagraph(Gdn_Format::PlainText($FirstBody, $FirstFormat), 160));
         // Add images to head for open graph
         $Dom = str_get_html(Gdn_Format::To($FirstBody, $FirstFormat));
     }
     if ($Dom) {
         foreach ($Dom->find('img') as $img) {
//.........这里部分代码省略.........
开发者ID:srikarrohit,项目名称:Vanillaforums-SSO,代码行数:101,代码来源:class.discussioncontroller.php

示例2: Discussion


//.........这里部分代码省略.........
                 }
                 if ($this->Form->GetFormValue('Sink', '') && !$Session->CheckPermission('Vanilla.Discussions.Sink', TRUE, 'Category', $this->Category->PermissionCategoryID)) {
                     $this->Form->AddError('You do not have permission to sink in this category', 'Sink');
                 }
                 if (!isset($this->Discussion) && (!$Session->CheckPermission('Vanilla.Discussions.Add', TRUE, 'Category', $this->Category->PermissionCategoryID) || !$this->Category->AllowDiscussions)) {
                     $this->Form->AddError('You do not have permission to start discussions in this category', 'CategoryID');
                 }
             }
             // Make sure that the title will not be invisible after rendering
             $Name = trim($this->Form->GetFormValue('Name', ''));
             if ($Name != '' && Gdn_Format::Text($Name) == '') {
                 $this->Form->AddError(T('You have entered an invalid discussion title'), 'Name');
             } else {
                 // Trim the name.
                 $FormValues['Name'] = $Name;
                 $this->Form->SetFormValue('Name', $Name);
             }
             if ($this->Form->ErrorCount() == 0) {
                 if ($Draft) {
                     $DraftID = $this->DraftModel->Save($FormValues);
                     $this->Form->SetValidationResults($this->DraftModel->ValidationResults());
                 } else {
                     $DiscussionID = $this->DiscussionModel->Save($FormValues, $this->CommentModel);
                     $this->Form->SetValidationResults($this->DiscussionModel->ValidationResults());
                     if ($DiscussionID > 0) {
                         if ($DraftID > 0) {
                             $this->DraftModel->Delete($DraftID);
                         }
                     }
                     if ($DiscussionID == SPAM || $DiscussionID == UNAPPROVED) {
                         $this->StatusMessage = T('DiscussionRequiresApprovalStatus', 'Your discussion will appear after it is approved.');
                         $this->Render('Spam');
                         return;
                     }
                 }
             }
         } else {
             // If this was a preview click, create a discussion/comment shell with the values for this comment
             $this->Discussion = new stdClass();
             $this->Discussion->Name = $this->Form->GetValue('Name', '');
             $this->Comment = new stdClass();
             $this->Comment->InsertUserID = $Session->User->UserID;
             $this->Comment->InsertName = $Session->User->Name;
             $this->Comment->InsertPhoto = $Session->User->Photo;
             $this->Comment->DateInserted = Gdn_Format::Date();
             $this->Comment->Body = ArrayValue('Body', $FormValues, '');
             $this->Comment->Format = GetValue('Format', $FormValues, C('Garden.InputFormatter'));
             $this->EventArguments['Discussion'] =& $this->Discussion;
             $this->EventArguments['Comment'] =& $this->Comment;
             $this->FireEvent('BeforeDiscussionPreview');
             if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
                 $this->AddAsset('Content', $this->FetchView('preview'));
             } else {
                 $this->View = 'preview';
             }
         }
         if ($this->Form->ErrorCount() > 0) {
             // Return the form errors
             $this->ErrorMessage($this->Form->Errors());
         } else {
             if ($DiscussionID > 0 || $DraftID > 0) {
                 // Make sure that the ajax request form knows about the newly created discussion or draft id
                 $this->SetJson('DiscussionID', $DiscussionID);
                 $this->SetJson('DraftID', $DraftID);
                 if (!$Preview) {
                     // If the discussion was not a draft
                     if (!$Draft) {
                         // Redirect to the new discussion
                         $Discussion = $this->DiscussionModel->GetID($DiscussionID, DATASET_TYPE_OBJECT, array('Slave' => FALSE));
                         $this->SetData('Discussion', $Discussion);
                         $this->EventArguments['Discussion'] = $Discussion;
                         $this->FireEvent('AfterDiscussionSave');
                         if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
                             Redirect(DiscussionUrl($Discussion)) . '?new=1';
                         } else {
                             $this->RedirectUrl = DiscussionUrl($Discussion, '', TRUE) . '?new=1';
                         }
                     } else {
                         // If this was a draft save, notify the user about the save
                         $this->InformMessage(sprintf(T('Draft saved at %s'), Gdn_Format::Date()));
                     }
                 }
             }
         }
     }
     // Add hidden fields for editing
     $this->Form->AddHidden('DiscussionID', $DiscussionID);
     $this->Form->AddHidden('DraftID', $DraftID, TRUE);
     $this->FireEvent('BeforeDiscussionRender');
     if ($this->CategoryID) {
         $Breadcrumbs = CategoryModel::GetAncestors($this->CategoryID);
     } else {
         $Breadcrumbs = array();
     }
     $Breadcrumbs[] = array('Name' => $this->Data('Title'), 'Url' => '/post/discussion');
     $this->SetData('Breadcrumbs', $Breadcrumbs);
     $this->SetData('_AnnounceOptions', $this->AnnounceOptions());
     // Render view (posts/discussion.php or post/preview.php)
     $this->Render();
 }
开发者ID:embo-hd,项目名称:vanilla,代码行数:101,代码来源:class.postcontroller.php

示例3: All

 /**
  * Show all (nested) categories.
  *
  * @since 2.0.17
  * @access public
  */
 public function All()
 {
     // Setup head.
     $this->Menu->HighlightRoute('/discussions');
     $Title = C('Garden.HomepageTitle');
     if ($Title) {
         $this->Title($Title, '');
     } else {
         $this->Title(T('All Categories'));
     }
     Gdn_Theme::Section('CategoryList');
     $this->Description(C('Garden.Description', NULL));
     $this->SetData('Breadcrumbs', array(array('Name' => T('Categories'), 'Url' => '/categories')), CategoryModel::GetAncestors(GetValue('CategoryID', $Category)));
     // Set the category follow toggle before we load category data so that it affects the category query appropriately.
     $CategoryFollowToggleModule = new CategoryFollowToggleModule($this);
     $CategoryFollowToggleModule->SetToggle();
     // Get category data
     $CategoryModel = new CategoryModel();
     $this->CategoryModel->Watching = !Gdn::Session()->GetPreference('ShowAllCategories');
     $Categories = $this->CategoryModel->GetFull()->ResultArray();
     $this->SetData('Categories', $Categories);
     // Add modules
     $this->AddModule('NewDiscussionModule');
     $this->AddModule('DiscussionFilterModule');
     $this->AddModule('BookmarkedModule');
     $this->AddModule($CategoryFollowToggleModule);
     $this->CanonicalUrl(Url('/categories', TRUE));
     // Set a definition of the user's current timezone from the db. jQuery
     // will pick this up, compare to the browser, and update the user's
     // timezone if necessary.
     $CurrentUser = Gdn::Session()->User;
     if (is_object($CurrentUser)) {
         $ClientHour = $CurrentUser->HourOffset + date('G', time());
         $this->AddDefinition('SetClientHour', $ClientHour);
     }
     include_once $this->FetchViewLocation('helper_functions', 'categories');
     $this->Render();
 }
开发者ID:remobjects,项目名称:Garden,代码行数:44,代码来源:class.categoriescontroller.php

示例4: all

 /**
  * Show all (nested) categories.
  *
  * @param string $Category The url code of the parent category.
  * @since 2.0.17
  * @access public
  */
 public function all($Category = '')
 {
     // Setup head.
     $this->Menu->highlightRoute('/discussions');
     if (!$this->title()) {
         $Title = c('Garden.HomepageTitle');
         if ($Title) {
             $this->title($Title, '');
         } else {
             $this->title(t('All Categories'));
         }
     }
     Gdn_Theme::section('CategoryList');
     if (!$Category) {
         $this->Description(c('Garden.Description', null));
     }
     $this->setData('Breadcrumbs', CategoryModel::GetAncestors(val('CategoryID', $this->data('Category'))));
     // Set the category follow toggle before we load category data so that it affects the category query appropriately.
     $CategoryFollowToggleModule = new CategoryFollowToggleModule($this);
     $CategoryFollowToggleModule->SetToggle();
     // Get category data
     $this->CategoryModel->Watching = !Gdn::session()->GetPreference('ShowAllCategories');
     if ($Category) {
         $Subtree = CategoryModel::GetSubtree($Category, false);
         $CategoryIDs = consolidateArrayValuesByKey($Subtree, 'CategoryID');
         $Categories = $this->CategoryModel->GetFull($CategoryIDs)->resultArray();
     } else {
         $Categories = $this->CategoryModel->GetFull()->resultArray();
     }
     $this->setData('Categories', $Categories);
     // Add modules
     $this->addModule('NewDiscussionModule');
     $this->addModule('DiscussionFilterModule');
     $this->addModule('BookmarkedModule');
     $this->addModule($CategoryFollowToggleModule);
     $this->canonicalUrl(url('/categories', true));
     $Location = $this->fetchViewLocation('helper_functions', 'categories', false, false);
     if ($Location) {
         include_once $Location;
     }
     $this->render();
 }
开发者ID:dimassrio,项目名称:vanilla,代码行数:49,代码来源:class.categoriescontroller.php

示例5: Index

 /**
  * Default single discussion display.
  * 
  * @since 2.0.0
  * @access public
  * 
  * @param int $DiscussionID Unique discussion ID
  * @param string $DiscussionStub URL-safe title slug
  * @param int $Page The current page of comments
  */
 public function Index($DiscussionID = '', $DiscussionStub = '', $Page = '')
 {
     // Setup head
     $Session = Gdn::Session();
     $this->AddJsFile('jquery.ui.packed.js');
     $this->AddJsFile('jquery.autogrow.js');
     $this->AddJsFile('options.js');
     $this->AddJsFile('bookmark.js');
     $this->AddJsFile('discussion.js');
     $this->AddJsFile('autosave.js');
     // Load the discussion record
     $DiscussionID = is_numeric($DiscussionID) && $DiscussionID > 0 ? $DiscussionID : 0;
     if (!array_key_exists('Discussion', $this->Data)) {
         $this->SetData('Discussion', $this->DiscussionModel->GetID($DiscussionID), TRUE);
     }
     if (!is_object($this->Discussion)) {
         throw new Exception(sprintf(T('%s Not Found'), T('Discussion')), 404);
     }
     // Define the query offset & limit.
     $Limit = C('Vanilla.Comments.PerPage', 30);
     $OffsetProvided = $Page != '';
     list($Offset, $Limit) = OffsetLimit($Page, $Limit);
     // Set the canonical url to have the proper page title.
     $this->CanonicalUrl(Url(ConcatSep('/', 'discussion/' . $this->Discussion->DiscussionID . '/' . Gdn_Format::Url($this->Discussion->Name), PageNumber($Offset, $Limit, TRUE, Gdn::Session()->UserID != 0)), TRUE), Gdn::Session()->UserID == 0);
     // Check permissions
     $this->Permission('Vanilla.Discussions.View', TRUE, 'Category', $this->Discussion->PermissionCategoryID);
     $this->SetData('CategoryID', $this->CategoryID = $this->Discussion->CategoryID, TRUE);
     $this->SetData('Breadcrumbs', CategoryModel::GetAncestors($this->CategoryID));
     // Setup
     $this->Title($this->Discussion->Name);
     // Actual number of comments, excluding the discussion itself
     $ActualResponses = $this->Discussion->CountComments - 1;
     // If $Offset isn't defined, assume that the user has not clicked to
     // view a next or previous page, and this is a "view" to be counted.
     // NOTE: This has been moved to an event fired from analyticstick.
     //      if ($Offset == '')
     //         $this->DiscussionModel->AddView($DiscussionID, $this->Discussion->CountViews);
     $this->Offset = $Offset;
     if (C('Vanilla.Comments.AutoOffset')) {
         if ($this->Discussion->CountCommentWatch > 1 && $OffsetProvided == '') {
             $this->AddDefinition('ScrollTo', 'a[name=Item_' . $this->Discussion->CountCommentWatch . ']');
         }
         if (!is_numeric($this->Offset) || $this->Offset < 0 || !$OffsetProvided) {
             // Round down to the appropriate offset based on the user's read comments & comments per page
             $CountCommentWatch = $this->Discussion->CountCommentWatch > 0 ? $this->Discussion->CountCommentWatch : 0;
             if ($CountCommentWatch > $ActualResponses) {
                 $CountCommentWatch = $ActualResponses;
             }
             // (((67 comments / 10 perpage) = 6.7) rounded down = 6) * 10 perpage = offset 60;
             $this->Offset = floor($CountCommentWatch / $Limit) * $Limit;
         }
         if ($ActualResponses <= $Limit) {
             $this->Offset = 0;
         }
         if ($this->Offset == $ActualResponses) {
             $this->Offset -= $Limit;
         }
     } else {
         if ($this->Offset == '') {
             $this->Offset = 0;
         }
     }
     if ($this->Offset < 0) {
         $this->Offset = 0;
     }
     // Load the comments
     $this->SetData('CommentData', $this->CommentModel->Get($DiscussionID, $Limit, $this->Offset), TRUE);
     $this->SetData('Comments', $this->CommentData);
     // Make sure to set the user's discussion watch records
     $this->CommentModel->SetWatch($this->Discussion, $this->CommentData->NumRows(), $this->Offset, $this->Discussion->CountComments);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->EventArguments['PagerType'] = 'Pager';
     $this->FireEvent('BeforeBuildPager');
     $this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Configure($this->Offset, $Limit, $ActualResponses, 'discussion/' . $DiscussionID . '/' . Gdn_Format::Url($this->Discussion->Name) . '/%1$s');
     $this->FireEvent('AfterBuildPager');
     // Define the form for the comment input
     $this->Form = Gdn::Factory('Form', 'Comment');
     $this->Form->Action = Url('/vanilla/post/comment/');
     $this->DiscussionID = $this->Discussion->DiscussionID;
     $this->Form->AddHidden('DiscussionID', $this->DiscussionID);
     $this->Form->AddHidden('CommentID', '');
     // Retrieve & apply the draft if there is one:
     if (Gdn::Session()->UserID) {
         $DraftModel = new DraftModel();
         $Draft = $DraftModel->Get($Session->UserID, 0, 1, $this->Discussion->DiscussionID)->FirstRow();
         $this->Form->AddHidden('DraftID', $Draft ? $Draft->DraftID : '');
         if ($Draft) {
//.........这里部分代码省略.........
开发者ID:Raz0r,项目名称:Garden,代码行数:101,代码来源:class.discussioncontroller.php

示例6: All

 /**
  * Show all (nested) categories.
  *
  * @since 2.0.17
  * @access public
  */
 public function All()
 {
     // Setup head.
     $this->Menu->HighlightRoute('/discussions');
     if (!$this->Title()) {
         $Title = C('Garden.HomepageTitle');
         if ($Title) {
             $this->Title($Title, '');
         } else {
             $this->Title(T('All Categories'));
         }
     }
     Gdn_Theme::Section('CategoryList');
     $this->Description(C('Garden.Description', NULL));
     $this->SetData('Breadcrumbs', CategoryModel::GetAncestors(GetValue('CategoryID', $this->Data('Category'))));
     // Set the category follow toggle before we load category data so that it affects the category query appropriately.
     $CategoryFollowToggleModule = new CategoryFollowToggleModule($this);
     $CategoryFollowToggleModule->SetToggle();
     // Get category data
     $this->CategoryModel->Watching = !Gdn::Session()->GetPreference('ShowAllCategories');
     $Categories = $this->CategoryModel->GetFull()->ResultArray();
     $this->SetData('Categories', $Categories);
     // Add modules
     $this->AddModule('NewDiscussionModule');
     $this->AddModule('DiscussionFilterModule');
     $this->AddModule('BookmarkedModule');
     $this->AddModule($CategoryFollowToggleModule);
     $this->CanonicalUrl(Url('/categories', TRUE));
     $Location = $this->FetchViewLocation('helper_functions', 'categories', FALSE, FALSE);
     if ($Location) {
         include_once $Location;
     }
     $this->Render();
 }
开发者ID:bishopb,项目名称:vanilla,代码行数:40,代码来源:class.categoriescontroller.php

示例7: Index

 /**
  * 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')
 {
     $Category = CategoryModel::Categories($CategoryIdentifier);
     if (empty($Category)) {
         if ($CategoryIdentifier) {
             throw NotFoundException();
         }
     }
     $Category = (object) $Category;
     // Load the breadcrumbs.
     $this->SetData('Breadcrumbs', CategoryModel::GetAncestors(GetValue('CategoryID', $Category)));
     $this->SetData('Category', $Category, TRUE);
     // Setup head
     $this->AddCssFile('vanilla.css');
     $this->Menu->HighlightRoute('/discussions');
     if ($this->Head) {
         $this->Head->Title(GetValue('Name', $Category, ''));
         $this->AddJsFile('discussions.js');
         $this->AddJsFile('bookmark.js');
         $this->AddJsFile('options.js');
         $this->AddJsFile('jquery.gardenmorepager.js');
         $this->Head->AddRss($this->SelfUrl . '/feed.rss', $this->Head->Title());
     }
     // Set CategoryID
     $this->SetData('CategoryID', GetValue('CategoryID', $Category), TRUE);
     // Add modules
     $this->AddModule('NewDiscussionModule');
     $this->AddModule('CategoriesModule');
     $this->AddModule('BookmarkedModule');
     // Get a DiscussionModel
     $DiscussionModel = new DiscussionModel();
     $Wheres = array('d.CategoryID' => $this->CategoryID);
     // 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);
     $AnnounceData = $Offset == 0 ? $DiscussionModel->GetAnnouncements($Wheres) : new Gdn_DataSet();
     $this->SetData('AnnounceData', $AnnounceData, TRUE);
     $this->DiscussionData = $this->SetData('Discussions', $DiscussionModel->Get($Offset, $Limit, $Wheres));
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->Pager = $PagerFactory->GetPager('Pager', $this);
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Configure($Offset, $Limit, $CountDiscussions, 'categories/' . $CategoryIdentifier . '/%1$s');
     $this->SetData('_PagerUrl', 'categories/' . rawurlencode($CategoryIdentifier) . '/{Page}');
     $this->SetData('_Page', $Page);
     // Set the canonical Url.
     $this->CanonicalUrl(Url(ConcatSep('/', 'categories/' . GetValue('UrlCode', $Category, $CategoryIdentifier), PageNumber($Offset, $Limit, TRUE, FALSE)), TRUE));
     // 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->Render();
 }
开发者ID:Raz0r,项目名称:Garden,代码行数:78,代码来源:class.categoriescontroller.php

示例8: all

 /**
  * Show all (nested) categories.
  *
  * @param string $Category The url code of the parent category.
  * @param string $displayAs
  * @since 2.0.17
  * @access public
  */
 public function all($Category = '', $displayAs = '')
 {
     // Setup head.
     $this->Menu->highlightRoute('/discussions');
     if (!$this->title()) {
         $Title = c('Garden.HomepageTitle');
         if ($Title) {
             $this->title($Title, '');
         } else {
             $this->title(t('All Categories'));
         }
     }
     Gdn_Theme::section('CategoryList');
     if (!$Category) {
         $this->Description(c('Garden.Description', null));
     }
     $this->setData('Breadcrumbs', CategoryModel::GetAncestors(val('CategoryID', $this->data('Category'))));
     // Set the category follow toggle before we load category data so that it affects the category query appropriately.
     $CategoryFollowToggleModule = new CategoryFollowToggleModule($this);
     $CategoryFollowToggleModule->SetToggle();
     // Get category data
     $this->CategoryModel->Watching = !Gdn::session()->GetPreference('ShowAllCategories');
     if ($Category) {
         $this->setData('Category', CategoryModel::categories($Category));
         $this->categoriesCompatibilityCallback = function () use($Category) {
             $Subtree = CategoryModel::GetSubtree($Category, false);
             $CategoryIDs = array_column($Subtree, 'CategoryID');
             return $this->CategoryModel->GetFull($CategoryIDs)->resultArray();
         };
     } else {
         $this->categoriesCompatibilityCallback = function () {
             return $this->CategoryModel->GetFull()->resultArray();
         };
     }
     $this->setData('CategoryTree', $this->getCategoryTree($Category ?: -1, $Category ? null : CategoryModel::getRootDisplayAs(), true, true));
     // Add modules
     $this->addModule('NewDiscussionModule');
     $this->addModule('DiscussionFilterModule');
     $this->addModule('BookmarkedModule');
     $this->addModule($CategoryFollowToggleModule);
     $this->canonicalUrl(url('/categories', true));
     if ($this->View === 'all' && $displayAs === 'Flat') {
         $this->View = 'flat_all';
     }
     $Location = $this->fetchViewLocation('helper_functions', 'categories', false, false);
     if ($Location) {
         include_once $Location;
     }
     $this->render();
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:58,代码来源:class.categoriescontroller.php


注:本文中的CategoryModel::GetAncestors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。