defaults.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <?php
  2. /**
  3. * Default strings and values which differ between the enterprise and the
  4. * community edition. Use the get methods to always get the right strings.
  5. */
  6. class OC_Defaults {
  7. private $theme;
  8. private $l;
  9. private $defaultEntity;
  10. private $defaultName;
  11. private $defaultTitle;
  12. private $defaultBaseUrl;
  13. private $defaultSyncClientUrl;
  14. private $defaultiOSClientUrl;
  15. private $defaultiTunesAppId;
  16. private $defaultAndroidClientUrl;
  17. private $defaultDocBaseUrl;
  18. private $defaultDocVersion;
  19. private $defaultSlogan;
  20. private $defaultLogoClaim;
  21. private $defaultMailHeaderColor;
  22. function __construct() {
  23. $this->l = \OC::$server->getL10N('lib');
  24. $version = OC_Util::getVersion();
  25. $this->defaultEntity = 'ownCloud'; /* e.g. company name, used for footers and copyright notices */
  26. $this->defaultName = 'ownCloud'; /* short name, used when referring to the software */
  27. $this->defaultTitle = 'ownCloud'; /* can be a longer name, for titles */
  28. $this->defaultBaseUrl = 'https://owncloud.org';
  29. $this->defaultSyncClientUrl = 'https://owncloud.org/sync-clients/';
  30. $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8';
  31. $this->defaultiTunesAppId = '543672169';
  32. $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.owncloud.android';
  33. $this->defaultDocBaseUrl = 'https://doc.owncloud.org';
  34. $this->defaultDocVersion = $version[0] . '.0'; // used to generate doc links
  35. $this->defaultSlogan = $this->l->t('web services under your control');
  36. $this->defaultLogoClaim = '';
  37. $this->defaultMailHeaderColor = '#1d2d44'; /* header color of mail notifications */
  38. $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
  39. if (file_exists($themePath)) {
  40. // prevent defaults.php from printing output
  41. ob_start();
  42. require_once $themePath;
  43. ob_end_clean();
  44. if (class_exists('OC_Theme')) {
  45. $this->theme = new OC_Theme();
  46. }
  47. }
  48. }
  49. /**
  50. * @param string $method
  51. */
  52. private function themeExist($method) {
  53. if (isset($this->theme) && method_exists($this->theme, $method)) {
  54. return true;
  55. }
  56. return false;
  57. }
  58. /**
  59. * Returns the base URL
  60. * @return string URL
  61. */
  62. public function getBaseUrl() {
  63. if ($this->themeExist('getBaseUrl')) {
  64. return $this->theme->getBaseUrl();
  65. } else {
  66. return $this->defaultBaseUrl;
  67. }
  68. }
  69. /**
  70. * Returns the URL where the sync clients are listed
  71. * @return string URL
  72. */
  73. public function getSyncClientUrl() {
  74. if ($this->themeExist('getSyncClientUrl')) {
  75. return $this->theme->getSyncClientUrl();
  76. } else {
  77. return $this->defaultSyncClientUrl;
  78. }
  79. }
  80. /**
  81. * Returns the URL to the App Store for the iOS Client
  82. * @return string URL
  83. */
  84. public function getiOSClientUrl() {
  85. if ($this->themeExist('getiOSClientUrl')) {
  86. return $this->theme->getiOSClientUrl();
  87. } else {
  88. return $this->defaultiOSClientUrl;
  89. }
  90. }
  91. /**
  92. * Returns the AppId for the App Store for the iOS Client
  93. * @return string AppId
  94. */
  95. public function getiTunesAppId() {
  96. if ($this->themeExist('getiTunesAppId')) {
  97. return $this->theme->getiTunesAppId();
  98. } else {
  99. return $this->defaultiTunesAppId;
  100. }
  101. }
  102. /**
  103. * Returns the URL to Google Play for the Android Client
  104. * @return string URL
  105. */
  106. public function getAndroidClientUrl() {
  107. if ($this->themeExist('getAndroidClientUrl')) {
  108. return $this->theme->getAndroidClientUrl();
  109. } else {
  110. return $this->defaultAndroidClientUrl;
  111. }
  112. }
  113. /**
  114. * Returns the documentation URL
  115. * @return string URL
  116. */
  117. public function getDocBaseUrl() {
  118. if ($this->themeExist('getDocBaseUrl')) {
  119. return $this->theme->getDocBaseUrl();
  120. } else {
  121. return $this->defaultDocBaseUrl;
  122. }
  123. }
  124. /**
  125. * Returns the title
  126. * @return string title
  127. */
  128. public function getTitle() {
  129. if ($this->themeExist('getTitle')) {
  130. return $this->theme->getTitle();
  131. } else {
  132. return $this->defaultTitle;
  133. }
  134. }
  135. /**
  136. * Returns the short name of the software
  137. * @return string title
  138. */
  139. public function getName() {
  140. if ($this->themeExist('getName')) {
  141. return $this->theme->getName();
  142. } else {
  143. return $this->defaultName;
  144. }
  145. }
  146. /**
  147. * Returns the short name of the software containing HTML strings
  148. * @return string title
  149. */
  150. public function getHTMLName() {
  151. if ($this->themeExist('getHTMLName')) {
  152. return $this->theme->getHTMLName();
  153. } else {
  154. return $this->defaultName;
  155. }
  156. }
  157. /**
  158. * Returns entity (e.g. company name) - used for footer, copyright
  159. * @return string entity name
  160. */
  161. public function getEntity() {
  162. if ($this->themeExist('getEntity')) {
  163. return $this->theme->getEntity();
  164. } else {
  165. return $this->defaultEntity;
  166. }
  167. }
  168. /**
  169. * Returns slogan
  170. * @return string slogan
  171. */
  172. public function getSlogan() {
  173. if ($this->themeExist('getSlogan')) {
  174. return $this->theme->getSlogan();
  175. } else {
  176. return $this->defaultSlogan;
  177. }
  178. }
  179. /**
  180. * Returns logo claim
  181. * @return string logo claim
  182. */
  183. public function getLogoClaim() {
  184. if ($this->themeExist('getLogoClaim')) {
  185. return $this->theme->getLogoClaim();
  186. } else {
  187. return $this->defaultLogoClaim;
  188. }
  189. }
  190. /**
  191. * Returns short version of the footer
  192. * @return string short footer
  193. */
  194. public function getShortFooter() {
  195. if ($this->themeExist('getShortFooter')) {
  196. $footer = $this->theme->getShortFooter();
  197. } else {
  198. $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
  199. ' rel="noreferrer">' .$this->getEntity() . '</a>'.
  200. ' – ' . $this->getSlogan();
  201. }
  202. return $footer;
  203. }
  204. /**
  205. * Returns long version of the footer
  206. * @return string long footer
  207. */
  208. public function getLongFooter() {
  209. if ($this->themeExist('getLongFooter')) {
  210. $footer = $this->theme->getLongFooter();
  211. } else {
  212. $footer = $this->getShortFooter();
  213. }
  214. return $footer;
  215. }
  216. public function buildDocLinkToKey($key) {
  217. if ($this->themeExist('buildDocLinkToKey')) {
  218. return $this->theme->buildDocLinkToKey($key);
  219. }
  220. return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
  221. }
  222. /**
  223. * Returns mail header color
  224. * @return string
  225. */
  226. public function getMailHeaderColor() {
  227. if ($this->themeExist('getMailHeaderColor')) {
  228. return $this->theme->getMailHeaderColor();
  229. } else {
  230. return $this->defaultMailHeaderColor;
  231. }
  232. }
  233. }