diff options
Diffstat (limited to 'lib/public/RichObjectStrings')
-rw-r--r-- | lib/public/RichObjectStrings/Definitions.php | 13 | ||||
-rw-r--r-- | lib/public/RichObjectStrings/IRichTextFormatter.php | 25 | ||||
-rw-r--r-- | lib/public/RichObjectStrings/IValidator.php | 45 | ||||
-rw-r--r-- | lib/public/RichObjectStrings/InvalidObjectExeption.php | 1 |
4 files changed, 82 insertions, 2 deletions
diff --git a/lib/public/RichObjectStrings/Definitions.php b/lib/public/RichObjectStrings/Definitions.php index 7c1935d0a9c..d6717e54aea 100644 --- a/lib/public/RichObjectStrings/Definitions.php +++ b/lib/public/RichObjectStrings/Definitions.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -368,6 +369,18 @@ class Definitions { 'description' => 'The height in pixels if the file is an image', 'example' => '1080', ], + 'blurhash' => [ + 'since' => '30.0.0', + 'required' => false, + 'description' => 'The blurhash of the image', + 'example' => 'LEHV9uae2yk8pyo0adR*.7kCMdnj', + ], + 'hide-download' => [ + 'since' => '31.0.5', + 'required' => false, + 'description' => 'Whether the download option should be hidden. If not set to `yes` the option can be shown', + 'example' => 'yes', + ], ], ], 'forms-form' => [ diff --git a/lib/public/RichObjectStrings/IRichTextFormatter.php b/lib/public/RichObjectStrings/IRichTextFormatter.php new file mode 100644 index 00000000000..1d72f480b07 --- /dev/null +++ b/lib/public/RichObjectStrings/IRichTextFormatter.php @@ -0,0 +1,25 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\RichObjectStrings; + +/** + * Parse rich text and format it with the richobjects + * + * @since 31.0.0 + */ +interface IRichTextFormatter { + /** + * @since 31.0.0 + * @param string $message + * @param array<string,array<string,string>> $parameters + * @throws \InvalidArgumentException if a parameter has no name or no type + */ + public function richToParsed(string $message, array $parameters): string; +} diff --git a/lib/public/RichObjectStrings/IValidator.php b/lib/public/RichObjectStrings/IValidator.php index 96b3b6ea743..fc486663c73 100644 --- a/lib/public/RichObjectStrings/IValidator.php +++ b/lib/public/RichObjectStrings/IValidator.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -8,14 +11,52 @@ namespace OCP\RichObjectStrings; /** * Class Validator * + * @psalm-type RichObjectParameter = array{ + * type: string, + * id: string, + * name: string, + * server?: string, + * link?: string, + * 'call-type'?: 'one2one'|'group'|'public', + * 'icon-url'?: string, + * 'message-id'?: string, + * boardname?: string, + * stackname?: string, + * size?: string, + * path?: string, + * mimetype?: string, + * 'preview-available'?: 'yes'|'no', + * 'hide-download'?: 'yes'|'no', + * mtime?: string, + * latitude?: string, + * longitude?: string, + * description?: string, + * thumb?: string, + * website?: string, + * visibility?: '0'|'1', + * assignable?: '0'|'1', + * conversation?: string, + * etag?: string, + * permissions?: string, + * width?: string, + * height?: string, + * blurhash?: string, + * } + * * @since 11.0.0 */ interface IValidator { /** + * Only alphanumeric, dash, underscore and dot are allowed, starting with a character + * @since 31.0.0 + */ + public const PLACEHOLDER_REGEX = '[A-Za-z][A-Za-z0-9\-_.]+'; + + /** * @param string $subject - * @param array[] $parameters + * @param array<non-empty-string, RichObjectParameter> $parameters * @throws InvalidObjectExeption * @since 11.0.0 */ - public function validate($subject, array $parameters); + public function validate(string $subject, array $parameters): void; } diff --git a/lib/public/RichObjectStrings/InvalidObjectExeption.php b/lib/public/RichObjectStrings/InvalidObjectExeption.php index 0316310c5f9..603f4432ba6 100644 --- a/lib/public/RichObjectStrings/InvalidObjectExeption.php +++ b/lib/public/RichObjectStrings/InvalidObjectExeption.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later |