From 6f4ebfbbcdaf11f1b5ae06cd14395e9036d7420a Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Sat, 21 Aug 2021 08:44:37 +0200 Subject: [PATCH] fonction de gestion du contenu des pages : getPage --- core/core.php | 25 +++++++++++++------------ core/module/addon/addon.php | 2 +- core/module/page/view/edit/edit.php | 2 +- module/search/search.php | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/core/core.php b/core/core.php index 25e48d37..60224418 100755 --- a/core/core.php +++ b/core/core.php @@ -211,7 +211,7 @@ class common { // Constructeur JsonDB $this->dataFiles[$keys] = new \Prowebcraft\JsonDb([ 'name' => $keys . '.json', - 'dir' => $this->dataPath ($keys,self::$i18n), + 'dir' => $this->dataPath ($keys, self::$i18n), 'backup' => file_exists('site/data/.backup') ]);; } @@ -234,7 +234,7 @@ class common { foreach ($this->dataFiles as $stageId => $item) { $folder = $this->dataPath ($stageId, self::$i18n); if (file_exists($folder . $stageId .'.json') === false) { - $this->initData($stageId,self::$i18n); + $this->initData($stageId, self::$i18n); common::$coreNotices [] = $stageId ; } } @@ -468,11 +468,12 @@ class common { /** * Lire les données de la page * @param string pageId + * @param string langue * @param return contenu de la page */ - public function getPage($page) { + public function getPage($page, $lang) { - return file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $page, 'content'])); + return file_get_contents(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $page, 'content'])); } @@ -481,7 +482,7 @@ class common { * @param string pageId * @param string contenu de la page */ - public function setPage($page, $value) { + public function setPage($page, $value, $lang) { file_put_contents(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $page, 'content']), $value); @@ -492,7 +493,7 @@ class common { * @param string pageId * @param return statut de l'effacement */ - public function deletePage($page) { + public function deletePage($page, $lang) { return unlink(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $page, 'content'])); @@ -2371,7 +2372,7 @@ class core extends common { $this->addOutput([ 'title' => $title, //'content' => file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $this->getUrl(0), 'content'])), - 'content' => $this->getPage($this->getUrl(0)), + 'content' => $this->getPage($this->getUrl(0), self::$i18n), 'metaDescription' => $this->getData(['page', $this->getUrl(0), 'metaDescription']), 'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']), 'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']), @@ -2379,11 +2380,11 @@ class core extends common { 'disable' => $this->getData(['page', $this->getUrl(0), 'disable']), 'contentRight' => $this->getData(['page',$this->getUrl(0),'barRight']) //file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $this->getData(['page',$this->getUrl(0),'barRight']), 'content'])) - ? $this->getPage($this->getData(['page',$this->getUrl(0),'barRight'])) + ? $this->getPage($this->getData(['page',$this->getUrl(0),'barRight']), self::$i18n) : '', 'contentLeft' => $this->getData(['page',$this->getUrl(0),'barLeft']) //file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $this->getData(['page',$this->getUrl(0),'barLeft']), 'content'])) - ? $this->getPage($this->getData(['page',$this->getUrl(0),'barLeft'])) + ? $this->getPage($this->getData(['page',$this->getUrl(0),'barLeft']), self::$i18n) : '', ]); } @@ -2406,15 +2407,15 @@ class core extends common { 'contentRight' => $this->getData(['page',$this->getUrl(0),'barRight']) //file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $this->getData(['page',$this->getUrl(0),'barRight']), 'content'])) //? $this->getPage($this->getData(['page',$this->getUrl(0),'barRight'])) - ? $this->getPage($this->getData(['page',$this->getUrl(0),'barRight'])) + ? $this->getPage($this->getData(['page',$this->getUrl(0),'barRight']), self::$i18n) : '', 'contentLeft' => $this->getData(['page',$this->getUrl(0),'barLeft']) // ? file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $this->getData(['page',$this->getUrl(0),'barLeft']), 'content'])) - ? $this->getPage($this->getData(['page',$this->getUrl(0),'barLeft'])) + ? $this->getPage($this->getData(['page',$this->getUrl(0),'barLeft']), self::$i18n) : '', ]); //$pageContent = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $this->getUrl(0), 'content'])); - $pageContent = $this->getPage($this->getUrl(0)); + $pageContent = $this->getPage($this->getUrl(0), self::$i18n); } else { $moduleId = $this->getUrl(0); diff --git a/core/module/addon/addon.php b/core/module/addon/addon.php index 41dbc02c..2b4d22f3 100644 --- a/core/module/addon/addon.php +++ b/core/module/addon/addon.php @@ -430,7 +430,7 @@ class addon extends common { $pageParam[$pageId] = $this->getData(['page',$pageId]); // Export du contenu de la page //$pageContent[$pageId] = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $pageId, 'content'])); - $pageContent[$pageId] = $this->getPage($pageId); + $pageContent[$pageId] = $this->getPage($pageId, self::$i18n); // Export de fr/module.json $moduleId = 'fr/module.json'; $moduleDir = str_replace('site/data/','',$infoModules[$this->getUrl(2)]['dataDirectory']); diff --git a/core/module/page/view/edit/edit.php b/core/module/page/view/edit/edit.php index a9c03355..d3e855f5 100644 --- a/core/module/page/view/edit/edit.php +++ b/core/module/page/view/edit/edit.php @@ -97,7 +97,7 @@ echo template::formOpen('pageEditForm'); 'editorWysiwyg', //'value' => file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $this->getUrl(2), 'content'])) - 'value' => $this->getPage($this->getUrl(2)) + 'value' => $this->getPage($this->getUrl(2), self::$i18n) ]); ?> diff --git a/module/search/search.php b/module/search/search.php index 4162b414..a99eb5d5 100644 --- a/module/search/search.php +++ b/module/search/search.php @@ -267,7 +267,7 @@ class search extends common { $url = $parentId; $titre = $this->getData(['page', $parentId, 'title']); //$content = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $parentId, 'content'])); - $content = $this->getPage($parentId); + $content = $this->getPage($parentId, self::$i18n); $contenu = $titre . ' ' . $contenu ; // Pages sauf pages filles et articles de blog $tempData = $this->occurrence($url, $titre, $contenu, $motclef, self::$motentier); @@ -284,7 +284,7 @@ class search extends common { $url = $childId; $titre = $this->getData(['page', $childId, 'title']); //$content = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $childId, 'content'])); - $content = $this->getPage($childId); + $content = $this->getPage($childId, self::$i18n); $contenu = $titre . ' ' . $contenu ; //Pages filles $tempData = $this->occurrence($url, $titre, $contenu, $motclef, self::$motentier);