2013-06-12 13:15:08 +00:00
|
|
|
|
<?php
|
2013-11-25 13:12:07 +00:00
|
|
|
|
/**
|
2016-07-21 15:07:57 +00:00
|
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
|
*
|
2016-05-26 17:56:05 +00:00
|
|
|
|
* @author Björn Schießle <bjoern@schiessle.org>
|
2017-11-06 14:56:42 +00:00
|
|
|
|
* @author Felix A. Epp <work@felixepp.de>
|
2015-03-26 10:44:34 +00:00
|
|
|
|
* @author Jan-Christoph Borchardt <hey@jancborchardt.net>
|
2017-11-06 14:56:42 +00:00
|
|
|
|
* @author Julius Haertl <jus@bitgrid.net>
|
|
|
|
|
* @author Julius Härtl <jus@bitgrid.net>
|
2015-03-26 10:44:34 +00:00
|
|
|
|
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
|
2016-05-26 17:56:05 +00:00
|
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2015-03-26 10:44:34 +00:00
|
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
|
|
|
|
* @author Pascal de Bruijn <pmjdebruijn@pcode.nl>
|
2016-07-21 16:13:36 +00:00
|
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
2016-01-12 14:02:16 +00:00
|
|
|
|
* @author Robin McCorkell <robin@mccorkell.me.uk>
|
2017-11-06 14:56:42 +00:00
|
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2015-03-26 10:44:34 +00:00
|
|
|
|
* @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/>
|
|
|
|
|
*
|
2013-11-25 13:12:07 +00:00
|
|
|
|
*/
|
2013-06-12 13:15:08 +00:00
|
|
|
|
class OC_Defaults {
|
|
|
|
|
|
2013-07-03 12:21:51 +00:00
|
|
|
|
private $theme;
|
2013-08-30 11:53:49 +00:00
|
|
|
|
private $l;
|
2013-07-03 12:21:51 +00:00
|
|
|
|
|
|
|
|
|
private $defaultEntity;
|
|
|
|
|
private $defaultName;
|
2013-07-11 14:38:07 +00:00
|
|
|
|
private $defaultTitle;
|
2013-07-03 12:21:51 +00:00
|
|
|
|
private $defaultBaseUrl;
|
|
|
|
|
private $defaultSyncClientUrl;
|
2014-07-30 09:38:17 +00:00
|
|
|
|
private $defaultiOSClientUrl;
|
2014-08-27 12:07:39 +00:00
|
|
|
|
private $defaultiTunesAppId;
|
2014-07-30 09:38:17 +00:00
|
|
|
|
private $defaultAndroidClientUrl;
|
2013-07-03 12:21:51 +00:00
|
|
|
|
private $defaultDocBaseUrl;
|
2014-05-28 23:21:54 +00:00
|
|
|
|
private $defaultDocVersion;
|
2013-07-03 12:21:51 +00:00
|
|
|
|
private $defaultSlogan;
|
2017-03-28 16:10:02 +00:00
|
|
|
|
private $defaultColorPrimary;
|
2017-12-08 11:16:05 +00:00
|
|
|
|
private $defaultTextColorPrimary;
|
2013-07-03 10:38:20 +00:00
|
|
|
|
|
2017-05-08 12:51:55 +00:00
|
|
|
|
public function __construct() {
|
2014-08-31 08:05:59 +00:00
|
|
|
|
$this->l = \OC::$server->getL10N('lib');
|
2018-03-26 17:12:26 +00:00
|
|
|
|
$config = \OC::$server->getConfig();
|
2013-07-03 10:38:20 +00:00
|
|
|
|
|
2016-06-08 14:46:26 +00:00
|
|
|
|
$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';
|
2018-03-26 17:12:26 +00:00
|
|
|
|
$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');
|
2016-11-15 18:17:42 +00:00
|
|
|
|
$this->defaultDocBaseUrl = 'https://docs.nextcloud.com';
|
2018-02-01 12:52:11 +00:00
|
|
|
|
$this->defaultDocVersion = '14'; // used to generate doc links
|
2016-06-08 14:46:26 +00:00
|
|
|
|
$this->defaultSlogan = $this->l->t('a safe home for all your data');
|
2017-03-28 16:10:02 +00:00
|
|
|
|
$this->defaultColorPrimary = '#0082c9';
|
2017-12-08 11:16:05 +00:00
|
|
|
|
$this->defaultTextColorPrimary = '#ffffff';
|
2014-07-08 13:51:05 +00:00
|
|
|
|
|
2015-02-12 10:20:38 +00:00
|
|
|
|
$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();
|
|
|
|
|
}
|
2013-07-03 10:38:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-12 13:15:08 +00:00
|
|
|
|
|
2014-02-06 15:30:58 +00:00
|
|
|
|
/**
|
|
|
|
|
* @param string $method
|
|
|
|
|
*/
|
2013-07-03 12:21:51 +00:00
|
|
|
|
private function themeExist($method) {
|
2014-07-15 13:39:44 +00:00
|
|
|
|
if (isset($this->theme) && method_exists($this->theme, $method)) {
|
2013-06-27 14:24:03 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-06-12 13:15:08 +00:00
|
|
|
|
|
2013-11-25 13:12:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns the base URL
|
|
|
|
|
* @return string URL
|
|
|
|
|
*/
|
2013-07-03 12:21:51 +00:00
|
|
|
|
public function getBaseUrl() {
|
|
|
|
|
if ($this->themeExist('getBaseUrl')) {
|
|
|
|
|
return $this->theme->getBaseUrl();
|
2013-06-12 13:15:08 +00:00
|
|
|
|
} else {
|
2013-07-03 12:21:51 +00:00
|
|
|
|
return $this->defaultBaseUrl;
|
2013-06-12 13:15:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 13:12:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns the URL where the sync clients are listed
|
|
|
|
|
* @return string URL
|
|
|
|
|
*/
|
2013-07-03 12:21:51 +00:00
|
|
|
|
public function getSyncClientUrl() {
|
|
|
|
|
if ($this->themeExist('getSyncClientUrl')) {
|
|
|
|
|
return $this->theme->getSyncClientUrl();
|
2013-06-12 13:44:11 +00:00
|
|
|
|
} else {
|
2013-07-03 12:21:51 +00:00
|
|
|
|
return $this->defaultSyncClientUrl;
|
2013-06-12 13:44:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-08 13:51:05 +00:00
|
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-27 12:07:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-08 13:51:05 +00:00
|
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 13:12:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns the documentation URL
|
|
|
|
|
* @return string URL
|
|
|
|
|
*/
|
2013-07-03 12:21:51 +00:00
|
|
|
|
public function getDocBaseUrl() {
|
|
|
|
|
if ($this->themeExist('getDocBaseUrl')) {
|
|
|
|
|
return $this->theme->getDocBaseUrl();
|
2013-06-12 14:19:28 +00:00
|
|
|
|
} else {
|
2013-07-03 12:21:51 +00:00
|
|
|
|
return $this->defaultDocBaseUrl;
|
2013-06-12 14:19:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 13:12:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns the title
|
|
|
|
|
* @return string title
|
|
|
|
|
*/
|
2013-07-11 14:38:07 +00:00
|
|
|
|
public function getTitle() {
|
|
|
|
|
if ($this->themeExist('getTitle')) {
|
|
|
|
|
return $this->theme->getTitle();
|
|
|
|
|
} else {
|
|
|
|
|
return $this->defaultTitle;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 13:12:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns the short name of the software
|
|
|
|
|
* @return string title
|
|
|
|
|
*/
|
2013-07-03 12:21:51 +00:00
|
|
|
|
public function getName() {
|
|
|
|
|
if ($this->themeExist('getName')) {
|
|
|
|
|
return $this->theme->getName();
|
2013-06-12 13:15:08 +00:00
|
|
|
|
} else {
|
2013-07-03 12:21:51 +00:00
|
|
|
|
return $this->defaultName;
|
2013-06-12 13:15:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-03 20:13:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 13:12:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns entity (e.g. company name) - used for footer, copyright
|
|
|
|
|
* @return string entity name
|
|
|
|
|
*/
|
2013-07-03 12:21:51 +00:00
|
|
|
|
public function getEntity() {
|
|
|
|
|
if ($this->themeExist('getEntity')) {
|
|
|
|
|
return $this->theme->getEntity();
|
2013-06-12 13:15:08 +00:00
|
|
|
|
} else {
|
2013-07-03 12:21:51 +00:00
|
|
|
|
return $this->defaultEntity;
|
2013-06-12 13:15:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 13:12:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns slogan
|
|
|
|
|
* @return string slogan
|
|
|
|
|
*/
|
2013-07-03 12:21:51 +00:00
|
|
|
|
public function getSlogan() {
|
|
|
|
|
if ($this->themeExist('getSlogan')) {
|
|
|
|
|
return $this->theme->getSlogan();
|
2013-06-12 13:15:08 +00:00
|
|
|
|
} else {
|
2013-07-03 12:21:51 +00:00
|
|
|
|
return $this->defaultSlogan;
|
2013-06-12 13:15:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 13:12:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns logo claim
|
|
|
|
|
* @return string logo claim
|
2017-08-02 15:10:25 +00:00
|
|
|
|
* @deprecated 13.0.0
|
2013-11-25 13:12:07 +00:00
|
|
|
|
*/
|
2013-07-03 12:21:51 +00:00
|
|
|
|
public function getLogoClaim() {
|
2017-08-02 15:10:25 +00:00
|
|
|
|
return '';
|
2013-06-28 08:06:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 13:12:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns short version of the footer
|
|
|
|
|
* @return string short footer
|
|
|
|
|
*/
|
2013-07-03 12:21:51 +00:00
|
|
|
|
public function getShortFooter() {
|
|
|
|
|
if ($this->themeExist('getShortFooter')) {
|
|
|
|
|
$footer = $this->theme->getShortFooter();
|
2013-06-27 14:24:03 +00:00
|
|
|
|
} else {
|
2015-02-16 12:37:54 +00:00
|
|
|
|
$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
|
2017-10-19 10:16:04 +00:00
|
|
|
|
' rel="noreferrer noopener">' .$this->getEntity() . '</a>'.
|
2013-07-03 12:21:51 +00:00
|
|
|
|
' – ' . $this->getSlogan();
|
2013-06-26 15:56:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $footer;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 13:12:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns long version of the footer
|
|
|
|
|
* @return string long footer
|
|
|
|
|
*/
|
2013-07-03 12:21:51 +00:00
|
|
|
|
public function getLongFooter() {
|
|
|
|
|
if ($this->themeExist('getLongFooter')) {
|
|
|
|
|
$footer = $this->theme->getLongFooter();
|
2013-06-26 15:56:19 +00:00
|
|
|
|
} else {
|
2013-07-03 12:21:51 +00:00
|
|
|
|
$footer = $this->getShortFooter();
|
2013-06-26 15:56:19 +00:00
|
|
|
|
}
|
2013-06-27 14:24:03 +00:00
|
|
|
|
|
2013-06-26 15:56:19 +00:00
|
|
|
|
return $footer;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-15 12:54:26 +00:00
|
|
|
|
/**
|
|
|
|
|
* @param string $key
|
2017-04-07 20:42:43 +00:00
|
|
|
|
* @return string URL to doc with key
|
2016-01-15 12:54:26 +00:00
|
|
|
|
*/
|
2014-02-25 22:06:23 +00:00
|
|
|
|
public function buildDocLinkToKey($key) {
|
|
|
|
|
if ($this->themeExist('buildDocLinkToKey')) {
|
|
|
|
|
return $this->theme->buildDocLinkToKey($key);
|
|
|
|
|
}
|
2014-05-28 23:21:54 +00:00
|
|
|
|
return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
|
2014-02-25 22:06:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-03 11:43:22 +00:00
|
|
|
|
/**
|
2017-03-28 16:10:02 +00:00
|
|
|
|
* Returns primary color
|
2014-05-11 20:51:30 +00:00
|
|
|
|
* @return string
|
2014-03-03 11:43:22 +00:00
|
|
|
|
*/
|
2017-03-27 23:37:47 +00:00
|
|
|
|
public function getColorPrimary() {
|
2017-03-28 11:29:59 +00:00
|
|
|
|
|
2017-03-27 23:37:47 +00:00
|
|
|
|
if ($this->themeExist('getColorPrimary')) {
|
|
|
|
|
return $this->theme->getColorPrimary();
|
2014-03-03 11:43:22 +00:00
|
|
|
|
}
|
2017-03-28 11:29:59 +00:00
|
|
|
|
if ($this->themeExist('getMailHeaderColor')) {
|
|
|
|
|
return $this->theme->getMailHeaderColor();
|
|
|
|
|
}
|
2017-03-28 16:10:02 +00:00
|
|
|
|
return $this->defaultColorPrimary;
|
2014-03-03 11:43:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 15:42:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* @return array scss variables to overwrite
|
|
|
|
|
*/
|
|
|
|
|
public function getScssVariables() {
|
|
|
|
|
if($this->themeExist('getScssVariables')) {
|
|
|
|
|
return $this->theme->getScssVariables();
|
|
|
|
|
}
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-21 12:10:55 +00:00
|
|
|
|
public function shouldReplaceIcons() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2017-04-07 20:42:43 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Themed logo url
|
|
|
|
|
*
|
2017-05-08 12:51:55 +00:00
|
|
|
|
* @param bool $useSvg Whether to point to the SVG image or a fallback
|
2017-04-07 20:42:43 +00:00
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2017-05-08 12:51:55 +00:00
|
|
|
|
public function getLogo($useSvg = true) {
|
2017-04-07 20:42:43 +00:00
|
|
|
|
if ($this->themeExist('getLogo')) {
|
2017-05-08 12:51:55 +00:00
|
|
|
|
return $this->theme->getLogo($useSvg);
|
2017-04-07 20:42:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-08 12:51:55 +00:00
|
|
|
|
if($useSvg) {
|
2018-08-28 13:58:27 +00:00
|
|
|
|
$logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.svg');
|
2017-05-08 12:51:55 +00:00
|
|
|
|
} else {
|
2018-08-28 13:58:27 +00:00
|
|
|
|
$logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.png');
|
2017-05-08 12:51:55 +00:00
|
|
|
|
}
|
|
|
|
|
return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion()));
|
2017-04-07 20:42:43 +00:00
|
|
|
|
}
|
2017-12-08 11:16:05 +00:00
|
|
|
|
|
|
|
|
|
public function getTextColorPrimary() {
|
|
|
|
|
if ($this->themeExist('getTextColorPrimary')) {
|
|
|
|
|
return $this->theme->getTextColorPrimary();
|
|
|
|
|
}
|
|
|
|
|
return $this->defaultTextColorPrimary;
|
|
|
|
|
}
|
2013-06-26 15:56:19 +00:00
|
|
|
|
}
|