@@ -45,282 +45,282 @@ |
||
45 | 45 | |
46 | 46 | class TemplateLayout extends \OC_Template { |
47 | 47 | |
48 | - private static $versionHash = ''; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var \OCP\IConfig |
|
52 | - */ |
|
53 | - private $config; |
|
54 | - |
|
55 | - /** |
|
56 | - * @param string $renderAs |
|
57 | - * @param string $appId application id |
|
58 | - */ |
|
59 | - public function __construct( $renderAs, $appId = '' ) { |
|
60 | - |
|
61 | - // yes - should be injected .... |
|
62 | - $this->config = \OC::$server->getConfig(); |
|
63 | - |
|
64 | - |
|
65 | - // Decide which page we show |
|
66 | - if($renderAs == 'user') { |
|
67 | - parent::__construct( 'core', 'layout.user' ); |
|
68 | - if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
69 | - $this->assign('bodyid', 'body-settings'); |
|
70 | - }else{ |
|
71 | - $this->assign('bodyid', 'body-user'); |
|
72 | - } |
|
73 | - |
|
74 | - // Code integrity notification |
|
75 | - $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
|
76 | - if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
77 | - \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
|
78 | - } |
|
79 | - |
|
80 | - // Add navigation entry |
|
81 | - $this->assign( 'application', ''); |
|
82 | - $this->assign( 'appid', $appId ); |
|
83 | - $navigation = \OC_App::getNavigation(); |
|
84 | - $this->assign( 'navigation', $navigation); |
|
85 | - $settingsNavigation = \OC_App::getSettingsNavigation(); |
|
86 | - $this->assign( 'settingsnavigation', $settingsNavigation); |
|
87 | - foreach($navigation as $entry) { |
|
88 | - if ($entry['active']) { |
|
89 | - $this->assign( 'application', $entry['name'] ); |
|
90 | - break; |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - foreach($settingsNavigation as $entry) { |
|
95 | - if ($entry['active']) { |
|
96 | - $this->assign( 'application', $entry['name'] ); |
|
97 | - break; |
|
98 | - } |
|
99 | - } |
|
100 | - $userDisplayName = \OC_User::getDisplayName(); |
|
101 | - $this->assign('user_displayname', $userDisplayName); |
|
102 | - $this->assign('user_uid', \OC_User::getUser()); |
|
103 | - |
|
104 | - if (\OC_User::getUser() === false) { |
|
105 | - $this->assign('userAvatarSet', false); |
|
106 | - } else { |
|
107 | - $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
108 | - $this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
109 | - } |
|
110 | - |
|
111 | - // check if app menu icons should be inverted |
|
112 | - try { |
|
113 | - /** @var \OCA\Theming\Util $util */ |
|
114 | - $util = \OC::$server->query(\OCA\Theming\Util::class); |
|
115 | - $this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary())); |
|
116 | - } catch (\OCP\AppFramework\QueryException $e) { |
|
117 | - $this->assign('themingInvertMenu', false); |
|
118 | - } |
|
119 | - |
|
120 | - } else if ($renderAs == 'error') { |
|
121 | - parent::__construct('core', 'layout.guest', '', false); |
|
122 | - $this->assign('bodyid', 'body-login'); |
|
123 | - } else if ($renderAs == 'guest') { |
|
124 | - parent::__construct('core', 'layout.guest'); |
|
125 | - $this->assign('bodyid', 'body-login'); |
|
126 | - } else { |
|
127 | - parent::__construct('core', 'layout.base'); |
|
128 | - |
|
129 | - } |
|
130 | - // Send the language to our layouts |
|
131 | - $this->assign('language', \OC::$server->getL10NFactory()->findLanguage()); |
|
132 | - |
|
133 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
134 | - if (empty(self::$versionHash)) { |
|
135 | - $v = \OC_App::getAppVersions(); |
|
136 | - $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
137 | - self::$versionHash = substr(md5(implode(',', $v)), 0, 8); |
|
138 | - } |
|
139 | - } else { |
|
140 | - self::$versionHash = md5('not installed'); |
|
141 | - } |
|
142 | - |
|
143 | - // Add the js files |
|
144 | - $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
145 | - $this->assign('jsfiles', array()); |
|
146 | - if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
147 | - if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
148 | - $jsConfigHelper = new JSConfigHelper( |
|
149 | - \OC::$server->getL10N('core'), |
|
150 | - \OC::$server->query(Defaults::class), |
|
151 | - \OC::$server->getAppManager(), |
|
152 | - \OC::$server->getSession(), |
|
153 | - \OC::$server->getUserSession()->getUser(), |
|
154 | - $this->config, |
|
155 | - \OC::$server->getGroupManager(), |
|
156 | - \OC::$server->getIniWrapper(), |
|
157 | - \OC::$server->getURLGenerator() |
|
158 | - ); |
|
159 | - $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
160 | - } else { |
|
161 | - $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
162 | - } |
|
163 | - } |
|
164 | - foreach($jsFiles as $info) { |
|
165 | - $web = $info[1]; |
|
166 | - $file = $info[2]; |
|
167 | - $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
168 | - } |
|
169 | - |
|
170 | - try { |
|
171 | - $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
172 | - } catch (\Exception $e) { |
|
173 | - $pathInfo = ''; |
|
174 | - } |
|
175 | - |
|
176 | - // Do not initialise scss appdata until we have a fully installed instance |
|
177 | - // Do not load scss for update, errors, installation or login page |
|
178 | - if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
179 | - && !\OCP\Util::needUpgrade() |
|
180 | - && $pathInfo !== '' |
|
181 | - && !preg_match('/^\/login/', $pathInfo)) { |
|
182 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
183 | - } else { |
|
184 | - // If we ignore the scss compiler, |
|
185 | - // we need to load the guest css fallback |
|
186 | - \OC_Util::addStyle('guest'); |
|
187 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
188 | - } |
|
189 | - |
|
190 | - $this->assign('cssfiles', array()); |
|
191 | - $this->assign('printcssfiles', []); |
|
192 | - $this->assign('versionHash', self::$versionHash); |
|
193 | - foreach($cssFiles as $info) { |
|
194 | - $web = $info[1]; |
|
195 | - $file = $info[2]; |
|
196 | - |
|
197 | - if (substr($file, -strlen('print.css')) === 'print.css') { |
|
198 | - $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
199 | - } else { |
|
200 | - $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file) ); |
|
201 | - } |
|
202 | - } |
|
203 | - } |
|
204 | - |
|
205 | - /** |
|
206 | - * @param string $path |
|
207 | - * @param string $file |
|
208 | - * @return string |
|
209 | - */ |
|
210 | - protected function getVersionHashSuffix($path = false, $file = false) { |
|
211 | - if ($this->config->getSystemValue('debug', false)) { |
|
212 | - // allows chrome workspace mapping in debug mode |
|
213 | - return ""; |
|
214 | - } |
|
215 | - $themingSuffix = ''; |
|
216 | - $v = []; |
|
217 | - |
|
218 | - if ($this->config->getSystemValue('installed', false)) { |
|
219 | - if (\OC::$server->getAppManager()->isInstalled('theming')) { |
|
220 | - $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
221 | - } |
|
222 | - $v = \OC_App::getAppVersions(); |
|
223 | - } |
|
224 | - |
|
225 | - // Try the webroot path for a match |
|
226 | - if ($path !== false && $path !== '') { |
|
227 | - $appName = $this->getAppNamefromPath($path); |
|
228 | - if(array_key_exists($appName, $v)) { |
|
229 | - $appVersion = $v[$appName]; |
|
230 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
231 | - } |
|
232 | - } |
|
233 | - // fallback to the file path instead |
|
234 | - if ($file !== false && $file !== '') { |
|
235 | - $appName = $this->getAppNamefromPath($file); |
|
236 | - if(array_key_exists($appName, $v)) { |
|
237 | - $appVersion = $v[$appName]; |
|
238 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
239 | - } |
|
240 | - } |
|
241 | - |
|
242 | - return '?v=' . self::$versionHash . $themingSuffix; |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * @param array $styles |
|
247 | - * @return array |
|
248 | - */ |
|
249 | - static public function findStylesheetFiles($styles, $compileScss = true) { |
|
250 | - // Read the selected theme from the config file |
|
251 | - $theme = \OC_Util::getTheme(); |
|
252 | - |
|
253 | - if($compileScss) { |
|
254 | - $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
|
255 | - } else { |
|
256 | - $SCSSCacher = null; |
|
257 | - } |
|
258 | - |
|
259 | - $locator = new \OC\Template\CSSResourceLocator( |
|
260 | - \OC::$server->getLogger(), |
|
261 | - $theme, |
|
262 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
263 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
264 | - $SCSSCacher |
|
265 | - ); |
|
266 | - $locator->find($styles); |
|
267 | - return $locator->getResources(); |
|
268 | - } |
|
269 | - |
|
270 | - /** |
|
271 | - * @param string $path |
|
272 | - * @return string|boolean |
|
273 | - */ |
|
274 | - public function getAppNamefromPath($path) { |
|
275 | - if ($path !== '' && is_string($path)) { |
|
276 | - $pathParts = explode('/', $path); |
|
277 | - if ($pathParts[0] === 'css') { |
|
278 | - // This is a scss request |
|
279 | - return $pathParts[1]; |
|
280 | - } |
|
281 | - return end($pathParts); |
|
282 | - } |
|
283 | - return false; |
|
284 | - |
|
285 | - } |
|
286 | - |
|
287 | - /** |
|
288 | - * @param array $scripts |
|
289 | - * @return array |
|
290 | - */ |
|
291 | - static public function findJavascriptFiles($scripts) { |
|
292 | - // Read the selected theme from the config file |
|
293 | - $theme = \OC_Util::getTheme(); |
|
294 | - |
|
295 | - $locator = new \OC\Template\JSResourceLocator( |
|
296 | - \OC::$server->getLogger(), |
|
297 | - $theme, |
|
298 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
299 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
300 | - new JSCombiner( |
|
301 | - \OC::$server->getAppDataDir('js'), |
|
302 | - \OC::$server->getURLGenerator(), |
|
303 | - \OC::$server->getMemCacheFactory()->createDistributed('JS'), |
|
304 | - \OC::$server->getSystemConfig(), |
|
305 | - \OC::$server->getLogger() |
|
306 | - ) |
|
307 | - ); |
|
308 | - $locator->find($scripts); |
|
309 | - return $locator->getResources(); |
|
310 | - } |
|
311 | - |
|
312 | - /** |
|
313 | - * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
314 | - * @param string $filePath Absolute path |
|
315 | - * @return string Relative path |
|
316 | - * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
317 | - */ |
|
318 | - public static function convertToRelativePath($filePath) { |
|
319 | - $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
320 | - if(count($relativePath) !== 2) { |
|
321 | - throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
322 | - } |
|
323 | - |
|
324 | - return $relativePath[1]; |
|
325 | - } |
|
48 | + private static $versionHash = ''; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var \OCP\IConfig |
|
52 | + */ |
|
53 | + private $config; |
|
54 | + |
|
55 | + /** |
|
56 | + * @param string $renderAs |
|
57 | + * @param string $appId application id |
|
58 | + */ |
|
59 | + public function __construct( $renderAs, $appId = '' ) { |
|
60 | + |
|
61 | + // yes - should be injected .... |
|
62 | + $this->config = \OC::$server->getConfig(); |
|
63 | + |
|
64 | + |
|
65 | + // Decide which page we show |
|
66 | + if($renderAs == 'user') { |
|
67 | + parent::__construct( 'core', 'layout.user' ); |
|
68 | + if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
69 | + $this->assign('bodyid', 'body-settings'); |
|
70 | + }else{ |
|
71 | + $this->assign('bodyid', 'body-user'); |
|
72 | + } |
|
73 | + |
|
74 | + // Code integrity notification |
|
75 | + $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
|
76 | + if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
77 | + \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
|
78 | + } |
|
79 | + |
|
80 | + // Add navigation entry |
|
81 | + $this->assign( 'application', ''); |
|
82 | + $this->assign( 'appid', $appId ); |
|
83 | + $navigation = \OC_App::getNavigation(); |
|
84 | + $this->assign( 'navigation', $navigation); |
|
85 | + $settingsNavigation = \OC_App::getSettingsNavigation(); |
|
86 | + $this->assign( 'settingsnavigation', $settingsNavigation); |
|
87 | + foreach($navigation as $entry) { |
|
88 | + if ($entry['active']) { |
|
89 | + $this->assign( 'application', $entry['name'] ); |
|
90 | + break; |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + foreach($settingsNavigation as $entry) { |
|
95 | + if ($entry['active']) { |
|
96 | + $this->assign( 'application', $entry['name'] ); |
|
97 | + break; |
|
98 | + } |
|
99 | + } |
|
100 | + $userDisplayName = \OC_User::getDisplayName(); |
|
101 | + $this->assign('user_displayname', $userDisplayName); |
|
102 | + $this->assign('user_uid', \OC_User::getUser()); |
|
103 | + |
|
104 | + if (\OC_User::getUser() === false) { |
|
105 | + $this->assign('userAvatarSet', false); |
|
106 | + } else { |
|
107 | + $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
108 | + $this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
109 | + } |
|
110 | + |
|
111 | + // check if app menu icons should be inverted |
|
112 | + try { |
|
113 | + /** @var \OCA\Theming\Util $util */ |
|
114 | + $util = \OC::$server->query(\OCA\Theming\Util::class); |
|
115 | + $this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary())); |
|
116 | + } catch (\OCP\AppFramework\QueryException $e) { |
|
117 | + $this->assign('themingInvertMenu', false); |
|
118 | + } |
|
119 | + |
|
120 | + } else if ($renderAs == 'error') { |
|
121 | + parent::__construct('core', 'layout.guest', '', false); |
|
122 | + $this->assign('bodyid', 'body-login'); |
|
123 | + } else if ($renderAs == 'guest') { |
|
124 | + parent::__construct('core', 'layout.guest'); |
|
125 | + $this->assign('bodyid', 'body-login'); |
|
126 | + } else { |
|
127 | + parent::__construct('core', 'layout.base'); |
|
128 | + |
|
129 | + } |
|
130 | + // Send the language to our layouts |
|
131 | + $this->assign('language', \OC::$server->getL10NFactory()->findLanguage()); |
|
132 | + |
|
133 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
134 | + if (empty(self::$versionHash)) { |
|
135 | + $v = \OC_App::getAppVersions(); |
|
136 | + $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
137 | + self::$versionHash = substr(md5(implode(',', $v)), 0, 8); |
|
138 | + } |
|
139 | + } else { |
|
140 | + self::$versionHash = md5('not installed'); |
|
141 | + } |
|
142 | + |
|
143 | + // Add the js files |
|
144 | + $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
145 | + $this->assign('jsfiles', array()); |
|
146 | + if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
147 | + if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
148 | + $jsConfigHelper = new JSConfigHelper( |
|
149 | + \OC::$server->getL10N('core'), |
|
150 | + \OC::$server->query(Defaults::class), |
|
151 | + \OC::$server->getAppManager(), |
|
152 | + \OC::$server->getSession(), |
|
153 | + \OC::$server->getUserSession()->getUser(), |
|
154 | + $this->config, |
|
155 | + \OC::$server->getGroupManager(), |
|
156 | + \OC::$server->getIniWrapper(), |
|
157 | + \OC::$server->getURLGenerator() |
|
158 | + ); |
|
159 | + $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
160 | + } else { |
|
161 | + $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
162 | + } |
|
163 | + } |
|
164 | + foreach($jsFiles as $info) { |
|
165 | + $web = $info[1]; |
|
166 | + $file = $info[2]; |
|
167 | + $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
168 | + } |
|
169 | + |
|
170 | + try { |
|
171 | + $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
172 | + } catch (\Exception $e) { |
|
173 | + $pathInfo = ''; |
|
174 | + } |
|
175 | + |
|
176 | + // Do not initialise scss appdata until we have a fully installed instance |
|
177 | + // Do not load scss for update, errors, installation or login page |
|
178 | + if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
179 | + && !\OCP\Util::needUpgrade() |
|
180 | + && $pathInfo !== '' |
|
181 | + && !preg_match('/^\/login/', $pathInfo)) { |
|
182 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
183 | + } else { |
|
184 | + // If we ignore the scss compiler, |
|
185 | + // we need to load the guest css fallback |
|
186 | + \OC_Util::addStyle('guest'); |
|
187 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
188 | + } |
|
189 | + |
|
190 | + $this->assign('cssfiles', array()); |
|
191 | + $this->assign('printcssfiles', []); |
|
192 | + $this->assign('versionHash', self::$versionHash); |
|
193 | + foreach($cssFiles as $info) { |
|
194 | + $web = $info[1]; |
|
195 | + $file = $info[2]; |
|
196 | + |
|
197 | + if (substr($file, -strlen('print.css')) === 'print.css') { |
|
198 | + $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
199 | + } else { |
|
200 | + $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file) ); |
|
201 | + } |
|
202 | + } |
|
203 | + } |
|
204 | + |
|
205 | + /** |
|
206 | + * @param string $path |
|
207 | + * @param string $file |
|
208 | + * @return string |
|
209 | + */ |
|
210 | + protected function getVersionHashSuffix($path = false, $file = false) { |
|
211 | + if ($this->config->getSystemValue('debug', false)) { |
|
212 | + // allows chrome workspace mapping in debug mode |
|
213 | + return ""; |
|
214 | + } |
|
215 | + $themingSuffix = ''; |
|
216 | + $v = []; |
|
217 | + |
|
218 | + if ($this->config->getSystemValue('installed', false)) { |
|
219 | + if (\OC::$server->getAppManager()->isInstalled('theming')) { |
|
220 | + $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
221 | + } |
|
222 | + $v = \OC_App::getAppVersions(); |
|
223 | + } |
|
224 | + |
|
225 | + // Try the webroot path for a match |
|
226 | + if ($path !== false && $path !== '') { |
|
227 | + $appName = $this->getAppNamefromPath($path); |
|
228 | + if(array_key_exists($appName, $v)) { |
|
229 | + $appVersion = $v[$appName]; |
|
230 | + return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
231 | + } |
|
232 | + } |
|
233 | + // fallback to the file path instead |
|
234 | + if ($file !== false && $file !== '') { |
|
235 | + $appName = $this->getAppNamefromPath($file); |
|
236 | + if(array_key_exists($appName, $v)) { |
|
237 | + $appVersion = $v[$appName]; |
|
238 | + return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
239 | + } |
|
240 | + } |
|
241 | + |
|
242 | + return '?v=' . self::$versionHash . $themingSuffix; |
|
243 | + } |
|
244 | + |
|
245 | + /** |
|
246 | + * @param array $styles |
|
247 | + * @return array |
|
248 | + */ |
|
249 | + static public function findStylesheetFiles($styles, $compileScss = true) { |
|
250 | + // Read the selected theme from the config file |
|
251 | + $theme = \OC_Util::getTheme(); |
|
252 | + |
|
253 | + if($compileScss) { |
|
254 | + $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
|
255 | + } else { |
|
256 | + $SCSSCacher = null; |
|
257 | + } |
|
258 | + |
|
259 | + $locator = new \OC\Template\CSSResourceLocator( |
|
260 | + \OC::$server->getLogger(), |
|
261 | + $theme, |
|
262 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
263 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
264 | + $SCSSCacher |
|
265 | + ); |
|
266 | + $locator->find($styles); |
|
267 | + return $locator->getResources(); |
|
268 | + } |
|
269 | + |
|
270 | + /** |
|
271 | + * @param string $path |
|
272 | + * @return string|boolean |
|
273 | + */ |
|
274 | + public function getAppNamefromPath($path) { |
|
275 | + if ($path !== '' && is_string($path)) { |
|
276 | + $pathParts = explode('/', $path); |
|
277 | + if ($pathParts[0] === 'css') { |
|
278 | + // This is a scss request |
|
279 | + return $pathParts[1]; |
|
280 | + } |
|
281 | + return end($pathParts); |
|
282 | + } |
|
283 | + return false; |
|
284 | + |
|
285 | + } |
|
286 | + |
|
287 | + /** |
|
288 | + * @param array $scripts |
|
289 | + * @return array |
|
290 | + */ |
|
291 | + static public function findJavascriptFiles($scripts) { |
|
292 | + // Read the selected theme from the config file |
|
293 | + $theme = \OC_Util::getTheme(); |
|
294 | + |
|
295 | + $locator = new \OC\Template\JSResourceLocator( |
|
296 | + \OC::$server->getLogger(), |
|
297 | + $theme, |
|
298 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
299 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
300 | + new JSCombiner( |
|
301 | + \OC::$server->getAppDataDir('js'), |
|
302 | + \OC::$server->getURLGenerator(), |
|
303 | + \OC::$server->getMemCacheFactory()->createDistributed('JS'), |
|
304 | + \OC::$server->getSystemConfig(), |
|
305 | + \OC::$server->getLogger() |
|
306 | + ) |
|
307 | + ); |
|
308 | + $locator->find($scripts); |
|
309 | + return $locator->getResources(); |
|
310 | + } |
|
311 | + |
|
312 | + /** |
|
313 | + * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
314 | + * @param string $filePath Absolute path |
|
315 | + * @return string Relative path |
|
316 | + * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
317 | + */ |
|
318 | + public static function convertToRelativePath($filePath) { |
|
319 | + $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
320 | + if(count($relativePath) !== 2) { |
|
321 | + throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
322 | + } |
|
323 | + |
|
324 | + return $relativePath[1]; |
|
325 | + } |
|
326 | 326 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | <meta charset="utf-8"> |
5 | 5 | <title> |
6 | 6 | <?php |
7 | - p(!empty($_['application'])?$_['application'].' - ':''); |
|
7 | + p(!empty($_['application']) ? $_['application'].' - ' : ''); |
|
8 | 8 | p($theme->getTitle()); |
9 | 9 | ?> |
10 | 10 | </title> |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | <meta name="apple-itunes-app" content="app-id=<?php p($theme->getiTunesAppId()); ?>"> |
15 | 15 | <meta name="apple-mobile-web-app-capable" content="yes"> |
16 | 16 | <meta name="apple-mobile-web-app-status-bar-style" content="black"> |
17 | - <meta name="apple-mobile-web-app-title" content="<?php p((!empty($_['application']) && $_['appid']!='files')? $_['application']:$theme->getTitle()); ?>"> |
|
17 | + <meta name="apple-mobile-web-app-title" content="<?php p((!empty($_['application']) && $_['appid'] != 'files') ? $_['application'] : $theme->getTitle()); ?>"> |
|
18 | 18 | <meta name="mobile-web-app-capable" content="yes"> |
19 | 19 | <meta name="theme-color" content="<?php p($theme->getColorPrimary()); ?>"> |
20 | 20 | <link rel="icon" href="<?php print_unescaped(image_path($_['appid'], 'favicon.ico')); /* IE11+ supports png */ ?>"> |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | <?php emit_script_loading_tags($_); ?> |
26 | 26 | <?php print_unescaped($_['headers']); ?> |
27 | 27 | </head> |
28 | - <body id="<?php p($_['bodyid']);?>"> |
|
28 | + <body id="<?php p($_['bodyid']); ?>"> |
|
29 | 29 | <?php include('layout.noscript.warning.php'); ?> |
30 | 30 | <div id="notification-container"> |
31 | 31 | <div id="notification"></div> |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | id="nextcloud"> |
37 | 37 | <div class="logo logo-icon"> |
38 | 38 | <h1 class="hidden-visually"> |
39 | - <?php p($theme->getName()); ?> <?php p(!empty($_['application'])?$_['application']: $l->t('Apps')); ?> |
|
39 | + <?php p($theme->getName()); ?> <?php p(!empty($_['application']) ? $_['application'] : $l->t('Apps')); ?> |
|
40 | 40 | </h1> |
41 | 41 | </div> |
42 | 42 | </a> |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | <?php if ($_['themingInvertMenu']) { ?> |
50 | 50 | <svg width="20" height="20" viewBox="0 0 20 20"> |
51 | 51 | <defs><filter id="invert-<?php p($entry['id']); ?>"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0" /></filter></defs> |
52 | - <image x="0" y="0" width="20" height="20" preserveAspectRatio="xMinYMin meet" filter="url(#invert-<?php p($entry['id']); ?>)" xlink:href="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>" class="app-icon" /></svg> |
|
52 | + <image x="0" y="0" width="20" height="20" preserveAspectRatio="xMinYMin meet" filter="url(#invert-<?php p($entry['id']); ?>)" xlink:href="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>" class="app-icon" /></svg> |
|
53 | 53 | <?php } else { ?> |
54 | - <img src="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>" |
|
54 | + <img src="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>" |
|
55 | 55 | class="app-icon" alt="<?php p($entry['name']); ?>" /> |
56 | 56 | <?php } ?> |
57 | 57 | <div class="icon-loading-small-dark" |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | <div id="navigation" style="display: none;"> |
75 | 75 | <div id="apps"> |
76 | 76 | <ul> |
77 | - <?php foreach($_['navigation'] as $entry): ?> |
|
77 | + <?php foreach ($_['navigation'] as $entry): ?> |
|
78 | 78 | <li data-id="<?php p($entry['id']); ?>"> |
79 | 79 | <a href="<?php print_unescaped($entry['href']); ?>" |
80 | - <?php if( $entry['active'] ): ?> class="active"<?php endif; ?>> |
|
80 | + <?php if ($entry['active']): ?> class="active"<?php endif; ?>> |
|
81 | 81 | <svg width="16" height="16" viewBox="0 0 16 16"> |
82 | 82 | <defs><filter id="invert-<?php p($entry['id']); ?>"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0"></feColorMatrix></filter></defs> |
83 | - <image x="0" y="0" width="16" height="16" preserveAspectRatio="xMinYMin meet" filter="url(#invert-<?php p($entry['id']); ?>)" xlink:href="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>" class="app-icon"></image> |
|
83 | + <image x="0" y="0" width="16" height="16" preserveAspectRatio="xMinYMin meet" filter="url(#invert-<?php p($entry['id']); ?>)" xlink:href="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>" class="app-icon"></image> |
|
84 | 84 | </svg> |
85 | 85 | <div class="icon-loading-small-dark" style="display:none;"></div> |
86 | 86 | <span><?php p($entry['name']); ?></span> |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | <div class="header-right"> |
98 | 98 | <form class="searchbox" action="#" method="post" role="search" novalidate> |
99 | 99 | <label for="searchbox" class="hidden-visually"> |
100 | - <?php p($l->t('Search'));?> |
|
100 | + <?php p($l->t('Search')); ?> |
|
101 | 101 | </label> |
102 | 102 | <input id="searchbox" type="search" name="query" |
103 | 103 | value="" required |
104 | 104 | autocomplete="off"> |
105 | - <button class="icon-close-white" type="reset"><span class="hidden-visually"><?php p($l->t('Reset search'));?></span></button> |
|
105 | + <button class="icon-close-white" type="reset"><span class="hidden-visually"><?php p($l->t('Reset search')); ?></span></button> |
|
106 | 106 | </form> |
107 | 107 | <div id="contactsmenu"> |
108 | 108 | <div class="icon-contacts menutoggle" tabindex="0" role="link"></div> |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | <div class="avatardiv<?php if ($_['userAvatarSet']) { print_unescaped(' avatardiv-shown'); } else { print_unescaped('" style="display: none'); } ?>"> |
114 | 114 | <?php if ($_['userAvatarSet']): ?> |
115 | 115 | <img alt="" width="32" height="32" |
116 | - src="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 32, 'v' => $_['userAvatarVersion']]));?>" |
|
117 | - srcset="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 64, 'v' => $_['userAvatarVersion']]));?> 2x, <?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 128, 'v' => $_['userAvatarVersion']]));?> 4x" |
|
116 | + src="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 32, 'v' => $_['userAvatarVersion']])); ?>" |
|
117 | + srcset="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 64, 'v' => $_['userAvatarVersion']])); ?> 2x, <?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 128, 'v' => $_['userAvatarVersion']])); ?> 4x" |
|
118 | 118 | > |
119 | 119 | <?php endif; ?> |
120 | 120 | </div> |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | </div> |
123 | 123 | <div id="expanddiv" style="display:none;"> |
124 | 124 | <ul> |
125 | - <?php foreach($_['settingsnavigation'] as $entry):?> |
|
125 | + <?php foreach ($_['settingsnavigation'] as $entry):?> |
|
126 | 126 | <li> |
127 | 127 | <a href="<?php print_unescaped($entry['href']); ?>" |
128 | - <?php if( $entry["active"] ): ?> class="active"<?php endif; ?>> |
|
129 | - <img alt="" src="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>"> |
|
128 | + <?php if ($entry["active"]): ?> class="active"<?php endif; ?>> |
|
129 | + <img alt="" src="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>"> |
|
130 | 130 | <?php p($entry['name']) ?> |
131 | 131 | </a> |
132 | 132 | </li> |