ISearchTemplate.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * FullTextSearch - Full text search framework for Nextcloud
  5. *
  6. * This file is licensed under the Affero General Public License version 3 or
  7. * later. See the COPYING file.
  8. *
  9. * @author Maxence Lange <maxence@artificial-owl.com>
  10. * @copyright 2018
  11. * @license GNU AGPL version 3 or any later version
  12. *
  13. * This program is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License as
  15. * published by the Free Software Foundation, either version 3 of the
  16. * License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. *
  26. */
  27. namespace OCP\FullTextSearch\Model;
  28. use OCP\FullTextSearch\IFullTextSearchProvider;
  29. /**
  30. * Class ISearchTemplate
  31. *
  32. * This is a data transfer object that should be created by Content Provider
  33. * when the getSearchTemplate() method is called.
  34. *
  35. * The object will contain templates to be displayed, and the list of the different
  36. * options to be available to the user when he start a new search.
  37. *
  38. * The display of the Options is generated by the FullTextSearch app and Options
  39. * can be displayed in 2 places:
  40. *
  41. * - the navigation page of the app that generate the indexed content.
  42. * (files, bookmarks, deck, mails, ...)
  43. * - the navigation page of the FullTextSearch app.
  44. *
  45. * Both pages will have different Options, and only the first one can integrate
  46. * a specific template.
  47. *
  48. * @see IFullTextSearchProvider::getSearchTemplate
  49. *
  50. * @since 16.0.0
  51. *
  52. * @package OCP\FullTextSearch\Model
  53. */
  54. interface ISearchTemplate {
  55. /**
  56. * Set the class of the icon to be displayed in the left panel of the
  57. * FullTextSearch navigation page, in front of the related Content Provider.
  58. *
  59. * @since 16.0.0
  60. *
  61. * @param string $class
  62. *
  63. * @return ISearchTemplate
  64. */
  65. public function setIcon(string $class): ISearchTemplate;
  66. /**
  67. * Get the class of the icon.
  68. *
  69. * @since 16.0.0
  70. *
  71. * @return string
  72. */
  73. public function getIcon(): string;
  74. /**
  75. * Set the path of a CSS file that will be loaded when needed.
  76. *
  77. * @since 16.0.0
  78. *
  79. * @param string $css
  80. *
  81. * @return ISearchTemplate
  82. */
  83. public function setCss(string $css): ISearchTemplate;
  84. /**
  85. * Get the path of the CSS file.
  86. *
  87. * @since 16.0.0
  88. *
  89. * @return string
  90. */
  91. public function getCss(): string;
  92. /**
  93. * Set the path of the file of a template that the HTML will be displayed
  94. * below the Options.
  95. * This should only be used if your Content Provider needs to set options in
  96. * a way not generated by FullTextSearch
  97. *
  98. * @since 16.0.0
  99. *
  100. * @param string $template
  101. *
  102. * @return ISearchTemplate
  103. */
  104. public function setTemplate(string $template): ISearchTemplate;
  105. /**
  106. * Get the path of the template file.
  107. *
  108. * @since 16.0.0
  109. *
  110. * @return string
  111. */
  112. public function getTemplate(): string;
  113. /**
  114. * Add an option in the Panel that is displayed when the user start a search
  115. * within the app that generate the content.
  116. *
  117. * @see ISearchOption
  118. *
  119. * @since 16.0.0
  120. *
  121. * @param ISearchOption $option
  122. *
  123. * @return ISearchTemplate
  124. */
  125. public function addPanelOption(ISearchOption $option): ISearchTemplate;
  126. /**
  127. * Get all options to be displayed in the Panel.
  128. *
  129. * @since 16.0.0
  130. *
  131. * @return ISearchOption[]
  132. */
  133. public function getPanelOptions(): array;
  134. /**
  135. * Add an option in the left panel of the FullTextSearch navigation page.
  136. *
  137. * @see ISearchOption
  138. *
  139. * @since 16.0.0
  140. *
  141. * @param ISearchOption $option
  142. *
  143. * @return ISearchTemplate
  144. */
  145. public function addNavigationOption(ISearchOption $option): ISearchTemplate;
  146. /**
  147. * Get all options to be displayed in the FullTextSearch navigation page.
  148. *
  149. * @since 16.0.0
  150. *
  151. * @return array
  152. */
  153. public function getNavigationOptions(): array;
  154. }