From ee1134c9e210fdff28009348ea5d06f37ed0a2bd Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Wed, 12 Feb 2025 20:27:59 -0300 Subject: [PATCH] fix: compatibility patch This code exists only at Nextcloud 32 Signed-off-by: Vitor Mattos --- lib/Handler/FooterHandler.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Handler/FooterHandler.php b/lib/Handler/FooterHandler.php index 0b18bdf35..ca866f562 100644 --- a/lib/Handler/FooterHandler.php +++ b/lib/Handler/FooterHandler.php @@ -35,6 +35,14 @@ class FooterHandler { private const MIN_QRCODE_SIZE = 100; private const POINT_TO_MILIMETER = 0.3527777778; private array $templateVars = []; + public const RTL_LANGUAGES = [ + 'ar', // Arabic + 'fa', // Persian + 'he', // Hebrew + 'ps', // Pashto, + 'ug', // 'Uyghurche / Uyghur + 'ur_PK', // Urdu + ]; public function __construct( private IAppConfig $appConfig, @@ -138,7 +146,7 @@ public function setTemplateVar(string $name, mixed $value): self { private function getTemplateVars(): array { $this->templateVars['signedBy'] = $this->appConfig->getValueString(Application::APP_ID, 'footer_signed_by', $this->l10n->t('Digital signed by LibreSign.')); - $this->templateVars['direction'] = $this->l10nFactory->getLanguageDirection($this->l10n->getLanguageCode()); + $this->templateVars['direction'] = $this->getLanguageDirection($this->l10n->getLanguageCode()); $this->templateVars['linkToSite'] = $this->appConfig->getValueString(Application::APP_ID, 'footer_link_to_site', 'https://libresign.coop'); @@ -167,6 +175,14 @@ private function getTemplateVars(): array { return $this->templateVars; } + private function getLanguageDirection(string $language): string { + if (in_array($language, self::RTL_LANGUAGES, true)) { + return 'rtl'; + } + + return 'ltr'; + } + private function getTemplateFile(): string { $footerTemplate = $this->appConfig->getValueString(Application::APP_ID, 'footer_template', ''); if ($footerTemplate) {