Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/dav/lib/connector/sabre/serverfactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function createServer($baseUri,
$server->setBaseUri($baseUri);

// Load plugins
$defaults = new \OC_Defaults();
$defaults = new \OCP\Defaults();
$server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin($this->config));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin($this->config));
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, $defaults->getName()));
Expand Down
8 changes: 7 additions & 1 deletion apps/theming/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
13 changes: 13 additions & 0 deletions apps/theming/lib/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ 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);
}
Expand All @@ -93,6 +97,15 @@ public function getSlogan() {
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 : '');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit test? 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


return $footer;
}

/**
* Color that is used for the header as well as for mail headers
*
Expand Down
46 changes: 46 additions & 0 deletions apps/theming/tests/lib/TemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@ public function testGetNameWithCustom() {
$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())
Expand Down Expand Up @@ -172,6 +192,32 @@ public function testGetSloganWithCustom() {
$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())
Expand Down
4 changes: 2 additions & 2 deletions core/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ public function __construct(array $urlParams=array()){
$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();
Expand Down
2 changes: 1 addition & 1 deletion core/command/maintenance/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
// 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'];
Expand Down
2 changes: 1 addition & 1 deletion lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ public static function handleRequest() {
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);
Expand Down
2 changes: 1 addition & 1 deletion lib/private/console/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/private/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ public function __construct($webRoot, \OC\Config $config) {
return new Mailer(
$c->getConfig(),
$c->getLogger(),
new \OC_Defaults()
$c->getThemingDefaults()
);
});
$this->registerService('OcsClient', function (Server $c) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ public static function updateHtaccess() {
}

$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());
Expand Down
2 changes: 1 addition & 1 deletion lib/private/urlgenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public function getAbsoluteURL($url) {
* @return string url to the online documentation
*/
public function linkToDocs($key) {
$theme = new OC_Defaults();
$theme = \OC::$server->getThemingDefaults();
return $theme->buildDocLinkToKey($key);
}
}
2 changes: 1 addition & 1 deletion lib/private/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ public static function checkServer(\OCP\IConfig $config) {

$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();

Expand Down
2 changes: 1 addition & 1 deletion lib/public/defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Defaults {
* @since 6.0.0
*/
function __construct() {
$this->defaults = new \OC_Defaults();
$this->defaults = \OC::$server->getThemingDefaults();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion settings/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function __construct(array $urlParams=[]){
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');
Expand Down
2 changes: 1 addition & 1 deletion settings/personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,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();
Expand Down