@@ -26,7 +26,7 @@ |
||
26 | 26 | $app = new \OCP\AppFramework\App('theming'); |
27 | 27 | /** @var \OCA\Theming\Util $util */ |
28 | 28 | $util = $app->getContainer()->query(\OCA\Theming\Util::class); |
29 | -if(!$util->isAlreadyThemed()) { |
|
29 | +if (!$util->isAlreadyThemed()) { |
|
30 | 30 | |
31 | 31 | $app->getContainer()->registerCapability(\OCA\Theming\Capabilities::class); |
32 | 32 |
@@ -100,40 +100,40 @@ discard block |
||
100 | 100 | * |
101 | 101 | * Returns a url to the given app and file. |
102 | 102 | */ |
103 | - public function linkTo( $app, $file, $args = array() ) { |
|
103 | + public function linkTo($app, $file, $args = array()) { |
|
104 | 104 | $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); |
105 | 105 | |
106 | - if( $app != '' ) { |
|
106 | + if ($app != '') { |
|
107 | 107 | $app_path = \OC_App::getAppPath($app); |
108 | 108 | // Check if the app is in the app folder |
109 | - if ($app_path && file_exists($app_path . '/' . $file)) { |
|
109 | + if ($app_path && file_exists($app_path.'/'.$file)) { |
|
110 | 110 | if (substr($file, -3) == 'php') { |
111 | 111 | |
112 | - $urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app; |
|
112 | + $urlLinkTo = \OC::$WEBROOT.'/index.php/apps/'.$app; |
|
113 | 113 | if ($frontControllerActive) { |
114 | - $urlLinkTo = \OC::$WEBROOT . '/apps/' . $app; |
|
114 | + $urlLinkTo = \OC::$WEBROOT.'/apps/'.$app; |
|
115 | 115 | } |
116 | - $urlLinkTo .= ($file != 'index.php') ? '/' . $file : ''; |
|
116 | + $urlLinkTo .= ($file != 'index.php') ? '/'.$file : ''; |
|
117 | 117 | } else { |
118 | - $urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file; |
|
118 | + $urlLinkTo = \OC_App::getAppWebPath($app).'/'.$file; |
|
119 | 119 | } |
120 | 120 | } else { |
121 | - $urlLinkTo = \OC::$WEBROOT . '/' . $app . '/' . $file; |
|
121 | + $urlLinkTo = \OC::$WEBROOT.'/'.$app.'/'.$file; |
|
122 | 122 | } |
123 | 123 | } else { |
124 | - if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) { |
|
125 | - $urlLinkTo = \OC::$WEBROOT . '/core/' . $file; |
|
124 | + if (file_exists(\OC::$SERVERROOT.'/core/'.$file)) { |
|
125 | + $urlLinkTo = \OC::$WEBROOT.'/core/'.$file; |
|
126 | 126 | } else { |
127 | 127 | if ($frontControllerActive && $file === 'index.php') { |
128 | - $urlLinkTo = \OC::$WEBROOT . '/'; |
|
128 | + $urlLinkTo = \OC::$WEBROOT.'/'; |
|
129 | 129 | } else { |
130 | - $urlLinkTo = \OC::$WEBROOT . '/' . $file; |
|
130 | + $urlLinkTo = \OC::$WEBROOT.'/'.$file; |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | 135 | if ($args && $query = http_build_query($args, '', '&')) { |
136 | - $urlLinkTo .= '?' . $query; |
|
136 | + $urlLinkTo .= '?'.$query; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | return $urlLinkTo; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | public function imagePath($app, $image) { |
152 | 152 | $cache = $this->cacheFactory->create('imagePath-'.md5($this->getBaseUrl()).'-'); |
153 | 153 | $cacheKey = $app.'-'.$image; |
154 | - if($key = $cache->get($cacheKey)) { |
|
154 | + if ($key = $cache->get($cacheKey)) { |
|
155 | 155 | return $key; |
156 | 156 | } |
157 | 157 | |
@@ -159,58 +159,58 @@ discard block |
||
159 | 159 | $theme = \OC_Util::getTheme(); |
160 | 160 | |
161 | 161 | //if a theme has a png but not an svg always use the png |
162 | - $basename = substr(basename($image),0,-4); |
|
162 | + $basename = substr(basename($image), 0, -4); |
|
163 | 163 | |
164 | 164 | $appPath = \OC_App::getAppPath($app); |
165 | 165 | |
166 | 166 | // Check if the app is in the app folder |
167 | 167 | $path = ''; |
168 | 168 | $themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming'); |
169 | - if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) { |
|
170 | - $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image"; |
|
171 | - } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg") |
|
172 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) { |
|
173 | - $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png"; |
|
174 | - } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) { |
|
175 | - $path = \OC::$WEBROOT . "/themes/$theme/$app/img/$image"; |
|
176 | - } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg") |
|
177 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) { |
|
178 | - $path = \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png"; |
|
179 | - } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) { |
|
180 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$image"; |
|
181 | - } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg") |
|
182 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) { |
|
183 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
184 | - } elseif($themingEnabled && $image === "favicon.ico" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
169 | + if (file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$image")) { |
|
170 | + $path = \OC::$WEBROOT."/themes/$theme/apps/$app/img/$image"; |
|
171 | + } elseif (!file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$basename.svg") |
|
172 | + && file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$basename.png")) { |
|
173 | + $path = \OC::$WEBROOT."/themes/$theme/apps/$app/img/$basename.png"; |
|
174 | + } elseif (!empty($app) and file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$image")) { |
|
175 | + $path = \OC::$WEBROOT."/themes/$theme/$app/img/$image"; |
|
176 | + } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$basename.svg") |
|
177 | + && file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$basename.png"))) { |
|
178 | + $path = \OC::$WEBROOT."/themes/$theme/$app/img/$basename.png"; |
|
179 | + } elseif (file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$image")) { |
|
180 | + $path = \OC::$WEBROOT."/themes/$theme/core/img/$image"; |
|
181 | + } elseif (!file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$basename.svg") |
|
182 | + && file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$basename.png")) { |
|
183 | + $path = \OC::$WEBROOT."/themes/$theme/core/img/$basename.png"; |
|
184 | + } elseif ($themingEnabled && $image === "favicon.ico" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
185 | 185 | $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
186 | - if($app==="") { $app = "core"; } |
|
187 | - $path = $this->linkToRoute('theming.Icon.getFavicon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; |
|
188 | - } elseif($themingEnabled && $image === "favicon-touch.png" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
186 | + if ($app === "") { $app = "core"; } |
|
187 | + $path = $this->linkToRoute('theming.Icon.getFavicon', ['app' => $app]).'?v='.$cacheBusterValue; |
|
188 | + } elseif ($themingEnabled && $image === "favicon-touch.png" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
189 | 189 | $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
190 | - if($app==="") { $app = "core"; } |
|
191 | - $path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; |
|
192 | - } elseif ($appPath && file_exists($appPath . "/img/$image")) { |
|
193 | - $path = \OC_App::getAppWebPath($app) . "/img/$image"; |
|
194 | - } elseif ($appPath && !file_exists($appPath . "/img/$basename.svg") |
|
195 | - && file_exists($appPath . "/img/$basename.png")) { |
|
196 | - $path = \OC_App::getAppWebPath($app) . "/img/$basename.png"; |
|
197 | - } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) { |
|
198 | - $path = \OC::$WEBROOT . "/$app/img/$image"; |
|
199 | - } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg") |
|
200 | - && file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) { |
|
201 | - $path = \OC::$WEBROOT . "/$app/img/$basename.png"; |
|
202 | - } elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) { |
|
203 | - $path = \OC::$WEBROOT . "/core/img/$image"; |
|
204 | - } elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg") |
|
205 | - && file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) { |
|
206 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
190 | + if ($app === "") { $app = "core"; } |
|
191 | + $path = $this->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]).'?v='.$cacheBusterValue; |
|
192 | + } elseif ($appPath && file_exists($appPath."/img/$image")) { |
|
193 | + $path = \OC_App::getAppWebPath($app)."/img/$image"; |
|
194 | + } elseif ($appPath && !file_exists($appPath."/img/$basename.svg") |
|
195 | + && file_exists($appPath."/img/$basename.png")) { |
|
196 | + $path = \OC_App::getAppWebPath($app)."/img/$basename.png"; |
|
197 | + } elseif (!empty($app) and file_exists(\OC::$SERVERROOT."/$app/img/$image")) { |
|
198 | + $path = \OC::$WEBROOT."/$app/img/$image"; |
|
199 | + } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT."/$app/img/$basename.svg") |
|
200 | + && file_exists(\OC::$SERVERROOT."/$app/img/$basename.png"))) { |
|
201 | + $path = \OC::$WEBROOT."/$app/img/$basename.png"; |
|
202 | + } elseif (file_exists(\OC::$SERVERROOT."/core/img/$image")) { |
|
203 | + $path = \OC::$WEBROOT."/core/img/$image"; |
|
204 | + } elseif (!file_exists(\OC::$SERVERROOT."/core/img/$basename.svg") |
|
205 | + && file_exists(\OC::$SERVERROOT."/core/img/$basename.png")) { |
|
206 | + $path = \OC::$WEBROOT."/themes/$theme/core/img/$basename.png"; |
|
207 | 207 | } |
208 | 208 | |
209 | - if($path !== '') { |
|
209 | + if ($path !== '') { |
|
210 | 210 | $cache->set($cacheKey, $path); |
211 | 211 | return $path; |
212 | 212 | } else { |
213 | - throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT); |
|
213 | + throw new RuntimeException('image not found: image:'.$image.' webroot:'.\OC::$WEBROOT.' serverroot:'.\OC::$SERVERROOT); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
@@ -224,14 +224,14 @@ discard block |
||
224 | 224 | $separator = $url[0] === '/' ? '' : '/'; |
225 | 225 | |
226 | 226 | if (\OC::$CLI && !defined('PHPUNIT_RUN')) { |
227 | - return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/'); |
|
227 | + return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/').'/'.ltrim($url, '/'); |
|
228 | 228 | } |
229 | 229 | // The ownCloud web root can already be prepended. |
230 | - if(substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT) { |
|
230 | + if (substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT) { |
|
231 | 231 | $url = substr($url, strlen(\OC::$WEBROOT)); |
232 | 232 | } |
233 | 233 | |
234 | - return $this->getBaseUrl() . $separator . $url; |
|
234 | + return $this->getBaseUrl().$separator.$url; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -247,6 +247,6 @@ discard block |
||
247 | 247 | * @return string base url of the current request |
248 | 248 | */ |
249 | 249 | public function getBaseUrl() { |
250 | - return $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT; |
|
250 | + return $this->request->getServerProtocol().'://'.$this->request->getServerHost().\OC::$WEBROOT; |
|
251 | 251 | } |
252 | 252 | } |