ISearchTemplate.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\FullTextSearch\Model;
  8. use OCP\FullTextSearch\IFullTextSearchProvider;
  9. /**
  10. * Class ISearchTemplate
  11. *
  12. * This is a data transfer object that should be created by Content Provider
  13. * when the getSearchTemplate() method is called.
  14. *
  15. * The object will contain templates to be displayed, and the list of the different
  16. * options to be available to the user when he start a new search.
  17. *
  18. * The display of the Options is generated by the FullTextSearch app and Options
  19. * can be displayed in 2 places:
  20. *
  21. * - the navigation page of the app that generate the indexed content.
  22. * (files, bookmarks, deck, mails, ...)
  23. * - the navigation page of the FullTextSearch app.
  24. *
  25. * Both pages will have different Options, and only the first one can integrate
  26. * a specific template.
  27. *
  28. * @see IFullTextSearchProvider::getSearchTemplate
  29. *
  30. * @since 16.0.0
  31. *
  32. */
  33. interface ISearchTemplate {
  34. /**
  35. * Set the class of the icon to be displayed in the left panel of the
  36. * FullTextSearch navigation page, in front of the related Content Provider.
  37. *
  38. * @since 16.0.0
  39. *
  40. * @param string $class
  41. *
  42. * @return ISearchTemplate
  43. */
  44. public function setIcon(string $class): ISearchTemplate;
  45. /**
  46. * Get the class of the icon.
  47. *
  48. * @since 16.0.0
  49. *
  50. * @return string
  51. */
  52. public function getIcon(): string;
  53. /**
  54. * Set the path of a CSS file that will be loaded when needed.
  55. *
  56. * @since 16.0.0
  57. *
  58. * @param string $css
  59. *
  60. * @return ISearchTemplate
  61. */
  62. public function setCss(string $css): ISearchTemplate;
  63. /**
  64. * Get the path of the CSS file.
  65. *
  66. * @since 16.0.0
  67. *
  68. * @return string
  69. */
  70. public function getCss(): string;
  71. /**
  72. * Set the path of the file of a template that the HTML will be displayed
  73. * below the Options.
  74. * This should only be used if your Content Provider needs to set options in
  75. * a way not generated by FullTextSearch
  76. *
  77. * @since 16.0.0
  78. *
  79. * @param string $template
  80. *
  81. * @return ISearchTemplate
  82. */
  83. public function setTemplate(string $template): ISearchTemplate;
  84. /**
  85. * Get the path of the template file.
  86. *
  87. * @since 16.0.0
  88. *
  89. * @return string
  90. */
  91. public function getTemplate(): string;
  92. /**
  93. * Add an option in the Panel that is displayed when the user start a search
  94. * within the app that generate the content.
  95. *
  96. * @see ISearchOption
  97. *
  98. * @since 16.0.0
  99. *
  100. * @param ISearchOption $option
  101. *
  102. * @return ISearchTemplate
  103. */
  104. public function addPanelOption(ISearchOption $option): ISearchTemplate;
  105. /**
  106. * Get all options to be displayed in the Panel.
  107. *
  108. * @since 16.0.0
  109. *
  110. * @return ISearchOption[]
  111. */
  112. public function getPanelOptions(): array;
  113. /**
  114. * Add an option in the left panel of the FullTextSearch navigation page.
  115. *
  116. * @see ISearchOption
  117. *
  118. * @since 16.0.0
  119. *
  120. * @param ISearchOption $option
  121. *
  122. * @return ISearchTemplate
  123. */
  124. public function addNavigationOption(ISearchOption $option): ISearchTemplate;
  125. /**
  126. * Get all options to be displayed in the FullTextSearch navigation page.
  127. *
  128. * @since 16.0.0
  129. *
  130. * @return array
  131. */
  132. public function getNavigationOptions(): array;
  133. }