@@ -42,203 +42,203 @@ |
||
42 | 42 | * Class to generate URLs |
43 | 43 | */ |
44 | 44 | class URLGenerator implements IURLGenerator { |
45 | - /** @var IConfig */ |
|
46 | - private $config; |
|
47 | - /** @var ICacheFactory */ |
|
48 | - private $cacheFactory; |
|
49 | - |
|
50 | - /** |
|
51 | - * @param IConfig $config |
|
52 | - * @param ICacheFactory $cacheFactory |
|
53 | - */ |
|
54 | - public function __construct(IConfig $config, |
|
55 | - ICacheFactory $cacheFactory) { |
|
56 | - $this->config = $config; |
|
57 | - $this->cacheFactory = $cacheFactory; |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Creates an url using a defined route |
|
62 | - * @param string $route |
|
63 | - * @param array $parameters args with param=>value, will be appended to the returned url |
|
64 | - * @return string the url |
|
65 | - * |
|
66 | - * Returns a url to the given route. |
|
67 | - */ |
|
68 | - public function linkToRoute($route, $parameters = array()) { |
|
69 | - // TODO: mock router |
|
70 | - $urlLinkTo = \OC::$server->getRouter()->generate($route, $parameters); |
|
71 | - return $urlLinkTo; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Creates an absolute url using a defined route |
|
76 | - * @param string $routeName |
|
77 | - * @param array $arguments args with param=>value, will be appended to the returned url |
|
78 | - * @return string the url |
|
79 | - * |
|
80 | - * Returns an absolute url to the given route. |
|
81 | - */ |
|
82 | - public function linkToRouteAbsolute($routeName, $arguments = array()) { |
|
83 | - return $this->getAbsoluteURL($this->linkToRoute($routeName, $arguments)); |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Creates an url |
|
88 | - * @param string $app app |
|
89 | - * @param string $file file |
|
90 | - * @param array $args array with param=>value, will be appended to the returned url |
|
91 | - * The value of $args will be urlencoded |
|
92 | - * @return string the url |
|
93 | - * |
|
94 | - * Returns a url to the given app and file. |
|
95 | - */ |
|
96 | - public function linkTo( $app, $file, $args = array() ) { |
|
97 | - $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); |
|
98 | - |
|
99 | - if( $app != '' ) { |
|
100 | - $app_path = \OC_App::getAppPath($app); |
|
101 | - // Check if the app is in the app folder |
|
102 | - if ($app_path && file_exists($app_path . '/' . $file)) { |
|
103 | - if (substr($file, -3) == 'php') { |
|
104 | - |
|
105 | - $urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app; |
|
106 | - if ($frontControllerActive) { |
|
107 | - $urlLinkTo = \OC::$WEBROOT . '/apps/' . $app; |
|
108 | - } |
|
109 | - $urlLinkTo .= ($file != 'index.php') ? '/' . $file : ''; |
|
110 | - } else { |
|
111 | - $urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file; |
|
112 | - } |
|
113 | - } else { |
|
114 | - $urlLinkTo = \OC::$WEBROOT . '/' . $app . '/' . $file; |
|
115 | - } |
|
116 | - } else { |
|
117 | - if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) { |
|
118 | - $urlLinkTo = \OC::$WEBROOT . '/core/' . $file; |
|
119 | - } else { |
|
120 | - if ($frontControllerActive && $file === 'index.php') { |
|
121 | - $urlLinkTo = \OC::$WEBROOT . '/'; |
|
122 | - } else { |
|
123 | - $urlLinkTo = \OC::$WEBROOT . '/' . $file; |
|
124 | - } |
|
125 | - } |
|
126 | - } |
|
127 | - |
|
128 | - if ($args && $query = http_build_query($args, '', '&')) { |
|
129 | - $urlLinkTo .= '?' . $query; |
|
130 | - } |
|
131 | - |
|
132 | - return $urlLinkTo; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Creates path to an image |
|
137 | - * @param string $app app |
|
138 | - * @param string $image image name |
|
139 | - * @throws \RuntimeException If the image does not exist |
|
140 | - * @return string the url |
|
141 | - * |
|
142 | - * Returns the path to the image. |
|
143 | - */ |
|
144 | - public function imagePath($app, $image) { |
|
145 | - $cache = $this->cacheFactory->create('imagePath'); |
|
146 | - $cacheKey = $app.'-'.$image; |
|
147 | - if($key = $cache->get($cacheKey)) { |
|
148 | - return $key; |
|
149 | - } |
|
150 | - |
|
151 | - // Read the selected theme from the config file |
|
152 | - $theme = \OC_Util::getTheme(); |
|
153 | - |
|
154 | - //if a theme has a png but not an svg always use the png |
|
155 | - $basename = substr(basename($image),0,-4); |
|
156 | - |
|
157 | - $appPath = \OC_App::getAppPath($app); |
|
158 | - |
|
159 | - // Check if the app is in the app folder |
|
160 | - $path = ''; |
|
161 | - $themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming'); |
|
162 | - if($themingEnabled && $image === 'favicon.ico' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
163 | - $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
164 | - if($app === '') { $app = 'core'; } |
|
165 | - $path = $this->linkToRoute('theming.Icon.getFavicon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; |
|
166 | - } elseif($themingEnabled && $image === 'favicon-touch.png' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
167 | - $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
168 | - if($app === '') { $app = 'core'; } |
|
169 | - $path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; |
|
170 | - } elseif($themingEnabled && $image === 'favicon-fb.png' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
171 | - $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
172 | - if($app === '') { $app = 'core'; } |
|
173 | - $path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; |
|
174 | - } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) { |
|
175 | - $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image"; |
|
176 | - } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg") |
|
177 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) { |
|
178 | - $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png"; |
|
179 | - } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) { |
|
180 | - $path = \OC::$WEBROOT . "/themes/$theme/$app/img/$image"; |
|
181 | - } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg") |
|
182 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) { |
|
183 | - $path = \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png"; |
|
184 | - } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) { |
|
185 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$image"; |
|
186 | - } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg") |
|
187 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) { |
|
188 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
189 | - } elseif ($appPath && file_exists($appPath . "/img/$image")) { |
|
190 | - $path = \OC_App::getAppWebPath($app) . "/img/$image"; |
|
191 | - } elseif ($appPath && !file_exists($appPath . "/img/$basename.svg") |
|
192 | - && file_exists($appPath . "/img/$basename.png")) { |
|
193 | - $path = \OC_App::getAppWebPath($app) . "/img/$basename.png"; |
|
194 | - } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) { |
|
195 | - $path = \OC::$WEBROOT . "/$app/img/$image"; |
|
196 | - } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg") |
|
197 | - && file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) { |
|
198 | - $path = \OC::$WEBROOT . "/$app/img/$basename.png"; |
|
199 | - } elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) { |
|
200 | - $path = \OC::$WEBROOT . "/core/img/$image"; |
|
201 | - } elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg") |
|
202 | - && file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) { |
|
203 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
204 | - } |
|
205 | - |
|
206 | - if($path !== '') { |
|
207 | - $cache->set($cacheKey, $path); |
|
208 | - return $path; |
|
209 | - } else { |
|
210 | - throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT); |
|
211 | - } |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * Makes an URL absolute |
|
217 | - * @param string $url the url in the ownCloud host |
|
218 | - * @return string the absolute version of the url |
|
219 | - */ |
|
220 | - public function getAbsoluteURL($url) { |
|
221 | - $separator = $url[0] === '/' ? '' : '/'; |
|
222 | - |
|
223 | - if (\OC::$CLI && !defined('PHPUNIT_RUN')) { |
|
224 | - return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/'); |
|
225 | - } |
|
226 | - |
|
227 | - // The ownCloud web root can already be prepended. |
|
228 | - $webRoot = substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT |
|
229 | - ? '' |
|
230 | - : \OC::$WEBROOT; |
|
231 | - |
|
232 | - $request = \OC::$server->getRequest(); |
|
233 | - return $request->getServerProtocol() . '://' . $request->getServerHost() . $webRoot . $separator . $url; |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * @param string $key |
|
238 | - * @return string url to the online documentation |
|
239 | - */ |
|
240 | - public function linkToDocs($key) { |
|
241 | - $theme = \OC::$server->getThemingDefaults(); |
|
242 | - return $theme->buildDocLinkToKey($key); |
|
243 | - } |
|
45 | + /** @var IConfig */ |
|
46 | + private $config; |
|
47 | + /** @var ICacheFactory */ |
|
48 | + private $cacheFactory; |
|
49 | + |
|
50 | + /** |
|
51 | + * @param IConfig $config |
|
52 | + * @param ICacheFactory $cacheFactory |
|
53 | + */ |
|
54 | + public function __construct(IConfig $config, |
|
55 | + ICacheFactory $cacheFactory) { |
|
56 | + $this->config = $config; |
|
57 | + $this->cacheFactory = $cacheFactory; |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Creates an url using a defined route |
|
62 | + * @param string $route |
|
63 | + * @param array $parameters args with param=>value, will be appended to the returned url |
|
64 | + * @return string the url |
|
65 | + * |
|
66 | + * Returns a url to the given route. |
|
67 | + */ |
|
68 | + public function linkToRoute($route, $parameters = array()) { |
|
69 | + // TODO: mock router |
|
70 | + $urlLinkTo = \OC::$server->getRouter()->generate($route, $parameters); |
|
71 | + return $urlLinkTo; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Creates an absolute url using a defined route |
|
76 | + * @param string $routeName |
|
77 | + * @param array $arguments args with param=>value, will be appended to the returned url |
|
78 | + * @return string the url |
|
79 | + * |
|
80 | + * Returns an absolute url to the given route. |
|
81 | + */ |
|
82 | + public function linkToRouteAbsolute($routeName, $arguments = array()) { |
|
83 | + return $this->getAbsoluteURL($this->linkToRoute($routeName, $arguments)); |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Creates an url |
|
88 | + * @param string $app app |
|
89 | + * @param string $file file |
|
90 | + * @param array $args array with param=>value, will be appended to the returned url |
|
91 | + * The value of $args will be urlencoded |
|
92 | + * @return string the url |
|
93 | + * |
|
94 | + * Returns a url to the given app and file. |
|
95 | + */ |
|
96 | + public function linkTo( $app, $file, $args = array() ) { |
|
97 | + $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); |
|
98 | + |
|
99 | + if( $app != '' ) { |
|
100 | + $app_path = \OC_App::getAppPath($app); |
|
101 | + // Check if the app is in the app folder |
|
102 | + if ($app_path && file_exists($app_path . '/' . $file)) { |
|
103 | + if (substr($file, -3) == 'php') { |
|
104 | + |
|
105 | + $urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app; |
|
106 | + if ($frontControllerActive) { |
|
107 | + $urlLinkTo = \OC::$WEBROOT . '/apps/' . $app; |
|
108 | + } |
|
109 | + $urlLinkTo .= ($file != 'index.php') ? '/' . $file : ''; |
|
110 | + } else { |
|
111 | + $urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file; |
|
112 | + } |
|
113 | + } else { |
|
114 | + $urlLinkTo = \OC::$WEBROOT . '/' . $app . '/' . $file; |
|
115 | + } |
|
116 | + } else { |
|
117 | + if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) { |
|
118 | + $urlLinkTo = \OC::$WEBROOT . '/core/' . $file; |
|
119 | + } else { |
|
120 | + if ($frontControllerActive && $file === 'index.php') { |
|
121 | + $urlLinkTo = \OC::$WEBROOT . '/'; |
|
122 | + } else { |
|
123 | + $urlLinkTo = \OC::$WEBROOT . '/' . $file; |
|
124 | + } |
|
125 | + } |
|
126 | + } |
|
127 | + |
|
128 | + if ($args && $query = http_build_query($args, '', '&')) { |
|
129 | + $urlLinkTo .= '?' . $query; |
|
130 | + } |
|
131 | + |
|
132 | + return $urlLinkTo; |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Creates path to an image |
|
137 | + * @param string $app app |
|
138 | + * @param string $image image name |
|
139 | + * @throws \RuntimeException If the image does not exist |
|
140 | + * @return string the url |
|
141 | + * |
|
142 | + * Returns the path to the image. |
|
143 | + */ |
|
144 | + public function imagePath($app, $image) { |
|
145 | + $cache = $this->cacheFactory->create('imagePath'); |
|
146 | + $cacheKey = $app.'-'.$image; |
|
147 | + if($key = $cache->get($cacheKey)) { |
|
148 | + return $key; |
|
149 | + } |
|
150 | + |
|
151 | + // Read the selected theme from the config file |
|
152 | + $theme = \OC_Util::getTheme(); |
|
153 | + |
|
154 | + //if a theme has a png but not an svg always use the png |
|
155 | + $basename = substr(basename($image),0,-4); |
|
156 | + |
|
157 | + $appPath = \OC_App::getAppPath($app); |
|
158 | + |
|
159 | + // Check if the app is in the app folder |
|
160 | + $path = ''; |
|
161 | + $themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming'); |
|
162 | + if($themingEnabled && $image === 'favicon.ico' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
163 | + $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
164 | + if($app === '') { $app = 'core'; } |
|
165 | + $path = $this->linkToRoute('theming.Icon.getFavicon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; |
|
166 | + } elseif($themingEnabled && $image === 'favicon-touch.png' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
167 | + $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
168 | + if($app === '') { $app = 'core'; } |
|
169 | + $path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; |
|
170 | + } elseif($themingEnabled && $image === 'favicon-fb.png' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
171 | + $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
172 | + if($app === '') { $app = 'core'; } |
|
173 | + $path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; |
|
174 | + } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) { |
|
175 | + $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image"; |
|
176 | + } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg") |
|
177 | + && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) { |
|
178 | + $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png"; |
|
179 | + } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) { |
|
180 | + $path = \OC::$WEBROOT . "/themes/$theme/$app/img/$image"; |
|
181 | + } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg") |
|
182 | + && file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) { |
|
183 | + $path = \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png"; |
|
184 | + } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) { |
|
185 | + $path = \OC::$WEBROOT . "/themes/$theme/core/img/$image"; |
|
186 | + } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg") |
|
187 | + && file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) { |
|
188 | + $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
189 | + } elseif ($appPath && file_exists($appPath . "/img/$image")) { |
|
190 | + $path = \OC_App::getAppWebPath($app) . "/img/$image"; |
|
191 | + } elseif ($appPath && !file_exists($appPath . "/img/$basename.svg") |
|
192 | + && file_exists($appPath . "/img/$basename.png")) { |
|
193 | + $path = \OC_App::getAppWebPath($app) . "/img/$basename.png"; |
|
194 | + } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) { |
|
195 | + $path = \OC::$WEBROOT . "/$app/img/$image"; |
|
196 | + } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg") |
|
197 | + && file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) { |
|
198 | + $path = \OC::$WEBROOT . "/$app/img/$basename.png"; |
|
199 | + } elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) { |
|
200 | + $path = \OC::$WEBROOT . "/core/img/$image"; |
|
201 | + } elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg") |
|
202 | + && file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) { |
|
203 | + $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
204 | + } |
|
205 | + |
|
206 | + if($path !== '') { |
|
207 | + $cache->set($cacheKey, $path); |
|
208 | + return $path; |
|
209 | + } else { |
|
210 | + throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT); |
|
211 | + } |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * Makes an URL absolute |
|
217 | + * @param string $url the url in the ownCloud host |
|
218 | + * @return string the absolute version of the url |
|
219 | + */ |
|
220 | + public function getAbsoluteURL($url) { |
|
221 | + $separator = $url[0] === '/' ? '' : '/'; |
|
222 | + |
|
223 | + if (\OC::$CLI && !defined('PHPUNIT_RUN')) { |
|
224 | + return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/'); |
|
225 | + } |
|
226 | + |
|
227 | + // The ownCloud web root can already be prepended. |
|
228 | + $webRoot = substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT |
|
229 | + ? '' |
|
230 | + : \OC::$WEBROOT; |
|
231 | + |
|
232 | + $request = \OC::$server->getRequest(); |
|
233 | + return $request->getServerProtocol() . '://' . $request->getServerHost() . $webRoot . $separator . $url; |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * @param string $key |
|
238 | + * @return string url to the online documentation |
|
239 | + */ |
|
240 | + public function linkToDocs($key) { |
|
241 | + $theme = \OC::$server->getThemingDefaults(); |
|
242 | + return $theme->buildDocLinkToKey($key); |
|
243 | + } |
|
244 | 244 | } |
@@ -93,40 +93,40 @@ discard block |
||
93 | 93 | * |
94 | 94 | * Returns a url to the given app and file. |
95 | 95 | */ |
96 | - public function linkTo( $app, $file, $args = array() ) { |
|
96 | + public function linkTo($app, $file, $args = array()) { |
|
97 | 97 | $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); |
98 | 98 | |
99 | - if( $app != '' ) { |
|
99 | + if ($app != '') { |
|
100 | 100 | $app_path = \OC_App::getAppPath($app); |
101 | 101 | // Check if the app is in the app folder |
102 | - if ($app_path && file_exists($app_path . '/' . $file)) { |
|
102 | + if ($app_path && file_exists($app_path.'/'.$file)) { |
|
103 | 103 | if (substr($file, -3) == 'php') { |
104 | 104 | |
105 | - $urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app; |
|
105 | + $urlLinkTo = \OC::$WEBROOT.'/index.php/apps/'.$app; |
|
106 | 106 | if ($frontControllerActive) { |
107 | - $urlLinkTo = \OC::$WEBROOT . '/apps/' . $app; |
|
107 | + $urlLinkTo = \OC::$WEBROOT.'/apps/'.$app; |
|
108 | 108 | } |
109 | - $urlLinkTo .= ($file != 'index.php') ? '/' . $file : ''; |
|
109 | + $urlLinkTo .= ($file != 'index.php') ? '/'.$file : ''; |
|
110 | 110 | } else { |
111 | - $urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file; |
|
111 | + $urlLinkTo = \OC_App::getAppWebPath($app).'/'.$file; |
|
112 | 112 | } |
113 | 113 | } else { |
114 | - $urlLinkTo = \OC::$WEBROOT . '/' . $app . '/' . $file; |
|
114 | + $urlLinkTo = \OC::$WEBROOT.'/'.$app.'/'.$file; |
|
115 | 115 | } |
116 | 116 | } else { |
117 | - if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) { |
|
118 | - $urlLinkTo = \OC::$WEBROOT . '/core/' . $file; |
|
117 | + if (file_exists(\OC::$SERVERROOT.'/core/'.$file)) { |
|
118 | + $urlLinkTo = \OC::$WEBROOT.'/core/'.$file; |
|
119 | 119 | } else { |
120 | 120 | if ($frontControllerActive && $file === 'index.php') { |
121 | - $urlLinkTo = \OC::$WEBROOT . '/'; |
|
121 | + $urlLinkTo = \OC::$WEBROOT.'/'; |
|
122 | 122 | } else { |
123 | - $urlLinkTo = \OC::$WEBROOT . '/' . $file; |
|
123 | + $urlLinkTo = \OC::$WEBROOT.'/'.$file; |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | 128 | if ($args && $query = http_build_query($args, '', '&')) { |
129 | - $urlLinkTo .= '?' . $query; |
|
129 | + $urlLinkTo .= '?'.$query; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | return $urlLinkTo; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | public function imagePath($app, $image) { |
145 | 145 | $cache = $this->cacheFactory->create('imagePath'); |
146 | 146 | $cacheKey = $app.'-'.$image; |
147 | - if($key = $cache->get($cacheKey)) { |
|
147 | + if ($key = $cache->get($cacheKey)) { |
|
148 | 148 | return $key; |
149 | 149 | } |
150 | 150 | |
@@ -152,62 +152,62 @@ discard block |
||
152 | 152 | $theme = \OC_Util::getTheme(); |
153 | 153 | |
154 | 154 | //if a theme has a png but not an svg always use the png |
155 | - $basename = substr(basename($image),0,-4); |
|
155 | + $basename = substr(basename($image), 0, -4); |
|
156 | 156 | |
157 | 157 | $appPath = \OC_App::getAppPath($app); |
158 | 158 | |
159 | 159 | // Check if the app is in the app folder |
160 | 160 | $path = ''; |
161 | 161 | $themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming'); |
162 | - if($themingEnabled && $image === 'favicon.ico' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
162 | + if ($themingEnabled && $image === 'favicon.ico' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
163 | 163 | $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
164 | - if($app === '') { $app = 'core'; } |
|
165 | - $path = $this->linkToRoute('theming.Icon.getFavicon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; |
|
166 | - } elseif($themingEnabled && $image === 'favicon-touch.png' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
164 | + if ($app === '') { $app = 'core'; } |
|
165 | + $path = $this->linkToRoute('theming.Icon.getFavicon', ['app' => $app]).'?v='.$cacheBusterValue; |
|
166 | + } elseif ($themingEnabled && $image === 'favicon-touch.png' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
167 | 167 | $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
168 | - if($app === '') { $app = 'core'; } |
|
169 | - $path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; |
|
170 | - } elseif($themingEnabled && $image === 'favicon-fb.png' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
168 | + if ($app === '') { $app = 'core'; } |
|
169 | + $path = $this->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]).'?v='.$cacheBusterValue; |
|
170 | + } elseif ($themingEnabled && $image === 'favicon-fb.png' && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
171 | 171 | $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
172 | - if($app === '') { $app = 'core'; } |
|
173 | - $path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; |
|
174 | - } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) { |
|
175 | - $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image"; |
|
176 | - } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg") |
|
177 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) { |
|
178 | - $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png"; |
|
179 | - } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) { |
|
180 | - $path = \OC::$WEBROOT . "/themes/$theme/$app/img/$image"; |
|
181 | - } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg") |
|
182 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) { |
|
183 | - $path = \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png"; |
|
184 | - } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) { |
|
185 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$image"; |
|
186 | - } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg") |
|
187 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) { |
|
188 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
189 | - } elseif ($appPath && file_exists($appPath . "/img/$image")) { |
|
190 | - $path = \OC_App::getAppWebPath($app) . "/img/$image"; |
|
191 | - } elseif ($appPath && !file_exists($appPath . "/img/$basename.svg") |
|
192 | - && file_exists($appPath . "/img/$basename.png")) { |
|
193 | - $path = \OC_App::getAppWebPath($app) . "/img/$basename.png"; |
|
194 | - } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) { |
|
195 | - $path = \OC::$WEBROOT . "/$app/img/$image"; |
|
196 | - } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg") |
|
197 | - && file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) { |
|
198 | - $path = \OC::$WEBROOT . "/$app/img/$basename.png"; |
|
199 | - } elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) { |
|
200 | - $path = \OC::$WEBROOT . "/core/img/$image"; |
|
201 | - } elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg") |
|
202 | - && file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) { |
|
203 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
172 | + if ($app === '') { $app = 'core'; } |
|
173 | + $path = $this->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]).'?v='.$cacheBusterValue; |
|
174 | + } elseif (file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$image")) { |
|
175 | + $path = \OC::$WEBROOT."/themes/$theme/apps/$app/img/$image"; |
|
176 | + } elseif (!file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$basename.svg") |
|
177 | + && file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$basename.png")) { |
|
178 | + $path = \OC::$WEBROOT."/themes/$theme/apps/$app/img/$basename.png"; |
|
179 | + } elseif (!empty($app) and file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$image")) { |
|
180 | + $path = \OC::$WEBROOT."/themes/$theme/$app/img/$image"; |
|
181 | + } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$basename.svg") |
|
182 | + && file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$basename.png"))) { |
|
183 | + $path = \OC::$WEBROOT."/themes/$theme/$app/img/$basename.png"; |
|
184 | + } elseif (file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$image")) { |
|
185 | + $path = \OC::$WEBROOT."/themes/$theme/core/img/$image"; |
|
186 | + } elseif (!file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$basename.svg") |
|
187 | + && file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$basename.png")) { |
|
188 | + $path = \OC::$WEBROOT."/themes/$theme/core/img/$basename.png"; |
|
189 | + } elseif ($appPath && file_exists($appPath."/img/$image")) { |
|
190 | + $path = \OC_App::getAppWebPath($app)."/img/$image"; |
|
191 | + } elseif ($appPath && !file_exists($appPath."/img/$basename.svg") |
|
192 | + && file_exists($appPath."/img/$basename.png")) { |
|
193 | + $path = \OC_App::getAppWebPath($app)."/img/$basename.png"; |
|
194 | + } elseif (!empty($app) and file_exists(\OC::$SERVERROOT."/$app/img/$image")) { |
|
195 | + $path = \OC::$WEBROOT."/$app/img/$image"; |
|
196 | + } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT."/$app/img/$basename.svg") |
|
197 | + && file_exists(\OC::$SERVERROOT."/$app/img/$basename.png"))) { |
|
198 | + $path = \OC::$WEBROOT."/$app/img/$basename.png"; |
|
199 | + } elseif (file_exists(\OC::$SERVERROOT."/core/img/$image")) { |
|
200 | + $path = \OC::$WEBROOT."/core/img/$image"; |
|
201 | + } elseif (!file_exists(\OC::$SERVERROOT."/core/img/$basename.svg") |
|
202 | + && file_exists(\OC::$SERVERROOT."/core/img/$basename.png")) { |
|
203 | + $path = \OC::$WEBROOT."/themes/$theme/core/img/$basename.png"; |
|
204 | 204 | } |
205 | 205 | |
206 | - if($path !== '') { |
|
206 | + if ($path !== '') { |
|
207 | 207 | $cache->set($cacheKey, $path); |
208 | 208 | return $path; |
209 | 209 | } else { |
210 | - throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT); |
|
210 | + throw new RuntimeException('image not found: image:'.$image.' webroot:'.\OC::$WEBROOT.' serverroot:'.\OC::$SERVERROOT); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $separator = $url[0] === '/' ? '' : '/'; |
222 | 222 | |
223 | 223 | if (\OC::$CLI && !defined('PHPUNIT_RUN')) { |
224 | - return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/'); |
|
224 | + return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/').'/'.ltrim($url, '/'); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // The ownCloud web root can already be prepended. |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | : \OC::$WEBROOT; |
231 | 231 | |
232 | 232 | $request = \OC::$server->getRequest(); |
233 | - return $request->getServerProtocol() . '://' . $request->getServerHost() . $webRoot . $separator . $url; |
|
233 | + return $request->getServerProtocol().'://'.$request->getServerHost().$webRoot.$separator.$url; |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |