Completed
Pull Request — master (#6451)
by Julius
27:38 queued 11:33
created
lib/private/URLGenerator.php 2 patches
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -44,208 +44,208 @@
 block discarded – undo
44 44
  * Class to generate URLs
45 45
  */
46 46
 class URLGenerator implements IURLGenerator {
47
-	/** @var IConfig */
48
-	private $config;
49
-	/** @var ICacheFactory */
50
-	private $cacheFactory;
51
-	/** @var IRequest */
52
-	private $request;
53
-
54
-	/**
55
-	 * @param IConfig $config
56
-	 * @param ICacheFactory $cacheFactory
57
-	 * @param IRequest $request
58
-	 */
59
-	public function __construct(IConfig $config,
60
-								ICacheFactory $cacheFactory,
61
-								IRequest $request) {
62
-		$this->config = $config;
63
-		$this->cacheFactory = $cacheFactory;
64
-		$this->request = $request;
65
-	}
66
-
67
-	/**
68
-	 * Creates an url using a defined route
69
-	 * @param string $route
70
-	 * @param array $parameters args with param=>value, will be appended to the returned url
71
-	 * @return string the url
72
-	 *
73
-	 * Returns a url to the given route.
74
-	 */
75
-	public function linkToRoute($route, $parameters = array()) {
76
-		// TODO: mock router
77
-		$urlLinkTo = \OC::$server->getRouter()->generate($route, $parameters);
78
-		return $urlLinkTo;
79
-	}
80
-
81
-	/**
82
-	 * Creates an absolute url using a defined route
83
-	 * @param string $routeName
84
-	 * @param array $arguments args with param=>value, will be appended to the returned url
85
-	 * @return string the url
86
-	 *
87
-	 * Returns an absolute url to the given route.
88
-	 */
89
-	public function linkToRouteAbsolute($routeName, $arguments = array()) {
90
-		return $this->getAbsoluteURL($this->linkToRoute($routeName, $arguments));
91
-	}
92
-
93
-	/**
94
-	 * Creates an url
95
-	 * @param string $app app
96
-	 * @param string $file file
97
-	 * @param array $args array with param=>value, will be appended to the returned url
98
-	 *    The value of $args will be urlencoded
99
-	 * @return string the url
100
-	 *
101
-	 * Returns a url to the given app and file.
102
-	 */
103
-	public function linkTo( $app, $file, $args = array() ) {
104
-		$frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true');
105
-
106
-		if( $app != '' ) {
107
-			$app_path = \OC_App::getAppPath($app);
108
-			// Check if the app is in the app folder
109
-			if ($app_path && file_exists($app_path . '/' . $file)) {
110
-				if (substr($file, -3) == 'php') {
111
-
112
-					$urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app;
113
-					if ($frontControllerActive) {
114
-						$urlLinkTo = \OC::$WEBROOT . '/apps/' . $app;
115
-					}
116
-					$urlLinkTo .= ($file != 'index.php') ? '/' . $file : '';
117
-				} else {
118
-					$urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file;
119
-				}
120
-			} else {
121
-				$urlLinkTo = \OC::$WEBROOT . '/' . $app . '/' . $file;
122
-			}
123
-		} else {
124
-			if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) {
125
-				$urlLinkTo = \OC::$WEBROOT . '/core/' . $file;
126
-			} else {
127
-				if ($frontControllerActive && $file === 'index.php') {
128
-					$urlLinkTo = \OC::$WEBROOT . '/';
129
-				} else {
130
-					$urlLinkTo = \OC::$WEBROOT . '/' . $file;
131
-				}
132
-			}
133
-		}
134
-
135
-		if ($args && $query = http_build_query($args, '', '&')) {
136
-			$urlLinkTo .= '?' . $query;
137
-		}
138
-
139
-		return $urlLinkTo;
140
-	}
141
-
142
-	/**
143
-	 * Creates path to an image
144
-	 * @param string $app app
145
-	 * @param string $image image name
146
-	 * @throws \RuntimeException If the image does not exist
147
-	 * @return string the url
148
-	 *
149
-	 * Returns the path to the image.
150
-	 */
151
-	public function imagePath($app, $image) {
152
-		$cache = $this->cacheFactory->create('imagePath-'.md5($this->getBaseUrl()).'-');
153
-		$cacheKey = $app.'-'.$image;
154
-		if($key = $cache->get($cacheKey)) {
155
-			return $key;
156
-		}
157
-
158
-		// Read the selected theme from the config file
159
-		$theme = \OC_Util::getTheme();
160
-
161
-		//if a theme has a png but not an svg always use the png
162
-		$basename = substr(basename($image),0,-4);
163
-
164
-		$appPath = \OC_App::getAppPath($app);
165
-
166
-		// Check if the app is in the app folder
167
-		$path = '';
168
-		$themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming');
169
-		$themingImagePath = false;
170
-		if($themingEnabled) {
171
-			$themingImagePath = \OC::$server->getThemingDefaults()->replaceImagePath($app, $image);
172
-		}
173
-
174
-		if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) {
175
-			$path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image";
176
-		} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg")
177
-			&& file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) {
178
-			$path =  \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png";
179
-		} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) {
180
-			$path =  \OC::$WEBROOT . "/themes/$theme/$app/img/$image";
181
-		} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg")
182
-			&& file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) {
183
-			$path =  \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png";
184
-		} elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) {
185
-			$path =  \OC::$WEBROOT . "/themes/$theme/core/img/$image";
186
-		} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg")
187
-			&& file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) {
188
-			$path =  \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
189
-		} elseif($themingEnabled && $themingImagePath) {
190
-			$path = $themingImagePath;
191
-		} elseif ($appPath && file_exists($appPath . "/img/$image")) {
192
-			$path =  \OC_App::getAppWebPath($app) . "/img/$image";
193
-		} elseif ($appPath && !file_exists($appPath . "/img/$basename.svg")
194
-			&& file_exists($appPath . "/img/$basename.png")) {
195
-			$path =  \OC_App::getAppWebPath($app) . "/img/$basename.png";
196
-		} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) {
197
-			$path =  \OC::$WEBROOT . "/$app/img/$image";
198
-		} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg")
199
-				&& file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) {
200
-			$path =  \OC::$WEBROOT . "/$app/img/$basename.png";
201
-		} elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) {
202
-			$path =  \OC::$WEBROOT . "/core/img/$image";
203
-		} elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg")
204
-			&& file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) {
205
-			$path =  \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
206
-		}
207
-
208
-		if($path !== '') {
209
-			$cache->set($cacheKey, $path);
210
-			return $path;
211
-		} else {
212
-			throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT);
213
-		}
214
-	}
215
-
216
-
217
-	/**
218
-	 * Makes an URL absolute
219
-	 * @param string $url the url in the ownCloud host
220
-	 * @return string the absolute version of the url
221
-	 */
222
-	public function getAbsoluteURL($url) {
223
-		$separator = $url[0] === '/' ? '' : '/';
224
-
225
-		if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
226
-			return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/');
227
-		}
228
-		// The ownCloud web root can already be prepended.
229
-		if(substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT) {
230
-			$url = substr($url, strlen(\OC::$WEBROOT));
231
-		}
232
-
233
-		return $this->getBaseUrl() . $separator . $url;
234
-	}
235
-
236
-	/**
237
-	 * @param string $key
238
-	 * @return string url to the online documentation
239
-	 */
240
-	public function linkToDocs($key) {
241
-		$theme = \OC::$server->getThemingDefaults();
242
-		return $theme->buildDocLinkToKey($key);
243
-	}
244
-
245
-	/**
246
-	 * @return string base url of the current request
247
-	 */
248
-	public function getBaseUrl() {
249
-		return $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT;
250
-	}
47
+    /** @var IConfig */
48
+    private $config;
49
+    /** @var ICacheFactory */
50
+    private $cacheFactory;
51
+    /** @var IRequest */
52
+    private $request;
53
+
54
+    /**
55
+     * @param IConfig $config
56
+     * @param ICacheFactory $cacheFactory
57
+     * @param IRequest $request
58
+     */
59
+    public function __construct(IConfig $config,
60
+                                ICacheFactory $cacheFactory,
61
+                                IRequest $request) {
62
+        $this->config = $config;
63
+        $this->cacheFactory = $cacheFactory;
64
+        $this->request = $request;
65
+    }
66
+
67
+    /**
68
+     * Creates an url using a defined route
69
+     * @param string $route
70
+     * @param array $parameters args with param=>value, will be appended to the returned url
71
+     * @return string the url
72
+     *
73
+     * Returns a url to the given route.
74
+     */
75
+    public function linkToRoute($route, $parameters = array()) {
76
+        // TODO: mock router
77
+        $urlLinkTo = \OC::$server->getRouter()->generate($route, $parameters);
78
+        return $urlLinkTo;
79
+    }
80
+
81
+    /**
82
+     * Creates an absolute url using a defined route
83
+     * @param string $routeName
84
+     * @param array $arguments args with param=>value, will be appended to the returned url
85
+     * @return string the url
86
+     *
87
+     * Returns an absolute url to the given route.
88
+     */
89
+    public function linkToRouteAbsolute($routeName, $arguments = array()) {
90
+        return $this->getAbsoluteURL($this->linkToRoute($routeName, $arguments));
91
+    }
92
+
93
+    /**
94
+     * Creates an url
95
+     * @param string $app app
96
+     * @param string $file file
97
+     * @param array $args array with param=>value, will be appended to the returned url
98
+     *    The value of $args will be urlencoded
99
+     * @return string the url
100
+     *
101
+     * Returns a url to the given app and file.
102
+     */
103
+    public function linkTo( $app, $file, $args = array() ) {
104
+        $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true');
105
+
106
+        if( $app != '' ) {
107
+            $app_path = \OC_App::getAppPath($app);
108
+            // Check if the app is in the app folder
109
+            if ($app_path && file_exists($app_path . '/' . $file)) {
110
+                if (substr($file, -3) == 'php') {
111
+
112
+                    $urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app;
113
+                    if ($frontControllerActive) {
114
+                        $urlLinkTo = \OC::$WEBROOT . '/apps/' . $app;
115
+                    }
116
+                    $urlLinkTo .= ($file != 'index.php') ? '/' . $file : '';
117
+                } else {
118
+                    $urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file;
119
+                }
120
+            } else {
121
+                $urlLinkTo = \OC::$WEBROOT . '/' . $app . '/' . $file;
122
+            }
123
+        } else {
124
+            if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) {
125
+                $urlLinkTo = \OC::$WEBROOT . '/core/' . $file;
126
+            } else {
127
+                if ($frontControllerActive && $file === 'index.php') {
128
+                    $urlLinkTo = \OC::$WEBROOT . '/';
129
+                } else {
130
+                    $urlLinkTo = \OC::$WEBROOT . '/' . $file;
131
+                }
132
+            }
133
+        }
134
+
135
+        if ($args && $query = http_build_query($args, '', '&')) {
136
+            $urlLinkTo .= '?' . $query;
137
+        }
138
+
139
+        return $urlLinkTo;
140
+    }
141
+
142
+    /**
143
+     * Creates path to an image
144
+     * @param string $app app
145
+     * @param string $image image name
146
+     * @throws \RuntimeException If the image does not exist
147
+     * @return string the url
148
+     *
149
+     * Returns the path to the image.
150
+     */
151
+    public function imagePath($app, $image) {
152
+        $cache = $this->cacheFactory->create('imagePath-'.md5($this->getBaseUrl()).'-');
153
+        $cacheKey = $app.'-'.$image;
154
+        if($key = $cache->get($cacheKey)) {
155
+            return $key;
156
+        }
157
+
158
+        // Read the selected theme from the config file
159
+        $theme = \OC_Util::getTheme();
160
+
161
+        //if a theme has a png but not an svg always use the png
162
+        $basename = substr(basename($image),0,-4);
163
+
164
+        $appPath = \OC_App::getAppPath($app);
165
+
166
+        // Check if the app is in the app folder
167
+        $path = '';
168
+        $themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming');
169
+        $themingImagePath = false;
170
+        if($themingEnabled) {
171
+            $themingImagePath = \OC::$server->getThemingDefaults()->replaceImagePath($app, $image);
172
+        }
173
+
174
+        if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) {
175
+            $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image";
176
+        } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg")
177
+            && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) {
178
+            $path =  \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png";
179
+        } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) {
180
+            $path =  \OC::$WEBROOT . "/themes/$theme/$app/img/$image";
181
+        } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg")
182
+            && file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) {
183
+            $path =  \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png";
184
+        } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) {
185
+            $path =  \OC::$WEBROOT . "/themes/$theme/core/img/$image";
186
+        } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg")
187
+            && file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) {
188
+            $path =  \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
189
+        } elseif($themingEnabled && $themingImagePath) {
190
+            $path = $themingImagePath;
191
+        } elseif ($appPath && file_exists($appPath . "/img/$image")) {
192
+            $path =  \OC_App::getAppWebPath($app) . "/img/$image";
193
+        } elseif ($appPath && !file_exists($appPath . "/img/$basename.svg")
194
+            && file_exists($appPath . "/img/$basename.png")) {
195
+            $path =  \OC_App::getAppWebPath($app) . "/img/$basename.png";
196
+        } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) {
197
+            $path =  \OC::$WEBROOT . "/$app/img/$image";
198
+        } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg")
199
+                && file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) {
200
+            $path =  \OC::$WEBROOT . "/$app/img/$basename.png";
201
+        } elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) {
202
+            $path =  \OC::$WEBROOT . "/core/img/$image";
203
+        } elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg")
204
+            && file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) {
205
+            $path =  \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
206
+        }
207
+
208
+        if($path !== '') {
209
+            $cache->set($cacheKey, $path);
210
+            return $path;
211
+        } else {
212
+            throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT);
213
+        }
214
+    }
215
+
216
+
217
+    /**
218
+     * Makes an URL absolute
219
+     * @param string $url the url in the ownCloud host
220
+     * @return string the absolute version of the url
221
+     */
222
+    public function getAbsoluteURL($url) {
223
+        $separator = $url[0] === '/' ? '' : '/';
224
+
225
+        if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
226
+            return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/');
227
+        }
228
+        // The ownCloud web root can already be prepended.
229
+        if(substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT) {
230
+            $url = substr($url, strlen(\OC::$WEBROOT));
231
+        }
232
+
233
+        return $this->getBaseUrl() . $separator . $url;
234
+    }
235
+
236
+    /**
237
+     * @param string $key
238
+     * @return string url to the online documentation
239
+     */
240
+    public function linkToDocs($key) {
241
+        $theme = \OC::$server->getThemingDefaults();
242
+        return $theme->buildDocLinkToKey($key);
243
+    }
244
+
245
+    /**
246
+     * @return string base url of the current request
247
+     */
248
+    public function getBaseUrl() {
249
+        return $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT;
250
+    }
251 251
 }
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -100,40 +100,40 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * Returns a url to the given app and file.
102 102
 	 */
103
-	public function linkTo( $app, $file, $args = array() ) {
103
+	public function linkTo($app, $file, $args = array()) {
104 104
 		$frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true');
105 105
 
106
-		if( $app != '' ) {
106
+		if ($app != '') {
107 107
 			$app_path = \OC_App::getAppPath($app);
108 108
 			// Check if the app is in the app folder
109
-			if ($app_path && file_exists($app_path . '/' . $file)) {
109
+			if ($app_path && file_exists($app_path.'/'.$file)) {
110 110
 				if (substr($file, -3) == 'php') {
111 111
 
112
-					$urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app;
112
+					$urlLinkTo = \OC::$WEBROOT.'/index.php/apps/'.$app;
113 113
 					if ($frontControllerActive) {
114
-						$urlLinkTo = \OC::$WEBROOT . '/apps/' . $app;
114
+						$urlLinkTo = \OC::$WEBROOT.'/apps/'.$app;
115 115
 					}
116
-					$urlLinkTo .= ($file != 'index.php') ? '/' . $file : '';
116
+					$urlLinkTo .= ($file != 'index.php') ? '/'.$file : '';
117 117
 				} else {
118
-					$urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file;
118
+					$urlLinkTo = \OC_App::getAppWebPath($app).'/'.$file;
119 119
 				}
120 120
 			} else {
121
-				$urlLinkTo = \OC::$WEBROOT . '/' . $app . '/' . $file;
121
+				$urlLinkTo = \OC::$WEBROOT.'/'.$app.'/'.$file;
122 122
 			}
123 123
 		} else {
124
-			if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) {
125
-				$urlLinkTo = \OC::$WEBROOT . '/core/' . $file;
124
+			if (file_exists(\OC::$SERVERROOT.'/core/'.$file)) {
125
+				$urlLinkTo = \OC::$WEBROOT.'/core/'.$file;
126 126
 			} else {
127 127
 				if ($frontControllerActive && $file === 'index.php') {
128
-					$urlLinkTo = \OC::$WEBROOT . '/';
128
+					$urlLinkTo = \OC::$WEBROOT.'/';
129 129
 				} else {
130
-					$urlLinkTo = \OC::$WEBROOT . '/' . $file;
130
+					$urlLinkTo = \OC::$WEBROOT.'/'.$file;
131 131
 				}
132 132
 			}
133 133
 		}
134 134
 
135 135
 		if ($args && $query = http_build_query($args, '', '&')) {
136
-			$urlLinkTo .= '?' . $query;
136
+			$urlLinkTo .= '?'.$query;
137 137
 		}
138 138
 
139 139
 		return $urlLinkTo;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	public function imagePath($app, $image) {
152 152
 		$cache = $this->cacheFactory->create('imagePath-'.md5($this->getBaseUrl()).'-');
153 153
 		$cacheKey = $app.'-'.$image;
154
-		if($key = $cache->get($cacheKey)) {
154
+		if ($key = $cache->get($cacheKey)) {
155 155
 			return $key;
156 156
 		}
157 157
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		$theme = \OC_Util::getTheme();
160 160
 
161 161
 		//if a theme has a png but not an svg always use the png
162
-		$basename = substr(basename($image),0,-4);
162
+		$basename = substr(basename($image), 0, -4);
163 163
 
164 164
 		$appPath = \OC_App::getAppPath($app);
165 165
 
@@ -167,49 +167,49 @@  discard block
 block discarded – undo
167 167
 		$path = '';
168 168
 		$themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming');
169 169
 		$themingImagePath = false;
170
-		if($themingEnabled) {
170
+		if ($themingEnabled) {
171 171
 			$themingImagePath = \OC::$server->getThemingDefaults()->replaceImagePath($app, $image);
172 172
 		}
173 173
 
174
-		if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) {
175
-			$path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image";
176
-		} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg")
177
-			&& file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) {
178
-			$path =  \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png";
179
-		} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) {
180
-			$path =  \OC::$WEBROOT . "/themes/$theme/$app/img/$image";
181
-		} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg")
182
-			&& file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) {
183
-			$path =  \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png";
184
-		} elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) {
185
-			$path =  \OC::$WEBROOT . "/themes/$theme/core/img/$image";
186
-		} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg")
187
-			&& file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) {
188
-			$path =  \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
189
-		} elseif($themingEnabled && $themingImagePath) {
174
+		if (file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$image")) {
175
+			$path = \OC::$WEBROOT."/themes/$theme/apps/$app/img/$image";
176
+		} elseif (!file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$basename.svg")
177
+			&& file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$basename.png")) {
178
+			$path = \OC::$WEBROOT."/themes/$theme/apps/$app/img/$basename.png";
179
+		} elseif (!empty($app) and file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$image")) {
180
+			$path = \OC::$WEBROOT."/themes/$theme/$app/img/$image";
181
+		} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$basename.svg")
182
+			&& file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$basename.png"))) {
183
+			$path = \OC::$WEBROOT."/themes/$theme/$app/img/$basename.png";
184
+		} elseif (file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$image")) {
185
+			$path = \OC::$WEBROOT."/themes/$theme/core/img/$image";
186
+		} elseif (!file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$basename.svg")
187
+			&& file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$basename.png")) {
188
+			$path = \OC::$WEBROOT."/themes/$theme/core/img/$basename.png";
189
+		} elseif ($themingEnabled && $themingImagePath) {
190 190
 			$path = $themingImagePath;
191
-		} elseif ($appPath && file_exists($appPath . "/img/$image")) {
192
-			$path =  \OC_App::getAppWebPath($app) . "/img/$image";
193
-		} elseif ($appPath && !file_exists($appPath . "/img/$basename.svg")
194
-			&& file_exists($appPath . "/img/$basename.png")) {
195
-			$path =  \OC_App::getAppWebPath($app) . "/img/$basename.png";
196
-		} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) {
197
-			$path =  \OC::$WEBROOT . "/$app/img/$image";
198
-		} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg")
199
-				&& file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) {
200
-			$path =  \OC::$WEBROOT . "/$app/img/$basename.png";
201
-		} elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) {
202
-			$path =  \OC::$WEBROOT . "/core/img/$image";
203
-		} elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg")
204
-			&& file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) {
205
-			$path =  \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
191
+		} elseif ($appPath && file_exists($appPath."/img/$image")) {
192
+			$path = \OC_App::getAppWebPath($app)."/img/$image";
193
+		} elseif ($appPath && !file_exists($appPath."/img/$basename.svg")
194
+			&& file_exists($appPath."/img/$basename.png")) {
195
+			$path = \OC_App::getAppWebPath($app)."/img/$basename.png";
196
+		} elseif (!empty($app) and file_exists(\OC::$SERVERROOT."/$app/img/$image")) {
197
+			$path = \OC::$WEBROOT."/$app/img/$image";
198
+		} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT."/$app/img/$basename.svg")
199
+				&& file_exists(\OC::$SERVERROOT."/$app/img/$basename.png"))) {
200
+			$path = \OC::$WEBROOT."/$app/img/$basename.png";
201
+		} elseif (file_exists(\OC::$SERVERROOT."/core/img/$image")) {
202
+			$path = \OC::$WEBROOT."/core/img/$image";
203
+		} elseif (!file_exists(\OC::$SERVERROOT."/core/img/$basename.svg")
204
+			&& file_exists(\OC::$SERVERROOT."/core/img/$basename.png")) {
205
+			$path = \OC::$WEBROOT."/themes/$theme/core/img/$basename.png";
206 206
 		}
207 207
 
208
-		if($path !== '') {
208
+		if ($path !== '') {
209 209
 			$cache->set($cacheKey, $path);
210 210
 			return $path;
211 211
 		} else {
212
-			throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT);
212
+			throw new RuntimeException('image not found: image:'.$image.' webroot:'.\OC::$WEBROOT.' serverroot:'.\OC::$SERVERROOT);
213 213
 		}
214 214
 	}
215 215
 
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
 		$separator = $url[0] === '/' ? '' : '/';
224 224
 
225 225
 		if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
226
-			return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/');
226
+			return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/').'/'.ltrim($url, '/');
227 227
 		}
228 228
 		// The ownCloud web root can already be prepended.
229
-		if(substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT) {
229
+		if (substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT) {
230 230
 			$url = substr($url, strlen(\OC::$WEBROOT));
231 231
 		}
232 232
 
233
-		return $this->getBaseUrl() . $separator . $url;
233
+		return $this->getBaseUrl().$separator.$url;
234 234
 	}
235 235
 
236 236
 	/**
@@ -246,6 +246,6 @@  discard block
 block discarded – undo
246 246
 	 * @return string base url of the current request
247 247
 	 */
248 248
 	public function getBaseUrl() {
249
-		return $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT;
249
+		return $this->request->getServerProtocol().'://'.$this->request->getServerHost().\OC::$WEBROOT;
250 250
 	}
251 251
 }
Please login to merge, or discard this patch.
apps/theming/appinfo/routes.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -25,64 +25,64 @@
 block discarded – undo
25 25
  */
26 26
 
27 27
 return ['routes' => [
28
-	[
29
-		'name' => 'Theming#updateStylesheet',
30
-		'url' => '/ajax/updateStylesheet',
31
-		'verb' => 'POST'
32
-	],
33
-	[
34
-		'name' => 'Theming#undo',
35
-		'url' => '/ajax/undoChanges',
36
-		'verb' => 'POST'
37
-	],
38
-	[
39
-		'name' => 'Theming#updateLogo',
40
-		'url' => '/ajax/updateLogo',
41
-		'verb' => 'POST'
42
-	],
43
-	[
44
-		'name' => 'Theming#getStylesheet',
45
-		'url' => '/styles',
46
-		'verb' => 'GET',
47
-	],
48
-	[
49
-		'name' => 'Theming#getLogo',
50
-		'url' => '/logo',
51
-		'verb' => 'GET',
52
-	],
53
-	[
54
-		'name' => 'Theming#getLoginBackground',
55
-		'url' => '/loginbackground',
56
-		'verb' => 'GET',
57
-	],
58
-	[
59
-		'name' => 'Theming#getJavascript',
60
-		'url' => '/js/theming',
61
-		'verb' => 'GET',
62
-	],
63
-	[
64
-		'name' => 'Theming#getManifest',
65
-		'url' => '/manifest/{app}',
66
-		'verb' => 'GET',
67
-		'defaults' => array('app' => 'core')
68
-	],
69
-	[
70
-		'name'	=> 'Icon#getFavicon',
71
-		'url' => '/favicon/{app}',
72
-		'verb' => 'GET',
73
-		'defaults' => array('app' => 'core'),
74
-	],
75
-	[
76
-		'name'	=> 'Icon#getTouchIcon',
77
-		'url' => '/icon/{app}',
78
-		'verb' => 'GET',
79
-		'defaults' => array('app' => 'core'),
80
-	],
81
-	[
82
-		'name'	=> 'Icon#getThemedIcon',
83
-		'url' => '/img/{app}/{image}',
84
-		'verb' => 'GET',
85
-		'requirements' => array('image' => '.+')
86
-	],
28
+    [
29
+        'name' => 'Theming#updateStylesheet',
30
+        'url' => '/ajax/updateStylesheet',
31
+        'verb' => 'POST'
32
+    ],
33
+    [
34
+        'name' => 'Theming#undo',
35
+        'url' => '/ajax/undoChanges',
36
+        'verb' => 'POST'
37
+    ],
38
+    [
39
+        'name' => 'Theming#updateLogo',
40
+        'url' => '/ajax/updateLogo',
41
+        'verb' => 'POST'
42
+    ],
43
+    [
44
+        'name' => 'Theming#getStylesheet',
45
+        'url' => '/styles',
46
+        'verb' => 'GET',
47
+    ],
48
+    [
49
+        'name' => 'Theming#getLogo',
50
+        'url' => '/logo',
51
+        'verb' => 'GET',
52
+    ],
53
+    [
54
+        'name' => 'Theming#getLoginBackground',
55
+        'url' => '/loginbackground',
56
+        'verb' => 'GET',
57
+    ],
58
+    [
59
+        'name' => 'Theming#getJavascript',
60
+        'url' => '/js/theming',
61
+        'verb' => 'GET',
62
+    ],
63
+    [
64
+        'name' => 'Theming#getManifest',
65
+        'url' => '/manifest/{app}',
66
+        'verb' => 'GET',
67
+        'defaults' => array('app' => 'core')
68
+    ],
69
+    [
70
+        'name'	=> 'Icon#getFavicon',
71
+        'url' => '/favicon/{app}',
72
+        'verb' => 'GET',
73
+        'defaults' => array('app' => 'core'),
74
+    ],
75
+    [
76
+        'name'	=> 'Icon#getTouchIcon',
77
+        'url' => '/icon/{app}',
78
+        'verb' => 'GET',
79
+        'defaults' => array('app' => 'core'),
80
+    ],
81
+    [
82
+        'name'	=> 'Icon#getThemedIcon',
83
+        'url' => '/img/{app}/{image}',
84
+        'verb' => 'GET',
85
+        'requirements' => array('image' => '.+')
86
+    ],
87 87
 ]];
88 88
 
Please login to merge, or discard this patch.
apps/theming/lib/Controller/ThemingController.php 2 patches
Indentation   +366 added lines, -366 removed lines patch added patch discarded remove patch
@@ -57,357 +57,357 @@  discard block
 block discarded – undo
57 57
  * @package OCA\Theming\Controller
58 58
  */
59 59
 class ThemingController extends Controller {
60
-	/** @var ThemingDefaults */
61
-	private $themingDefaults;
62
-	/** @var Util */
63
-	private $util;
64
-	/** @var ITimeFactory */
65
-	private $timeFactory;
66
-	/** @var IL10N */
67
-	private $l10n;
68
-	/** @var IConfig */
69
-	private $config;
70
-	/** @var ITempManager */
71
-	private $tempManager;
72
-	/** @var IAppData */
73
-	private $appData;
74
-	/** @var SCSSCacher */
75
-	private $scssCacher;
76
-	/** @var IURLGenerator */
77
-	private $urlGenerator;
60
+    /** @var ThemingDefaults */
61
+    private $themingDefaults;
62
+    /** @var Util */
63
+    private $util;
64
+    /** @var ITimeFactory */
65
+    private $timeFactory;
66
+    /** @var IL10N */
67
+    private $l10n;
68
+    /** @var IConfig */
69
+    private $config;
70
+    /** @var ITempManager */
71
+    private $tempManager;
72
+    /** @var IAppData */
73
+    private $appData;
74
+    /** @var SCSSCacher */
75
+    private $scssCacher;
76
+    /** @var IURLGenerator */
77
+    private $urlGenerator;
78 78
 
79
-	/**
80
-	 * ThemingController constructor.
81
-	 *
82
-	 * @param string $appName
83
-	 * @param IRequest $request
84
-	 * @param IConfig $config
85
-	 * @param ThemingDefaults $themingDefaults
86
-	 * @param Util $util
87
-	 * @param ITimeFactory $timeFactory
88
-	 * @param IL10N $l
89
-	 * @param ITempManager $tempManager
90
-	 * @param IAppData $appData
91
-	 * @param SCSSCacher $scssCacher
92
-	 * @param IURLGenerator $urlGenerator
93
-	 */
94
-	public function __construct(
95
-		$appName,
96
-		IRequest $request,
97
-		IConfig $config,
98
-		ThemingDefaults $themingDefaults,
99
-		Util $util,
100
-		ITimeFactory $timeFactory,
101
-		IL10N $l,
102
-		ITempManager $tempManager,
103
-		IAppData $appData,
104
-		SCSSCacher $scssCacher,
105
-		IURLGenerator $urlGenerator
106
-	) {
107
-		parent::__construct($appName, $request);
79
+    /**
80
+     * ThemingController constructor.
81
+     *
82
+     * @param string $appName
83
+     * @param IRequest $request
84
+     * @param IConfig $config
85
+     * @param ThemingDefaults $themingDefaults
86
+     * @param Util $util
87
+     * @param ITimeFactory $timeFactory
88
+     * @param IL10N $l
89
+     * @param ITempManager $tempManager
90
+     * @param IAppData $appData
91
+     * @param SCSSCacher $scssCacher
92
+     * @param IURLGenerator $urlGenerator
93
+     */
94
+    public function __construct(
95
+        $appName,
96
+        IRequest $request,
97
+        IConfig $config,
98
+        ThemingDefaults $themingDefaults,
99
+        Util $util,
100
+        ITimeFactory $timeFactory,
101
+        IL10N $l,
102
+        ITempManager $tempManager,
103
+        IAppData $appData,
104
+        SCSSCacher $scssCacher,
105
+        IURLGenerator $urlGenerator
106
+    ) {
107
+        parent::__construct($appName, $request);
108 108
 
109
-		$this->themingDefaults = $themingDefaults;
110
-		$this->util = $util;
111
-		$this->timeFactory = $timeFactory;
112
-		$this->l10n = $l;
113
-		$this->config = $config;
114
-		$this->tempManager = $tempManager;
115
-		$this->appData = $appData;
116
-		$this->scssCacher = $scssCacher;
117
-		$this->urlGenerator = $urlGenerator;
118
-	}
109
+        $this->themingDefaults = $themingDefaults;
110
+        $this->util = $util;
111
+        $this->timeFactory = $timeFactory;
112
+        $this->l10n = $l;
113
+        $this->config = $config;
114
+        $this->tempManager = $tempManager;
115
+        $this->appData = $appData;
116
+        $this->scssCacher = $scssCacher;
117
+        $this->urlGenerator = $urlGenerator;
118
+    }
119 119
 
120
-	/**
121
-	 * @param string $setting
122
-	 * @param string $value
123
-	 * @return DataResponse
124
-	 * @internal param string $color
125
-	 */
126
-	public function updateStylesheet($setting, $value) {
127
-		$value = trim($value);
128
-		switch ($setting) {
129
-			case 'name':
130
-				if (strlen($value) > 250) {
131
-					return new DataResponse([
132
-						'data' => [
133
-							'message' => $this->l10n->t('The given name is too long'),
134
-						],
135
-						'status' => 'error'
136
-					]);
137
-				}
138
-				break;
139
-			case 'url':
140
-				if (strlen($value) > 500) {
141
-					return new DataResponse([
142
-						'data' => [
143
-							'message' => $this->l10n->t('The given web address is too long'),
144
-						],
145
-						'status' => 'error'
146
-					]);
147
-				}
148
-				break;
149
-			case 'slogan':
150
-				if (strlen($value) > 500) {
151
-					return new DataResponse([
152
-						'data' => [
153
-							'message' => $this->l10n->t('The given slogan is too long'),
154
-						],
155
-						'status' => 'error'
156
-					]);
157
-				}
158
-				break;
159
-			case 'color':
160
-				if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
161
-					return new DataResponse([
162
-						'data' => [
163
-							'message' => $this->l10n->t('The given color is invalid'),
164
-						],
165
-						'status' => 'error'
166
-					]);
167
-				}
168
-				break;
169
-		}
120
+    /**
121
+     * @param string $setting
122
+     * @param string $value
123
+     * @return DataResponse
124
+     * @internal param string $color
125
+     */
126
+    public function updateStylesheet($setting, $value) {
127
+        $value = trim($value);
128
+        switch ($setting) {
129
+            case 'name':
130
+                if (strlen($value) > 250) {
131
+                    return new DataResponse([
132
+                        'data' => [
133
+                            'message' => $this->l10n->t('The given name is too long'),
134
+                        ],
135
+                        'status' => 'error'
136
+                    ]);
137
+                }
138
+                break;
139
+            case 'url':
140
+                if (strlen($value) > 500) {
141
+                    return new DataResponse([
142
+                        'data' => [
143
+                            'message' => $this->l10n->t('The given web address is too long'),
144
+                        ],
145
+                        'status' => 'error'
146
+                    ]);
147
+                }
148
+                break;
149
+            case 'slogan':
150
+                if (strlen($value) > 500) {
151
+                    return new DataResponse([
152
+                        'data' => [
153
+                            'message' => $this->l10n->t('The given slogan is too long'),
154
+                        ],
155
+                        'status' => 'error'
156
+                    ]);
157
+                }
158
+                break;
159
+            case 'color':
160
+                if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
161
+                    return new DataResponse([
162
+                        'data' => [
163
+                            'message' => $this->l10n->t('The given color is invalid'),
164
+                        ],
165
+                        'status' => 'error'
166
+                    ]);
167
+                }
168
+                break;
169
+        }
170 170
 
171
-		$this->themingDefaults->set($setting, $value);
171
+        $this->themingDefaults->set($setting, $value);
172 172
 
173
-		// reprocess server scss for preview
174
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/server.scss', 'core');
173
+        // reprocess server scss for preview
174
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/server.scss', 'core');
175 175
 
176
-		return new DataResponse(
177
-			[
178
-				'data' =>
179
-					[
180
-						'message' => $this->l10n->t('Saved'),
181
-						'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
182
-					],
183
-				'status' => 'success'
184
-			]
185
-		);
186
-	}
176
+        return new DataResponse(
177
+            [
178
+                'data' =>
179
+                    [
180
+                        'message' => $this->l10n->t('Saved'),
181
+                        'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
182
+                    ],
183
+                'status' => 'success'
184
+            ]
185
+        );
186
+    }
187 187
 
188
-	/**
189
-	 * Update the logos and background image
190
-	 *
191
-	 * @return DataResponse
192
-	 */
193
-	public function updateLogo() {
194
-		$backgroundColor = $this->request->getParam('backgroundColor', false);
195
-		if($backgroundColor) {
196
-			$this->themingDefaults->set('backgroundMime', 'backgroundColor');
197
-			return new DataResponse(
198
-				[
199
-					'data' =>
200
-						[
201
-							'name' => 'backgroundColor',
202
-							'message' => $this->l10n->t('Saved')
203
-						],
204
-					'status' => 'success'
205
-				]
206
-			);
207
-		}
208
-		$newLogo = $this->request->getUploadedFile('uploadlogo');
209
-		$newBackgroundLogo = $this->request->getUploadedFile('upload-login-background');
210
-		if (empty($newLogo) && empty($newBackgroundLogo)) {
211
-			return new DataResponse(
212
-				[
213
-					'data' => [
214
-						'message' => $this->l10n->t('No file uploaded')
215
-					]
216
-				],
217
-				Http::STATUS_UNPROCESSABLE_ENTITY
218
-			);
219
-		}
188
+    /**
189
+     * Update the logos and background image
190
+     *
191
+     * @return DataResponse
192
+     */
193
+    public function updateLogo() {
194
+        $backgroundColor = $this->request->getParam('backgroundColor', false);
195
+        if($backgroundColor) {
196
+            $this->themingDefaults->set('backgroundMime', 'backgroundColor');
197
+            return new DataResponse(
198
+                [
199
+                    'data' =>
200
+                        [
201
+                            'name' => 'backgroundColor',
202
+                            'message' => $this->l10n->t('Saved')
203
+                        ],
204
+                    'status' => 'success'
205
+                ]
206
+            );
207
+        }
208
+        $newLogo = $this->request->getUploadedFile('uploadlogo');
209
+        $newBackgroundLogo = $this->request->getUploadedFile('upload-login-background');
210
+        if (empty($newLogo) && empty($newBackgroundLogo)) {
211
+            return new DataResponse(
212
+                [
213
+                    'data' => [
214
+                        'message' => $this->l10n->t('No file uploaded')
215
+                    ]
216
+                ],
217
+                Http::STATUS_UNPROCESSABLE_ENTITY
218
+            );
219
+        }
220 220
 
221
-		$name = '';
222
-		try {
223
-			$folder = $this->appData->getFolder('images');
224
-		} catch (NotFoundException $e) {
225
-			$folder = $this->appData->newFolder('images');
226
-		}
221
+        $name = '';
222
+        try {
223
+            $folder = $this->appData->getFolder('images');
224
+        } catch (NotFoundException $e) {
225
+            $folder = $this->appData->newFolder('images');
226
+        }
227 227
 
228
-		if (!empty($newLogo)) {
229
-			$target = $folder->newFile('logo');
230
-			$target->putContent(file_get_contents($newLogo['tmp_name'], 'r'));
231
-			$this->themingDefaults->set('logoMime', $newLogo['type']);
232
-			$name = $newLogo['name'];
233
-		}
234
-		if (!empty($newBackgroundLogo)) {
235
-			$target = $folder->newFile('background');
236
-			$image = @imagecreatefromstring(file_get_contents($newBackgroundLogo['tmp_name'], 'r'));
237
-			if ($image === false) {
238
-				return new DataResponse(
239
-					[
240
-						'data' => [
241
-							'message' => $this->l10n->t('Unsupported image type'),
242
-						],
243
-						'status' => 'failure',
244
-					],
245
-					Http::STATUS_UNPROCESSABLE_ENTITY
246
-				);
247
-			}
228
+        if (!empty($newLogo)) {
229
+            $target = $folder->newFile('logo');
230
+            $target->putContent(file_get_contents($newLogo['tmp_name'], 'r'));
231
+            $this->themingDefaults->set('logoMime', $newLogo['type']);
232
+            $name = $newLogo['name'];
233
+        }
234
+        if (!empty($newBackgroundLogo)) {
235
+            $target = $folder->newFile('background');
236
+            $image = @imagecreatefromstring(file_get_contents($newBackgroundLogo['tmp_name'], 'r'));
237
+            if ($image === false) {
238
+                return new DataResponse(
239
+                    [
240
+                        'data' => [
241
+                            'message' => $this->l10n->t('Unsupported image type'),
242
+                        ],
243
+                        'status' => 'failure',
244
+                    ],
245
+                    Http::STATUS_UNPROCESSABLE_ENTITY
246
+                );
247
+            }
248 248
 
249
-			// Optimize the image since some people may upload images that will be
250
-			// either to big or are not progressive rendering.
251
-			$tmpFile = $this->tempManager->getTemporaryFile();
252
-			if (function_exists('imagescale')) {
253
-				// FIXME: Once PHP 5.5.0 is a requirement the above check can be removed
254
-				// Workaround for https://bugs.php.net/bug.php?id=65171
255
-				$newHeight = imagesy($image) / (imagesx($image) / 1920);
256
-				$image = imagescale($image, 1920, $newHeight);
257
-			}
258
-			imageinterlace($image, 1);
259
-			imagejpeg($image, $tmpFile, 75);
260
-			imagedestroy($image);
249
+            // Optimize the image since some people may upload images that will be
250
+            // either to big or are not progressive rendering.
251
+            $tmpFile = $this->tempManager->getTemporaryFile();
252
+            if (function_exists('imagescale')) {
253
+                // FIXME: Once PHP 5.5.0 is a requirement the above check can be removed
254
+                // Workaround for https://bugs.php.net/bug.php?id=65171
255
+                $newHeight = imagesy($image) / (imagesx($image) / 1920);
256
+                $image = imagescale($image, 1920, $newHeight);
257
+            }
258
+            imageinterlace($image, 1);
259
+            imagejpeg($image, $tmpFile, 75);
260
+            imagedestroy($image);
261 261
 
262
-			$target->putContent(file_get_contents($tmpFile, 'r'));
263
-			$this->themingDefaults->set('backgroundMime', $newBackgroundLogo['type']);
264
-			$name = $newBackgroundLogo['name'];
265
-		}
262
+            $target->putContent(file_get_contents($tmpFile, 'r'));
263
+            $this->themingDefaults->set('backgroundMime', $newBackgroundLogo['type']);
264
+            $name = $newBackgroundLogo['name'];
265
+        }
266 266
 
267
-		return new DataResponse(
268
-			[
269
-				'data' =>
270
-					[
271
-						'name' => $name,
272
-						'message' => $this->l10n->t('Saved')
273
-					],
274
-				'status' => 'success'
275
-			]
276
-		);
277
-	}
267
+        return new DataResponse(
268
+            [
269
+                'data' =>
270
+                    [
271
+                        'name' => $name,
272
+                        'message' => $this->l10n->t('Saved')
273
+                    ],
274
+                'status' => 'success'
275
+            ]
276
+        );
277
+    }
278 278
 
279
-	/**
280
-	 * Revert setting to default value
281
-	 *
282
-	 * @param string $setting setting which should be reverted
283
-	 * @return DataResponse
284
-	 */
285
-	public function undo($setting) {
286
-		$value = $this->themingDefaults->undo($setting);
287
-		// reprocess server scss for preview
288
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/server.scss', 'core');
279
+    /**
280
+     * Revert setting to default value
281
+     *
282
+     * @param string $setting setting which should be reverted
283
+     * @return DataResponse
284
+     */
285
+    public function undo($setting) {
286
+        $value = $this->themingDefaults->undo($setting);
287
+        // reprocess server scss for preview
288
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/server.scss', 'core');
289 289
 
290
-		if($setting === 'logoMime') {
291
-			try {
292
-				$file = $this->appData->getFolder('images')->getFile('logo');
293
-				$file->delete();
294
-			} catch (NotFoundException $e) {
295
-			} catch (NotPermittedException $e) {
296
-			}
297
-		}
298
-		if($setting === 'backgroundMime') {
299
-			try {
300
-				$file = $this->appData->getFolder('images')->getFile('background');
301
-				$file->delete();
302
-			} catch (NotFoundException $e) {
303
-			} catch (NotPermittedException $e) {
304
-			}
305
-		}
290
+        if($setting === 'logoMime') {
291
+            try {
292
+                $file = $this->appData->getFolder('images')->getFile('logo');
293
+                $file->delete();
294
+            } catch (NotFoundException $e) {
295
+            } catch (NotPermittedException $e) {
296
+            }
297
+        }
298
+        if($setting === 'backgroundMime') {
299
+            try {
300
+                $file = $this->appData->getFolder('images')->getFile('background');
301
+                $file->delete();
302
+            } catch (NotFoundException $e) {
303
+            } catch (NotPermittedException $e) {
304
+            }
305
+        }
306 306
 
307
-		return new DataResponse(
308
-			[
309
-				'data' =>
310
-					[
311
-						'value' => $value,
312
-						'message' => $this->l10n->t('Saved'),
313
-						'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
314
-					],
315
-				'status' => 'success'
316
-			]
317
-		);
318
-	}
307
+        return new DataResponse(
308
+            [
309
+                'data' =>
310
+                    [
311
+                        'value' => $value,
312
+                        'message' => $this->l10n->t('Saved'),
313
+                        'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
314
+                    ],
315
+                'status' => 'success'
316
+            ]
317
+        );
318
+    }
319 319
 
320
-	/**
321
-	 * @PublicPage
322
-	 * @NoCSRFRequired
323
-	 *
324
-	 * @return FileDisplayResponse|NotFoundResponse
325
-	 */
326
-	public function getLogo() {
327
-		try {
328
-			/** @var File $file */
329
-			$file = $this->appData->getFolder('images')->getFile('logo');
330
-		} catch (NotFoundException $e) {
331
-			return new NotFoundResponse();
332
-		}
320
+    /**
321
+     * @PublicPage
322
+     * @NoCSRFRequired
323
+     *
324
+     * @return FileDisplayResponse|NotFoundResponse
325
+     */
326
+    public function getLogo() {
327
+        try {
328
+            /** @var File $file */
329
+            $file = $this->appData->getFolder('images')->getFile('logo');
330
+        } catch (NotFoundException $e) {
331
+            return new NotFoundResponse();
332
+        }
333 333
 
334
-		$response = new FileDisplayResponse($file);
335
-		$response->cacheFor(3600);
336
-		$expires = new \DateTime();
337
-		$expires->setTimestamp($this->timeFactory->getTime());
338
-		$expires->add(new \DateInterval('PT24H'));
339
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
340
-		$response->addHeader('Pragma', 'cache');
341
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', ''));
342
-		return $response;
343
-	}
334
+        $response = new FileDisplayResponse($file);
335
+        $response->cacheFor(3600);
336
+        $expires = new \DateTime();
337
+        $expires->setTimestamp($this->timeFactory->getTime());
338
+        $expires->add(new \DateInterval('PT24H'));
339
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
340
+        $response->addHeader('Pragma', 'cache');
341
+        $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', ''));
342
+        return $response;
343
+    }
344 344
 
345
-	/**
346
-	 * @PublicPage
347
-	 * @NoCSRFRequired
348
-	 *
349
-	 * @return FileDisplayResponse|NotFoundResponse
350
-	 */
351
-	public function getLoginBackground() {
352
-		try {
353
-			/** @var File $file */
354
-			$file = $this->appData->getFolder('images')->getFile('background');
355
-		} catch (NotFoundException $e) {
356
-			return new NotFoundResponse();
357
-		}
345
+    /**
346
+     * @PublicPage
347
+     * @NoCSRFRequired
348
+     *
349
+     * @return FileDisplayResponse|NotFoundResponse
350
+     */
351
+    public function getLoginBackground() {
352
+        try {
353
+            /** @var File $file */
354
+            $file = $this->appData->getFolder('images')->getFile('background');
355
+        } catch (NotFoundException $e) {
356
+            return new NotFoundResponse();
357
+        }
358 358
 
359
-		$response = new FileDisplayResponse($file);
360
-		$response->cacheFor(3600);
361
-		$expires = new \DateTime();
362
-		$expires->setTimestamp($this->timeFactory->getTime());
363
-		$expires->add(new \DateInterval('PT24H'));
364
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
365
-		$response->addHeader('Pragma', 'cache');
366
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', ''));
367
-		return $response;
368
-	}
359
+        $response = new FileDisplayResponse($file);
360
+        $response->cacheFor(3600);
361
+        $expires = new \DateTime();
362
+        $expires->setTimestamp($this->timeFactory->getTime());
363
+        $expires->add(new \DateInterval('PT24H'));
364
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
365
+        $response->addHeader('Pragma', 'cache');
366
+        $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', ''));
367
+        return $response;
368
+    }
369 369
 
370
-	/**
371
-	 * @NoCSRFRequired
372
-	 * @PublicPage
373
-	 *
374
-	 * @return FileDisplayResponse|NotFoundResponse
375
-	 */
376
-	public function getStylesheet() {
377
-		$appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1);
378
-		/* SCSSCacher is required here
370
+    /**
371
+     * @NoCSRFRequired
372
+     * @PublicPage
373
+     *
374
+     * @return FileDisplayResponse|NotFoundResponse
375
+     */
376
+    public function getStylesheet() {
377
+        $appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1);
378
+        /* SCSSCacher is required here
379 379
 		 * We cannot rely on automatic caching done by \OC_Util::addStyle,
380 380
 		 * since we need to add the cacheBuster value to the url
381 381
 		 */
382
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming');
383
-		if(!$cssCached) {
384
-			return new NotFoundResponse();
385
-		}
382
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming');
383
+        if(!$cssCached) {
384
+            return new NotFoundResponse();
385
+        }
386 386
 
387
-		try {
388
-			$cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css');
389
-			$response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
390
-			$response->cacheFor(86400);
391
-			$expires = new \DateTime();
392
-			$expires->setTimestamp($this->timeFactory->getTime());
393
-			$expires->add(new \DateInterval('PT24H'));
394
-			$response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
395
-			$response->addHeader('Pragma', 'cache');
396
-			return $response;
397
-		} catch (NotFoundException $e) {
398
-			return new NotFoundResponse();
399
-		}
400
-	}
387
+        try {
388
+            $cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css');
389
+            $response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
390
+            $response->cacheFor(86400);
391
+            $expires = new \DateTime();
392
+            $expires->setTimestamp($this->timeFactory->getTime());
393
+            $expires->add(new \DateInterval('PT24H'));
394
+            $response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
395
+            $response->addHeader('Pragma', 'cache');
396
+            return $response;
397
+        } catch (NotFoundException $e) {
398
+            return new NotFoundResponse();
399
+        }
400
+    }
401 401
 
402
-	/**
403
-	 * @NoCSRFRequired
404
-	 * @PublicPage
405
-	 *
406
-	 * @return DataDownloadResponse
407
-	 */
408
-	public function getJavascript() {
409
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
410
-		$responseJS = '(function() {
402
+    /**
403
+     * @NoCSRFRequired
404
+     * @PublicPage
405
+     *
406
+     * @return DataDownloadResponse
407
+     */
408
+    public function getJavascript() {
409
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
410
+        $responseJS = '(function() {
411 411
 	OCA.Theming = {
412 412
 		name: ' . json_encode($this->themingDefaults->getName()) . ',
413 413
 		url: ' . json_encode($this->themingDefaults->getBaseUrl()) . ',
@@ -417,45 +417,45 @@  discard block
 block discarded – undo
417 417
 		cacheBuster: ' . json_encode($cacheBusterValue) . '
418 418
 	};
419 419
 })();';
420
-		$response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
421
-		$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
422
-		$response->addHeader('Pragma', 'cache');
423
-		$response->cacheFor(3600);
424
-		return $response;
425
-	}
420
+        $response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
421
+        $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
422
+        $response->addHeader('Pragma', 'cache');
423
+        $response->cacheFor(3600);
424
+        return $response;
425
+    }
426 426
 
427
-	/**
428
-	 * @NoCSRFRequired
429
-	 * @PublicPage
430
-	 *
431
-	 * @return Http\JSONResponse
432
-	 */
433
-	public function getManifest($app) {
434
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
435
-		$responseJS = [
436
-			'name' => $this->themingDefaults->getName(),
437
-			'start_url' => $this->urlGenerator->getBaseUrl(),
438
-			'icons' =>
439
-				[
440
-					[
441
-						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
442
-								['app' => $app]) . '?v=' . $cacheBusterValue,
443
-						'type'=> 'image/png',
444
-						'sizes'=> '128x128'
445
-					],
446
-					[
447
-						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
448
-								['app' => $app]) . '?v=' . $cacheBusterValue,
449
-						'type' => 'image/svg+xml',
450
-						'sizes' => '16x16'
451
-					]
452
-				],
453
-			'display' => 'standalone'
454
-		];
455
-		$response = new Http\JSONResponse($responseJS);
456
-		$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
457
-		$response->addHeader('Pragma', 'cache');
458
-		$response->cacheFor(3600);
459
-		return $response;
460
-	}
427
+    /**
428
+     * @NoCSRFRequired
429
+     * @PublicPage
430
+     *
431
+     * @return Http\JSONResponse
432
+     */
433
+    public function getManifest($app) {
434
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
435
+        $responseJS = [
436
+            'name' => $this->themingDefaults->getName(),
437
+            'start_url' => $this->urlGenerator->getBaseUrl(),
438
+            'icons' =>
439
+                [
440
+                    [
441
+                        'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
442
+                                ['app' => $app]) . '?v=' . $cacheBusterValue,
443
+                        'type'=> 'image/png',
444
+                        'sizes'=> '128x128'
445
+                    ],
446
+                    [
447
+                        'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
448
+                                ['app' => $app]) . '?v=' . $cacheBusterValue,
449
+                        'type' => 'image/svg+xml',
450
+                        'sizes' => '16x16'
451
+                    ]
452
+                ],
453
+            'display' => 'standalone'
454
+        ];
455
+        $response = new Http\JSONResponse($responseJS);
456
+        $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
457
+        $response->addHeader('Pragma', 'cache');
458
+        $response->cacheFor(3600);
459
+        return $response;
460
+    }
461 461
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 */
193 193
 	public function updateLogo() {
194 194
 		$backgroundColor = $this->request->getParam('backgroundColor', false);
195
-		if($backgroundColor) {
195
+		if ($backgroundColor) {
196 196
 			$this->themingDefaults->set('backgroundMime', 'backgroundColor');
197 197
 			return new DataResponse(
198 198
 				[
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		// reprocess server scss for preview
288 288
 		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/server.scss', 'core');
289 289
 
290
-		if($setting === 'logoMime') {
290
+		if ($setting === 'logoMime') {
291 291
 			try {
292 292
 				$file = $this->appData->getFolder('images')->getFile('logo');
293 293
 				$file->delete();
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 			} catch (NotPermittedException $e) {
296 296
 			}
297 297
 		}
298
-		if($setting === 'backgroundMime') {
298
+		if ($setting === 'backgroundMime') {
299 299
 			try {
300 300
 				$file = $this->appData->getFolder('images')->getFile('background');
301 301
 				$file->delete();
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
 		 * We cannot rely on automatic caching done by \OC_Util::addStyle,
380 380
 		 * since we need to add the cacheBuster value to the url
381 381
 		 */
382
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming');
383
-		if(!$cssCached) {
382
+		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath.'/css/theming.scss', 'theming');
383
+		if (!$cssCached) {
384 384
 			return new NotFoundResponse();
385 385
 		}
386 386
 
@@ -409,12 +409,12 @@  discard block
 block discarded – undo
409 409
 		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
410 410
 		$responseJS = '(function() {
411 411
 	OCA.Theming = {
412
-		name: ' . json_encode($this->themingDefaults->getName()) . ',
413
-		url: ' . json_encode($this->themingDefaults->getBaseUrl()) . ',
414
-		slogan: ' . json_encode($this->themingDefaults->getSlogan()) . ',
415
-		color: ' . json_encode($this->themingDefaults->getColorPrimary()) . ',
416
-		inverted: ' . json_encode($this->util->invertTextColor($this->themingDefaults->getColorPrimary())) . ',
417
-		cacheBuster: ' . json_encode($cacheBusterValue) . '
412
+		name: ' . json_encode($this->themingDefaults->getName()).',
413
+		url: ' . json_encode($this->themingDefaults->getBaseUrl()).',
414
+		slogan: ' . json_encode($this->themingDefaults->getSlogan()).',
415
+		color: ' . json_encode($this->themingDefaults->getColorPrimary()).',
416
+		inverted: ' . json_encode($this->util->invertTextColor($this->themingDefaults->getColorPrimary())).',
417
+		cacheBuster: ' . json_encode($cacheBusterValue).'
418 418
 	};
419 419
 })();';
420 420
 		$response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
@@ -439,13 +439,13 @@  discard block
 block discarded – undo
439 439
 				[
440 440
 					[
441 441
 						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
442
-								['app' => $app]) . '?v=' . $cacheBusterValue,
442
+								['app' => $app]).'?v='.$cacheBusterValue,
443 443
 						'type'=> 'image/png',
444 444
 						'sizes'=> '128x128'
445 445
 					],
446 446
 					[
447 447
 						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
448
-								['app' => $app]) . '?v=' . $cacheBusterValue,
448
+								['app' => $app]).'?v='.$cacheBusterValue,
449 449
 						'type' => 'image/svg+xml',
450 450
 						'sizes' => '16x16'
451 451
 					]
Please login to merge, or discard this patch.
apps/theming/lib/ThemingDefaults.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,7 +64,6 @@  discard block
 block discarded – undo
64 64
 	 * @param IConfig $config
65 65
 	 * @param IL10N $l
66 66
 	 * @param IURLGenerator $urlGenerator
67
-	 * @param \OC_Defaults $defaults
68 67
 	 * @param IAppData $appData
69 68
 	 * @param ICacheFactory $cacheFactory
70 69
 	 * @param Util $util
@@ -254,7 +253,7 @@  discard block
 block discarded – undo
254 253
 	 *
255 254
 	 * @param string $app name of the app
256 255
 	 * @param string $image filename of the image
257
-	 * @return bool|string false if image should not replaced, otherwise the location of the image
256
+	 * @return string|false false if image should not replaced, otherwise the location of the image
258 257
 	 */
259 258
 	public function replaceImagePath($app, $image) {
260 259
 		if($app==='') {
Please login to merge, or discard this patch.
Indentation   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -31,324 +31,324 @@
 block discarded – undo
31 31
 
32 32
 class ThemingDefaults extends \OC_Defaults {
33 33
 
34
-	/** @var IConfig */
35
-	private $config;
36
-	/** @var IL10N */
37
-	private $l;
38
-	/** @var IURLGenerator */
39
-	private $urlGenerator;
40
-	/** @var IAppData */
41
-	private $appData;
42
-	/** @var ICacheFactory */
43
-	private $cacheFactory;
44
-	/** @var string */
45
-	private $name;
46
-	/** @var string */
47
-	private $url;
48
-	/** @var string */
49
-	private $slogan;
50
-	/** @var string */
51
-	private $color;
52
-	/** @var Util */
53
-	private $util;
54
-	/** @var string */
55
-	private $iTunesAppId;
56
-	/** @var string */
57
-	private $iOSClientUrl;
58
-	/** @var string */
59
-	private $AndroidClientUrl;
60
-
61
-	/**
62
-	 * ThemingDefaults constructor.
63
-	 *
64
-	 * @param IConfig $config
65
-	 * @param IL10N $l
66
-	 * @param IURLGenerator $urlGenerator
67
-	 * @param \OC_Defaults $defaults
68
-	 * @param IAppData $appData
69
-	 * @param ICacheFactory $cacheFactory
70
-	 * @param Util $util
71
-	 */
72
-	public function __construct(IConfig $config,
73
-								IL10N $l,
74
-								IURLGenerator $urlGenerator,
75
-								IAppData $appData,
76
-								ICacheFactory $cacheFactory,
77
-								Util $util
78
-	) {
79
-		parent::__construct();
80
-		$this->config = $config;
81
-		$this->l = $l;
82
-		$this->urlGenerator = $urlGenerator;
83
-		$this->appData = $appData;
84
-		$this->cacheFactory = $cacheFactory;
85
-		$this->util = $util;
86
-
87
-		$this->name = parent::getName();
88
-		$this->url = parent::getBaseUrl();
89
-		$this->slogan = parent::getSlogan();
90
-		$this->color = parent::getColorPrimary();
91
-		$this->iTunesAppId = parent::getiTunesAppId();
92
-		$this->iOSClientUrl = parent::getiOSClientUrl();
93
-		$this->AndroidClientUrl = parent::getAndroidClientUrl();
94
-	}
95
-
96
-	public function getName() {
97
-		return strip_tags($this->config->getAppValue('theming', 'name', $this->name));
98
-	}
99
-
100
-	public function getHTMLName() {
101
-		return $this->config->getAppValue('theming', 'name', $this->name);
102
-	}
103
-
104
-	public function getTitle() {
105
-		return $this->getName();
106
-	}
107
-
108
-	public function getEntity() {
109
-		return $this->getName();
110
-	}
111
-
112
-	public function getBaseUrl() {
113
-		return $this->config->getAppValue('theming', 'url', $this->url);
114
-	}
115
-
116
-	public function getSlogan() {
117
-		return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan));
118
-	}
119
-
120
-	public function getShortFooter() {
121
-		$slogan = $this->getSlogan();
122
-		$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
123
-			' rel="noreferrer">' .$this->getEntity() . '</a>'.
124
-			($slogan !== '' ? ' – ' . $slogan : '');
125
-
126
-		return $footer;
127
-	}
128
-
129
-	/**
130
-	 * Color that is used for the header as well as for mail headers
131
-	 *
132
-	 * @return string
133
-	 */
134
-	public function getColorPrimary() {
135
-		return $this->config->getAppValue('theming', 'color', $this->color);
136
-	}
137
-
138
-	/**
139
-	 * Themed logo url
140
-	 *
141
-	 * @param bool $useSvg Whether to point to the SVG image or a fallback
142
-	 * @return string
143
-	 */
144
-	public function getLogo($useSvg = true) {
145
-		$logo = $this->config->getAppValue('theming', 'logoMime', false);
146
-
147
-		$logoExists = true;
148
-		try {
149
-			$this->appData->getFolder('images')->getFile('logo');
150
-		} catch (\Exception $e) {
151
-			$logoExists = false;
152
-		}
153
-
154
-		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
155
-
156
-		if(!$logo || !$logoExists) {
157
-			if($useSvg) {
158
-				$logo = $this->urlGenerator->imagePath('core', 'logo.svg');
159
-			} else {
160
-				$logo = $this->urlGenerator->imagePath('core', 'logo.png');
161
-			}
162
-			return $logo . '?v=' . $cacheBusterCounter;
163
-		}
164
-
165
-		return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter;
166
-	}
167
-
168
-	/**
169
-	 * Themed background image url
170
-	 *
171
-	 * @return string
172
-	 */
173
-	public function getBackground() {
174
-		$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false);
175
-
176
-		$backgroundExists = true;
177
-		try {
178
-			$this->appData->getFolder('images')->getFile('background');
179
-		} catch (\Exception $e) {
180
-			$backgroundExists = false;
181
-		}
182
-
183
-		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
184
-
185
-		if(!$backgroundLogo || !$backgroundExists) {
186
-			return $this->urlGenerator->imagePath('core','background.png') . '?v=' . $cacheBusterCounter;
187
-		}
188
-
189
-		return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground') . '?v=' . $cacheBusterCounter;
190
-	}
191
-
192
-	/**
193
-	 * @return string
194
-	 */
195
-	public function getiTunesAppId() {
196
-		return $this->config->getAppValue('theming', 'iTunesAppId', $this->iTunesAppId);
197
-	}
198
-
199
-	/**
200
-	 * @return string
201
-	 */
202
-	public function getiOSClientUrl() {
203
-		return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl);
204
-	}
205
-
206
-	/**
207
-	 * @return string
208
-	 */
209
-	public function getAndroidClientUrl() {
210
-		return $this->config->getAppValue('theming', 'AndroidClientUrl', $this->AndroidClientUrl);
211
-	}
212
-
213
-
214
-	/**
215
-	 * @return array scss variables to overwrite
216
-	 */
217
-	public function getScssVariables() {
218
-		$cache = $this->cacheFactory->create('theming');
219
-		if ($value = $cache->get('getScssVariables')) {
220
-			return $value;
221
-		}
222
-
223
-		$variables = [
224
-			'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'",
225
-			'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime', '') . "'",
226
-			'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime', '') . "'"
227
-		];
228
-
229
-		$variables['image-logo'] = "'".$this->urlGenerator->getAbsoluteURL($this->getLogo())."'";
230
-		$variables['image-login-background'] = "'".$this->urlGenerator->getAbsoluteURL($this->getBackground())."'";
231
-		$variables['image-login-plain'] = 'false';
232
-
233
-		if ($this->config->getAppValue('theming', 'color', null) !== null) {
234
-			if ($this->util->invertTextColor($this->getColorPrimary())) {
235
-				$colorPrimaryText = '#000000';
236
-			} else {
237
-				$colorPrimaryText = '#ffffff';
238
-			}
239
-			$variables['color-primary'] = $this->getColorPrimary();
240
-			$variables['color-primary-text'] = $colorPrimaryText;
241
-			$variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary());
242
-		}
243
-
244
-		if ($this->config->getAppValue('theming', 'backgroundMime', null) === 'backgroundColor') {
245
-			$variables['image-login-plain'] = 'true';
246
-		}
247
-		$cache->set('getScssVariables', $variables);
248
-		return $variables;
249
-	}
250
-
251
-	/**
252
-	 * Check if the image should be replaced by the theming app
253
-	 * and return the new image location then
254
-	 *
255
-	 * @param string $app name of the app
256
-	 * @param string $image filename of the image
257
-	 * @return bool|string false if image should not replaced, otherwise the location of the image
258
-	 */
259
-	public function replaceImagePath($app, $image) {
260
-		if($app==='') {
261
-			$app = 'core';
262
-		}
263
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
264
-
265
-		if ($image === 'favicon.ico' && $this->shouldReplaceIcons()) {
266
-			return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue;
267
-		}
268
-		if ($image === 'favicon-touch.png' && $this->shouldReplaceIcons()) {
269
-			return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue;
270
-		}
271
-		if ($image === 'manifest.json') {
272
-			$appPath = \OC_App::getAppPath($app);
273
-			if ($appPath && file_exists($appPath . '/img/manifest.json')) {
274
-				return false;
275
-			}
276
-			return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue;
277
-		}
278
-		return false;
279
-	}
280
-
281
-	/**
282
-	 * Check if Imagemagick is enabled and if SVG is supported
283
-	 * otherwise we can't render custom icons
284
-	 *
285
-	 * @return bool
286
-	 */
287
-	public function shouldReplaceIcons() {
288
-		$cache = $this->cacheFactory->create('theming');
289
-		if($value = $cache->get('shouldReplaceIcons')) {
290
-			return (bool)$value;
291
-		}
292
-		$value = false;
293
-		if(extension_loaded('imagick')) {
294
-			$checkImagick = new \Imagick();
295
-			if (count($checkImagick->queryFormats('SVG')) >= 1) {
296
-				$value = true;
297
-			}
298
-			$checkImagick->clear();
299
-		}
300
-		$cache->set('shouldReplaceIcons', $value);
301
-		return $value;
302
-	}
303
-
304
-	/**
305
-	 * Increases the cache buster key
306
-	 */
307
-	private function increaseCacheBuster() {
308
-		$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
309
-		$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
310
-		$this->cacheFactory->create('theming')->clear('getScssVariables');
311
-	}
312
-
313
-	/**
314
-	 * Update setting in the database
315
-	 *
316
-	 * @param string $setting
317
-	 * @param string $value
318
-	 */
319
-	public function set($setting, $value) {
320
-		$this->config->setAppValue('theming', $setting, $value);
321
-		$this->increaseCacheBuster();
322
-	}
323
-
324
-	/**
325
-	 * Revert settings to the default value
326
-	 *
327
-	 * @param string $setting setting which should be reverted
328
-	 * @return string default value
329
-	 */
330
-	public function undo($setting) {
331
-		$this->config->deleteAppValue('theming', $setting);
332
-		$this->increaseCacheBuster();
333
-
334
-		switch ($setting) {
335
-			case 'name':
336
-				$returnValue = $this->getEntity();
337
-				break;
338
-			case 'url':
339
-				$returnValue = $this->getBaseUrl();
340
-				break;
341
-			case 'slogan':
342
-				$returnValue = $this->getSlogan();
343
-				break;
344
-			case 'color':
345
-				$returnValue = $this->getColorPrimary();
346
-				break;
347
-			default:
348
-				$returnValue = '';
349
-				break;
350
-		}
351
-
352
-		return $returnValue;
353
-	}
34
+    /** @var IConfig */
35
+    private $config;
36
+    /** @var IL10N */
37
+    private $l;
38
+    /** @var IURLGenerator */
39
+    private $urlGenerator;
40
+    /** @var IAppData */
41
+    private $appData;
42
+    /** @var ICacheFactory */
43
+    private $cacheFactory;
44
+    /** @var string */
45
+    private $name;
46
+    /** @var string */
47
+    private $url;
48
+    /** @var string */
49
+    private $slogan;
50
+    /** @var string */
51
+    private $color;
52
+    /** @var Util */
53
+    private $util;
54
+    /** @var string */
55
+    private $iTunesAppId;
56
+    /** @var string */
57
+    private $iOSClientUrl;
58
+    /** @var string */
59
+    private $AndroidClientUrl;
60
+
61
+    /**
62
+     * ThemingDefaults constructor.
63
+     *
64
+     * @param IConfig $config
65
+     * @param IL10N $l
66
+     * @param IURLGenerator $urlGenerator
67
+     * @param \OC_Defaults $defaults
68
+     * @param IAppData $appData
69
+     * @param ICacheFactory $cacheFactory
70
+     * @param Util $util
71
+     */
72
+    public function __construct(IConfig $config,
73
+                                IL10N $l,
74
+                                IURLGenerator $urlGenerator,
75
+                                IAppData $appData,
76
+                                ICacheFactory $cacheFactory,
77
+                                Util $util
78
+    ) {
79
+        parent::__construct();
80
+        $this->config = $config;
81
+        $this->l = $l;
82
+        $this->urlGenerator = $urlGenerator;
83
+        $this->appData = $appData;
84
+        $this->cacheFactory = $cacheFactory;
85
+        $this->util = $util;
86
+
87
+        $this->name = parent::getName();
88
+        $this->url = parent::getBaseUrl();
89
+        $this->slogan = parent::getSlogan();
90
+        $this->color = parent::getColorPrimary();
91
+        $this->iTunesAppId = parent::getiTunesAppId();
92
+        $this->iOSClientUrl = parent::getiOSClientUrl();
93
+        $this->AndroidClientUrl = parent::getAndroidClientUrl();
94
+    }
95
+
96
+    public function getName() {
97
+        return strip_tags($this->config->getAppValue('theming', 'name', $this->name));
98
+    }
99
+
100
+    public function getHTMLName() {
101
+        return $this->config->getAppValue('theming', 'name', $this->name);
102
+    }
103
+
104
+    public function getTitle() {
105
+        return $this->getName();
106
+    }
107
+
108
+    public function getEntity() {
109
+        return $this->getName();
110
+    }
111
+
112
+    public function getBaseUrl() {
113
+        return $this->config->getAppValue('theming', 'url', $this->url);
114
+    }
115
+
116
+    public function getSlogan() {
117
+        return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan));
118
+    }
119
+
120
+    public function getShortFooter() {
121
+        $slogan = $this->getSlogan();
122
+        $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
123
+            ' rel="noreferrer">' .$this->getEntity() . '</a>'.
124
+            ($slogan !== '' ? ' – ' . $slogan : '');
125
+
126
+        return $footer;
127
+    }
128
+
129
+    /**
130
+     * Color that is used for the header as well as for mail headers
131
+     *
132
+     * @return string
133
+     */
134
+    public function getColorPrimary() {
135
+        return $this->config->getAppValue('theming', 'color', $this->color);
136
+    }
137
+
138
+    /**
139
+     * Themed logo url
140
+     *
141
+     * @param bool $useSvg Whether to point to the SVG image or a fallback
142
+     * @return string
143
+     */
144
+    public function getLogo($useSvg = true) {
145
+        $logo = $this->config->getAppValue('theming', 'logoMime', false);
146
+
147
+        $logoExists = true;
148
+        try {
149
+            $this->appData->getFolder('images')->getFile('logo');
150
+        } catch (\Exception $e) {
151
+            $logoExists = false;
152
+        }
153
+
154
+        $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
155
+
156
+        if(!$logo || !$logoExists) {
157
+            if($useSvg) {
158
+                $logo = $this->urlGenerator->imagePath('core', 'logo.svg');
159
+            } else {
160
+                $logo = $this->urlGenerator->imagePath('core', 'logo.png');
161
+            }
162
+            return $logo . '?v=' . $cacheBusterCounter;
163
+        }
164
+
165
+        return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter;
166
+    }
167
+
168
+    /**
169
+     * Themed background image url
170
+     *
171
+     * @return string
172
+     */
173
+    public function getBackground() {
174
+        $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false);
175
+
176
+        $backgroundExists = true;
177
+        try {
178
+            $this->appData->getFolder('images')->getFile('background');
179
+        } catch (\Exception $e) {
180
+            $backgroundExists = false;
181
+        }
182
+
183
+        $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
184
+
185
+        if(!$backgroundLogo || !$backgroundExists) {
186
+            return $this->urlGenerator->imagePath('core','background.png') . '?v=' . $cacheBusterCounter;
187
+        }
188
+
189
+        return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground') . '?v=' . $cacheBusterCounter;
190
+    }
191
+
192
+    /**
193
+     * @return string
194
+     */
195
+    public function getiTunesAppId() {
196
+        return $this->config->getAppValue('theming', 'iTunesAppId', $this->iTunesAppId);
197
+    }
198
+
199
+    /**
200
+     * @return string
201
+     */
202
+    public function getiOSClientUrl() {
203
+        return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl);
204
+    }
205
+
206
+    /**
207
+     * @return string
208
+     */
209
+    public function getAndroidClientUrl() {
210
+        return $this->config->getAppValue('theming', 'AndroidClientUrl', $this->AndroidClientUrl);
211
+    }
212
+
213
+
214
+    /**
215
+     * @return array scss variables to overwrite
216
+     */
217
+    public function getScssVariables() {
218
+        $cache = $this->cacheFactory->create('theming');
219
+        if ($value = $cache->get('getScssVariables')) {
220
+            return $value;
221
+        }
222
+
223
+        $variables = [
224
+            'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'",
225
+            'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime', '') . "'",
226
+            'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime', '') . "'"
227
+        ];
228
+
229
+        $variables['image-logo'] = "'".$this->urlGenerator->getAbsoluteURL($this->getLogo())."'";
230
+        $variables['image-login-background'] = "'".$this->urlGenerator->getAbsoluteURL($this->getBackground())."'";
231
+        $variables['image-login-plain'] = 'false';
232
+
233
+        if ($this->config->getAppValue('theming', 'color', null) !== null) {
234
+            if ($this->util->invertTextColor($this->getColorPrimary())) {
235
+                $colorPrimaryText = '#000000';
236
+            } else {
237
+                $colorPrimaryText = '#ffffff';
238
+            }
239
+            $variables['color-primary'] = $this->getColorPrimary();
240
+            $variables['color-primary-text'] = $colorPrimaryText;
241
+            $variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary());
242
+        }
243
+
244
+        if ($this->config->getAppValue('theming', 'backgroundMime', null) === 'backgroundColor') {
245
+            $variables['image-login-plain'] = 'true';
246
+        }
247
+        $cache->set('getScssVariables', $variables);
248
+        return $variables;
249
+    }
250
+
251
+    /**
252
+     * Check if the image should be replaced by the theming app
253
+     * and return the new image location then
254
+     *
255
+     * @param string $app name of the app
256
+     * @param string $image filename of the image
257
+     * @return bool|string false if image should not replaced, otherwise the location of the image
258
+     */
259
+    public function replaceImagePath($app, $image) {
260
+        if($app==='') {
261
+            $app = 'core';
262
+        }
263
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
264
+
265
+        if ($image === 'favicon.ico' && $this->shouldReplaceIcons()) {
266
+            return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue;
267
+        }
268
+        if ($image === 'favicon-touch.png' && $this->shouldReplaceIcons()) {
269
+            return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue;
270
+        }
271
+        if ($image === 'manifest.json') {
272
+            $appPath = \OC_App::getAppPath($app);
273
+            if ($appPath && file_exists($appPath . '/img/manifest.json')) {
274
+                return false;
275
+            }
276
+            return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue;
277
+        }
278
+        return false;
279
+    }
280
+
281
+    /**
282
+     * Check if Imagemagick is enabled and if SVG is supported
283
+     * otherwise we can't render custom icons
284
+     *
285
+     * @return bool
286
+     */
287
+    public function shouldReplaceIcons() {
288
+        $cache = $this->cacheFactory->create('theming');
289
+        if($value = $cache->get('shouldReplaceIcons')) {
290
+            return (bool)$value;
291
+        }
292
+        $value = false;
293
+        if(extension_loaded('imagick')) {
294
+            $checkImagick = new \Imagick();
295
+            if (count($checkImagick->queryFormats('SVG')) >= 1) {
296
+                $value = true;
297
+            }
298
+            $checkImagick->clear();
299
+        }
300
+        $cache->set('shouldReplaceIcons', $value);
301
+        return $value;
302
+    }
303
+
304
+    /**
305
+     * Increases the cache buster key
306
+     */
307
+    private function increaseCacheBuster() {
308
+        $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
309
+        $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
310
+        $this->cacheFactory->create('theming')->clear('getScssVariables');
311
+    }
312
+
313
+    /**
314
+     * Update setting in the database
315
+     *
316
+     * @param string $setting
317
+     * @param string $value
318
+     */
319
+    public function set($setting, $value) {
320
+        $this->config->setAppValue('theming', $setting, $value);
321
+        $this->increaseCacheBuster();
322
+    }
323
+
324
+    /**
325
+     * Revert settings to the default value
326
+     *
327
+     * @param string $setting setting which should be reverted
328
+     * @return string default value
329
+     */
330
+    public function undo($setting) {
331
+        $this->config->deleteAppValue('theming', $setting);
332
+        $this->increaseCacheBuster();
333
+
334
+        switch ($setting) {
335
+            case 'name':
336
+                $returnValue = $this->getEntity();
337
+                break;
338
+            case 'url':
339
+                $returnValue = $this->getBaseUrl();
340
+                break;
341
+            case 'slogan':
342
+                $returnValue = $this->getSlogan();
343
+                break;
344
+            case 'color':
345
+                $returnValue = $this->getColorPrimary();
346
+                break;
347
+            default:
348
+                $returnValue = '';
349
+                break;
350
+        }
351
+
352
+        return $returnValue;
353
+    }
354 354
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 
120 120
 	public function getShortFooter() {
121 121
 		$slogan = $this->getSlogan();
122
-		$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
123
-			' rel="noreferrer">' .$this->getEntity() . '</a>'.
124
-			($slogan !== '' ? ' – ' . $slogan : '');
122
+		$footer = '<a href="'.$this->getBaseUrl().'" target="_blank"'.
123
+			' rel="noreferrer">'.$this->getEntity().'</a>'.
124
+			($slogan !== '' ? ' – '.$slogan : '');
125 125
 
126 126
 		return $footer;
127 127
 	}
@@ -153,16 +153,16 @@  discard block
 block discarded – undo
153 153
 
154 154
 		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
155 155
 
156
-		if(!$logo || !$logoExists) {
157
-			if($useSvg) {
156
+		if (!$logo || !$logoExists) {
157
+			if ($useSvg) {
158 158
 				$logo = $this->urlGenerator->imagePath('core', 'logo.svg');
159 159
 			} else {
160 160
 				$logo = $this->urlGenerator->imagePath('core', 'logo.png');
161 161
 			}
162
-			return $logo . '?v=' . $cacheBusterCounter;
162
+			return $logo.'?v='.$cacheBusterCounter;
163 163
 		}
164 164
 
165
-		return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter;
165
+		return $this->urlGenerator->linkToRoute('theming.Theming.getLogo').'?v='.$cacheBusterCounter;
166 166
 	}
167 167
 
168 168
 	/**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 * @return string
172 172
 	 */
173 173
 	public function getBackground() {
174
-		$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false);
174
+		$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false);
175 175
 
176 176
 		$backgroundExists = true;
177 177
 		try {
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 
183 183
 		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
184 184
 
185
-		if(!$backgroundLogo || !$backgroundExists) {
186
-			return $this->urlGenerator->imagePath('core','background.png') . '?v=' . $cacheBusterCounter;
185
+		if (!$backgroundLogo || !$backgroundExists) {
186
+			return $this->urlGenerator->imagePath('core', 'background.png').'?v='.$cacheBusterCounter;
187 187
 		}
188 188
 
189
-		return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground') . '?v=' . $cacheBusterCounter;
189
+		return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground').'?v='.$cacheBusterCounter;
190 190
 	}
191 191
 
192 192
 	/**
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 		}
222 222
 
223 223
 		$variables = [
224
-			'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'",
225
-			'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime', '') . "'",
226
-			'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime', '') . "'"
224
+			'theming-cachebuster' => "'".$this->config->getAppValue('theming', 'cachebuster', '0')."'",
225
+			'theming-logo-mime' => "'".$this->config->getAppValue('theming', 'logoMime', '')."'",
226
+			'theming-background-mime' => "'".$this->config->getAppValue('theming', 'backgroundMime', '')."'"
227 227
 		];
228 228
 
229 229
 		$variables['image-logo'] = "'".$this->urlGenerator->getAbsoluteURL($this->getLogo())."'";
@@ -257,23 +257,23 @@  discard block
 block discarded – undo
257 257
 	 * @return bool|string false if image should not replaced, otherwise the location of the image
258 258
 	 */
259 259
 	public function replaceImagePath($app, $image) {
260
-		if($app==='') {
260
+		if ($app === '') {
261 261
 			$app = 'core';
262 262
 		}
263 263
 		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
264 264
 
265 265
 		if ($image === 'favicon.ico' && $this->shouldReplaceIcons()) {
266
-			return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue;
266
+			return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]).'?v='.$cacheBusterValue;
267 267
 		}
268 268
 		if ($image === 'favicon-touch.png' && $this->shouldReplaceIcons()) {
269
-			return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue;
269
+			return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]).'?v='.$cacheBusterValue;
270 270
 		}
271 271
 		if ($image === 'manifest.json') {
272 272
 			$appPath = \OC_App::getAppPath($app);
273
-			if ($appPath && file_exists($appPath . '/img/manifest.json')) {
273
+			if ($appPath && file_exists($appPath.'/img/manifest.json')) {
274 274
 				return false;
275 275
 			}
276
-			return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue;
276
+			return $this->urlGenerator->linkToRoute('theming.Theming.getManifest').'?v='.$cacheBusterValue;
277 277
 		}
278 278
 		return false;
279 279
 	}
@@ -286,11 +286,11 @@  discard block
 block discarded – undo
286 286
 	 */
287 287
 	public function shouldReplaceIcons() {
288 288
 		$cache = $this->cacheFactory->create('theming');
289
-		if($value = $cache->get('shouldReplaceIcons')) {
290
-			return (bool)$value;
289
+		if ($value = $cache->get('shouldReplaceIcons')) {
290
+			return (bool) $value;
291 291
 		}
292 292
 		$value = false;
293
-		if(extension_loaded('imagick')) {
293
+		if (extension_loaded('imagick')) {
294 294
 			$checkImagick = new \Imagick();
295 295
 			if (count($checkImagick->queryFormats('SVG')) >= 1) {
296 296
 				$value = true;
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 */
307 307
 	private function increaseCacheBuster() {
308 308
 		$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
309
-		$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
309
+		$this->config->setAppValue('theming', 'cachebuster', (int) $cacheBusterKey + 1);
310 310
 		$this->cacheFactory->create('theming')->clear('getScssVariables');
311 311
 	}
312 312
 
Please login to merge, or discard this patch.