123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 |
- <?php
- /**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Björn Schießle <bjoern@schiessle.org>
- * @author Felix A. Epp <work@felixepp.de>
- * @author Jan-Christoph Borchardt <hey@jancborchardt.net>
- * @author Julius Haertl <jus@bitgrid.net>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Pascal de Bruijn <pmjdebruijn@pcode.nl>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author scolebrook <scolebrook@mac.com>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Volkan Gezer <volkangezer@gmail.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
- class OC_Defaults {
- private $theme;
- private $defaultEntity;
- private $defaultName;
- private $defaultTitle;
- private $defaultBaseUrl;
- private $defaultSyncClientUrl;
- private $defaultiOSClientUrl;
- private $defaultiTunesAppId;
- private $defaultAndroidClientUrl;
- private $defaultDocBaseUrl;
- private $defaultDocVersion;
- private $defaultSlogan;
- private $defaultColorPrimary;
- private $defaultTextColorPrimary;
- public function __construct() {
- $l10n = \OC::$server->getL10N('lib');
- $config = \OC::$server->getConfig();
- $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */
- $this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */
- $this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */
- $this->defaultBaseUrl = 'https://nextcloud.com';
- $this->defaultSyncClientUrl = $config->getSystemValue('customclient_desktop', 'https://nextcloud.com/install/#install-clients');
- $this->defaultiOSClientUrl = $config->getSystemValue('customclient_ios', 'https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8');
- $this->defaultiTunesAppId = $config->getSystemValue('customclient_ios_appid', '1125420102');
- $this->defaultAndroidClientUrl = $config->getSystemValue('customclient_android', 'https://play.google.com/store/apps/details?id=com.nextcloud.client');
- $this->defaultDocBaseUrl = 'https://docs.nextcloud.com';
- $this->defaultDocVersion = \OC_Util::getVersion()[0]; // used to generate doc links
- $this->defaultSlogan = $l10n->t('a safe home for all your data');
- $this->defaultColorPrimary = '#0082c9';
- $this->defaultTextColorPrimary = '#ffffff';
- $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
- if (file_exists($themePath)) {
- // prevent defaults.php from printing output
- ob_start();
- require_once $themePath;
- ob_end_clean();
- if (class_exists('OC_Theme')) {
- $this->theme = new OC_Theme();
- }
- }
- }
- /**
- * @param string $method
- */
- private function themeExist($method) {
- if (isset($this->theme) && method_exists($this->theme, $method)) {
- return true;
- }
- return false;
- }
- /**
- * Returns the base URL
- * @return string URL
- */
- public function getBaseUrl() {
- if ($this->themeExist('getBaseUrl')) {
- return $this->theme->getBaseUrl();
- } else {
- return $this->defaultBaseUrl;
- }
- }
- /**
- * Returns the URL where the sync clients are listed
- * @return string URL
- */
- public function getSyncClientUrl() {
- if ($this->themeExist('getSyncClientUrl')) {
- return $this->theme->getSyncClientUrl();
- } else {
- return $this->defaultSyncClientUrl;
- }
- }
- /**
- * Returns the URL to the App Store for the iOS Client
- * @return string URL
- */
- public function getiOSClientUrl() {
- if ($this->themeExist('getiOSClientUrl')) {
- return $this->theme->getiOSClientUrl();
- } else {
- return $this->defaultiOSClientUrl;
- }
- }
- /**
- * Returns the AppId for the App Store for the iOS Client
- * @return string AppId
- */
- public function getiTunesAppId() {
- if ($this->themeExist('getiTunesAppId')) {
- return $this->theme->getiTunesAppId();
- } else {
- return $this->defaultiTunesAppId;
- }
- }
- /**
- * Returns the URL to Google Play for the Android Client
- * @return string URL
- */
- public function getAndroidClientUrl() {
- if ($this->themeExist('getAndroidClientUrl')) {
- return $this->theme->getAndroidClientUrl();
- } else {
- return $this->defaultAndroidClientUrl;
- }
- }
- /**
- * Returns the documentation URL
- * @return string URL
- */
- public function getDocBaseUrl() {
- if ($this->themeExist('getDocBaseUrl')) {
- return $this->theme->getDocBaseUrl();
- } else {
- return $this->defaultDocBaseUrl;
- }
- }
- /**
- * Returns the title
- * @return string title
- */
- public function getTitle() {
- if ($this->themeExist('getTitle')) {
- return $this->theme->getTitle();
- } else {
- return $this->defaultTitle;
- }
- }
- /**
- * Returns the short name of the software
- * @return string title
- */
- public function getName() {
- if ($this->themeExist('getName')) {
- return $this->theme->getName();
- } else {
- return $this->defaultName;
- }
- }
- /**
- * Returns the short name of the software containing HTML strings
- * @return string title
- */
- public function getHTMLName() {
- if ($this->themeExist('getHTMLName')) {
- return $this->theme->getHTMLName();
- } else {
- return $this->defaultName;
- }
- }
- /**
- * Returns entity (e.g. company name) - used for footer, copyright
- * @return string entity name
- */
- public function getEntity() {
- if ($this->themeExist('getEntity')) {
- return $this->theme->getEntity();
- } else {
- return $this->defaultEntity;
- }
- }
- /**
- * Returns slogan
- * @return string slogan
- */
- public function getSlogan() {
- if ($this->themeExist('getSlogan')) {
- return $this->theme->getSlogan();
- } else {
- return $this->defaultSlogan;
- }
- }
- /**
- * Returns logo claim
- * @return string logo claim
- * @deprecated 13.0.0
- */
- public function getLogoClaim() {
- return '';
- }
- /**
- * Returns short version of the footer
- * @return string short footer
- */
- public function getShortFooter() {
- if ($this->themeExist('getShortFooter')) {
- $footer = $this->theme->getShortFooter();
- } else {
- $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
- ' rel="noreferrer noopener">' .$this->getEntity() . '</a>'.
- ' – ' . $this->getSlogan();
- }
- return $footer;
- }
- /**
- * Returns long version of the footer
- * @return string long footer
- */
- public function getLongFooter() {
- if ($this->themeExist('getLongFooter')) {
- $footer = $this->theme->getLongFooter();
- } else {
- $footer = $this->getShortFooter();
- }
- return $footer;
- }
- /**
- * @param string $key
- * @return string URL to doc with key
- */
- public function buildDocLinkToKey($key) {
- if ($this->themeExist('buildDocLinkToKey')) {
- return $this->theme->buildDocLinkToKey($key);
- }
- return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
- }
- /**
- * Returns primary color
- * @return string
- */
- public function getColorPrimary() {
- if ($this->themeExist('getColorPrimary')) {
- return $this->theme->getColorPrimary();
- }
- if ($this->themeExist('getMailHeaderColor')) {
- return $this->theme->getMailHeaderColor();
- }
- return $this->defaultColorPrimary;
- }
- /**
- * @return array scss variables to overwrite
- */
- public function getScssVariables() {
- if($this->themeExist('getScssVariables')) {
- return $this->theme->getScssVariables();
- }
- return [];
- }
- public function shouldReplaceIcons() {
- return false;
- }
- /**
- * Themed logo url
- *
- * @param bool $useSvg Whether to point to the SVG image or a fallback
- * @return string
- */
- public function getLogo($useSvg = true) {
- if ($this->themeExist('getLogo')) {
- return $this->theme->getLogo($useSvg);
- }
- if($useSvg) {
- $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.svg');
- } else {
- $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.png');
- }
- return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion()));
- }
- public function getTextColorPrimary() {
- if ($this->themeExist('getTextColorPrimary')) {
- return $this->theme->getTextColorPrimary();
- }
- return $this->defaultTextColorPrimary;
- }
- }
|