Defaults.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  6. * SPDX-License-Identifier: AGPL-3.0-only
  7. */
  8. // use OCP namespace for all classes that are considered public.
  9. // This means that they should be used by apps instead of the internal Nextcloud classes
  10. namespace OCP;
  11. /**
  12. * public api to access default strings and urls for your templates
  13. * @since 6.0.0
  14. */
  15. class Defaults {
  16. /**
  17. * \OC_Defaults instance to retrieve the defaults
  18. * @since 6.0.0
  19. */
  20. private $defaults;
  21. /**
  22. * creates a \OC_Defaults instance which is used in all methods to retrieve the
  23. * actual defaults
  24. * @since 6.0.0
  25. */
  26. public function __construct(?\OC_Defaults $defaults = null) {
  27. if ($defaults === null) {
  28. $defaults = \OC::$server->get('ThemingDefaults');
  29. }
  30. $this->defaults = $defaults;
  31. }
  32. /**
  33. * get base URL for the organisation behind your ownCloud instance
  34. * @return string
  35. * @since 6.0.0
  36. */
  37. public function getBaseUrl(): string {
  38. return $this->defaults->getBaseUrl();
  39. }
  40. /**
  41. * link to the desktop sync client
  42. * @return string
  43. * @since 6.0.0
  44. */
  45. public function getSyncClientUrl(): string {
  46. return $this->defaults->getSyncClientUrl();
  47. }
  48. /**
  49. * link to the iOS client
  50. * @return string
  51. * @since 8.0.0
  52. */
  53. public function getiOSClientUrl(): string {
  54. return $this->defaults->getiOSClientUrl();
  55. }
  56. /**
  57. * link to the Android client
  58. * @return string
  59. * @since 8.0.0
  60. */
  61. public function getAndroidClientUrl(): string {
  62. return $this->defaults->getAndroidClientUrl();
  63. }
  64. /**
  65. * link to the Android client on F-Droid
  66. * @return string
  67. * @since 23.0.0
  68. */
  69. public function getFDroidClientUrl() {
  70. return $this->defaults->getFDroidClientUrl();
  71. }
  72. /**
  73. * base URL to the documentation of your ownCloud instance
  74. * @return string
  75. * @since 6.0.0
  76. */
  77. public function getDocBaseUrl(): string {
  78. return $this->defaults->getDocBaseUrl();
  79. }
  80. /**
  81. * name of your Nextcloud instance (e.g. MyPrivateCloud)
  82. * @return string
  83. * @since 6.0.0
  84. */
  85. public function getName(): string {
  86. return $this->defaults->getName();
  87. }
  88. /**
  89. * Name of the software product (defaults to Nextcloud)
  90. *
  91. * @return string
  92. * @since 22.0.0
  93. */
  94. public function getProductName(): string {
  95. return $this->defaults->getProductName();
  96. }
  97. /**
  98. * name of your ownCloud instance containing HTML styles
  99. * @return string
  100. * @since 8.0.0
  101. * @deprecated 22.0.0
  102. */
  103. public function getHTMLName(): string {
  104. return $this->defaults->getHTMLName();
  105. }
  106. /**
  107. * Entity behind your onwCloud instance
  108. * @return string
  109. * @since 6.0.0
  110. */
  111. public function getEntity(): string {
  112. return $this->defaults->getEntity();
  113. }
  114. /**
  115. * ownCloud slogan
  116. * @return string
  117. * @since 6.0.0
  118. */
  119. public function getSlogan(?string $lang = null): string {
  120. return $this->defaults->getSlogan($lang);
  121. }
  122. /**
  123. * footer, short version
  124. * @return string
  125. * @since 6.0.0
  126. */
  127. public function getShortFooter(): string {
  128. return $this->defaults->getShortFooter();
  129. }
  130. /**
  131. * footer, long version
  132. * @return string
  133. * @since 6.0.0
  134. */
  135. public function getLongFooter(): string {
  136. return $this->defaults->getLongFooter();
  137. }
  138. /**
  139. * Returns the AppId for the App Store for the iOS Client
  140. * @return string AppId
  141. * @since 8.0.0
  142. */
  143. public function getiTunesAppId(): string {
  144. return $this->defaults->getiTunesAppId();
  145. }
  146. /**
  147. * Themed logo url
  148. *
  149. * @param bool $useSvg Whether to point to the SVG image or a fallback
  150. * @return string
  151. * @since 12.0.0
  152. */
  153. public function getLogo(bool $useSvg = true): string {
  154. return $this->defaults->getLogo($useSvg);
  155. }
  156. /**
  157. * Returns primary color
  158. * @return string
  159. * @since 12.0.0
  160. */
  161. public function getColorPrimary(): string {
  162. return $this->defaults->getColorPrimary();
  163. }
  164. /**
  165. * Return the default color primary
  166. * @return string
  167. * @since 25.0.4
  168. */
  169. public function getDefaultColorPrimary(): string {
  170. if (method_exists($this->defaults, 'getDefaultColorPrimary')) {
  171. return $this->defaults->getDefaultColorPrimary();
  172. }
  173. return $this->defaults->getColorPrimary();
  174. }
  175. /**
  176. * @param string $key
  177. * @return string URL to doc with key
  178. * @since 12.0.0
  179. */
  180. public function buildDocLinkToKey(string $key): string {
  181. return $this->defaults->buildDocLinkToKey($key);
  182. }
  183. /**
  184. * Returns the title
  185. * @return string title
  186. * @since 12.0.0
  187. */
  188. public function getTitle(): string {
  189. return $this->defaults->getTitle();
  190. }
  191. /**
  192. * Returns primary color
  193. * @return string
  194. * @since 13.0.0
  195. */
  196. public function getTextColorPrimary(): string {
  197. return $this->defaults->getTextColorPrimary();
  198. }
  199. /**
  200. * Returns primary color
  201. * @return string
  202. * @since 25.0.4
  203. */
  204. public function getDefaultTextColorPrimary(): string {
  205. if (method_exists($this->defaults, 'getDefaultTextColorPrimary')) {
  206. return $this->defaults->getDefaultTextColorPrimary();
  207. }
  208. return $this->defaults->getTextColorPrimary();
  209. }
  210. }