DefaultData à modifier

This commit is contained in:
fredtempez 2021-05-28 20:09:53 +02:00
parent ae0cb8bc70
commit 47df12b856
3 changed files with 54 additions and 12 deletions

View File

@ -530,7 +530,6 @@ class common {
} else {
$db->set($module,init::$defaultData[$module]);
}
$db->save;
}
@ -1715,6 +1714,25 @@ class common {
}
}
// Externaliser les contenus des pages
// Liste des pages dans pageList
$pageList = array();
// Creation du contenu de la page
if (!is_dir(self::DATA_DIR . self::$i18n . '/content')) {
mkdir(self::DATA_DIR . self::$i18n . '/content');
}
foreach ($this->getHierarchy(null,null,null) as $parentKey=>$parentValue) {
$pageList [] = $parentKey;
foreach ($parentValue as $childKey) {
$pageList [] = $childKey;
}
}
foreach ($pageList as $parentKey => $parent) {
$content = $this->getData(['page', $parent, 'content']);
file_put_contents(self::DATA_DIR . self::$i18n . '/content/' . $parent . '.html', $content);
$this->setData(['page', $parent, 'content', $parent . '.html']);
}
$this->setData(['core', 'dataVersion', 11000]);
}
}
@ -2144,17 +2162,20 @@ class core extends common {
) {
$this->addOutput([
'title' => $title,
'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'])),
'metaDescription' => $this->getData(['page', $this->getUrl(0), 'metaDescription']),
'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']),
'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']),
'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']),
'disable' => $this->getData(['page', $this->getUrl(0), 'disable']),
'contentRight' => $this->getData(['page',$this->getData(['page',$this->getUrl(0),'barRight']),'content']),
'contentLeft' => $this->getData(['page',$this->getData(['page',$this->getUrl(0),'barLeft']),'content']),
'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']))
: '',
'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']))
: '',
]);
}
// Importe le module
else {
// Id du module, et valeurs en sortie de la page si il s'agit d'un module de page
@ -2171,10 +2192,15 @@ class core extends common {
'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']),
'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']),
'disable' => $this->getData(['page', $this->getUrl(0), 'disable']),
'contentRight' => $this->getData(['page',$this->getData(['page',$this->getUrl(0),'barRight']),'content']),
'contentLeft' => $this->getData(['page',$this->getData(['page',$this->getUrl(0),'barLeft']),'content'])
'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']))
: '',
'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']))
: '',
]);
$pageContent = $this->getData(['page', $this->getUrl(0), 'content']);
$pageContent = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $this->getUrl(0), 'content']));
}
else {
$moduleId = $this->getUrl(0);

View File

@ -57,6 +57,7 @@ class page extends common {
'parents' => 'Le menu',
'children' => 'Le sous-menu de la page parente'
];
public static $content = '';
/**
* Duplication
@ -127,7 +128,7 @@ class page extends common {
'typeMenu' => 'text',
'iconUrl' => '',
'disable' => false,
'content' => 'Contenu de votre nouvelle page.',
'content' => $pageId . '.html',
'hideTitle' => false,
'breadCrumb' => false,
'metaDescription' => '',
@ -148,6 +149,11 @@ class page extends common {
'hideMenuChildren' => false
]
]);
// Creation du contenu de la page
if (!is_dir(self::DATA_DIR . self::$i18n . '/content')) {
mkdir(self::DATA_DIR . self::$i18n . '/content');
}
file_put_contents(self::DATA_DIR . self::$i18n . '/content/' . $pageId . '.html', '<p>Contenu de votre nouvelle page.</p>');
// Met à jour le site map
$this->createSitemap('all');
// Valeurs en sortie
@ -267,6 +273,9 @@ class page extends common {
}
// Effacer la page
$this->deleteData(['page', $url[0]]);
if (file_exists(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html')) {
unlink(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html');
}
$this->deleteData(['module', $url[0]]);
// Met à jour le site map
$this->createSitemap('all');
@ -399,7 +408,7 @@ class page extends common {
'typeMenu' => $this->getinput('pageTypeMenu'),
'iconUrl' => $this->getinput('pageIconUrl'),
'disable'=> $this->getinput('pageEditDisable', helper::FILTER_BOOLEAN),
'content' => (empty($this->getInput('pageEditContent', null)) ? '<p>&nbsp;</p>' : $this->getInput('pageEditContent', null)),
'content' => $pageId . '.html',
'hideTitle' => $hideTitle,
'breadCrumb' => $this->getInput('pageEditbreadCrumb', helper::FILTER_BOOLEAN),
'metaDescription' => $this->getInput('pageEditMetaDescription', helper::FILTER_STRING_LONG),
@ -420,6 +429,12 @@ class page extends common {
'hideMenuChildren' => $this->getinput('pageEditHideMenuChildren', helper::FILTER_BOOLEAN)
]
]);
// Creation du contenu de la page
if (!is_dir(self::DATA_DIR . self::$i18n . '/content')) {
mkdir(self::DATA_DIR . self::$i18n . '/content');
}
$content = empty($this->getInput('pageEditContent', null)) ? '<p>&nbsp;</p>' : $this->getInput('pageEditContent', null);
file_put_contents( self::DATA_DIR . self::$i18n . '/content/' . $pageid . '.html' , $content );
// Barre renommée : changement le nom de la barre dans les pages mères
if ($this->getinput('pageEditBlock') === 'bar') {
foreach ($this->getHierarchy() as $eachPageId=>$parentId) {
@ -472,6 +487,8 @@ class page extends common {
self::$pagesBarId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
}
}
// Contenu de la page
self::$content = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $this->getUrl(2), 'content']));
// Valeurs en sortie
$this->addOutput([
'title' => $this->getData(['page', $this->getUrl(2), 'title']),
@ -482,5 +499,4 @@ class page extends common {
]);
}
}
}

View File

@ -96,7 +96,7 @@ echo template::formOpen('pageEditForm');
<div class="col12">
<?php echo template::textarea('pageEditContent', [
'class' => 'editorWysiwyg',
'value' => $this->getData(['page', $this->getUrl(2), 'content'])
'value' => $module::$content
]); ?>
</div>
</div>