From 8645c2a024276c70a96b0ebc3b83480649bd09d7 Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Sun, 31 Mar 2024 07:03:40 +0300 Subject: [PATCH 1/2] fix(ui): Fix to Bug In Web Page Initialization There was a bug which is using the language while it was not loaded in initialization. --- webfiori/framework/ui/WebPage.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/webfiori/framework/ui/WebPage.php b/webfiori/framework/ui/WebPage.php index c4baf81f..a6409d72 100644 --- a/webfiori/framework/ui/WebPage.php +++ b/webfiori/framework/ui/WebPage.php @@ -12,6 +12,7 @@ use Error; use Exception; +use TypeError; use webfiori\collections\LinkedList; use webfiori\framework\App; use webfiori\framework\exceptions\MissingLangException; @@ -790,9 +791,14 @@ public function reset() { $this->setTitleSep(App::getConfig()->getTitleSeparator()); - $langObj = $this->getTranslation(); + try { + $langObj = $this->getTranslation(); + $this->contentDir = $langObj->getWritingDir(); + } catch (TypeError $ex) { + $this->contentDir = 'ltr'; + } - $this->contentDir = $langObj === null ? 'ltr' : $langObj->getWritingDir(); + $this->incFooter = true; $this->incHeader = true; @@ -1313,6 +1319,7 @@ private function usingLanguage() { if (!$this->skipLangCheck) { throw new MissingLangException($ex->getMessage()); } + return; } $pageLang = $this->getTranslation(); From 38b084385251e8b5bfdae2c8ade3ab0219bba046 Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Sun, 31 Mar 2024 07:09:14 +0300 Subject: [PATCH 2/2] fix(ui): Fix to Load Language After Page Initialization --- webfiori/framework/ui/WebPage.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/webfiori/framework/ui/WebPage.php b/webfiori/framework/ui/WebPage.php index a6409d72..87fcf4b3 100644 --- a/webfiori/framework/ui/WebPage.php +++ b/webfiori/framework/ui/WebPage.php @@ -573,6 +573,11 @@ public function getTitleSep() : string { * */ public function getTranslation() : Lang { + + if (!$this->skipLangCheck && $this->tr === null) { + $this->usingLanguage(); + } + return $this->tr; } /**