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