From f54a8794152fe8abd3675da628e525ee11c68199 Mon Sep 17 00:00:00 2001 From: abrahammordev Date: Fri, 24 Jul 2026 12:13:39 +0200 Subject: [PATCH] fix: Improve wiki title and language for further pdf print --- .../UICore/classes/class.ilGlobalTemplate.php | 17 +++++++++++ .../class.WikiPrintViewProviderGUI.php | 29 ++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/components/ILIAS/UICore/classes/class.ilGlobalTemplate.php b/components/ILIAS/UICore/classes/class.ilGlobalTemplate.php index b218923e4c1c..aeb561bbea12 100755 --- a/components/ILIAS/UICore/classes/class.ilGlobalTemplate.php +++ b/components/ILIAS/UICore/classes/class.ilGlobalTemplate.php @@ -98,6 +98,7 @@ class ilGlobalTemplate implements ilGlobalTemplateInterface protected string $left_content = ''; protected string $right_content = ''; protected string $login_target_par = ''; + protected ?string $content_language = null; /** * @throws ilTemplateException|ilSystemStyleException @@ -854,12 +855,28 @@ public function fillContentLanguage(): void global $DIC; $lng = $DIC->language(); + if ($this->content_language !== null) { + $this->setVariable('META_CONTENT_LANGUAGE', $this->content_language); + $this->setVariable( + 'LANGUAGE_DIRECTION', + in_array($this->content_language, ["ar", "fa", "ur", "he"], true) + ? "rtl" + : "ltr" + ); + return; + } + if (is_object($lng)) { $this->setVariable('META_CONTENT_LANGUAGE', $lng->getContentLanguage()); $this->setVariable('LANGUAGE_DIRECTION', $lng->getTextDirection()); } } + public function setContentLanguage(string $content_language): void + { + $this->content_language = $content_language; + } + public function fillWindowTitle(): void { global $DIC; diff --git a/components/ILIAS/Wiki/PrintView/class.WikiPrintViewProviderGUI.php b/components/ILIAS/Wiki/PrintView/class.WikiPrintViewProviderGUI.php index c2573b3ac3bd..dc627fae5e69 100755 --- a/components/ILIAS/Wiki/PrintView/class.WikiPrintViewProviderGUI.php +++ b/components/ILIAS/Wiki/PrintView/class.WikiPrintViewProviderGUI.php @@ -61,14 +61,41 @@ public function getTemplateInjectors(): array $page ); $resource_injector = new COPage\ResourcesInjector($resource_collector); + $document_title = $this->getDocumentTitle(); + $document_language = $this->getDocumentLanguage(); return [ - function ($tpl) use ($resource_injector) { + function ($tpl) use ($resource_injector, $document_title, $document_language) { + $tpl->setHeaderPageTitle($document_title); + $tpl->setContentLanguage($document_language); $resource_injector->inject($tpl); } ]; } + private function getDocumentTitle(): string + { + if (count($this->selected_pages) !== 1) { + return $this->wiki->getTitle(); + } + + $page_title = \ilWikiPage::lookupTitle($this->selected_pages[0]); + return $page_title === null + ? $this->wiki->getTitle() + : $this->wiki->getTitle() . " - " . $page_title; + } + + private function getDocumentLanguage(): string + { + $language = $this->wiki->getObjectProperties() + ->getPropertyTranslations() + ->getBaseLanguage(); + + return $language !== "" + ? $language + : $this->lng->getContentLanguage(); + } + public function getPages(): array { $print_pages = [];