예제 #1
0
 protected function Build()
 {
     $DiscussionModel = new DiscussionModel();
     $Offset = 0;
     $Limit = 1000;
     while ($Discussions = $DiscussionModel->Get($Offset, $Limit)) {
         if (!$Discussions->NumRows()) {
             break;
         }
         $Offset += $Discussions->NumRows();
         $Day = 24 * 3600;
         $Week = 7 * $Day;
         $Month = 4 * $Week;
         $Year = 12 * $Month;
         $PriorityMatrix = array('hourly' => 1, 'daily' => 0.8, 'weekly' => 0.6, 'monthly' => 0.4, 'yearly' => 0.2);
         while ($Discussion = $Discussions->NextRow()) {
             $ChangeFreq = 'hourly';
             $DiffDate = time() - strtotime($Discussion->DateLastComment);
             $Priority = 1;
             if ($DiffDate < $Day) {
                 $ChangeFreq = 'hourly';
             } elseif ($DiffDate < $Week) {
                 $ChangeFreq = 'daily';
             } elseif ($DiffDate < $Month) {
                 $ChangeFreq = 'weekly';
             } elseif ($DiffDate < $Year) {
                 $ChangeFreq = 'monthly';
             } else {
                 $ChangeFreq = 'yearly';
             }
             $this->MapItem(DiscussionLink($Discussion, FALSE), date('Y-m-d', strtotime($Discussion->DateLastComment)), $ChangeFreq, $PriorityMatrix[$ChangeFreq]);
         }
     }
     $this->WriteIndex();
 }
   public function GetData($Limit = 10) {
      $this->Data = FALSE;
      if (Gdn::Session()->IsValid() && C('Vanilla.Modules.ShowBookmarkedModule', TRUE)) {
         $BookmarkIDs = Gdn::SQL()
            ->Select('DiscussionID')
            ->From('UserDiscussion')
            ->Where('UserID', Gdn::Session()->UserID)
            ->Where('Bookmarked', 1)
            ->Get()->ResultArray();
         $BookmarkIDs = ConsolidateArrayValuesByKey($BookmarkIDs, 'DiscussionID');

         if (count($BookmarkIDs)) {
            $DiscussionModel = new DiscussionModel();
            DiscussionModel::CategoryPermissions();

            $DiscussionModel->SQL->WhereIn('d.DiscussionID', $BookmarkIDs);
            
            $this->Data = $DiscussionModel->Get(
               0,
               $Limit
            );
         } else {
            $this->Data = FALSE;
         }
      }
   }
예제 #3
0
 public function GetData($Limit = 10)
 {
     $Session = Gdn::Session();
     if ($Session->IsValid()) {
         $DiscussionModel = new DiscussionModel();
         $this->_DiscussionData = $DiscussionModel->Get(0, $Limit, array('w.Bookmarked' => '1', 'w.UserID' => $Session->UserID));
     }
 }
 public function GetData($Limit = FALSE)
 {
     if (!$Limit) {
         $Limit = $this->Limit;
     }
     $DiscussionModel = new DiscussionModel();
     $this->SetData('Discussions', $DiscussionModel->Get(0, $Limit, array('Announce' => 'all')));
 }
예제 #5
0
 /**
  * Load discussions for a specific tag.
  */
 public function DiscussionsController_Tagged_Create($Sender)
 {
     $Offset = GetValue('1', $Sender->RequestArgs, 'p1');
     list($Offset, $Limit) = OffsetLimit($Offset, Gdn::Config('Vanilla.Discussions.PerPage', 30));
     $Sender->Tag = GetValue('0', $Sender->RequestArgs, '');
     $Sender->Title(T('Tagged with ') . $Sender->Tag);
     $Sender->Head->Title($Sender->Head->Title());
     $Sender->CanonicalUrl(Url(ConcatSep('/', 'discussions/tagged/' . $Sender->Tag, PageNumber($Offset, $Limit, TRUE)), TRUE));
     if ($Sender->Head) {
         $Sender->AddJsFile('discussions.js');
         $Sender->AddJsFile('bookmark.js');
         $Sender->AddJsFile('js/library/jquery.menu.js');
         $Sender->AddJsFile('options.js');
         $Sender->Head->AddRss($Sender->SelfUrl . '/feed.rss', $Sender->Head->Title());
     }
     if (!is_numeric($Offset) || $Offset < 0) {
         $Offset = 0;
     }
     // Add Modules
     $Sender->AddModule('NewDiscussionModule');
     $BookmarkedModule = new BookmarkedModule($Sender);
     $BookmarkedModule->GetData();
     $Sender->AddModule($BookmarkedModule);
     $Sender->SetData('Category', FALSE, TRUE);
     $DiscussionModel = new DiscussionModel();
     $Tag = $DiscussionModel->SQL->Select()->From('Tag')->Where('Name', $Sender->Tag)->Get()->FirstRow();
     $TagID = $Tag ? $Tag->TagID : 0;
     $CountDiscussions = $Tag ? $Tag->CountDiscussions : 0;
     $Sender->SetData('CountDiscussions', $CountDiscussions);
     $Sender->AnnounceData = FALSE;
     $Sender->SetData('Announcements', array(), TRUE);
     $DiscussionModel->FilterToTagID = $TagID;
     $Sender->DiscussionData = $DiscussionModel->Get($Offset, $Limit);
     $Sender->SetData('Discussions', $Sender->DiscussionData, TRUE);
     $Sender->SetJson('Loading', $Offset . ' to ' . $Limit);
     // Build a pager.
     $PagerFactory = new Gdn_PagerFactory();
     $Sender->Pager = $PagerFactory->GetPager('Pager', $Sender);
     $Sender->Pager->ClientID = 'Pager';
     $Sender->Pager->Configure($Offset, $Limit, $CountDiscussions, 'discussions/tagged/' . $Sender->Tag . '/%1$s');
     // Deliver json data if necessary
     if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL) {
         $Sender->SetJson('LessRow', $Sender->Pager->ToString('less'));
         $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more'));
         $Sender->View = 'discussions';
     }
     // 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());
         $Sender->AddDefinition('SetClientHour', $ClientHour);
     }
     // Render the controller
     $Sender->Render(PATH_PLUGINS . '/Tagging/views/taggeddiscussions.php');
 }
 public function GetData()
 {
     if (Gdn::Session()->IsValid()) {
         $BookmarkIDs = Gdn::SQL()->Select('DiscussionID')->From('UserDiscussion')->Where('UserID', Gdn::Session()->UserID)->Where('Bookmarked', 1)->Get()->ResultArray();
         $BookmarkIDs = ConsolidateArrayValuesByKey($BookmarkIDs, 'DiscussionID');
         if (count($BookmarkIDs)) {
             $DiscussionModel = new DiscussionModel();
             DiscussionModel::CategoryPermissions();
             $DiscussionModel->SQL->WhereIn('d.DiscussionID', $BookmarkIDs);
             $Bookmarks = $DiscussionModel->Get(0, $this->Limit, array('w.Bookmarked' => '1'));
             $this->SetData('Bookmarks', $Bookmarks);
         } else {
             $this->SetData('Bookmarks', new Gdn_DataSet());
         }
     }
 }
 public function Index()
 {
     $Session = Gdn::Session();
     $categories = array();
     $discussionsPerCategory = 4;
     $DiscussionModel = new DiscussionModel();
     $this->CategoryData = $this->CategoryModel->GetFull();
     $this->CategoryDiscussionData = array();
     foreach ($this->CategoryData->Result() as $Category) {
         $this->Category = $Category;
         if ($Session->CheckPermission('Vanilla.Discussions.View', $this->Category->CategoryID)) {
             //TODO be nice if options could be passed to filter
             // discussions that are closed, sunk, etc etc...
             $this->DiscussionData = $DiscussionModel->Get(0, $discussionsPerCategory, array('d.CategoryID' => $Category->CategoryID));
             $category = array();
             foreach ($Category as $key => $value) {
                 $category[$key] = $value;
             }
             #$category["CategoryURL"] = Gdn::Config('Garden.Domain')."/categories/".$Category->UrlCode;
             $category["CategoryURL"] = Gdn::Request()->Domain() . "/categories/" . $Category->UrlCode;
             if ($this->DiscussionData->NumRows() > 0) {
                 $count = 0;
                 $discussion = array();
                 $category["discussions"] = array();
                 foreach ($this->DiscussionData->Result() as $Discussion) {
                     foreach ($Discussion as $key => $value) {
                         $discussion[$key] = $value;
                     }
                     //$discussion["DiscussionURL"] = Gdn::Config('Garden.Domain').'/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name);
                     $discussion["DiscussionURL"] = Gdn::Request()->Domain() . '/discussion/' . $Discussion->DiscussionID . '/' . Gdn_Format::Url($Discussion->Name);
                     if ($count++ < $discussionsPerCategory) {
                         $category["discussions"][] = $discussion;
                     } else {
                         break;
                     }
                 }
             }
             $categories[] = $category;
         }
     }
     $this->SetJSON("categories", $categories);
     $this->Render();
 }
예제 #8
0
파일: hooks.php 프로젝트: kidmax/Garden
 public function ProfileController_Discussions_Create(&$Sender)
 {
     $UserReference = ArrayValue(0, $Sender->EventArguments, '');
     $Offset = ArrayValue(1, $Sender->EventArguments, 0);
     // Tell the ProfileController what tab to load
     $Sender->SetTabView($UserReference, 'Discussions', 'Profile', 'Discussions', 'Vanilla');
     // Load the data for the requested tab.
     if (!is_numeric($Offset) || $Offset < 0) {
         $Offset = 0;
     }
     $Limit = Gdn::Config('Vanilla.Discussions.PerPage', 30);
     $DiscussionModel = new DiscussionModel();
     $Sender->DiscussionData = $DiscussionModel->Get($Offset, $Limit, array('d.InsertUserID' => $Sender->User->UserID));
     $CountDiscussions = $Offset + $Sender->DiscussionData->NumRows();
     if ($Sender->DiscussionData->NumRows() == $Limit) {
         $CountDiscussions = $Offset + $Limit + 1;
     }
     // Build a pager
     $PagerFactory = new PagerFactory();
     $Sender->Pager = $PagerFactory->GetPager('MorePager', $Sender);
     $Sender->Pager->MoreCode = 'More Discussions';
     $Sender->Pager->LessCode = 'Newer Discussions';
     $Sender->Pager->ClientID = 'Pager';
     $Sender->Pager->Configure($Offset, $Limit, $CountDiscussions, 'profile/discussions/' . urlencode($Sender->User->Name) . '/%1$s/');
     // Deliver json data if necessary
     if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL && $Offset > 0) {
         $Sender->SetJson('LessRow', $Sender->Pager->ToString('less'));
         $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more'));
         $Sender->View = 'discussions';
     }
     // Set the handlertype back to normal on the profilecontroller so that it fetches it's own views
     $Sender->HandlerType = HANDLER_TYPE_NORMAL;
     // Do not show discussion options
     $Sender->ShowOptions = FALSE;
     // Render the ProfileController
     $Sender->Render();
 }
예제 #9
0
 /**
  * Load discussions for a specific tag.
  */
 public function DiscussionsController_Tagged_Create($Sender)
 {
     if ($Sender->Request->Get('Tag')) {
         $Tag = $Sender->Request->Get('Tag');
         $Page = GetValue('0', $Sender->RequestArgs, 'p1');
     } else {
         $Tag = urldecode(GetValue('0', $Sender->RequestArgs, ''));
         $Page = GetValue('1', $Sender->RequestArgs, 'p1');
     }
     if ($Sender->Request->Get('Page')) {
         $Page = $Sender->Request->Get('Page');
     }
     $Tag = StringEndsWith($Tag, '.rss', TRUE, TRUE);
     list($Offset, $Limit) = OffsetLimit($Page, Gdn::Config('Vanilla.Discussions.PerPage', 30));
     $Sender->SetData('Tag', $Tag, TRUE);
     $Sender->Title(T('Tagged with ') . htmlspecialchars($Tag));
     $Sender->Head->Title($Sender->Head->Title());
     if (urlencode($Tag) == $Tag) {
         $Sender->CanonicalUrl(Url(ConcatSep('/', 'discussions/tagged/' . urlencode($Tag), PageNumber($Offset, $Limit, TRUE)), TRUE));
     } else {
         $Sender->CanonicalUrl(Url(ConcatSep('/', 'discussions/tagged', PageNumber($Offset, $Limit, TRUE)) . '?Tag=' . urlencode($Tag), TRUE));
     }
     if ($Sender->Head) {
         $Sender->AddJsFile('discussions.js');
         $Sender->AddJsFile('bookmark.js');
         $Sender->AddJsFile('js/library/jquery.menu.js');
         $Sender->AddJsFile('options.js');
         $Sender->Head->AddRss($Sender->SelfUrl . '/feed.rss', $Sender->Head->Title());
     }
     if (!is_numeric($Offset) || $Offset < 0) {
         $Offset = 0;
     }
     // Add Modules
     $Sender->AddModule('NewDiscussionModule');
     $BookmarkedModule = new BookmarkedModule($Sender);
     $BookmarkedModule->GetData();
     $Sender->AddModule($BookmarkedModule);
     $Sender->SetData('Category', FALSE, TRUE);
     $Sender->SetData('CountDiscussions', FALSE);
     $Sender->AnnounceData = FALSE;
     $Sender->SetData('Announcements', array(), TRUE);
     $DiscussionModel = new DiscussionModel();
     $this->_SetTagSql($DiscussionModel->SQL, $Tag, $Limit, $Offset, $Sender->Request->Get('op', 'or'));
     $Sender->DiscussionData = $DiscussionModel->Get(FALSE);
     $Sender->SetData('Discussions', $Sender->DiscussionData, TRUE);
     $Sender->SetJson('Loading', $Offset . ' to ' . $Limit);
     // Build a pager.
     $PagerFactory = new Gdn_PagerFactory();
     $Sender->Pager = $PagerFactory->GetPager('Pager', $Sender);
     $Sender->Pager->ClientID = 'Pager';
     if (urlencode($Sender->Tag) == $Sender->Tag) {
         $PageUrlFormat = "discussions/tagged/{$Sender->Tag}/{Page}";
     } else {
         $PageUrlFormat = 'discussions/tagged/{Page}?Tag=' . urlencode($Sender->Tag);
     }
     $Sender->Pager->Configure($Offset, $Limit, FALSE, $PageUrlFormat);
     // Deliver json data if necessary.
     if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL) {
         $Sender->SetJson('LessRow', $Sender->Pager->ToString('less'));
         $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more'));
         $Sender->View = 'discussions';
     }
     // 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());
         $Sender->AddDefinition('SetClientHour', $ClientHour);
     }
     // Render the controller
     $Sender->Render('TaggedDiscussions', '', 'plugins/Tagging');
 }
예제 #10
0
 public function Mine($Offset = '0')
 {
     $this->Permission('Garden.SignIn.Allow');
     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 DiscussionModel();
     $this->DiscussionData = $DiscussionModel->Get($Offset, $Limit, $Wheres);
     $this->SetData('Discussions', $this->DiscussionData);
     $CountDiscussions = $this->SetData('CountDiscussions', $DiscussionModel->GetCount($Wheres));
     // Build a pager
     $PagerFactory = new Gdn_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, '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();
 }
예제 #11
0
 /**
  * Unanswered discussions list.
  */
 public function DiscussionsController_Unanswered_Create($Sender, $Args)
 {
     $Sender->Permission('Garden.Moderation.Manage');
     $Page = ArrayValue(0, $Args, 0);
     // Determine offset from $Page
     list($Page, $Limit) = OffsetLimit($Page, C('Vanilla.Discussions.PerPage', 30));
     // Validate $Page
     if (!is_numeric($Page) || $Page < 0) {
         $Page = 0;
     }
     $DiscussionModel = new DiscussionModel();
     $Wheres = array('d.Answered' => '0');
     $Sender->DiscussionData = $DiscussionModel->Get($Page, $Limit, $Wheres);
     $Sender->SetData('Discussions', $Sender->DiscussionData);
     $CountDiscussions = $DiscussionModel->GetCount($Wheres);
     $Sender->SetData('CountDiscussions', $CountDiscussions);
     $Sender->Category = FALSE;
     $Sender->SetJson('Loading', $Page . ' to ' . $Limit);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $Sender->EventArguments['PagerType'] = 'Pager';
     $Sender->FireEvent('BeforeBuildBookmarkedPager');
     $Sender->Pager = $PagerFactory->GetPager($Sender->EventArguments['PagerType'], $Sender);
     $Sender->Pager->ClientID = 'Pager';
     $Sender->Pager->Configure($Page, $Limit, $CountDiscussions, 'discussions/unanswered/%1$s');
     if (!$Sender->Data('_PagerUrl')) {
         $Sender->SetData('_PagerUrl', 'discussions/unanswered/{Page}');
     }
     $Sender->SetData('_Page', $Page);
     $Sender->SetData('_Limit', $Limit);
     $Sender->FireEvent('AfterBuildBookmarkedPager');
     // Deliver JSON data if necessary
     if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL) {
         $Sender->SetJson('LessRow', $Sender->Pager->ToString('less'));
         $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more'));
         $Sender->View = 'discussions';
     }
     // Add modules
     $Sender->AddModule('DiscussionFilterModule');
     $Sender->AddModule('NewDiscussionModule');
     $Sender->AddModule('CategoriesModule');
     // Render default view (discussions/bookmarked.php)
     $Sender->SetData('Title', T('Unanswered'));
     $Sender->SetData('Breadcrumbs', array(array('Name' => T('Unanswered'), 'Url' => '/discussions/unanswered')));
     $Sender->Render('index');
 }
 /**
  * Display discussions started by the user.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $Offset Number of discussions to skip.
  */
 public function Mine($Page = 'p1')
 {
     $this->Permission('Garden.SignIn.Allow');
     Gdn_Theme::Section('DiscussionList');
     // Set criteria & get discussions data
     list($Offset, $Limit) = OffsetLimit($Page, C('Vanilla.Discussions.PerPage', 30));
     $Session = Gdn::Session();
     $Wheres = array('d.InsertUserID' => $Session->UserID);
     $DiscussionModel = new DiscussionModel();
     $this->DiscussionData = $DiscussionModel->Get($Offset, $Limit, $Wheres);
     $this->SetData('Discussions', $this->DiscussionData);
     $CountDiscussions = $this->SetData('CountDiscussions', $DiscussionModel->GetCount($Wheres));
     $this->View = 'index';
     if (C('Vanilla.Discussions.Layout') === 'table') {
         $this->View = 'table';
     }
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->EventArguments['PagerType'] = 'MorePager';
     $this->FireEvent('BeforeBuildMinePager');
     $this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
     $this->Pager->MoreCode = 'More Discussions';
     $this->Pager->LessCode = 'Newer Discussions';
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Configure($Offset, $Limit, $CountDiscussions, 'discussions/mine/%1$s');
     $this->SetData('_PagerUrl', 'discussions/mine/{Page}');
     $this->SetData('_Page', $Page);
     $this->SetData('_Limit', $Limit);
     $this->FireEvent('AfterBuildMinePager');
     // 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('DiscussionFilterModule');
     $this->AddModule('NewDiscussionModule');
     $this->AddModule('CategoriesModule');
     $this->AddModule('BookmarkedModule');
     // Render view
     $this->SetData('Title', T('My Discussions'));
     $this->SetData('Breadcrumbs', array(array('Name' => T('My Discussions'), 'Url' => '/discussions/mine')));
     $this->Render();
 }
예제 #13
0
 public function Mine($Offset = '0')
 {
     $this->Permission('Garden.SignIn.Allow');
     if ($this->Head) {
         $this->Head->AddScript('/js/library/jquery.resizable.js');
         $this->Head->AddScript('/js/library/jquery.ui.packed.js');
         $this->Head->AddScript('/applications/vanilla/js/bookmark.js');
         $this->Head->AddScript('/applications/vanilla/js/discussions.js');
         $this->Head->AddScript('/applications/vanilla/js/options.js');
     }
     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 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);
     $DraftsModule = new DraftsModule($this);
     $DraftsModule->GetData();
     $this->AddModule($DraftsModule);
     // Render the controller
     $this->Render();
 }
 /**
  * Show all categories and few discussions from each.
  * 
  * @since 2.0.0
  * @access public
  */
 public function Discussions()
 {
     // Setup head
     $this->AddCssFile('vanilla.css');
     $this->Menu->HighlightRoute('/discussions');
     $this->AddJsFile('bookmark.js');
     $this->AddJsFile('discussions.js');
     $this->AddJsFile('options.js');
     $Title = C('Garden.HomepageTitle');
     if ($Title) {
         $this->Title($Title, '');
     } else {
         $this->Title(T('All Categories'));
     }
     $this->Description(C('Garden.Description', NULL));
     Gdn_Theme::Section('CategoryDiscussionList');
     // 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 and discussions
     $this->DiscussionsPerCategory = C('Vanilla.Discussions.PerCategory', 5);
     $DiscussionModel = new DiscussionModel();
     $this->CategoryModel->Watching = !Gdn::Session()->GetPreference('ShowAllCategories');
     $this->CategoryData = $this->CategoryModel->GetFull();
     $this->SetData('Categories', $this->CategoryData);
     $this->CategoryDiscussionData = array();
     foreach ($this->CategoryData->Result() as $Category) {
         if ($Category->CategoryID > 0) {
             $this->CategoryDiscussionData[$Category->CategoryID] = $DiscussionModel->Get(0, $this->DiscussionsPerCategory, array('d.CategoryID' => $Category->CategoryID, 'Announce' => 'all'));
         }
     }
     // Add modules
     $this->AddModule('NewDiscussionModule');
     $this->AddModule('DiscussionFilterModule');
     $this->AddModule('CategoriesModule');
     $this->AddModule('BookmarkedModule');
     $this->AddModule($CategoryFollowToggleModule);
     // Set view and render
     $this->View = 'discussions';
     $this->CanonicalUrl(Url('/categories', TRUE));
     include_once $this->FetchViewLocation('helper_functions', 'discussions');
     $this->Render();
 }
예제 #15
0
 public function GetDiscussions($Tag, $Limit, $Offset, $Op = 'or')
 {
     $DiscussionModel = new DiscussionModel();
     $this->SetTagSql($DiscussionModel->SQL, $Tag, $Limit, $Offset, $Op);
     $Result = $DiscussionModel->Get($Offset, $Limit, array('Announce' => 'all'));
     return $Result;
 }
   /**
    * Display discussions started by the user.
    * 
    * @since 2.0.0
    * @access public
    *
    * @param int $Offset Number of discussions to skip.
    */
   public function Mine($Offset = '0') {
      $this->Permission('Garden.SignIn.Allow');
      
      // Validate $Offset
      if (!is_numeric($Offset) || $Offset < 0)
         $Offset = 0;
      
      // Set criteria & get discussions data
      $Limit = Gdn::Config('Vanilla.Discussions.PerPage', 30);
      $Session = Gdn::Session();
      $Wheres = array('d.InsertUserID' => $Session->UserID);
      $DiscussionModel = new DiscussionModel();
      $this->DiscussionData = $DiscussionModel->Get($Offset, $Limit, $Wheres);
      $this->SetData('Discussions', $this->DiscussionData);
      $CountDiscussions = $this->SetData('CountDiscussions', $DiscussionModel->GetCount($Wheres));
      
      // Build a pager
      $PagerFactory = new Gdn_PagerFactory();
		$this->EventArguments['PagerType'] = 'MorePager';
		$this->FireEvent('BeforeBuildMinePager');
      $this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
      $this->Pager->MoreCode = 'More Discussions';
      $this->Pager->LessCode = 'Newer Discussions';
      $this->Pager->ClientID = 'Pager';
      $this->Pager->Configure(
         $Offset,
         $Limit,
         $CountDiscussions,
         'discussions/mine/%1$s'
      );
		$this->FireEvent('AfterBuildMinePager');
      
      // 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');
      $this->AddModule('BookmarkedModule');
      
      // Render default view (discussions/mine.php)
      $this->SetData('Title', T('My Discussions'));
      $this->Render('Index');
   }
예제 #17
0
 /**
  * Load discussions for a specific tag.
  */
 public function DiscussionsController_Tagged_Create($Sender)
 {
     Gdn_Theme::Section('DiscussionList');
     if ($Sender->Request->Get('Tag')) {
         $Tag = $Sender->Request->Get('Tag');
         $Page = GetValue('0', $Sender->RequestArgs, 'p1');
     } else {
         $Tag = urldecode(GetValue('0', $Sender->RequestArgs, ''));
         $Page = GetValue('1', $Sender->RequestArgs, 'p1');
     }
     if ($Sender->Request->Get('Page')) {
         $Page = $Sender->Request->Get('Page');
     }
     $Tag = StringEndsWith($Tag, '.rss', TRUE, TRUE);
     list($Offset, $Limit) = OffsetLimit($Page, C('Vanilla.Discussions.PerPage', 30));
     $Sender->SetData('Tag', $Tag, TRUE);
     $Sender->Title(T('Tagged with ') . htmlspecialchars($Tag));
     $Sender->Head->Title($Sender->Head->Title());
     $UrlTag = rawurlencode($Tag);
     if (urlencode($Tag) == $Tag) {
         $Sender->CanonicalUrl(Url(ConcatSep('/', "/discussions/tagged/{$UrlTag}", PageNumber($Offset, $Limit, TRUE)), TRUE));
         $FeedUrl = Url(ConcatSep('/', "/discussions/tagged/{$UrlTag}/feed.rss", PageNumber($Offset, $Limit, TRUE, FALSE)), '//');
     } else {
         $Sender->CanonicalUrl(Url(ConcatSep('/', 'discussions/tagged', PageNumber($Offset, $Limit, TRUE)) . '?Tag=' . $UrlTag, TRUE));
         $FeedUrl = Url(ConcatSep('/', 'discussions/tagged', PageNumber($Offset, $Limit, TRUE, FALSE), 'feed.rss') . '?Tag=' . $UrlTag, '//');
     }
     if ($Sender->Head) {
         $Sender->AddJsFile('discussions.js');
         $Sender->Head->AddRss($FeedUrl, $Sender->Head->Title());
     }
     if (!is_numeric($Offset) || $Offset < 0) {
         $Offset = 0;
     }
     // Add Modules
     $Sender->AddModule('NewDiscussionModule');
     $Sender->AddModule('DiscussionFilterModule');
     $BookmarkedModule = new BookmarkedModule($Sender);
     $BookmarkedModule->GetData();
     $Sender->AddModule($BookmarkedModule);
     $Sender->SetData('Category', FALSE, TRUE);
     $Sender->SetData('CountDiscussions', FALSE);
     $Sender->AnnounceData = FALSE;
     $Sender->SetData('Announcements', array(), TRUE);
     $DiscussionModel = new DiscussionModel();
     $this->_SetTagSql($DiscussionModel->SQL, $Tag, $Limit, $Offset, $Sender->Request->Get('op', 'or'));
     $Sender->DiscussionData = $DiscussionModel->Get($Offset, $Limit, array('Announce' => 'all'));
     $Sender->SetData('Discussions', $Sender->DiscussionData, TRUE);
     $Sender->SetJson('Loading', $Offset . ' to ' . $Limit);
     // Build a pager.
     $PagerFactory = new Gdn_PagerFactory();
     $Sender->Pager = $PagerFactory->GetPager('Pager', $Sender);
     $Sender->Pager->ClientID = 'Pager';
     if (urlencode($Sender->Tag) == $Sender->Tag) {
         $PageUrlFormat = "discussions/tagged/{$Sender->Tag}/{Page}";
     } else {
         $PageUrlFormat = 'discussions/tagged/{Page}?Tag=' . urlencode($Sender->Tag);
     }
     $Sender->Pager->Configure($Offset, $Limit, FALSE, $PageUrlFormat);
     // Deliver json data if necessary.
     if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL) {
         $Sender->SetJson('LessRow', $Sender->Pager->ToString('less'));
         $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more'));
         $Sender->View = 'discussions';
     }
     // Render the controller
     $Sender->Render('TaggedDiscussions', '', 'plugins/Tagging');
 }
예제 #18
0
 /**
  * Load popular discussions.
  */
 public function DiscussionsController_Popular_Create($Sender)
 {
     //		if (!C('Plugins.Voting.Enabled'))
     //			return;
     $Sender->AddModule('DiscussionFilterModule');
     $Sender->Title(T('Popular'));
     $Sender->Head->Title($Sender->Head->Title());
     $Offset = GetValue('0', $Sender->RequestArgs, '0');
     // Get rid of announcements from this view
     if ($Sender->Head) {
         $Sender->AddJsFile('discussions.js');
         $Sender->Head->AddRss($Sender->SelfUrl . '/feed.rss', $Sender->Head->Title());
     }
     if (!is_numeric($Offset) || $Offset < 0) {
         $Offset = 0;
     }
     // Add Modules
     $Sender->AddModule('NewDiscussionModule');
     $BookmarkedModule = new BookmarkedModule($Sender);
     $BookmarkedModule->GetData();
     $Sender->AddModule($BookmarkedModule);
     $Sender->SetData('Category', FALSE, TRUE);
     $Limit = C('Vanilla.Discussions.PerPage', 30);
     $DiscussionModel = new DiscussionModel();
     $CountDiscussions = $DiscussionModel->GetCount();
     $Sender->SetData('CountDiscussions', $CountDiscussions);
     $Sender->AnnounceData = FALSE;
     $Sender->SetData('Announcements', array(), TRUE);
     $DiscussionModel->SQL->OrderBy('d.CountViews', 'desc');
     $Sender->DiscussionData = $DiscussionModel->Get($Offset, $Limit);
     $Sender->SetData('Discussions', $Sender->DiscussionData, TRUE);
     $Sender->SetJson('Loading', $Offset . ' to ' . $Limit);
     // Build a pager.
     $PagerFactory = new Gdn_PagerFactory();
     $Sender->Pager = $PagerFactory->GetPager('Pager', $Sender);
     $Sender->Pager->ClientID = 'Pager';
     $Sender->Pager->Configure($Offset, $Limit, $CountDiscussions, 'discussions/popular/%1$s');
     // Deliver json data if necessary
     if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL) {
         $Sender->SetJson('LessRow', $Sender->Pager->ToString('less'));
         $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more'));
         $Sender->View = 'discussions';
     }
     // Render the controller
     $Sender->View = 'index';
     $Sender->Render();
 }
예제 #19
0
 /**
  * Record the user's watch data.
  * 
  * @since 2.0.0
  * @access public
  * 
  * @param object $Discussion Discussion being watched.
  * @param int $Limit Max number to get.
  * @param int $Offset Number to skip.
  * @param int $TotalComments Total in entire discussion (hard limit).
  */
 public function SetWatch($Discussion, $Limit, $Offset, $TotalComments)
 {
     $NewComments = FALSE;
     $Session = Gdn::Session();
     if ($Session->UserID > 0) {
         // Max comments we could have seen
         $CountWatch = $Limit * ($Offset + 1);
         if ($CountWatch > $TotalComments) {
             $CountWatch = $TotalComments;
         }
         // This dicussion looks familiar...
         if (is_numeric($Discussion->CountCommentWatch)) {
             if (isset($Discussion->DateLastViewed)) {
                 $NewComments |= Gdn_Format::ToTimestamp($Discussion->DateLastComment) > Gdn_Format::ToTimestamp($Discussion->DateLastViewed);
             }
             if ($TotalComments > $Discussion->CountCommentWatch) {
                 $NewComments |= TRUE;
             }
             // Update the watch data.
             if ($NewComments) {
                 // Only update the watch if there are new comments.
                 $this->SQL->Put('UserDiscussion', array('CountComments' => $CountWatch, 'DateLastViewed' => Gdn_Format::ToDateTime()), array('UserID' => $Session->UserID, 'DiscussionID' => $Discussion->DiscussionID));
             }
         } else {
             // Make sure the discussion isn't archived.
             $ArchiveDate = C('Vanilla.Archive.Date', FALSE);
             if (!$ArchiveDate || Gdn_Format::ToTimestamp($Discussion->DateLastComment) > Gdn_Format::ToTimestamp($ArchiveDate)) {
                 $NewComments = TRUE;
                 // Insert watch data.
                 $this->SQL->Options('Ignore', TRUE);
                 $this->SQL->Insert('UserDiscussion', array('UserID' => $Session->UserID, 'DiscussionID' => $Discussion->DiscussionID, 'CountComments' => $CountWatch, 'DateLastViewed' => Gdn_Format::ToDateTime()));
             }
         }
         /**
          * Fuzzy way of trying to automatically mark a cateogyr read again
          * if the user reads all the comments on the first few pages.
          */
         // If this discussion is in a category that has been marked read,
         // check if reading this thread causes it to be completely read again
         $CategoryID = GetValue('CategoryID', $Discussion);
         if ($CategoryID) {
             $Category = CategoryModel::Categories($CategoryID);
             if ($Category) {
                 $DateMarkedRead = GetValue('DateMarkedRead', $Category);
                 if ($DateMarkedRead) {
                     // Fuzzy way of looking back about 2 pages into the past
                     $LookBackCount = C('Vanilla.Discussions.PerPage', 50) * 2;
                     // Find all discussions with content from after DateMarkedRead
                     $DiscussionModel = new DiscussionModel();
                     $Discussions = $DiscussionModel->Get(0, 101, array('CategoryID' => $CategoryID, 'DateLastComment>' => $DateMarkedRead));
                     unset($DiscussionModel);
                     // Abort if we get back as many as we asked for, meaning a
                     // lot has happened.
                     $NumDiscussions = $Discussions->NumRows();
                     if ($NumDiscussions <= $LookBackCount) {
                         // Loop over these and see if any are still unread
                         $MarkAsRead = TRUE;
                         while ($Discussion = $Discussions->NextRow(DATASET_TYPE_ARRAY)) {
                             if ($Discussion['Read']) {
                                 continue;
                             }
                             $MarkAsRead = FALSE;
                             break;
                         }
                         // Mark this category read if all the new content is read
                         if ($MarkAsRead) {
                             $CategoryModel = new CategoryModel();
                             $CategoryModel->SaveUserTree($CategoryID, array('DateMarkedRead' => Gdn_Format::ToDateTime()));
                             unset($CategoryModel);
                         }
                     }
                 }
             }
         }
     }
 }
 public function GetData($Limit = 10)
 {
     $DiscussionModel = new DiscussionModel();
     $this->Data = $DiscussionModel->Get(0, $Limit);
 }
예제 #21
0
 /**
  * Discussions filter: Unresolved.
  *
  * @return void
  */
 public function discussionsController_unresolved_create($sender, $args)
 {
     $sender->permission('Plugins.Resolved.Manage');
     $page = val(0, $args, 0);
     // Determine offset from $Page
     list($page, $limit) = offsetLimit($page, C('Vanilla.Discussions.PerPage', 30));
     // Validate $Page
     if (!is_numeric($page) || $page < 0) {
         $page = 0;
     }
     $discussionModel = new DiscussionModel();
     $wheres = array('d.Resolved' => '0');
     // Hack in our wheregroup.
     Gdn::sql()->beginWhereGroup()->whereNotIn('d.Type', array('page', 'Report', 'poll', 'SimplePage'))->orWhere('d.Type is null')->endWhereGroup();
     $sender->DiscussionData = $discussionModel->Get($page, $limit, $wheres);
     $sender->setData('Discussions', $sender->DiscussionData);
     $countDiscussions = $discussionModel->GetCount($wheres);
     $sender->setData('CountDiscussions', $countDiscussions);
     $sender->Category = false;
     $sender->setJson('Loading', $page . ' to ' . $limit);
     // Build a pager
     $pagerFactory = new Gdn_PagerFactory();
     $sender->EventArguments['PagerType'] = 'Pager';
     $sender->fireEvent('BeforeBuildBookmarkedPager');
     $sender->Pager = $pagerFactory->getPager($sender->EventArguments['PagerType'], $sender);
     $sender->Pager->ClientID = 'Pager';
     $sender->Pager->configure($page, $limit, $countDiscussions, 'discussions/unresolved/%1$s');
     if (!$sender->data('_PagerUrl')) {
         $sender->setData('_PagerUrl', 'discussions/unresolved/{Page}');
     }
     $sender->setData('_Page', $page);
     $sender->setData('_Limit', $limit);
     $sender->fireEvent('AfterBuildBookmarkedPager');
     // Deliver JSON data if necessary
     if ($sender->deliveryType() != DELIVERY_TYPE_ALL) {
         $sender->setJson('LessRow', $sender->Pager->toString('less'));
         $sender->setJson('MoreRow', $sender->Pager->toString('more'));
         $sender->View = 'discussions';
     }
     // Add modules
     $sender->addModule('DiscussionFilterModule');
     $sender->addModule('NewDiscussionModule');
     $sender->addModule('CategoriesModule');
     // Render default view
     $sender->setData('Title', T('Unresolved'));
     $sender->setData('Breadcrumbs', array(array('Name' => T('Unresolved'), 'Url' => '/discussions/unresolved')));
     $sender->render('index');
 }
   /**
    * Load popular discussions.
    */
   public function DiscussionsController_Popular_Create($Sender) {
		if (!C('Plugins.Voting.Enabled'))
			return;

      $Sender->Title(T('Popular'));
      $Sender->Head->Title($Sender->Head->Title());

      $Offset = GetValue('0', $Sender->RequestArgs, '0');

      // Get rid of announcements from this view
      if ($Sender->Head) {
         $Sender->AddJsFile('discussions.js');
         $Sender->AddJsFile('bookmark.js');
         $Sender->AddJsFile('options.js');
         $Sender->Head->AddRss($Sender->SelfUrl.'/feed.rss', $Sender->Head->Title());
      }
      if (!is_numeric($Offset) || $Offset < 0)
         $Offset = 0;
      
      // Add Modules
      $Sender->AddModule('NewDiscussionModule');
      $BookmarkedModule = new BookmarkedModule($Sender);
      $BookmarkedModule->GetData();
      $Sender->AddModule($BookmarkedModule);

      $Sender->SetData('Category', FALSE, TRUE);
      $Limit = C('Vanilla.Discussions.PerPage', 30);
      $DiscussionModel = new DiscussionModel();
      $CountDiscussions = $DiscussionModel->GetCount();
      $Sender->SetData('CountDiscussions', $CountDiscussions);
      $Sender->AnnounceData = FALSE;
		$Sender->SetData('Announcements', array(), TRUE);
      $DiscussionModel->SQL->OrderBy('d.CountViews', 'desc');
      $Sender->DiscussionData = $DiscussionModel->Get($Offset, $Limit);
      $Sender->SetData('Discussions', $Sender->DiscussionData, TRUE);
      $Sender->SetJson('Loading', $Offset . ' to ' . $Limit);

      // Build a pager.
      $PagerFactory = new Gdn_PagerFactory();
      $Sender->Pager = $PagerFactory->GetPager('Pager', $Sender);
      $Sender->Pager->ClientID = 'Pager';
      $Sender->Pager->Configure(
         $Offset,
         $Limit,
         $CountDiscussions,
         'discussions/popular/%1$s'
      );
      
      // Deliver json data if necessary
      if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL) {
         $Sender->SetJson('LessRow', $Sender->Pager->ToString('less'));
         $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more'));
         $Sender->View = 'discussions';
      }
      
      // 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());
         $Sender->AddDefinition('SetClientHour', $ClientHour);
      }
      
      // Render the controller
      $Sender->View = 'index';
      $Sender->Render();
   }
예제 #23
0
 /**
  * Load discussions for a specific tag.
  * @param DiscussionsController $Sender
  */
 public function DiscussionsController_Tagged_Create($Sender)
 {
     Gdn_Theme::Section('DiscussionList');
     $Args = $Sender->RequestArgs;
     $Get = array_change_key_case($Sender->Request->Get());
     if ($UseCategories = C('Plugins.Tagging.UseCategories')) {
         // The url is in the form /category/tag/p1
         $CategoryCode = GetValue(0, $Args);
         $Tag = GetValue(1, $Args);
         $Page = GetValue(2, $Args);
     } else {
         // The url is in the form /tag/p1
         $CategoryCode = '';
         $Tag = GetValue(0, $Args);
         $Page = GetValue(1, $Args);
     }
     // Look for explcit values.
     $CategoryCode = GetValue('category', $Get, $CategoryCode);
     $Tag = GetValue('tag', $Get, $Tag);
     $Page = GetValue('page', $Get, $Page);
     $Category = CategoryModel::Categories($CategoryCode);
     $Tag = StringEndsWith($Tag, '.rss', TRUE, TRUE);
     list($Offset, $Limit) = OffsetLimit($Page, C('Vanilla.Discussions.PerPage', 30));
     $MultipleTags = strpos($Tag, ',') !== FALSE;
     $Sender->SetData('Tag', $Tag, TRUE);
     $TagModel = TagModel::instance();
     $RecordCount = FALSE;
     if (!$MultipleTags) {
         $Tags = $TagModel->GetWhere(array('Name' => $Tag))->ResultArray();
         if (count($Tags) == 0) {
             throw NotFoundException('Page');
         }
         if (count($Tags) > 1) {
             foreach ($Tags as $TagRow) {
                 if ($TagRow['CategoryID'] == GetValue('CategoryID', $Category)) {
                     break;
                 }
             }
         } else {
             $TagRow = array_pop($Tags);
         }
         $Tags = $TagModel->getRelatedTags($TagRow);
         $RecordCount = $TagRow['CountDiscussions'];
         $Sender->SetData('CountDiscussions', $RecordCount);
         $Sender->SetData('Tags', $Tags);
         $Sender->SetData('Tag', $TagRow);
         $ChildTags = $TagModel->getChildTags($TagRow['TagID']);
         $Sender->SetData('ChildTags', $ChildTags);
     }
     $Sender->Title(htmlspecialchars($TagRow['FullName']));
     $UrlTag = rawurlencode($Tag);
     if (urlencode($Tag) == $Tag) {
         $Sender->CanonicalUrl(Url(ConcatSep('/', "/discussions/tagged/{$UrlTag}", PageNumber($Offset, $Limit, TRUE)), TRUE));
         $FeedUrl = Url(ConcatSep('/', "/discussions/tagged/{$UrlTag}/feed.rss", PageNumber($Offset, $Limit, TRUE, FALSE)), '//');
     } else {
         $Sender->CanonicalUrl(Url(ConcatSep('/', 'discussions/tagged', PageNumber($Offset, $Limit, TRUE)) . '?Tag=' . $UrlTag, TRUE));
         $FeedUrl = Url(ConcatSep('/', 'discussions/tagged', PageNumber($Offset, $Limit, TRUE, FALSE), 'feed.rss') . '?Tag=' . $UrlTag, '//');
     }
     if ($Sender->Head) {
         $Sender->AddJsFile('discussions.js');
         $Sender->Head->AddRss($FeedUrl, $Sender->Head->Title());
     }
     if (!is_numeric($Offset) || $Offset < 0) {
         $Offset = 0;
     }
     // Add Modules
     $Sender->AddModule('NewDiscussionModule');
     $Sender->AddModule('DiscussionFilterModule');
     $Sender->AddModule('BookmarkedModule');
     $Sender->SetData('Category', FALSE, TRUE);
     $Sender->AnnounceData = FALSE;
     $Sender->SetData('Announcements', array(), TRUE);
     $DiscussionModel = new DiscussionModel();
     $TagModel->SetTagSql($DiscussionModel->SQL, $Tag, $Limit, $Offset, $Sender->Request->Get('op', 'or'));
     $Sender->DiscussionData = $DiscussionModel->Get($Offset, $Limit, array('Announce' => 'all'));
     $Sender->SetData('Discussions', $Sender->DiscussionData, TRUE);
     $Sender->SetJson('Loading', $Offset . ' to ' . $Limit);
     // Build a pager.
     $PagerFactory = new Gdn_PagerFactory();
     $Sender->Pager = $PagerFactory->GetPager('Pager', $Sender);
     $Sender->Pager->ClientID = 'Pager';
     $Sender->Pager->Configure($Offset, $Limit, $RecordCount, '');
     $Sender->View = C('Vanilla.Discussions.Layout');
     /*
           // If these don't equal, then there is a category that should be inserted.
           if ($UseCategories && $Category && $TagRow['FullName'] != GetValue('Name', $Category)) {
              $Sender->Data['Breadcrumbs'][] = array('Name' => $Category['Name'], 'Url' => TagUrl($TagRow));
           }
           $Sender->Data['Breadcrumbs'][] = array('Name' => $TagRow['FullName'], 'Url' => '');
     */
     // Render the controller.
     $this->View = C('Vanilla.Discussions.Layout') == 'table' ? 'table' : 'index';
     $Sender->Render($this->View, 'discussions', 'vanilla');
 }
예제 #24
0
 /**
  * Show all categories, and few discussions from each.
  */
 public function All()
 {
     $this->AddCssFile('vanilla.css');
     $this->Menu->HighlightRoute('/discussions');
     if ($this->Head) {
         $this->Head->AddScript('/applications/vanilla/js/discussions.js');
         $this->Head->AddScript('/applications/vanilla/js/options.js');
     }
     $this->DiscussionsPerCategory = Gdn::Config('Vanilla.Discussions.PerCategory', 5);
     $DiscussionModel = new DiscussionModel();
     $this->CategoryData = $this->CategoryModel->GetFull();
     $this->CategoryDiscussionData = array();
     foreach ($this->CategoryData->Result() as $Category) {
         $this->CategoryDiscussionData[$Category->CategoryID] = $DiscussionModel->Get(0, $this->DiscussionsPerCategory, array('d.CategoryID' => $Category->CategoryID));
     }
     // 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);
     $this->View = 'all';
     $this->Render();
 }
예제 #25
0
 /**
  * Show all categories, and few discussions from each.
  */
 public function All()
 {
     $this->AddCssFile('vanilla.css');
     $this->Menu->HighlightRoute('/discussions');
     $this->AddJsFile('discussions.js');
     $this->AddJsFile('bookmark.js');
     $this->AddJsFile('js/library/jquery.menu.js');
     $this->AddJsFile('options.js');
     $this->Title(T('All Categories'));
     $this->DiscussionsPerCategory = Gdn::Config('Vanilla.Discussions.PerCategory', 5);
     $DiscussionModel = new DiscussionModel();
     $this->CategoryData = $this->CategoryModel->GetFull();
     $this->CategoryDiscussionData = array();
     foreach ($this->CategoryData->Result() as $Category) {
         $this->CategoryDiscussionData[$Category->CategoryID] = $DiscussionModel->Get(0, $this->DiscussionsPerCategory, array('d.CategoryID' => $Category->CategoryID));
     }
     // Add Modules
     $this->AddModule('NewDiscussionModule');
     $this->AddModule('CategoriesModule');
     $BookmarkedModule = new BookmarkedModule($this);
     $BookmarkedModule->GetData();
     $this->AddModule($BookmarkedModule);
     $this->View = 'all';
     $this->Render();
 }
   /**
    * Show all categories and few discussions from each.
    * 
    * @since 2.0.0
    * @access public
    */
   public function Discussions() {
      // Setup head
      $this->AddCssFile('vanilla.css');
      $this->Menu->HighlightRoute('/discussions');
      $this->AddJsFile('bookmark.js');
      $this->AddJsFile('discussions.js');
      $this->Title(T('All Categories'));
      
		// 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 and discussions
      $this->DiscussionsPerCategory = C('Vanilla.Discussions.PerCategory', 5);
      $DiscussionModel = new DiscussionModel();
      $this->CategoryModel->Watching = !Gdn::Session()->GetPreference('ShowAllCategories');
      $this->CategoryData = $this->CategoryModel->GetFull();
		$this->SetData('Categories', $this->CategoryData);
      $this->CategoryDiscussionData = array();
      foreach ($this->CategoryData->Result() as $Category) {
			if ($Category->CategoryID > 0)
				$this->CategoryDiscussionData[$Category->CategoryID] = $DiscussionModel->Get(0, $this->DiscussionsPerCategory, array('d.CategoryID' => $Category->CategoryID));
      }
      
      // Add modules
      $this->AddModule('NewDiscussionModule');
      $this->AddModule('CategoriesModule');
      $this->AddModule('BookmarkedModule');
		$this->AddModule($CategoryFollowToggleModule);
      
      // Set view and render
      $this->View = 'discussions';
      $this->Render();
   }