@@ -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 |
@@ -45,285 +45,285 @@ |
||
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::$server->getNavigationManager()->getAll(); |
|
84 | - $this->assign( 'navigation', $navigation); |
|
85 | - $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings'); |
|
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 if ($renderAs == 'public') { |
|
127 | - parent::__construct('core', 'layout.public'); |
|
128 | - $this->assign( 'appid', $appId ); |
|
129 | - $this->assign('bodyid', 'body-public'); |
|
130 | - } else { |
|
131 | - parent::__construct('core', 'layout.base'); |
|
132 | - |
|
133 | - } |
|
134 | - // Send the language to our layouts |
|
135 | - $lang = \OC::$server->getL10NFactory()->findLanguage(); |
|
136 | - $lang = str_replace('_', '-', $lang); |
|
137 | - $this->assign('language', $lang); |
|
138 | - |
|
139 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
140 | - if (empty(self::$versionHash)) { |
|
141 | - $v = \OC_App::getAppVersions(); |
|
142 | - $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
143 | - self::$versionHash = substr(md5(implode(',', $v)), 0, 8); |
|
144 | - } |
|
145 | - } else { |
|
146 | - self::$versionHash = md5('not installed'); |
|
147 | - } |
|
148 | - |
|
149 | - // Add the js files |
|
150 | - $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
151 | - $this->assign('jsfiles', array()); |
|
152 | - if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
153 | - if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
154 | - $jsConfigHelper = new JSConfigHelper( |
|
155 | - \OC::$server->getL10N('lib'), |
|
156 | - \OC::$server->query(Defaults::class), |
|
157 | - \OC::$server->getAppManager(), |
|
158 | - \OC::$server->getSession(), |
|
159 | - \OC::$server->getUserSession()->getUser(), |
|
160 | - $this->config, |
|
161 | - \OC::$server->getGroupManager(), |
|
162 | - \OC::$server->getIniWrapper(), |
|
163 | - \OC::$server->getURLGenerator(), |
|
164 | - \OC::$server->getCapabilitiesManager() |
|
165 | - ); |
|
166 | - $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
167 | - } else { |
|
168 | - $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
169 | - } |
|
170 | - } |
|
171 | - foreach($jsFiles as $info) { |
|
172 | - $web = $info[1]; |
|
173 | - $file = $info[2]; |
|
174 | - $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
175 | - } |
|
176 | - |
|
177 | - try { |
|
178 | - $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
179 | - } catch (\Exception $e) { |
|
180 | - $pathInfo = ''; |
|
181 | - } |
|
182 | - |
|
183 | - // Do not initialise scss appdata until we have a fully installed instance |
|
184 | - // Do not load scss for update, errors, installation or login page |
|
185 | - if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
186 | - && !\OCP\Util::needUpgrade() |
|
187 | - && $pathInfo !== '' |
|
188 | - && !preg_match('/^\/login/', $pathInfo) |
|
189 | - && $renderAs !== 'error' && $renderAs !== 'guest' |
|
190 | - ) { |
|
191 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
192 | - } else { |
|
193 | - // If we ignore the scss compiler, |
|
194 | - // we need to load the guest css fallback |
|
195 | - \OC_Util::addStyle('guest'); |
|
196 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
197 | - } |
|
198 | - |
|
199 | - $this->assign('cssfiles', array()); |
|
200 | - $this->assign('printcssfiles', []); |
|
201 | - $this->assign('versionHash', self::$versionHash); |
|
202 | - foreach($cssFiles as $info) { |
|
203 | - $web = $info[1]; |
|
204 | - $file = $info[2]; |
|
205 | - |
|
206 | - if (substr($file, -strlen('print.css')) === 'print.css') { |
|
207 | - $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
208 | - } else { |
|
209 | - $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file) ); |
|
210 | - } |
|
211 | - } |
|
212 | - } |
|
213 | - |
|
214 | - /** |
|
215 | - * @param string $path |
|
216 | - * @param string $file |
|
217 | - * @return string |
|
218 | - */ |
|
219 | - protected function getVersionHashSuffix($path = false, $file = false) { |
|
220 | - if ($this->config->getSystemValue('debug', false)) { |
|
221 | - // allows chrome workspace mapping in debug mode |
|
222 | - return ""; |
|
223 | - } |
|
224 | - $themingSuffix = ''; |
|
225 | - $v = []; |
|
226 | - |
|
227 | - if ($this->config->getSystemValue('installed', false)) { |
|
228 | - if (\OC::$server->getAppManager()->isInstalled('theming')) { |
|
229 | - $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
230 | - } |
|
231 | - $v = \OC_App::getAppVersions(); |
|
232 | - } |
|
233 | - |
|
234 | - // Try the webroot path for a match |
|
235 | - if ($path !== false && $path !== '') { |
|
236 | - $appName = $this->getAppNamefromPath($path); |
|
237 | - if(array_key_exists($appName, $v)) { |
|
238 | - $appVersion = $v[$appName]; |
|
239 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
240 | - } |
|
241 | - } |
|
242 | - // fallback to the file path instead |
|
243 | - if ($file !== false && $file !== '') { |
|
244 | - $appName = $this->getAppNamefromPath($file); |
|
245 | - if(array_key_exists($appName, $v)) { |
|
246 | - $appVersion = $v[$appName]; |
|
247 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
248 | - } |
|
249 | - } |
|
250 | - |
|
251 | - return '?v=' . self::$versionHash . $themingSuffix; |
|
252 | - } |
|
253 | - |
|
254 | - /** |
|
255 | - * @param array $styles |
|
256 | - * @return array |
|
257 | - */ |
|
258 | - static public function findStylesheetFiles($styles, $compileScss = true) { |
|
259 | - // Read the selected theme from the config file |
|
260 | - $theme = \OC_Util::getTheme(); |
|
261 | - |
|
262 | - if($compileScss) { |
|
263 | - $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
|
264 | - } else { |
|
265 | - $SCSSCacher = null; |
|
266 | - } |
|
267 | - |
|
268 | - $locator = new \OC\Template\CSSResourceLocator( |
|
269 | - \OC::$server->getLogger(), |
|
270 | - $theme, |
|
271 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
272 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
273 | - $SCSSCacher |
|
274 | - ); |
|
275 | - $locator->find($styles); |
|
276 | - return $locator->getResources(); |
|
277 | - } |
|
278 | - |
|
279 | - /** |
|
280 | - * @param string $path |
|
281 | - * @return string|boolean |
|
282 | - */ |
|
283 | - public function getAppNamefromPath($path) { |
|
284 | - if ($path !== '' && is_string($path)) { |
|
285 | - $pathParts = explode('/', $path); |
|
286 | - if ($pathParts[0] === 'css') { |
|
287 | - // This is a scss request |
|
288 | - return $pathParts[1]; |
|
289 | - } |
|
290 | - return end($pathParts); |
|
291 | - } |
|
292 | - return false; |
|
293 | - |
|
294 | - } |
|
295 | - |
|
296 | - /** |
|
297 | - * @param array $scripts |
|
298 | - * @return array |
|
299 | - */ |
|
300 | - static public function findJavascriptFiles($scripts) { |
|
301 | - // Read the selected theme from the config file |
|
302 | - $theme = \OC_Util::getTheme(); |
|
303 | - |
|
304 | - $locator = new \OC\Template\JSResourceLocator( |
|
305 | - \OC::$server->getLogger(), |
|
306 | - $theme, |
|
307 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
308 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
309 | - \OC::$server->query(JSCombiner::class) |
|
310 | - ); |
|
311 | - $locator->find($scripts); |
|
312 | - return $locator->getResources(); |
|
313 | - } |
|
314 | - |
|
315 | - /** |
|
316 | - * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
317 | - * @param string $filePath Absolute path |
|
318 | - * @return string Relative path |
|
319 | - * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
320 | - */ |
|
321 | - public static function convertToRelativePath($filePath) { |
|
322 | - $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
323 | - if(count($relativePath) !== 2) { |
|
324 | - throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
325 | - } |
|
326 | - |
|
327 | - return $relativePath[1]; |
|
328 | - } |
|
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::$server->getNavigationManager()->getAll(); |
|
84 | + $this->assign( 'navigation', $navigation); |
|
85 | + $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings'); |
|
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 if ($renderAs == 'public') { |
|
127 | + parent::__construct('core', 'layout.public'); |
|
128 | + $this->assign( 'appid', $appId ); |
|
129 | + $this->assign('bodyid', 'body-public'); |
|
130 | + } else { |
|
131 | + parent::__construct('core', 'layout.base'); |
|
132 | + |
|
133 | + } |
|
134 | + // Send the language to our layouts |
|
135 | + $lang = \OC::$server->getL10NFactory()->findLanguage(); |
|
136 | + $lang = str_replace('_', '-', $lang); |
|
137 | + $this->assign('language', $lang); |
|
138 | + |
|
139 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
140 | + if (empty(self::$versionHash)) { |
|
141 | + $v = \OC_App::getAppVersions(); |
|
142 | + $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
143 | + self::$versionHash = substr(md5(implode(',', $v)), 0, 8); |
|
144 | + } |
|
145 | + } else { |
|
146 | + self::$versionHash = md5('not installed'); |
|
147 | + } |
|
148 | + |
|
149 | + // Add the js files |
|
150 | + $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
151 | + $this->assign('jsfiles', array()); |
|
152 | + if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
153 | + if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
154 | + $jsConfigHelper = new JSConfigHelper( |
|
155 | + \OC::$server->getL10N('lib'), |
|
156 | + \OC::$server->query(Defaults::class), |
|
157 | + \OC::$server->getAppManager(), |
|
158 | + \OC::$server->getSession(), |
|
159 | + \OC::$server->getUserSession()->getUser(), |
|
160 | + $this->config, |
|
161 | + \OC::$server->getGroupManager(), |
|
162 | + \OC::$server->getIniWrapper(), |
|
163 | + \OC::$server->getURLGenerator(), |
|
164 | + \OC::$server->getCapabilitiesManager() |
|
165 | + ); |
|
166 | + $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
167 | + } else { |
|
168 | + $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
169 | + } |
|
170 | + } |
|
171 | + foreach($jsFiles as $info) { |
|
172 | + $web = $info[1]; |
|
173 | + $file = $info[2]; |
|
174 | + $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
175 | + } |
|
176 | + |
|
177 | + try { |
|
178 | + $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
179 | + } catch (\Exception $e) { |
|
180 | + $pathInfo = ''; |
|
181 | + } |
|
182 | + |
|
183 | + // Do not initialise scss appdata until we have a fully installed instance |
|
184 | + // Do not load scss for update, errors, installation or login page |
|
185 | + if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
186 | + && !\OCP\Util::needUpgrade() |
|
187 | + && $pathInfo !== '' |
|
188 | + && !preg_match('/^\/login/', $pathInfo) |
|
189 | + && $renderAs !== 'error' && $renderAs !== 'guest' |
|
190 | + ) { |
|
191 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
192 | + } else { |
|
193 | + // If we ignore the scss compiler, |
|
194 | + // we need to load the guest css fallback |
|
195 | + \OC_Util::addStyle('guest'); |
|
196 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
197 | + } |
|
198 | + |
|
199 | + $this->assign('cssfiles', array()); |
|
200 | + $this->assign('printcssfiles', []); |
|
201 | + $this->assign('versionHash', self::$versionHash); |
|
202 | + foreach($cssFiles as $info) { |
|
203 | + $web = $info[1]; |
|
204 | + $file = $info[2]; |
|
205 | + |
|
206 | + if (substr($file, -strlen('print.css')) === 'print.css') { |
|
207 | + $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
208 | + } else { |
|
209 | + $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file) ); |
|
210 | + } |
|
211 | + } |
|
212 | + } |
|
213 | + |
|
214 | + /** |
|
215 | + * @param string $path |
|
216 | + * @param string $file |
|
217 | + * @return string |
|
218 | + */ |
|
219 | + protected function getVersionHashSuffix($path = false, $file = false) { |
|
220 | + if ($this->config->getSystemValue('debug', false)) { |
|
221 | + // allows chrome workspace mapping in debug mode |
|
222 | + return ""; |
|
223 | + } |
|
224 | + $themingSuffix = ''; |
|
225 | + $v = []; |
|
226 | + |
|
227 | + if ($this->config->getSystemValue('installed', false)) { |
|
228 | + if (\OC::$server->getAppManager()->isInstalled('theming')) { |
|
229 | + $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
230 | + } |
|
231 | + $v = \OC_App::getAppVersions(); |
|
232 | + } |
|
233 | + |
|
234 | + // Try the webroot path for a match |
|
235 | + if ($path !== false && $path !== '') { |
|
236 | + $appName = $this->getAppNamefromPath($path); |
|
237 | + if(array_key_exists($appName, $v)) { |
|
238 | + $appVersion = $v[$appName]; |
|
239 | + return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
240 | + } |
|
241 | + } |
|
242 | + // fallback to the file path instead |
|
243 | + if ($file !== false && $file !== '') { |
|
244 | + $appName = $this->getAppNamefromPath($file); |
|
245 | + if(array_key_exists($appName, $v)) { |
|
246 | + $appVersion = $v[$appName]; |
|
247 | + return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
248 | + } |
|
249 | + } |
|
250 | + |
|
251 | + return '?v=' . self::$versionHash . $themingSuffix; |
|
252 | + } |
|
253 | + |
|
254 | + /** |
|
255 | + * @param array $styles |
|
256 | + * @return array |
|
257 | + */ |
|
258 | + static public function findStylesheetFiles($styles, $compileScss = true) { |
|
259 | + // Read the selected theme from the config file |
|
260 | + $theme = \OC_Util::getTheme(); |
|
261 | + |
|
262 | + if($compileScss) { |
|
263 | + $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
|
264 | + } else { |
|
265 | + $SCSSCacher = null; |
|
266 | + } |
|
267 | + |
|
268 | + $locator = new \OC\Template\CSSResourceLocator( |
|
269 | + \OC::$server->getLogger(), |
|
270 | + $theme, |
|
271 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
272 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
273 | + $SCSSCacher |
|
274 | + ); |
|
275 | + $locator->find($styles); |
|
276 | + return $locator->getResources(); |
|
277 | + } |
|
278 | + |
|
279 | + /** |
|
280 | + * @param string $path |
|
281 | + * @return string|boolean |
|
282 | + */ |
|
283 | + public function getAppNamefromPath($path) { |
|
284 | + if ($path !== '' && is_string($path)) { |
|
285 | + $pathParts = explode('/', $path); |
|
286 | + if ($pathParts[0] === 'css') { |
|
287 | + // This is a scss request |
|
288 | + return $pathParts[1]; |
|
289 | + } |
|
290 | + return end($pathParts); |
|
291 | + } |
|
292 | + return false; |
|
293 | + |
|
294 | + } |
|
295 | + |
|
296 | + /** |
|
297 | + * @param array $scripts |
|
298 | + * @return array |
|
299 | + */ |
|
300 | + static public function findJavascriptFiles($scripts) { |
|
301 | + // Read the selected theme from the config file |
|
302 | + $theme = \OC_Util::getTheme(); |
|
303 | + |
|
304 | + $locator = new \OC\Template\JSResourceLocator( |
|
305 | + \OC::$server->getLogger(), |
|
306 | + $theme, |
|
307 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
308 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
309 | + \OC::$server->query(JSCombiner::class) |
|
310 | + ); |
|
311 | + $locator->find($scripts); |
|
312 | + return $locator->getResources(); |
|
313 | + } |
|
314 | + |
|
315 | + /** |
|
316 | + * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
317 | + * @param string $filePath Absolute path |
|
318 | + * @return string Relative path |
|
319 | + * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
320 | + */ |
|
321 | + public static function convertToRelativePath($filePath) { |
|
322 | + $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
323 | + if(count($relativePath) !== 2) { |
|
324 | + throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
325 | + } |
|
326 | + |
|
327 | + return $relativePath[1]; |
|
328 | + } |
|
329 | 329 | } |
@@ -56,44 +56,44 @@ discard block |
||
56 | 56 | * @param string $renderAs |
57 | 57 | * @param string $appId application id |
58 | 58 | */ |
59 | - public function __construct( $renderAs, $appId = '' ) { |
|
59 | + public function __construct($renderAs, $appId = '') { |
|
60 | 60 | |
61 | 61 | // yes - should be injected .... |
62 | 62 | $this->config = \OC::$server->getConfig(); |
63 | 63 | |
64 | 64 | |
65 | 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) { |
|
66 | + if ($renderAs == 'user') { |
|
67 | + parent::__construct('core', 'layout.user'); |
|
68 | + if (in_array(\OC_App::getCurrentApp(), ['settings', 'admin', 'help']) !== false) { |
|
69 | 69 | $this->assign('bodyid', 'body-settings'); |
70 | - }else{ |
|
70 | + } else { |
|
71 | 71 | $this->assign('bodyid', 'body-user'); |
72 | 72 | } |
73 | 73 | |
74 | 74 | // Code integrity notification |
75 | 75 | $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
76 | - if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
76 | + if (\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
77 | 77 | \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // Add navigation entry |
81 | - $this->assign( 'application', ''); |
|
82 | - $this->assign( 'appid', $appId ); |
|
81 | + $this->assign('application', ''); |
|
82 | + $this->assign('appid', $appId); |
|
83 | 83 | $navigation = \OC::$server->getNavigationManager()->getAll(); |
84 | - $this->assign( 'navigation', $navigation); |
|
84 | + $this->assign('navigation', $navigation); |
|
85 | 85 | $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings'); |
86 | - $this->assign( 'settingsnavigation', $settingsNavigation); |
|
87 | - foreach($navigation as $entry) { |
|
86 | + $this->assign('settingsnavigation', $settingsNavigation); |
|
87 | + foreach ($navigation as $entry) { |
|
88 | 88 | if ($entry['active']) { |
89 | - $this->assign( 'application', $entry['name'] ); |
|
89 | + $this->assign('application', $entry['name']); |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | - foreach($settingsNavigation as $entry) { |
|
94 | + foreach ($settingsNavigation as $entry) { |
|
95 | 95 | if ($entry['active']) { |
96 | - $this->assign( 'application', $entry['name'] ); |
|
96 | + $this->assign('application', $entry['name']); |
|
97 | 97 | break; |
98 | 98 | } |
99 | 99 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $this->assign('bodyid', 'body-login'); |
126 | 126 | } else if ($renderAs == 'public') { |
127 | 127 | parent::__construct('core', 'layout.public'); |
128 | - $this->assign( 'appid', $appId ); |
|
128 | + $this->assign('appid', $appId); |
|
129 | 129 | $this->assign('bodyid', 'body-public'); |
130 | 130 | } else { |
131 | 131 | parent::__construct('core', 'layout.base'); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $lang = str_replace('_', '-', $lang); |
137 | 137 | $this->assign('language', $lang); |
138 | 138 | |
139 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
139 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
140 | 140 | if (empty(self::$versionHash)) { |
141 | 141 | $v = \OC_App::getAppVersions(); |
142 | 142 | $v['core'] = implode('.', \OCP\Util::getVersion()); |
@@ -168,10 +168,10 @@ discard block |
||
168 | 168 | $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
169 | 169 | } |
170 | 170 | } |
171 | - foreach($jsFiles as $info) { |
|
171 | + foreach ($jsFiles as $info) { |
|
172 | 172 | $web = $info[1]; |
173 | 173 | $file = $info[2]; |
174 | - $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
174 | + $this->append('jsfiles', $web.'/'.$file.$this->getVersionHashSuffix()); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | try { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | // Do not initialise scss appdata until we have a fully installed instance |
184 | 184 | // Do not load scss for update, errors, installation or login page |
185 | - if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
185 | + if (\OC::$server->getSystemConfig()->getValue('installed', false) |
|
186 | 186 | && !\OCP\Util::needUpgrade() |
187 | 187 | && $pathInfo !== '' |
188 | 188 | && !preg_match('/^\/login/', $pathInfo) |
@@ -199,14 +199,14 @@ discard block |
||
199 | 199 | $this->assign('cssfiles', array()); |
200 | 200 | $this->assign('printcssfiles', []); |
201 | 201 | $this->assign('versionHash', self::$versionHash); |
202 | - foreach($cssFiles as $info) { |
|
202 | + foreach ($cssFiles as $info) { |
|
203 | 203 | $web = $info[1]; |
204 | 204 | $file = $info[2]; |
205 | 205 | |
206 | 206 | if (substr($file, -strlen('print.css')) === 'print.css') { |
207 | - $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
207 | + $this->append('printcssfiles', $web.'/'.$file.$this->getVersionHashSuffix()); |
|
208 | 208 | } else { |
209 | - $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file) ); |
|
209 | + $this->append('cssfiles', $web.'/'.$file.$this->getVersionHashSuffix($web, $file)); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | if ($this->config->getSystemValue('installed', false)) { |
228 | 228 | if (\OC::$server->getAppManager()->isInstalled('theming')) { |
229 | - $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
229 | + $themingSuffix = '-'.$this->config->getAppValue('theming', 'cachebuster', '0'); |
|
230 | 230 | } |
231 | 231 | $v = \OC_App::getAppVersions(); |
232 | 232 | } |
@@ -234,21 +234,21 @@ discard block |
||
234 | 234 | // Try the webroot path for a match |
235 | 235 | if ($path !== false && $path !== '') { |
236 | 236 | $appName = $this->getAppNamefromPath($path); |
237 | - if(array_key_exists($appName, $v)) { |
|
237 | + if (array_key_exists($appName, $v)) { |
|
238 | 238 | $appVersion = $v[$appName]; |
239 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
239 | + return '?v='.substr(md5($appVersion), 0, 8).$themingSuffix; |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | // fallback to the file path instead |
243 | 243 | if ($file !== false && $file !== '') { |
244 | 244 | $appName = $this->getAppNamefromPath($file); |
245 | - if(array_key_exists($appName, $v)) { |
|
245 | + if (array_key_exists($appName, $v)) { |
|
246 | 246 | $appVersion = $v[$appName]; |
247 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
247 | + return '?v='.substr(md5($appVersion), 0, 8).$themingSuffix; |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | - return '?v=' . self::$versionHash . $themingSuffix; |
|
251 | + return '?v='.self::$versionHash.$themingSuffix; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | // Read the selected theme from the config file |
260 | 260 | $theme = \OC_Util::getTheme(); |
261 | 261 | |
262 | - if($compileScss) { |
|
262 | + if ($compileScss) { |
|
263 | 263 | $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
264 | 264 | } else { |
265 | 265 | $SCSSCacher = null; |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | $locator = new \OC\Template\CSSResourceLocator( |
269 | 269 | \OC::$server->getLogger(), |
270 | 270 | $theme, |
271 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
272 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
271 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
272 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
273 | 273 | $SCSSCacher |
274 | 274 | ); |
275 | 275 | $locator->find($styles); |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | $locator = new \OC\Template\JSResourceLocator( |
305 | 305 | \OC::$server->getLogger(), |
306 | 306 | $theme, |
307 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
308 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
307 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
308 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
309 | 309 | \OC::$server->query(JSCombiner::class) |
310 | 310 | ); |
311 | 311 | $locator->find($scripts); |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public static function convertToRelativePath($filePath) { |
322 | 322 | $relativePath = explode(\OC::$SERVERROOT, $filePath); |
323 | - if(count($relativePath) !== 2) { |
|
323 | + if (count($relativePath) !== 2) { |
|
324 | 324 | throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
325 | 325 | } |
326 | 326 |
@@ -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 |
@@ -37,81 +37,81 @@ |
||
37 | 37 | */ |
38 | 38 | class BackgroundRepair extends TimedJob { |
39 | 39 | |
40 | - /** @var IJobList */ |
|
41 | - private $jobList; |
|
40 | + /** @var IJobList */ |
|
41 | + private $jobList; |
|
42 | 42 | |
43 | - /** @var ILogger */ |
|
44 | - private $logger; |
|
43 | + /** @var ILogger */ |
|
44 | + private $logger; |
|
45 | 45 | |
46 | - /** @var EventDispatcher */ |
|
47 | - private $dispatcher; |
|
46 | + /** @var EventDispatcher */ |
|
47 | + private $dispatcher; |
|
48 | 48 | |
49 | - public function setDispatcher(EventDispatcher $dispatcher) { |
|
50 | - $this->dispatcher = $dispatcher; |
|
51 | - } |
|
52 | - /** |
|
53 | - * run the job, then remove it from the job list |
|
54 | - * |
|
55 | - * @param JobList $jobList |
|
56 | - * @param ILogger|null $logger |
|
57 | - */ |
|
58 | - public function execute($jobList, ILogger $logger = null) { |
|
59 | - // add an interval of 15 mins |
|
60 | - $this->setInterval(15*60); |
|
49 | + public function setDispatcher(EventDispatcher $dispatcher) { |
|
50 | + $this->dispatcher = $dispatcher; |
|
51 | + } |
|
52 | + /** |
|
53 | + * run the job, then remove it from the job list |
|
54 | + * |
|
55 | + * @param JobList $jobList |
|
56 | + * @param ILogger|null $logger |
|
57 | + */ |
|
58 | + public function execute($jobList, ILogger $logger = null) { |
|
59 | + // add an interval of 15 mins |
|
60 | + $this->setInterval(15*60); |
|
61 | 61 | |
62 | - $this->jobList = $jobList; |
|
63 | - $this->logger = $logger; |
|
64 | - parent::execute($jobList, $logger); |
|
65 | - } |
|
62 | + $this->jobList = $jobList; |
|
63 | + $this->logger = $logger; |
|
64 | + parent::execute($jobList, $logger); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @param array $argument |
|
69 | - * @throws \Exception |
|
70 | - * @throws \OC\NeedsUpdateException |
|
71 | - */ |
|
72 | - protected function run($argument) { |
|
73 | - if (!isset($argument['app']) || !isset($argument['step'])) { |
|
74 | - // remove the job - we can never execute it |
|
75 | - $this->jobList->remove($this, $this->argument); |
|
76 | - return; |
|
77 | - } |
|
78 | - $app = $argument['app']; |
|
67 | + /** |
|
68 | + * @param array $argument |
|
69 | + * @throws \Exception |
|
70 | + * @throws \OC\NeedsUpdateException |
|
71 | + */ |
|
72 | + protected function run($argument) { |
|
73 | + if (!isset($argument['app']) || !isset($argument['step'])) { |
|
74 | + // remove the job - we can never execute it |
|
75 | + $this->jobList->remove($this, $this->argument); |
|
76 | + return; |
|
77 | + } |
|
78 | + $app = $argument['app']; |
|
79 | 79 | |
80 | - try { |
|
81 | - $this->loadApp($app); |
|
82 | - } catch (NeedsUpdateException $ex) { |
|
83 | - // as long as the app is not yet done with it's offline migration |
|
84 | - // we better not start with the live migration |
|
85 | - return; |
|
86 | - } |
|
80 | + try { |
|
81 | + $this->loadApp($app); |
|
82 | + } catch (NeedsUpdateException $ex) { |
|
83 | + // as long as the app is not yet done with it's offline migration |
|
84 | + // we better not start with the live migration |
|
85 | + return; |
|
86 | + } |
|
87 | 87 | |
88 | - $step = $argument['step']; |
|
89 | - $repair = new Repair([], $this->dispatcher); |
|
90 | - try { |
|
91 | - $repair->addStep($step); |
|
92 | - } catch (\Exception $ex) { |
|
93 | - $this->logger->logException($ex,[ |
|
94 | - 'app' => 'migration' |
|
95 | - ]); |
|
88 | + $step = $argument['step']; |
|
89 | + $repair = new Repair([], $this->dispatcher); |
|
90 | + try { |
|
91 | + $repair->addStep($step); |
|
92 | + } catch (\Exception $ex) { |
|
93 | + $this->logger->logException($ex,[ |
|
94 | + 'app' => 'migration' |
|
95 | + ]); |
|
96 | 96 | |
97 | - // remove the job - we can never execute it |
|
98 | - $this->jobList->remove($this, $this->argument); |
|
99 | - return; |
|
100 | - } |
|
97 | + // remove the job - we can never execute it |
|
98 | + $this->jobList->remove($this, $this->argument); |
|
99 | + return; |
|
100 | + } |
|
101 | 101 | |
102 | - // execute the repair step |
|
103 | - $repair->run(); |
|
102 | + // execute the repair step |
|
103 | + $repair->run(); |
|
104 | 104 | |
105 | - // remove the job once executed successfully |
|
106 | - $this->jobList->remove($this, $this->argument); |
|
107 | - } |
|
105 | + // remove the job once executed successfully |
|
106 | + $this->jobList->remove($this, $this->argument); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @codeCoverageIgnore |
|
111 | - * @param $app |
|
112 | - * @throws NeedsUpdateException |
|
113 | - */ |
|
114 | - protected function loadApp($app) { |
|
115 | - OC_App::loadApp($app); |
|
116 | - } |
|
109 | + /** |
|
110 | + * @codeCoverageIgnore |
|
111 | + * @param $app |
|
112 | + * @throws NeedsUpdateException |
|
113 | + */ |
|
114 | + protected function loadApp($app) { |
|
115 | + OC_App::loadApp($app); |
|
116 | + } |
|
117 | 117 | } |
@@ -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; |