@@ -61,7 +61,7 @@ |
||
61 | 61 | parent::__construct( 'core', 'layout.user' ); |
62 | 62 | if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
63 | 63 | $this->assign('bodyid', 'body-settings'); |
64 | - }else{ |
|
64 | + } else{ |
|
65 | 65 | $this->assign('bodyid', 'body-user'); |
66 | 66 | } |
67 | 67 |
@@ -52,313 +52,313 @@ |
||
52 | 52 | |
53 | 53 | class TemplateLayout extends \OC_Template { |
54 | 54 | |
55 | - private static $versionHash = ''; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var \OCP\IConfig |
|
59 | - */ |
|
60 | - private $config; |
|
61 | - |
|
62 | - /** |
|
63 | - * @param string $renderAs |
|
64 | - * @param string $appId application id |
|
65 | - */ |
|
66 | - public function __construct( $renderAs, $appId = '' ) { |
|
67 | - |
|
68 | - // yes - should be injected .... |
|
69 | - $this->config = \OC::$server->getConfig(); |
|
70 | - |
|
71 | - if(\OCP\Util::isIE()) { |
|
72 | - \OC_Util::addStyle('ie'); |
|
73 | - } |
|
74 | - |
|
75 | - // Decide which page we show |
|
76 | - if($renderAs === 'user') { |
|
77 | - parent::__construct( 'core', 'layout.user' ); |
|
78 | - if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
79 | - $this->assign('bodyid', 'body-settings'); |
|
80 | - }else{ |
|
81 | - $this->assign('bodyid', 'body-user'); |
|
82 | - } |
|
83 | - |
|
84 | - // Add navigation entry |
|
85 | - $this->assign( 'application', ''); |
|
86 | - $this->assign( 'appid', $appId ); |
|
87 | - $navigation = \OC::$server->getNavigationManager()->getAll(); |
|
88 | - $this->assign( 'navigation', $navigation); |
|
89 | - $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings'); |
|
90 | - $this->assign( 'settingsnavigation', $settingsNavigation); |
|
91 | - foreach($navigation as $entry) { |
|
92 | - if ($entry['active']) { |
|
93 | - $this->assign( 'application', $entry['name'] ); |
|
94 | - break; |
|
95 | - } |
|
96 | - } |
|
97 | - |
|
98 | - foreach($settingsNavigation as $entry) { |
|
99 | - if ($entry['active']) { |
|
100 | - $this->assign( 'application', $entry['name'] ); |
|
101 | - break; |
|
102 | - } |
|
103 | - } |
|
104 | - $userDisplayName = \OC_User::getDisplayName(); |
|
105 | - $this->assign('user_displayname', $userDisplayName); |
|
106 | - $this->assign('user_uid', \OC_User::getUser()); |
|
107 | - |
|
108 | - if (\OC_User::getUser() === false) { |
|
109 | - $this->assign('userAvatarSet', false); |
|
110 | - } else { |
|
111 | - $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
112 | - $this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
113 | - } |
|
114 | - |
|
115 | - // check if app menu icons should be inverted |
|
116 | - try { |
|
117 | - /** @var \OCA\Theming\Util $util */ |
|
118 | - $util = \OC::$server->query(\OCA\Theming\Util::class); |
|
119 | - $this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary())); |
|
120 | - } catch (\OCP\AppFramework\QueryException $e) { |
|
121 | - $this->assign('themingInvertMenu', false); |
|
122 | - } catch (\OCP\AutoloadNotAllowedException $e) { |
|
123 | - $this->assign('themingInvertMenu', false); |
|
124 | - } |
|
125 | - |
|
126 | - } else if ($renderAs === 'error') { |
|
127 | - parent::__construct('core', 'layout.guest', '', false); |
|
128 | - $this->assign('bodyid', 'body-login'); |
|
129 | - $this->assign('user_displayname', ''); |
|
130 | - $this->assign('user_uid', ''); |
|
131 | - } else if ($renderAs === 'guest') { |
|
132 | - parent::__construct('core', 'layout.guest'); |
|
133 | - \OC_Util::addStyle('guest'); |
|
134 | - $this->assign('bodyid', 'body-login'); |
|
135 | - |
|
136 | - $userDisplayName = \OC_User::getDisplayName(); |
|
137 | - $this->assign('user_displayname', $userDisplayName); |
|
138 | - $this->assign('user_uid', \OC_User::getUser()); |
|
139 | - } else if ($renderAs === 'public') { |
|
140 | - parent::__construct('core', 'layout.public'); |
|
141 | - $this->assign( 'appid', $appId ); |
|
142 | - $this->assign('bodyid', 'body-public'); |
|
143 | - |
|
144 | - /** @var IRegistry $subscription */ |
|
145 | - $subscription = \OC::$server->query(IRegistry::class); |
|
146 | - $showSimpleSignup = $this->config->getSystemValueBool('simpleSignUpLink.shown', true); |
|
147 | - if ($showSimpleSignup && $subscription->delegateHasValidSubscription()) { |
|
148 | - $showSimpleSignup = false; |
|
149 | - } |
|
150 | - $this->assign('showSimpleSignUpLink', $showSimpleSignup); |
|
151 | - } else { |
|
152 | - parent::__construct('core', 'layout.base'); |
|
153 | - |
|
154 | - } |
|
155 | - // Send the language and the locale to our layouts |
|
156 | - $lang = \OC::$server->getL10NFactory()->findLanguage(); |
|
157 | - $locale = \OC::$server->getL10NFactory()->findLocale($lang); |
|
158 | - |
|
159 | - $lang = str_replace('_', '-', $lang); |
|
160 | - $this->assign('language', $lang); |
|
161 | - $this->assign('locale', $locale); |
|
162 | - |
|
163 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
164 | - if (empty(self::$versionHash)) { |
|
165 | - $v = \OC_App::getAppVersions(); |
|
166 | - $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
167 | - self::$versionHash = substr(md5(implode(',', $v)), 0, 8); |
|
168 | - } |
|
169 | - } else { |
|
170 | - self::$versionHash = md5('not installed'); |
|
171 | - } |
|
172 | - |
|
173 | - // Add the js files |
|
174 | - $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
175 | - $this->assign('jsfiles', []); |
|
176 | - if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
177 | - if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
178 | - $jsConfigHelper = new JSConfigHelper( |
|
179 | - \OC::$server->getL10N('lib'), |
|
180 | - \OC::$server->query(Defaults::class), |
|
181 | - \OC::$server->getAppManager(), |
|
182 | - \OC::$server->getSession(), |
|
183 | - \OC::$server->getUserSession()->getUser(), |
|
184 | - $this->config, |
|
185 | - \OC::$server->getGroupManager(), |
|
186 | - \OC::$server->getIniWrapper(), |
|
187 | - \OC::$server->getURLGenerator(), |
|
188 | - \OC::$server->getCapabilitiesManager() |
|
189 | - ); |
|
190 | - $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
191 | - } else { |
|
192 | - $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
193 | - } |
|
194 | - } |
|
195 | - foreach($jsFiles as $info) { |
|
196 | - $web = $info[1]; |
|
197 | - $file = $info[2]; |
|
198 | - $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
199 | - } |
|
200 | - |
|
201 | - try { |
|
202 | - $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
203 | - } catch (\Exception $e) { |
|
204 | - $pathInfo = ''; |
|
205 | - } |
|
206 | - |
|
207 | - // Do not initialise scss appdata until we have a fully installed instance |
|
208 | - // Do not load scss for update, errors, installation or login page |
|
209 | - if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
210 | - && !\OCP\Util::needUpgrade() |
|
211 | - && $pathInfo !== '' |
|
212 | - && !preg_match('/^\/login/', $pathInfo) |
|
213 | - && $renderAs !== 'error' |
|
214 | - ) { |
|
215 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
216 | - } else { |
|
217 | - // If we ignore the scss compiler, |
|
218 | - // we need to load the guest css fallback |
|
219 | - \OC_Util::addStyle('guest'); |
|
220 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
221 | - } |
|
222 | - |
|
223 | - $this->assign('cssfiles', []); |
|
224 | - $this->assign('printcssfiles', []); |
|
225 | - $this->assign('versionHash', self::$versionHash); |
|
226 | - foreach($cssFiles as $info) { |
|
227 | - $web = $info[1]; |
|
228 | - $file = $info[2]; |
|
229 | - |
|
230 | - if (substr($file, -strlen('print.css')) === 'print.css') { |
|
231 | - $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
232 | - } else { |
|
233 | - $suffix = $this->getVersionHashSuffix($web, $file); |
|
234 | - |
|
235 | - if (strpos($file, '?v=') == false) { |
|
236 | - $this->append( 'cssfiles', $web.'/'.$file . $suffix); |
|
237 | - } else { |
|
238 | - $this->append( 'cssfiles', $web.'/'.$file . '-' . substr($suffix, 3)); |
|
239 | - } |
|
240 | - |
|
241 | - } |
|
242 | - } |
|
243 | - |
|
244 | - /** @var InitialStateService $initialState */ |
|
245 | - $initialState = \OC::$server->query(InitialStateService::class); |
|
246 | - $this->assign('initialStates', $initialState->getInitialStates()); |
|
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * @param string $path |
|
251 | - * @param string $file |
|
252 | - * @return string |
|
253 | - */ |
|
254 | - protected function getVersionHashSuffix($path = false, $file = false) { |
|
255 | - if ($this->config->getSystemValue('debug', false)) { |
|
256 | - // allows chrome workspace mapping in debug mode |
|
257 | - return ""; |
|
258 | - } |
|
259 | - $themingSuffix = ''; |
|
260 | - $v = []; |
|
261 | - |
|
262 | - if ($this->config->getSystemValue('installed', false)) { |
|
263 | - if (\OC::$server->getAppManager()->isInstalled('theming')) { |
|
264 | - $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
265 | - } |
|
266 | - $v = \OC_App::getAppVersions(); |
|
267 | - } |
|
268 | - |
|
269 | - // Try the webroot path for a match |
|
270 | - if ($path !== false && $path !== '') { |
|
271 | - $appName = $this->getAppNamefromPath($path); |
|
272 | - if(array_key_exists($appName, $v)) { |
|
273 | - $appVersion = $v[$appName]; |
|
274 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
275 | - } |
|
276 | - } |
|
277 | - // fallback to the file path instead |
|
278 | - if ($file !== false && $file !== '') { |
|
279 | - $appName = $this->getAppNamefromPath($file); |
|
280 | - if(array_key_exists($appName, $v)) { |
|
281 | - $appVersion = $v[$appName]; |
|
282 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
283 | - } |
|
284 | - } |
|
285 | - |
|
286 | - return '?v=' . self::$versionHash . $themingSuffix; |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * @param array $styles |
|
291 | - * @return array |
|
292 | - */ |
|
293 | - static public function findStylesheetFiles($styles, $compileScss = true) { |
|
294 | - // Read the selected theme from the config file |
|
295 | - $theme = \OC_Util::getTheme(); |
|
296 | - |
|
297 | - if($compileScss) { |
|
298 | - $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
|
299 | - } else { |
|
300 | - $SCSSCacher = null; |
|
301 | - } |
|
302 | - |
|
303 | - $locator = new \OC\Template\CSSResourceLocator( |
|
304 | - \OC::$server->getLogger(), |
|
305 | - $theme, |
|
306 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
307 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
308 | - $SCSSCacher |
|
309 | - ); |
|
310 | - $locator->find($styles); |
|
311 | - return $locator->getResources(); |
|
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * @param string $path |
|
316 | - * @return string|boolean |
|
317 | - */ |
|
318 | - public function getAppNamefromPath($path) { |
|
319 | - if ($path !== '' && is_string($path)) { |
|
320 | - $pathParts = explode('/', $path); |
|
321 | - if ($pathParts[0] === 'css') { |
|
322 | - // This is a scss request |
|
323 | - return $pathParts[1]; |
|
324 | - } |
|
325 | - return end($pathParts); |
|
326 | - } |
|
327 | - return false; |
|
328 | - |
|
329 | - } |
|
330 | - |
|
331 | - /** |
|
332 | - * @param array $scripts |
|
333 | - * @return array |
|
334 | - */ |
|
335 | - static public function findJavascriptFiles($scripts) { |
|
336 | - // Read the selected theme from the config file |
|
337 | - $theme = \OC_Util::getTheme(); |
|
338 | - |
|
339 | - $locator = new \OC\Template\JSResourceLocator( |
|
340 | - \OC::$server->getLogger(), |
|
341 | - $theme, |
|
342 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
343 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
344 | - \OC::$server->query(JSCombiner::class) |
|
345 | - ); |
|
346 | - $locator->find($scripts); |
|
347 | - return $locator->getResources(); |
|
348 | - } |
|
349 | - |
|
350 | - /** |
|
351 | - * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
352 | - * @param string $filePath Absolute path |
|
353 | - * @return string Relative path |
|
354 | - * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
355 | - */ |
|
356 | - public static function convertToRelativePath($filePath) { |
|
357 | - $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
358 | - if(count($relativePath) !== 2) { |
|
359 | - throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
360 | - } |
|
361 | - |
|
362 | - return $relativePath[1]; |
|
363 | - } |
|
55 | + private static $versionHash = ''; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var \OCP\IConfig |
|
59 | + */ |
|
60 | + private $config; |
|
61 | + |
|
62 | + /** |
|
63 | + * @param string $renderAs |
|
64 | + * @param string $appId application id |
|
65 | + */ |
|
66 | + public function __construct( $renderAs, $appId = '' ) { |
|
67 | + |
|
68 | + // yes - should be injected .... |
|
69 | + $this->config = \OC::$server->getConfig(); |
|
70 | + |
|
71 | + if(\OCP\Util::isIE()) { |
|
72 | + \OC_Util::addStyle('ie'); |
|
73 | + } |
|
74 | + |
|
75 | + // Decide which page we show |
|
76 | + if($renderAs === 'user') { |
|
77 | + parent::__construct( 'core', 'layout.user' ); |
|
78 | + if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
79 | + $this->assign('bodyid', 'body-settings'); |
|
80 | + }else{ |
|
81 | + $this->assign('bodyid', 'body-user'); |
|
82 | + } |
|
83 | + |
|
84 | + // Add navigation entry |
|
85 | + $this->assign( 'application', ''); |
|
86 | + $this->assign( 'appid', $appId ); |
|
87 | + $navigation = \OC::$server->getNavigationManager()->getAll(); |
|
88 | + $this->assign( 'navigation', $navigation); |
|
89 | + $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings'); |
|
90 | + $this->assign( 'settingsnavigation', $settingsNavigation); |
|
91 | + foreach($navigation as $entry) { |
|
92 | + if ($entry['active']) { |
|
93 | + $this->assign( 'application', $entry['name'] ); |
|
94 | + break; |
|
95 | + } |
|
96 | + } |
|
97 | + |
|
98 | + foreach($settingsNavigation as $entry) { |
|
99 | + if ($entry['active']) { |
|
100 | + $this->assign( 'application', $entry['name'] ); |
|
101 | + break; |
|
102 | + } |
|
103 | + } |
|
104 | + $userDisplayName = \OC_User::getDisplayName(); |
|
105 | + $this->assign('user_displayname', $userDisplayName); |
|
106 | + $this->assign('user_uid', \OC_User::getUser()); |
|
107 | + |
|
108 | + if (\OC_User::getUser() === false) { |
|
109 | + $this->assign('userAvatarSet', false); |
|
110 | + } else { |
|
111 | + $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
112 | + $this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
113 | + } |
|
114 | + |
|
115 | + // check if app menu icons should be inverted |
|
116 | + try { |
|
117 | + /** @var \OCA\Theming\Util $util */ |
|
118 | + $util = \OC::$server->query(\OCA\Theming\Util::class); |
|
119 | + $this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary())); |
|
120 | + } catch (\OCP\AppFramework\QueryException $e) { |
|
121 | + $this->assign('themingInvertMenu', false); |
|
122 | + } catch (\OCP\AutoloadNotAllowedException $e) { |
|
123 | + $this->assign('themingInvertMenu', false); |
|
124 | + } |
|
125 | + |
|
126 | + } else if ($renderAs === 'error') { |
|
127 | + parent::__construct('core', 'layout.guest', '', false); |
|
128 | + $this->assign('bodyid', 'body-login'); |
|
129 | + $this->assign('user_displayname', ''); |
|
130 | + $this->assign('user_uid', ''); |
|
131 | + } else if ($renderAs === 'guest') { |
|
132 | + parent::__construct('core', 'layout.guest'); |
|
133 | + \OC_Util::addStyle('guest'); |
|
134 | + $this->assign('bodyid', 'body-login'); |
|
135 | + |
|
136 | + $userDisplayName = \OC_User::getDisplayName(); |
|
137 | + $this->assign('user_displayname', $userDisplayName); |
|
138 | + $this->assign('user_uid', \OC_User::getUser()); |
|
139 | + } else if ($renderAs === 'public') { |
|
140 | + parent::__construct('core', 'layout.public'); |
|
141 | + $this->assign( 'appid', $appId ); |
|
142 | + $this->assign('bodyid', 'body-public'); |
|
143 | + |
|
144 | + /** @var IRegistry $subscription */ |
|
145 | + $subscription = \OC::$server->query(IRegistry::class); |
|
146 | + $showSimpleSignup = $this->config->getSystemValueBool('simpleSignUpLink.shown', true); |
|
147 | + if ($showSimpleSignup && $subscription->delegateHasValidSubscription()) { |
|
148 | + $showSimpleSignup = false; |
|
149 | + } |
|
150 | + $this->assign('showSimpleSignUpLink', $showSimpleSignup); |
|
151 | + } else { |
|
152 | + parent::__construct('core', 'layout.base'); |
|
153 | + |
|
154 | + } |
|
155 | + // Send the language and the locale to our layouts |
|
156 | + $lang = \OC::$server->getL10NFactory()->findLanguage(); |
|
157 | + $locale = \OC::$server->getL10NFactory()->findLocale($lang); |
|
158 | + |
|
159 | + $lang = str_replace('_', '-', $lang); |
|
160 | + $this->assign('language', $lang); |
|
161 | + $this->assign('locale', $locale); |
|
162 | + |
|
163 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
164 | + if (empty(self::$versionHash)) { |
|
165 | + $v = \OC_App::getAppVersions(); |
|
166 | + $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
167 | + self::$versionHash = substr(md5(implode(',', $v)), 0, 8); |
|
168 | + } |
|
169 | + } else { |
|
170 | + self::$versionHash = md5('not installed'); |
|
171 | + } |
|
172 | + |
|
173 | + // Add the js files |
|
174 | + $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
175 | + $this->assign('jsfiles', []); |
|
176 | + if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
177 | + if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
178 | + $jsConfigHelper = new JSConfigHelper( |
|
179 | + \OC::$server->getL10N('lib'), |
|
180 | + \OC::$server->query(Defaults::class), |
|
181 | + \OC::$server->getAppManager(), |
|
182 | + \OC::$server->getSession(), |
|
183 | + \OC::$server->getUserSession()->getUser(), |
|
184 | + $this->config, |
|
185 | + \OC::$server->getGroupManager(), |
|
186 | + \OC::$server->getIniWrapper(), |
|
187 | + \OC::$server->getURLGenerator(), |
|
188 | + \OC::$server->getCapabilitiesManager() |
|
189 | + ); |
|
190 | + $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
191 | + } else { |
|
192 | + $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
193 | + } |
|
194 | + } |
|
195 | + foreach($jsFiles as $info) { |
|
196 | + $web = $info[1]; |
|
197 | + $file = $info[2]; |
|
198 | + $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
199 | + } |
|
200 | + |
|
201 | + try { |
|
202 | + $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
203 | + } catch (\Exception $e) { |
|
204 | + $pathInfo = ''; |
|
205 | + } |
|
206 | + |
|
207 | + // Do not initialise scss appdata until we have a fully installed instance |
|
208 | + // Do not load scss for update, errors, installation or login page |
|
209 | + if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
210 | + && !\OCP\Util::needUpgrade() |
|
211 | + && $pathInfo !== '' |
|
212 | + && !preg_match('/^\/login/', $pathInfo) |
|
213 | + && $renderAs !== 'error' |
|
214 | + ) { |
|
215 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
216 | + } else { |
|
217 | + // If we ignore the scss compiler, |
|
218 | + // we need to load the guest css fallback |
|
219 | + \OC_Util::addStyle('guest'); |
|
220 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
221 | + } |
|
222 | + |
|
223 | + $this->assign('cssfiles', []); |
|
224 | + $this->assign('printcssfiles', []); |
|
225 | + $this->assign('versionHash', self::$versionHash); |
|
226 | + foreach($cssFiles as $info) { |
|
227 | + $web = $info[1]; |
|
228 | + $file = $info[2]; |
|
229 | + |
|
230 | + if (substr($file, -strlen('print.css')) === 'print.css') { |
|
231 | + $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
232 | + } else { |
|
233 | + $suffix = $this->getVersionHashSuffix($web, $file); |
|
234 | + |
|
235 | + if (strpos($file, '?v=') == false) { |
|
236 | + $this->append( 'cssfiles', $web.'/'.$file . $suffix); |
|
237 | + } else { |
|
238 | + $this->append( 'cssfiles', $web.'/'.$file . '-' . substr($suffix, 3)); |
|
239 | + } |
|
240 | + |
|
241 | + } |
|
242 | + } |
|
243 | + |
|
244 | + /** @var InitialStateService $initialState */ |
|
245 | + $initialState = \OC::$server->query(InitialStateService::class); |
|
246 | + $this->assign('initialStates', $initialState->getInitialStates()); |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * @param string $path |
|
251 | + * @param string $file |
|
252 | + * @return string |
|
253 | + */ |
|
254 | + protected function getVersionHashSuffix($path = false, $file = false) { |
|
255 | + if ($this->config->getSystemValue('debug', false)) { |
|
256 | + // allows chrome workspace mapping in debug mode |
|
257 | + return ""; |
|
258 | + } |
|
259 | + $themingSuffix = ''; |
|
260 | + $v = []; |
|
261 | + |
|
262 | + if ($this->config->getSystemValue('installed', false)) { |
|
263 | + if (\OC::$server->getAppManager()->isInstalled('theming')) { |
|
264 | + $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
265 | + } |
|
266 | + $v = \OC_App::getAppVersions(); |
|
267 | + } |
|
268 | + |
|
269 | + // Try the webroot path for a match |
|
270 | + if ($path !== false && $path !== '') { |
|
271 | + $appName = $this->getAppNamefromPath($path); |
|
272 | + if(array_key_exists($appName, $v)) { |
|
273 | + $appVersion = $v[$appName]; |
|
274 | + return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
275 | + } |
|
276 | + } |
|
277 | + // fallback to the file path instead |
|
278 | + if ($file !== false && $file !== '') { |
|
279 | + $appName = $this->getAppNamefromPath($file); |
|
280 | + if(array_key_exists($appName, $v)) { |
|
281 | + $appVersion = $v[$appName]; |
|
282 | + return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
283 | + } |
|
284 | + } |
|
285 | + |
|
286 | + return '?v=' . self::$versionHash . $themingSuffix; |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * @param array $styles |
|
291 | + * @return array |
|
292 | + */ |
|
293 | + static public function findStylesheetFiles($styles, $compileScss = true) { |
|
294 | + // Read the selected theme from the config file |
|
295 | + $theme = \OC_Util::getTheme(); |
|
296 | + |
|
297 | + if($compileScss) { |
|
298 | + $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
|
299 | + } else { |
|
300 | + $SCSSCacher = null; |
|
301 | + } |
|
302 | + |
|
303 | + $locator = new \OC\Template\CSSResourceLocator( |
|
304 | + \OC::$server->getLogger(), |
|
305 | + $theme, |
|
306 | + [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
307 | + [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
308 | + $SCSSCacher |
|
309 | + ); |
|
310 | + $locator->find($styles); |
|
311 | + return $locator->getResources(); |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * @param string $path |
|
316 | + * @return string|boolean |
|
317 | + */ |
|
318 | + public function getAppNamefromPath($path) { |
|
319 | + if ($path !== '' && is_string($path)) { |
|
320 | + $pathParts = explode('/', $path); |
|
321 | + if ($pathParts[0] === 'css') { |
|
322 | + // This is a scss request |
|
323 | + return $pathParts[1]; |
|
324 | + } |
|
325 | + return end($pathParts); |
|
326 | + } |
|
327 | + return false; |
|
328 | + |
|
329 | + } |
|
330 | + |
|
331 | + /** |
|
332 | + * @param array $scripts |
|
333 | + * @return array |
|
334 | + */ |
|
335 | + static public function findJavascriptFiles($scripts) { |
|
336 | + // Read the selected theme from the config file |
|
337 | + $theme = \OC_Util::getTheme(); |
|
338 | + |
|
339 | + $locator = new \OC\Template\JSResourceLocator( |
|
340 | + \OC::$server->getLogger(), |
|
341 | + $theme, |
|
342 | + [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
343 | + [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
344 | + \OC::$server->query(JSCombiner::class) |
|
345 | + ); |
|
346 | + $locator->find($scripts); |
|
347 | + return $locator->getResources(); |
|
348 | + } |
|
349 | + |
|
350 | + /** |
|
351 | + * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
352 | + * @param string $filePath Absolute path |
|
353 | + * @return string Relative path |
|
354 | + * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
355 | + */ |
|
356 | + public static function convertToRelativePath($filePath) { |
|
357 | + $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
358 | + if(count($relativePath) !== 2) { |
|
359 | + throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
360 | + } |
|
361 | + |
|
362 | + return $relativePath[1]; |
|
363 | + } |
|
364 | 364 | } |
@@ -63,41 +63,41 @@ discard block |
||
63 | 63 | * @param string $renderAs |
64 | 64 | * @param string $appId application id |
65 | 65 | */ |
66 | - public function __construct( $renderAs, $appId = '' ) { |
|
66 | + public function __construct($renderAs, $appId = '') { |
|
67 | 67 | |
68 | 68 | // yes - should be injected .... |
69 | 69 | $this->config = \OC::$server->getConfig(); |
70 | 70 | |
71 | - if(\OCP\Util::isIE()) { |
|
71 | + if (\OCP\Util::isIE()) { |
|
72 | 72 | \OC_Util::addStyle('ie'); |
73 | 73 | } |
74 | 74 | |
75 | 75 | // Decide which page we show |
76 | - if($renderAs === 'user') { |
|
77 | - parent::__construct( 'core', 'layout.user' ); |
|
78 | - if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
76 | + if ($renderAs === 'user') { |
|
77 | + parent::__construct('core', 'layout.user'); |
|
78 | + if (in_array(\OC_App::getCurrentApp(), ['settings', 'admin', 'help']) !== false) { |
|
79 | 79 | $this->assign('bodyid', 'body-settings'); |
80 | - }else{ |
|
80 | + } else { |
|
81 | 81 | $this->assign('bodyid', 'body-user'); |
82 | 82 | } |
83 | 83 | |
84 | 84 | // Add navigation entry |
85 | - $this->assign( 'application', ''); |
|
86 | - $this->assign( 'appid', $appId ); |
|
85 | + $this->assign('application', ''); |
|
86 | + $this->assign('appid', $appId); |
|
87 | 87 | $navigation = \OC::$server->getNavigationManager()->getAll(); |
88 | - $this->assign( 'navigation', $navigation); |
|
88 | + $this->assign('navigation', $navigation); |
|
89 | 89 | $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings'); |
90 | - $this->assign( 'settingsnavigation', $settingsNavigation); |
|
91 | - foreach($navigation as $entry) { |
|
90 | + $this->assign('settingsnavigation', $settingsNavigation); |
|
91 | + foreach ($navigation as $entry) { |
|
92 | 92 | if ($entry['active']) { |
93 | - $this->assign( 'application', $entry['name'] ); |
|
93 | + $this->assign('application', $entry['name']); |
|
94 | 94 | break; |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - foreach($settingsNavigation as $entry) { |
|
98 | + foreach ($settingsNavigation as $entry) { |
|
99 | 99 | if ($entry['active']) { |
100 | - $this->assign( 'application', $entry['name'] ); |
|
100 | + $this->assign('application', $entry['name']); |
|
101 | 101 | break; |
102 | 102 | } |
103 | 103 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $this->assign('user_uid', \OC_User::getUser()); |
139 | 139 | } else if ($renderAs === 'public') { |
140 | 140 | parent::__construct('core', 'layout.public'); |
141 | - $this->assign( 'appid', $appId ); |
|
141 | + $this->assign('appid', $appId); |
|
142 | 142 | $this->assign('bodyid', 'body-public'); |
143 | 143 | |
144 | 144 | /** @var IRegistry $subscription */ |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $this->assign('language', $lang); |
161 | 161 | $this->assign('locale', $locale); |
162 | 162 | |
163 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
163 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
164 | 164 | if (empty(self::$versionHash)) { |
165 | 165 | $v = \OC_App::getAppVersions(); |
166 | 166 | $v['core'] = implode('.', \OCP\Util::getVersion()); |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
193 | 193 | } |
194 | 194 | } |
195 | - foreach($jsFiles as $info) { |
|
195 | + foreach ($jsFiles as $info) { |
|
196 | 196 | $web = $info[1]; |
197 | 197 | $file = $info[2]; |
198 | - $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
198 | + $this->append('jsfiles', $web.'/'.$file.$this->getVersionHashSuffix()); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | try { |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | // Do not initialise scss appdata until we have a fully installed instance |
208 | 208 | // Do not load scss for update, errors, installation or login page |
209 | - if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
209 | + if (\OC::$server->getSystemConfig()->getValue('installed', false) |
|
210 | 210 | && !\OCP\Util::needUpgrade() |
211 | 211 | && $pathInfo !== '' |
212 | 212 | && !preg_match('/^\/login/', $pathInfo) |
@@ -223,19 +223,19 @@ discard block |
||
223 | 223 | $this->assign('cssfiles', []); |
224 | 224 | $this->assign('printcssfiles', []); |
225 | 225 | $this->assign('versionHash', self::$versionHash); |
226 | - foreach($cssFiles as $info) { |
|
226 | + foreach ($cssFiles as $info) { |
|
227 | 227 | $web = $info[1]; |
228 | 228 | $file = $info[2]; |
229 | 229 | |
230 | 230 | if (substr($file, -strlen('print.css')) === 'print.css') { |
231 | - $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
231 | + $this->append('printcssfiles', $web.'/'.$file.$this->getVersionHashSuffix()); |
|
232 | 232 | } else { |
233 | 233 | $suffix = $this->getVersionHashSuffix($web, $file); |
234 | 234 | |
235 | 235 | if (strpos($file, '?v=') == false) { |
236 | - $this->append( 'cssfiles', $web.'/'.$file . $suffix); |
|
236 | + $this->append('cssfiles', $web.'/'.$file.$suffix); |
|
237 | 237 | } else { |
238 | - $this->append( 'cssfiles', $web.'/'.$file . '-' . substr($suffix, 3)); |
|
238 | + $this->append('cssfiles', $web.'/'.$file.'-'.substr($suffix, 3)); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | if ($this->config->getSystemValue('installed', false)) { |
263 | 263 | if (\OC::$server->getAppManager()->isInstalled('theming')) { |
264 | - $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
264 | + $themingSuffix = '-'.$this->config->getAppValue('theming', 'cachebuster', '0'); |
|
265 | 265 | } |
266 | 266 | $v = \OC_App::getAppVersions(); |
267 | 267 | } |
@@ -269,21 +269,21 @@ discard block |
||
269 | 269 | // Try the webroot path for a match |
270 | 270 | if ($path !== false && $path !== '') { |
271 | 271 | $appName = $this->getAppNamefromPath($path); |
272 | - if(array_key_exists($appName, $v)) { |
|
272 | + if (array_key_exists($appName, $v)) { |
|
273 | 273 | $appVersion = $v[$appName]; |
274 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
274 | + return '?v='.substr(md5($appVersion), 0, 8).$themingSuffix; |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | // fallback to the file path instead |
278 | 278 | if ($file !== false && $file !== '') { |
279 | 279 | $appName = $this->getAppNamefromPath($file); |
280 | - if(array_key_exists($appName, $v)) { |
|
280 | + if (array_key_exists($appName, $v)) { |
|
281 | 281 | $appVersion = $v[$appName]; |
282 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
282 | + return '?v='.substr(md5($appVersion), 0, 8).$themingSuffix; |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
286 | - return '?v=' . self::$versionHash . $themingSuffix; |
|
286 | + return '?v='.self::$versionHash.$themingSuffix; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | // Read the selected theme from the config file |
295 | 295 | $theme = \OC_Util::getTheme(); |
296 | 296 | |
297 | - if($compileScss) { |
|
297 | + if ($compileScss) { |
|
298 | 298 | $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
299 | 299 | } else { |
300 | 300 | $SCSSCacher = null; |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | $locator = new \OC\Template\CSSResourceLocator( |
304 | 304 | \OC::$server->getLogger(), |
305 | 305 | $theme, |
306 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
307 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
306 | + [\OC::$SERVERROOT => \OC::$WEBROOT], |
|
307 | + [\OC::$SERVERROOT => \OC::$WEBROOT], |
|
308 | 308 | $SCSSCacher |
309 | 309 | ); |
310 | 310 | $locator->find($styles); |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | $locator = new \OC\Template\JSResourceLocator( |
340 | 340 | \OC::$server->getLogger(), |
341 | 341 | $theme, |
342 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
343 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
342 | + [\OC::$SERVERROOT => \OC::$WEBROOT], |
|
343 | + [\OC::$SERVERROOT => \OC::$WEBROOT], |
|
344 | 344 | \OC::$server->query(JSCombiner::class) |
345 | 345 | ); |
346 | 346 | $locator->find($scripts); |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | */ |
356 | 356 | public static function convertToRelativePath($filePath) { |
357 | 357 | $relativePath = explode(\OC::$SERVERROOT, $filePath); |
358 | - if(count($relativePath) !== 2) { |
|
358 | + if (count($relativePath) !== 2) { |
|
359 | 359 | throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
360 | 360 | } |
361 | 361 |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function execute($jobList, ILogger $logger = null) { |
59 | 59 | // add an interval of 15 mins |
60 | - $this->setInterval(15*60); |
|
60 | + $this->setInterval(15 * 60); |
|
61 | 61 | |
62 | 62 | $this->jobList = $jobList; |
63 | 63 | $this->logger = $logger; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | try { |
91 | 91 | $repair->addStep($step); |
92 | 92 | } catch (\Exception $ex) { |
93 | - $this->logger->logException($ex,[ |
|
93 | + $this->logger->logException($ex, [ |
|
94 | 94 | 'app' => 'migration' |
95 | 95 | ]); |
96 | 96 |
@@ -39,82 +39,82 @@ |
||
39 | 39 | */ |
40 | 40 | class BackgroundRepair extends TimedJob { |
41 | 41 | |
42 | - /** @var IJobList */ |
|
43 | - private $jobList; |
|
44 | - |
|
45 | - /** @var ILogger */ |
|
46 | - private $logger; |
|
47 | - |
|
48 | - /** @var EventDispatcherInterface */ |
|
49 | - private $dispatcher; |
|
50 | - |
|
51 | - public function __construct(EventDispatcherInterface $dispatcher) { |
|
52 | - $this->dispatcher = $dispatcher; |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * run the job, then remove it from the job list |
|
57 | - * |
|
58 | - * @param JobList $jobList |
|
59 | - * @param ILogger|null $logger |
|
60 | - */ |
|
61 | - public function execute($jobList, ILogger $logger = null) { |
|
62 | - // add an interval of 15 mins |
|
63 | - $this->setInterval(15*60); |
|
64 | - |
|
65 | - $this->jobList = $jobList; |
|
66 | - $this->logger = $logger; |
|
67 | - parent::execute($jobList, $logger); |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * @param array $argument |
|
72 | - * @throws \Exception |
|
73 | - * @throws \OC\NeedsUpdateException |
|
74 | - */ |
|
75 | - protected function run($argument) { |
|
76 | - if (!isset($argument['app']) || !isset($argument['step'])) { |
|
77 | - // remove the job - we can never execute it |
|
78 | - $this->jobList->remove($this, $this->argument); |
|
79 | - return; |
|
80 | - } |
|
81 | - $app = $argument['app']; |
|
82 | - |
|
83 | - try { |
|
84 | - $this->loadApp($app); |
|
85 | - } catch (NeedsUpdateException $ex) { |
|
86 | - // as long as the app is not yet done with it's offline migration |
|
87 | - // we better not start with the live migration |
|
88 | - return; |
|
89 | - } |
|
90 | - |
|
91 | - $step = $argument['step']; |
|
92 | - $repair = new Repair([], $this->dispatcher); |
|
93 | - try { |
|
94 | - $repair->addStep($step); |
|
95 | - } catch (\Exception $ex) { |
|
96 | - $this->logger->logException($ex,[ |
|
97 | - 'app' => 'migration' |
|
98 | - ]); |
|
99 | - |
|
100 | - // remove the job - we can never execute it |
|
101 | - $this->jobList->remove($this, $this->argument); |
|
102 | - return; |
|
103 | - } |
|
104 | - |
|
105 | - // execute the repair step |
|
106 | - $repair->run(); |
|
107 | - |
|
108 | - // remove the job once executed successfully |
|
109 | - $this->jobList->remove($this, $this->argument); |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * @codeCoverageIgnore |
|
114 | - * @param $app |
|
115 | - * @throws NeedsUpdateException |
|
116 | - */ |
|
117 | - protected function loadApp($app) { |
|
118 | - OC_App::loadApp($app); |
|
119 | - } |
|
42 | + /** @var IJobList */ |
|
43 | + private $jobList; |
|
44 | + |
|
45 | + /** @var ILogger */ |
|
46 | + private $logger; |
|
47 | + |
|
48 | + /** @var EventDispatcherInterface */ |
|
49 | + private $dispatcher; |
|
50 | + |
|
51 | + public function __construct(EventDispatcherInterface $dispatcher) { |
|
52 | + $this->dispatcher = $dispatcher; |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * run the job, then remove it from the job list |
|
57 | + * |
|
58 | + * @param JobList $jobList |
|
59 | + * @param ILogger|null $logger |
|
60 | + */ |
|
61 | + public function execute($jobList, ILogger $logger = null) { |
|
62 | + // add an interval of 15 mins |
|
63 | + $this->setInterval(15*60); |
|
64 | + |
|
65 | + $this->jobList = $jobList; |
|
66 | + $this->logger = $logger; |
|
67 | + parent::execute($jobList, $logger); |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * @param array $argument |
|
72 | + * @throws \Exception |
|
73 | + * @throws \OC\NeedsUpdateException |
|
74 | + */ |
|
75 | + protected function run($argument) { |
|
76 | + if (!isset($argument['app']) || !isset($argument['step'])) { |
|
77 | + // remove the job - we can never execute it |
|
78 | + $this->jobList->remove($this, $this->argument); |
|
79 | + return; |
|
80 | + } |
|
81 | + $app = $argument['app']; |
|
82 | + |
|
83 | + try { |
|
84 | + $this->loadApp($app); |
|
85 | + } catch (NeedsUpdateException $ex) { |
|
86 | + // as long as the app is not yet done with it's offline migration |
|
87 | + // we better not start with the live migration |
|
88 | + return; |
|
89 | + } |
|
90 | + |
|
91 | + $step = $argument['step']; |
|
92 | + $repair = new Repair([], $this->dispatcher); |
|
93 | + try { |
|
94 | + $repair->addStep($step); |
|
95 | + } catch (\Exception $ex) { |
|
96 | + $this->logger->logException($ex,[ |
|
97 | + 'app' => 'migration' |
|
98 | + ]); |
|
99 | + |
|
100 | + // remove the job - we can never execute it |
|
101 | + $this->jobList->remove($this, $this->argument); |
|
102 | + return; |
|
103 | + } |
|
104 | + |
|
105 | + // execute the repair step |
|
106 | + $repair->run(); |
|
107 | + |
|
108 | + // remove the job once executed successfully |
|
109 | + $this->jobList->remove($this, $this->argument); |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * @codeCoverageIgnore |
|
114 | + * @param $app |
|
115 | + * @throws NeedsUpdateException |
|
116 | + */ |
|
117 | + protected function loadApp($app) { |
|
118 | + OC_App::loadApp($app); |
|
119 | + } |
|
120 | 120 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | if ($command instanceof ICommand) { |
56 | 56 | // ensure the command can be serialized |
57 | 57 | $serialized = serialize($command); |
58 | - if(strlen($serialized) > 4000) { |
|
58 | + if (strlen($serialized) > 4000) { |
|
59 | 59 | throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)'); |
60 | 60 | } |
61 | 61 | $unserialized = unserialize($serialized); |
@@ -26,48 +26,48 @@ |
||
26 | 26 | use OCP\Command\ICommand; |
27 | 27 | |
28 | 28 | class QueueBus implements IBus { |
29 | - /** |
|
30 | - * @var ICommand[]|callable[] |
|
31 | - */ |
|
32 | - private $queue = []; |
|
29 | + /** |
|
30 | + * @var ICommand[]|callable[] |
|
31 | + */ |
|
32 | + private $queue = []; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Schedule a command to be fired |
|
36 | - * |
|
37 | - * @param \OCP\Command\ICommand | callable $command |
|
38 | - */ |
|
39 | - public function push($command) { |
|
40 | - $this->queue[] = $command; |
|
41 | - } |
|
34 | + /** |
|
35 | + * Schedule a command to be fired |
|
36 | + * |
|
37 | + * @param \OCP\Command\ICommand | callable $command |
|
38 | + */ |
|
39 | + public function push($command) { |
|
40 | + $this->queue[] = $command; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Require all commands using a trait to be run synchronous |
|
45 | - * |
|
46 | - * @param string $trait |
|
47 | - */ |
|
48 | - public function requireSync($trait) { |
|
49 | - } |
|
43 | + /** |
|
44 | + * Require all commands using a trait to be run synchronous |
|
45 | + * |
|
46 | + * @param string $trait |
|
47 | + */ |
|
48 | + public function requireSync($trait) { |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param \OCP\Command\ICommand | callable $command |
|
53 | - */ |
|
54 | - private function runCommand($command) { |
|
55 | - if ($command instanceof ICommand) { |
|
56 | - // ensure the command can be serialized |
|
57 | - $serialized = serialize($command); |
|
58 | - if(strlen($serialized) > 4000) { |
|
59 | - throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)'); |
|
60 | - } |
|
61 | - $unserialized = unserialize($serialized); |
|
62 | - $unserialized->handle(); |
|
63 | - } else { |
|
64 | - $command(); |
|
65 | - } |
|
66 | - } |
|
51 | + /** |
|
52 | + * @param \OCP\Command\ICommand | callable $command |
|
53 | + */ |
|
54 | + private function runCommand($command) { |
|
55 | + if ($command instanceof ICommand) { |
|
56 | + // ensure the command can be serialized |
|
57 | + $serialized = serialize($command); |
|
58 | + if(strlen($serialized) > 4000) { |
|
59 | + throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)'); |
|
60 | + } |
|
61 | + $unserialized = unserialize($serialized); |
|
62 | + $unserialized->handle(); |
|
63 | + } else { |
|
64 | + $command(); |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | - public function run() { |
|
69 | - while ($command = array_shift($this->queue)) { |
|
70 | - $this->runCommand($command); |
|
71 | - } |
|
72 | - } |
|
68 | + public function run() { |
|
69 | + while ($command = array_shift($this->queue)) { |
|
70 | + $this->runCommand($command); |
|
71 | + } |
|
72 | + } |
|
73 | 73 | } |
@@ -25,12 +25,12 @@ |
||
25 | 25 | use OC\BackgroundJob\QueuedJob; |
26 | 26 | |
27 | 27 | class CallableJob extends QueuedJob { |
28 | - protected function run($serializedCallable) { |
|
29 | - $callable = unserialize($serializedCallable); |
|
30 | - if (is_callable($callable)) { |
|
31 | - $callable(); |
|
32 | - } else { |
|
33 | - throw new \InvalidArgumentException('Invalid serialized callable'); |
|
34 | - } |
|
35 | - } |
|
28 | + protected function run($serializedCallable) { |
|
29 | + $callable = unserialize($serializedCallable); |
|
30 | + if (is_callable($callable)) { |
|
31 | + $callable(); |
|
32 | + } else { |
|
33 | + throw new \InvalidArgumentException('Invalid serialized callable'); |
|
34 | + } |
|
35 | + } |
|
36 | 36 | } |
@@ -26,13 +26,13 @@ |
||
26 | 26 | use SuperClosure\Serializer; |
27 | 27 | |
28 | 28 | class ClosureJob extends QueuedJob { |
29 | - protected function run($serializedCallable) { |
|
30 | - $serializer = new Serializer(); |
|
31 | - $callable = $serializer->unserialize($serializedCallable); |
|
32 | - if (is_callable($callable)) { |
|
33 | - $callable(); |
|
34 | - } else { |
|
35 | - throw new \InvalidArgumentException('Invalid serialized callable'); |
|
36 | - } |
|
37 | - } |
|
29 | + protected function run($serializedCallable) { |
|
30 | + $serializer = new Serializer(); |
|
31 | + $callable = $serializer->unserialize($serializedCallable); |
|
32 | + if (is_callable($callable)) { |
|
33 | + $callable(); |
|
34 | + } else { |
|
35 | + throw new \InvalidArgumentException('Invalid serialized callable'); |
|
36 | + } |
|
37 | + } |
|
38 | 38 | } |
@@ -25,12 +25,12 @@ |
||
25 | 25 | use OCP\IUser; |
26 | 26 | |
27 | 27 | trait FileAccess { |
28 | - protected function setupFS(IUser $user){ |
|
29 | - \OC_Util::setupFS($user->getUID()); |
|
30 | - } |
|
28 | + protected function setupFS(IUser $user){ |
|
29 | + \OC_Util::setupFS($user->getUID()); |
|
30 | + } |
|
31 | 31 | |
32 | - protected function getUserFolder(IUser $user) { |
|
33 | - $this->setupFS($user); |
|
34 | - return \OC::$server->getUserFolder($user->getUID()); |
|
35 | - } |
|
32 | + protected function getUserFolder(IUser $user) { |
|
33 | + $this->setupFS($user); |
|
34 | + return \OC::$server->getUserFolder($user->getUID()); |
|
35 | + } |
|
36 | 36 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | use OCP\IUser; |
26 | 26 | |
27 | 27 | trait FileAccess { |
28 | - protected function setupFS(IUser $user){ |
|
28 | + protected function setupFS(IUser $user) { |
|
29 | 29 | \OC_Util::setupFS($user->getUID()); |
30 | 30 | } |
31 | 31 |
@@ -29,12 +29,12 @@ |
||
29 | 29 | * Wrap a command in the background job interface |
30 | 30 | */ |
31 | 31 | class CommandJob extends QueuedJob { |
32 | - protected function run($serializedCommand) { |
|
33 | - $command = unserialize($serializedCommand); |
|
34 | - if ($command instanceof ICommand) { |
|
35 | - $command->handle(); |
|
36 | - } else { |
|
37 | - throw new \InvalidArgumentException('Invalid serialized command'); |
|
38 | - } |
|
39 | - } |
|
32 | + protected function run($serializedCommand) { |
|
33 | + $command = unserialize($serializedCommand); |
|
34 | + if ($command instanceof ICommand) { |
|
35 | + $command->handle(); |
|
36 | + } else { |
|
37 | + throw new \InvalidArgumentException('Invalid serialized command'); |
|
38 | + } |
|
39 | + } |
|
40 | 40 | } |
@@ -24,23 +24,23 @@ |
||
24 | 24 | namespace OC\Template; |
25 | 25 | |
26 | 26 | class ResourceNotFoundException extends \LogicException { |
27 | - protected $resource; |
|
28 | - protected $webPath; |
|
27 | + protected $resource; |
|
28 | + protected $webPath; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param string $resource |
|
32 | - * @param string $webPath |
|
33 | - */ |
|
34 | - public function __construct($resource, $webPath) { |
|
35 | - parent::__construct('Resource not found'); |
|
36 | - $this->resource = $resource; |
|
37 | - $this->webPath = $webPath; |
|
38 | - } |
|
30 | + /** |
|
31 | + * @param string $resource |
|
32 | + * @param string $webPath |
|
33 | + */ |
|
34 | + public function __construct($resource, $webPath) { |
|
35 | + parent::__construct('Resource not found'); |
|
36 | + $this->resource = $resource; |
|
37 | + $this->webPath = $webPath; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function getResourcePath() { |
|
44 | - return $this->webPath . '/' . $this->resource; |
|
45 | - } |
|
40 | + /** |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function getResourcePath() { |
|
44 | + return $this->webPath . '/' . $this->resource; |
|
45 | + } |
|
46 | 46 | } |
@@ -41,6 +41,6 @@ |
||
41 | 41 | * @return string |
42 | 42 | */ |
43 | 43 | public function getResourcePath() { |
44 | - return $this->webPath . '/' . $this->resource; |
|
44 | + return $this->webPath.'/'.$this->resource; |
|
45 | 45 | } |
46 | 46 | } |
@@ -26,37 +26,37 @@ |
||
26 | 26 | namespace OC\Template; |
27 | 27 | |
28 | 28 | class TemplateFileLocator { |
29 | - protected $dirs; |
|
30 | - private $path; |
|
29 | + protected $dirs; |
|
30 | + private $path; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param string[] $dirs |
|
34 | - */ |
|
35 | - public function __construct( $dirs ) { |
|
36 | - $this->dirs = $dirs; |
|
37 | - } |
|
32 | + /** |
|
33 | + * @param string[] $dirs |
|
34 | + */ |
|
35 | + public function __construct( $dirs ) { |
|
36 | + $this->dirs = $dirs; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $template |
|
41 | - * @return string |
|
42 | - * @throws \Exception |
|
43 | - */ |
|
44 | - public function find( $template ) { |
|
45 | - if ($template === '') { |
|
46 | - throw new \InvalidArgumentException('Empty template name'); |
|
47 | - } |
|
39 | + /** |
|
40 | + * @param string $template |
|
41 | + * @return string |
|
42 | + * @throws \Exception |
|
43 | + */ |
|
44 | + public function find( $template ) { |
|
45 | + if ($template === '') { |
|
46 | + throw new \InvalidArgumentException('Empty template name'); |
|
47 | + } |
|
48 | 48 | |
49 | - foreach($this->dirs as $dir) { |
|
50 | - $file = $dir.$template.'.php'; |
|
51 | - if (is_file($file)) { |
|
52 | - $this->path = $dir; |
|
53 | - return $file; |
|
54 | - } |
|
55 | - } |
|
56 | - throw new \Exception('template file not found: template:'.$template); |
|
57 | - } |
|
49 | + foreach($this->dirs as $dir) { |
|
50 | + $file = $dir.$template.'.php'; |
|
51 | + if (is_file($file)) { |
|
52 | + $this->path = $dir; |
|
53 | + return $file; |
|
54 | + } |
|
55 | + } |
|
56 | + throw new \Exception('template file not found: template:'.$template); |
|
57 | + } |
|
58 | 58 | |
59 | - public function getPath() { |
|
60 | - return $this->path; |
|
61 | - } |
|
59 | + public function getPath() { |
|
60 | + return $this->path; |
|
61 | + } |
|
62 | 62 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @param string[] $dirs |
34 | 34 | */ |
35 | - public function __construct( $dirs ) { |
|
35 | + public function __construct($dirs) { |
|
36 | 36 | $this->dirs = $dirs; |
37 | 37 | } |
38 | 38 | |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | * @return string |
42 | 42 | * @throws \Exception |
43 | 43 | */ |
44 | - public function find( $template ) { |
|
44 | + public function find($template) { |
|
45 | 45 | if ($template === '') { |
46 | 46 | throw new \InvalidArgumentException('Empty template name'); |
47 | 47 | } |
48 | 48 | |
49 | - foreach($this->dirs as $dir) { |
|
49 | + foreach ($this->dirs as $dir) { |
|
50 | 50 | $file = $dir.$template.'.php'; |
51 | 51 | if (is_file($file)) { |
52 | 52 | $this->path = $dir; |