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/PublicAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __construct(IRequest $request,
$this->session = $session;

// setup realm
$defaults = new \OC_Defaults();
$defaults = new \OCP\Defaults();
Copy link
Member

Choose a reason for hiding this comment

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

any reasons why we don't use \OC::$server->getThemingDefaults() here and below?

Copy link
Member Author

Choose a reason for hiding this comment

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

getThemingDefaults() is marked as internal, and the constructor of OCP\Default uses this internal method after this PR.

$this->realm = $defaults->getName();
}

Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct(ISession $session,
$this->principalPrefix = $principalPrefix;

// setup realm
$defaults = new \OC_Defaults();
$defaults = new \OCP\Defaults();
$this->realm = $defaults->getName();
}

Expand Down
2 changes: 1 addition & 1 deletion apps/federation/lib/DAV/FedAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(DbHandler $db) {
$this->principalPrefix = 'principals/system/';

// setup realm
$defaults = new \OC_Defaults();
$defaults = new \OCP\Defaults();
$this->realm = $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"' .
Copy link
Member

Choose a reason for hiding this comment

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

needs escaping?

Copy link
Member Author

Choose a reason for hiding this comment

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

No? Or atleast this is just copy paste of the parent class, so it would need fixing there as.

' rel="noreferrer">' .$this->getEntity() . '</a>'.
($slogan !== '' ? ' – ' . $slogan : '');

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
6 changes: 3 additions & 3 deletions core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
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;

Expand Down Expand Up @@ -165,8 +165,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 @@ -64,7 +64,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
8 changes: 3 additions & 5 deletions core/Controller/LostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
use OCP\IUserManager;
use OCP\Mail\IMailer;
use OCP\Security\ISecureRandom;
use \OC_Defaults;
use OCP\Security\StringUtils;

/**
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -90,7 +88,7 @@ public function __construct($appName,
IRequest $request,
IURLGenerator $urlGenerator,
IUserManager $userManager,
OC_Defaults $defaults,
\OC_Defaults $defaults,
IL10N $l10n,
IConfig $config,
ISecureRandom $secureRandom,
Expand Down
2 changes: 1 addition & 1 deletion lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,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
4 changes: 2 additions & 2 deletions lib/private/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 @@ -562,7 +562,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 @@ -426,7 +426,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
4 changes: 2 additions & 2 deletions lib/private/URLGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/

namespace OC;
use OC_Defaults;
use OCP\Defaults;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IURLGenerator;
Expand Down Expand Up @@ -222,7 +222,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/legacy/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,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 @@ -227,7 +227,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
1 change: 0 additions & 1 deletion settings/Controller/MailSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use OCP\IL10N;
use OCP\IConfig;
use OCP\Mail\IMailer;
use OCP\Mail\IMessage;

/**
* @package OC\Settings\Controller
Expand Down
2 changes: 1 addition & 1 deletion settings/personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down