defaults.php 7.3 KB

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