Prefer custom theme over theming app
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
d23bc9a99a
commit
ce5ad7e7f4
5 changed files with 78 additions and 43 deletions
|
@ -23,6 +23,13 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$app = new \OCP\AppFramework\App('theming');
|
||||||
|
/** @var \OCA\Theming\Util $util */
|
||||||
|
$util = $app->getContainer()->query(\OCA\Theming\Util::class);
|
||||||
|
if(!$util->isAlreadyThemed()) {
|
||||||
|
|
||||||
|
$app->getContainer()->registerCapability(\OCA\Theming\Capabilities::class);
|
||||||
|
|
||||||
$linkToCSS = \OC::$server->getURLGenerator()->linkToRoute(
|
$linkToCSS = \OC::$server->getURLGenerator()->linkToRoute(
|
||||||
'theming.Theming.getStylesheet',
|
'theming.Theming.getStylesheet',
|
||||||
[
|
[
|
||||||
|
@ -51,5 +58,4 @@ $linkToJs = \OC::$server->getURLGenerator()->linkToRoute(
|
||||||
], ''
|
], ''
|
||||||
);
|
);
|
||||||
|
|
||||||
$app = new \OCP\AppFramework\App('theming');
|
}
|
||||||
$app->getContainer()->registerCapability(\OCA\Theming\Capabilities::class);
|
|
|
@ -199,4 +199,17 @@ class Util {
|
||||||
return $svg;
|
return $svg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a custom theme is set in the server configuration
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isAlreadyThemed() {
|
||||||
|
$theme = $this->config->getSystemValue('theme', '');
|
||||||
|
if ($theme !== '') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,4 +180,24 @@ class UtilTest extends TestCase {
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testIsAlreadyThemedFalse() {
|
||||||
|
$theme = $this->config->getSystemValue('theme', '');
|
||||||
|
$this->config->expects($this->once())
|
||||||
|
->method('getSystemValue')
|
||||||
|
->with('theme', '')
|
||||||
|
->willReturn('');
|
||||||
|
$actual = $this->util->isAlreadyThemed();
|
||||||
|
$this->assertFalse($actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testIsAlreadyThemedTrue() {
|
||||||
|
$theme = $this->config->getSystemValue('theme', '');
|
||||||
|
$this->config->expects($this->once())
|
||||||
|
->method('getSystemValue')
|
||||||
|
->with('theme', '')
|
||||||
|
->willReturn('example');
|
||||||
|
$actual = $this->util->isAlreadyThemed();
|
||||||
|
$this->assertTrue($actual);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ OC.MimeType = {
|
||||||
path += icon;
|
path += icon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(OCA.Theming) {
|
if(OCA.Theming && gotIcon === null) {
|
||||||
path = OC.generateUrl('/apps/theming/img/core/filetypes/');
|
path = OC.generateUrl('/apps/theming/img/core/filetypes/');
|
||||||
path += OC.MimeType._getFile(mimeType, OC.MimeTypeList.files);
|
path += OC.MimeType._getFile(mimeType, OC.MimeTypeList.files);
|
||||||
gotIcon = true;
|
gotIcon = true;
|
||||||
|
|
|
@ -166,19 +166,7 @@ class URLGenerator implements IURLGenerator {
|
||||||
// Check if the app is in the app folder
|
// Check if the app is in the app folder
|
||||||
$path = '';
|
$path = '';
|
||||||
$themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming');
|
$themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming');
|
||||||
if($themingEnabled && $image === 'favicon.ico' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) {
|
if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) {
|
||||||
$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
|
|
||||||
if($app === '') { $app = 'core'; }
|
|
||||||
$path = $this->linkToRoute('theming.Icon.getFavicon', [ 'app' => $app ]) . '?v='. $cacheBusterValue;
|
|
||||||
} elseif($themingEnabled && $image === 'favicon-touch.png' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) {
|
|
||||||
$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
|
|
||||||
if($app === '') { $app = 'core'; }
|
|
||||||
$path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue;
|
|
||||||
} elseif($themingEnabled && $image === 'favicon-fb.png' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) {
|
|
||||||
$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
|
|
||||||
if($app === '') { $app = 'core'; }
|
|
||||||
$path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue;
|
|
||||||
} elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) {
|
|
||||||
$path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image";
|
$path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image";
|
||||||
} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg")
|
} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg")
|
||||||
&& file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) {
|
&& file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) {
|
||||||
|
@ -193,6 +181,14 @@ class URLGenerator implements IURLGenerator {
|
||||||
} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg")
|
} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg")
|
||||||
&& file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) {
|
&& file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) {
|
||||||
$path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
|
$path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
|
||||||
|
} elseif($themingEnabled && $image === "favicon.ico" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) {
|
||||||
|
$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
|
||||||
|
if($app==="") { $app = "core"; }
|
||||||
|
$path = $this->linkToRoute('theming.Icon.getFavicon', [ 'app' => $app ]) . '?v='. $cacheBusterValue;
|
||||||
|
} elseif($themingEnabled && $image === "favicon-touch.png" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) {
|
||||||
|
$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
|
||||||
|
if($app==="") { $app = "core"; }
|
||||||
|
$path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue;
|
||||||
} elseif ($appPath && file_exists($appPath . "/img/$image")) {
|
} elseif ($appPath && file_exists($appPath . "/img/$image")) {
|
||||||
$path = \OC_App::getAppWebPath($app) . "/img/$image";
|
$path = \OC_App::getAppWebPath($app) . "/img/$image";
|
||||||
} elseif ($appPath && !file_exists($appPath . "/img/$basename.svg")
|
} elseif ($appPath && !file_exists($appPath . "/img/$basename.svg")
|
||||||
|
|
Loading…
Reference in a new issue