From 18fd8ff70cb00a886b86dd8e540f40be1ee4d735 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Fri, 12 Aug 2016 15:30:35 +0200 Subject: rename "Tenmplate" to "ThemingDefaults" to make the auto loader happy" --- apps/theming/lib/Settings/Admin.php | 4 +- apps/theming/lib/Template.php | 171 ----------------------------------- apps/theming/lib/ThemingDefaults.php | 166 ++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+), 173 deletions(-) delete mode 100644 apps/theming/lib/Template.php create mode 100644 apps/theming/lib/ThemingDefaults.php (limited to 'apps/theming/lib') diff --git a/apps/theming/lib/Settings/Admin.php b/apps/theming/lib/Settings/Admin.php index 07dfe75ec60..03356c11383 100644 --- a/apps/theming/lib/Settings/Admin.php +++ b/apps/theming/lib/Settings/Admin.php @@ -23,7 +23,7 @@ namespace OCA\Theming\Settings; -use OCA\Theming\Template; +use OCA\Theming\ThemingDefaults; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; use OCP\IL10N; @@ -44,7 +44,7 @@ class Admin implements ISettings { /** @var IURLGenerator */ private $urlGenerator; - public function __construct(IConfig $config, IL10N $l, Template $themingDefaults, IURLGenerator $urlGenerator) { + public function __construct(IConfig $config, IL10N $l, ThemingDefaults $themingDefaults, IURLGenerator $urlGenerator) { $this->config = $config; $this->l = $l; $this->themingDefaults = $themingDefaults; diff --git a/apps/theming/lib/Template.php b/apps/theming/lib/Template.php deleted file mode 100644 index 25730aad95b..00000000000 --- a/apps/theming/lib/Template.php +++ /dev/null @@ -1,171 +0,0 @@ - - * @copyright Copyright (c) 2016 Lukas Reschke - * - * @author Bjoern Schiessle - * @author Joas Schilling - * @author Lukas Reschke - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * 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 - * along with this program. If not, see . - * - */ - -namespace OCA\Theming; - -use OCP\IConfig; -use OCP\IL10N; -use OCP\IURLGenerator; - -/** - * Class Template - * - * Handle all the values which can be modified by this app - * - * @package OCA\Theming - */ -class Template extends \OC_Defaults { - /** @var IConfig */ - private $config; - /** @var IL10N */ - private $l; - /** @var IURLGenerator */ - private $urlGenerator; - /** @var string */ - private $name; - /** @var string */ - private $url; - /** @var string */ - private $slogan; - /** @var string */ - private $color; - - /** - * Template constructor. - * - * @param IConfig $config - * @param IL10N $l - * @param IURLGenerator $urlGenerator - * @param \OC_Defaults $defaults - */ - public function __construct(IConfig $config, - IL10N $l, - IURLGenerator $urlGenerator, - \OC_Defaults $defaults - ) { - parent::__construct(); - $this->config = $config; - $this->l = $l; - $this->urlGenerator = $urlGenerator; - - $this->name = $defaults->getName(); - $this->url = $defaults->getBaseUrl(); - $this->slogan = $defaults->getSlogan(); - $this->color = $defaults->getMailHeaderColor(); - } - - public function getName() { - return $this->config->getAppValue('theming', 'name', $this->name); - } - - public function getHTMLName() { - return $this->config->getAppValue('theming', 'name', $this->name); - } - - public function getTitle() { - return $this->config->getAppValue('theming', 'name', $this->name); - } - - public function getEntity() { - return $this->config->getAppValue('theming', 'name', $this->name); - } - - public function getBaseUrl() { - return $this->config->getAppValue('theming', 'url', $this->url); - } - - public function getSlogan() { - return $this->config->getAppValue('theming', 'slogan', $this->slogan); - } - - public function getShortFooter() { - $slogan = $this->getSlogan(); - $footer = '' .$this->getEntity() . ''. - ($slogan !== '' ? ' – ' . $slogan : ''); - - return $footer; - } - - /** - * Color that is used for the header as well as for mail headers - * - * @return string - */ - public function getMailHeaderColor() { - return $this->config->getAppValue('theming', 'color', $this->color); - } - - /** - * Increases the cache buster key - */ - private function increaseCacheBuster() { - $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); - $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); - } - - /** - * Update setting in the database - * - * @param string $setting - * @param string $value - */ - public function set($setting, $value) { - $this->config->setAppValue('theming', $setting, $value); - $this->increaseCacheBuster(); - } - - /** - * Revert settings to the default value - * - * @param string $setting setting which should be reverted - * @return string default value - */ - public function undo($setting) { - $this->config->deleteAppValue('theming', $setting); - $this->increaseCacheBuster(); - - switch ($setting) { - case 'name': - $returnValue = $this->getEntity(); - break; - case 'url': - $returnValue = $this->getBaseUrl(); - break; - case 'slogan': - $returnValue = $this->getSlogan(); - break; - case 'color': - $returnValue = $this->getMailHeaderColor(); - break; - default: - $returnValue = ''; - break; - } - - return $returnValue; - } -} diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php new file mode 100644 index 00000000000..a7af208b96d --- /dev/null +++ b/apps/theming/lib/ThemingDefaults.php @@ -0,0 +1,166 @@ + + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OCA\Theming; + + + + +use OCP\IConfig; +use OCP\IL10N; +use OCP\IURLGenerator; + + +class ThemingDefaults extends \OC_Defaults { + + /** @var IConfig */ + private $config; + /** @var IL10N */ + private $l; + /** @var IURLGenerator */ + private $urlGenerator; + /** @var string */ + private $name; + /** @var string */ + private $url; + /** @var string */ + private $slogan; + /** @var string */ + private $color; + + /** + * Template constructor. + * + * @param IConfig $config + * @param IL10N $l + * @param IURLGenerator $urlGenerator + * @param \OC_Defaults $defaults + */ + public function __construct(IConfig $config, + IL10N $l, + IURLGenerator $urlGenerator, + \OC_Defaults $defaults + ) { + parent::__construct(); + $this->config = $config; + $this->l = $l; + $this->urlGenerator = $urlGenerator; + + $this->name = $defaults->getName(); + $this->url = $defaults->getBaseUrl(); + $this->slogan = $defaults->getSlogan(); + $this->color = $defaults->getMailHeaderColor(); + } + + public function getName() { + return $this->config->getAppValue('theming', 'name', $this->name); + } + + public function getHTMLName() { + return $this->config->getAppValue('theming', 'name', $this->name); + } + + public function getTitle() { + return $this->config->getAppValue('theming', 'name', $this->name); + } + + public function getEntity() { + return $this->config->getAppValue('theming', 'name', $this->name); + } + + public function getBaseUrl() { + return $this->config->getAppValue('theming', 'url', $this->url); + } + + public function getSlogan() { + return $this->config->getAppValue('theming', 'slogan', $this->slogan); + } + + public function getShortFooter() { + $slogan = $this->getSlogan(); + $footer = '' .$this->getEntity() . ''. + ($slogan !== '' ? ' – ' . $slogan : ''); + + return $footer; + } + + /** + * Color that is used for the header as well as for mail headers + * + * @return string + */ + public function getMailHeaderColor() { + return $this->config->getAppValue('theming', 'color', $this->color); + } + + /** + * Increases the cache buster key + */ + private function increaseCacheBuster() { + $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); + $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); + } + + /** + * Update setting in the database + * + * @param string $setting + * @param string $value + */ + public function set($setting, $value) { + $this->config->setAppValue('theming', $setting, $value); + $this->increaseCacheBuster(); + } + + /** + * Revert settings to the default value + * + * @param string $setting setting which should be reverted + * @return string default value + */ + public function undo($setting) { + $this->config->deleteAppValue('theming', $setting); + $this->increaseCacheBuster(); + + switch ($setting) { + case 'name': + $returnValue = $this->getEntity(); + break; + case 'url': + $returnValue = $this->getBaseUrl(); + break; + case 'slogan': + $returnValue = $this->getSlogan(); + break; + case 'color': + $returnValue = $this->getMailHeaderColor(); + break; + default: + $returnValue = ''; + break; + } + + return $returnValue; + } + +} -- cgit v1.2.3