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