Completed
Pull Request — master (#4108)
by Jan-Christoph
58:51 queued 46:45
created
apps/theming/lib/Capabilities.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -33,37 +33,37 @@
 block discarded – undo
33 33
  */
34 34
 class Capabilities implements ICapability {
35 35
 
36
-	/** @var ThemingDefaults */
37
-	protected $theming;
36
+    /** @var ThemingDefaults */
37
+    protected $theming;
38 38
 
39 39
 
40
-	/** @var IURLGenerator */
41
-	protected $url;
40
+    /** @var IURLGenerator */
41
+    protected $url;
42 42
 
43
-	/**
44
-	 * @param ThemingDefaults $theming
45
-	 * @param IURLGenerator $url
46
-	 */
47
-	public function __construct(ThemingDefaults $theming, IURLGenerator $url) {
48
-		$this->theming = $theming;
49
-		$this->url = $url;
50
-	}
43
+    /**
44
+     * @param ThemingDefaults $theming
45
+     * @param IURLGenerator $url
46
+     */
47
+    public function __construct(ThemingDefaults $theming, IURLGenerator $url) {
48
+        $this->theming = $theming;
49
+        $this->url = $url;
50
+    }
51 51
 
52
-	/**
53
-	 * Return this classes capabilities
54
-	 *
55
-	 * @return array
56
-	 */
57
-	public function getCapabilities() {
58
-		return [
59
-			'theming' => [
60
-				'name' => $this->theming->getName(),
61
-				'url' => $this->theming->getBaseUrl(),
62
-				'slogan' => $this->theming->getSlogan(),
63
-				'color' => $this->theming->getColorPrimary(),
64
-				'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()),
65
-				'background' => $this->url->getAbsoluteURL($this->theming->getBackground()),
66
-			],
67
-		];
68
-	}
52
+    /**
53
+     * Return this classes capabilities
54
+     *
55
+     * @return array
56
+     */
57
+    public function getCapabilities() {
58
+        return [
59
+            'theming' => [
60
+                'name' => $this->theming->getName(),
61
+                'url' => $this->theming->getBaseUrl(),
62
+                'slogan' => $this->theming->getSlogan(),
63
+                'color' => $this->theming->getColorPrimary(),
64
+                'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()),
65
+                'background' => $this->url->getAbsoluteURL($this->theming->getBackground()),
66
+            ],
67
+        ];
68
+    }
69 69
 }
Please login to merge, or discard this patch.
apps/theming/lib/IconBuilder.php 1 patch
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -28,162 +28,162 @@
 block discarded – undo
28 28
 use OCP\App\AppPathNotFoundException;
29 29
 
30 30
 class IconBuilder {
31
-	/** @var ThemingDefaults */
32
-	private $themingDefaults;
33
-	/** @var Util */
34
-	private $util;
35
-
36
-	/**
37
-	 * IconBuilder constructor.
38
-	 *
39
-	 * @param ThemingDefaults $themingDefaults
40
-	 * @param Util $util
41
-	 */
42
-	public function __construct(
43
-		ThemingDefaults $themingDefaults,
44
-		Util $util
45
-	) {
46
-		$this->themingDefaults = $themingDefaults;
47
-		$this->util = $util;
48
-	}
49
-
50
-	/**
51
-	 * @param $app string app name
52
-	 * @return string|false image blob
53
-	 */
54
-	public function getFavicon($app) {
55
-		$icon = $this->renderAppIcon($app, 32);
56
-		if($icon === false) {
57
-			return false;
58
-		}
59
-		$icon->setImageFormat("png24");
60
-		$data = $icon->getImageBlob();
61
-		$icon->destroy();
62
-		return $data;
63
-	}
64
-
65
-	/**
66
-	 * @param $app string app name
67
-	 * @return string|false image blob
68
-	 */
69
-	public function getTouchIcon($app) {
70
-		$icon = $this->renderAppIcon($app, 512);
71
-		if($icon === false) {
72
-			return false;
73
-		}
74
-		$icon->setImageFormat("png24");
75
-		$data = $icon->getImageBlob();
76
-		$icon->destroy();
77
-		return $data;
78
-	}
79
-
80
-	/**
81
-	 * Render app icon on themed background color
82
-	 * fallback to logo
83
-	 *
84
-	 * @param $app string app name
85
-	 * @param $size int size of the icon in px
86
-	 * @return Imagick|false
87
-	 */
88
-	public function renderAppIcon($app, $size) {
89
-		try {
90
-			$appIcon = $this->util->getAppIcon($app);
91
-			$appIconContent = file_get_contents($appIcon);
92
-		} catch (AppPathNotFoundException $e) {
93
-			return false;
94
-		}
95
-
96
-		if($appIconContent === false) {
97
-			return false;
98
-		}
99
-
100
-		$color = $this->themingDefaults->getColorPrimary();
101
-		$mime = mime_content_type($appIcon);
102
-
103
-		// generate background image with rounded corners
104
-		$background = '<?xml version="1.0" encoding="UTF-8"?>' .
105
-			'<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:cc="http://creativecommons.org/ns#" width="512" height="512" xmlns:xlink="http://www.w3.org/1999/xlink">' .
106
-			'<rect x="0" y="0" rx="100" ry="100" width="512" height="512" style="fill:' . $color . ';" />' .
107
-			'</svg>';
108
-		// resize svg magic as this seems broken in Imagemagick
109
-		if($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") {
110
-			if(substr($appIconContent, 0, 5) !== "<?xml") {
111
-				$svg = "<?xml version=\"1.0\"?>".$appIconContent;
112
-			} else {
113
-				$svg = $appIconContent;
114
-			}
115
-			$tmp = new Imagick();
116
-			$tmp->readImageBlob($svg);
117
-			$x = $tmp->getImageWidth();
118
-			$y = $tmp->getImageHeight();
119
-			$res = $tmp->getImageResolution();
120
-			$tmp->destroy();
121
-
122
-			if($x>$y) {
123
-				$max = $x;
124
-			} else {
125
-				$max = $y;
126
-			}
127
-
128
-			// convert svg to resized image
129
-			$appIconFile = new Imagick();
130
-			$resX = (int)(512 * $res['x'] / $max * 2.53);
131
-			$resY = (int)(512 * $res['y'] / $max * 2.53);
132
-			$appIconFile->setResolution($resX, $resY);
133
-			$appIconFile->setBackgroundColor(new ImagickPixel('transparent'));
134
-			$appIconFile->readImageBlob($svg);
135
-			$appIconFile->scaleImage(512, 512, true);
136
-		} else {
137
-			$appIconFile = new Imagick();
138
-			$appIconFile->setBackgroundColor(new ImagickPixel('transparent'));
139
-			$appIconFile->readImageBlob(file_get_contents($appIcon));
140
-			$appIconFile->scaleImage(512, 512, true);
141
-		}
142
-
143
-		// offset for icon positioning
144
-		$border_w = (int)($appIconFile->getImageWidth() * 0.05);
145
-		$border_h = (int)($appIconFile->getImageHeight() * 0.05);
146
-		$innerWidth = (int)($appIconFile->getImageWidth() - $border_w * 2);
147
-		$innerHeight = (int)($appIconFile->getImageHeight() - $border_h * 2);
148
-		$appIconFile->adaptiveResizeImage($innerWidth, $innerHeight);
149
-		// center icon
150
-		$offset_w = 512 / 2 - $innerWidth / 2;
151
-		$offset_h = 512 / 2 - $innerHeight / 2;
152
-
153
-		$appIconFile->setImageFormat("png24");
154
-
155
-		$finalIconFile = new Imagick();
156
-		$finalIconFile->setBackgroundColor(new ImagickPixel('transparent'));
157
-		$finalIconFile->readImageBlob($background);
158
-		$finalIconFile->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
159
-		$finalIconFile->setImageArtifact('compose:args', "1,0,-0.5,0.5");
160
-		$finalIconFile->compositeImage($appIconFile, Imagick::COMPOSITE_ATOP, $offset_w, $offset_h);
161
-		$finalIconFile->setImageFormat('png24');
162
-		if (defined("Imagick::INTERPOLATE_BICUBIC") === true) {
163
-			$filter = Imagick::INTERPOLATE_BICUBIC;
164
-		} else {
165
-			$filter = Imagick::FILTER_LANCZOS;
166
-		}
167
-		$finalIconFile->resizeImage($size, $size, $filter, 1, false);
168
-
169
-		$appIconFile->destroy();
170
-		return $finalIconFile;
171
-	}
172
-
173
-	public function colorSvg($app, $image) {
174
-		try {
175
-			$imageFile = $this->util->getAppImage($app, $image);
176
-		} catch (AppPathNotFoundException $e) {
177
-			return false;
178
-		}
179
-		$svg = file_get_contents($imageFile);
180
-		if ($svg !== false && $svg !== "") {
181
-			$color = $this->util->elementColor($this->themingDefaults->getColorPrimary());
182
-			$svg = $this->util->colorizeSvg($svg, $color);
183
-			return $svg;
184
-		} else {
185
-			return false;
186
-		}
187
-	}
31
+    /** @var ThemingDefaults */
32
+    private $themingDefaults;
33
+    /** @var Util */
34
+    private $util;
35
+
36
+    /**
37
+     * IconBuilder constructor.
38
+     *
39
+     * @param ThemingDefaults $themingDefaults
40
+     * @param Util $util
41
+     */
42
+    public function __construct(
43
+        ThemingDefaults $themingDefaults,
44
+        Util $util
45
+    ) {
46
+        $this->themingDefaults = $themingDefaults;
47
+        $this->util = $util;
48
+    }
49
+
50
+    /**
51
+     * @param $app string app name
52
+     * @return string|false image blob
53
+     */
54
+    public function getFavicon($app) {
55
+        $icon = $this->renderAppIcon($app, 32);
56
+        if($icon === false) {
57
+            return false;
58
+        }
59
+        $icon->setImageFormat("png24");
60
+        $data = $icon->getImageBlob();
61
+        $icon->destroy();
62
+        return $data;
63
+    }
64
+
65
+    /**
66
+     * @param $app string app name
67
+     * @return string|false image blob
68
+     */
69
+    public function getTouchIcon($app) {
70
+        $icon = $this->renderAppIcon($app, 512);
71
+        if($icon === false) {
72
+            return false;
73
+        }
74
+        $icon->setImageFormat("png24");
75
+        $data = $icon->getImageBlob();
76
+        $icon->destroy();
77
+        return $data;
78
+    }
79
+
80
+    /**
81
+     * Render app icon on themed background color
82
+     * fallback to logo
83
+     *
84
+     * @param $app string app name
85
+     * @param $size int size of the icon in px
86
+     * @return Imagick|false
87
+     */
88
+    public function renderAppIcon($app, $size) {
89
+        try {
90
+            $appIcon = $this->util->getAppIcon($app);
91
+            $appIconContent = file_get_contents($appIcon);
92
+        } catch (AppPathNotFoundException $e) {
93
+            return false;
94
+        }
95
+
96
+        if($appIconContent === false) {
97
+            return false;
98
+        }
99
+
100
+        $color = $this->themingDefaults->getColorPrimary();
101
+        $mime = mime_content_type($appIcon);
102
+
103
+        // generate background image with rounded corners
104
+        $background = '<?xml version="1.0" encoding="UTF-8"?>' .
105
+            '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:cc="http://creativecommons.org/ns#" width="512" height="512" xmlns:xlink="http://www.w3.org/1999/xlink">' .
106
+            '<rect x="0" y="0" rx="100" ry="100" width="512" height="512" style="fill:' . $color . ';" />' .
107
+            '</svg>';
108
+        // resize svg magic as this seems broken in Imagemagick
109
+        if($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") {
110
+            if(substr($appIconContent, 0, 5) !== "<?xml") {
111
+                $svg = "<?xml version=\"1.0\"?>".$appIconContent;
112
+            } else {
113
+                $svg = $appIconContent;
114
+            }
115
+            $tmp = new Imagick();
116
+            $tmp->readImageBlob($svg);
117
+            $x = $tmp->getImageWidth();
118
+            $y = $tmp->getImageHeight();
119
+            $res = $tmp->getImageResolution();
120
+            $tmp->destroy();
121
+
122
+            if($x>$y) {
123
+                $max = $x;
124
+            } else {
125
+                $max = $y;
126
+            }
127
+
128
+            // convert svg to resized image
129
+            $appIconFile = new Imagick();
130
+            $resX = (int)(512 * $res['x'] / $max * 2.53);
131
+            $resY = (int)(512 * $res['y'] / $max * 2.53);
132
+            $appIconFile->setResolution($resX, $resY);
133
+            $appIconFile->setBackgroundColor(new ImagickPixel('transparent'));
134
+            $appIconFile->readImageBlob($svg);
135
+            $appIconFile->scaleImage(512, 512, true);
136
+        } else {
137
+            $appIconFile = new Imagick();
138
+            $appIconFile->setBackgroundColor(new ImagickPixel('transparent'));
139
+            $appIconFile->readImageBlob(file_get_contents($appIcon));
140
+            $appIconFile->scaleImage(512, 512, true);
141
+        }
142
+
143
+        // offset for icon positioning
144
+        $border_w = (int)($appIconFile->getImageWidth() * 0.05);
145
+        $border_h = (int)($appIconFile->getImageHeight() * 0.05);
146
+        $innerWidth = (int)($appIconFile->getImageWidth() - $border_w * 2);
147
+        $innerHeight = (int)($appIconFile->getImageHeight() - $border_h * 2);
148
+        $appIconFile->adaptiveResizeImage($innerWidth, $innerHeight);
149
+        // center icon
150
+        $offset_w = 512 / 2 - $innerWidth / 2;
151
+        $offset_h = 512 / 2 - $innerHeight / 2;
152
+
153
+        $appIconFile->setImageFormat("png24");
154
+
155
+        $finalIconFile = new Imagick();
156
+        $finalIconFile->setBackgroundColor(new ImagickPixel('transparent'));
157
+        $finalIconFile->readImageBlob($background);
158
+        $finalIconFile->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
159
+        $finalIconFile->setImageArtifact('compose:args', "1,0,-0.5,0.5");
160
+        $finalIconFile->compositeImage($appIconFile, Imagick::COMPOSITE_ATOP, $offset_w, $offset_h);
161
+        $finalIconFile->setImageFormat('png24');
162
+        if (defined("Imagick::INTERPOLATE_BICUBIC") === true) {
163
+            $filter = Imagick::INTERPOLATE_BICUBIC;
164
+        } else {
165
+            $filter = Imagick::FILTER_LANCZOS;
166
+        }
167
+        $finalIconFile->resizeImage($size, $size, $filter, 1, false);
168
+
169
+        $appIconFile->destroy();
170
+        return $finalIconFile;
171
+    }
172
+
173
+    public function colorSvg($app, $image) {
174
+        try {
175
+            $imageFile = $this->util->getAppImage($app, $image);
176
+        } catch (AppPathNotFoundException $e) {
177
+            return false;
178
+        }
179
+        $svg = file_get_contents($imageFile);
180
+        if ($svg !== false && $svg !== "") {
181
+            $color = $this->util->elementColor($this->themingDefaults->getColorPrimary());
182
+            $svg = $this->util->colorizeSvg($svg, $color);
183
+            return $svg;
184
+        } else {
185
+            return false;
186
+        }
187
+    }
188 188
 
189 189
 }
Please login to merge, or discard this patch.
lib/private/Files/ObjectStore/Swift.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,6 @@
 block discarded – undo
28 28
 use OCP\Files\ObjectStore\IObjectStore;
29 29
 use OCP\Files\StorageAuthException;
30 30
 use OCP\Files\StorageNotAvailableException;
31
-use OpenCloud\Common\Exceptions\EndpointError;
32 31
 use OpenCloud\Common\Service\Catalog;
33 32
 use OpenCloud\Common\Service\CatalogItem;
34 33
 use OpenCloud\ObjectStore\Service;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 			}
162 162
 		}
163 163
 
164
-		$availableRegions = implode(', ', array_map(function ($endpoint) {
164
+		$availableRegions = implode(', ', array_map(function($endpoint) {
165 165
 			return $endpoint->region;
166 166
 		}, $endPoints));
167 167
 
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
 	}
170 170
 
171 171
 	private function getAvailableServiceNames(Catalog $catalog) {
172
-		return array_map(function (CatalogItem $item) {
172
+		return array_map(function(CatalogItem $item) {
173 173
 			return $item->getName();
174
-		}, array_filter($catalog->getItems(), function (CatalogItem $item) {
174
+		}, array_filter($catalog->getItems(), function(CatalogItem $item) {
175 175
 			return $item->hasType(Service::DEFAULT_TYPE);
176 176
 		}));
177 177
 	}
Please login to merge, or discard this patch.
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -37,198 +37,198 @@
 block discarded – undo
37 37
 
38 38
 class Swift implements IObjectStore {
39 39
 
40
-	/**
41
-	 * @var \OpenCloud\OpenStack
42
-	 */
43
-	private $client;
44
-
45
-	/**
46
-	 * @var array
47
-	 */
48
-	private $params;
49
-
50
-	/**
51
-	 * @var \OpenCloud\ObjectStore\Service
52
-	 */
53
-	private $objectStoreService;
54
-
55
-	/**
56
-	 * @var \OpenCloud\ObjectStore\Resource\Container
57
-	 */
58
-	private $container;
59
-
60
-	public function __construct($params) {
61
-		if (isset($params['bucket'])) {
62
-			$params['container'] = $params['bucket'];
63
-		}
64
-		if (!isset($params['container'])) {
65
-			$params['container'] = 'owncloud';
66
-		}
67
-		if (!isset($params['autocreate'])) {
68
-			// should only be true for tests
69
-			$params['autocreate'] = false;
70
-		}
71
-
72
-		if (isset($params['apiKey'])) {
73
-			$this->client = new Rackspace($params['url'], $params);
74
-		} else {
75
-			$this->client = new OpenStack($params['url'], $params);
76
-		}
77
-		$this->params = $params;
78
-	}
79
-
80
-	protected function init() {
81
-		if ($this->container) {
82
-			return;
83
-		}
84
-
85
-		try {
86
-			$this->client->authenticate();
87
-		} catch (ClientErrorResponseException $e) {
88
-			$statusCode = $e->getResponse()->getStatusCode();
89
-			if ($statusCode == 412) {
90
-				throw new StorageAuthException('Precondition failed, verify the keystone url', $e);
91
-			} else if ($statusCode === 401) {
92
-				throw new StorageAuthException('Authentication failed, verify the username, password and possibly tenant', $e);
93
-			} else {
94
-				throw new StorageAuthException('Unknown error', $e);
95
-			}
96
-		}
97
-
98
-		/** @var Catalog $catalog */
99
-		$catalog = $this->client->getCatalog();
100
-
101
-		if (isset($this->params['serviceName'])) {
102
-			$serviceName = $this->params['serviceName'];
103
-		} else {
104
-			$serviceName = Service::DEFAULT_NAME;
105
-		}
106
-
107
-		if (isset($this->params['urlType'])) {
108
-			$urlType = $this->params['urlType'];
109
-			if ($urlType !== 'internalURL' && $urlType !== 'publicURL') {
110
-				throw new StorageNotAvailableException('Invalid url type');
111
-			}
112
-		} else {
113
-			$urlType = Service::DEFAULT_URL_TYPE;
114
-		}
115
-
116
-		$catalogItem = $this->getCatalogForService($catalog, $serviceName);
117
-		if (!$catalogItem) {
118
-			$available = implode(', ', $this->getAvailableServiceNames($catalog));
119
-			throw new StorageNotAvailableException(
120
-				"Service $serviceName not found in service catalog, available services: $available"
121
-			);
122
-		} else if (isset($this->params['region'])) {
123
-			$this->validateRegion($catalogItem, $this->params['region']);
124
-		}
125
-
126
-		$this->objectStoreService = $this->client->objectStoreService($serviceName, $this->params['region'], $urlType);
127
-
128
-		try {
129
-			$this->container = $this->objectStoreService->getContainer($this->params['container']);
130
-		} catch (ClientErrorResponseException $ex) {
131
-			// if the container does not exist and autocreate is true try to create the container on the fly
132
-			if (isset($this->params['autocreate']) && $this->params['autocreate'] === true) {
133
-				$this->container = $this->objectStoreService->createContainer($this->params['container']);
134
-			} else {
135
-				throw $ex;
136
-			}
137
-		}
138
-	}
139
-
140
-	/**
141
-	 * @param Catalog $catalog
142
-	 * @param $name
143
-	 * @return null|CatalogItem
144
-	 */
145
-	private function getCatalogForService(Catalog $catalog, $name) {
146
-		foreach ($catalog->getItems() as $item) {
147
-			/** @var CatalogItem $item */
148
-			if ($item->hasType(Service::DEFAULT_TYPE) && $item->hasName($name)) {
149
-				return $item;
150
-			}
151
-		}
152
-
153
-		return null;
154
-	}
155
-
156
-	private function validateRegion(CatalogItem $item, $region) {
157
-		$endPoints = $item->getEndpoints();
158
-		foreach ($endPoints as $endPoint) {
159
-			if ($endPoint->region === $region) {
160
-				return;
161
-			}
162
-		}
163
-
164
-		$availableRegions = implode(', ', array_map(function ($endpoint) {
165
-			return $endpoint->region;
166
-		}, $endPoints));
167
-
168
-		throw new StorageNotAvailableException("Invalid region '$region', available regions: $availableRegions");
169
-	}
170
-
171
-	private function getAvailableServiceNames(Catalog $catalog) {
172
-		return array_map(function (CatalogItem $item) {
173
-			return $item->getName();
174
-		}, array_filter($catalog->getItems(), function (CatalogItem $item) {
175
-			return $item->hasType(Service::DEFAULT_TYPE);
176
-		}));
177
-	}
178
-
179
-	/**
180
-	 * @return string the container name where objects are stored
181
-	 */
182
-	public function getStorageId() {
183
-		return $this->params['container'];
184
-	}
185
-
186
-	/**
187
-	 * @param string $urn the unified resource name used to identify the object
188
-	 * @param resource $stream stream with the data to write
189
-	 * @throws Exception from openstack lib when something goes wrong
190
-	 */
191
-	public function writeObject($urn, $stream) {
192
-		$this->init();
193
-		$this->container->uploadObject($urn, $stream);
194
-	}
195
-
196
-	/**
197
-	 * @param string $urn the unified resource name used to identify the object
198
-	 * @return resource stream with the read data
199
-	 * @throws Exception from openstack lib when something goes wrong
200
-	 */
201
-	public function readObject($urn) {
202
-		$this->init();
203
-		$object = $this->container->getObject($urn);
204
-
205
-		// we need to keep a reference to objectContent or
206
-		// the stream will be closed before we can do anything with it
207
-		/** @var $objectContent \Guzzle\Http\EntityBody * */
208
-		$objectContent = $object->getContent();
209
-		$objectContent->rewind();
210
-
211
-		$stream = $objectContent->getStream();
212
-		// save the object content in the context of the stream to prevent it being gc'd until the stream is closed
213
-		stream_context_set_option($stream, 'swift', 'content', $objectContent);
214
-
215
-		return $stream;
216
-	}
217
-
218
-	/**
219
-	 * @param string $urn Unified Resource Name
220
-	 * @return void
221
-	 * @throws Exception from openstack lib when something goes wrong
222
-	 */
223
-	public function deleteObject($urn) {
224
-		$this->init();
225
-		// see https://github.com/rackspace/php-opencloud/issues/243#issuecomment-30032242
226
-		$this->container->dataObject()->setName($urn)->delete();
227
-	}
228
-
229
-	public function deleteContainer($recursive = false) {
230
-		$this->init();
231
-		$this->container->delete($recursive);
232
-	}
40
+    /**
41
+     * @var \OpenCloud\OpenStack
42
+     */
43
+    private $client;
44
+
45
+    /**
46
+     * @var array
47
+     */
48
+    private $params;
49
+
50
+    /**
51
+     * @var \OpenCloud\ObjectStore\Service
52
+     */
53
+    private $objectStoreService;
54
+
55
+    /**
56
+     * @var \OpenCloud\ObjectStore\Resource\Container
57
+     */
58
+    private $container;
59
+
60
+    public function __construct($params) {
61
+        if (isset($params['bucket'])) {
62
+            $params['container'] = $params['bucket'];
63
+        }
64
+        if (!isset($params['container'])) {
65
+            $params['container'] = 'owncloud';
66
+        }
67
+        if (!isset($params['autocreate'])) {
68
+            // should only be true for tests
69
+            $params['autocreate'] = false;
70
+        }
71
+
72
+        if (isset($params['apiKey'])) {
73
+            $this->client = new Rackspace($params['url'], $params);
74
+        } else {
75
+            $this->client = new OpenStack($params['url'], $params);
76
+        }
77
+        $this->params = $params;
78
+    }
79
+
80
+    protected function init() {
81
+        if ($this->container) {
82
+            return;
83
+        }
84
+
85
+        try {
86
+            $this->client->authenticate();
87
+        } catch (ClientErrorResponseException $e) {
88
+            $statusCode = $e->getResponse()->getStatusCode();
89
+            if ($statusCode == 412) {
90
+                throw new StorageAuthException('Precondition failed, verify the keystone url', $e);
91
+            } else if ($statusCode === 401) {
92
+                throw new StorageAuthException('Authentication failed, verify the username, password and possibly tenant', $e);
93
+            } else {
94
+                throw new StorageAuthException('Unknown error', $e);
95
+            }
96
+        }
97
+
98
+        /** @var Catalog $catalog */
99
+        $catalog = $this->client->getCatalog();
100
+
101
+        if (isset($this->params['serviceName'])) {
102
+            $serviceName = $this->params['serviceName'];
103
+        } else {
104
+            $serviceName = Service::DEFAULT_NAME;
105
+        }
106
+
107
+        if (isset($this->params['urlType'])) {
108
+            $urlType = $this->params['urlType'];
109
+            if ($urlType !== 'internalURL' && $urlType !== 'publicURL') {
110
+                throw new StorageNotAvailableException('Invalid url type');
111
+            }
112
+        } else {
113
+            $urlType = Service::DEFAULT_URL_TYPE;
114
+        }
115
+
116
+        $catalogItem = $this->getCatalogForService($catalog, $serviceName);
117
+        if (!$catalogItem) {
118
+            $available = implode(', ', $this->getAvailableServiceNames($catalog));
119
+            throw new StorageNotAvailableException(
120
+                "Service $serviceName not found in service catalog, available services: $available"
121
+            );
122
+        } else if (isset($this->params['region'])) {
123
+            $this->validateRegion($catalogItem, $this->params['region']);
124
+        }
125
+
126
+        $this->objectStoreService = $this->client->objectStoreService($serviceName, $this->params['region'], $urlType);
127
+
128
+        try {
129
+            $this->container = $this->objectStoreService->getContainer($this->params['container']);
130
+        } catch (ClientErrorResponseException $ex) {
131
+            // if the container does not exist and autocreate is true try to create the container on the fly
132
+            if (isset($this->params['autocreate']) && $this->params['autocreate'] === true) {
133
+                $this->container = $this->objectStoreService->createContainer($this->params['container']);
134
+            } else {
135
+                throw $ex;
136
+            }
137
+        }
138
+    }
139
+
140
+    /**
141
+     * @param Catalog $catalog
142
+     * @param $name
143
+     * @return null|CatalogItem
144
+     */
145
+    private function getCatalogForService(Catalog $catalog, $name) {
146
+        foreach ($catalog->getItems() as $item) {
147
+            /** @var CatalogItem $item */
148
+            if ($item->hasType(Service::DEFAULT_TYPE) && $item->hasName($name)) {
149
+                return $item;
150
+            }
151
+        }
152
+
153
+        return null;
154
+    }
155
+
156
+    private function validateRegion(CatalogItem $item, $region) {
157
+        $endPoints = $item->getEndpoints();
158
+        foreach ($endPoints as $endPoint) {
159
+            if ($endPoint->region === $region) {
160
+                return;
161
+            }
162
+        }
163
+
164
+        $availableRegions = implode(', ', array_map(function ($endpoint) {
165
+            return $endpoint->region;
166
+        }, $endPoints));
167
+
168
+        throw new StorageNotAvailableException("Invalid region '$region', available regions: $availableRegions");
169
+    }
170
+
171
+    private function getAvailableServiceNames(Catalog $catalog) {
172
+        return array_map(function (CatalogItem $item) {
173
+            return $item->getName();
174
+        }, array_filter($catalog->getItems(), function (CatalogItem $item) {
175
+            return $item->hasType(Service::DEFAULT_TYPE);
176
+        }));
177
+    }
178
+
179
+    /**
180
+     * @return string the container name where objects are stored
181
+     */
182
+    public function getStorageId() {
183
+        return $this->params['container'];
184
+    }
185
+
186
+    /**
187
+     * @param string $urn the unified resource name used to identify the object
188
+     * @param resource $stream stream with the data to write
189
+     * @throws Exception from openstack lib when something goes wrong
190
+     */
191
+    public function writeObject($urn, $stream) {
192
+        $this->init();
193
+        $this->container->uploadObject($urn, $stream);
194
+    }
195
+
196
+    /**
197
+     * @param string $urn the unified resource name used to identify the object
198
+     * @return resource stream with the read data
199
+     * @throws Exception from openstack lib when something goes wrong
200
+     */
201
+    public function readObject($urn) {
202
+        $this->init();
203
+        $object = $this->container->getObject($urn);
204
+
205
+        // we need to keep a reference to objectContent or
206
+        // the stream will be closed before we can do anything with it
207
+        /** @var $objectContent \Guzzle\Http\EntityBody * */
208
+        $objectContent = $object->getContent();
209
+        $objectContent->rewind();
210
+
211
+        $stream = $objectContent->getStream();
212
+        // save the object content in the context of the stream to prevent it being gc'd until the stream is closed
213
+        stream_context_set_option($stream, 'swift', 'content', $objectContent);
214
+
215
+        return $stream;
216
+    }
217
+
218
+    /**
219
+     * @param string $urn Unified Resource Name
220
+     * @return void
221
+     * @throws Exception from openstack lib when something goes wrong
222
+     */
223
+    public function deleteObject($urn) {
224
+        $this->init();
225
+        // see https://github.com/rackspace/php-opencloud/issues/243#issuecomment-30032242
226
+        $this->container->dataObject()->setName($urn)->delete();
227
+    }
228
+
229
+    public function deleteContainer($recursive = false) {
230
+        $this->init();
231
+        $this->container->delete($recursive);
232
+    }
233 233
 
234 234
 }
Please login to merge, or discard this patch.
apps/encryption/templates/mail.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	<tr><td>
28 28
 			<table cellspacing="0" cellpadding="0" border="0" width="600px">
29 29
 				<tr>
30
-					<td colspan="2" bgcolor="<?php p($theme->getColorPrimary());?>">
30
+					<td colspan="2" bgcolor="<?php p($theme->getColorPrimary()); ?>">
31 31
 						<img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL(image_path('', 'logo-mail.png'))); ?>" alt="<?php p($theme->getName()); ?>"/>
32 32
 					</td>
33 33
 				</tr>
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 					<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">--<br>
53 53
 						<?php p($theme->getName()); ?> -
54 54
 						<?php p($theme->getSlogan()); ?>
55
-						<br><a href="<?php p($theme->getBaseUrl()); ?>"><?php p($theme->getBaseUrl());?></a>
55
+						<br><a href="<?php p($theme->getBaseUrl()); ?>"><?php p($theme->getBaseUrl()); ?></a>
56 56
 					</td>
57 57
 				</tr>
58 58
 				<tr>
Please login to merge, or discard this patch.
lib/private/legacy/defaults.php 2 patches
Indentation   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -31,262 +31,262 @@
 block discarded – undo
31 31
  */
32 32
 class OC_Defaults {
33 33
 
34
-	private $theme;
35
-	private $l;
34
+    private $theme;
35
+    private $l;
36 36
 
37
-	private $defaultEntity;
38
-	private $defaultName;
39
-	private $defaultTitle;
40
-	private $defaultBaseUrl;
41
-	private $defaultSyncClientUrl;
42
-	private $defaultiOSClientUrl;
43
-	private $defaultiTunesAppId;
44
-	private $defaultAndroidClientUrl;
45
-	private $defaultDocBaseUrl;
46
-	private $defaultDocVersion;
47
-	private $defaultSlogan;
48
-	private $defaultLogoClaim;
49
-	private $defaultColorPrimary;
37
+    private $defaultEntity;
38
+    private $defaultName;
39
+    private $defaultTitle;
40
+    private $defaultBaseUrl;
41
+    private $defaultSyncClientUrl;
42
+    private $defaultiOSClientUrl;
43
+    private $defaultiTunesAppId;
44
+    private $defaultAndroidClientUrl;
45
+    private $defaultDocBaseUrl;
46
+    private $defaultDocVersion;
47
+    private $defaultSlogan;
48
+    private $defaultLogoClaim;
49
+    private $defaultColorPrimary;
50 50
 
51
-	function __construct() {
52
-		$this->l = \OC::$server->getL10N('lib');
51
+    function __construct() {
52
+        $this->l = \OC::$server->getL10N('lib');
53 53
 
54
-		$this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */
55
-		$this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */
56
-		$this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */
57
-		$this->defaultBaseUrl = 'https://nextcloud.com';
58
-		$this->defaultSyncClientUrl = 'https://nextcloud.com/install/#install-clients';
59
-		$this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8';
60
-		$this->defaultiTunesAppId = '1125420102';
61
-		$this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.nextcloud.client';
62
-		$this->defaultDocBaseUrl = 'https://docs.nextcloud.com';
63
-		$this->defaultDocVersion = '11'; // used to generate doc links
64
-		$this->defaultSlogan = $this->l->t('a safe home for all your data');
65
-		$this->defaultLogoClaim = '';
66
-		$this->defaultColorPrimary = '#0082c9';
54
+        $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */
55
+        $this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */
56
+        $this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */
57
+        $this->defaultBaseUrl = 'https://nextcloud.com';
58
+        $this->defaultSyncClientUrl = 'https://nextcloud.com/install/#install-clients';
59
+        $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8';
60
+        $this->defaultiTunesAppId = '1125420102';
61
+        $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.nextcloud.client';
62
+        $this->defaultDocBaseUrl = 'https://docs.nextcloud.com';
63
+        $this->defaultDocVersion = '11'; // used to generate doc links
64
+        $this->defaultSlogan = $this->l->t('a safe home for all your data');
65
+        $this->defaultLogoClaim = '';
66
+        $this->defaultColorPrimary = '#0082c9';
67 67
 
68
-		$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
69
-		if (file_exists($themePath)) {
70
-			// prevent defaults.php from printing output
71
-			ob_start();
72
-			require_once $themePath;
73
-			ob_end_clean();
74
-			if (class_exists('OC_Theme')) {
75
-				$this->theme = new OC_Theme();
76
-			}
77
-		}
78
-	}
68
+        $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
69
+        if (file_exists($themePath)) {
70
+            // prevent defaults.php from printing output
71
+            ob_start();
72
+            require_once $themePath;
73
+            ob_end_clean();
74
+            if (class_exists('OC_Theme')) {
75
+                $this->theme = new OC_Theme();
76
+            }
77
+        }
78
+    }
79 79
 
80
-	/**
81
-	 * @param string $method
82
-	 */
83
-	private function themeExist($method) {
84
-		if (isset($this->theme) && method_exists($this->theme, $method)) {
85
-			return true;
86
-		}
87
-		return false;
88
-	}
80
+    /**
81
+     * @param string $method
82
+     */
83
+    private function themeExist($method) {
84
+        if (isset($this->theme) && method_exists($this->theme, $method)) {
85
+            return true;
86
+        }
87
+        return false;
88
+    }
89 89
 
90
-	/**
91
-	 * Returns the base URL
92
-	 * @return string URL
93
-	 */
94
-	public function getBaseUrl() {
95
-		if ($this->themeExist('getBaseUrl')) {
96
-			return $this->theme->getBaseUrl();
97
-		} else {
98
-			return $this->defaultBaseUrl;
99
-		}
100
-	}
90
+    /**
91
+     * Returns the base URL
92
+     * @return string URL
93
+     */
94
+    public function getBaseUrl() {
95
+        if ($this->themeExist('getBaseUrl')) {
96
+            return $this->theme->getBaseUrl();
97
+        } else {
98
+            return $this->defaultBaseUrl;
99
+        }
100
+    }
101 101
 
102
-	/**
103
-	 * Returns the URL where the sync clients are listed
104
-	 * @return string URL
105
-	 */
106
-	public function getSyncClientUrl() {
107
-		if ($this->themeExist('getSyncClientUrl')) {
108
-			return $this->theme->getSyncClientUrl();
109
-		} else {
110
-			return $this->defaultSyncClientUrl;
111
-		}
112
-	}
102
+    /**
103
+     * Returns the URL where the sync clients are listed
104
+     * @return string URL
105
+     */
106
+    public function getSyncClientUrl() {
107
+        if ($this->themeExist('getSyncClientUrl')) {
108
+            return $this->theme->getSyncClientUrl();
109
+        } else {
110
+            return $this->defaultSyncClientUrl;
111
+        }
112
+    }
113 113
 
114
-	/**
115
-	 * Returns the URL to the App Store for the iOS Client
116
-	 * @return string URL
117
-	 */
118
-	public function getiOSClientUrl() {
119
-		if ($this->themeExist('getiOSClientUrl')) {
120
-			return $this->theme->getiOSClientUrl();
121
-		} else {
122
-			return $this->defaultiOSClientUrl;
123
-		}
124
-	}
114
+    /**
115
+     * Returns the URL to the App Store for the iOS Client
116
+     * @return string URL
117
+     */
118
+    public function getiOSClientUrl() {
119
+        if ($this->themeExist('getiOSClientUrl')) {
120
+            return $this->theme->getiOSClientUrl();
121
+        } else {
122
+            return $this->defaultiOSClientUrl;
123
+        }
124
+    }
125 125
 
126
-	/**
127
-	 * Returns the AppId for the App Store for the iOS Client
128
-	 * @return string AppId
129
-	 */
130
-	public function getiTunesAppId() {
131
-		if ($this->themeExist('getiTunesAppId')) {
132
-			return $this->theme->getiTunesAppId();
133
-		} else {
134
-			return $this->defaultiTunesAppId;
135
-		}
136
-	}
126
+    /**
127
+     * Returns the AppId for the App Store for the iOS Client
128
+     * @return string AppId
129
+     */
130
+    public function getiTunesAppId() {
131
+        if ($this->themeExist('getiTunesAppId')) {
132
+            return $this->theme->getiTunesAppId();
133
+        } else {
134
+            return $this->defaultiTunesAppId;
135
+        }
136
+    }
137 137
 
138
-	/**
139
-	 * Returns the URL to Google Play for the Android Client
140
-	 * @return string URL
141
-	 */
142
-	public function getAndroidClientUrl() {
143
-		if ($this->themeExist('getAndroidClientUrl')) {
144
-			return $this->theme->getAndroidClientUrl();
145
-		} else {
146
-			return $this->defaultAndroidClientUrl;
147
-		}
148
-	}
138
+    /**
139
+     * Returns the URL to Google Play for the Android Client
140
+     * @return string URL
141
+     */
142
+    public function getAndroidClientUrl() {
143
+        if ($this->themeExist('getAndroidClientUrl')) {
144
+            return $this->theme->getAndroidClientUrl();
145
+        } else {
146
+            return $this->defaultAndroidClientUrl;
147
+        }
148
+    }
149 149
 
150
-	/**
151
-	 * Returns the documentation URL
152
-	 * @return string URL
153
-	 */
154
-	public function getDocBaseUrl() {
155
-		if ($this->themeExist('getDocBaseUrl')) {
156
-			return $this->theme->getDocBaseUrl();
157
-		} else {
158
-			return $this->defaultDocBaseUrl;
159
-		}
160
-	}
150
+    /**
151
+     * Returns the documentation URL
152
+     * @return string URL
153
+     */
154
+    public function getDocBaseUrl() {
155
+        if ($this->themeExist('getDocBaseUrl')) {
156
+            return $this->theme->getDocBaseUrl();
157
+        } else {
158
+            return $this->defaultDocBaseUrl;
159
+        }
160
+    }
161 161
 
162
-	/**
163
-	 * Returns the title
164
-	 * @return string title
165
-	 */
166
-	public function getTitle() {
167
-		if ($this->themeExist('getTitle')) {
168
-			return $this->theme->getTitle();
169
-		} else {
170
-			return $this->defaultTitle;
171
-		}
172
-	}
162
+    /**
163
+     * Returns the title
164
+     * @return string title
165
+     */
166
+    public function getTitle() {
167
+        if ($this->themeExist('getTitle')) {
168
+            return $this->theme->getTitle();
169
+        } else {
170
+            return $this->defaultTitle;
171
+        }
172
+    }
173 173
 
174
-	/**
175
-	 * Returns the short name of the software
176
-	 * @return string title
177
-	 */
178
-	public function getName() {
179
-		if ($this->themeExist('getName')) {
180
-			return $this->theme->getName();
181
-		} else {
182
-			return $this->defaultName;
183
-		}
184
-	}
174
+    /**
175
+     * Returns the short name of the software
176
+     * @return string title
177
+     */
178
+    public function getName() {
179
+        if ($this->themeExist('getName')) {
180
+            return $this->theme->getName();
181
+        } else {
182
+            return $this->defaultName;
183
+        }
184
+    }
185 185
 
186
-	/**
187
-	 * Returns the short name of the software containing HTML strings
188
-	 * @return string title
189
-	 */
190
-	public function getHTMLName() {
191
-		if ($this->themeExist('getHTMLName')) {
192
-			return $this->theme->getHTMLName();
193
-		} else {
194
-			return $this->defaultName;
195
-		}
196
-	}
186
+    /**
187
+     * Returns the short name of the software containing HTML strings
188
+     * @return string title
189
+     */
190
+    public function getHTMLName() {
191
+        if ($this->themeExist('getHTMLName')) {
192
+            return $this->theme->getHTMLName();
193
+        } else {
194
+            return $this->defaultName;
195
+        }
196
+    }
197 197
 
198
-	/**
199
-	 * Returns entity (e.g. company name) - used for footer, copyright
200
-	 * @return string entity name
201
-	 */
202
-	public function getEntity() {
203
-		if ($this->themeExist('getEntity')) {
204
-			return $this->theme->getEntity();
205
-		} else {
206
-			return $this->defaultEntity;
207
-		}
208
-	}
198
+    /**
199
+     * Returns entity (e.g. company name) - used for footer, copyright
200
+     * @return string entity name
201
+     */
202
+    public function getEntity() {
203
+        if ($this->themeExist('getEntity')) {
204
+            return $this->theme->getEntity();
205
+        } else {
206
+            return $this->defaultEntity;
207
+        }
208
+    }
209 209
 
210
-	/**
211
-	 * Returns slogan
212
-	 * @return string slogan
213
-	 */
214
-	public function getSlogan() {
215
-		if ($this->themeExist('getSlogan')) {
216
-			return $this->theme->getSlogan();
217
-		} else {
218
-			return $this->defaultSlogan;
219
-		}
220
-	}
210
+    /**
211
+     * Returns slogan
212
+     * @return string slogan
213
+     */
214
+    public function getSlogan() {
215
+        if ($this->themeExist('getSlogan')) {
216
+            return $this->theme->getSlogan();
217
+        } else {
218
+            return $this->defaultSlogan;
219
+        }
220
+    }
221 221
 
222
-	/**
223
-	 * Returns logo claim
224
-	 * @return string logo claim
225
-	 */
226
-	public function getLogoClaim() {
227
-		if ($this->themeExist('getLogoClaim')) {
228
-			return $this->theme->getLogoClaim();
229
-		} else {
230
-			return $this->defaultLogoClaim;
231
-		}
232
-	}
222
+    /**
223
+     * Returns logo claim
224
+     * @return string logo claim
225
+     */
226
+    public function getLogoClaim() {
227
+        if ($this->themeExist('getLogoClaim')) {
228
+            return $this->theme->getLogoClaim();
229
+        } else {
230
+            return $this->defaultLogoClaim;
231
+        }
232
+    }
233 233
 
234
-	/**
235
-	 * Returns short version of the footer
236
-	 * @return string short footer
237
-	 */
238
-	public function getShortFooter() {
239
-		if ($this->themeExist('getShortFooter')) {
240
-			$footer = $this->theme->getShortFooter();
241
-		} else {
242
-			$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
243
-				' rel="noreferrer">' .$this->getEntity() . '</a>'.
244
-				' – ' . $this->getSlogan();
245
-		}
234
+    /**
235
+     * Returns short version of the footer
236
+     * @return string short footer
237
+     */
238
+    public function getShortFooter() {
239
+        if ($this->themeExist('getShortFooter')) {
240
+            $footer = $this->theme->getShortFooter();
241
+        } else {
242
+            $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
243
+                ' rel="noreferrer">' .$this->getEntity() . '</a>'.
244
+                ' – ' . $this->getSlogan();
245
+        }
246 246
 
247
-		return $footer;
248
-	}
247
+        return $footer;
248
+    }
249 249
 
250
-	/**
251
-	 * Returns long version of the footer
252
-	 * @return string long footer
253
-	 */
254
-	public function getLongFooter() {
255
-		if ($this->themeExist('getLongFooter')) {
256
-			$footer = $this->theme->getLongFooter();
257
-		} else {
258
-			$footer = $this->getShortFooter();
259
-		}
250
+    /**
251
+     * Returns long version of the footer
252
+     * @return string long footer
253
+     */
254
+    public function getLongFooter() {
255
+        if ($this->themeExist('getLongFooter')) {
256
+            $footer = $this->theme->getLongFooter();
257
+        } else {
258
+            $footer = $this->getShortFooter();
259
+        }
260 260
 
261
-		return $footer;
262
-	}
261
+        return $footer;
262
+    }
263 263
 
264
-	/**
265
-	 * @param string $key
266
-	 */
267
-	public function buildDocLinkToKey($key) {
268
-		if ($this->themeExist('buildDocLinkToKey')) {
269
-			return $this->theme->buildDocLinkToKey($key);
270
-		}
271
-		return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
272
-	}
264
+    /**
265
+     * @param string $key
266
+     */
267
+    public function buildDocLinkToKey($key) {
268
+        if ($this->themeExist('buildDocLinkToKey')) {
269
+            return $this->theme->buildDocLinkToKey($key);
270
+        }
271
+        return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
272
+    }
273 273
 
274
-	/**
275
-	 * Returns primary color
276
-	 * @return string
277
-	 */
278
-	public function getColorPrimary() {
274
+    /**
275
+     * Returns primary color
276
+     * @return string
277
+     */
278
+    public function getColorPrimary() {
279 279
 
280
-		if ($this->themeExist('getColorPrimary')) {
281
-			return $this->theme->getColorPrimary();
282
-		}
283
-		if ($this->themeExist('getMailHeaderColor')) {
284
-			return $this->theme->getMailHeaderColor();
285
-		}
286
-		return $this->defaultColorPrimary;
287
-	}
280
+        if ($this->themeExist('getColorPrimary')) {
281
+            return $this->theme->getColorPrimary();
282
+        }
283
+        if ($this->themeExist('getMailHeaderColor')) {
284
+            return $this->theme->getMailHeaderColor();
285
+        }
286
+        return $this->defaultColorPrimary;
287
+    }
288 288
 
289
-	public function shouldReplaceIcons() {
290
-		return false;
291
-	}
289
+    public function shouldReplaceIcons() {
290
+        return false;
291
+    }
292 292
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		$this->defaultLogoClaim = '';
66 66
 		$this->defaultColorPrimary = '#0082c9';
67 67
 
68
-		$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
68
+		$themePath = OC::$SERVERROOT.'/themes/'.OC_Util::getTheme().'/defaults.php';
69 69
 		if (file_exists($themePath)) {
70 70
 			// prevent defaults.php from printing output
71 71
 			ob_start();
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
 		if ($this->themeExist('getShortFooter')) {
240 240
 			$footer = $this->theme->getShortFooter();
241 241
 		} else {
242
-			$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
243
-				' rel="noreferrer">' .$this->getEntity() . '</a>'.
244
-				' – ' . $this->getSlogan();
242
+			$footer = '<a href="'.$this->getBaseUrl().'" target="_blank"'.
243
+				' rel="noreferrer">'.$this->getEntity().'</a>'.
244
+				' – '.$this->getSlogan();
245 245
 		}
246 246
 
247 247
 		return $footer;
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		if ($this->themeExist('buildDocLinkToKey')) {
269 269
 			return $this->theme->buildDocLinkToKey($key);
270 270
 		}
271
-		return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
271
+		return $this->getDocBaseUrl().'/server/'.$this->defaultDocVersion.'/go.php?to='.$key;
272 272
 	}
273 273
 
274 274
 	/**
Please login to merge, or discard this patch.