ISearchTemplate.php 3.9 KB

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