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


PHP PaginatedList::setCurrentPage方法代码示例

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


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

示例1: getSubmissions

 /**
  * Return the submissions from the site
  *
  * @return PaginatedList
  */
 public function getSubmissions($page = 1)
 {
     $record = $this->form->getRecord();
     $submissions = $record->getComponents('Submissions', null, "\"Created\" DESC");
     $query = DB::query(sprintf("SELECT COUNT(*) AS \"CountRows\" FROM \"SubmittedForm\" WHERE \"ParentID\" = '%d'", $record->ID));
     $totalCount = 0;
     foreach ($query as $r) {
         $totalCount = $r['CountRows'];
     }
     $list = new PaginatedList($submissions);
     $list->setCurrentPage($page);
     $list->setPageLength(10);
     $list->setTotalItems($totalCount);
     return $list;
 }
开发者ID:nzjoel,项目名称:silverstripe-userforms,代码行数:20,代码来源:SubmittedFormReportField.php

示例2: get_items

 /**
  * Return paginated results in class
  * Only returns items that contain Link()
  * Limited to 1000 results per page
  *
  * @param string
  * @return ArrayList
  */
 public static function get_items($className, $page = 1)
 {
     $items = self::get_filtered_results($className);
     $list = new PaginatedList($items);
     $list->setPageLength(1000);
     $list->setCurrentPage($page);
     $output = new ArrayList();
     /* only push items with a link */
     foreach ($list as $item) {
         $item->ChangeFrequency = self::get_frequency_for_class($className);
         $item->GooglePriority = self::get_priority_for_class($className);
         if ($item->hasMethod('SitemapAbsoluteURL')) {
             $item->SitemapAbsoluteURL = $SitemapAbsoluteURL->SitemapAbsoluteURL();
             $output->push($item);
         } elseif ($item->hasMethod('Link')) {
             $item->SitemapAbsoluteURL = Director::absoluteURL($item->Link());
             $output->push($item);
         }
     }
     /* Make sure we only include one of each link, and no external links (ie: redirector pages */
     $output->removeDuplicates('SitemapAbsoluteURL');
     $external_links = array();
     $base_url = preg_quote(Director::absoluteBaseURL(), '/');
     foreach ($output as $item) {
         if (!preg_match('/^' . $base_url . '/', $item->SitemapAbsoluteURL)) {
             array_push($external_links, $item->SitemapAbsoluteURL);
         }
     }
     if (count($external_links) > 0) {
         $output = $output->exclude('SitemapAbsoluteURL', $external_links);
     }
     return $output;
 }
开发者ID:axllent,项目名称:silverstripe-sitemap,代码行数:41,代码来源:Sitemap.php

示例3: testPrevLink

 public function testPrevLink()
 {
     $list = new PaginatedList(new ArrayList());
     $list->setTotalItems(50);
     $this->assertNull($list->PrevLink());
     $list->setCurrentPage(2);
     $this->assertContains('start=0', $list->PrevLink());
     $list->setCurrentPage(3);
     $this->assertContains('start=10', $list->PrevLink());
     $list->setCurrentPage(5);
     $this->assertContains('start=30', $list->PrevLink());
     // Disable paging
     $list->setPageLength(0);
     $this->assertNull($list->PrevLink());
 }
开发者ID:assertchris,项目名称:silverstripe-framework,代码行数:15,代码来源:PaginatedListTest.php


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