pagedprovider.php 1.7 KB

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