Пример #1
0
 public function SettingsController_DashboardData_Handler(&$Sender)
 {
     $DiscussionModel = new Gdn_DiscussionModel();
     // Number of Discussions
     $CountDiscussions = $DiscussionModel->GetCount();
     $Sender->AddDefinition('CountDiscussions', $CountDiscussions);
     $Sender->BuzzData[Gdn::Translate('Discussions')] = number_format($CountDiscussions);
     // Number of New Discussions in the last day
     $Sender->BuzzData[Translate('New discussions in the last day')] = number_format($DiscussionModel->GetCount(array('d.DateInserted >=' => Format::ToDateTime(strtotime('-1 day')))));
     // Number of New Discussions in the last week
     $Sender->BuzzData[Translate('New discussions in the last week')] = number_format($DiscussionModel->GetCount(array('d.DateInserted >=' => Format::ToDateTime(strtotime('-1 week')))));
     $CommentModel = new Gdn_CommentModel();
     // Number of Comments
     $CountComments = $CommentModel->GetCountWhere();
     $Sender->AddDefinition('CountComments', $CountComments);
     $Sender->BuzzData[Gdn::Translate('Comments')] = number_format($CountComments);
     // Number of New Comments in the last day
     $Sender->BuzzData[Translate('New comments in the last day')] = number_format($CommentModel->GetCountWhere(array('DateInserted >=' => Format::ToDateTime(strtotime('-1 day')))));
     // Number of New Comments in the last week
     $Sender->BuzzData[Translate('New comments in the last week')] = number_format($CommentModel->GetCountWhere(array('DateInserted >=' => Format::ToDateTime(strtotime('-1 week')))));
 }
Пример #2
0
 /**
  * Show all discussions in a particular category.
  */
 public function Index($CategoryIdentifier = '', $Offset = '0')
 {
     if (!is_numeric($CategoryIdentifier)) {
         $Category = $this->CategoryModel->GetFullByName(urldecode($CategoryIdentifier));
     } else {
         $Category = $this->CategoryModel->GetFull($CategoryIdentifier);
     }
     $this->SetData('Category', $Category, TRUE);
     if ($Category === FALSE) {
         return $this->All();
     }
     $this->AddCssFile('vanilla.css');
     $this->Menu->HighlightRoute('/discussions');
     if ($this->Head) {
         $this->Head->Title($Category->Name);
         $this->Head->AddScript('/applications/vanilla/js/discussions.js');
         $this->Head->AddScript('/applications/vanilla/js/options.js');
         $this->Head->AddScript('/js/library/jquery.gardenmorepager.js');
         $this->Head->AddRss('/rss/' . $this->SelfUrl, $this->Head->Title());
     }
     if (!is_numeric($Offset) || $Offset < 0) {
         $Offset = 0;
     }
     $this->SetData('CategoryID', $this->Category->CategoryID, TRUE);
     // Add Modules
     $this->AddModule('NewDiscussionModule');
     $this->AddModule('CategoriesModule');
     $BookmarkedModule = new BookmarkedModule($this);
     $BookmarkedModule->GetData();
     $this->AddModule($BookmarkedModule);
     $DraftsModule = new DraftsModule($this);
     $DraftsModule->GetData();
     $this->AddModule($DraftsModule);
     $Limit = Gdn::Config('Vanilla.Discussions.PerPage', 30);
     $DiscussionModel = new Gdn_DiscussionModel();
     $Wheres = array('d.CategoryID' => $this->CategoryID);
     $this->Permission('Vanilla.Discussions.View', $this->CategoryID);
     $CountDiscussions = $DiscussionModel->GetCount($Wheres);
     $this->SetData('CountDiscussions', $CountDiscussions);
     $TmpLimit = $Limit;
     $AnnounceData = FALSE;
     if ($Offset == 0) {
         $AnnounceData = $DiscussionModel->GetAnnouncements($Wheres);
         $TmpLimit = $Limit - $AnnounceData->NumRows();
     }
     $this->SetData('AnnounceData', $AnnounceData, TRUE);
     $this->SetData('DiscussionData', $DiscussionModel->Get($Offset, $TmpLimit, $Wheres), TRUE);
     // Build a pager
     $PagerFactory = new PagerFactory();
     $this->Pager = $PagerFactory->GetPager('MorePager', $this);
     $this->Pager->MoreCode = 'More Discussions';
     $this->Pager->LessCode = 'Newer Discussions';
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Configure($Offset, $Limit, $CountDiscussions, 'categories/' . $CategoryIdentifier . '/%1$s');
     // 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 the controller
     $this->Render();
 }
Пример #3
0
 public function Mine($Offset = '0')
 {
     $this->Permission('Garden.SignIn.Allow');
     $this->AddJsFile('/js/library/jquery.resizable.js');
     $this->AddJsFile('/js/library/jquery.ui.packed.js');
     $this->AddJsFile('bookmark.js');
     $this->AddJsFile('discussions.js');
     $this->AddJsFile('options.js');
     $this->Title(Translate('My Discussions'));
     if (!is_numeric($Offset) || $Offset < 0) {
         $Offset = 0;
     }
     $Limit = Gdn::Config('Vanilla.Discussions.PerPage', 30);
     $Session = Gdn::Session();
     $Wheres = array('d.InsertUserID' => $Session->UserID);
     $DiscussionModel = new Gdn_DiscussionModel();
     $this->SetData('DiscussionData', $DiscussionModel->Get($Offset, $Limit, $Wheres), TRUE);
     $CountDiscussions = $this->SetData('CountDiscussions', $DiscussionModel->GetCount($Wheres));
     // Build a pager
     $PagerFactory = new PagerFactory();
     $this->Pager = $PagerFactory->GetPager('MorePager', $this);
     $this->Pager->MoreCode = 'More Discussions';
     $this->Pager->LessCode = 'Newer Discussions';
     $this->Pager->Wrapper = '<li %1$s>%2$s</li>';
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Configure($Offset, $Limit, $CountDiscussions, 'discussions/mine/%1$s');
     // 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';
     }
     // Add Modules
     $this->AddModule('NewDiscussionModule');
     $this->AddModule('CategoriesModule');
     $BookmarkedModule = new BookmarkedModule($this);
     $BookmarkedModule->GetData();
     $this->AddModule($BookmarkedModule);
     // Render the controller
     $this->Render();
 }