Completed
Push — master ( 1a8096...9675bb )
by Lukas
40:13 queued 27:07
created
lib/private/Template/SCSSCacher.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,6 @@
 block discarded – undo
25 25
 use Leafo\ScssPhp\Exception\ParserException;
26 26
 use Leafo\ScssPhp\Formatter\Crunched;
27 27
 use Leafo\ScssPhp\Formatter\Expanded;
28
-use OC\SystemConfig;
29 28
 use OCP\Files\IAppData;
30 29
 use OCP\Files\NotFoundException;
31 30
 use OCP\Files\NotPermittedException;
Please login to merge, or discard this patch.
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -37,193 +37,193 @@
 block discarded – undo
37 37
 
38 38
 class SCSSCacher {
39 39
 
40
-	/** @var ILogger */
41
-	protected $logger;
42
-
43
-	/** @var IAppData */
44
-	protected $appData;
45
-
46
-	/** @var IURLGenerator */
47
-	protected $urlGenerator;
48
-
49
-	/** @var IConfig */
50
-	protected $config;
51
-
52
-	/** @var string */
53
-	protected $serverRoot;
54
-
55
-	/** @var ICache */
56
-	protected $depsCache;
57
-
58
-	/**
59
-	 * @param ILogger $logger
60
-	 * @param IAppData $appData
61
-	 * @param IURLGenerator $urlGenerator
62
-	 * @param IConfig $config
63
-	 * @param string $serverRoot
64
-	 * @param ICache $depsCache
65
-	 */
66
-	public function __construct(ILogger $logger,
67
-								IAppData $appData,
68
-								IURLGenerator $urlGenerator,
69
-								IConfig $config,
70
-								$serverRoot,
71
-								ICache $depsCache) {
72
-		$this->logger = $logger;
73
-		$this->appData = $appData;
74
-		$this->urlGenerator = $urlGenerator;
75
-		$this->config = $config;
76
-		$this->serverRoot = $serverRoot;
77
-		$this->depsCache = $depsCache;
78
-	}
79
-
80
-	/**
81
-	 * Process the caching process if needed
82
-	 * @param string $root Root path to the nextcloud installation
83
-	 * @param string $file
84
-	 * @param string $app The app name
85
-	 * @return boolean
86
-	 */
87
-	public function process($root, $file, $app) {
88
-		$path = explode('/', $root . '/' . $file);
89
-
90
-		$fileNameSCSS = array_pop($path);
91
-		$fileNameCSS = str_replace('.scss', '.css', $fileNameSCSS);
92
-
93
-		$path = implode('/', $path);
94
-
95
-		$webDir = substr($path, strlen($this->serverRoot)+1);
96
-
97
-		try {
98
-			$folder = $this->appData->getFolder($app);
99
-		} catch(NotFoundException $e) {
100
-			// creating css appdata folder
101
-			$folder = $this->appData->newFolder($app);
102
-		}
103
-
104
-		if($this->isCached($fileNameCSS, $folder)) {
105
-			return true;
106
-		}
107
-		return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir);
108
-	}
109
-
110
-	/**
111
-	 * Check if the file is cached or not
112
-	 * @param string $fileNameCSS
113
-	 * @param ISimpleFolder $folder
114
-	 * @return boolean
115
-	 */
116
-	private function isCached($fileNameCSS, ISimpleFolder $folder) {
117
-		try {
118
-			$cachedFile = $folder->getFile($fileNameCSS);
119
-			if ($cachedFile->getSize() > 0) {
120
-				$depFileName = $fileNameCSS . '.deps';
121
-				$deps = $this->depsCache->get($folder->getName() . '-' . $depFileName);
122
-				if ($deps === null) {
123
-					$depFile = $folder->getFile($depFileName);
124
-					$deps = $depFile->getContent();
125
-					//Set to memcache for next run
126
-					$this->depsCache->set($folder->getName() . '-' . $depFileName, $deps);
127
-				}
128
-				$deps = json_decode($deps, true);
129
-
130
-				foreach ($deps as $file=>$mtime) {
131
-					if (!file_exists($file) || filemtime($file) > $mtime) {
132
-						return false;
133
-					}
134
-				}
135
-			}
136
-			return true;
137
-		} catch(NotFoundException $e) {
138
-			return false;
139
-		}
140
-	}
141
-
142
-	/**
143
-	 * Cache the file with AppData
144
-	 * @param string $path
145
-	 * @param string $fileNameCSS
146
-	 * @param string $fileNameSCSS
147
-	 * @param ISimpleFolder $folder
148
-	 * @param string $webDir
149
-	 * @return boolean
150
-	 */
151
-	private function cache($path, $fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $webDir) {
152
-		$scss = new Compiler();
153
-		$scss->setImportPaths([
154
-			$path,
155
-			\OC::$SERVERROOT . '/core/css/',
156
-		]);
157
-		if($this->config->getSystemValue('debug')) {
158
-			// Debug mode
159
-			$scss->setFormatter(Expanded::class);
160
-			$scss->setLineNumberStyle(Compiler::LINE_COMMENTS);
161
-		} else {
162
-			// Compression
163
-			$scss->setFormatter(Crunched::class);
164
-		}
165
-
166
-		try {
167
-			$cachedfile = $folder->getFile($fileNameCSS);
168
-		} catch(NotFoundException $e) {
169
-			$cachedfile = $folder->newFile($fileNameCSS);
170
-		}
171
-
172
-		$depFileName = $fileNameCSS . '.deps';
173
-		try {
174
-			$depFile = $folder->getFile($depFileName);
175
-		} catch (NotFoundException $e) {
176
-			$depFile = $folder->newFile($depFileName);
177
-		}
178
-
179
-		// Compile
180
-		try {
181
-			$compiledScss = $scss->compile(
182
-				'@import "variables.scss";' .
183
-				'@import "'.$fileNameSCSS.'";');
184
-		} catch(ParserException $e) {
185
-			$this->logger->error($e, ['app' => 'core']);
186
-			return false;
187
-		}
188
-
189
-		try {
190
-			$cachedfile->putContent($this->rebaseUrls($compiledScss, $webDir));
191
-			$depFile->putContent(json_encode($scss->getParsedFiles()));
192
-			$this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']);
193
-			return true;
194
-		} catch(NotPermittedException $e) {
195
-			return false;
196
-		}
197
-	}
198
-
199
-	/**
200
-	 * Add the correct uri prefix to make uri valid again
201
-	 * @param string $css
202
-	 * @param string $webDir
203
-	 * @return string
204
-	 */
205
-	private function rebaseUrls($css, $webDir) {
206
-		$re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x';
207
-		// OC\Route\Router:75
208
-		if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
209
-			$subst = 'url(\'../../'.$webDir.'/$1\')';	
210
-		} else {
211
-			$subst = 'url(\'../../../'.$webDir.'/$1\')';
212
-		}
213
-		return preg_replace($re, $subst, $css);
214
-	}
215
-
216
-	/**
217
-	 * Return the cached css file uri
218
-	 * @param string $appName the app name
219
-	 * @param string $fileName
220
-	 * @return string
221
-	 */
222
-	public function getCachedSCSS($appName, $fileName) {
223
-		$tmpfileLoc = explode('/', $fileName);
224
-		$fileName = array_pop($tmpfileLoc);
225
-		$fileName = str_replace('.scss', '.css', $fileName);
226
-
227
-		return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1);
228
-	}
40
+    /** @var ILogger */
41
+    protected $logger;
42
+
43
+    /** @var IAppData */
44
+    protected $appData;
45
+
46
+    /** @var IURLGenerator */
47
+    protected $urlGenerator;
48
+
49
+    /** @var IConfig */
50
+    protected $config;
51
+
52
+    /** @var string */
53
+    protected $serverRoot;
54
+
55
+    /** @var ICache */
56
+    protected $depsCache;
57
+
58
+    /**
59
+     * @param ILogger $logger
60
+     * @param IAppData $appData
61
+     * @param IURLGenerator $urlGenerator
62
+     * @param IConfig $config
63
+     * @param string $serverRoot
64
+     * @param ICache $depsCache
65
+     */
66
+    public function __construct(ILogger $logger,
67
+                                IAppData $appData,
68
+                                IURLGenerator $urlGenerator,
69
+                                IConfig $config,
70
+                                $serverRoot,
71
+                                ICache $depsCache) {
72
+        $this->logger = $logger;
73
+        $this->appData = $appData;
74
+        $this->urlGenerator = $urlGenerator;
75
+        $this->config = $config;
76
+        $this->serverRoot = $serverRoot;
77
+        $this->depsCache = $depsCache;
78
+    }
79
+
80
+    /**
81
+     * Process the caching process if needed
82
+     * @param string $root Root path to the nextcloud installation
83
+     * @param string $file
84
+     * @param string $app The app name
85
+     * @return boolean
86
+     */
87
+    public function process($root, $file, $app) {
88
+        $path = explode('/', $root . '/' . $file);
89
+
90
+        $fileNameSCSS = array_pop($path);
91
+        $fileNameCSS = str_replace('.scss', '.css', $fileNameSCSS);
92
+
93
+        $path = implode('/', $path);
94
+
95
+        $webDir = substr($path, strlen($this->serverRoot)+1);
96
+
97
+        try {
98
+            $folder = $this->appData->getFolder($app);
99
+        } catch(NotFoundException $e) {
100
+            // creating css appdata folder
101
+            $folder = $this->appData->newFolder($app);
102
+        }
103
+
104
+        if($this->isCached($fileNameCSS, $folder)) {
105
+            return true;
106
+        }
107
+        return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir);
108
+    }
109
+
110
+    /**
111
+     * Check if the file is cached or not
112
+     * @param string $fileNameCSS
113
+     * @param ISimpleFolder $folder
114
+     * @return boolean
115
+     */
116
+    private function isCached($fileNameCSS, ISimpleFolder $folder) {
117
+        try {
118
+            $cachedFile = $folder->getFile($fileNameCSS);
119
+            if ($cachedFile->getSize() > 0) {
120
+                $depFileName = $fileNameCSS . '.deps';
121
+                $deps = $this->depsCache->get($folder->getName() . '-' . $depFileName);
122
+                if ($deps === null) {
123
+                    $depFile = $folder->getFile($depFileName);
124
+                    $deps = $depFile->getContent();
125
+                    //Set to memcache for next run
126
+                    $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps);
127
+                }
128
+                $deps = json_decode($deps, true);
129
+
130
+                foreach ($deps as $file=>$mtime) {
131
+                    if (!file_exists($file) || filemtime($file) > $mtime) {
132
+                        return false;
133
+                    }
134
+                }
135
+            }
136
+            return true;
137
+        } catch(NotFoundException $e) {
138
+            return false;
139
+        }
140
+    }
141
+
142
+    /**
143
+     * Cache the file with AppData
144
+     * @param string $path
145
+     * @param string $fileNameCSS
146
+     * @param string $fileNameSCSS
147
+     * @param ISimpleFolder $folder
148
+     * @param string $webDir
149
+     * @return boolean
150
+     */
151
+    private function cache($path, $fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $webDir) {
152
+        $scss = new Compiler();
153
+        $scss->setImportPaths([
154
+            $path,
155
+            \OC::$SERVERROOT . '/core/css/',
156
+        ]);
157
+        if($this->config->getSystemValue('debug')) {
158
+            // Debug mode
159
+            $scss->setFormatter(Expanded::class);
160
+            $scss->setLineNumberStyle(Compiler::LINE_COMMENTS);
161
+        } else {
162
+            // Compression
163
+            $scss->setFormatter(Crunched::class);
164
+        }
165
+
166
+        try {
167
+            $cachedfile = $folder->getFile($fileNameCSS);
168
+        } catch(NotFoundException $e) {
169
+            $cachedfile = $folder->newFile($fileNameCSS);
170
+        }
171
+
172
+        $depFileName = $fileNameCSS . '.deps';
173
+        try {
174
+            $depFile = $folder->getFile($depFileName);
175
+        } catch (NotFoundException $e) {
176
+            $depFile = $folder->newFile($depFileName);
177
+        }
178
+
179
+        // Compile
180
+        try {
181
+            $compiledScss = $scss->compile(
182
+                '@import "variables.scss";' .
183
+                '@import "'.$fileNameSCSS.'";');
184
+        } catch(ParserException $e) {
185
+            $this->logger->error($e, ['app' => 'core']);
186
+            return false;
187
+        }
188
+
189
+        try {
190
+            $cachedfile->putContent($this->rebaseUrls($compiledScss, $webDir));
191
+            $depFile->putContent(json_encode($scss->getParsedFiles()));
192
+            $this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']);
193
+            return true;
194
+        } catch(NotPermittedException $e) {
195
+            return false;
196
+        }
197
+    }
198
+
199
+    /**
200
+     * Add the correct uri prefix to make uri valid again
201
+     * @param string $css
202
+     * @param string $webDir
203
+     * @return string
204
+     */
205
+    private function rebaseUrls($css, $webDir) {
206
+        $re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x';
207
+        // OC\Route\Router:75
208
+        if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
209
+            $subst = 'url(\'../../'.$webDir.'/$1\')';	
210
+        } else {
211
+            $subst = 'url(\'../../../'.$webDir.'/$1\')';
212
+        }
213
+        return preg_replace($re, $subst, $css);
214
+    }
215
+
216
+    /**
217
+     * Return the cached css file uri
218
+     * @param string $appName the app name
219
+     * @param string $fileName
220
+     * @return string
221
+     */
222
+    public function getCachedSCSS($appName, $fileName) {
223
+        $tmpfileLoc = explode('/', $fileName);
224
+        $fileName = array_pop($tmpfileLoc);
225
+        $fileName = str_replace('.scss', '.css', $fileName);
226
+
227
+        return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1);
228
+    }
229 229
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -85,23 +85,23 @@  discard block
 block discarded – undo
85 85
 	 * @return boolean
86 86
 	 */
87 87
 	public function process($root, $file, $app) {
88
-		$path = explode('/', $root . '/' . $file);
88
+		$path = explode('/', $root.'/'.$file);
89 89
 
90 90
 		$fileNameSCSS = array_pop($path);
91 91
 		$fileNameCSS = str_replace('.scss', '.css', $fileNameSCSS);
92 92
 
93 93
 		$path = implode('/', $path);
94 94
 
95
-		$webDir = substr($path, strlen($this->serverRoot)+1);
95
+		$webDir = substr($path, strlen($this->serverRoot) + 1);
96 96
 
97 97
 		try {
98 98
 			$folder = $this->appData->getFolder($app);
99
-		} catch(NotFoundException $e) {
99
+		} catch (NotFoundException $e) {
100 100
 			// creating css appdata folder
101 101
 			$folder = $this->appData->newFolder($app);
102 102
 		}
103 103
 
104
-		if($this->isCached($fileNameCSS, $folder)) {
104
+		if ($this->isCached($fileNameCSS, $folder)) {
105 105
 			return true;
106 106
 		}
107 107
 		return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir);
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
 		try {
118 118
 			$cachedFile = $folder->getFile($fileNameCSS);
119 119
 			if ($cachedFile->getSize() > 0) {
120
-				$depFileName = $fileNameCSS . '.deps';
121
-				$deps = $this->depsCache->get($folder->getName() . '-' . $depFileName);
120
+				$depFileName = $fileNameCSS.'.deps';
121
+				$deps = $this->depsCache->get($folder->getName().'-'.$depFileName);
122 122
 				if ($deps === null) {
123 123
 					$depFile = $folder->getFile($depFileName);
124 124
 					$deps = $depFile->getContent();
125 125
 					//Set to memcache for next run
126
-					$this->depsCache->set($folder->getName() . '-' . $depFileName, $deps);
126
+					$this->depsCache->set($folder->getName().'-'.$depFileName, $deps);
127 127
 				}
128 128
 				$deps = json_decode($deps, true);
129 129
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 				}
135 135
 			}
136 136
 			return true;
137
-		} catch(NotFoundException $e) {
137
+		} catch (NotFoundException $e) {
138 138
 			return false;
139 139
 		}
140 140
 	}
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 		$scss = new Compiler();
153 153
 		$scss->setImportPaths([
154 154
 			$path,
155
-			\OC::$SERVERROOT . '/core/css/',
155
+			\OC::$SERVERROOT.'/core/css/',
156 156
 		]);
157
-		if($this->config->getSystemValue('debug')) {
157
+		if ($this->config->getSystemValue('debug')) {
158 158
 			// Debug mode
159 159
 			$scss->setFormatter(Expanded::class);
160 160
 			$scss->setLineNumberStyle(Compiler::LINE_COMMENTS);
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 
166 166
 		try {
167 167
 			$cachedfile = $folder->getFile($fileNameCSS);
168
-		} catch(NotFoundException $e) {
168
+		} catch (NotFoundException $e) {
169 169
 			$cachedfile = $folder->newFile($fileNameCSS);
170 170
 		}
171 171
 
172
-		$depFileName = $fileNameCSS . '.deps';
172
+		$depFileName = $fileNameCSS.'.deps';
173 173
 		try {
174 174
 			$depFile = $folder->getFile($depFileName);
175 175
 		} catch (NotFoundException $e) {
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 		// Compile
180 180
 		try {
181 181
 			$compiledScss = $scss->compile(
182
-				'@import "variables.scss";' .
182
+				'@import "variables.scss";'.
183 183
 				'@import "'.$fileNameSCSS.'";');
184
-		} catch(ParserException $e) {
184
+		} catch (ParserException $e) {
185 185
 			$this->logger->error($e, ['app' => 'core']);
186 186
 			return false;
187 187
 		}
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 			$depFile->putContent(json_encode($scss->getParsedFiles()));
192 192
 			$this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']);
193 193
 			return true;
194
-		} catch(NotPermittedException $e) {
194
+		} catch (NotPermittedException $e) {
195 195
 			return false;
196 196
 		}
197 197
 	}
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	private function rebaseUrls($css, $webDir) {
206 206
 		$re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x';
207 207
 		// OC\Route\Router:75
208
-		if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
208
+		if (($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
209 209
 			$subst = 'url(\'../../'.$webDir.'/$1\')';	
210 210
 		} else {
211 211
 			$subst = 'url(\'../../../'.$webDir.'/$1\')';
Please login to merge, or discard this patch.
lib/private/TemplateLayout.php 2 patches
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -40,232 +40,232 @@
 block discarded – undo
40 40
 
41 41
 class TemplateLayout extends \OC_Template {
42 42
 
43
-	private static $versionHash = '';
43
+    private static $versionHash = '';
44 44
 
45
-	/**
46
-	 * @var \OCP\IConfig
47
-	 */
48
-	private $config;
45
+    /**
46
+     * @var \OCP\IConfig
47
+     */
48
+    private $config;
49 49
 
50
-	/**
51
-	 * @param string $renderAs
52
-	 * @param string $appId application id
53
-	 */
54
-	public function __construct( $renderAs, $appId = '' ) {
50
+    /**
51
+     * @param string $renderAs
52
+     * @param string $appId application id
53
+     */
54
+    public function __construct( $renderAs, $appId = '' ) {
55 55
 
56
-		// yes - should be injected ....
57
-		$this->config = \OC::$server->getConfig();
56
+        // yes - should be injected ....
57
+        $this->config = \OC::$server->getConfig();
58 58
 
59
-		// Decide which page we show
60
-		if($renderAs == 'user') {
61
-			parent::__construct( 'core', 'layout.user' );
62
-			if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
63
-				$this->assign('bodyid', 'body-settings');
64
-			}else{
65
-				$this->assign('bodyid', 'body-user');
66
-			}
59
+        // Decide which page we show
60
+        if($renderAs == 'user') {
61
+            parent::__construct( 'core', 'layout.user' );
62
+            if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
63
+                $this->assign('bodyid', 'body-settings');
64
+            }else{
65
+                $this->assign('bodyid', 'body-user');
66
+            }
67 67
 
68
-			// Code integrity notification
69
-			$integrityChecker = \OC::$server->getIntegrityCodeChecker();
70
-			if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
71
-				\OCP\Util::addScript('core', 'integritycheck-failed-notification');
72
-			}
68
+            // Code integrity notification
69
+            $integrityChecker = \OC::$server->getIntegrityCodeChecker();
70
+            if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
71
+                \OCP\Util::addScript('core', 'integritycheck-failed-notification');
72
+            }
73 73
 
74
-			// Add navigation entry
75
-			$this->assign( 'application', '');
76
-			$this->assign( 'appid', $appId );
77
-			$navigation = \OC_App::getNavigation();
78
-			$this->assign( 'navigation', $navigation);
79
-			$navigation = \OC_App::getHeaderNavigation();
80
-			$this->assign( 'headernavigation', $navigation);
81
-			$settingsNavigation = \OC_App::getSettingsNavigation();
82
-			$this->assign( 'settingsnavigation', $settingsNavigation);
83
-			foreach($navigation as $entry) {
84
-				if ($entry['active']) {
85
-					$this->assign( 'application', $entry['name'] );
86
-					break;
87
-				}
88
-			}
74
+            // Add navigation entry
75
+            $this->assign( 'application', '');
76
+            $this->assign( 'appid', $appId );
77
+            $navigation = \OC_App::getNavigation();
78
+            $this->assign( 'navigation', $navigation);
79
+            $navigation = \OC_App::getHeaderNavigation();
80
+            $this->assign( 'headernavigation', $navigation);
81
+            $settingsNavigation = \OC_App::getSettingsNavigation();
82
+            $this->assign( 'settingsnavigation', $settingsNavigation);
83
+            foreach($navigation as $entry) {
84
+                if ($entry['active']) {
85
+                    $this->assign( 'application', $entry['name'] );
86
+                    break;
87
+                }
88
+            }
89 89
 			
90
-			foreach($settingsNavigation as $entry) {
91
-				if ($entry['active']) {
92
-					$this->assign( 'application', $entry['name'] );
93
-					break;
94
-				}
95
-			}
96
-			$userDisplayName = \OC_User::getDisplayName();
97
-			$appsMgmtActive = strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0;
98
-			if ($appsMgmtActive) {
99
-				$l = \OC::$server->getL10N('lib');
100
-				$this->assign('application', $l->t('Apps'));
101
-			}
102
-			$this->assign('user_displayname', $userDisplayName);
103
-			$this->assign('user_uid', \OC_User::getUser());
104
-			$this->assign('appsmanagement_active', $appsMgmtActive);
90
+            foreach($settingsNavigation as $entry) {
91
+                if ($entry['active']) {
92
+                    $this->assign( 'application', $entry['name'] );
93
+                    break;
94
+                }
95
+            }
96
+            $userDisplayName = \OC_User::getDisplayName();
97
+            $appsMgmtActive = strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0;
98
+            if ($appsMgmtActive) {
99
+                $l = \OC::$server->getL10N('lib');
100
+                $this->assign('application', $l->t('Apps'));
101
+            }
102
+            $this->assign('user_displayname', $userDisplayName);
103
+            $this->assign('user_uid', \OC_User::getUser());
104
+            $this->assign('appsmanagement_active', $appsMgmtActive);
105 105
 
106
-			if (\OC_User::getUser() === false) {
107
-				$this->assign('userAvatarSet', false);
108
-			} else {
109
-				$this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
110
-				$this->assign('userAvatarVersion', \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
111
-			}
106
+            if (\OC_User::getUser() === false) {
107
+                $this->assign('userAvatarSet', false);
108
+            } else {
109
+                $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
110
+                $this->assign('userAvatarVersion', \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
111
+            }
112 112
 
113
-		} else if ($renderAs == 'error') {
114
-			parent::__construct('core', 'layout.guest', '', false);
115
-			$this->assign('bodyid', 'body-login');
116
-		} else if ($renderAs == 'guest') {
117
-			parent::__construct('core', 'layout.guest');
118
-			$this->assign('bodyid', 'body-login');
119
-		} else {
120
-			parent::__construct('core', 'layout.base');
113
+        } else if ($renderAs == 'error') {
114
+            parent::__construct('core', 'layout.guest', '', false);
115
+            $this->assign('bodyid', 'body-login');
116
+        } else if ($renderAs == 'guest') {
117
+            parent::__construct('core', 'layout.guest');
118
+            $this->assign('bodyid', 'body-login');
119
+        } else {
120
+            parent::__construct('core', 'layout.base');
121 121
 
122
-		}
123
-		// Send the language to our layouts
124
-		$this->assign('language', \OC::$server->getL10NFactory()->findLanguage());
122
+        }
123
+        // Send the language to our layouts
124
+        $this->assign('language', \OC::$server->getL10NFactory()->findLanguage());
125 125
 
126
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
127
-			if (empty(self::$versionHash)) {
128
-				$v = \OC_App::getAppVersions();
129
-				$v['core'] = implode('.', \OCP\Util::getVersion());
130
-				self::$versionHash = md5(implode(',', $v));
131
-			}
132
-		} else {
133
-			self::$versionHash = md5('not installed');
134
-		}
126
+        if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
127
+            if (empty(self::$versionHash)) {
128
+                $v = \OC_App::getAppVersions();
129
+                $v['core'] = implode('.', \OCP\Util::getVersion());
130
+                self::$versionHash = md5(implode(',', $v));
131
+            }
132
+        } else {
133
+            self::$versionHash = md5('not installed');
134
+        }
135 135
 
136
-		// Add the js files
137
-		$jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
138
-		$this->assign('jsfiles', array());
139
-		if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
140
-			if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
141
-				$jsConfigHelper = new JSConfigHelper(
142
-					\OC::$server->getL10N('core'),
143
-					\OC::$server->getThemingDefaults(),
144
-					\OC::$server->getAppManager(),
145
-					\OC::$server->getSession(),
146
-					\OC::$server->getUserSession()->getUser(),
147
-					\OC::$server->getConfig(),
148
-					\OC::$server->getGroupManager(),
149
-					\OC::$server->getIniWrapper(),
150
-					\OC::$server->getURLGenerator()
151
-				);
152
-				$this->assign('inline_ocjs', $jsConfigHelper->getConfig());
153
-			} else {
154
-				$this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
155
-			}
156
-		}
157
-		foreach($jsFiles as $info) {
158
-			$web = $info[1];
159
-			$file = $info[2];
160
-			$this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
161
-		}
136
+        // Add the js files
137
+        $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
138
+        $this->assign('jsfiles', array());
139
+        if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
140
+            if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
141
+                $jsConfigHelper = new JSConfigHelper(
142
+                    \OC::$server->getL10N('core'),
143
+                    \OC::$server->getThemingDefaults(),
144
+                    \OC::$server->getAppManager(),
145
+                    \OC::$server->getSession(),
146
+                    \OC::$server->getUserSession()->getUser(),
147
+                    \OC::$server->getConfig(),
148
+                    \OC::$server->getGroupManager(),
149
+                    \OC::$server->getIniWrapper(),
150
+                    \OC::$server->getURLGenerator()
151
+                );
152
+                $this->assign('inline_ocjs', $jsConfigHelper->getConfig());
153
+            } else {
154
+                $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
155
+            }
156
+        }
157
+        foreach($jsFiles as $info) {
158
+            $web = $info[1];
159
+            $file = $info[2];
160
+            $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
161
+        }
162 162
 
163
-		try {
164
-			$pathInfo = \OC::$server->getRequest()->getPathInfo();
165
-		} catch (\Exception $e) {
166
-			$pathInfo = '';
167
-		}
163
+        try {
164
+            $pathInfo = \OC::$server->getRequest()->getPathInfo();
165
+        } catch (\Exception $e) {
166
+            $pathInfo = '';
167
+        }
168 168
 
169
-		// Do not initialise scss appdata until we have a fully installed instance
170
-		// Do not load scss for update, errors, installation or login page
171
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)
172
-			&& !\OCP\Util::needUpgrade()
173
-			&& $pathInfo !== ''
174
-			&& !preg_match('/^\/login/', $pathInfo)) {
175
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
176
-		} else {
177
-			// If we ignore the scss compiler,
178
-			// we need to load the guest css fallback
179
-			\OC_Util::addStyle('guest');
180
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
181
-		}
169
+        // Do not initialise scss appdata until we have a fully installed instance
170
+        // Do not load scss for update, errors, installation or login page
171
+        if(\OC::$server->getSystemConfig()->getValue('installed', false)
172
+            && !\OCP\Util::needUpgrade()
173
+            && $pathInfo !== ''
174
+            && !preg_match('/^\/login/', $pathInfo)) {
175
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
176
+        } else {
177
+            // If we ignore the scss compiler,
178
+            // we need to load the guest css fallback
179
+            \OC_Util::addStyle('guest');
180
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
181
+        }
182 182
 
183
-		$this->assign('cssfiles', array());
184
-		$this->assign('printcssfiles', []);
185
-		$this->assign('versionHash', self::$versionHash);
186
-		foreach($cssFiles as $info) {
187
-			$web = $info[1];
188
-			$file = $info[2];
183
+        $this->assign('cssfiles', array());
184
+        $this->assign('printcssfiles', []);
185
+        $this->assign('versionHash', self::$versionHash);
186
+        foreach($cssFiles as $info) {
187
+            $web = $info[1];
188
+            $file = $info[2];
189 189
 
190
-			if (substr($file, -strlen('print.css')) === 'print.css') {
191
-				$this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
192
-			} else {
193
-				$this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix()  );
194
-			}
195
-		}
196
-	}
190
+            if (substr($file, -strlen('print.css')) === 'print.css') {
191
+                $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
192
+            } else {
193
+                $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix()  );
194
+            }
195
+        }
196
+    }
197 197
 
198
-	protected function getVersionHashSuffix() {
199
-		if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
200
-			// allows chrome workspace mapping in debug mode
201
-			return "";
202
-		}
198
+    protected function getVersionHashSuffix() {
199
+        if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
200
+            // allows chrome workspace mapping in debug mode
201
+            return "";
202
+        }
203 203
 
204
-		return '?v=' . self::$versionHash;
205
-	}
204
+        return '?v=' . self::$versionHash;
205
+    }
206 206
 
207
-	/**
208
-	 * @param array $styles
209
-	 * @return array
210
-	 */
211
-	static public function findStylesheetFiles($styles, $compileScss = true) {
212
-		// Read the selected theme from the config file
213
-		$theme = \OC_Util::getTheme();
207
+    /**
208
+     * @param array $styles
209
+     * @return array
210
+     */
211
+    static public function findStylesheetFiles($styles, $compileScss = true) {
212
+        // Read the selected theme from the config file
213
+        $theme = \OC_Util::getTheme();
214 214
 
215
-		if($compileScss) {
216
-			/** @var \OC\Memcache\Factory $cache */
217
-			$cache = \OC::$server->query('MemCacheFactory');
218
-			$SCSSCacher = new SCSSCacher(
219
-				\OC::$server->getLogger(),
220
-				\OC::$server->getAppDataDir('css'),
221
-				\OC::$server->getURLGenerator(),
222
-				\OC::$server->getConfig(),
223
-				\OC::$SERVERROOT,
224
-				$cache->createLocal('SCSS')
225
-			);
226
-		} else {
227
-			$SCSSCacher = null;
228
-		}
215
+        if($compileScss) {
216
+            /** @var \OC\Memcache\Factory $cache */
217
+            $cache = \OC::$server->query('MemCacheFactory');
218
+            $SCSSCacher = new SCSSCacher(
219
+                \OC::$server->getLogger(),
220
+                \OC::$server->getAppDataDir('css'),
221
+                \OC::$server->getURLGenerator(),
222
+                \OC::$server->getConfig(),
223
+                \OC::$SERVERROOT,
224
+                $cache->createLocal('SCSS')
225
+            );
226
+        } else {
227
+            $SCSSCacher = null;
228
+        }
229 229
 
230
-		$locator = new \OC\Template\CSSResourceLocator(
231
-			\OC::$server->getLogger(),
232
-			$theme,
233
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
234
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
235
-			$SCSSCacher);
236
-		$locator->find($styles);
237
-		return $locator->getResources();
238
-	}
230
+        $locator = new \OC\Template\CSSResourceLocator(
231
+            \OC::$server->getLogger(),
232
+            $theme,
233
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
234
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
235
+            $SCSSCacher);
236
+        $locator->find($styles);
237
+        return $locator->getResources();
238
+    }
239 239
 
240
-	/**
241
-	 * @param array $scripts
242
-	 * @return array
243
-	 */
244
-	static public function findJavascriptFiles($scripts) {
245
-		// Read the selected theme from the config file
246
-		$theme = \OC_Util::getTheme();
240
+    /**
241
+     * @param array $scripts
242
+     * @return array
243
+     */
244
+    static public function findJavascriptFiles($scripts) {
245
+        // Read the selected theme from the config file
246
+        $theme = \OC_Util::getTheme();
247 247
 
248
-		$locator = new \OC\Template\JSResourceLocator(
249
-			\OC::$server->getLogger(),
250
-			$theme,
251
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
252
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ));
253
-		$locator->find($scripts);
254
-		return $locator->getResources();
255
-	}
248
+        $locator = new \OC\Template\JSResourceLocator(
249
+            \OC::$server->getLogger(),
250
+            $theme,
251
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
252
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ));
253
+        $locator->find($scripts);
254
+        return $locator->getResources();
255
+    }
256 256
 
257
-	/**
258
-	 * Converts the absolute file path to a relative path from \OC::$SERVERROOT
259
-	 * @param string $filePath Absolute path
260
-	 * @return string Relative path
261
-	 * @throws \Exception If $filePath is not under \OC::$SERVERROOT
262
-	 */
263
-	public static function convertToRelativePath($filePath) {
264
-		$relativePath = explode(\OC::$SERVERROOT, $filePath);
265
-		if(count($relativePath) !== 2) {
266
-			throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
267
-		}
257
+    /**
258
+     * Converts the absolute file path to a relative path from \OC::$SERVERROOT
259
+     * @param string $filePath Absolute path
260
+     * @return string Relative path
261
+     * @throws \Exception If $filePath is not under \OC::$SERVERROOT
262
+     */
263
+    public static function convertToRelativePath($filePath) {
264
+        $relativePath = explode(\OC::$SERVERROOT, $filePath);
265
+        if(count($relativePath) !== 2) {
266
+            throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
267
+        }
268 268
 
269
-		return $relativePath[1];
270
-	}
269
+        return $relativePath[1];
270
+    }
271 271
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -51,45 +51,45 @@  discard block
 block discarded – undo
51 51
 	 * @param string $renderAs
52 52
 	 * @param string $appId application id
53 53
 	 */
54
-	public function __construct( $renderAs, $appId = '' ) {
54
+	public function __construct($renderAs, $appId = '') {
55 55
 
56 56
 		// yes - should be injected ....
57 57
 		$this->config = \OC::$server->getConfig();
58 58
 
59 59
 		// Decide which page we show
60
-		if($renderAs == 'user') {
61
-			parent::__construct( 'core', 'layout.user' );
62
-			if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
60
+		if ($renderAs == 'user') {
61
+			parent::__construct('core', 'layout.user');
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
 
68 68
 			// Code integrity notification
69 69
 			$integrityChecker = \OC::$server->getIntegrityCodeChecker();
70
-			if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
70
+			if (\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
71 71
 				\OCP\Util::addScript('core', 'integritycheck-failed-notification');
72 72
 			}
73 73
 
74 74
 			// Add navigation entry
75
-			$this->assign( 'application', '');
76
-			$this->assign( 'appid', $appId );
75
+			$this->assign('application', '');
76
+			$this->assign('appid', $appId);
77 77
 			$navigation = \OC_App::getNavigation();
78
-			$this->assign( 'navigation', $navigation);
78
+			$this->assign('navigation', $navigation);
79 79
 			$navigation = \OC_App::getHeaderNavigation();
80
-			$this->assign( 'headernavigation', $navigation);
80
+			$this->assign('headernavigation', $navigation);
81 81
 			$settingsNavigation = \OC_App::getSettingsNavigation();
82
-			$this->assign( 'settingsnavigation', $settingsNavigation);
83
-			foreach($navigation as $entry) {
82
+			$this->assign('settingsnavigation', $settingsNavigation);
83
+			foreach ($navigation as $entry) {
84 84
 				if ($entry['active']) {
85
-					$this->assign( 'application', $entry['name'] );
85
+					$this->assign('application', $entry['name']);
86 86
 					break;
87 87
 				}
88 88
 			}
89 89
 			
90
-			foreach($settingsNavigation as $entry) {
90
+			foreach ($settingsNavigation as $entry) {
91 91
 				if ($entry['active']) {
92
-					$this->assign( 'application', $entry['name'] );
92
+					$this->assign('application', $entry['name']);
93 93
 					break;
94 94
 				}
95 95
 			}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		// Send the language to our layouts
124 124
 		$this->assign('language', \OC::$server->getL10NFactory()->findLanguage());
125 125
 
126
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
126
+		if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
127 127
 			if (empty(self::$versionHash)) {
128 128
 				$v = \OC_App::getAppVersions();
129 129
 				$v['core'] = implode('.', \OCP\Util::getVersion());
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
 				$this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
155 155
 			}
156 156
 		}
157
-		foreach($jsFiles as $info) {
157
+		foreach ($jsFiles as $info) {
158 158
 			$web = $info[1];
159 159
 			$file = $info[2];
160
-			$this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
160
+			$this->append('jsfiles', $web.'/'.$file.$this->getVersionHashSuffix());
161 161
 		}
162 162
 
163 163
 		try {
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
 		// Do not initialise scss appdata until we have a fully installed instance
170 170
 		// Do not load scss for update, errors, installation or login page
171
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)
171
+		if (\OC::$server->getSystemConfig()->getValue('installed', false)
172 172
 			&& !\OCP\Util::needUpgrade()
173 173
 			&& $pathInfo !== ''
174 174
 			&& !preg_match('/^\/login/', $pathInfo)) {
@@ -183,25 +183,25 @@  discard block
 block discarded – undo
183 183
 		$this->assign('cssfiles', array());
184 184
 		$this->assign('printcssfiles', []);
185 185
 		$this->assign('versionHash', self::$versionHash);
186
-		foreach($cssFiles as $info) {
186
+		foreach ($cssFiles as $info) {
187 187
 			$web = $info[1];
188 188
 			$file = $info[2];
189 189
 
190 190
 			if (substr($file, -strlen('print.css')) === 'print.css') {
191
-				$this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
191
+				$this->append('printcssfiles', $web.'/'.$file.$this->getVersionHashSuffix());
192 192
 			} else {
193
-				$this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix()  );
193
+				$this->append('cssfiles', $web.'/'.$file.$this->getVersionHashSuffix());
194 194
 			}
195 195
 		}
196 196
 	}
197 197
 
198 198
 	protected function getVersionHashSuffix() {
199
-		if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
199
+		if (\OC::$server->getConfig()->getSystemValue('debug', false)) {
200 200
 			// allows chrome workspace mapping in debug mode
201 201
 			return "";
202 202
 		}
203 203
 
204
-		return '?v=' . self::$versionHash;
204
+		return '?v='.self::$versionHash;
205 205
 	}
206 206
 
207 207
 	/**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		// Read the selected theme from the config file
213 213
 		$theme = \OC_Util::getTheme();
214 214
 
215
-		if($compileScss) {
215
+		if ($compileScss) {
216 216
 			/** @var \OC\Memcache\Factory $cache */
217 217
 			$cache = \OC::$server->query('MemCacheFactory');
218 218
 			$SCSSCacher = new SCSSCacher(
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 		$locator = new \OC\Template\CSSResourceLocator(
231 231
 			\OC::$server->getLogger(),
232 232
 			$theme,
233
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
234
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
233
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
234
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
235 235
 			$SCSSCacher);
236 236
 		$locator->find($styles);
237 237
 		return $locator->getResources();
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 		$locator = new \OC\Template\JSResourceLocator(
249 249
 			\OC::$server->getLogger(),
250 250
 			$theme,
251
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
252
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ));
251
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
252
+			array(\OC::$SERVERROOT => \OC::$WEBROOT));
253 253
 		$locator->find($scripts);
254 254
 		return $locator->getResources();
255 255
 	}
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 */
263 263
 	public static function convertToRelativePath($filePath) {
264 264
 		$relativePath = explode(\OC::$SERVERROOT, $filePath);
265
-		if(count($relativePath) !== 2) {
265
+		if (count($relativePath) !== 2) {
266 266
 			throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
267 267
 		}
268 268
 
Please login to merge, or discard this patch.