1
0

PagedProvider.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  7. * @author Lukas Reschke <lukas@statuscode.ch>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OCP\Search;
  27. /**
  28. * Provides a template for search functionality throughout ownCloud;
  29. * @since 8.0.0
  30. */
  31. abstract class PagedProvider extends Provider {
  32. /**
  33. * show all results
  34. * @since 8.0.0
  35. */
  36. const SIZE_ALL = 0;
  37. /**
  38. * Constructor
  39. * @param array $options
  40. * @since 8.0.0
  41. */
  42. public function __construct($options) {
  43. parent::__construct($options);
  44. }
  45. /**
  46. * Search for $query
  47. * @param string $query
  48. * @return array An array of OCP\Search\Result's
  49. * @since 8.0.0
  50. */
  51. public function search($query) {
  52. // old apps might assume they get all results, so we use SIZE_ALL
  53. return $this->searchPaged($query, 1, self::SIZE_ALL);
  54. }
  55. /**
  56. * Search for $query
  57. * @param string $query
  58. * @param int $page pages start at page 1
  59. * @param int $size 0 = SIZE_ALL
  60. * @return array An array of OCP\Search\Result's
  61. * @since 8.0.0
  62. */
  63. abstract public function searchPaged($query, $page, $size);
  64. }