• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Gdn_PagerFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: index

 /**
  * List all update checks.
  *
  * @param bool|false $Offset
  * @param string $SortField
  */
 public function index($Offset = false, $SortField = '')
 {
     $this->permission('Garden.Settings.Manage');
     $this->addSideMenu('updates');
     $this->addJsFile('jquery.gardenmorepager.js');
     $this->title('Remote Updates');
     $this->Form->Method = 'get';
     $Limit = 30;
     $SortField = $SortField == 'CountComments' ? 'c.CountComments' : 'c.DateInserted';
     // Input Validation
     $Offset = is_numeric($Offset) ? $Offset : 0;
     // What the actual model in my controller, guy?
     $this->UpdateData = Gdn::sql()->query("\n            select s.Location, s.RemoteIp, c.DateInserted, c.CountUsers, c.CountDiscussions, c.CountComments\n            from GDN_UpdateCheckSource s\n            join (select SourceID, max(UpdateCheckID) as UpdateCheckID from GDN_UpdateCheck group by SourceID) mc\n                on s.SourceID = mc.SourceID\n            join GDN_UpdateCheck c\n                on mc.UpdateCheckID = c.UpdateCheckID\n            order by {$SortField} desc\n            limit {$Offset}, {$Limit}");
     $TotalRecords = Gdn::sql()->select('SourceID', 'count', 'CountSources')->from('UpdateCheckSource')->get()->firstRow()->CountSources;
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->Pager = $PagerFactory->getPager('MorePager', $this);
     $this->Pager->MoreCode = 'More';
     $this->Pager->LessCode = 'Previous';
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Wrapper = '<tr %1$s><td colspan="6">%2$s</td></tr>';
     $this->Pager->configure($Offset, $Limit, $TotalRecords, 'updates/index/%1$s/' . urlencode($SortField));
     // 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->render();
 }
开发者ID:vanilla,项目名称:community,代码行数:35,代码来源:class.updatescontroller.php


示例2: Index

 public function Index($Offset = 0, $Limit = NULL)
 {
     $this->AddJsFile('/js/library/jquery.gardenmorepager.js');
     $this->AddJsFile('search.js');
     $this->Title(T('Search'));
     if (!is_numeric($Limit)) {
         $Limit = Gdn::Config('Garden.Search.PerPage', 20);
     }
     $Search = $this->Form->GetFormValue('Search');
     $ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
     $this->SetData('SearchResults', $ResultSet, TRUE);
     $this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE);
     if ($ResultSet) {
         $NumResults = $ResultSet->NumRows();
     } else {
         $NumResults = 0;
     }
     if ($NumResults == $Offset + $Limit) {
         $NumResults++;
     }
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $Pager = $PagerFactory->GetPager('MorePager', $this);
     $Pager->MoreCode = 'More Results';
     $Pager->LessCode = 'Previous Results';
     $Pager->ClientID = 'Pager';
     $Pager->Configure($Offset, $Limit, $NumResults, 'dashboard/search/%1$s/%2$s/?Search=' . Gdn_Format::Url($Search));
     $this->SetData('Pager', $Pager, TRUE);
     if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
         $this->SetJson('LessRow', $this->Pager->ToString('less'));
         $this->SetJson('MoreRow', $this->Pager->ToString('more'));
         $this->View = 'results';
     }
     $this->Render();
 }
开发者ID:sipp11,项目名称:Garden,代码行数:35,代码来源:class.searchcontroller.php


示例3: BuildPager

 private function BuildPager($Sender, $Total)
 {
     $Sanitized = $this->ValidateInputs();
     //get offset
     $GETString = '?' . Gdn_Url::QueryString() . '&tar=srch';
     //use this to providea link back to search - be sure to append the '&tar=srch' to tell to load the main search page
     $GETString = str_replace('p=search&', 'search?', $GETString);
     //echo $GETString; die;
     $Limit = $this->Settings['Admin']->LimitResultsPage;
     $Offset = ($Sanitized['Offset'] - 1) * $Limit;
     //limit per page
     $Pos = strpos($GETString, '&pg=' . $_GET['pg']);
     if (!$Pos == FALSE) {
         //$Url = substr($GETString, 0, $Pos); //strip the page number if it exists
         $Url = str_replace('&pg=' . GetIncomingValue('pg'), '', $GETString);
         //strip the page number if it exists
         $Url = str_replace('&tar=srch', '', $Url);
         //don't want to load adv search page when clicking page numbers
     } else {
         $Url = str_replace('&tar=srch', '', $GETString);
     }
     //don't want to load adv search page when clicking page numbers
     $PagerFactory = new Gdn_PagerFactory();
     $Sender->Pager = $PagerFactory->GetPager('Pager', $Sender);
     $Sender->Pager->MoreCode = '>';
     $Sender->Pager->LessCode = '<';
     $Sender->Pager->ClientID = 'Pager';
     $Sender->Pager->Configure($Offset, $Limit, $Total, $Url . '&pg=%1$s');
     //echo $Url; die;
     $Sender->SetData('GETString', $GETString);
 }
开发者ID:Nordic-T,项目名称:vanilla-plugins,代码行数:31,代码来源:class.widget.main.php


示例4: index

 /**
  * List download stats.
  *
  * @param bool|false $Offset
  */
 public function index($Offset = false)
 {
     $this->permission('Garden.Settings.Manage');
     $this->addSideMenu('vstats');
     $this->addJsFile('jquery.gardenmorepager.js');
     $this->title('Vanilla Stats');
     $this->Form->Method = 'get';
     $Offset = is_numeric($Offset) ? $Offset : 0;
     $Limit = 19;
     $this->StatsData = array();
     $Offset--;
     $Year = date('Y');
     $Month = date('m');
     $BaseDate = Gdn_Format::toTimestamp($Year . '-' . str_pad($Month, 2, '0', STR_PAD_LEFT) . '-01 00:00:00');
     for ($i = $Offset; $i <= $Limit; ++$i) {
         $String = "-{$i} month";
         $this->StatsData[] = $this->_getStats(date("Y-m-d 00:00:00", strtotime($String, $BaseDate)));
     }
     $TotalRecords = count($this->StatsData);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->Pager = $PagerFactory->getPager('MorePager', $this);
     $this->Pager->MoreCode = 'More';
     $this->Pager->LessCode = 'Previous';
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Wrapper = '<tr %1$s><td colspan="6">%2$s</td></tr>';
     $this->Pager->configure($Offset, $Limit, $TotalRecords, 'vstats/index/%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->render();
 }
开发者ID:vanilla,项目名称:community,代码行数:39,代码来源:class.vstatscontroller.php


示例5: Index

 /**
  * Show all discussions in a particular category.
  */
 public function Index($CategoryIdentifier = '', $Offset = '0')
 {
     if (!is_numeric($CategoryIdentifier)) {
         $Category = $this->CategoryModel->GetFullByUrlCode(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->AddJsFile('discussions.js');
         $this->AddJsFile('bookmark.js');
         $this->AddJsFile('js/library/jquery.menu.js');
         $this->AddJsFile('options.js');
         $this->AddJsFile('/js/library/jquery.gardenmorepager.js');
         $this->Head->AddRss($this->SelfUrl . '/feed.rss', $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);
     $Limit = Gdn::Config('Vanilla.Discussions.PerPage', 30);
     $DiscussionModel = new DiscussionModel();
     $Wheres = array('d.CategoryID' => $this->CategoryID);
     $this->Permission('Vanilla.Discussions.View', TRUE, 'Category', $this->CategoryID);
     $CountDiscussions = $DiscussionModel->GetCount($Wheres);
     $this->SetData('CountDiscussions', $CountDiscussions);
     $this->SetData('DiscussionData', $DiscussionModel->Get($Offset, $Limit, $Wheres), TRUE);
     // 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');
     // 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();
 }
开发者ID:sipp11,项目名称:Garden,代码行数:60,代码来源:class.categoriescontroller.php


示例6: DiscussionsController_Tagged_Create

 /**
  * 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');
 }
开发者ID:nickhx,项目名称:Garden,代码行数:60,代码来源:class.tagging.plugin.php


示例7: Index

	public function Index($Offset = 0, $Limit = NULL) {
		$this->AddJsFile('jquery.gardenmorepager.js');
		$this->AddJsFile('search.js');
		$this->Title(T('Search'));

		if(!is_numeric($Limit))
			$Limit = Gdn::Config('Garden.Search.PerPage', 20);
		
		$Search = $this->Form->GetFormValue('Search');
      $Mode = $this->Form->GetFormValue('Mode');
      if ($Mode)
         $this->SearchModel->ForceSearchMode = $Mode;
      try {
         $ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
      } catch (Gdn_UserException $Ex) {
         $this->Form->AddError($Ex);
         $ResultSet = array();
      } catch (Exception $Ex) {
         $ResultSet = array();
      }
		$this->SetData('SearchResults', $ResultSet, TRUE);
		$this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE);
		if($ResultSet)
			$NumResults = count($ResultSet);
		else
			$NumResults = 0;
		if ($NumResults == $Offset + $Limit)
			$NumResults++;
		
		// Build a pager
		$PagerFactory = new Gdn_PagerFactory();
		$this->Pager = $PagerFactory->GetPager('MorePager', $this);
		$this->Pager->MoreCode = 'More Results';
		$this->Pager->LessCode = 'Previous Results';
		$this->Pager->ClientID = 'Pager';
		$this->Pager->Configure(
			$Offset,
			$Limit,
			$NumResults,
			'dashboard/search/%1$s/%2$s/?Search='.Gdn_Format::Url($Search)
		);
		
		if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
         $this->SetJson('LessRow', $this->Pager->ToString('less'));
         $this->SetJson('MoreRow', $this->Pager->ToString('more'));
         $this->View = 'results';
      }
		
      $this->CanonicalUrl(Url('search', TRUE));

		$this->Render();
	}
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:52,代码来源:class.searchcontroller.php


示例8: Index

 /**
  * Default all drafts view: chronological by time saved.
  * 
  * @since 2.0.0
  * @access public
  * 
  * @param int $Offset Number of drafts to skip.
  */
 public function Index($Offset = '0')
 {
     // Setup head
     $this->Permission('Garden.SignIn.Allow');
     $this->AddCssFile('vanilla.css');
     $this->AddJsFile('jquery.gardenmorepager.js');
     $this->AddJsFile('discussions.js');
     $this->AddJsFile('options.js');
     $this->Title(T('My Drafts'));
     // Validate $Offset
     if (!is_numeric($Offset) || $Offset < 0) {
         $Offset = 0;
     }
     // Set criteria & get drafts data
     $Limit = Gdn::Config('Vanilla.Discussions.PerPage', 30);
     $Session = Gdn::Session();
     $Wheres = array('d.InsertUserID' => $Session->UserID);
     $this->DraftData = $this->DraftModel->Get($Session->UserID, $Offset, $Limit);
     $CountDrafts = $this->DraftModel->GetCount($Session->UserID);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->Pager = $PagerFactory->GetPager('MorePager', $this);
     $this->Pager->MoreCode = 'More drafts';
     $this->Pager->LessCode = 'Newer drafts';
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Configure($Offset, $Limit, $CountDrafts, 'drafts/%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 = 'drafts';
     }
     // Add modules
     $this->AddModule('NewDiscussionModule');
     $this->AddModule('CategoriesModule');
     $BookmarkedModule = new BookmarkedModule($this);
     $BookmarkedModule->GetData();
     $this->AddModule($BookmarkedModule);
     // Render default view (drafts/index.php)
     $this->Render();
 }
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:49,代码来源:class.draftscontroller.php


示例9: Index

 public function Index($Offset = FALSE, $Keywords = '')
 {
     $this->Permission(array('Garden.Users.Add', 'Garden.Users.Edit', 'Garden.Users.Delete'), '', FALSE);
     $this->AddJsFile('jquery.gardenmorepager.js');
     $this->AddJsFile('user.js');
     $this->Title(T('Users'));
     $this->AddSideMenu('dashboard/user');
     $this->Form->Method = 'get';
     // Input Validation
     $Offset = is_numeric($Offset) ? $Offset : 0;
     if (!$Keywords) {
         $Keywords = $this->Form->GetFormValue('Keywords');
         if ($Keywords) {
             $Offset = 0;
         }
     }
     // Put the Keyword back in the form
     if ($Keywords) {
         $this->Form->SetFormValue('Keywords', $Keywords);
     }
     $UserModel = new UserModel();
     //$Like = trim($Keywords) == '' ? FALSE : array('u.Name' => $Keywords, 'u.Email' => $Keywords);
     $Limit = 30;
     $TotalRecords = $UserModel->SearchCount($Keywords);
     $this->UserData = $UserModel->Search($Keywords, 'u.Name', 'asc', $Limit, $Offset);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->Pager = $PagerFactory->GetPager('MorePager', $this);
     $this->Pager->MoreCode = 'More';
     $this->Pager->LessCode = 'Previous';
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Wrapper = '<tr %1$s><td colspan="5">%2$s</td></tr>';
     $this->Pager->Configure($Offset, $Limit, $TotalRecords, 'user/browse/%1$s/' . urlencode($Keywords));
     // 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 = 'users';
     }
     $this->Render();
 }
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:41,代码来源:class.usercontroller.php


示例10: embed


//.........这里部分代码省略.........
            if (!is_numeric($Limit) || $Limit < 0) {
                $Limit = c('Garden.Embed.CommentsPerPage', 30);
            }
            $OffsetProvided = $Offset != '';
            list($Offset, $Limit) = offsetLimit($Offset, $Limit);
            $this->Offset = $Offset;
            if (c('Vanilla.Comments.AutoOffset')) {
                if ($ActualResponses <= $Limit) {
                    $this->Offset = 0;
                }
                if ($this->Offset == $ActualResponses) {
                    $this->Offset -= $Limit;
                }
            } elseif ($this->Offset == '') {
                $this->Offset = 0;
            }
            if ($this->Offset < 0) {
                $this->Offset = 0;
            }
            // Set the canonical url to have the proper page title.
            $this->canonicalUrl(discussionUrl($Discussion, pageNumber($this->Offset, $Limit)));
            // Load the comments.
            $CurrentOrderBy = $this->CommentModel->orderBy();
            if (stringBeginsWith(GetValueR('0.0', $CurrentOrderBy), 'c.DateInserted')) {
                $this->CommentModel->orderBy('c.DateInserted ' . $SortComments);
                // allow custom sort
            }
            $this->setData('Comments', $this->CommentModel->get($Discussion->DiscussionID, $Limit, $this->Offset), true);
            if (count($this->CommentModel->where()) > 0) {
                $ActualResponses = false;
            }
            $this->setData('_Count', $ActualResponses);
            // Build a pager
            $PagerFactory = new Gdn_PagerFactory();
            $this->EventArguments['PagerType'] = 'MorePager';
            $this->fireEvent('BeforeBuildPager');
            $this->Pager = $PagerFactory->getPager($this->EventArguments['PagerType'], $this);
            $this->Pager->ClientID = 'Pager';
            $this->Pager->MoreCode = 'More Comments';
            $this->Pager->configure($this->Offset, $Limit, $ActualResponses, 'discussion/embed/' . $Discussion->DiscussionID . '/' . Gdn_Format::url($Discussion->Name) . '/%1$s');
            $this->Pager->CurrentRecords = $this->Comments->numRows();
            $this->fireEvent('AfterBuildPager');
        }
        // Define the form for the comment input
        $this->Form = Gdn::Factory('Form', 'Comment');
        $this->Form->Action = url('/post/comment/');
        $this->Form->addHidden('CommentID', '');
        $this->Form->addHidden('Embedded', 'true');
        // Tell the post controller that this is an embedded page (in case there are custom views it needs to pick up from a theme).
        $this->Form->addHidden('DisplayNewCommentOnly', 'true');
        // Only load/display the new comment after posting (don't load all new comments since the page last loaded).
        // Grab the page title
        if ($this->Request->get('title')) {
            $this->Form->setValue('Name', $this->Request->get('title'));
        }
        // Set existing DiscussionID for comment form
        if ($Discussion) {
            $this->Form->addHidden('DiscussionID', $Discussion->DiscussionID);
        }
        foreach ($ForeignSource as $Key => $Val) {
            // Drop the foreign source information into the form so it can be used if creating a discussion
            $this->Form->addHidden($Key, $Val);
            // Also drop it into the definitions so it can be picked up for stashing comments
            $this->addDefinition($Key, $Val);
        }
        // Retrieve & apply the draft if there is one:
开发者ID:caidongyun,项目名称:vanilla,代码行数:67,代码来源:class.discussioncontroller.php


示例11: DiscussionsController_Tagged_Create

 /**
  * 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');
 }
开发者ID:3marproof,项目名称:vanilla,代码行数:98,代码来源:class.tagging.plugin.php


示例12: Index


//.........这里部分代码省略.........
         return;
     } else {
         Gdn_Theme::Section('DiscussionList');
         // Figure out which discussions layout to choose (Defined on "Homepage" settings page).
         $Layout = C('Vanilla.Discussions.Layout');
         switch ($Layout) {
             case 'table':
                 if ($this->SyndicationMethod == SYNDICATION_NONE) {
                     $this->View = 'table';
                 }
                 break;
             default:
                 // $this->View = 'index';
                 break;
         }
         $Category = CategoryModel::Categories($CategoryIdentifier);
         if (empty($Category)) {
             if ($CategoryIdentifier) {
                 throw NotFoundException();
             }
         }
         $Category = (object) $Category;
         Gdn_Theme::Section($Category->CssClass);
         // Load the breadcrumbs.
         $this->SetData('Breadcrumbs', CategoryModel::GetAncestors(GetValue('CategoryID', $Category)));
         $this->SetData('Category', $Category, TRUE);
         // Load the subtree.
         if (C('Vanilla.ExpandCategories')) {
             $Categories = CategoryModel::GetSubtree($CategoryIdentifier);
         } else {
             $Categories = array($Category);
         }
         $this->SetData('Categories', $Categories);
         // Setup head
         $this->AddCssFile('vanilla.css');
         $this->Menu->HighlightRoute('/discussions');
         if ($this->Head) {
             $this->AddJsFile('discussions.js');
             $this->AddJsFile('bookmark.js');
             $this->AddJsFile('options.js');
             $this->Head->AddRss($this->SelfUrl . '/feed.rss', $this->Head->Title());
         }
         $this->Title(GetValue('Name', $Category, ''));
         $this->Description(GetValue('Description', $Category), TRUE);
         // Set CategoryID
         $CategoryID = GetValue('CategoryID', $Category);
         $this->SetData('CategoryID', $CategoryID, TRUE);
         // Add modules
         $this->AddModule('NewDiscussionModule');
         $this->AddModule('DiscussionFilterModule');
         $this->AddModule('CategoriesModule');
         $this->AddModule('BookmarkedModule');
         // Get a DiscussionModel
         $DiscussionModel = new DiscussionModel();
         $CategoryIDs = ConsolidateArrayValuesByKey($this->Data('Categories'), 'CategoryID');
         $Wheres = array('d.CategoryID' => $CategoryIDs);
         $this->SetData('_ShowCategoryLink', count($CategoryIDs) > 1);
         // Check permission
         $this->Permission('Vanilla.Discussions.View', TRUE, 'Category', GetValue('PermissionCategoryID', $Category));
         // Set discussion meta data.
         $this->EventArguments['PerPage'] = C('Vanilla.Discussions.PerPage', 30);
         $this->FireEvent('BeforeGetDiscussions');
         list($Offset, $Limit) = OffsetLimit($Page, $this->EventArguments['PerPage']);
         if (!is_numeric($Offset) || $Offset < 0) {
             $Offset = 0;
         }
         $CountDiscussions = $DiscussionModel->GetCount($Wheres);
         $this->SetData('CountDiscussions', $CountDiscussions);
         $this->SetData('_Limit', $Limit);
         // We don't wan't child categories in announcements.
         $Wheres['d.CategoryID'] = $CategoryID;
         $AnnounceData = $Offset == 0 ? $DiscussionModel->GetAnnouncements($Wheres) : new Gdn_DataSet();
         $this->SetData('AnnounceData', $AnnounceData, TRUE);
         $Wheres['d.CategoryID'] = $CategoryIDs;
         $this->DiscussionData = $this->SetData('Discussions', $DiscussionModel->GetWhere($Wheres, $Offset, $Limit));
         // Build a pager
         $PagerFactory = new Gdn_PagerFactory();
         $this->Pager = $PagerFactory->GetPager('Pager', $this);
         $this->Pager->ClientID = 'Pager';
         $this->Pager->Configure($Offset, $Limit, $CountDiscussions, array('CategoryUrl'));
         $this->Pager->Record = $Category;
         PagerModule::Current($this->Pager);
         $this->SetData('_Page', $Page);
         // Set the canonical Url.
         $this->CanonicalUrl(CategoryUrl($Category, PageNumber($Offset, $Limit)));
         // Change the controller name so that it knows to grab the discussion views
         $this->ControllerName = 'DiscussionsController';
         // Pick up the discussions class
         $this->CssClass = 'Discussions';
         // Deliver JSON data if necessary
         if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
             $this->SetJson('LessRow', $this->Pager->ToString('less'));
             $this->SetJson('MoreRow', $this->Pager->ToString('more'));
             $this->View = 'discussions';
         }
         // Render default view.
         $this->FireEvent('BeforeCategoriesRender');
         $this->Render();
     }
 }
开发者ID:remobjects,项目名称:Garden,代码行数:101,代码来源:class.categoriescontroller.php


示例13: discussionsController_unresolved_create

 /**
  * 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');
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:53,代码来源:class.resolved.plugin.php


示例14: Index

 /**
  * Shows all uncleared messages within a conversation for the viewing user
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $ConversationID Unique ID of conversation to view.
  * @param int $Offset Number to skip.
  * @param int $Limit Number to show.
  */
 public function Index($ConversationID = FALSE, $Offset = -1, $Limit = '')
 {
     $this->Offset = $Offset;
     $Session = Gdn::Session();
     Gdn_Theme::Section('Conversation');
     // Figure out Conversation ID
     if (!is_numeric($ConversationID) || $ConversationID < 0) {
         $ConversationID = 0;
     }
     // Form setup for adding comments
     $this->Form->SetModel($this->ConversationMessageModel);
     $this->Form->AddHidden('ConversationID', $ConversationID);
     // Get conversation data
     $this->RecipientData = $this->ConversationModel->GetRecipients($ConversationID);
     $this->SetData('Recipients', $this->RecipientData);
     // Check permissions on the recipients.
     $InConversation = FALSE;
     foreach ($this->RecipientData->Result() as $Recipient) {
         if ($Recipient->UserID == Gdn::Session()->UserID) {
             $InConversation = TRUE;
             break;
         }
     }
     if (!$InConversation) {
         // Conversation moderation must be enabled and they must have permission
         if (!C('Conversations.Moderation.Allow', FALSE)) {
             throw PermissionException();
         }
         $this->Permission('Conversations.Moderation.Manage');
     }
     $this->Conversation = $this->ConversationModel->GetID($ConversationID);
     $this->SetData('Conversation', $this->Conversation);
     // Bad conversation? Redirect
     if ($this->Conversation === FALSE) {
         throw NotFoundException('Conversation');
     }
     // Get limit
     if ($Limit == '' || !is_numeric($Limit) || $Limit < 0) {
         $Limit = Gdn::Config('Conversations.Messages.PerPage', 50);
     }
     // Calculate counts
     if (!is_numeric($this->Offset) || $this->Offset < 0) {
         // Round down to the appropriate offset based on the user's read messages & messages per page
         $CountReadMessages = $this->Conversation->CountMessages - $this->Conversation->CountNewMessages;
         if ($CountReadMessages < 0) {
             $CountReadMessages = 0;
         }
         if ($CountReadMessages > $this->Conversation->CountMessages) {
             $CountReadMessages = $this->Conversation->CountMessages;
         }
         // (((67 comments / 10 perpage) = 6.7) rounded down = 6) * 10 perpage = offset 60;
         $this->Offset = floor($CountReadMessages / $Limit) * $Limit;
         // Send the hash link in.
         if ($CountReadMessages > 1) {
             $this->AddDefinition('LocationHash', '#Item_' . $CountReadMessages);
         }
     }
     // Fetch message data
     $this->MessageData = $this->ConversationMessageModel->Get($ConversationID, $Session->UserID, $this->Offset, $Limit);
     // Figure out who's participating.
     $this->Participants = '';
     $Count = 0;
     $Users = array();
     $InConversation = FALSE;
     foreach ($this->RecipientData->Result() as $User) {
         $Count++;
         if ($User->UserID == $Session->UserID) {
             $InConversation = TRUE;
             continue;
         }
         if ($User->Deleted) {
             $Users[] = Wrap(UserAnchor($User), 'del', array('title' => sprintf(T('%s has left this conversation.'), htmlspecialchars($User->Name))));
             $this->SetData('_HasDeletedUsers', TRUE);
         } else {
             $Users[] = UserAnchor($User);
         }
     }
     if ($InConversation) {
         if (count($Users) == 0) {
             $this->Participants = T('Just you!');
         } else {
             $this->Participants = sprintf(T('%s and you'), implode(', ', $Users));
         }
     } else {
         $this->Participants = implode(', ', $Users);
     }
     $this->Title(strip_tags($this->Participants));
     // $CountMessages = $this->ConversationMessageModel->GetCount($ConversationID, $Session->UserID);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
//.........这里部分代码省略.........
开发者ID:rnovino,项目名称:Garden,代码行数:101,代码来源:class.messagescontroller.php


示例15: Notifications

 /**
  * Show notifications for current user.
  *
  * @since 2.0.0
  * @access public
  * @param int $Page Number to skip (paging).
  */
 public function Notifications($Page = FALSE)
 {
     $this->Permission('Garden.SignIn.Allow');
     $this->EditMode(FALSE);
     list($Offset, $Limit) = OffsetLimit($Page, 30);
     $this->GetUserInfo();
     $this->_SetBreadcrumbs(T('Notifications'), '/profile/notifications');
     $this->SetTabView('Notifications');
     $Session = Gdn::Session();
     $this->ActivityModel = new ActivityModel();
     // Drop notification count back to zero.
     $this->ActivityModel->MarkRead($Session->UserID);
     // Get notifications data.
     $Activities = $this->ActivityModel->GetNotifications($Session->UserID, $Offset, $Limit)->ResultArray();
     $this->ActivityModel->JoinComments($Activities);
     $this->SetData('Activities', $Activities);
     unset($Activities);
     //$TotalRecords = $this->ActivityModel->GetCountNotifications($Session->UserID);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->Pager = $PagerFactory->GetPager('MorePager', $this);
     $this->Pager->MoreCode = 'More';
     $this->Pager->LessCode = 'Newer Notifications';
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Configure($Offset, $Limit, FALSE, 'profile/notifications/%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'));
         if ($Offset > 0) {
             $this->View = 'activities';
             $this->ControllerName = 'Activity';
         }
     }
     $this->Render();
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:43,代码来源:class.profilecontroller.php


示例16: ProfileController_Discussions_Create

 /**
  * Creates virtual 'Discussions' method in ProfileController.
  * 
  * @since 2.0.0
  * @package Vanilla
  *
  * @param ProfileController $Sender ProfileController.
  */
 public function ProfileController_Discussions_Create($Sender, $UserReference = '', $Username = '', $Page = '', $UserID = '')
 {
     $Sender->EditMode(FALSE);
     // Tell the ProfileController what tab to load
     $Sender->GetUserInfo($UserReference, $Username, $UserID);
     $Sender->_SetBreadcrumbs(T('Discussions'), '/profile/discussions');
     $Sender->SetTabView('Discussions', 'Profile', 'Discussions', 'Vanilla');
     $Sender->CountCommentsPerPage = C('Vanilla.Comments.PerPage', 30);
     list($Offset, $Limit) = OffsetLimit($Page, Gdn::Config('Vanilla.Discussions.PerPage', 30));
     $DiscussionModel = new DiscussionModel();
     $Discussions = $DiscussionModel->GetByUser($Sender->User->UserID, $Limit, $Offset, FALSE, Gdn::Session()->UserID);
     $CountDiscussions = $Offset + $DiscussionModel->LastDiscussionCount + 1;
     $Sender->DiscussionData = $Sender->SetData('Discussions', $Discussions);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $Sender->Pager = $PagerFactory->GetPager('MorePager', $Sender);
     $Sender->Pager->MoreCode = 'More Discussions';
     $Sender->P 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Gdn_PasswordHash类代码示例发布时间:2022-05-23
下一篇:
PHP Gdn_Module类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap