summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2017-04-11 14:39:46 +0200
committerGitHub <noreply@github.com>2017-04-11 14:39:46 +0200
commitafb5d45705f7d7743b9dfd2d79b618938cb05b77 (patch)
treea0828097cae435e504350d6aae0bbca56f40435c /apps
parent5ca5ebe584999d6dbc4b363bb285c8ae00c1b5f2 (diff)
parentd83c8e02718f5ae555e75d8582904611a4d6766a (diff)
downloadnextcloud-server-afb5d45705f7d7743b9dfd2d79b618938cb05b77.tar.gz
nextcloud-server-afb5d45705f7d7743b9dfd2d79b618938cb05b77.zip
Merge pull request #4256 from nextcloud/theming
Move OC_Defaults to OCP\Defaults
Diffstat (limited to 'apps')
-rw-r--r--apps/federatedfilesharing/settings-personal.php3
-rw-r--r--apps/files_sharing/lib/AppInfo/Application.php3
-rw-r--r--apps/files_sharing/lib/Controller/ShareController.php4
-rw-r--r--apps/files_sharing/tests/Controller/ShareControllerTest.php2
-rw-r--r--apps/provisioning_api/lib/AppInfo/Application.php3
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php8
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php6
-rw-r--r--apps/theming/lib/Controller/IconController.php8
-rw-r--r--apps/theming/lib/ThemingDefaults.php15
-rw-r--r--apps/theming/tests/Controller/IconControllerTest.php6
-rw-r--r--apps/theming/tests/ThemingDefaultsTest.php18
11 files changed, 41 insertions, 35 deletions
diff --git a/apps/federatedfilesharing/settings-personal.php b/apps/federatedfilesharing/settings-personal.php
index 71353cdef2e..d70f4e491a5 100644
--- a/apps/federatedfilesharing/settings-personal.php
+++ b/apps/federatedfilesharing/settings-personal.php
@@ -41,7 +41,8 @@ if (count($matches) > 0 && $matches[1] <= 9) {
$cloudID = \OC::$server->getUserSession()->getUser()->getCloudId();
$url = 'https://nextcloud.com/federation#' . $cloudID;
$logoPath = \OC::$server->getURLGenerator()->imagePath('core', 'logo-icon.svg');
-$theme = \OC::$server->getThemingDefaults();
+/** @var \OCP\Defaults $theme */
+$theme = \OC::$server->query(\OCP\Defaults::class);
$color = $theme->getColorPrimary();
$textColor = "#ffffff";
if(\OC::$server->getAppManager()->isEnabledForUser("theming")) {
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php
index c8cf723630b..f9540df3ff2 100644
--- a/apps/files_sharing/lib/AppInfo/Application.php
+++ b/apps/files_sharing/lib/AppInfo/Application.php
@@ -35,6 +35,7 @@ use OC\AppFramework\Utility\SimpleContainer;
use OCA\Files_Sharing\Controller\ExternalSharesController;
use OCA\Files_Sharing\Controller\ShareController;
use OCA\Files_Sharing\Middleware\SharingCheckMiddleware;
+use OCP\Defaults;
use OCP\Federation\ICloudIdManager;
use \OCP\IContainer;
use OCP\IServerContainer;
@@ -67,7 +68,7 @@ class Application extends App {
$federatedSharingApp->getFederatedShareProvider(),
$server->getEventDispatcher(),
$server->getL10N($c->query('AppName')),
- $server->getThemingDefaults()
+ $server->query(Defaults::class)
);
});
$container->registerService('ExternalSharesController', function (SimpleContainer $c) {
diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php
index bf3b6c77f94..2c6e953a0f5 100644
--- a/apps/files_sharing/lib/Controller/ShareController.php
+++ b/apps/files_sharing/lib/Controller/ShareController.php
@@ -106,7 +106,7 @@ class ShareController extends Controller {
* @param FederatedShareProvider $federatedShareProvider
* @param EventDispatcherInterface $eventDispatcher
* @param IL10N $l10n
- * @param \OC_Defaults $defaults
+ * @param Defaults $defaults
*/
public function __construct($appName,
IRequest $request,
@@ -122,7 +122,7 @@ class ShareController extends Controller {
FederatedShareProvider $federatedShareProvider,
EventDispatcherInterface $eventDispatcher,
IL10N $l10n,
- \OC_Defaults $defaults) {
+ Defaults $defaults) {
parent::__construct($appName, $request);
$this->config = $config;
diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php
index dae7740b3ae..c9a1d5ecb24 100644
--- a/apps/files_sharing/tests/Controller/ShareControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php
@@ -111,7 +111,7 @@ class ShareControllerTest extends \Test\TestCase {
$this->federatedShareProvider,
$this->eventDispatcher,
$this->getMockBuilder('\OCP\IL10N')->getMock(),
- $this->getMockBuilder('\OC_Defaults')->getMock()
+ $this->getMockBuilder('\OCP\Defaults')->getMock()
);
diff --git a/apps/provisioning_api/lib/AppInfo/Application.php b/apps/provisioning_api/lib/AppInfo/Application.php
index fd03fd41e16..b1c257de689 100644
--- a/apps/provisioning_api/lib/AppInfo/Application.php
+++ b/apps/provisioning_api/lib/AppInfo/Application.php
@@ -7,6 +7,7 @@ use OC\AppFramework\Utility\TimeFactory;
use OC\Settings\Mailer\NewUserMailHelper;
use OCA\Provisioning_API\Middleware\ProvisioningApiMiddleware;
use OCP\AppFramework\App;
+use OCP\Defaults;
use OCP\Util;
class Application extends App {
@@ -18,7 +19,7 @@ class Application extends App {
$container->registerService(NewUserMailHelper::class, function(SimpleContainer $c) use ($server) {
return new NewUserMailHelper(
- $server->getThemingDefaults(),
+ $server->query(Defaults::class),
$server->getURLGenerator(),
$server->getL10N('settings'),
$server->getMailer(),
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index 9684c7f5656..d2aeac540d2 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -33,10 +33,10 @@ use OC\Accounts\AccountManager;
use OC\Settings\Mailer\NewUserMailHelper;
use \OC_Helper;
use OCP\AppFramework\Http\DataResponse;
-use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCSController;
+use OCP\Defaults;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IGroup;
@@ -69,7 +69,7 @@ class UsersController extends OCSController {
private $urlGenerator;
/** @var IMailer */
private $mailer;
- /** @var \OC_Defaults */
+ /** @var Defaults */
private $defaults;
/** @var IFactory */
private $l10nFactory;
@@ -88,7 +88,7 @@ class UsersController extends OCSController {
* @param string $fromMailAddress
* @param IURLGenerator $urlGenerator
* @param IMailer $mailer
- * @param \OC_Defaults $defaults
+ * @param Defaults $defaults
* @param IFactory $l10nFactory
* @param NewUserMailHelper $newUserMailHelper
*/
@@ -103,7 +103,7 @@ class UsersController extends OCSController {
$fromMailAddress,
IURLGenerator $urlGenerator,
IMailer $mailer,
- \OC_Defaults $defaults,
+ Defaults $defaults,
IFactory $l10nFactory,
NewUserMailHelper $newUserMailHelper) {
parent::__construct($appName, $request);
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index 24516840a7a..24de84a0690 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -37,10 +37,10 @@ use OC\Settings\Mailer\NewUserMailHelper;
use OC\SubAdmin;
use OCA\Provisioning_API\Controller\UsersController;
use OCP\AppFramework\Http\DataResponse;
+use OCP\Defaults;
use OCP\IConfig;
use OCP\IGroup;
use OCP\ILogger;
-use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IURLGenerator;
@@ -74,7 +74,7 @@ class UsersControllerTest extends TestCase {
private $urlGenerator;
/** @var IMailer|PHPUnit_Framework_MockObject_MockObject */
private $mailer;
- /** @var \OC_Defaults|PHPUnit_Framework_MockObject_MockObject */
+ /** @var Defaults|PHPUnit_Framework_MockObject_MockObject */
private $defaults;
/** @var IFactory|PHPUnit_Framework_MockObject_MockObject */
private $l10nFactory;
@@ -93,7 +93,7 @@ class UsersControllerTest extends TestCase {
$this->accountManager = $this->createMock(AccountManager::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->mailer = $this->createMock(IMailer::class);
- $this->defaults = $this->createMock(\OC_Defaults::class);
+ $this->defaults = $this->createMock(Defaults::class);
$this->l10nFactory = $this->createMock(IFactory::class);
$this->newUserMailHelper = $this->createMock(NewUserMailHelper::class);
diff --git a/apps/theming/lib/Controller/IconController.php b/apps/theming/lib/Controller/IconController.php
index 7c4e209d0df..ddd1240fab8 100644
--- a/apps/theming/lib/Controller/IconController.php
+++ b/apps/theming/lib/Controller/IconController.php
@@ -24,19 +24,19 @@ namespace OCA\Theming\Controller;
use OCA\Theming\IconBuilder;
use OCA\Theming\ImageManager;
-use OCA\Theming\ThemingDefaults;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\Defaults;
use OCP\Files\NotFoundException;
use OCP\IRequest;
use OCA\Theming\Util;
use OCP\IConfig;
class IconController extends Controller {
- /** @var ThemingDefaults */
+ /** @var Defaults */
private $themingDefaults;
/** @var Util */
private $util;
@@ -54,7 +54,7 @@ class IconController extends Controller {
*
* @param string $appName
* @param IRequest $request
- * @param ThemingDefaults $themingDefaults
+ * @param Defaults $themingDefaults
* @param Util $util
* @param ITimeFactory $timeFactory
* @param IConfig $config
@@ -64,7 +64,7 @@ class IconController extends Controller {
public function __construct(
$appName,
IRequest $request,
- ThemingDefaults $themingDefaults,
+ Defaults $themingDefaults,
Util $util,
ITimeFactory $timeFactory,
IConfig $config,
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php
index d4dc56d3ba9..073410da2c3 100644
--- a/apps/theming/lib/ThemingDefaults.php
+++ b/apps/theming/lib/ThemingDefaults.php
@@ -138,11 +138,13 @@ class ThemingDefaults extends \OC_Defaults {
$logoExists = false;
}
+ $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
+
if(!$logo || !$logoExists) {
- return $this->urlGenerator->imagePath('core','logo.svg');
+ return $this->urlGenerator->imagePath('core','logo.svg') . '?v=' . $cacheBusterCounter;
}
- return $this->urlGenerator->linkToRoute('theming.Theming.getLogo');
+ return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter;
}
/**
@@ -191,15 +193,6 @@ class ThemingDefaults extends \OC_Defaults {
}
/**
- * Gets the current cache buster count
- *
- * @return string
- */
- public function getCacheBusterCounter() {
- return $this->config->getAppValue('theming', 'cachebuster', '0');
- }
-
- /**
* Increases the cache buster key
*/
private function increaseCacheBuster() {
diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php
index 591c1075492..ce053ff0eab 100644
--- a/apps/theming/tests/Controller/IconControllerTest.php
+++ b/apps/theming/tests/Controller/IconControllerTest.php
@@ -26,8 +26,8 @@ namespace OCA\Theming\Tests\Controller;
use OC\Files\SimpleFS\SimpleFile;
use OCA\Theming\ImageManager;
use OCP\AppFramework\Http;
-use OCP\AppFramework\Http\DataDisplayResponse;
use OCP\AppFramework\Http\NotFoundResponse;
+use OCP\Defaults;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IConfig;
@@ -41,7 +41,7 @@ use OCP\AppFramework\Http\FileDisplayResponse;
class IconControllerTest extends TestCase {
/** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */
private $request;
- /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Defaults|\PHPUnit_Framework_MockObject_MockObject */
private $themingDefaults;
/** @var Util */
private $util;
@@ -58,7 +58,7 @@ class IconControllerTest extends TestCase {
public function setUp() {
$this->request = $this->getMockBuilder('OCP\IRequest')->getMock();
- $this->themingDefaults = $this->getMockBuilder('OCA\Theming\ThemingDefaults')
+ $this->themingDefaults = $this->getMockBuilder('OCP\Defaults')
->disableOriginalConstructor()->getMock();
$this->util = $this->getMockBuilder('\OCA\Theming\Util')->disableOriginalConstructor()
->setMethods(['getAppImage', 'getAppIcon', 'elementColor'])->getMock();
diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php
index 986b2f34267..ad8f86f1c13 100644
--- a/apps/theming/tests/ThemingDefaultsTest.php
+++ b/apps/theming/tests/ThemingDefaultsTest.php
@@ -417,25 +417,35 @@ class ThemingDefaultsTest extends TestCase {
public function testGetLogoDefault() {
$this->config
- ->expects($this->once())
+ ->expects($this->at(0))
->method('getAppValue')
->with('theming', 'logoMime')
->willReturn('');
+ $this->config
+ ->expects($this->at(1))
+ ->method('getAppValue')
+ ->with('theming', 'cachebuster', '0')
+ ->willReturn('0');
$this->appData
->expects($this->once())
->method('getFolder')
->with('images')
->willThrowException(new \Exception());
- $expected = $this->urlGenerator->imagePath('core','logo.svg');
+ $expected = $this->urlGenerator->imagePath('core','logo.svg') . '?v=0';
$this->assertEquals($expected, $this->template->getLogo());
}
public function testGetLogoCustom() {
$this->config
- ->expects($this->once())
+ ->expects($this->at(0))
->method('getAppValue')
->with('theming', 'logoMime')
->willReturn('image/svg+xml');
+ $this->config
+ ->expects($this->at(1))
+ ->method('getAppValue')
+ ->with('theming', 'cachebuster', '0')
+ ->willReturn('0');
$simpleFolder = $this->createMock(ISimpleFolder::class);
$this->appData
->expects($this->once())
@@ -447,7 +457,7 @@ class ThemingDefaultsTest extends TestCase {
->method('getFile')
->with('logo')
->willReturn('');
- $expected = $this->urlGenerator->linkToRoute('theming.Theming.getLogo');
+ $expected = $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=0';
$this->assertEquals($expected, $this->template->getLogo());
}
}