fonction de gestion du contenu des pages : getPage

This commit is contained in:
Fred Tempez 2021-08-21 08:44:37 +02:00
parent 9f9817aee0
commit 6f4ebfbbcd
4 changed files with 17 additions and 16 deletions

View File

@ -211,7 +211,7 @@ class common {
// Constructeur JsonDB // Constructeur JsonDB
$this->dataFiles[$keys] = new \Prowebcraft\JsonDb([ $this->dataFiles[$keys] = new \Prowebcraft\JsonDb([
'name' => $keys . '.json', 'name' => $keys . '.json',
'dir' => $this->dataPath ($keys,self::$i18n), 'dir' => $this->dataPath ($keys, self::$i18n),
'backup' => file_exists('site/data/.backup') 'backup' => file_exists('site/data/.backup')
]);; ]);;
} }
@ -234,7 +234,7 @@ class common {
foreach ($this->dataFiles as $stageId => $item) { foreach ($this->dataFiles as $stageId => $item) {
$folder = $this->dataPath ($stageId, self::$i18n); $folder = $this->dataPath ($stageId, self::$i18n);
if (file_exists($folder . $stageId .'.json') === false) { if (file_exists($folder . $stageId .'.json') === false) {
$this->initData($stageId,self::$i18n); $this->initData($stageId, self::$i18n);
common::$coreNotices [] = $stageId ; common::$coreNotices [] = $stageId ;
} }
} }
@ -468,11 +468,12 @@ class common {
/** /**
* Lire les données de la page * Lire les données de la page
* @param string pageId * @param string pageId
* @param string langue
* @param return contenu de la page * @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 pageId
* @param string contenu de la page * @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); file_put_contents(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $page, 'content']), $value);
@ -492,7 +493,7 @@ class common {
* @param string pageId * @param string pageId
* @param return statut de l'effacement * @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'])); return unlink(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $page, 'content']));
@ -2371,7 +2372,7 @@ class core extends common {
$this->addOutput([ $this->addOutput([
'title' => $title, 'title' => $title,
//'content' => file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $this->getUrl(0), 'content'])), //'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']), 'metaDescription' => $this->getData(['page', $this->getUrl(0), 'metaDescription']),
'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']), 'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']),
'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']), 'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']),
@ -2379,11 +2380,11 @@ class core extends common {
'disable' => $this->getData(['page', $this->getUrl(0), 'disable']), 'disable' => $this->getData(['page', $this->getUrl(0), 'disable']),
'contentRight' => $this->getData(['page',$this->getUrl(0),'barRight']) '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'])) //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']) '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'])) //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']) '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'])) //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'])) ? $this->getPage($this->getData(['page',$this->getUrl(0),'barRight']), self::$i18n)
: '', : '',
'contentLeft' => $this->getData(['page',$this->getUrl(0),'barLeft']) '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'])) // ? 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 = 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 { else {
$moduleId = $this->getUrl(0); $moduleId = $this->getUrl(0);

View File

@ -430,7 +430,7 @@ class addon extends common {
$pageParam[$pageId] = $this->getData(['page',$pageId]); $pageParam[$pageId] = $this->getData(['page',$pageId]);
// Export du contenu de la page // Export du contenu de la page
//$pageContent[$pageId] = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $pageId, 'content'])); //$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 // Export de fr/module.json
$moduleId = 'fr/module.json'; $moduleId = 'fr/module.json';
$moduleDir = str_replace('site/data/','',$infoModules[$this->getUrl(2)]['dataDirectory']); $moduleDir = str_replace('site/data/','',$infoModules[$this->getUrl(2)]['dataDirectory']);

View File

@ -97,7 +97,7 @@ echo template::formOpen('pageEditForm');
<?php echo template::textarea('pageEditContent', [ <?php echo template::textarea('pageEditContent', [
'class' => 'editorWysiwyg', 'class' => 'editorWysiwyg',
//'value' => file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $this->getUrl(2), 'content'])) //'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)
]); ?> ]); ?>
</div> </div>
</div> </div>

View File

@ -267,7 +267,7 @@ class search extends common {
$url = $parentId; $url = $parentId;
$titre = $this->getData(['page', $parentId, 'title']); $titre = $this->getData(['page', $parentId, 'title']);
//$content = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $parentId, 'content'])); //$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 ; $contenu = $titre . ' ' . $contenu ;
// Pages sauf pages filles et articles de blog // Pages sauf pages filles et articles de blog
$tempData = $this->occurrence($url, $titre, $contenu, $motclef, self::$motentier); $tempData = $this->occurrence($url, $titre, $contenu, $motclef, self::$motentier);
@ -284,7 +284,7 @@ class search extends common {
$url = $childId; $url = $childId;
$titre = $this->getData(['page', $childId, 'title']); $titre = $this->getData(['page', $childId, 'title']);
//$content = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $childId, 'content'])); //$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 ; $contenu = $titre . ' ' . $contenu ;
//Pages filles //Pages filles
$tempData = $this->occurrence($url, $titre, $contenu, $motclef, self::$motentier); $tempData = $this->occurrence($url, $titre, $contenu, $motclef, self::$motentier);