diff options
author | Julius Härtl <jus@bitgrid.net> | 2017-09-11 16:03:47 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2017-09-12 10:22:57 +0300 |
commit | b49ab065b783b3ec041ca395739d747d20e2e187 (patch) | |
tree | daa0369e10cd7959258337d9048aac404711101a /apps/theming/lib/ThemingDefaults.php | |
parent | 88731848c609a454aa90a533e7361bca5f4e66b8 (diff) |
Move theming related imagePath logic to ThemingDefaults
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Diffstat (limited to 'apps/theming/lib/ThemingDefaults.php')
-rw-r--r-- | apps/theming/lib/ThemingDefaults.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 8200957edc0..0a9d5a6cc1f 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -249,6 +249,36 @@ class ThemingDefaults extends \OC_Defaults { } /** + * Check if the image should be replaced by the theming app + * and return the new image location then + * + * @param string $app name of the app + * @param string $image filename of the image + * @return bool|string false if image should not replaced, otherwise the location of the image + */ + public function replaceImagePath($app, $image) { + if($app==='') { + $app = 'core'; + } + $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); + + if ($image === 'favicon.ico' && $this->shouldReplaceIcons()) { + return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue; + } + if ($image === 'favicon-touch.png' && $this->shouldReplaceIcons()) { + return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue; + } + if ($image === 'manifest.json') { + $appPath = \OC_App::getAppPath($app); + if ($appPath && file_exists($appPath . '/img/manifest.json')) { + return false; + } + return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue; + } + return false; + } + + /** * Check if Imagemagick is enabled and if SVG is supported * otherwise we can't render custom icons * |