Completed
Pull Request — master (#5070)
by Julius
18:15
created
apps/theming/lib/Util.php 1 patch
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -33,183 +33,183 @@
 block discarded – undo
33 33
 
34 34
 class Util {
35 35
 
36
-	/** @var IConfig */
37
-	private $config;
38
-
39
-	/** @var IAppManager */
40
-	private $appManager;
41
-
42
-	/** @var IAppData */
43
-	private $appData;
44
-
45
-	/**
46
-	 * Util constructor.
47
-	 *
48
-	 * @param IConfig $config
49
-	 * @param IAppManager $appManager
50
-	 * @param IAppData $appData
51
-	 */
52
-	public function __construct(IConfig $config, IAppManager $appManager, IAppData $appData) {
53
-		$this->config = $config;
54
-		$this->appManager = $appManager;
55
-		$this->appData = $appData;
56
-	}
57
-
58
-	/**
59
-	 * @param string $color rgb color value
60
-	 * @return bool
61
-	 */
62
-	public function invertTextColor($color) {
63
-		$l = $this->calculateLuminance($color);
64
-		if($l>0.5) {
65
-			return true;
66
-		} else {
67
-			return false;
68
-		}
69
-	}
70
-
71
-	/**
72
-	 * get color for on-page elements:
73
-	 * theme color by default, grey if theme color is to bright
74
-	 * @param $color
75
-	 * @return string
76
-	 */
77
-	public function elementColor($color) {
78
-		$l = $this->calculateLuminance($color);
79
-		if($l>0.8) {
80
-			return '#555555';
81
-		} else {
82
-			return $color;
83
-		}
84
-	}
85
-
86
-	/**
87
-	 * @param string $color rgb color value
88
-	 * @return float
89
-	 */
90
-	public function calculateLuminance($color) {
91
-		$hex = preg_replace("/[^0-9A-Fa-f]/", '', $color);
92
-		if (strlen($hex) === 3) {
93
-			$hex = $hex{0} . $hex{0} . $hex{1} . $hex{1} . $hex{2} . $hex{2};
94
-		}
95
-		if (strlen($hex) !== 6) {
96
-			return 0;
97
-		}
98
-		$r = hexdec(substr($hex, 0, 2));
99
-		$g = hexdec(substr($hex, 2, 2));
100
-		$b = hexdec(substr($hex, 4, 2));
101
-		return (0.299 * $r + 0.587 * $g + 0.114 * $b)/255;
102
-	}
103
-
104
-	/**
105
-	 * @param $color
106
-	 * @return string base64 encoded radio button svg
107
-	 */
108
-	public function generateRadioButton($color) {
109
-		$radioButtonIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">' .
110
-			'<path d="M8 1a7 7 0 0 0-7 7 7 7 0 0 0 7 7 7 7 0 0 0 7-7 7 7 0 0 0-7-7zm0 1a6 6 0 0 1 6 6 6 6 0 0 1-6 6 6 6 0 0 1-6-6 6 6 0 0 1 6-6zm0 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" fill="'.$color.'"/></svg>';
111
-		return base64_encode($radioButtonIcon);
112
-	}
113
-
114
-
115
-	/**
116
-	 * @param $app string app name
117
-	 * @return string|ISimpleFile path to app icon / file of logo
118
-	 */
119
-	public function getAppIcon($app) {
120
-		$app = str_replace(array('\0', '/', '\\', '..'), '', $app);
121
-		try {
122
-			$appPath = $this->appManager->getAppPath($app);
123
-			$icon = $appPath . '/img/' . $app . '.svg';
124
-			if (file_exists($icon)) {
125
-				return $icon;
126
-			}
127
-			$icon = $appPath . '/img/app.svg';
128
-			if (file_exists($icon)) {
129
-				return $icon;
130
-			}
131
-		} catch (AppPathNotFoundException $e) {}
132
-
133
-		if ($this->config->getAppValue('theming', 'logoMime', '') !== '') {
134
-			$logoFile = null;
135
-			try {
136
-				$folder = $this->appData->getFolder('images');
137
-				if ($folder !== null) {
138
-					return $folder->getFile('logo');
139
-				}
140
-			} catch (NotFoundException $e) {}
141
-		}
142
-		return \OC::$SERVERROOT . '/core/img/logo.svg';
143
-	}
144
-
145
-	/**
146
-	 * @param $app string app name
147
-	 * @param $image string relative path to image in app folder
148
-	 * @return string|false absolute path to image
149
-	 */
150
-	public function getAppImage($app, $image) {
151
-		$app = str_replace(array('\0', '/', '\\', '..'), '', $app);
152
-		$image = str_replace(array('\0', '\\', '..'), '', $image);
153
-		if ($app === "core") {
154
-			$icon = \OC::$SERVERROOT . '/core/img/' . $image;
155
-			if (file_exists($icon)) {
156
-				return $icon;
157
-			}
158
-		}
159
-
160
-		try {
161
-			$appPath = $this->appManager->getAppPath($app);
162
-		} catch (AppPathNotFoundException $e) {
163
-			return false;
164
-		}
165
-
166
-		$icon = $appPath . '/img/' . $image;
167
-		if (file_exists($icon)) {
168
-			return $icon;
169
-		}
170
-		$icon = $appPath . '/img/' . $image . '.svg';
171
-		if (file_exists($icon)) {
172
-			return $icon;
173
-		}
174
-		$icon = $appPath . '/img/' . $image . '.png';
175
-		if (file_exists($icon)) {
176
-			return $icon;
177
-		}
178
-		$icon = $appPath . '/img/' . $image . '.gif';
179
-		if (file_exists($icon)) {
180
-			return $icon;
181
-		}
182
-		$icon = $appPath . '/img/' . $image . '.jpg';
183
-		if (file_exists($icon)) {
184
-			return $icon;
185
-		}
186
-
187
-		return false;
188
-	}
189
-
190
-	/**
191
-	 * replace default color with a custom one
192
-	 *
193
-	 * @param $svg string content of a svg file
194
-	 * @param $color string color to match
195
-	 * @return string
196
-	 */
197
-	public function colorizeSvg($svg, $color) {
198
-		$svg = preg_replace('/#0082c9/i', $color, $svg);
199
-		return $svg;
200
-	}
201
-
202
-	/**
203
-	 * Check if a custom theme is set in the server configuration
204
-	 * 
205
-	 * @return bool
206
-	 */
207
-	public function isAlreadyThemed() {
208
-		$theme = $this->config->getSystemValue('theme', '');
209
-		if ($theme !== '') {
210
-			return true;
211
-		}
212
-		return false;
213
-	}
36
+    /** @var IConfig */
37
+    private $config;
38
+
39
+    /** @var IAppManager */
40
+    private $appManager;
41
+
42
+    /** @var IAppData */
43
+    private $appData;
44
+
45
+    /**
46
+     * Util constructor.
47
+     *
48
+     * @param IConfig $config
49
+     * @param IAppManager $appManager
50
+     * @param IAppData $appData
51
+     */
52
+    public function __construct(IConfig $config, IAppManager $appManager, IAppData $appData) {
53
+        $this->config = $config;
54
+        $this->appManager = $appManager;
55
+        $this->appData = $appData;
56
+    }
57
+
58
+    /**
59
+     * @param string $color rgb color value
60
+     * @return bool
61
+     */
62
+    public function invertTextColor($color) {
63
+        $l = $this->calculateLuminance($color);
64
+        if($l>0.5) {
65
+            return true;
66
+        } else {
67
+            return false;
68
+        }
69
+    }
70
+
71
+    /**
72
+     * get color for on-page elements:
73
+     * theme color by default, grey if theme color is to bright
74
+     * @param $color
75
+     * @return string
76
+     */
77
+    public function elementColor($color) {
78
+        $l = $this->calculateLuminance($color);
79
+        if($l>0.8) {
80
+            return '#555555';
81
+        } else {
82
+            return $color;
83
+        }
84
+    }
85
+
86
+    /**
87
+     * @param string $color rgb color value
88
+     * @return float
89
+     */
90
+    public function calculateLuminance($color) {
91
+        $hex = preg_replace("/[^0-9A-Fa-f]/", '', $color);
92
+        if (strlen($hex) === 3) {
93
+            $hex = $hex{0} . $hex{0} . $hex{1} . $hex{1} . $hex{2} . $hex{2};
94
+        }
95
+        if (strlen($hex) !== 6) {
96
+            return 0;
97
+        }
98
+        $r = hexdec(substr($hex, 0, 2));
99
+        $g = hexdec(substr($hex, 2, 2));
100
+        $b = hexdec(substr($hex, 4, 2));
101
+        return (0.299 * $r + 0.587 * $g + 0.114 * $b)/255;
102
+    }
103
+
104
+    /**
105
+     * @param $color
106
+     * @return string base64 encoded radio button svg
107
+     */
108
+    public function generateRadioButton($color) {
109
+        $radioButtonIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">' .
110
+            '<path d="M8 1a7 7 0 0 0-7 7 7 7 0 0 0 7 7 7 7 0 0 0 7-7 7 7 0 0 0-7-7zm0 1a6 6 0 0 1 6 6 6 6 0 0 1-6 6 6 6 0 0 1-6-6 6 6 0 0 1 6-6zm0 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" fill="'.$color.'"/></svg>';
111
+        return base64_encode($radioButtonIcon);
112
+    }
113
+
114
+
115
+    /**
116
+     * @param $app string app name
117
+     * @return string|ISimpleFile path to app icon / file of logo
118
+     */
119
+    public function getAppIcon($app) {
120
+        $app = str_replace(array('\0', '/', '\\', '..'), '', $app);
121
+        try {
122
+            $appPath = $this->appManager->getAppPath($app);
123
+            $icon = $appPath . '/img/' . $app . '.svg';
124
+            if (file_exists($icon)) {
125
+                return $icon;
126
+            }
127
+            $icon = $appPath . '/img/app.svg';
128
+            if (file_exists($icon)) {
129
+                return $icon;
130
+            }
131
+        } catch (AppPathNotFoundException $e) {}
132
+
133
+        if ($this->config->getAppValue('theming', 'logoMime', '') !== '') {
134
+            $logoFile = null;
135
+            try {
136
+                $folder = $this->appData->getFolder('images');
137
+                if ($folder !== null) {
138
+                    return $folder->getFile('logo');
139
+                }
140
+            } catch (NotFoundException $e) {}
141
+        }
142
+        return \OC::$SERVERROOT . '/core/img/logo.svg';
143
+    }
144
+
145
+    /**
146
+     * @param $app string app name
147
+     * @param $image string relative path to image in app folder
148
+     * @return string|false absolute path to image
149
+     */
150
+    public function getAppImage($app, $image) {
151
+        $app = str_replace(array('\0', '/', '\\', '..'), '', $app);
152
+        $image = str_replace(array('\0', '\\', '..'), '', $image);
153
+        if ($app === "core") {
154
+            $icon = \OC::$SERVERROOT . '/core/img/' . $image;
155
+            if (file_exists($icon)) {
156
+                return $icon;
157
+            }
158
+        }
159
+
160
+        try {
161
+            $appPath = $this->appManager->getAppPath($app);
162
+        } catch (AppPathNotFoundException $e) {
163
+            return false;
164
+        }
165
+
166
+        $icon = $appPath . '/img/' . $image;
167
+        if (file_exists($icon)) {
168
+            return $icon;
169
+        }
170
+        $icon = $appPath . '/img/' . $image . '.svg';
171
+        if (file_exists($icon)) {
172
+            return $icon;
173
+        }
174
+        $icon = $appPath . '/img/' . $image . '.png';
175
+        if (file_exists($icon)) {
176
+            return $icon;
177
+        }
178
+        $icon = $appPath . '/img/' . $image . '.gif';
179
+        if (file_exists($icon)) {
180
+            return $icon;
181
+        }
182
+        $icon = $appPath . '/img/' . $image . '.jpg';
183
+        if (file_exists($icon)) {
184
+            return $icon;
185
+        }
186
+
187
+        return false;
188
+    }
189
+
190
+    /**
191
+     * replace default color with a custom one
192
+     *
193
+     * @param $svg string content of a svg file
194
+     * @param $color string color to match
195
+     * @return string
196
+     */
197
+    public function colorizeSvg($svg, $color) {
198
+        $svg = preg_replace('/#0082c9/i', $color, $svg);
199
+        return $svg;
200
+    }
201
+
202
+    /**
203
+     * Check if a custom theme is set in the server configuration
204
+     * 
205
+     * @return bool
206
+     */
207
+    public function isAlreadyThemed() {
208
+        $theme = $this->config->getSystemValue('theme', '');
209
+        if ($theme !== '') {
210
+            return true;
211
+        }
212
+        return false;
213
+    }
214 214
 
215 215
 }
Please login to merge, or discard this patch.
apps/theming/appinfo/app.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -28,34 +28,34 @@
 block discarded – undo
28 28
 $util = $app->getContainer()->query(\OCA\Theming\Util::class);
29 29
 if(!$util->isAlreadyThemed()) {
30 30
 
31
-	$app->getContainer()->registerCapability(\OCA\Theming\Capabilities::class);
31
+    $app->getContainer()->registerCapability(\OCA\Theming\Capabilities::class);
32 32
 
33
-	$linkToCSS = \OC::$server->getURLGenerator()->linkToRoute(
34
-		'theming.Theming.getStylesheet',
35
-		[
36
-			'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'),
37
-		]
38
-	);
39
-	\OCP\Util::addHeader(
40
-		'link',
41
-		[
42
-			'rel' => 'stylesheet',
43
-			'href' => $linkToCSS,
44
-		]
45
-	);
33
+    $linkToCSS = \OC::$server->getURLGenerator()->linkToRoute(
34
+        'theming.Theming.getStylesheet',
35
+        [
36
+            'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'),
37
+        ]
38
+    );
39
+    \OCP\Util::addHeader(
40
+        'link',
41
+        [
42
+            'rel' => 'stylesheet',
43
+            'href' => $linkToCSS,
44
+        ]
45
+    );
46 46
 
47
-	$linkToJs = \OC::$server->getURLGenerator()->linkToRoute(
48
-		'theming.Theming.getJavascript',
49
-		[
50
-			'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'),
51
-		]
52
-	);
53
-	\OCP\Util::addHeader(
54
-		'script',
55
-		[
56
-			'src' => $linkToJs,
57
-			'nonce' => \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
58
-		], ''
59
-	);
47
+    $linkToJs = \OC::$server->getURLGenerator()->linkToRoute(
48
+        'theming.Theming.getJavascript',
49
+        [
50
+            'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'),
51
+        ]
52
+    );
53
+    \OCP\Util::addHeader(
54
+        'script',
55
+        [
56
+            'src' => $linkToJs,
57
+            'nonce' => \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
58
+        ], ''
59
+    );
60 60
 
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 $app = new \OCP\AppFramework\App('theming');
27 27
 /** @var \OCA\Theming\Util $util */
28 28
 $util = $app->getContainer()->query(\OCA\Theming\Util::class);
29
-if(!$util->isAlreadyThemed()) {
29
+if (!$util->isAlreadyThemed()) {
30 30
 
31 31
 	$app->getContainer()->registerCapability(\OCA\Theming\Capabilities::class);
32 32
 
Please login to merge, or discard this patch.
lib/private/URLGenerator.php 2 patches
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -44,209 +44,209 @@
 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
-		if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) {
170
-			$path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image";
171
-		} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg")
172
-			&& file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) {
173
-			$path =  \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png";
174
-		} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) {
175
-			$path =  \OC::$WEBROOT . "/themes/$theme/$app/img/$image";
176
-		} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg")
177
-			&& file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) {
178
-			$path =  \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png";
179
-		} elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) {
180
-			$path =  \OC::$WEBROOT . "/themes/$theme/core/img/$image";
181
-		} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg")
182
-			&& file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) {
183
-			$path =  \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
184
-		} elseif($themingEnabled && $image === "favicon.ico" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) {
185
-			$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
186
-			if($app==="") { $app = "core"; }
187
-			$path = $this->linkToRoute('theming.Icon.getFavicon', [ 'app' => $app ]) . '?v='. $cacheBusterValue;
188
-		} elseif($themingEnabled && $image === "favicon-touch.png" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) {
189
-			$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
190
-			if($app==="") { $app = "core"; }
191
-			$path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue;
192
-		} elseif ($appPath && file_exists($appPath . "/img/$image")) {
193
-			$path =  \OC_App::getAppWebPath($app) . "/img/$image";
194
-		} elseif ($appPath && !file_exists($appPath . "/img/$basename.svg")
195
-			&& file_exists($appPath . "/img/$basename.png")) {
196
-			$path =  \OC_App::getAppWebPath($app) . "/img/$basename.png";
197
-		} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) {
198
-			$path =  \OC::$WEBROOT . "/$app/img/$image";
199
-		} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg")
200
-				&& file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) {
201
-			$path =  \OC::$WEBROOT . "/$app/img/$basename.png";
202
-		} elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) {
203
-			$path =  \OC::$WEBROOT . "/core/img/$image";
204
-		} elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg")
205
-			&& file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) {
206
-			$path =  \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
207
-		}
208
-
209
-		if($path !== '') {
210
-			$cache->set($cacheKey, $path);
211
-			return $path;
212
-		} else {
213
-			throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT);
214
-		}
215
-	}
216
-
217
-
218
-	/**
219
-	 * Makes an URL absolute
220
-	 * @param string $url the url in the ownCloud host
221
-	 * @return string the absolute version of the url
222
-	 */
223
-	public function getAbsoluteURL($url) {
224
-		$separator = $url[0] === '/' ? '' : '/';
225
-
226
-		if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
227
-			return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/');
228
-		}
229
-		// The ownCloud web root can already be prepended.
230
-		if(substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT) {
231
-			$url = substr($url, strlen(\OC::$WEBROOT));
232
-		}
233
-
234
-		return $this->getBaseUrl() . $separator . $url;
235
-	}
236
-
237
-	/**
238
-	 * @param string $key
239
-	 * @return string url to the online documentation
240
-	 */
241
-	public function linkToDocs($key) {
242
-		$theme = \OC::$server->getThemingDefaults();
243
-		return $theme->buildDocLinkToKey($key);
244
-	}
245
-
246
-	/**
247
-	 * @return string base url of the current request
248
-	 */
249
-	public function getBaseUrl() {
250
-		return $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT;
251
-	}
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
+        if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) {
170
+            $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image";
171
+        } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg")
172
+            && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) {
173
+            $path =  \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png";
174
+        } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) {
175
+            $path =  \OC::$WEBROOT . "/themes/$theme/$app/img/$image";
176
+        } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg")
177
+            && file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) {
178
+            $path =  \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png";
179
+        } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) {
180
+            $path =  \OC::$WEBROOT . "/themes/$theme/core/img/$image";
181
+        } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg")
182
+            && file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) {
183
+            $path =  \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
184
+        } elseif($themingEnabled && $image === "favicon.ico" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) {
185
+            $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
186
+            if($app==="") { $app = "core"; }
187
+            $path = $this->linkToRoute('theming.Icon.getFavicon', [ 'app' => $app ]) . '?v='. $cacheBusterValue;
188
+        } elseif($themingEnabled && $image === "favicon-touch.png" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) {
189
+            $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
190
+            if($app==="") { $app = "core"; }
191
+            $path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue;
192
+        } elseif ($appPath && file_exists($appPath . "/img/$image")) {
193
+            $path =  \OC_App::getAppWebPath($app) . "/img/$image";
194
+        } elseif ($appPath && !file_exists($appPath . "/img/$basename.svg")
195
+            && file_exists($appPath . "/img/$basename.png")) {
196
+            $path =  \OC_App::getAppWebPath($app) . "/img/$basename.png";
197
+        } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) {
198
+            $path =  \OC::$WEBROOT . "/$app/img/$image";
199
+        } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg")
200
+                && file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) {
201
+            $path =  \OC::$WEBROOT . "/$app/img/$basename.png";
202
+        } elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) {
203
+            $path =  \OC::$WEBROOT . "/core/img/$image";
204
+        } elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg")
205
+            && file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) {
206
+            $path =  \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
207
+        }
208
+
209
+        if($path !== '') {
210
+            $cache->set($cacheKey, $path);
211
+            return $path;
212
+        } else {
213
+            throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT);
214
+        }
215
+    }
216
+
217
+
218
+    /**
219
+     * Makes an URL absolute
220
+     * @param string $url the url in the ownCloud host
221
+     * @return string the absolute version of the url
222
+     */
223
+    public function getAbsoluteURL($url) {
224
+        $separator = $url[0] === '/' ? '' : '/';
225
+
226
+        if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
227
+            return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/');
228
+        }
229
+        // The ownCloud web root can already be prepended.
230
+        if(substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT) {
231
+            $url = substr($url, strlen(\OC::$WEBROOT));
232
+        }
233
+
234
+        return $this->getBaseUrl() . $separator . $url;
235
+    }
236
+
237
+    /**
238
+     * @param string $key
239
+     * @return string url to the online documentation
240
+     */
241
+    public function linkToDocs($key) {
242
+        $theme = \OC::$server->getThemingDefaults();
243
+        return $theme->buildDocLinkToKey($key);
244
+    }
245
+
246
+    /**
247
+     * @return string base url of the current request
248
+     */
249
+    public function getBaseUrl() {
250
+        return $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT;
251
+    }
252 252
 }
Please login to merge, or discard this patch.
Spacing   +57 added lines, -57 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,58 +159,58 @@  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
 
166 166
 		// Check if the app is in the app folder
167 167
 		$path = '';
168 168
 		$themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming');
169
-		if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) {
170
-			$path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image";
171
-		} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg")
172
-			&& file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) {
173
-			$path =  \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png";
174
-		} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) {
175
-			$path =  \OC::$WEBROOT . "/themes/$theme/$app/img/$image";
176
-		} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg")
177
-			&& file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) {
178
-			$path =  \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png";
179
-		} elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) {
180
-			$path =  \OC::$WEBROOT . "/themes/$theme/core/img/$image";
181
-		} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg")
182
-			&& file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) {
183
-			$path =  \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
184
-		} elseif($themingEnabled && $image === "favicon.ico" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) {
169
+		if (file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$image")) {
170
+			$path = \OC::$WEBROOT."/themes/$theme/apps/$app/img/$image";
171
+		} elseif (!file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$basename.svg")
172
+			&& file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$basename.png")) {
173
+			$path = \OC::$WEBROOT."/themes/$theme/apps/$app/img/$basename.png";
174
+		} elseif (!empty($app) and file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$image")) {
175
+			$path = \OC::$WEBROOT."/themes/$theme/$app/img/$image";
176
+		} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$basename.svg")
177
+			&& file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$basename.png"))) {
178
+			$path = \OC::$WEBROOT."/themes/$theme/$app/img/$basename.png";
179
+		} elseif (file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$image")) {
180
+			$path = \OC::$WEBROOT."/themes/$theme/core/img/$image";
181
+		} elseif (!file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$basename.svg")
182
+			&& file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$basename.png")) {
183
+			$path = \OC::$WEBROOT."/themes/$theme/core/img/$basename.png";
184
+		} elseif ($themingEnabled && $image === "favicon.ico" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) {
185 185
 			$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
186
-			if($app==="") { $app = "core"; }
187
-			$path = $this->linkToRoute('theming.Icon.getFavicon', [ 'app' => $app ]) . '?v='. $cacheBusterValue;
188
-		} elseif($themingEnabled && $image === "favicon-touch.png" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) {
186
+			if ($app === "") { $app = "core"; }
187
+			$path = $this->linkToRoute('theming.Icon.getFavicon', ['app' => $app]).'?v='.$cacheBusterValue;
188
+		} elseif ($themingEnabled && $image === "favicon-touch.png" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) {
189 189
 			$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
190
-			if($app==="") { $app = "core"; }
191
-			$path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue;
192
-		} elseif ($appPath && file_exists($appPath . "/img/$image")) {
193
-			$path =  \OC_App::getAppWebPath($app) . "/img/$image";
194
-		} elseif ($appPath && !file_exists($appPath . "/img/$basename.svg")
195
-			&& file_exists($appPath . "/img/$basename.png")) {
196
-			$path =  \OC_App::getAppWebPath($app) . "/img/$basename.png";
197
-		} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) {
198
-			$path =  \OC::$WEBROOT . "/$app/img/$image";
199
-		} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg")
200
-				&& file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) {
201
-			$path =  \OC::$WEBROOT . "/$app/img/$basename.png";
202
-		} elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) {
203
-			$path =  \OC::$WEBROOT . "/core/img/$image";
204
-		} elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg")
205
-			&& file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) {
206
-			$path =  \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
190
+			if ($app === "") { $app = "core"; }
191
+			$path = $this->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]).'?v='.$cacheBusterValue;
192
+		} elseif ($appPath && file_exists($appPath."/img/$image")) {
193
+			$path = \OC_App::getAppWebPath($app)."/img/$image";
194
+		} elseif ($appPath && !file_exists($appPath."/img/$basename.svg")
195
+			&& file_exists($appPath."/img/$basename.png")) {
196
+			$path = \OC_App::getAppWebPath($app)."/img/$basename.png";
197
+		} elseif (!empty($app) and file_exists(\OC::$SERVERROOT."/$app/img/$image")) {
198
+			$path = \OC::$WEBROOT."/$app/img/$image";
199
+		} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT."/$app/img/$basename.svg")
200
+				&& file_exists(\OC::$SERVERROOT."/$app/img/$basename.png"))) {
201
+			$path = \OC::$WEBROOT."/$app/img/$basename.png";
202
+		} elseif (file_exists(\OC::$SERVERROOT."/core/img/$image")) {
203
+			$path = \OC::$WEBROOT."/core/img/$image";
204
+		} elseif (!file_exists(\OC::$SERVERROOT."/core/img/$basename.svg")
205
+			&& file_exists(\OC::$SERVERROOT."/core/img/$basename.png")) {
206
+			$path = \OC::$WEBROOT."/themes/$theme/core/img/$basename.png";
207 207
 		}
208 208
 
209
-		if($path !== '') {
209
+		if ($path !== '') {
210 210
 			$cache->set($cacheKey, $path);
211 211
 			return $path;
212 212
 		} else {
213
-			throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT);
213
+			throw new RuntimeException('image not found: image:'.$image.' webroot:'.\OC::$WEBROOT.' serverroot:'.\OC::$SERVERROOT);
214 214
 		}
215 215
 	}
216 216
 
@@ -224,14 +224,14 @@  discard block
 block discarded – undo
224 224
 		$separator = $url[0] === '/' ? '' : '/';
225 225
 
226 226
 		if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
227
-			return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/');
227
+			return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/').'/'.ltrim($url, '/');
228 228
 		}
229 229
 		// The ownCloud web root can already be prepended.
230
-		if(substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT) {
230
+		if (substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT) {
231 231
 			$url = substr($url, strlen(\OC::$WEBROOT));
232 232
 		}
233 233
 
234
-		return $this->getBaseUrl() . $separator . $url;
234
+		return $this->getBaseUrl().$separator.$url;
235 235
 	}
236 236
 
237 237
 	/**
@@ -247,6 +247,6 @@  discard block
 block discarded – undo
247 247
 	 * @return string base url of the current request
248 248
 	 */
249 249
 	public function getBaseUrl() {
250
-		return $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT;
250
+		return $this->request->getServerProtocol().'://'.$this->request->getServerHost().\OC::$WEBROOT;
251 251
 	}
252 252
 }
Please login to merge, or discard this patch.