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


PHP PaginatedList::setPageLEngth方法代码示例

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


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

示例1: searchEngine

 /**
  * The core search engine configuration.
  * @todo There is a fulltext search for SQLite making use of virtual tables, the fts3 extension and the
  * MATCH operator
  * there are a few issues with fts:
  * - shared cached lock doesn't allow to create virtual tables on versions prior to 3.6.17
  * - there must not be more than one MATCH operator per statement
  * - the fts3 extension needs to be available
  * for now we use the MySQL implementation with the MATCH()AGAINST() uglily replaced with LIKE
  * 
  * @param string $keywords Keywords as a space separated string
  * @return object DataObjectSet of result pages
  */
 public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $sortBy = "Relevance DESC", $extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false)
 {
     $keywords = $this->escapeString(str_replace(array('*', '+', '-', '"', '\''), '', $keywords));
     $htmlEntityKeywords = htmlentities(utf8_decode($keywords));
     $extraFilters = array('SiteTree' => '', 'File' => '');
     if ($extraFilter) {
         $extraFilters['SiteTree'] = " AND {$extraFilter}";
         if ($alternativeFileFilter) {
             $extraFilters['File'] = " AND {$alternativeFileFilter}";
         } else {
             $extraFilters['File'] = $extraFilters['SiteTree'];
         }
     }
     // Always ensure that only pages with ShowInSearch = 1 can be searched
     $extraFilters['SiteTree'] .= ' AND ShowInSearch <> 0';
     // File.ShowInSearch was added later, keep the database driver backwards compatible
     // by checking for its existence first
     $fields = $this->getSchemaManager()->fieldList('File');
     if (array_key_exists('ShowInSearch', $fields)) {
         $extraFilters['File'] .= " AND ShowInSearch <> 0";
     }
     $limit = $start . ", " . (int) $pageLength;
     $notMatch = $invertedMatch ? "NOT " : "";
     if ($keywords) {
         $match['SiteTree'] = "\r\n\t\t\t\t(Title LIKE '%{$keywords}%' OR MenuTitle LIKE '%{$keywords}%' OR Content LIKE '%{$keywords}%' OR MetaDescription LIKE '%{$keywords}%' OR\r\n\t\t\t\tTitle LIKE '%{$htmlEntityKeywords}%' OR MenuTitle LIKE '%{$htmlEntityKeywords}%' OR Content LIKE '%{$htmlEntityKeywords}%' OR MetaDescription LIKE '%{$htmlEntityKeywords}%')\r\n\t\t\t";
         $match['File'] = "(Filename LIKE '%{$keywords}%' OR Title LIKE '%{$keywords}%' OR Content LIKE '%{$keywords}%') AND ClassName = 'File'";
         // We make the relevance search by converting a boolean mode search into a normal one
         $relevanceKeywords = $keywords;
         $htmlEntityRelevanceKeywords = $htmlEntityKeywords;
         $relevance['SiteTree'] = "(Title LIKE '%{$relevanceKeywords}%' OR MenuTitle LIKE '%{$relevanceKeywords}%' OR Content LIKE '%{$relevanceKeywords}%' OR MetaDescription LIKE '%{$relevanceKeywords}%') + (Title LIKE '%{$htmlEntityRelevanceKeywords}%' OR MenuTitle LIKE '%{$htmlEntityRelevanceKeywords}%' OR Content LIKE '%{$htmlEntityRelevanceKeywords}%' OR MetaDescription LIKE '%{$htmlEntityRelevanceKeywords}%')";
         $relevance['File'] = "(Filename LIKE '%{$relevanceKeywords}%' OR Title LIKE '%{$relevanceKeywords}%' OR Content LIKE '%{$relevanceKeywords}%')";
     } else {
         $relevance['SiteTree'] = $relevance['File'] = 1;
         $match['SiteTree'] = $match['File'] = "1 = 1";
     }
     // Generate initial queries and base table names
     $baseClasses = array('SiteTree' => '', 'File' => '');
     $queries = array();
     foreach ($classesToSearch as $class) {
         $queries[$class] = DataList::create($class)->where($notMatch . $match[$class] . $extraFilters[$class], "")->dataQuery()->query();
         $fromArr = $queries[$class]->getFrom();
         $baseClasses[$class] = reset($fromArr);
     }
     // Make column selection lists
     $select = array('SiteTree' => array("\"ClassName\"", "\"ID\"", "\"ParentID\"", "\"Title\"", "\"URLSegment\"", "\"Content\"", "\"LastEdited\"", "\"Created\"", "NULL AS \"Filename\"", "NULL AS \"Name\"", "\"CanViewType\"", "{$relevance['SiteTree']} AS Relevance"), 'File' => array("\"ClassName\"", "\"ID\"", "NULL AS \"ParentID\"", "\"Title\"", "NULL AS \"URLSegment\"", "\"Content\"", "\"LastEdited\"", "\"Created\"", "\"Filename\"", "\"Name\"", "NULL AS \"CanViewType\"", "{$relevance['File']} AS Relevance"));
     // Process queries
     foreach ($classesToSearch as $class) {
         // There's no need to do all that joining
         $queries[$class]->setFrom($baseClasses[$class]);
         $queries[$class]->setSelect(array());
         foreach ($select[$class] as $clause) {
             if (preg_match('/^(.*) +AS +"?([^"]*)"?/i', $clause, $matches)) {
                 $queries[$class]->selectField($matches[1], $matches[2]);
             } else {
                 $queries[$class]->selectField(str_replace('"', '', $clause));
             }
         }
         $queries[$class]->setOrderBy(array());
     }
     // Combine queries
     $querySQLs = array();
     $queryParameters = array();
     $totalCount = 0;
     foreach ($queries as $query) {
         $querySQLs[] = $query->sql($parameters);
         $queryParameters = array_merge($queryParameters, $parameters);
         $totalCount += $query->unlimitedRowCount();
     }
     $fullQuery = implode(" UNION ", $querySQLs) . " ORDER BY {$sortBy} LIMIT {$limit}";
     // Get records
     $records = $this->preparedQuery($fullQuery, $queryParameters);
     foreach ($records as $record) {
         $objects[] = new $record['ClassName']($record);
     }
     if (isset($objects)) {
         $doSet = new ArrayList($objects);
     } else {
         $doSet = new ArrayList();
     }
     $list = new PaginatedList($doSet);
     $list->setPageStart($start);
     $list->setPageLEngth($pageLength);
     $list->setTotalItems($totalCount);
     return $list;
 }
开发者ID:skapl,项目名称:design,代码行数:98,代码来源:SQLite3Database.php


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