Skip to content

Commit ea470f8

Browse files
authored
Merge pull request #405 from nextcloud/theming-fixes
Theming fixes
2 parents 68735c1 + ec6f696 commit ea470f8

File tree

19 files changed

+87
-25
lines changed

19 files changed

+87
-25
lines changed

apps/dav/lib/Connector/PublicAuth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function __construct(IRequest $request,
6565
$this->session = $session;
6666

6767
// setup realm
68-
$defaults = new \OC_Defaults();
68+
$defaults = new \OCP\Defaults();
6969
$this->realm = $defaults->getName();
7070
}
7171

apps/dav/lib/Connector/Sabre/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function __construct(ISession $session,
7878
$this->principalPrefix = $principalPrefix;
7979

8080
// setup realm
81-
$defaults = new \OC_Defaults();
81+
$defaults = new \OCP\Defaults();
8282
$this->realm = $defaults->getName();
8383
}
8484

apps/federation/lib/DAV/FedAuth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(DbHandler $db) {
3838
$this->principalPrefix = 'principals/system/';
3939

4040
// setup realm
41-
$defaults = new \OC_Defaults();
41+
$defaults = new \OCP\Defaults();
4242
$this->realm = $defaults->getName();
4343
}
4444

apps/theming/appinfo/info.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@
55
<description>Adjust the Nextcloud theme</description>
66
<licence>AGPL</licence>
77
<author>Nextcloud</author>
8-
<version>0.1.0</version>
8+
<version>0.2.0</version>
99
<namespace>Theming</namespace>
1010
<category>other</category>
11+
1112
<dependencies>
1213
<owncloud min-version="9.0" max-version="9.1" />
1314
</dependencies>
15+
16+
<types>
17+
<logging/>
18+
</types>
19+
1420
<default_enable/>
1521
</info>

apps/theming/lib/template.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ public function getName() {
7777
return $this->config->getAppValue('theming', 'name', $this->name);
7878
}
7979

80+
public function getHTMLName() {
81+
return $this->config->getAppValue('theming', 'name', $this->name);
82+
}
83+
8084
public function getTitle() {
8185
return $this->config->getAppValue('theming', 'name', $this->name);
8286
}
@@ -93,6 +97,15 @@ public function getSlogan() {
9397
return $this->config->getAppValue('theming', 'slogan', $this->slogan);
9498
}
9599

100+
public function getShortFooter() {
101+
$slogan = $this->getSlogan();
102+
$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
103+
' rel="noreferrer">' .$this->getEntity() . '</a>'.
104+
($slogan !== '' ? '' . $slogan : '');
105+
106+
return $footer;
107+
}
108+
96109
/**
97110
* Color that is used for the header as well as for mail headers
98111
*

apps/theming/tests/lib/TemplateTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,26 @@ public function testGetNameWithCustom() {
9191
$this->assertEquals('MyCustomCloud', $this->template->getName());
9292
}
9393

94+
public function testGetHTMLNameWithDefault() {
95+
$this->config
96+
->expects($this->once())
97+
->method('getAppValue')
98+
->with('theming', 'name', 'Nextcloud')
99+
->willReturn('Nextcloud');
100+
101+
$this->assertEquals('Nextcloud', $this->template->getHTMLName());
102+
}
103+
104+
public function testGetHTMLNameWithCustom() {
105+
$this->config
106+
->expects($this->once())
107+
->method('getAppValue')
108+
->with('theming', 'name', 'Nextcloud')
109+
->willReturn('MyCustomCloud');
110+
111+
$this->assertEquals('MyCustomCloud', $this->template->getHTMLName());
112+
}
113+
94114
public function testGetTitleWithDefault() {
95115
$this->config
96116
->expects($this->once())
@@ -172,6 +192,32 @@ public function testGetSloganWithCustom() {
172192
$this->assertEquals('My custom Slogan', $this->template->getSlogan());
173193
}
174194

195+
public function testGetShortFooter() {
196+
$this->config
197+
->expects($this->exactly(3))
198+
->method('getAppValue')
199+
->willReturnMap([
200+
['theming', 'url', 'https://nextcloud.com/', 'url'],
201+
['theming', 'name', 'Nextcloud', 'Name'],
202+
['theming', 'slogan', 'Safe Data', 'Slogan'],
203+
]);
204+
205+
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer">Name</a> – Slogan', $this->template->getShortFooter());
206+
}
207+
208+
public function testGetShortFooterEmptySlogan() {
209+
$this->config
210+
->expects($this->exactly(3))
211+
->method('getAppValue')
212+
->willReturnMap([
213+
['theming', 'url', 'https://nextcloud.com/', 'url'],
214+
['theming', 'name', 'Nextcloud', 'Name'],
215+
['theming', 'slogan', 'Safe Data', ''],
216+
]);
217+
218+
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer">Name</a>', $this->template->getShortFooter());
219+
}
220+
175221
public function testGetMailHeaderColorWithDefault() {
176222
$this->config
177223
->expects($this->once())

core/Application.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
use OC\Core\Controller\TokenController;
3636
use OC\Core\Controller\TwoFactorChallengeController;
3737
use OC\Core\Controller\UserController;
38-
use OC_Defaults;
38+
use OCP\Defaults;
3939
use OCP\AppFramework\App;
4040
use OCP\Util;
4141

@@ -165,8 +165,8 @@ public function __construct(array $urlParams=array()){
165165
$container->registerService('UserFolder', function(SimpleContainer $c) {
166166
return $c->query('ServerContainer')->getUserFolder();
167167
});
168-
$container->registerService('Defaults', function() {
169-
return new OC_Defaults;
168+
$container->registerService('Defaults', function(SimpleContainer $c) {
169+
return $c->query('ServerContainer')->getThemingDefaults();
170170
});
171171
$container->registerService('Mailer', function(SimpleContainer $c) {
172172
return $c->query('ServerContainer')->getMailer();

core/Command/Maintenance/Install.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
6464
// validate the environment
6565
$server = \OC::$server;
6666
$setupHelper = new Setup($this->config, $server->getIniWrapper(),
67-
$server->getL10N('lib'), new \OC_Defaults(), $server->getLogger(),
67+
$server->getL10N('lib'), $server->getThemingDefaults(), $server->getLogger(),
6868
$server->getSecureRandom());
6969
$sysInfo = $setupHelper->getSystemInfo(true);
7070
$errors = $sysInfo['errors'];

core/Controller/LostController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
use OCP\IUserManager;
3939
use OCP\Mail\IMailer;
4040
use OCP\Security\ISecureRandom;
41-
use \OC_Defaults;
4241
use OCP\Security\StringUtils;
4342

4443
/**
@@ -54,8 +53,7 @@ class LostController extends Controller {
5453
protected $urlGenerator;
5554
/** @var IUserManager */
5655
protected $userManager;
57-
// FIXME: Inject a non-static factory of OC_Defaults for better unit-testing
58-
/** @var OC_Defaults */
56+
/** @var \OC_Defaults */
5957
protected $defaults;
6058
/** @var IL10N */
6159
protected $l10n;
@@ -77,7 +75,7 @@ class LostController extends Controller {
7775
* @param IRequest $request
7876
* @param IURLGenerator $urlGenerator
7977
* @param IUserManager $userManager
80-
* @param OC_Defaults $defaults
78+
* @param \OC_Defaults $defaults
8179
* @param IL10N $l10n
8280
* @param IConfig $config
8381
* @param ISecureRandom $secureRandom
@@ -90,7 +88,7 @@ public function __construct($appName,
9088
IRequest $request,
9189
IURLGenerator $urlGenerator,
9290
IUserManager $userManager,
93-
OC_Defaults $defaults,
91+
\OC_Defaults $defaults,
9492
IL10N $l10n,
9593
IConfig $config,
9694
ISecureRandom $secureRandom,

lib/base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ public static function handleRequest() {
812812
if (!$systemConfig->getValue('installed', false)) {
813813
\OC::$server->getSession()->clear();
814814
$setupHelper = new OC\Setup(\OC::$server->getConfig(), \OC::$server->getIniWrapper(),
815-
\OC::$server->getL10N('lib'), new \OC_Defaults(), \OC::$server->getLogger(),
815+
\OC::$server->getL10N('lib'), \OC::$server->getThemingDefaults(), \OC::$server->getLogger(),
816816
\OC::$server->getSecureRandom());
817817
$controller = new OC\Core\Controller\SetupController($setupHelper);
818818
$controller->run($_POST);

0 commit comments

Comments
 (0)