Completed
Pull Request — master (#5719)
by Morris
13:14
created
lib/private/Template/JSCombiner.php 2 patches
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -33,192 +33,192 @@
 block discarded – undo
33 33
 
34 34
 class JSCombiner {
35 35
 
36
-	/** @var IAppData */
37
-	protected $appData;
38
-
39
-	/** @var IURLGenerator */
40
-	protected $urlGenerator;
41
-
42
-	/** @var ICache */
43
-	protected $depsCache;
44
-
45
-	/** @var SystemConfig */
46
-	protected $config;
47
-
48
-	/** @var ILogger */
49
-	protected $logger;
50
-
51
-	/**
52
-	 * @param IAppData $appData
53
-	 * @param IURLGenerator $urlGenerator
54
-	 * @param ICache $depsCache
55
-	 * @param SystemConfig $config
56
-	 * @param ILogger $logger
57
-	 */
58
-	public function __construct(IAppData $appData,
59
-								IURLGenerator $urlGenerator,
60
-								ICache $depsCache,
61
-								SystemConfig $config,
62
-								ILogger $logger) {
63
-		$this->appData = $appData;
64
-		$this->urlGenerator = $urlGenerator;
65
-		$this->depsCache = $depsCache;
66
-		$this->config = $config;
67
-		$this->logger = $logger;
68
-	}
69
-
70
-	/**
71
-	 * @param string $root
72
-	 * @param string $file
73
-	 * @param string $app
74
-	 * @return bool
75
-	 */
76
-	public function process($root, $file, $app) {
77
-		if ($this->config->getValue('debug') || !$this->config->getValue('installed')) {
78
-			return false;
79
-		}
80
-
81
-		$path = explode('/', $root . '/' . $file);
82
-
83
-		$fileName = array_pop($path);
84
-		$path = implode('/', $path);
85
-
86
-		try {
87
-			$folder = $this->appData->getFolder($app);
88
-		} catch(NotFoundException $e) {
89
-			// creating css appdata folder
90
-			$folder = $this->appData->newFolder($app);
91
-		}
92
-
93
-		if($this->isCached($fileName, $folder)) {
94
-			return true;
95
-		}
96
-		return $this->cache($path, $fileName, $folder);
97
-	}
98
-
99
-	/**
100
-	 * @param string $fileName
101
-	 * @param ISimpleFolder $folder
102
-	 * @return bool
103
-	 */
104
-	protected function isCached($fileName, ISimpleFolder $folder) {
105
-		$fileName = str_replace('.json', '.js', $fileName) . '.deps';
106
-		try {
107
-			$deps = $this->depsCache->get($folder->getName() . '-' . $fileName);
108
-			if ($deps === null || $deps === '') {
109
-				$depFile = $folder->getFile($fileName);
110
-				$deps = $depFile->getContent();
111
-			}
112
-			// check again
113
-			if ($deps === null || $deps === '') {
114
-				$this->logger->info('JSCombiner: deps file empty: ' . $fileName);
115
-				return false;
116
-			}
117
-
118
-			$deps = json_decode($deps, true);
119
-
120
-			foreach ($deps as $file=>$mtime) {
121
-				if (!file_exists($file) || filemtime($file) > $mtime) {
122
-					return false;
123
-				}
124
-			}
125
-
126
-			return true;
127
-		} catch(NotFoundException $e) {
128
-			return false;
129
-		}
130
-	}
131
-
132
-	/**
133
-	 * @param string $path
134
-	 * @param string $fileName
135
-	 * @param ISimpleFolder $folder
136
-	 * @return bool
137
-	 */
138
-	protected function cache($path, $fileName, ISimpleFolder $folder) {
139
-		$deps = [];
140
-		$fullPath = $path . '/' . $fileName;
141
-		$data = json_decode(file_get_contents($fullPath));
142
-		$deps[$fullPath] = filemtime($fullPath);
143
-
144
-		$res = '';
145
-		foreach ($data as $file) {
146
-			$filePath = $path . '/' . $file;
147
-
148
-			if (is_file($filePath)) {
149
-				$res .= file_get_contents($filePath);
150
-				$res .= PHP_EOL . PHP_EOL;
151
-				$deps[$filePath] = filemtime($filePath);
152
-			}
153
-		}
154
-
155
-		$fileName = str_replace('.json', '.js', $fileName);
156
-		try {
157
-			$cachedfile = $folder->getFile($fileName);
158
-		} catch(NotFoundException $e) {
159
-			$cachedfile = $folder->newFile($fileName);
160
-		}
161
-
162
-		$depFileName = $fileName . '.deps';
163
-		try {
164
-			$depFile = $folder->getFile($depFileName);
165
-		} catch (NotFoundException $e) {
166
-			$depFile = $folder->newFile($depFileName);
167
-		}
168
-
169
-		try {
170
-			$gzipFile = $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz
171
-		} catch (NotFoundException $e) {
172
-			$gzipFile = $folder->newFile($fileName . '.gzip'); # Safari doesn't like .gz
173
-		}
174
-
175
-		try {
176
-			$cachedfile->putContent($res);
177
-			$deps = json_encode($deps);
178
-			$depFile->putContent($deps);
179
-			$this->depsCache->set($folder->getName() . '-' . $depFileName, $deps);
180
-			$gzipFile->putContent(gzencode($res, 9));
181
-
182
-			return true;
183
-		} catch (NotPermittedException $e) {
184
-			return false;
185
-		}
186
-	}
187
-
188
-	/**
189
-	 * @param string $appName
190
-	 * @param string $fileName
191
-	 * @return string
192
-	 */
193
-	public function getCachedJS($appName, $fileName) {
194
-		$tmpfileLoc = explode('/', $fileName);
195
-		$fileName = array_pop($tmpfileLoc);
196
-		$fileName = str_replace('.json', '.js', $fileName);
197
-
198
-		return substr($this->urlGenerator->linkToRoute('core.Js.getJs', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1);
199
-	}
200
-
201
-	/**
202
-	 * @param string $root
203
-	 * @param string $file
204
-	 * @return string[]
205
-	 */
206
-	public function getContent($root, $file) {
207
-		/** @var array $data */
208
-		$data = json_decode(file_get_contents($root . '/' . $file));
209
-		if(!is_array($data)) {
210
-			return [];
211
-		}
212
-
213
-		$path = explode('/', $file);
214
-		array_pop($path);
215
-		$path = implode('/', $path);
216
-
217
-		$result = [];
218
-		foreach ($data as $f) {
219
-			$result[] = $path . '/' . $f;
220
-		}
221
-
222
-		return $result;
223
-	}
36
+    /** @var IAppData */
37
+    protected $appData;
38
+
39
+    /** @var IURLGenerator */
40
+    protected $urlGenerator;
41
+
42
+    /** @var ICache */
43
+    protected $depsCache;
44
+
45
+    /** @var SystemConfig */
46
+    protected $config;
47
+
48
+    /** @var ILogger */
49
+    protected $logger;
50
+
51
+    /**
52
+     * @param IAppData $appData
53
+     * @param IURLGenerator $urlGenerator
54
+     * @param ICache $depsCache
55
+     * @param SystemConfig $config
56
+     * @param ILogger $logger
57
+     */
58
+    public function __construct(IAppData $appData,
59
+                                IURLGenerator $urlGenerator,
60
+                                ICache $depsCache,
61
+                                SystemConfig $config,
62
+                                ILogger $logger) {
63
+        $this->appData = $appData;
64
+        $this->urlGenerator = $urlGenerator;
65
+        $this->depsCache = $depsCache;
66
+        $this->config = $config;
67
+        $this->logger = $logger;
68
+    }
69
+
70
+    /**
71
+     * @param string $root
72
+     * @param string $file
73
+     * @param string $app
74
+     * @return bool
75
+     */
76
+    public function process($root, $file, $app) {
77
+        if ($this->config->getValue('debug') || !$this->config->getValue('installed')) {
78
+            return false;
79
+        }
80
+
81
+        $path = explode('/', $root . '/' . $file);
82
+
83
+        $fileName = array_pop($path);
84
+        $path = implode('/', $path);
85
+
86
+        try {
87
+            $folder = $this->appData->getFolder($app);
88
+        } catch(NotFoundException $e) {
89
+            // creating css appdata folder
90
+            $folder = $this->appData->newFolder($app);
91
+        }
92
+
93
+        if($this->isCached($fileName, $folder)) {
94
+            return true;
95
+        }
96
+        return $this->cache($path, $fileName, $folder);
97
+    }
98
+
99
+    /**
100
+     * @param string $fileName
101
+     * @param ISimpleFolder $folder
102
+     * @return bool
103
+     */
104
+    protected function isCached($fileName, ISimpleFolder $folder) {
105
+        $fileName = str_replace('.json', '.js', $fileName) . '.deps';
106
+        try {
107
+            $deps = $this->depsCache->get($folder->getName() . '-' . $fileName);
108
+            if ($deps === null || $deps === '') {
109
+                $depFile = $folder->getFile($fileName);
110
+                $deps = $depFile->getContent();
111
+            }
112
+            // check again
113
+            if ($deps === null || $deps === '') {
114
+                $this->logger->info('JSCombiner: deps file empty: ' . $fileName);
115
+                return false;
116
+            }
117
+
118
+            $deps = json_decode($deps, true);
119
+
120
+            foreach ($deps as $file=>$mtime) {
121
+                if (!file_exists($file) || filemtime($file) > $mtime) {
122
+                    return false;
123
+                }
124
+            }
125
+
126
+            return true;
127
+        } catch(NotFoundException $e) {
128
+            return false;
129
+        }
130
+    }
131
+
132
+    /**
133
+     * @param string $path
134
+     * @param string $fileName
135
+     * @param ISimpleFolder $folder
136
+     * @return bool
137
+     */
138
+    protected function cache($path, $fileName, ISimpleFolder $folder) {
139
+        $deps = [];
140
+        $fullPath = $path . '/' . $fileName;
141
+        $data = json_decode(file_get_contents($fullPath));
142
+        $deps[$fullPath] = filemtime($fullPath);
143
+
144
+        $res = '';
145
+        foreach ($data as $file) {
146
+            $filePath = $path . '/' . $file;
147
+
148
+            if (is_file($filePath)) {
149
+                $res .= file_get_contents($filePath);
150
+                $res .= PHP_EOL . PHP_EOL;
151
+                $deps[$filePath] = filemtime($filePath);
152
+            }
153
+        }
154
+
155
+        $fileName = str_replace('.json', '.js', $fileName);
156
+        try {
157
+            $cachedfile = $folder->getFile($fileName);
158
+        } catch(NotFoundException $e) {
159
+            $cachedfile = $folder->newFile($fileName);
160
+        }
161
+
162
+        $depFileName = $fileName . '.deps';
163
+        try {
164
+            $depFile = $folder->getFile($depFileName);
165
+        } catch (NotFoundException $e) {
166
+            $depFile = $folder->newFile($depFileName);
167
+        }
168
+
169
+        try {
170
+            $gzipFile = $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz
171
+        } catch (NotFoundException $e) {
172
+            $gzipFile = $folder->newFile($fileName . '.gzip'); # Safari doesn't like .gz
173
+        }
174
+
175
+        try {
176
+            $cachedfile->putContent($res);
177
+            $deps = json_encode($deps);
178
+            $depFile->putContent($deps);
179
+            $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps);
180
+            $gzipFile->putContent(gzencode($res, 9));
181
+
182
+            return true;
183
+        } catch (NotPermittedException $e) {
184
+            return false;
185
+        }
186
+    }
187
+
188
+    /**
189
+     * @param string $appName
190
+     * @param string $fileName
191
+     * @return string
192
+     */
193
+    public function getCachedJS($appName, $fileName) {
194
+        $tmpfileLoc = explode('/', $fileName);
195
+        $fileName = array_pop($tmpfileLoc);
196
+        $fileName = str_replace('.json', '.js', $fileName);
197
+
198
+        return substr($this->urlGenerator->linkToRoute('core.Js.getJs', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1);
199
+    }
200
+
201
+    /**
202
+     * @param string $root
203
+     * @param string $file
204
+     * @return string[]
205
+     */
206
+    public function getContent($root, $file) {
207
+        /** @var array $data */
208
+        $data = json_decode(file_get_contents($root . '/' . $file));
209
+        if(!is_array($data)) {
210
+            return [];
211
+        }
212
+
213
+        $path = explode('/', $file);
214
+        array_pop($path);
215
+        $path = implode('/', $path);
216
+
217
+        $result = [];
218
+        foreach ($data as $f) {
219
+            $result[] = $path . '/' . $f;
220
+        }
221
+
222
+        return $result;
223
+    }
224 224
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -78,19 +78,19 @@  discard block
 block discarded – undo
78 78
 			return false;
79 79
 		}
80 80
 
81
-		$path = explode('/', $root . '/' . $file);
81
+		$path = explode('/', $root.'/'.$file);
82 82
 
83 83
 		$fileName = array_pop($path);
84 84
 		$path = implode('/', $path);
85 85
 
86 86
 		try {
87 87
 			$folder = $this->appData->getFolder($app);
88
-		} catch(NotFoundException $e) {
88
+		} catch (NotFoundException $e) {
89 89
 			// creating css appdata folder
90 90
 			$folder = $this->appData->newFolder($app);
91 91
 		}
92 92
 
93
-		if($this->isCached($fileName, $folder)) {
93
+		if ($this->isCached($fileName, $folder)) {
94 94
 			return true;
95 95
 		}
96 96
 		return $this->cache($path, $fileName, $folder);
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
 	 * @return bool
103 103
 	 */
104 104
 	protected function isCached($fileName, ISimpleFolder $folder) {
105
-		$fileName = str_replace('.json', '.js', $fileName) . '.deps';
105
+		$fileName = str_replace('.json', '.js', $fileName).'.deps';
106 106
 		try {
107
-			$deps = $this->depsCache->get($folder->getName() . '-' . $fileName);
107
+			$deps = $this->depsCache->get($folder->getName().'-'.$fileName);
108 108
 			if ($deps === null || $deps === '') {
109 109
 				$depFile = $folder->getFile($fileName);
110 110
 				$deps = $depFile->getContent();
111 111
 			}
112 112
 			// check again
113 113
 			if ($deps === null || $deps === '') {
114
-				$this->logger->info('JSCombiner: deps file empty: ' . $fileName);
114
+				$this->logger->info('JSCombiner: deps file empty: '.$fileName);
115 115
 				return false;
116 116
 			}
117 117
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 			}
125 125
 
126 126
 			return true;
127
-		} catch(NotFoundException $e) {
127
+		} catch (NotFoundException $e) {
128 128
 			return false;
129 129
 		}
130 130
 	}
@@ -137,17 +137,17 @@  discard block
 block discarded – undo
137 137
 	 */
138 138
 	protected function cache($path, $fileName, ISimpleFolder $folder) {
139 139
 		$deps = [];
140
-		$fullPath = $path . '/' . $fileName;
140
+		$fullPath = $path.'/'.$fileName;
141 141
 		$data = json_decode(file_get_contents($fullPath));
142 142
 		$deps[$fullPath] = filemtime($fullPath);
143 143
 
144 144
 		$res = '';
145 145
 		foreach ($data as $file) {
146
-			$filePath = $path . '/' . $file;
146
+			$filePath = $path.'/'.$file;
147 147
 
148 148
 			if (is_file($filePath)) {
149 149
 				$res .= file_get_contents($filePath);
150
-				$res .= PHP_EOL . PHP_EOL;
150
+				$res .= PHP_EOL.PHP_EOL;
151 151
 				$deps[$filePath] = filemtime($filePath);
152 152
 			}
153 153
 		}
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
 		$fileName = str_replace('.json', '.js', $fileName);
156 156
 		try {
157 157
 			$cachedfile = $folder->getFile($fileName);
158
-		} catch(NotFoundException $e) {
158
+		} catch (NotFoundException $e) {
159 159
 			$cachedfile = $folder->newFile($fileName);
160 160
 		}
161 161
 
162
-		$depFileName = $fileName . '.deps';
162
+		$depFileName = $fileName.'.deps';
163 163
 		try {
164 164
 			$depFile = $folder->getFile($depFileName);
165 165
 		} catch (NotFoundException $e) {
@@ -167,16 +167,16 @@  discard block
 block discarded – undo
167 167
 		}
168 168
 
169 169
 		try {
170
-			$gzipFile = $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz
170
+			$gzipFile = $folder->getFile($fileName.'.gzip'); # Safari doesn't like .gz
171 171
 		} catch (NotFoundException $e) {
172
-			$gzipFile = $folder->newFile($fileName . '.gzip'); # Safari doesn't like .gz
172
+			$gzipFile = $folder->newFile($fileName.'.gzip'); # Safari doesn't like .gz
173 173
 		}
174 174
 
175 175
 		try {
176 176
 			$cachedfile->putContent($res);
177 177
 			$deps = json_encode($deps);
178 178
 			$depFile->putContent($deps);
179
-			$this->depsCache->set($folder->getName() . '-' . $depFileName, $deps);
179
+			$this->depsCache->set($folder->getName().'-'.$depFileName, $deps);
180 180
 			$gzipFile->putContent(gzencode($res, 9));
181 181
 
182 182
 			return true;
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 	 */
206 206
 	public function getContent($root, $file) {
207 207
 		/** @var array $data */
208
-		$data = json_decode(file_get_contents($root . '/' . $file));
209
-		if(!is_array($data)) {
208
+		$data = json_decode(file_get_contents($root.'/'.$file));
209
+		if (!is_array($data)) {
210 210
 			return [];
211 211
 		}
212 212
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
 		$result = [];
218 218
 		foreach ($data as $f) {
219
-			$result[] = $path . '/' . $f;
219
+			$result[] = $path.'/'.$f;
220 220
 		}
221 221
 
222 222
 		return $result;
Please login to merge, or discard this patch.
lib/private/TemplateLayout.php 1 patch
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -42,227 +42,227 @@
 block discarded – undo
42 42
 
43 43
 class TemplateLayout extends \OC_Template {
44 44
 
45
-	private static $versionHash = '';
45
+    private static $versionHash = '';
46 46
 
47
-	/**
48
-	 * @var \OCP\IConfig
49
-	 */
50
-	private $config;
47
+    /**
48
+     * @var \OCP\IConfig
49
+     */
50
+    private $config;
51 51
 
52
-	/**
53
-	 * @param string $renderAs
54
-	 * @param string $appId application id
55
-	 */
56
-	public function __construct( $renderAs, $appId = '' ) {
52
+    /**
53
+     * @param string $renderAs
54
+     * @param string $appId application id
55
+     */
56
+    public function __construct( $renderAs, $appId = '' ) {
57 57
 
58
-		// yes - should be injected ....
59
-		$this->config = \OC::$server->getConfig();
58
+        // yes - should be injected ....
59
+        $this->config = \OC::$server->getConfig();
60 60
 
61 61
 
62
-		// Decide which page we show
63
-		if($renderAs == 'user') {
64
-			parent::__construct( 'core', 'layout.user' );
65
-			if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
66
-				$this->assign('bodyid', 'body-settings');
67
-			}else{
68
-				$this->assign('bodyid', 'body-user');
69
-			}
62
+        // Decide which page we show
63
+        if($renderAs == 'user') {
64
+            parent::__construct( 'core', 'layout.user' );
65
+            if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
66
+                $this->assign('bodyid', 'body-settings');
67
+            }else{
68
+                $this->assign('bodyid', 'body-user');
69
+            }
70 70
 
71
-			// Code integrity notification
72
-			$integrityChecker = \OC::$server->getIntegrityCodeChecker();
73
-			if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
74
-				\OCP\Util::addScript('core', 'integritycheck-failed-notification');
75
-			}
71
+            // Code integrity notification
72
+            $integrityChecker = \OC::$server->getIntegrityCodeChecker();
73
+            if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
74
+                \OCP\Util::addScript('core', 'integritycheck-failed-notification');
75
+            }
76 76
 
77
-			// Add navigation entry
78
-			$this->assign( 'application', '');
79
-			$this->assign( 'appid', $appId );
80
-			$navigation = \OC_App::getNavigation();
81
-			$this->assign( 'navigation', $navigation);
82
-			$settingsNavigation = \OC_App::getSettingsNavigation();
83
-			$this->assign( 'settingsnavigation', $settingsNavigation);
84
-			foreach($navigation as $entry) {
85
-				if ($entry['active']) {
86
-					$this->assign( 'application', $entry['name'] );
87
-					break;
88
-				}
89
-			}
77
+            // Add navigation entry
78
+            $this->assign( 'application', '');
79
+            $this->assign( 'appid', $appId );
80
+            $navigation = \OC_App::getNavigation();
81
+            $this->assign( 'navigation', $navigation);
82
+            $settingsNavigation = \OC_App::getSettingsNavigation();
83
+            $this->assign( 'settingsnavigation', $settingsNavigation);
84
+            foreach($navigation as $entry) {
85
+                if ($entry['active']) {
86
+                    $this->assign( 'application', $entry['name'] );
87
+                    break;
88
+                }
89
+            }
90 90
 			
91
-			foreach($settingsNavigation as $entry) {
92
-				if ($entry['active']) {
93
-					$this->assign( 'application', $entry['name'] );
94
-					break;
95
-				}
96
-			}
97
-			$userDisplayName = \OC_User::getDisplayName();
98
-			$this->assign('user_displayname', $userDisplayName);
99
-			$this->assign('user_uid', \OC_User::getUser());
91
+            foreach($settingsNavigation as $entry) {
92
+                if ($entry['active']) {
93
+                    $this->assign( 'application', $entry['name'] );
94
+                    break;
95
+                }
96
+            }
97
+            $userDisplayName = \OC_User::getDisplayName();
98
+            $this->assign('user_displayname', $userDisplayName);
99
+            $this->assign('user_uid', \OC_User::getUser());
100 100
 
101
-			if (\OC_User::getUser() === false) {
102
-				$this->assign('userAvatarSet', false);
103
-			} else {
104
-				$this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
105
-				$this->assign('userAvatarVersion', \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
106
-			}
101
+            if (\OC_User::getUser() === false) {
102
+                $this->assign('userAvatarSet', false);
103
+            } else {
104
+                $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
105
+                $this->assign('userAvatarVersion', \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
106
+            }
107 107
 
108
-		} else if ($renderAs == 'error') {
109
-			parent::__construct('core', 'layout.guest', '', false);
110
-			$this->assign('bodyid', 'body-login');
111
-		} else if ($renderAs == 'guest') {
112
-			parent::__construct('core', 'layout.guest');
113
-			$this->assign('bodyid', 'body-login');
114
-		} else {
115
-			parent::__construct('core', 'layout.base');
108
+        } else if ($renderAs == 'error') {
109
+            parent::__construct('core', 'layout.guest', '', false);
110
+            $this->assign('bodyid', 'body-login');
111
+        } else if ($renderAs == 'guest') {
112
+            parent::__construct('core', 'layout.guest');
113
+            $this->assign('bodyid', 'body-login');
114
+        } else {
115
+            parent::__construct('core', 'layout.base');
116 116
 
117
-		}
118
-		// Send the language to our layouts
119
-		$this->assign('language', \OC::$server->getL10NFactory()->findLanguage());
117
+        }
118
+        // Send the language to our layouts
119
+        $this->assign('language', \OC::$server->getL10NFactory()->findLanguage());
120 120
 
121
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
122
-			if (empty(self::$versionHash)) {
123
-				$v = \OC_App::getAppVersions();
124
-				$v['core'] = implode('.', \OCP\Util::getVersion());
125
-				self::$versionHash = md5(implode(',', $v));
126
-			}
127
-		} else {
128
-			self::$versionHash = md5('not installed');
129
-		}
121
+        if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
122
+            if (empty(self::$versionHash)) {
123
+                $v = \OC_App::getAppVersions();
124
+                $v['core'] = implode('.', \OCP\Util::getVersion());
125
+                self::$versionHash = md5(implode(',', $v));
126
+            }
127
+        } else {
128
+            self::$versionHash = md5('not installed');
129
+        }
130 130
 
131
-		// Add the js files
132
-		$jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
133
-		$this->assign('jsfiles', array());
134
-		if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
135
-			if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
136
-				$jsConfigHelper = new JSConfigHelper(
137
-					\OC::$server->getL10N('core'),
138
-					\OC::$server->query(Defaults::class),
139
-					\OC::$server->getAppManager(),
140
-					\OC::$server->getSession(),
141
-					\OC::$server->getUserSession()->getUser(),
142
-					\OC::$server->getConfig(),
143
-					\OC::$server->getGroupManager(),
144
-					\OC::$server->getIniWrapper(),
145
-					\OC::$server->getURLGenerator()
146
-				);
147
-				$this->assign('inline_ocjs', $jsConfigHelper->getConfig());
148
-			} else {
149
-				$this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
150
-			}
151
-		}
152
-		foreach($jsFiles as $info) {
153
-			$web = $info[1];
154
-			$file = $info[2];
155
-			$this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
156
-		}
131
+        // Add the js files
132
+        $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
133
+        $this->assign('jsfiles', array());
134
+        if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
135
+            if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
136
+                $jsConfigHelper = new JSConfigHelper(
137
+                    \OC::$server->getL10N('core'),
138
+                    \OC::$server->query(Defaults::class),
139
+                    \OC::$server->getAppManager(),
140
+                    \OC::$server->getSession(),
141
+                    \OC::$server->getUserSession()->getUser(),
142
+                    \OC::$server->getConfig(),
143
+                    \OC::$server->getGroupManager(),
144
+                    \OC::$server->getIniWrapper(),
145
+                    \OC::$server->getURLGenerator()
146
+                );
147
+                $this->assign('inline_ocjs', $jsConfigHelper->getConfig());
148
+            } else {
149
+                $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
150
+            }
151
+        }
152
+        foreach($jsFiles as $info) {
153
+            $web = $info[1];
154
+            $file = $info[2];
155
+            $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
156
+        }
157 157
 
158
-		try {
159
-			$pathInfo = \OC::$server->getRequest()->getPathInfo();
160
-		} catch (\Exception $e) {
161
-			$pathInfo = '';
162
-		}
158
+        try {
159
+            $pathInfo = \OC::$server->getRequest()->getPathInfo();
160
+        } catch (\Exception $e) {
161
+            $pathInfo = '';
162
+        }
163 163
 
164
-		// Do not initialise scss appdata until we have a fully installed instance
165
-		// Do not load scss for update, errors, installation or login page
166
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)
167
-			&& !\OCP\Util::needUpgrade()
168
-			&& $pathInfo !== ''
169
-			&& !preg_match('/^\/login/', $pathInfo)) {
170
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
171
-		} else {
172
-			// If we ignore the scss compiler,
173
-			// we need to load the guest css fallback
174
-			\OC_Util::addStyle('guest');
175
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
176
-		}
164
+        // Do not initialise scss appdata until we have a fully installed instance
165
+        // Do not load scss for update, errors, installation or login page
166
+        if(\OC::$server->getSystemConfig()->getValue('installed', false)
167
+            && !\OCP\Util::needUpgrade()
168
+            && $pathInfo !== ''
169
+            && !preg_match('/^\/login/', $pathInfo)) {
170
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
171
+        } else {
172
+            // If we ignore the scss compiler,
173
+            // we need to load the guest css fallback
174
+            \OC_Util::addStyle('guest');
175
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
176
+        }
177 177
 
178
-		$this->assign('cssfiles', array());
179
-		$this->assign('printcssfiles', []);
180
-		$this->assign('versionHash', self::$versionHash);
181
-		foreach($cssFiles as $info) {
182
-			$web = $info[1];
183
-			$file = $info[2];
178
+        $this->assign('cssfiles', array());
179
+        $this->assign('printcssfiles', []);
180
+        $this->assign('versionHash', self::$versionHash);
181
+        foreach($cssFiles as $info) {
182
+            $web = $info[1];
183
+            $file = $info[2];
184 184
 
185
-			if (substr($file, -strlen('print.css')) === 'print.css') {
186
-				$this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
187
-			} else {
188
-				$this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix()  );
189
-			}
190
-		}
191
-	}
185
+            if (substr($file, -strlen('print.css')) === 'print.css') {
186
+                $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
187
+            } else {
188
+                $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix()  );
189
+            }
190
+        }
191
+    }
192 192
 
193
-	protected function getVersionHashSuffix() {
194
-		if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
195
-			// allows chrome workspace mapping in debug mode
196
-			return "";
197
-		}
198
-		if ($this->config->getSystemValue('installed', false) && \OC::$server->getAppManager()->isInstalled('theming')) {
199
-			return '?v=' . self::$versionHash . '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
200
-		}
201
-		return '?v=' . self::$versionHash;
202
-	}
193
+    protected function getVersionHashSuffix() {
194
+        if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
195
+            // allows chrome workspace mapping in debug mode
196
+            return "";
197
+        }
198
+        if ($this->config->getSystemValue('installed', false) && \OC::$server->getAppManager()->isInstalled('theming')) {
199
+            return '?v=' . self::$versionHash . '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
200
+        }
201
+        return '?v=' . self::$versionHash;
202
+    }
203 203
 
204
-	/**
205
-	 * @param array $styles
206
-	 * @return array
207
-	 */
208
-	static public function findStylesheetFiles($styles, $compileScss = true) {
209
-		// Read the selected theme from the config file
210
-		$theme = \OC_Util::getTheme();
204
+    /**
205
+     * @param array $styles
206
+     * @return array
207
+     */
208
+    static public function findStylesheetFiles($styles, $compileScss = true) {
209
+        // Read the selected theme from the config file
210
+        $theme = \OC_Util::getTheme();
211 211
 
212
-		if($compileScss) {
213
-			$SCSSCacher = \OC::$server->query(SCSSCacher::class);
214
-		} else {
215
-			$SCSSCacher = null;
216
-		}
212
+        if($compileScss) {
213
+            $SCSSCacher = \OC::$server->query(SCSSCacher::class);
214
+        } else {
215
+            $SCSSCacher = null;
216
+        }
217 217
 
218
-		$locator = new \OC\Template\CSSResourceLocator(
219
-			\OC::$server->getLogger(),
220
-			$theme,
221
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
222
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
223
-			$SCSSCacher
224
-		);
225
-		$locator->find($styles);
226
-		return $locator->getResources();
227
-	}
218
+        $locator = new \OC\Template\CSSResourceLocator(
219
+            \OC::$server->getLogger(),
220
+            $theme,
221
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
222
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
223
+            $SCSSCacher
224
+        );
225
+        $locator->find($styles);
226
+        return $locator->getResources();
227
+    }
228 228
 
229
-	/**
230
-	 * @param array $scripts
231
-	 * @return array
232
-	 */
233
-	static public function findJavascriptFiles($scripts) {
234
-		// Read the selected theme from the config file
235
-		$theme = \OC_Util::getTheme();
229
+    /**
230
+     * @param array $scripts
231
+     * @return array
232
+     */
233
+    static public function findJavascriptFiles($scripts) {
234
+        // Read the selected theme from the config file
235
+        $theme = \OC_Util::getTheme();
236 236
 
237
-		$locator = new \OC\Template\JSResourceLocator(
238
-			\OC::$server->getLogger(),
239
-			$theme,
240
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
241
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
242
-			new JSCombiner(
243
-				\OC::$server->getAppDataDir('js'),
244
-				\OC::$server->getURLGenerator(),
245
-				\OC::$server->getMemCacheFactory()->create('JS'),
246
-				\OC::$server->getSystemConfig(),
247
-				\OC::$server->getLogger()
248
-			)
249
-			);
250
-		$locator->find($scripts);
251
-		return $locator->getResources();
252
-	}
237
+        $locator = new \OC\Template\JSResourceLocator(
238
+            \OC::$server->getLogger(),
239
+            $theme,
240
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
241
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
242
+            new JSCombiner(
243
+                \OC::$server->getAppDataDir('js'),
244
+                \OC::$server->getURLGenerator(),
245
+                \OC::$server->getMemCacheFactory()->create('JS'),
246
+                \OC::$server->getSystemConfig(),
247
+                \OC::$server->getLogger()
248
+            )
249
+            );
250
+        $locator->find($scripts);
251
+        return $locator->getResources();
252
+    }
253 253
 
254
-	/**
255
-	 * Converts the absolute file path to a relative path from \OC::$SERVERROOT
256
-	 * @param string $filePath Absolute path
257
-	 * @return string Relative path
258
-	 * @throws \Exception If $filePath is not under \OC::$SERVERROOT
259
-	 */
260
-	public static function convertToRelativePath($filePath) {
261
-		$relativePath = explode(\OC::$SERVERROOT, $filePath);
262
-		if(count($relativePath) !== 2) {
263
-			throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
264
-		}
254
+    /**
255
+     * Converts the absolute file path to a relative path from \OC::$SERVERROOT
256
+     * @param string $filePath Absolute path
257
+     * @return string Relative path
258
+     * @throws \Exception If $filePath is not under \OC::$SERVERROOT
259
+     */
260
+    public static function convertToRelativePath($filePath) {
261
+        $relativePath = explode(\OC::$SERVERROOT, $filePath);
262
+        if(count($relativePath) !== 2) {
263
+            throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
264
+        }
265 265
 
266
-		return $relativePath[1];
267
-	}
266
+        return $relativePath[1];
267
+    }
268 268
 }
Please login to merge, or discard this patch.