Passed
Push — master ( 22a9c5...0b7449 )
by Joas
12:22 queued 12s
created
lib/public/Files/StorageBadConfigException.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,16 +27,16 @@
 block discarded – undo
27 27
  */
28 28
 class StorageBadConfigException extends StorageNotAvailableException {
29 29
 
30
-	/**
31
-	 * ExtStorageBadConfigException constructor.
32
-	 *
33
-	 * @param string $message
34
-	 * @param \Exception|null $previous
35
-	 * @since 9.0.0
36
-	 */
37
-	public function __construct($message = '', \Exception $previous = null) {
38
-		$l = \OC::$server->getL10N('core');
39
-		parent::__construct($l->t('Storage incomplete configuration. %s', [$message]), self::STATUS_INCOMPLETE_CONF, $previous);
40
-	}
30
+    /**
31
+     * ExtStorageBadConfigException constructor.
32
+     *
33
+     * @param string $message
34
+     * @param \Exception|null $previous
35
+     * @since 9.0.0
36
+     */
37
+    public function __construct($message = '', \Exception $previous = null) {
38
+        $l = \OC::$server->getL10N('core');
39
+        parent::__construct($l->t('Storage incomplete configuration. %s', [$message]), self::STATUS_INCOMPLETE_CONF, $previous);
40
+    }
41 41
 
42 42
 }
Please login to merge, or discard this patch.
lib/public/Files/ForbiddenException.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -32,25 +32,25 @@
 block discarded – undo
32 32
  */
33 33
 class ForbiddenException extends \Exception {
34 34
 
35
-	/** @var bool */
36
-	private $retry;
35
+    /** @var bool */
36
+    private $retry;
37 37
 
38
-	/**
39
-	 * @param string $message
40
-	 * @param bool $retry
41
-	 * @param \Exception|null $previous previous exception for cascading
42
-	 * @since 9.0.0
43
-	 */
44
-	public function __construct($message, $retry, \Exception $previous = null) {
45
-		parent::__construct($message, 0, $previous);
46
-		$this->retry = $retry;
47
-	}
38
+    /**
39
+     * @param string $message
40
+     * @param bool $retry
41
+     * @param \Exception|null $previous previous exception for cascading
42
+     * @since 9.0.0
43
+     */
44
+    public function __construct($message, $retry, \Exception $previous = null) {
45
+        parent::__construct($message, 0, $previous);
46
+        $this->retry = $retry;
47
+    }
48 48
 
49
-	/**
50
-	 * @return bool
51
-	 * @since 9.0.0
52
-	 */
53
-	public function getRetry() {
54
-		return (bool) $this->retry;
55
-	}
49
+    /**
50
+     * @return bool
51
+     * @since 9.0.0
52
+     */
53
+    public function getRetry() {
54
+        return (bool) $this->retry;
55
+    }
56 56
 }
Please login to merge, or discard this patch.
lib/public/Files/StorageTimeoutException.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,15 +27,15 @@
 block discarded – undo
27 27
  */
28 28
 class StorageTimeoutException extends StorageNotAvailableException {
29 29
 
30
-	/**
31
-	 * StorageTimeoutException constructor.
32
-	 *
33
-	 * @param string $message
34
-	 * @param \Exception|null $previous
35
-	 * @since 9.0.0
36
-	 */
37
-	public function __construct($message = '', \Exception $previous = null) {
38
-		$l = \OC::$server->getL10N('core');
39
-		parent::__construct($l->t('Storage connection timeout. %s', [$message]), self::STATUS_TIMEOUT, $previous);
40
-	}
30
+    /**
31
+     * StorageTimeoutException constructor.
32
+     *
33
+     * @param string $message
34
+     * @param \Exception|null $previous
35
+     * @since 9.0.0
36
+     */
37
+    public function __construct($message = '', \Exception $previous = null) {
38
+        $l = \OC::$server->getL10N('core');
39
+        parent::__construct($l->t('Storage connection timeout. %s', [$message]), self::STATUS_TIMEOUT, $previous);
40
+    }
41 41
 }
Please login to merge, or discard this patch.
lib/public/Files/StorageConnectionException.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,15 +27,15 @@
 block discarded – undo
27 27
  */
28 28
 class StorageConnectionException extends StorageNotAvailableException {
29 29
 
30
-	/**
31
-	 * StorageConnectionException constructor.
32
-	 *
33
-	 * @param string $message
34
-	 * @param \Exception|null $previous
35
-	 * @since 9.0.0
36
-	 */
37
-	public function __construct($message = '', \Exception $previous = null) {
38
-		$l = \OC::$server->getL10N('core');
39
-		parent::__construct($l->t('Storage connection error. %s', [$message]), self::STATUS_NETWORK_ERROR, $previous);
40
-	}
30
+    /**
31
+     * StorageConnectionException constructor.
32
+     *
33
+     * @param string $message
34
+     * @param \Exception|null $previous
35
+     * @since 9.0.0
36
+     */
37
+    public function __construct($message = '', \Exception $previous = null) {
38
+        $l = \OC::$server->getL10N('core');
39
+        parent::__construct($l->t('Storage connection error. %s', [$message]), self::STATUS_NETWORK_ERROR, $previous);
40
+    }
41 41
 }
Please login to merge, or discard this patch.
core/Controller/ContactsMenuController.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -33,46 +33,46 @@
 block discarded – undo
33 33
 
34 34
 class ContactsMenuController extends Controller {
35 35
 
36
-	/** @var Manager */
37
-	private $manager;
36
+    /** @var Manager */
37
+    private $manager;
38 38
 
39
-	/** @var IUserSession */
40
-	private $userSession;
39
+    /** @var IUserSession */
40
+    private $userSession;
41 41
 
42
-	/**
43
-	 * @param IRequest $request
44
-	 * @param IUserSession $userSession
45
-	 * @param Manager $manager
46
-	 */
47
-	public function __construct(IRequest $request, IUserSession $userSession, Manager $manager) {
48
-		parent::__construct('core', $request);
49
-		$this->userSession = $userSession;
50
-		$this->manager = $manager;
51
-	}
42
+    /**
43
+     * @param IRequest $request
44
+     * @param IUserSession $userSession
45
+     * @param Manager $manager
46
+     */
47
+    public function __construct(IRequest $request, IUserSession $userSession, Manager $manager) {
48
+        parent::__construct('core', $request);
49
+        $this->userSession = $userSession;
50
+        $this->manager = $manager;
51
+    }
52 52
 
53
-	/**
54
-	 * @NoAdminRequired
55
-	 *
56
-	 * @param string|null filter
57
-	 * @return \JsonSerializable[]
58
-	 */
59
-	public function index($filter = null) {
60
-		return $this->manager->getEntries($this->userSession->getUser(), $filter);
61
-	}
53
+    /**
54
+     * @NoAdminRequired
55
+     *
56
+     * @param string|null filter
57
+     * @return \JsonSerializable[]
58
+     */
59
+    public function index($filter = null) {
60
+        return $this->manager->getEntries($this->userSession->getUser(), $filter);
61
+    }
62 62
 
63
-	/**
64
-	 * @NoAdminRequired
65
-	 *
66
-	 * @param integer $shareType
67
-	 * @param string $shareWith
68
-	 * @return JSONResponse|\JsonSerializable
69
-	 */
70
-	public function findOne($shareType, $shareWith) {
71
-		$contact = $this->manager->findOne($this->userSession->getUser(), $shareType, $shareWith);
63
+    /**
64
+     * @NoAdminRequired
65
+     *
66
+     * @param integer $shareType
67
+     * @param string $shareWith
68
+     * @return JSONResponse|\JsonSerializable
69
+     */
70
+    public function findOne($shareType, $shareWith) {
71
+        $contact = $this->manager->findOne($this->userSession->getUser(), $shareType, $shareWith);
72 72
 
73
-		if ($contact) {
74
-			return $contact;
75
-		}
76
-		return new JSONResponse([], Http::STATUS_NOT_FOUND);
77
-	}
73
+        if ($contact) {
74
+            return $contact;
75
+        }
76
+        return new JSONResponse([], Http::STATUS_NOT_FOUND);
77
+    }
78 78
 }
Please login to merge, or discard this patch.
files_external/lib/Lib/InsufficientDataForMeaningfulAnswerException.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@
 block discarded – undo
29 29
  * Authentication mechanism or backend has insufficient data
30 30
  */
31 31
 class InsufficientDataForMeaningfulAnswerException extends StorageNotAvailableException {
32
-	/**
33
-	 * StorageNotAvailableException constructor.
34
-	 *
35
-	 * @param string $message
36
-	 * @param int $code
37
-	 * @param \Exception|null $previous
38
-	 * @since 6.0.0
39
-	 */
40
-	public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) {
41
-		parent::__construct($message, $code, $previous);
42
-	}
32
+    /**
33
+     * StorageNotAvailableException constructor.
34
+     *
35
+     * @param string $message
36
+     * @param int $code
37
+     * @param \Exception|null $previous
38
+     * @since 6.0.0
39
+     */
40
+    public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) {
41
+        parent::__construct($message, $code, $previous);
42
+    }
43 43
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/IdentifierTrait.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -28,76 +28,76 @@
 block discarded – undo
28 28
  */
29 29
 trait IdentifierTrait {
30 30
 
31
-	/** @var string */
32
-	protected $identifier;
31
+    /** @var string */
32
+    protected $identifier;
33 33
 
34
-	/** @var string[] */
35
-	protected $identifierAliases = [];
34
+    /** @var string[] */
35
+    protected $identifierAliases = [];
36 36
 
37
-	/** @var IdentifierTrait */
38
-	protected $deprecateTo = null;
37
+    /** @var IdentifierTrait */
38
+    protected $deprecateTo = null;
39 39
 
40
-	/**
41
-	 * @return string
42
-	 */
43
-	public function getIdentifier() {
44
-		return $this->identifier;
45
-	}
40
+    /**
41
+     * @return string
42
+     */
43
+    public function getIdentifier() {
44
+        return $this->identifier;
45
+    }
46 46
 
47
-	/**
48
-	 * @param string $identifier
49
-	 * @return $this
50
-	 */
51
-	public function setIdentifier($identifier) {
52
-		$this->identifier = $identifier;
53
-		$this->identifierAliases[] = $identifier;
54
-		return $this;
55
-	}
47
+    /**
48
+     * @param string $identifier
49
+     * @return $this
50
+     */
51
+    public function setIdentifier($identifier) {
52
+        $this->identifier = $identifier;
53
+        $this->identifierAliases[] = $identifier;
54
+        return $this;
55
+    }
56 56
 
57
-	/**
58
-	 * @return string[]
59
-	 */
60
-	public function getIdentifierAliases() {
61
-		return $this->identifierAliases;
62
-	}
57
+    /**
58
+     * @return string[]
59
+     */
60
+    public function getIdentifierAliases() {
61
+        return $this->identifierAliases;
62
+    }
63 63
 
64
-	/**
65
-	 * @param string $alias
66
-	 * @return $this
67
-	 */
68
-	public function addIdentifierAlias($alias) {
69
-		$this->identifierAliases[] = $alias;
70
-		return $this;
71
-	}
64
+    /**
65
+     * @param string $alias
66
+     * @return $this
67
+     */
68
+    public function addIdentifierAlias($alias) {
69
+        $this->identifierAliases[] = $alias;
70
+        return $this;
71
+    }
72 72
 
73
-	/**
74
-	 * @return object|null
75
-	 */
76
-	public function getDeprecateTo() {
77
-		return $this->deprecateTo;
78
-	}
73
+    /**
74
+     * @return object|null
75
+     */
76
+    public function getDeprecateTo() {
77
+        return $this->deprecateTo;
78
+    }
79 79
 
80
-	/**
81
-	 * @param object $destinationObject
82
-	 * @return self
83
-	 */
84
-	public function deprecateTo($destinationObject) {
85
-		$this->deprecateTo = $destinationObject;
86
-		return $this;
87
-	}
80
+    /**
81
+     * @param object $destinationObject
82
+     * @return self
83
+     */
84
+    public function deprecateTo($destinationObject) {
85
+        $this->deprecateTo = $destinationObject;
86
+        return $this;
87
+    }
88 88
 
89
-	/**
90
-	 * @return array
91
-	 */
92
-	public function jsonSerializeIdentifier() {
93
-		$data = [
94
-			'identifier' => $this->identifier,
95
-			'identifierAliases' => $this->identifierAliases,
96
-		];
97
-		if ($this->deprecateTo) {
98
-			$data['deprecateTo'] = $this->deprecateTo->getIdentifier();
99
-		}
100
-		return $data;
101
-	}
89
+    /**
90
+     * @return array
91
+     */
92
+    public function jsonSerializeIdentifier() {
93
+        $data = [
94
+            'identifier' => $this->identifier,
95
+            'identifierAliases' => $this->identifierAliases,
96
+        ];
97
+        if ($this->deprecateTo) {
98
+            $data['deprecateTo'] = $this->deprecateTo->getIdentifier();
99
+        }
100
+        return $data;
101
+    }
102 102
 
103 103
 }
Please login to merge, or discard this patch.
lib/public/Util.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -304,9 +304,9 @@
 block discarded – undo
304 304
 	 */
305 305
 	public static function linkToRemote($service) {
306 306
 		$urlGenerator = \OC::$server->getURLGenerator();
307
-		$remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service;
307
+		$remoteBase = $urlGenerator->linkTo('', 'remote.php').'/'.$service;
308 308
 		return $urlGenerator->getAbsoluteURL(
309
-			$remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '')
309
+			$remoteBase.(($service[strlen($service) - 1] != '/') ? '/' : '')
310 310
 		);
311 311
 	}
312 312
 
Please login to merge, or discard this patch.
Indentation   +542 added lines, -542 removed lines patch added patch discarded remove patch
@@ -55,546 +55,546 @@
 block discarded – undo
55 55
  * @since 4.0.0
56 56
  */
57 57
 class Util {
58
-	/**
59
-	 * @deprecated 14.0.0 use \OCP\ILogger::DEBUG
60
-	 */
61
-	public const DEBUG = 0;
62
-	/**
63
-	 * @deprecated 14.0.0 use \OCP\ILogger::INFO
64
-	 */
65
-	public const INFO = 1;
66
-	/**
67
-	 * @deprecated 14.0.0 use \OCP\ILogger::WARN
68
-	 */
69
-	public const WARN = 2;
70
-	/**
71
-	 * @deprecated 14.0.0 use \OCP\ILogger::ERROR
72
-	 */
73
-	public const ERROR = 3;
74
-	/**
75
-	 * @deprecated 14.0.0 use \OCP\ILogger::FATAL
76
-	 */
77
-	public const FATAL = 4;
78
-
79
-	/** @var \OCP\Share\IManager */
80
-	private static $shareManager;
81
-
82
-	/** @var array */
83
-	private static $scripts = [];
84
-
85
-	/** @var array */
86
-	private static $scriptDeps = [];
87
-
88
-	/** @var array */
89
-	private static $sortedScriptDeps = [];
90
-
91
-	/**
92
-	 * get the current installed version of Nextcloud
93
-	 * @return array
94
-	 * @since 4.0.0
95
-	 */
96
-	public static function getVersion() {
97
-		return \OC_Util::getVersion();
98
-	}
99
-
100
-	/**
101
-	 * @since 17.0.0
102
-	 */
103
-	public static function hasExtendedSupport(): bool {
104
-		try {
105
-			/** @var \OCP\Support\Subscription\IRegistry */
106
-			$subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class);
107
-			return $subscriptionRegistry->delegateHasExtendedSupport();
108
-		} catch (AppFramework\QueryException $e) {
109
-		}
110
-		return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false);
111
-	}
112
-
113
-	/**
114
-	 * Set current update channel
115
-	 * @param string $channel
116
-	 * @since 8.1.0
117
-	 */
118
-	public static function setChannel($channel) {
119
-		\OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel);
120
-	}
121
-
122
-	/**
123
-	 * Get current update channel
124
-	 * @return string
125
-	 * @since 8.1.0
126
-	 */
127
-	public static function getChannel() {
128
-		return \OC_Util::getChannel();
129
-	}
130
-
131
-	/**
132
-	 * write a message in the log
133
-	 * @param string $app
134
-	 * @param string $message
135
-	 * @param int $level
136
-	 * @since 4.0.0
137
-	 * @deprecated 13.0.0 use log of \OCP\ILogger
138
-	 */
139
-	public static function writeLog($app, $message, $level) {
140
-		$context = ['app' => $app];
141
-		\OC::$server->getLogger()->log($level, $message, $context);
142
-	}
143
-
144
-	/**
145
-	 * check if sharing is disabled for the current user
146
-	 *
147
-	 * @return boolean
148
-	 * @since 7.0.0
149
-	 * @deprecated 9.1.0 Use \OC::$server->getShareManager()->sharingDisabledForUser
150
-	 */
151
-	public static function isSharingDisabledForUser() {
152
-		if (self::$shareManager === null) {
153
-			self::$shareManager = \OC::$server->getShareManager();
154
-		}
155
-
156
-		$user = \OC::$server->getUserSession()->getUser();
157
-		if ($user !== null) {
158
-			$user = $user->getUID();
159
-		}
160
-
161
-		return self::$shareManager->sharingDisabledForUser($user);
162
-	}
163
-
164
-	/**
165
-	 * get l10n object
166
-	 * @param string $application
167
-	 * @param string|null $language
168
-	 * @return \OCP\IL10N
169
-	 * @since 6.0.0 - parameter $language was added in 8.0.0
170
-	 */
171
-	public static function getL10N($application, $language = null) {
172
-		return \OC::$server->getL10N($application, $language);
173
-	}
174
-
175
-	/**
176
-	 * add a css file
177
-	 * @param string $application
178
-	 * @param string $file
179
-	 * @since 4.0.0
180
-	 */
181
-	public static function addStyle($application, $file = null) {
182
-		\OC_Util::addStyle($application, $file);
183
-	}
184
-
185
-	/**
186
-	 * add a javascript file
187
-	 *
188
-	 * @param string $application
189
-	 * @param string|null $file
190
-	 * @param string $afterAppId
191
-	 * @since 4.0.0
192
-	 */
193
-	public static function addScript(string $application, string $file = null, string $afterAppId = 'core'): void {
194
-		if (!empty($application)) {
195
-			$path = "$application/js/$file";
196
-		} else {
197
-			$path = "js/$file";
198
-		}
199
-
200
-		// Inject js translations if we load a script for
201
-		// a specific app that is not core, as those js files
202
-		// need separate handling
203
-		if ($application !== 'core'
204
-			&& $file !== null
205
-			&& strpos($file, 'l10n') === false) {
206
-			self::addTranslations($application);
207
-		}
208
-
209
-		// store app in dependency list
210
-		if (!array_key_exists($application, self::$scriptDeps)) {
211
-			self::$scriptDeps[$application] = new AppScriptDependency($application, [$afterAppId]);
212
-		} else {
213
-			self::$scriptDeps[$application]->addDep($afterAppId);
214
-		}
215
-
216
-		self::$scripts[$application][] = $path;
217
-	}
218
-
219
-	/**
220
-	 * Return the list of scripts injected to the page
221
-	 *
222
-	 * @return array
223
-	 * @since 24.0.0
224
-	 */
225
-	public static function getScripts(): array {
226
-		// Sort scriptDeps into sortedScriptDeps
227
-		$scriptSort = \OC::$server->get(AppScriptSort::class);
228
-		$sortedScripts = $scriptSort->sort(self::$scripts, self::$scriptDeps);
229
-
230
-		// Flatten array and remove duplicates
231
-		return $sortedScripts ? array_unique(array_merge(...array_values(($sortedScripts)))) : [];
232
-	}
233
-
234
-	/**
235
-	 * Add a translation JS file
236
-	 * @param string $application application id
237
-	 * @param string $languageCode language code, defaults to the current locale
238
-	 * @since 8.0.0
239
-	 */
240
-	public static function addTranslations($application, $languageCode = null) {
241
-		if (is_null($languageCode)) {
242
-			$languageCode = \OC::$server->getL10NFactory()->findLanguage($application);
243
-		}
244
-		if (!empty($application)) {
245
-			$path = "$application/l10n/$languageCode";
246
-		} else {
247
-			$path = "l10n/$languageCode";
248
-		}
249
-		self::$scripts[$application][] = $path;
250
-	}
251
-
252
-	/**
253
-	 * Add a custom element to the header
254
-	 * If $text is null then the element will be written as empty element.
255
-	 * So use "" to get a closing tag.
256
-	 * @param string $tag tag name of the element
257
-	 * @param array $attributes array of attributes for the element
258
-	 * @param string $text the text content for the element
259
-	 * @since 4.0.0
260
-	 */
261
-	public static function addHeader($tag, $attributes, $text = null) {
262
-		\OC_Util::addHeader($tag, $attributes, $text);
263
-	}
264
-
265
-	/**
266
-	 * Creates an absolute url to the given app and file.
267
-	 * @param string $app app
268
-	 * @param string $file file
269
-	 * @param array $args array with param=>value, will be appended to the returned url
270
-	 * 	The value of $args will be urlencoded
271
-	 * @return string the url
272
-	 * @since 4.0.0 - parameter $args was added in 4.5.0
273
-	 */
274
-	public static function linkToAbsolute($app, $file, $args = []) {
275
-		$urlGenerator = \OC::$server->getURLGenerator();
276
-		return $urlGenerator->getAbsoluteURL(
277
-			$urlGenerator->linkTo($app, $file, $args)
278
-		);
279
-	}
280
-
281
-	/**
282
-	 * Creates an absolute url for remote use.
283
-	 * @param string $service id
284
-	 * @return string the url
285
-	 * @since 4.0.0
286
-	 */
287
-	public static function linkToRemote($service) {
288
-		$urlGenerator = \OC::$server->getURLGenerator();
289
-		$remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service;
290
-		return $urlGenerator->getAbsoluteURL(
291
-			$remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '')
292
-		);
293
-	}
294
-
295
-	/**
296
-	 * Creates an absolute url for public use
297
-	 * @param string $service id
298
-	 * @return string the url
299
-	 * @since 4.5.0
300
-	 * @deprecated 15.0.0 - use OCP\IURLGenerator
301
-	 */
302
-	public static function linkToPublic($service) {
303
-		$urlGenerator = \OC::$server->getURLGenerator();
304
-		if ($service === 'files') {
305
-			return $urlGenerator->getAbsoluteURL('/s');
306
-		}
307
-		return $urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'public.php').'?service='.$service);
308
-	}
309
-
310
-	/**
311
-	 * Returns the server host name without an eventual port number
312
-	 * @return string the server hostname
313
-	 * @since 5.0.0
314
-	 */
315
-	public static function getServerHostName() {
316
-		$host_name = \OC::$server->getRequest()->getServerHost();
317
-		// strip away port number (if existing)
318
-		$colon_pos = strpos($host_name, ':');
319
-		if ($colon_pos != false) {
320
-			$host_name = substr($host_name, 0, $colon_pos);
321
-		}
322
-		return $host_name;
323
-	}
324
-
325
-	/**
326
-	 * Returns the default email address
327
-	 * @param string $user_part the user part of the address
328
-	 * @return string the default email address
329
-	 *
330
-	 * Assembles a default email address (using the server hostname
331
-	 * and the given user part, and returns it
332
-	 * Example: when given lostpassword-noreply as $user_part param,
333
-	 *     and is currently accessed via http(s)://example.com/,
334
-	 *     it would return '[email protected]'
335
-	 *
336
-	 * If the configuration value 'mail_from_address' is set in
337
-	 * config.php, this value will override the $user_part that
338
-	 * is passed to this function
339
-	 * @since 5.0.0
340
-	 */
341
-	public static function getDefaultEmailAddress($user_part) {
342
-		$config = \OC::$server->getConfig();
343
-		$user_part = $config->getSystemValue('mail_from_address', $user_part);
344
-		$host_name = self::getServerHostName();
345
-		$host_name = $config->getSystemValue('mail_domain', $host_name);
346
-		$defaultEmailAddress = $user_part.'@'.$host_name;
347
-
348
-		$mailer = \OC::$server->getMailer();
349
-		if ($mailer->validateMailAddress($defaultEmailAddress)) {
350
-			return $defaultEmailAddress;
351
-		}
352
-
353
-		// in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain'
354
-		return $user_part.'@localhost.localdomain';
355
-	}
356
-
357
-	/**
358
-	 * Make a human file size (2048 to 2 kB)
359
-	 * @param int $bytes file size in bytes
360
-	 * @return string a human readable file size
361
-	 * @since 4.0.0
362
-	 */
363
-	public static function humanFileSize($bytes) {
364
-		return \OC_Helper::humanFileSize($bytes);
365
-	}
366
-
367
-	/**
368
-	 * Make a computer file size (2 kB to 2048)
369
-	 * @param string $str file size in a fancy format
370
-	 * @return float a file size in bytes
371
-	 *
372
-	 * Inspired by: https://www.php.net/manual/en/function.filesize.php#92418
373
-	 * @since 4.0.0
374
-	 */
375
-	public static function computerFileSize($str) {
376
-		return \OC_Helper::computerFileSize($str);
377
-	}
378
-
379
-	/**
380
-	 * connects a function to a hook
381
-	 *
382
-	 * @param string $signalClass class name of emitter
383
-	 * @param string $signalName name of signal
384
-	 * @param string|object $slotClass class name of slot
385
-	 * @param string $slotName name of slot
386
-	 * @return bool
387
-	 *
388
-	 * This function makes it very easy to connect to use hooks.
389
-	 *
390
-	 * TODO: write example
391
-	 * @since 4.0.0
392
-	 * @deprecated 21.0.0 use \OCP\EventDispatcher\IEventDispatcher::addListener
393
-	 */
394
-	public static function connectHook($signalClass, $signalName, $slotClass, $slotName) {
395
-		return \OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName);
396
-	}
397
-
398
-	/**
399
-	 * Emits a signal. To get data from the slot use references!
400
-	 * @param string $signalclass class name of emitter
401
-	 * @param string $signalname name of signal
402
-	 * @param array $params default: array() array with additional data
403
-	 * @return bool true if slots exists or false if not
404
-	 *
405
-	 * TODO: write example
406
-	 * @since 4.0.0
407
-	 * @deprecated 21.0.0 use \OCP\EventDispatcher\IEventDispatcher::dispatchTypedEvent
408
-	 */
409
-	public static function emitHook($signalclass, $signalname, $params = []) {
410
-		return \OC_Hook::emit($signalclass, $signalname, $params);
411
-	}
412
-
413
-	/**
414
-	 * Cached encrypted CSRF token. Some static unit-tests of ownCloud compare
415
-	 * multiple OC_Template elements which invoke `callRegister`. If the value
416
-	 * would not be cached these unit-tests would fail.
417
-	 * @var string
418
-	 */
419
-	private static $token = '';
420
-
421
-	/**
422
-	 * Register an get/post call. This is important to prevent CSRF attacks
423
-	 * @since 4.5.0
424
-	 */
425
-	public static function callRegister() {
426
-		if (self::$token === '') {
427
-			self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue();
428
-		}
429
-		return self::$token;
430
-	}
431
-
432
-	/**
433
-	 * Used to sanitize HTML
434
-	 *
435
-	 * This function is used to sanitize HTML and should be applied on any
436
-	 * string or array of strings before displaying it on a web page.
437
-	 *
438
-	 * @param string|string[] $value
439
-	 * @return string|string[] an array of sanitized strings or a single sanitized string, depends on the input parameter.
440
-	 * @since 4.5.0
441
-	 */
442
-	public static function sanitizeHTML($value) {
443
-		return \OC_Util::sanitizeHTML($value);
444
-	}
445
-
446
-	/**
447
-	 * Public function to encode url parameters
448
-	 *
449
-	 * This function is used to encode path to file before output.
450
-	 * Encoding is done according to RFC 3986 with one exception:
451
-	 * Character '/' is preserved as is.
452
-	 *
453
-	 * @param string $component part of URI to encode
454
-	 * @return string
455
-	 * @since 6.0.0
456
-	 */
457
-	public static function encodePath($component) {
458
-		return \OC_Util::encodePath($component);
459
-	}
460
-
461
-	/**
462
-	 * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
463
-	 *
464
-	 * @param array $input The array to work on
465
-	 * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
466
-	 * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
467
-	 * @return array
468
-	 * @since 4.5.0
469
-	 */
470
-	public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') {
471
-		return \OC_Helper::mb_array_change_key_case($input, $case, $encoding);
472
-	}
473
-
474
-	/**
475
-	 * performs a search in a nested array
476
-	 *
477
-	 * @param array $haystack the array to be searched
478
-	 * @param string $needle the search string
479
-	 * @param mixed $index optional, only search this key name
480
-	 * @return mixed the key of the matching field, otherwise false
481
-	 * @since 4.5.0
482
-	 * @deprecated 15.0.0
483
-	 */
484
-	public static function recursiveArraySearch($haystack, $needle, $index = null) {
485
-		return \OC_Helper::recursiveArraySearch($haystack, $needle, $index);
486
-	}
487
-
488
-	/**
489
-	 * calculates the maximum upload size respecting system settings, free space and user quota
490
-	 *
491
-	 * @param string $dir the current folder where the user currently operates
492
-	 * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly
493
-	 * @return int number of bytes representing
494
-	 * @since 5.0.0
495
-	 */
496
-	public static function maxUploadFilesize($dir, $free = null) {
497
-		return \OC_Helper::maxUploadFilesize($dir, $free);
498
-	}
499
-
500
-	/**
501
-	 * Calculate free space left within user quota
502
-	 * @param string $dir the current folder where the user currently operates
503
-	 * @return int number of bytes representing
504
-	 * @since 7.0.0
505
-	 */
506
-	public static function freeSpace($dir) {
507
-		return \OC_Helper::freeSpace($dir);
508
-	}
509
-
510
-	/**
511
-	 * Calculate PHP upload limit
512
-	 *
513
-	 * @return int number of bytes representing
514
-	 * @since 7.0.0
515
-	 */
516
-	public static function uploadLimit() {
517
-		return \OC_Helper::uploadLimit();
518
-	}
519
-
520
-	/**
521
-	 * Returns whether the given file name is valid
522
-	 * @param string $file file name to check
523
-	 * @return bool true if the file name is valid, false otherwise
524
-	 * @deprecated 8.1.0 use \OC\Files\View::verifyPath()
525
-	 * @since 7.0.0
526
-	 * @suppress PhanDeprecatedFunction
527
-	 */
528
-	public static function isValidFileName($file) {
529
-		return \OC_Util::isValidFileName($file);
530
-	}
531
-
532
-	/**
533
-	 * Compare two strings to provide a natural sort
534
-	 * @param string $a first string to compare
535
-	 * @param string $b second string to compare
536
-	 * @return int -1 if $b comes before $a, 1 if $a comes before $b
537
-	 * or 0 if the strings are identical
538
-	 * @since 7.0.0
539
-	 */
540
-	public static function naturalSortCompare($a, $b) {
541
-		return \OC\NaturalSort::getInstance()->compare($a, $b);
542
-	}
543
-
544
-	/**
545
-	 * check if a password is required for each public link
546
-	 * @return boolean
547
-	 * @since 7.0.0
548
-	 */
549
-	public static function isPublicLinkPasswordRequired() {
550
-		return \OC_Util::isPublicLinkPasswordRequired();
551
-	}
552
-
553
-	/**
554
-	 * check if share API enforces a default expire date
555
-	 * @return boolean
556
-	 * @since 8.0.0
557
-	 */
558
-	public static function isDefaultExpireDateEnforced() {
559
-		return \OC_Util::isDefaultExpireDateEnforced();
560
-	}
561
-
562
-	protected static $needUpgradeCache = null;
563
-
564
-	/**
565
-	 * Checks whether the current version needs upgrade.
566
-	 *
567
-	 * @return bool true if upgrade is needed, false otherwise
568
-	 * @since 7.0.0
569
-	 */
570
-	public static function needUpgrade() {
571
-		if (!isset(self::$needUpgradeCache)) {
572
-			self::$needUpgradeCache = \OC_Util::needUpgrade(\OC::$server->getSystemConfig());
573
-		}
574
-		return self::$needUpgradeCache;
575
-	}
576
-
577
-	/**
578
-	 * Sometimes a string has to be shortened to fit within a certain maximum
579
-	 * data length in bytes. substr() you may break multibyte characters,
580
-	 * because it operates on single byte level. mb_substr() operates on
581
-	 * characters, so does not ensure that the shortend string satisfies the
582
-	 * max length in bytes.
583
-	 *
584
-	 * For example, json_encode is messing with multibyte characters a lot,
585
-	 * replacing them with something along "\u1234".
586
-	 *
587
-	 * This function shortens the string with by $accurancy (-5) from
588
-	 * $dataLength characters, until it fits within $dataLength bytes.
589
-	 *
590
-	 * @since 23.0.0
591
-	 */
592
-	public static function shortenMultibyteString(string $subject, int $dataLength, int $accuracy = 5): string {
593
-		$temp = mb_substr($subject, 0, $dataLength);
594
-		// json encodes encapsulates the string in double quotes, they need to be substracted
595
-		while ((strlen(json_encode($temp)) - 2) > $dataLength) {
596
-			$temp = mb_substr($temp, 0, -$accuracy);
597
-		}
598
-		return $temp;
599
-	}
58
+    /**
59
+     * @deprecated 14.0.0 use \OCP\ILogger::DEBUG
60
+     */
61
+    public const DEBUG = 0;
62
+    /**
63
+     * @deprecated 14.0.0 use \OCP\ILogger::INFO
64
+     */
65
+    public const INFO = 1;
66
+    /**
67
+     * @deprecated 14.0.0 use \OCP\ILogger::WARN
68
+     */
69
+    public const WARN = 2;
70
+    /**
71
+     * @deprecated 14.0.0 use \OCP\ILogger::ERROR
72
+     */
73
+    public const ERROR = 3;
74
+    /**
75
+     * @deprecated 14.0.0 use \OCP\ILogger::FATAL
76
+     */
77
+    public const FATAL = 4;
78
+
79
+    /** @var \OCP\Share\IManager */
80
+    private static $shareManager;
81
+
82
+    /** @var array */
83
+    private static $scripts = [];
84
+
85
+    /** @var array */
86
+    private static $scriptDeps = [];
87
+
88
+    /** @var array */
89
+    private static $sortedScriptDeps = [];
90
+
91
+    /**
92
+     * get the current installed version of Nextcloud
93
+     * @return array
94
+     * @since 4.0.0
95
+     */
96
+    public static function getVersion() {
97
+        return \OC_Util::getVersion();
98
+    }
99
+
100
+    /**
101
+     * @since 17.0.0
102
+     */
103
+    public static function hasExtendedSupport(): bool {
104
+        try {
105
+            /** @var \OCP\Support\Subscription\IRegistry */
106
+            $subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class);
107
+            return $subscriptionRegistry->delegateHasExtendedSupport();
108
+        } catch (AppFramework\QueryException $e) {
109
+        }
110
+        return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false);
111
+    }
112
+
113
+    /**
114
+     * Set current update channel
115
+     * @param string $channel
116
+     * @since 8.1.0
117
+     */
118
+    public static function setChannel($channel) {
119
+        \OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel);
120
+    }
121
+
122
+    /**
123
+     * Get current update channel
124
+     * @return string
125
+     * @since 8.1.0
126
+     */
127
+    public static function getChannel() {
128
+        return \OC_Util::getChannel();
129
+    }
130
+
131
+    /**
132
+     * write a message in the log
133
+     * @param string $app
134
+     * @param string $message
135
+     * @param int $level
136
+     * @since 4.0.0
137
+     * @deprecated 13.0.0 use log of \OCP\ILogger
138
+     */
139
+    public static function writeLog($app, $message, $level) {
140
+        $context = ['app' => $app];
141
+        \OC::$server->getLogger()->log($level, $message, $context);
142
+    }
143
+
144
+    /**
145
+     * check if sharing is disabled for the current user
146
+     *
147
+     * @return boolean
148
+     * @since 7.0.0
149
+     * @deprecated 9.1.0 Use \OC::$server->getShareManager()->sharingDisabledForUser
150
+     */
151
+    public static function isSharingDisabledForUser() {
152
+        if (self::$shareManager === null) {
153
+            self::$shareManager = \OC::$server->getShareManager();
154
+        }
155
+
156
+        $user = \OC::$server->getUserSession()->getUser();
157
+        if ($user !== null) {
158
+            $user = $user->getUID();
159
+        }
160
+
161
+        return self::$shareManager->sharingDisabledForUser($user);
162
+    }
163
+
164
+    /**
165
+     * get l10n object
166
+     * @param string $application
167
+     * @param string|null $language
168
+     * @return \OCP\IL10N
169
+     * @since 6.0.0 - parameter $language was added in 8.0.0
170
+     */
171
+    public static function getL10N($application, $language = null) {
172
+        return \OC::$server->getL10N($application, $language);
173
+    }
174
+
175
+    /**
176
+     * add a css file
177
+     * @param string $application
178
+     * @param string $file
179
+     * @since 4.0.0
180
+     */
181
+    public static function addStyle($application, $file = null) {
182
+        \OC_Util::addStyle($application, $file);
183
+    }
184
+
185
+    /**
186
+     * add a javascript file
187
+     *
188
+     * @param string $application
189
+     * @param string|null $file
190
+     * @param string $afterAppId
191
+     * @since 4.0.0
192
+     */
193
+    public static function addScript(string $application, string $file = null, string $afterAppId = 'core'): void {
194
+        if (!empty($application)) {
195
+            $path = "$application/js/$file";
196
+        } else {
197
+            $path = "js/$file";
198
+        }
199
+
200
+        // Inject js translations if we load a script for
201
+        // a specific app that is not core, as those js files
202
+        // need separate handling
203
+        if ($application !== 'core'
204
+            && $file !== null
205
+            && strpos($file, 'l10n') === false) {
206
+            self::addTranslations($application);
207
+        }
208
+
209
+        // store app in dependency list
210
+        if (!array_key_exists($application, self::$scriptDeps)) {
211
+            self::$scriptDeps[$application] = new AppScriptDependency($application, [$afterAppId]);
212
+        } else {
213
+            self::$scriptDeps[$application]->addDep($afterAppId);
214
+        }
215
+
216
+        self::$scripts[$application][] = $path;
217
+    }
218
+
219
+    /**
220
+     * Return the list of scripts injected to the page
221
+     *
222
+     * @return array
223
+     * @since 24.0.0
224
+     */
225
+    public static function getScripts(): array {
226
+        // Sort scriptDeps into sortedScriptDeps
227
+        $scriptSort = \OC::$server->get(AppScriptSort::class);
228
+        $sortedScripts = $scriptSort->sort(self::$scripts, self::$scriptDeps);
229
+
230
+        // Flatten array and remove duplicates
231
+        return $sortedScripts ? array_unique(array_merge(...array_values(($sortedScripts)))) : [];
232
+    }
233
+
234
+    /**
235
+     * Add a translation JS file
236
+     * @param string $application application id
237
+     * @param string $languageCode language code, defaults to the current locale
238
+     * @since 8.0.0
239
+     */
240
+    public static function addTranslations($application, $languageCode = null) {
241
+        if (is_null($languageCode)) {
242
+            $languageCode = \OC::$server->getL10NFactory()->findLanguage($application);
243
+        }
244
+        if (!empty($application)) {
245
+            $path = "$application/l10n/$languageCode";
246
+        } else {
247
+            $path = "l10n/$languageCode";
248
+        }
249
+        self::$scripts[$application][] = $path;
250
+    }
251
+
252
+    /**
253
+     * Add a custom element to the header
254
+     * If $text is null then the element will be written as empty element.
255
+     * So use "" to get a closing tag.
256
+     * @param string $tag tag name of the element
257
+     * @param array $attributes array of attributes for the element
258
+     * @param string $text the text content for the element
259
+     * @since 4.0.0
260
+     */
261
+    public static function addHeader($tag, $attributes, $text = null) {
262
+        \OC_Util::addHeader($tag, $attributes, $text);
263
+    }
264
+
265
+    /**
266
+     * Creates an absolute url to the given app and file.
267
+     * @param string $app app
268
+     * @param string $file file
269
+     * @param array $args array with param=>value, will be appended to the returned url
270
+     * 	The value of $args will be urlencoded
271
+     * @return string the url
272
+     * @since 4.0.0 - parameter $args was added in 4.5.0
273
+     */
274
+    public static function linkToAbsolute($app, $file, $args = []) {
275
+        $urlGenerator = \OC::$server->getURLGenerator();
276
+        return $urlGenerator->getAbsoluteURL(
277
+            $urlGenerator->linkTo($app, $file, $args)
278
+        );
279
+    }
280
+
281
+    /**
282
+     * Creates an absolute url for remote use.
283
+     * @param string $service id
284
+     * @return string the url
285
+     * @since 4.0.0
286
+     */
287
+    public static function linkToRemote($service) {
288
+        $urlGenerator = \OC::$server->getURLGenerator();
289
+        $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service;
290
+        return $urlGenerator->getAbsoluteURL(
291
+            $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '')
292
+        );
293
+    }
294
+
295
+    /**
296
+     * Creates an absolute url for public use
297
+     * @param string $service id
298
+     * @return string the url
299
+     * @since 4.5.0
300
+     * @deprecated 15.0.0 - use OCP\IURLGenerator
301
+     */
302
+    public static function linkToPublic($service) {
303
+        $urlGenerator = \OC::$server->getURLGenerator();
304
+        if ($service === 'files') {
305
+            return $urlGenerator->getAbsoluteURL('/s');
306
+        }
307
+        return $urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'public.php').'?service='.$service);
308
+    }
309
+
310
+    /**
311
+     * Returns the server host name without an eventual port number
312
+     * @return string the server hostname
313
+     * @since 5.0.0
314
+     */
315
+    public static function getServerHostName() {
316
+        $host_name = \OC::$server->getRequest()->getServerHost();
317
+        // strip away port number (if existing)
318
+        $colon_pos = strpos($host_name, ':');
319
+        if ($colon_pos != false) {
320
+            $host_name = substr($host_name, 0, $colon_pos);
321
+        }
322
+        return $host_name;
323
+    }
324
+
325
+    /**
326
+     * Returns the default email address
327
+     * @param string $user_part the user part of the address
328
+     * @return string the default email address
329
+     *
330
+     * Assembles a default email address (using the server hostname
331
+     * and the given user part, and returns it
332
+     * Example: when given lostpassword-noreply as $user_part param,
333
+     *     and is currently accessed via http(s)://example.com/,
334
+     *     it would return '[email protected]'
335
+     *
336
+     * If the configuration value 'mail_from_address' is set in
337
+     * config.php, this value will override the $user_part that
338
+     * is passed to this function
339
+     * @since 5.0.0
340
+     */
341
+    public static function getDefaultEmailAddress($user_part) {
342
+        $config = \OC::$server->getConfig();
343
+        $user_part = $config->getSystemValue('mail_from_address', $user_part);
344
+        $host_name = self::getServerHostName();
345
+        $host_name = $config->getSystemValue('mail_domain', $host_name);
346
+        $defaultEmailAddress = $user_part.'@'.$host_name;
347
+
348
+        $mailer = \OC::$server->getMailer();
349
+        if ($mailer->validateMailAddress($defaultEmailAddress)) {
350
+            return $defaultEmailAddress;
351
+        }
352
+
353
+        // in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain'
354
+        return $user_part.'@localhost.localdomain';
355
+    }
356
+
357
+    /**
358
+     * Make a human file size (2048 to 2 kB)
359
+     * @param int $bytes file size in bytes
360
+     * @return string a human readable file size
361
+     * @since 4.0.0
362
+     */
363
+    public static function humanFileSize($bytes) {
364
+        return \OC_Helper::humanFileSize($bytes);
365
+    }
366
+
367
+    /**
368
+     * Make a computer file size (2 kB to 2048)
369
+     * @param string $str file size in a fancy format
370
+     * @return float a file size in bytes
371
+     *
372
+     * Inspired by: https://www.php.net/manual/en/function.filesize.php#92418
373
+     * @since 4.0.0
374
+     */
375
+    public static function computerFileSize($str) {
376
+        return \OC_Helper::computerFileSize($str);
377
+    }
378
+
379
+    /**
380
+     * connects a function to a hook
381
+     *
382
+     * @param string $signalClass class name of emitter
383
+     * @param string $signalName name of signal
384
+     * @param string|object $slotClass class name of slot
385
+     * @param string $slotName name of slot
386
+     * @return bool
387
+     *
388
+     * This function makes it very easy to connect to use hooks.
389
+     *
390
+     * TODO: write example
391
+     * @since 4.0.0
392
+     * @deprecated 21.0.0 use \OCP\EventDispatcher\IEventDispatcher::addListener
393
+     */
394
+    public static function connectHook($signalClass, $signalName, $slotClass, $slotName) {
395
+        return \OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName);
396
+    }
397
+
398
+    /**
399
+     * Emits a signal. To get data from the slot use references!
400
+     * @param string $signalclass class name of emitter
401
+     * @param string $signalname name of signal
402
+     * @param array $params default: array() array with additional data
403
+     * @return bool true if slots exists or false if not
404
+     *
405
+     * TODO: write example
406
+     * @since 4.0.0
407
+     * @deprecated 21.0.0 use \OCP\EventDispatcher\IEventDispatcher::dispatchTypedEvent
408
+     */
409
+    public static function emitHook($signalclass, $signalname, $params = []) {
410
+        return \OC_Hook::emit($signalclass, $signalname, $params);
411
+    }
412
+
413
+    /**
414
+     * Cached encrypted CSRF token. Some static unit-tests of ownCloud compare
415
+     * multiple OC_Template elements which invoke `callRegister`. If the value
416
+     * would not be cached these unit-tests would fail.
417
+     * @var string
418
+     */
419
+    private static $token = '';
420
+
421
+    /**
422
+     * Register an get/post call. This is important to prevent CSRF attacks
423
+     * @since 4.5.0
424
+     */
425
+    public static function callRegister() {
426
+        if (self::$token === '') {
427
+            self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue();
428
+        }
429
+        return self::$token;
430
+    }
431
+
432
+    /**
433
+     * Used to sanitize HTML
434
+     *
435
+     * This function is used to sanitize HTML and should be applied on any
436
+     * string or array of strings before displaying it on a web page.
437
+     *
438
+     * @param string|string[] $value
439
+     * @return string|string[] an array of sanitized strings or a single sanitized string, depends on the input parameter.
440
+     * @since 4.5.0
441
+     */
442
+    public static function sanitizeHTML($value) {
443
+        return \OC_Util::sanitizeHTML($value);
444
+    }
445
+
446
+    /**
447
+     * Public function to encode url parameters
448
+     *
449
+     * This function is used to encode path to file before output.
450
+     * Encoding is done according to RFC 3986 with one exception:
451
+     * Character '/' is preserved as is.
452
+     *
453
+     * @param string $component part of URI to encode
454
+     * @return string
455
+     * @since 6.0.0
456
+     */
457
+    public static function encodePath($component) {
458
+        return \OC_Util::encodePath($component);
459
+    }
460
+
461
+    /**
462
+     * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
463
+     *
464
+     * @param array $input The array to work on
465
+     * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
466
+     * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
467
+     * @return array
468
+     * @since 4.5.0
469
+     */
470
+    public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') {
471
+        return \OC_Helper::mb_array_change_key_case($input, $case, $encoding);
472
+    }
473
+
474
+    /**
475
+     * performs a search in a nested array
476
+     *
477
+     * @param array $haystack the array to be searched
478
+     * @param string $needle the search string
479
+     * @param mixed $index optional, only search this key name
480
+     * @return mixed the key of the matching field, otherwise false
481
+     * @since 4.5.0
482
+     * @deprecated 15.0.0
483
+     */
484
+    public static function recursiveArraySearch($haystack, $needle, $index = null) {
485
+        return \OC_Helper::recursiveArraySearch($haystack, $needle, $index);
486
+    }
487
+
488
+    /**
489
+     * calculates the maximum upload size respecting system settings, free space and user quota
490
+     *
491
+     * @param string $dir the current folder where the user currently operates
492
+     * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly
493
+     * @return int number of bytes representing
494
+     * @since 5.0.0
495
+     */
496
+    public static function maxUploadFilesize($dir, $free = null) {
497
+        return \OC_Helper::maxUploadFilesize($dir, $free);
498
+    }
499
+
500
+    /**
501
+     * Calculate free space left within user quota
502
+     * @param string $dir the current folder where the user currently operates
503
+     * @return int number of bytes representing
504
+     * @since 7.0.0
505
+     */
506
+    public static function freeSpace($dir) {
507
+        return \OC_Helper::freeSpace($dir);
508
+    }
509
+
510
+    /**
511
+     * Calculate PHP upload limit
512
+     *
513
+     * @return int number of bytes representing
514
+     * @since 7.0.0
515
+     */
516
+    public static function uploadLimit() {
517
+        return \OC_Helper::uploadLimit();
518
+    }
519
+
520
+    /**
521
+     * Returns whether the given file name is valid
522
+     * @param string $file file name to check
523
+     * @return bool true if the file name is valid, false otherwise
524
+     * @deprecated 8.1.0 use \OC\Files\View::verifyPath()
525
+     * @since 7.0.0
526
+     * @suppress PhanDeprecatedFunction
527
+     */
528
+    public static function isValidFileName($file) {
529
+        return \OC_Util::isValidFileName($file);
530
+    }
531
+
532
+    /**
533
+     * Compare two strings to provide a natural sort
534
+     * @param string $a first string to compare
535
+     * @param string $b second string to compare
536
+     * @return int -1 if $b comes before $a, 1 if $a comes before $b
537
+     * or 0 if the strings are identical
538
+     * @since 7.0.0
539
+     */
540
+    public static function naturalSortCompare($a, $b) {
541
+        return \OC\NaturalSort::getInstance()->compare($a, $b);
542
+    }
543
+
544
+    /**
545
+     * check if a password is required for each public link
546
+     * @return boolean
547
+     * @since 7.0.0
548
+     */
549
+    public static function isPublicLinkPasswordRequired() {
550
+        return \OC_Util::isPublicLinkPasswordRequired();
551
+    }
552
+
553
+    /**
554
+     * check if share API enforces a default expire date
555
+     * @return boolean
556
+     * @since 8.0.0
557
+     */
558
+    public static function isDefaultExpireDateEnforced() {
559
+        return \OC_Util::isDefaultExpireDateEnforced();
560
+    }
561
+
562
+    protected static $needUpgradeCache = null;
563
+
564
+    /**
565
+     * Checks whether the current version needs upgrade.
566
+     *
567
+     * @return bool true if upgrade is needed, false otherwise
568
+     * @since 7.0.0
569
+     */
570
+    public static function needUpgrade() {
571
+        if (!isset(self::$needUpgradeCache)) {
572
+            self::$needUpgradeCache = \OC_Util::needUpgrade(\OC::$server->getSystemConfig());
573
+        }
574
+        return self::$needUpgradeCache;
575
+    }
576
+
577
+    /**
578
+     * Sometimes a string has to be shortened to fit within a certain maximum
579
+     * data length in bytes. substr() you may break multibyte characters,
580
+     * because it operates on single byte level. mb_substr() operates on
581
+     * characters, so does not ensure that the shortend string satisfies the
582
+     * max length in bytes.
583
+     *
584
+     * For example, json_encode is messing with multibyte characters a lot,
585
+     * replacing them with something along "\u1234".
586
+     *
587
+     * This function shortens the string with by $accurancy (-5) from
588
+     * $dataLength characters, until it fits within $dataLength bytes.
589
+     *
590
+     * @since 23.0.0
591
+     */
592
+    public static function shortenMultibyteString(string $subject, int $dataLength, int $accuracy = 5): string {
593
+        $temp = mb_substr($subject, 0, $dataLength);
594
+        // json encodes encapsulates the string in double quotes, they need to be substracted
595
+        while ((strlen(json_encode($temp)) - 2) > $dataLength) {
596
+            $temp = mb_substr($temp, 0, -$accuracy);
597
+        }
598
+        return $temp;
599
+    }
600 600
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Controller.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		// default responders
80 80
 		$this->responders = [
81
-			'json' => function ($data) {
81
+			'json' => function($data) {
82 82
 				if ($data instanceof DataResponse) {
83 83
 					$response = new JSONResponse(
84 84
 						$data->getData(),
@@ -153,6 +153,6 @@  discard block
 block discarded – undo
153 153
 			return $responder($response);
154 154
 		}
155 155
 		throw new \DomainException('No responder registered for format '.
156
-			$format . '!');
156
+			$format.'!');
157 157
 	}
158 158
 }
Please login to merge, or discard this patch.
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -45,122 +45,122 @@
 block discarded – undo
45 45
  */
46 46
 abstract class Controller {
47 47
 
48
-	/**
49
-	 * app name
50
-	 * @var string
51
-	 * @since 7.0.0
52
-	 */
53
-	protected $appName;
54
-
55
-	/**
56
-	 * current request
57
-	 * @var \OCP\IRequest
58
-	 * @since 6.0.0
59
-	 */
60
-	protected $request;
61
-
62
-	/**
63
-	 * @var array
64
-	 * @since 7.0.0
65
-	 */
66
-	private $responders;
67
-
68
-	/**
69
-	 * constructor of the controller
70
-	 * @param string $appName the name of the app
71
-	 * @param IRequest $request an instance of the request
72
-	 * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0
73
-	 */
74
-	public function __construct($appName,
75
-								IRequest $request) {
76
-		$this->appName = $appName;
77
-		$this->request = $request;
78
-
79
-		// default responders
80
-		$this->responders = [
81
-			'json' => function ($data) {
82
-				if ($data instanceof DataResponse) {
83
-					$response = new JSONResponse(
84
-						$data->getData(),
85
-						$data->getStatus()
86
-					);
87
-					$dataHeaders = $data->getHeaders();
88
-					$headers = $response->getHeaders();
89
-					// do not overwrite Content-Type if it already exists
90
-					if (isset($dataHeaders['Content-Type'])) {
91
-						unset($headers['Content-Type']);
92
-					}
93
-					$response->setHeaders(array_merge($dataHeaders, $headers));
94
-
95
-					if ($data->getETag() !== null) {
96
-						$response->setETag($data->getETag());
97
-					}
98
-					if ($data->getLastModified() !== null) {
99
-						$response->setLastModified($data->getLastModified());
100
-					}
101
-
102
-					return $response;
103
-				}
104
-				return new JSONResponse($data);
105
-			}
106
-		];
107
-	}
108
-
109
-
110
-	/**
111
-	 * Parses an HTTP accept header and returns the supported responder type
112
-	 * @param string $acceptHeader
113
-	 * @param string $default
114
-	 * @return string the responder type
115
-	 * @since 7.0.0
116
-	 * @since 9.1.0 Added default parameter
117
-	 */
118
-	public function getResponderByHTTPHeader($acceptHeader, $default = 'json') {
119
-		$headers = explode(',', $acceptHeader);
120
-
121
-		// return the first matching responder
122
-		foreach ($headers as $header) {
123
-			$header = strtolower(trim($header));
124
-
125
-			$responder = str_replace('application/', '', $header);
126
-
127
-			if (array_key_exists($responder, $this->responders)) {
128
-				return $responder;
129
-			}
130
-		}
131
-
132
-		// no matching header return default
133
-		return $default;
134
-	}
135
-
136
-
137
-	/**
138
-	 * Registers a formatter for a type
139
-	 * @param string $format
140
-	 * @param \Closure $responder
141
-	 * @since 7.0.0
142
-	 */
143
-	protected function registerResponder($format, \Closure $responder) {
144
-		$this->responders[$format] = $responder;
145
-	}
146
-
147
-
148
-	/**
149
-	 * Serializes and formats a response
150
-	 * @param mixed $response the value that was returned from a controller and
151
-	 * is not a Response instance
152
-	 * @param string $format the format for which a formatter has been registered
153
-	 * @throws \DomainException if format does not match a registered formatter
154
-	 * @return Response
155
-	 * @since 7.0.0
156
-	 */
157
-	public function buildResponse($response, $format = 'json') {
158
-		if (array_key_exists($format, $this->responders)) {
159
-			$responder = $this->responders[$format];
160
-
161
-			return $responder($response);
162
-		}
163
-		throw new \DomainException('No responder registered for format '.
164
-			$format . '!');
165
-	}
48
+    /**
49
+     * app name
50
+     * @var string
51
+     * @since 7.0.0
52
+     */
53
+    protected $appName;
54
+
55
+    /**
56
+     * current request
57
+     * @var \OCP\IRequest
58
+     * @since 6.0.0
59
+     */
60
+    protected $request;
61
+
62
+    /**
63
+     * @var array
64
+     * @since 7.0.0
65
+     */
66
+    private $responders;
67
+
68
+    /**
69
+     * constructor of the controller
70
+     * @param string $appName the name of the app
71
+     * @param IRequest $request an instance of the request
72
+     * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0
73
+     */
74
+    public function __construct($appName,
75
+                                IRequest $request) {
76
+        $this->appName = $appName;
77
+        $this->request = $request;
78
+
79
+        // default responders
80
+        $this->responders = [
81
+            'json' => function ($data) {
82
+                if ($data instanceof DataResponse) {
83
+                    $response = new JSONResponse(
84
+                        $data->getData(),
85
+                        $data->getStatus()
86
+                    );
87
+                    $dataHeaders = $data->getHeaders();
88
+                    $headers = $response->getHeaders();
89
+                    // do not overwrite Content-Type if it already exists
90
+                    if (isset($dataHeaders['Content-Type'])) {
91
+                        unset($headers['Content-Type']);
92
+                    }
93
+                    $response->setHeaders(array_merge($dataHeaders, $headers));
94
+
95
+                    if ($data->getETag() !== null) {
96
+                        $response->setETag($data->getETag());
97
+                    }
98
+                    if ($data->getLastModified() !== null) {
99
+                        $response->setLastModified($data->getLastModified());
100
+                    }
101
+
102
+                    return $response;
103
+                }
104
+                return new JSONResponse($data);
105
+            }
106
+        ];
107
+    }
108
+
109
+
110
+    /**
111
+     * Parses an HTTP accept header and returns the supported responder type
112
+     * @param string $acceptHeader
113
+     * @param string $default
114
+     * @return string the responder type
115
+     * @since 7.0.0
116
+     * @since 9.1.0 Added default parameter
117
+     */
118
+    public function getResponderByHTTPHeader($acceptHeader, $default = 'json') {
119
+        $headers = explode(',', $acceptHeader);
120
+
121
+        // return the first matching responder
122
+        foreach ($headers as $header) {
123
+            $header = strtolower(trim($header));
124
+
125
+            $responder = str_replace('application/', '', $header);
126
+
127
+            if (array_key_exists($responder, $this->responders)) {
128
+                return $responder;
129
+            }
130
+        }
131
+
132
+        // no matching header return default
133
+        return $default;
134
+    }
135
+
136
+
137
+    /**
138
+     * Registers a formatter for a type
139
+     * @param string $format
140
+     * @param \Closure $responder
141
+     * @since 7.0.0
142
+     */
143
+    protected function registerResponder($format, \Closure $responder) {
144
+        $this->responders[$format] = $responder;
145
+    }
146
+
147
+
148
+    /**
149
+     * Serializes and formats a response
150
+     * @param mixed $response the value that was returned from a controller and
151
+     * is not a Response instance
152
+     * @param string $format the format for which a formatter has been registered
153
+     * @throws \DomainException if format does not match a registered formatter
154
+     * @return Response
155
+     * @since 7.0.0
156
+     */
157
+    public function buildResponse($response, $format = 'json') {
158
+        if (array_key_exists($format, $this->responders)) {
159
+            $responder = $this->responders[$format];
160
+
161
+            return $responder($response);
162
+        }
163
+        throw new \DomainException('No responder registered for format '.
164
+            $format . '!');
165
+    }
166 166
 }
Please login to merge, or discard this patch.