PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/private/defaults.php

https://gitlab.com/Red54/core
PHP | 283 lines | 165 code | 25 blank | 93 comment | 35 complexity | bf23838a955290e9bb7d43db8a0c39a2 MD5 | raw file
  1. <?php
  2. /**
  3. * @author Björn Schießle <schiessle@owncloud.com>
  4. * @author Jan-Christoph Borchardt <hey@jancborchardt.net>
  5. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  6. * @author Lukas Reschke <lukas@owncloud.com>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Pascal de Bruijn <pmjdebruijn@pcode.nl>
  9. * @author Robin Appelman <icewind@owncloud.com>
  10. * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
  11. * @author scolebrook <scolebrook@mac.com>
  12. * @author Thomas Müller <thomas.mueller@tmit.eu>
  13. * @author Volkan Gezer <volkangezer@gmail.com>
  14. *
  15. * @copyright Copyright (c) 2015, ownCloud, Inc.
  16. * @license AGPL-3.0
  17. *
  18. * This code is free software: you can redistribute it and/or modify
  19. * it under the terms of the GNU Affero General Public License, version 3,
  20. * as published by the Free Software Foundation.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU Affero General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU Affero General Public License, version 3,
  28. * along with this program. If not, see <http://www.gnu.org/licenses/>
  29. *
  30. */
  31. class OC_Defaults {
  32. private $theme;
  33. private $l;
  34. private $defaultEntity;
  35. private $defaultName;
  36. private $defaultTitle;
  37. private $defaultBaseUrl;
  38. private $defaultSyncClientUrl;
  39. private $defaultiOSClientUrl;
  40. private $defaultiTunesAppId;
  41. private $defaultAndroidClientUrl;
  42. private $defaultDocBaseUrl;
  43. private $defaultDocVersion;
  44. private $defaultSlogan;
  45. private $defaultLogoClaim;
  46. private $defaultMailHeaderColor;
  47. function __construct() {
  48. $this->l = \OC::$server->getL10N('lib');
  49. $version = OC_Util::getVersion();
  50. $this->defaultEntity = 'ownCloud'; /* e.g. company name, used for footers and copyright notices */
  51. $this->defaultName = 'ownCloud'; /* short name, used when referring to the software */
  52. $this->defaultTitle = 'ownCloud'; /* can be a longer name, for titles */
  53. $this->defaultBaseUrl = 'https://owncloud.org';
  54. $this->defaultSyncClientUrl = 'https://owncloud.org/sync-clients/';
  55. $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8';
  56. $this->defaultiTunesAppId = '543672169';
  57. $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.owncloud.android';
  58. $this->defaultDocBaseUrl = 'https://doc.owncloud.org';
  59. $this->defaultDocVersion = $version[0] . '.' . $version[1]; // used to generate doc links
  60. $this->defaultSlogan = $this->l->t('web services under your control');
  61. $this->defaultLogoClaim = '';
  62. $this->defaultMailHeaderColor = '#1d2d44'; /* header color of mail notifications */
  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. public function buildDocLinkToKey($key) {
  242. if ($this->themeExist('buildDocLinkToKey')) {
  243. return $this->theme->buildDocLinkToKey($key);
  244. }
  245. return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
  246. }
  247. /**
  248. * Returns mail header color
  249. * @return string
  250. */
  251. public function getMailHeaderColor() {
  252. if ($this->themeExist('getMailHeaderColor')) {
  253. return $this->theme->getMailHeaderColor();
  254. } else {
  255. return $this->defaultMailHeaderColor;
  256. }
  257. }
  258. }