diff options
author | Björn Schießle <bjoern@schiessle.org> | 2016-07-18 15:59:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-18 15:59:47 +0200 |
commit | ea470f877760c72b1e8b865ba600d5bd483027c0 (patch) | |
tree | 3b4c4fa327d8e6521c782e6e45f1d73eb95d70ec | |
parent | 68735c188c0f9777f932f55b1c290039c9d6e433 (diff) | |
parent | ec6f6969789ca2f455c0d2fd04557337c782176b (diff) | |
download | nextcloud-server-ea470f877760c72b1e8b865ba600d5bd483027c0.tar.gz nextcloud-server-ea470f877760c72b1e8b865ba600d5bd483027c0.zip |
Merge pull request #405 from nextcloud/theming-fixes
Theming fixes
-rw-r--r-- | apps/dav/lib/Connector/PublicAuth.php | 2 | ||||
-rw-r--r-- | apps/dav/lib/Connector/Sabre/Auth.php | 2 | ||||
-rw-r--r-- | apps/federation/lib/DAV/FedAuth.php | 2 | ||||
-rw-r--r-- | apps/theming/appinfo/info.xml | 8 | ||||
-rw-r--r-- | apps/theming/lib/template.php | 13 | ||||
-rw-r--r-- | apps/theming/tests/lib/TemplateTest.php | 46 | ||||
-rw-r--r-- | core/Application.php | 6 | ||||
-rw-r--r-- | core/Command/Maintenance/Install.php | 2 | ||||
-rw-r--r-- | core/Controller/LostController.php | 8 | ||||
-rw-r--r-- | lib/base.php | 2 | ||||
-rw-r--r-- | lib/private/Console/Application.php | 4 | ||||
-rw-r--r-- | lib/private/Server.php | 2 | ||||
-rw-r--r-- | lib/private/Setup.php | 2 | ||||
-rw-r--r-- | lib/private/URLGenerator.php | 4 | ||||
-rw-r--r-- | lib/private/legacy/util.php | 2 | ||||
-rw-r--r-- | lib/public/Defaults.php | 2 | ||||
-rw-r--r-- | settings/Application.php | 2 | ||||
-rw-r--r-- | settings/Controller/MailSettingsController.php | 1 | ||||
-rw-r--r-- | settings/personal.php | 2 |
19 files changed, 87 insertions, 25 deletions
diff --git a/apps/dav/lib/Connector/PublicAuth.php b/apps/dav/lib/Connector/PublicAuth.php index 4e63ca1d29e..9b386c7609d 100644 --- a/apps/dav/lib/Connector/PublicAuth.php +++ b/apps/dav/lib/Connector/PublicAuth.php @@ -65,7 +65,7 @@ class PublicAuth extends AbstractBasic { $this->session = $session; // setup realm - $defaults = new \OC_Defaults(); + $defaults = new \OCP\Defaults(); $this->realm = $defaults->getName(); } diff --git a/apps/dav/lib/Connector/Sabre/Auth.php b/apps/dav/lib/Connector/Sabre/Auth.php index 82c2711b560..28e4ae2bcde 100644 --- a/apps/dav/lib/Connector/Sabre/Auth.php +++ b/apps/dav/lib/Connector/Sabre/Auth.php @@ -78,7 +78,7 @@ class Auth extends AbstractBasic { $this->principalPrefix = $principalPrefix; // setup realm - $defaults = new \OC_Defaults(); + $defaults = new \OCP\Defaults(); $this->realm = $defaults->getName(); } diff --git a/apps/federation/lib/DAV/FedAuth.php b/apps/federation/lib/DAV/FedAuth.php index 21c0d61487c..ff83932283c 100644 --- a/apps/federation/lib/DAV/FedAuth.php +++ b/apps/federation/lib/DAV/FedAuth.php @@ -38,7 +38,7 @@ class FedAuth extends AbstractBasic { $this->principalPrefix = 'principals/system/'; // setup realm - $defaults = new \OC_Defaults(); + $defaults = new \OCP\Defaults(); $this->realm = $defaults->getName(); } diff --git a/apps/theming/appinfo/info.xml b/apps/theming/appinfo/info.xml index 58c839f2758..6db66632a45 100644 --- a/apps/theming/appinfo/info.xml +++ b/apps/theming/appinfo/info.xml @@ -5,11 +5,17 @@ <description>Adjust the Nextcloud theme</description> <licence>AGPL</licence> <author>Nextcloud</author> - <version>0.1.0</version> + <version>0.2.0</version> <namespace>Theming</namespace> <category>other</category> + <dependencies> <owncloud min-version="9.0" max-version="9.1" /> </dependencies> + + <types> + <logging/> + </types> + <default_enable/> </info> diff --git a/apps/theming/lib/template.php b/apps/theming/lib/template.php index a09a854ca69..436dfe86a03 100644 --- a/apps/theming/lib/template.php +++ b/apps/theming/lib/template.php @@ -77,6 +77,10 @@ class Template extends \OC_Defaults { 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); } @@ -93,6 +97,15 @@ class Template extends \OC_Defaults { return $this->config->getAppValue('theming', 'slogan', $this->slogan); } + public function getShortFooter() { + $slogan = $this->getSlogan(); + $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . + ' rel="noreferrer">' .$this->getEntity() . '</a>'. + ($slogan !== '' ? ' – ' . $slogan : ''); + + return $footer; + } + /** * Color that is used for the header as well as for mail headers * diff --git a/apps/theming/tests/lib/TemplateTest.php b/apps/theming/tests/lib/TemplateTest.php index 1ee860f93c4..cd7115d2086 100644 --- a/apps/theming/tests/lib/TemplateTest.php +++ b/apps/theming/tests/lib/TemplateTest.php @@ -91,6 +91,26 @@ class TemplateTest extends TestCase { $this->assertEquals('MyCustomCloud', $this->template->getName()); } + public function testGetHTMLNameWithDefault() { + $this->config + ->expects($this->once()) + ->method('getAppValue') + ->with('theming', 'name', 'Nextcloud') + ->willReturn('Nextcloud'); + + $this->assertEquals('Nextcloud', $this->template->getHTMLName()); + } + + public function testGetHTMLNameWithCustom() { + $this->config + ->expects($this->once()) + ->method('getAppValue') + ->with('theming', 'name', 'Nextcloud') + ->willReturn('MyCustomCloud'); + + $this->assertEquals('MyCustomCloud', $this->template->getHTMLName()); + } + public function testGetTitleWithDefault() { $this->config ->expects($this->once()) @@ -172,6 +192,32 @@ class TemplateTest extends TestCase { $this->assertEquals('My custom Slogan', $this->template->getSlogan()); } + public function testGetShortFooter() { + $this->config + ->expects($this->exactly(3)) + ->method('getAppValue') + ->willReturnMap([ + ['theming', 'url', 'https://nextcloud.com/', 'url'], + ['theming', 'name', 'Nextcloud', 'Name'], + ['theming', 'slogan', 'Safe Data', 'Slogan'], + ]); + + $this->assertEquals('<a href="url" target="_blank" rel="noreferrer">Name</a> – Slogan', $this->template->getShortFooter()); + } + + public function testGetShortFooterEmptySlogan() { + $this->config + ->expects($this->exactly(3)) + ->method('getAppValue') + ->willReturnMap([ + ['theming', 'url', 'https://nextcloud.com/', 'url'], + ['theming', 'name', 'Nextcloud', 'Name'], + ['theming', 'slogan', 'Safe Data', ''], + ]); + + $this->assertEquals('<a href="url" target="_blank" rel="noreferrer">Name</a>', $this->template->getShortFooter()); + } + public function testGetMailHeaderColorWithDefault() { $this->config ->expects($this->once()) diff --git a/core/Application.php b/core/Application.php index a87917b626a..1485f7a7516 100644 --- a/core/Application.php +++ b/core/Application.php @@ -35,7 +35,7 @@ use OC\Core\Controller\LostController; use OC\Core\Controller\TokenController; use OC\Core\Controller\TwoFactorChallengeController; use OC\Core\Controller\UserController; -use OC_Defaults; +use OCP\Defaults; use OCP\AppFramework\App; use OCP\Util; @@ -165,8 +165,8 @@ class Application extends App { $container->registerService('UserFolder', function(SimpleContainer $c) { return $c->query('ServerContainer')->getUserFolder(); }); - $container->registerService('Defaults', function() { - return new OC_Defaults; + $container->registerService('Defaults', function(SimpleContainer $c) { + return $c->query('ServerContainer')->getThemingDefaults(); }); $container->registerService('Mailer', function(SimpleContainer $c) { return $c->query('ServerContainer')->getMailer(); diff --git a/core/Command/Maintenance/Install.php b/core/Command/Maintenance/Install.php index cee0c60b488..3e9e043b036 100644 --- a/core/Command/Maintenance/Install.php +++ b/core/Command/Maintenance/Install.php @@ -64,7 +64,7 @@ class Install extends Command { // validate the environment $server = \OC::$server; $setupHelper = new Setup($this->config, $server->getIniWrapper(), - $server->getL10N('lib'), new \OC_Defaults(), $server->getLogger(), + $server->getL10N('lib'), $server->getThemingDefaults(), $server->getLogger(), $server->getSecureRandom()); $sysInfo = $setupHelper->getSystemInfo(true); $errors = $sysInfo['errors']; diff --git a/core/Controller/LostController.php b/core/Controller/LostController.php index b509d4bf632..774404af0a5 100644 --- a/core/Controller/LostController.php +++ b/core/Controller/LostController.php @@ -38,7 +38,6 @@ use \OCP\IConfig; use OCP\IUserManager; use OCP\Mail\IMailer; use OCP\Security\ISecureRandom; -use \OC_Defaults; use OCP\Security\StringUtils; /** @@ -54,8 +53,7 @@ class LostController extends Controller { protected $urlGenerator; /** @var IUserManager */ protected $userManager; - // FIXME: Inject a non-static factory of OC_Defaults for better unit-testing - /** @var OC_Defaults */ + /** @var \OC_Defaults */ protected $defaults; /** @var IL10N */ protected $l10n; @@ -77,7 +75,7 @@ class LostController extends Controller { * @param IRequest $request * @param IURLGenerator $urlGenerator * @param IUserManager $userManager - * @param OC_Defaults $defaults + * @param \OC_Defaults $defaults * @param IL10N $l10n * @param IConfig $config * @param ISecureRandom $secureRandom @@ -90,7 +88,7 @@ class LostController extends Controller { IRequest $request, IURLGenerator $urlGenerator, IUserManager $userManager, - OC_Defaults $defaults, + \OC_Defaults $defaults, IL10N $l10n, IConfig $config, ISecureRandom $secureRandom, diff --git a/lib/base.php b/lib/base.php index 70fac6d707b..62ace1bc0ef 100644 --- a/lib/base.php +++ b/lib/base.php @@ -812,7 +812,7 @@ class OC { if (!$systemConfig->getValue('installed', false)) { \OC::$server->getSession()->clear(); $setupHelper = new OC\Setup(\OC::$server->getConfig(), \OC::$server->getIniWrapper(), - \OC::$server->getL10N('lib'), new \OC_Defaults(), \OC::$server->getLogger(), + \OC::$server->getL10N('lib'), \OC::$server->getThemingDefaults(), \OC::$server->getLogger(), \OC::$server->getSecureRandom()); $controller = new OC\Core\Controller\SetupController($setupHelper); $controller->run($_POST); diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php index ec91064278e..be561342178 100644 --- a/lib/private/Console/Application.php +++ b/lib/private/Console/Application.php @@ -26,8 +26,8 @@ namespace OC\Console; use OC_App; -use OC_Defaults; use OCP\Console\ConsoleEvent; +use OCP\Defaults; use OCP\IConfig; use OCP\IRequest; use Symfony\Component\Console\Application as SymfonyApplication; @@ -51,7 +51,7 @@ class Application { * @param IRequest $request */ public function __construct(IConfig $config, EventDispatcherInterface $dispatcher, IRequest $request) { - $defaults = new OC_Defaults; + $defaults = \OC::$server->getThemingDefaults(); $this->config = $config; $this->application = new SymfonyApplication($defaults->getName(), \OC_Util::getVersionString()); $this->dispatcher = $dispatcher; diff --git a/lib/private/Server.php b/lib/private/Server.php index c663bc44261..d69e384ad75 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -562,7 +562,7 @@ class Server extends ServerContainer implements IServerContainer { return new Mailer( $c->getConfig(), $c->getLogger(), - new \OC_Defaults() + $c->getThemingDefaults() ); }); $this->registerService('OcsClient', function (Server $c) { diff --git a/lib/private/Setup.php b/lib/private/Setup.php index c78654de957..4a81bb31516 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -426,7 +426,7 @@ class Setup { } $setupHelper = new \OC\Setup($config, \OC::$server->getIniWrapper(), - \OC::$server->getL10N('lib'), new \OC_Defaults(), \OC::$server->getLogger(), + \OC::$server->getL10N('lib'), \OC::$server->getThemingDefaults(), \OC::$server->getLogger(), \OC::$server->getSecureRandom()); $htaccessContent = file_get_contents($setupHelper->pathToHtaccess()); diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index 9ae99d67bc6..c7b2b222faf 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -29,7 +29,7 @@ */ namespace OC; -use OC_Defaults; +use OCP\Defaults; use OCP\ICacheFactory; use OCP\IConfig; use OCP\IURLGenerator; @@ -222,7 +222,7 @@ class URLGenerator implements IURLGenerator { * @return string url to the online documentation */ public function linkToDocs($key) { - $theme = new OC_Defaults(); + $theme = \OC::$server->getThemingDefaults(); return $theme->buildDocLinkToKey($key); } } diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index 2a876eda4d0..63da546ec82 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -631,7 +631,7 @@ class OC_Util { $webServerRestart = false; $setup = new \OC\Setup($config, \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'), - new \OC_Defaults(), \OC::$server->getLogger(), \OC::$server->getSecureRandom()); + \OC::$server->getThemingDefaults(), \OC::$server->getLogger(), \OC::$server->getSecureRandom()); $urlGenerator = \OC::$server->getURLGenerator(); diff --git a/lib/public/Defaults.php b/lib/public/Defaults.php index 791ed5827de..5194484fea2 100644 --- a/lib/public/Defaults.php +++ b/lib/public/Defaults.php @@ -51,7 +51,7 @@ class Defaults { * @since 6.0.0 */ function __construct() { - $this->defaults = new \OC_Defaults(); + $this->defaults = \OC::$server->getThemingDefaults(); } /** diff --git a/settings/Application.php b/settings/Application.php index aedf1e00b2d..1549b273c51 100644 --- a/settings/Application.php +++ b/settings/Application.php @@ -227,7 +227,7 @@ class Application extends App { return $c->query('ServerContainer')->getMailer(); }); $container->registerService('Defaults', function(IContainer $c) { - return new \OC_Defaults; + return $c->query('ServerContainer')->getThemingDefaults(); }); $container->registerService('DefaultMailAddress', function(IContainer $c) { return Util::getDefaultEmailAddress('no-reply'); diff --git a/settings/Controller/MailSettingsController.php b/settings/Controller/MailSettingsController.php index 11f72e7e8ee..cd3c6e2224a 100644 --- a/settings/Controller/MailSettingsController.php +++ b/settings/Controller/MailSettingsController.php @@ -29,7 +29,6 @@ use OCP\IRequest; use OCP\IL10N; use OCP\IConfig; use OCP\Mail\IMailer; -use OCP\Mail\IMessage; /** * @package OC\Settings\Controller diff --git a/settings/personal.php b/settings/personal.php index e7a928f88bf..0519e68beaa 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -37,7 +37,7 @@ OC_Util::checkLoggedIn(); -$defaults = new OC_Defaults(); // initialize themable default strings and urls +$defaults = \OC::$server->getThemingDefaults(); $certificateManager = \OC::$server->getCertificateManager(); $config = \OC::$server->getConfig(); $urlGenerator = \OC::$server->getURLGenerator(); |