Defaults.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Björn Schießle <bjoern@schiessle.org>
  7. * @author J0WI <J0WI@users.noreply.github.com>
  8. * @author Joas Schilling <coding@schilljs.com>
  9. * @author Julius Härtl <jus@bitgrid.net>
  10. * @author Lukas Reschke <lukas@statuscode.ch>
  11. * @author Morris Jobke <hey@morrisjobke.de>
  12. * @author Roeland Jago Douma <roeland@famdouma.nl>
  13. * @author scolebrook <scolebrook@mac.com>
  14. *
  15. * @license AGPL-3.0
  16. *
  17. * This code is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License, version 3,
  19. * as published by the Free Software Foundation.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License, version 3,
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>
  28. *
  29. */
  30. // use OCP namespace for all classes that are considered public.
  31. // This means that they should be used by apps instead of the internal ownCloud classes
  32. namespace OCP;
  33. /**
  34. * public api to access default strings and urls for your templates
  35. * @since 6.0.0
  36. */
  37. class Defaults {
  38. /**
  39. * \OC_Defaults instance to retrieve the defaults
  40. * @since 6.0.0
  41. */
  42. private $defaults;
  43. /**
  44. * creates a \OC_Defaults instance which is used in all methods to retrieve the
  45. * actual defaults
  46. * @since 6.0.0
  47. */
  48. public function __construct(\OC_Defaults $defaults = null) {
  49. if ($defaults === null) {
  50. $defaults = \OC::$server->getThemingDefaults();
  51. }
  52. $this->defaults = $defaults;
  53. }
  54. /**
  55. * get base URL for the organisation behind your ownCloud instance
  56. * @return string
  57. * @since 6.0.0
  58. */
  59. public function getBaseUrl(): string {
  60. return $this->defaults->getBaseUrl();
  61. }
  62. /**
  63. * link to the desktop sync client
  64. * @return string
  65. * @since 6.0.0
  66. */
  67. public function getSyncClientUrl(): string {
  68. return $this->defaults->getSyncClientUrl();
  69. }
  70. /**
  71. * link to the iOS client
  72. * @return string
  73. * @since 8.0.0
  74. */
  75. public function getiOSClientUrl(): string {
  76. return $this->defaults->getiOSClientUrl();
  77. }
  78. /**
  79. * link to the Android client
  80. * @return string
  81. * @since 8.0.0
  82. */
  83. public function getAndroidClientUrl(): string {
  84. return $this->defaults->getAndroidClientUrl();
  85. }
  86. /**
  87. * link to the Android client on F-Droid
  88. * @return string
  89. * @since 23.0.0
  90. */
  91. public function getFDroidClientUrl() {
  92. return $this->defaults->getFDroidClientUrl();
  93. }
  94. /**
  95. * base URL to the documentation of your ownCloud instance
  96. * @return string
  97. * @since 6.0.0
  98. */
  99. public function getDocBaseUrl(): string {
  100. return $this->defaults->getDocBaseUrl();
  101. }
  102. /**
  103. * name of your Nextcloud instance (e.g. MyPrivateCloud)
  104. * @return string
  105. * @since 6.0.0
  106. */
  107. public function getName(): string {
  108. return $this->defaults->getName();
  109. }
  110. /**
  111. * Name of the software product (defaults to Nextcloud)
  112. *
  113. * @return string
  114. * @since 22.0.0
  115. */
  116. public function getProductName(): string {
  117. return $this->defaults->getProductName();
  118. }
  119. /**
  120. * name of your ownCloud instance containing HTML styles
  121. * @return string
  122. * @since 8.0.0
  123. * @deprecated 22.0.0
  124. */
  125. public function getHTMLName(): string {
  126. return $this->defaults->getHTMLName();
  127. }
  128. /**
  129. * Entity behind your onwCloud instance
  130. * @return string
  131. * @since 6.0.0
  132. */
  133. public function getEntity(): string {
  134. return $this->defaults->getEntity();
  135. }
  136. /**
  137. * ownCloud slogan
  138. * @return string
  139. * @since 6.0.0
  140. */
  141. public function getSlogan(?string $lang = null): string {
  142. return $this->defaults->getSlogan($lang);
  143. }
  144. /**
  145. * footer, short version
  146. * @return string
  147. * @since 6.0.0
  148. */
  149. public function getShortFooter(): string {
  150. return $this->defaults->getShortFooter();
  151. }
  152. /**
  153. * footer, long version
  154. * @return string
  155. * @since 6.0.0
  156. */
  157. public function getLongFooter(): string {
  158. return $this->defaults->getLongFooter();
  159. }
  160. /**
  161. * Returns the AppId for the App Store for the iOS Client
  162. * @return string AppId
  163. * @since 8.0.0
  164. */
  165. public function getiTunesAppId(): string {
  166. return $this->defaults->getiTunesAppId();
  167. }
  168. /**
  169. * Themed logo url
  170. *
  171. * @param bool $useSvg Whether to point to the SVG image or a fallback
  172. * @return string
  173. * @since 12.0.0
  174. */
  175. public function getLogo(bool $useSvg = true): string {
  176. return $this->defaults->getLogo($useSvg);
  177. }
  178. /**
  179. * Returns primary color
  180. * @return string
  181. * @since 12.0.0
  182. */
  183. public function getColorPrimary(): string {
  184. return $this->defaults->getColorPrimary();
  185. }
  186. /**
  187. * Return the default color primary
  188. * @return string
  189. * @since 25.0.4
  190. */
  191. public function getDefaultColorPrimary(): string {
  192. if (method_exists($this->defaults, 'getDefaultColorPrimary')) {
  193. return $this->defaults->getDefaultColorPrimary();
  194. }
  195. return $this->defaults->getColorPrimary();
  196. }
  197. /**
  198. * @param string $key
  199. * @return string URL to doc with key
  200. * @since 12.0.0
  201. */
  202. public function buildDocLinkToKey(string $key): string {
  203. return $this->defaults->buildDocLinkToKey($key);
  204. }
  205. /**
  206. * Returns the title
  207. * @return string title
  208. * @since 12.0.0
  209. */
  210. public function getTitle(): string {
  211. return $this->defaults->getTitle();
  212. }
  213. /**
  214. * Returns primary color
  215. * @return string
  216. * @since 13.0.0
  217. */
  218. public function getTextColorPrimary(): string {
  219. return $this->defaults->getTextColorPrimary();
  220. }
  221. /**
  222. * Returns primary color
  223. * @return string
  224. * @since 25.0.4
  225. */
  226. public function getDefaultTextColorPrimary(): string {
  227. if (method_exists($this->defaults, 'getDefaultTextColorPrimary')) {
  228. return $this->defaults->getDefaultTextColorPrimary();
  229. }
  230. return $this->defaults->getTextColorPrimary();
  231. }
  232. }