defaults.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Björn Schießle <bjoern@schiessle.org>
  7. * @author Jan-Christoph Borchardt <hey@jancborchardt.net>
  8. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Pascal de Bruijn <pmjdebruijn@pcode.nl>
  12. * @author Robin Appelman <robin@icewind.nl>
  13. * @author Robin McCorkell <robin@mccorkell.me.uk>
  14. * @author scolebrook <scolebrook@mac.com>
  15. * @author Thomas Müller <thomas.mueller@tmit.eu>
  16. * @author Volkan Gezer <volkangezer@gmail.com>
  17. *
  18. * @license AGPL-3.0
  19. *
  20. * This code is free software: you can redistribute it and/or modify
  21. * it under the terms of the GNU Affero General Public License, version 3,
  22. * as published by the Free Software Foundation.
  23. *
  24. * This program is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU Affero General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU Affero General Public License, version 3,
  30. * along with this program. If not, see <http://www.gnu.org/licenses/>
  31. *
  32. */
  33. class OC_Defaults {
  34. private $theme;
  35. private $l;
  36. private $defaultEntity;
  37. private $defaultName;
  38. private $defaultTitle;
  39. private $defaultBaseUrl;
  40. private $defaultSyncClientUrl;
  41. private $defaultiOSClientUrl;
  42. private $defaultiTunesAppId;
  43. private $defaultAndroidClientUrl;
  44. private $defaultDocBaseUrl;
  45. private $defaultDocVersion;
  46. private $defaultSlogan;
  47. private $defaultLogoClaim;
  48. private $defaultMailHeaderColor;
  49. function __construct() {
  50. $this->l = \OC::$server->getL10N('lib');
  51. $version = \OCP\Util::getVersion();
  52. $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */
  53. $this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */
  54. $this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */
  55. $this->defaultBaseUrl = 'https://nextcloud.com';
  56. $this->defaultSyncClientUrl = 'https://nextcloud.com/install';
  57. $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8';
  58. $this->defaultiTunesAppId = '1125420102';
  59. $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.nextcloud.client';
  60. $this->defaultDocBaseUrl = 'https://docs.nextcloud.org';
  61. $this->defaultDocVersion = $version[0] . '.' . $version[1]; // used to generate doc links
  62. $this->defaultSlogan = $this->l->t('a safe home for all your data');
  63. $this->defaultLogoClaim = '';
  64. $this->defaultMailHeaderColor = '#0082c9'; /* header color of mail notifications */
  65. $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
  66. if (file_exists($themePath)) {
  67. // prevent defaults.php from printing output
  68. ob_start();
  69. require_once $themePath;
  70. ob_end_clean();
  71. if (class_exists('OC_Theme')) {
  72. $this->theme = new OC_Theme();
  73. }
  74. }
  75. }
  76. /**
  77. * @param string $method
  78. */
  79. private function themeExist($method) {
  80. if (isset($this->theme) && method_exists($this->theme, $method)) {
  81. return true;
  82. }
  83. return false;
  84. }
  85. /**
  86. * Returns the base URL
  87. * @return string URL
  88. */
  89. public function getBaseUrl() {
  90. if ($this->themeExist('getBaseUrl')) {
  91. return $this->theme->getBaseUrl();
  92. } else {
  93. return $this->defaultBaseUrl;
  94. }
  95. }
  96. /**
  97. * Returns the URL where the sync clients are listed
  98. * @return string URL
  99. */
  100. public function getSyncClientUrl() {
  101. if ($this->themeExist('getSyncClientUrl')) {
  102. return $this->theme->getSyncClientUrl();
  103. } else {
  104. return $this->defaultSyncClientUrl;
  105. }
  106. }
  107. /**
  108. * Returns the URL to the App Store for the iOS Client
  109. * @return string URL
  110. */
  111. public function getiOSClientUrl() {
  112. if ($this->themeExist('getiOSClientUrl')) {
  113. return $this->theme->getiOSClientUrl();
  114. } else {
  115. return $this->defaultiOSClientUrl;
  116. }
  117. }
  118. /**
  119. * Returns the AppId for the App Store for the iOS Client
  120. * @return string AppId
  121. */
  122. public function getiTunesAppId() {
  123. if ($this->themeExist('getiTunesAppId')) {
  124. return $this->theme->getiTunesAppId();
  125. } else {
  126. return $this->defaultiTunesAppId;
  127. }
  128. }
  129. /**
  130. * Returns the URL to Google Play for the Android Client
  131. * @return string URL
  132. */
  133. public function getAndroidClientUrl() {
  134. if ($this->themeExist('getAndroidClientUrl')) {
  135. return $this->theme->getAndroidClientUrl();
  136. } else {
  137. return $this->defaultAndroidClientUrl;
  138. }
  139. }
  140. /**
  141. * Returns the documentation URL
  142. * @return string URL
  143. */
  144. public function getDocBaseUrl() {
  145. if ($this->themeExist('getDocBaseUrl')) {
  146. return $this->theme->getDocBaseUrl();
  147. } else {
  148. return $this->defaultDocBaseUrl;
  149. }
  150. }
  151. /**
  152. * Returns the title
  153. * @return string title
  154. */
  155. public function getTitle() {
  156. if ($this->themeExist('getTitle')) {
  157. return $this->theme->getTitle();
  158. } else {
  159. return $this->defaultTitle;
  160. }
  161. }
  162. /**
  163. * Returns the short name of the software
  164. * @return string title
  165. */
  166. public function getName() {
  167. if ($this->themeExist('getName')) {
  168. return $this->theme->getName();
  169. } else {
  170. return $this->defaultName;
  171. }
  172. }
  173. /**
  174. * Returns the short name of the software containing HTML strings
  175. * @return string title
  176. */
  177. public function getHTMLName() {
  178. if ($this->themeExist('getHTMLName')) {
  179. return $this->theme->getHTMLName();
  180. } else {
  181. return $this->defaultName;
  182. }
  183. }
  184. /**
  185. * Returns entity (e.g. company name) - used for footer, copyright
  186. * @return string entity name
  187. */
  188. public function getEntity() {
  189. if ($this->themeExist('getEntity')) {
  190. return $this->theme->getEntity();
  191. } else {
  192. return $this->defaultEntity;
  193. }
  194. }
  195. /**
  196. * Returns slogan
  197. * @return string slogan
  198. */
  199. public function getSlogan() {
  200. if ($this->themeExist('getSlogan')) {
  201. return $this->theme->getSlogan();
  202. } else {
  203. return $this->defaultSlogan;
  204. }
  205. }
  206. /**
  207. * Returns logo claim
  208. * @return string logo claim
  209. */
  210. public function getLogoClaim() {
  211. if ($this->themeExist('getLogoClaim')) {
  212. return $this->theme->getLogoClaim();
  213. } else {
  214. return $this->defaultLogoClaim;
  215. }
  216. }
  217. /**
  218. * Returns short version of the footer
  219. * @return string short footer
  220. */
  221. public function getShortFooter() {
  222. if ($this->themeExist('getShortFooter')) {
  223. $footer = $this->theme->getShortFooter();
  224. } else {
  225. $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
  226. ' rel="noreferrer">' .$this->getEntity() . '</a>'.
  227. ' – ' . $this->getSlogan();
  228. }
  229. return $footer;
  230. }
  231. /**
  232. * Returns long version of the footer
  233. * @return string long footer
  234. */
  235. public function getLongFooter() {
  236. if ($this->themeExist('getLongFooter')) {
  237. $footer = $this->theme->getLongFooter();
  238. } else {
  239. $footer = $this->getShortFooter();
  240. }
  241. return $footer;
  242. }
  243. /**
  244. * @param string $key
  245. */
  246. public function buildDocLinkToKey($key) {
  247. if ($this->themeExist('buildDocLinkToKey')) {
  248. return $this->theme->buildDocLinkToKey($key);
  249. }
  250. return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
  251. }
  252. /**
  253. * Returns mail header color
  254. * @return string
  255. */
  256. public function getMailHeaderColor() {
  257. if ($this->themeExist('getMailHeaderColor')) {
  258. return $this->theme->getMailHeaderColor();
  259. } else {
  260. return $this->defaultMailHeaderColor;
  261. }
  262. }
  263. }