Installe le profil dans toutes les langues installées

This commit is contained in:
Fred Tempez 2023-07-28 14:43:48 +02:00
parent 6c55881789
commit f67da9bd13
1 changed files with 57 additions and 47 deletions

View File

@ -18,15 +18,15 @@ if ($this->getData(['core', 'dataVersion']) < 10000) {
//---------------------------------------- //----------------------------------------
// Mettre à jour les données des galeries // Mettre à jour les données des galeries
$pageList = array(); $hierarchy = array();
foreach ($this->getHierarchy() as $parentKey => $parentValue) { foreach ($this->getHierarchy() as $parentKey => $parentValue) {
$pageList[] = $parentKey; $hierarchy[] = $parentKey;
foreach ($parentValue as $childKey) { foreach ($parentValue as $childKey) {
$pageList[] = $childKey; $hierarchy[] = $childKey;
} }
} }
// Mise à jour des données pour la galerie v2 // Mise à jour des données pour la galerie v2
foreach ($pageList as $parentKey => $parent) { foreach ($hierarchy as $parentKey => $parent) {
//La page a une galerie //La page a une galerie
if ($this->getData(['page', $parent, 'moduleId']) === 'gallery') { if ($this->getData(['page', $parent, 'moduleId']) === 'gallery') {
// Parcourir les dossiers de la galerie // Parcourir les dossiers de la galerie
@ -179,15 +179,15 @@ if ($this->getData(['core', 'dataVersion']) < 10300) {
$this->setData(['config', 'searchPageId', '']); $this->setData(['config', 'searchPageId', '']);
// Mettre à jour les données des galeries // Mettre à jour les données des galeries
$pageList = array(); foreach ($this->getHierarchy() as $parentKey => $parentValue) { $hierarchy = array(); foreach ($this->getHierarchy() as $parentKey => $parentValue) {
$pageList[] = $parentKey; $hierarchy[] = $parentKey;
foreach ($parentValue as $childKey) { foreach ($parentValue as $childKey) {
$pageList[] = $childKey; $hierarchy[] = $childKey;
} }
} }
// Mise à jour des données de thème de la galerie // Mise à jour des données de thème de la galerie
// Les données de thème sont communes au site // Les données de thème sont communes au site
foreach ($pageList as $parentKey => $parent) { foreach ($hierarchy as $parentKey => $parent) {
//La page a une galerie //La page a une galerie
if ($this->getData(['page', $parent, 'moduleId']) === 'gallery') { if ($this->getData(['page', $parent, 'moduleId']) === 'gallery') {
foreach ($this->getData(['module', $parent]) as $galleryKey => $galleryItem) { foreach ($this->getData(['module', $parent]) as $galleryKey => $galleryItem) {
@ -239,15 +239,15 @@ if ($this->getData(['core', 'dataVersion']) < 10304) {
// Version 10.3.06 // Version 10.3.06
if ($this->getData(['core', 'dataVersion']) < 10306) { if ($this->getData(['core', 'dataVersion']) < 10306) {
// Liste des pages // Liste des pages
$pageList = array(); $hierarchy = array();
foreach ($this->getHierarchy() as $parentKey => $parentValue) { foreach ($this->getHierarchy() as $parentKey => $parentValue) {
$pageList[] = $parentKey; $hierarchy[] = $parentKey;
foreach ($parentValue as $childKey) { foreach ($parentValue as $childKey) {
$pageList[] = $childKey; $hierarchy[] = $childKey;
} }
} }
// Mettre à jour les données des blogs les articles sont dans posts // Mettre à jour les données des blogs les articles sont dans posts
foreach ($pageList as $parentKey => $parent) { foreach ($hierarchy as $parentKey => $parent) {
//La page a un blog //La page a un blog
if ($this->getData(['page', $parent, 'moduleId']) === 'blog') { if ($this->getData(['page', $parent, 'moduleId']) === 'blog') {
if (is_array($this->getData(['module', $parent]))) { if (is_array($this->getData(['module', $parent]))) {
@ -262,7 +262,7 @@ if ($this->getData(['core', 'dataVersion']) < 10306) {
} }
} }
} }
foreach ($pageList as $parentKey => $parent) { foreach ($hierarchy as $parentKey => $parent) {
//La page a une news //La page a une news
if ($this->getData(['page', $parent, 'moduleId']) === 'news') { if ($this->getData(['page', $parent, 'moduleId']) === 'news') {
if (is_array($this->getData(['module', $parent]))) { if (is_array($this->getData(['module', $parent]))) {
@ -297,16 +297,16 @@ if ($this->getData(['core', 'dataVersion']) < 10400) {
// Ajouter les champs de blog v3 // Ajouter les champs de blog v3
// Liste des pages dans pageList // Liste des pages dans pageList
$pageList = array(); $hierarchy = array();
foreach ($this->getHierarchy() as $parentKey => $parentValue) { foreach ($this->getHierarchy() as $parentKey => $parentValue) {
$pageList[] = $parentKey; $hierarchy[] = $parentKey;
foreach ($parentValue as $childKey) { foreach ($parentValue as $childKey) {
$pageList[] = $childKey; $hierarchy[] = $childKey;
} }
} }
// Parcourir pageList et rechercher les modules de blog // Parcourir pageList et rechercher les modules de blog
foreach ($pageList as $parentKey => $parent) { foreach ($hierarchy as $parentKey => $parent) {
//La page est un blog //La page est un blog
if ($this->getData(['page', $parent, 'moduleId']) === 'blog') { if ($this->getData(['page', $parent, 'moduleId']) === 'blog') {
$articleIds = array_keys(helper::arrayColumn($this->getData(['module', $parent, 'posts']), 'publishedOn', 'SORT_DESC')); $articleIds = array_keys(helper::arrayColumn($this->getData(['module', $parent, 'posts']), 'publishedOn', 'SORT_DESC'));
@ -388,15 +388,15 @@ if ($this->getData(['core', 'dataVersion']) < 10600) {
// Mise à jour des données des modules autonomes // Mise à jour des données des modules autonomes
// Liste des pages dans pageList // Liste des pages dans pageList
$pageList = array(); $hierarchy = array();
foreach ($this->getHierarchy() as $parentKey => $parentValue) { foreach ($this->getHierarchy() as $parentKey => $parentValue) {
$pageList[] = $parentKey; $hierarchy[] = $parentKey;
foreach ($parentValue as $childKey) { foreach ($parentValue as $childKey) {
$pageList[] = $childKey; $hierarchy[] = $childKey;
} }
} }
// Parcourir pageList et rechercher les modules au CSS autonomes // Parcourir pageList et rechercher les modules au CSS autonomes
foreach ($pageList as $parentKey => $parent) { foreach ($hierarchy as $parentKey => $parent) {
if ( if (
$this->getData(['page', $parent, 'moduleId']) === 'search' $this->getData(['page', $parent, 'moduleId']) === 'search'
|| $this->getData(['page', $parent, 'moduleId']) === 'gallery' || $this->getData(['page', $parent, 'moduleId']) === 'gallery'
@ -446,18 +446,18 @@ if ($this->getData(['core', 'dataVersion']) < 11000) {
// Externaliser les contenus des pages // Externaliser les contenus des pages
// Liste des pages dans pageList // Liste des pages dans pageList
$pageList = array(); $hierarchy = array();
// Creation du contenu de la page // Creation du contenu de la page
if (!is_dir(self::DATA_DIR . self::$i18nContent . '/content')) { if (!is_dir(self::DATA_DIR . self::$i18nContent . '/content')) {
mkdir(self::DATA_DIR . self::$i18nContent . '/content', 0755); mkdir(self::DATA_DIR . self::$i18nContent . '/content', 0755);
} }
foreach ($this->getHierarchy() as $parentKey => $parentValue) { foreach ($this->getHierarchy() as $parentKey => $parentValue) {
$pageList[] = $parentKey; $hierarchy[] = $parentKey;
foreach ($parentValue as $childKey) { foreach ($parentValue as $childKey) {
$pageList[] = $childKey; $hierarchy[] = $childKey;
} }
} }
foreach ($pageList as $parentKey => $parent) { foreach ($hierarchy as $parentKey => $parent) {
$content = $this->getData(['page', $parent, 'content']); $content = $this->getData(['page', $parent, 'content']);
//file_put_contents(self::DATA_DIR . self::$i18nContent . '/content/' . $parent . '.html', $content); //file_put_contents(self::DATA_DIR . self::$i18nContent . '/content/' . $parent . '.html', $content);
$this->setPage($parent, $content, 'fr'); $this->setPage($parent, $content, 'fr');
@ -510,12 +510,12 @@ if ($this->getData(['core', 'dataVersion']) < 11200) {
// Ajout de la variable shortTitle basée sur Title // Ajout de la variable shortTitle basée sur Title
foreach ($this->getHierarchy() as $parentKey => $parentValue) { foreach ($this->getHierarchy() as $parentKey => $parentValue) {
$pageList[] = $parentKey; $hierarchy[] = $parentKey;
foreach ($parentValue as $childKey) { foreach ($parentValue as $childKey) {
$pageList[] = $childKey; $hierarchy[] = $childKey;
} }
} }
foreach ($pageList as $parentKey => $parent) { foreach ($hierarchy as $parentKey => $parent) {
$this->setData(['page', $parent, 'shortTitle', $this->getData(['page', $parent, 'title'])]); $this->setData(['page', $parent, 'shortTitle', $this->getData(['page', $parent, 'title'])]);
} }
@ -670,12 +670,12 @@ if ($this->getData(['core', 'dataVersion']) < 11303) {
// Ajout de la variable shortTitle basée sur Title // Ajout de la variable shortTitle basée sur Title
foreach ($this->getHierarchy() as $parentKey => $parentValue) { foreach ($this->getHierarchy() as $parentKey => $parentValue) {
$pageList[] = $parentKey; $hierarchy[] = $parentKey;
foreach ($parentValue as $childKey) { foreach ($parentValue as $childKey) {
$pageList[] = $childKey; $hierarchy[] = $childKey;
} }
} }
foreach ($pageList as $parentKey => $parent) { foreach ($hierarchy as $parentKey => $parent) {
$this->setData(['page', $parent, 'extraPosition', false]); $this->setData(['page', $parent, 'extraPosition', false]);
} }
@ -1026,28 +1026,38 @@ if ($this->getData(['core', 'dataVersion']) < 13000) {
} }
} }
//---------------------------------------- // Récupérer la liste de toutes les pages dans toutes langues
// Mettre à jour les données des galeries $hierarchy = array();
$pageList = array(); $languages = array();
foreach ($this->getHierarchy() as $parentKey => $parentValue) { // Tableau des langues non installées
$pageList[] = $parentKey; foreach (self::$languages as $key => $value) {
foreach ($parentValue as $childKey) { if (is_dir(self::DATA_DIR . $key))
$pageList[] = $childKey; $languages[] = $key;
foreach ($this->getHierarchy() as $parentKey => $parentValue) {
$hierarchy[] = $parentKey;
foreach ($parentValue as $childKey) {
$hierarchy[] = $childKey;
}
} }
} }
// Mise à jour des pages, le profil est mis à 0 pour les groupes sans profil et 1 pour es groupes avec profil // Mise à jour des pages, le profil est mis à 0 pour les groupes sans profil et 1 pour es groupes avec profil
foreach ($pageList as $parentKey => $parent) { $currentlanguage = $_SESSION['ZWII_CONTENT'];
switch ($this->getData(['page', $parent, 'group'])) { foreach ($languages as $langId) {
case 1: echo $langId;
case 2: foreach ($hierarchy as $parentKey => $parent) {
$this->setData(['page', $parent, 'profil', 1]); switch ($this->getData(['page', $parent, 'group'])) {
break; case 1:
default: case 2:
$this->setData(['page', $parent, 'profil', 0]); $this->setData(['page', $parent, 'profil', 1]);
break; break;
default:
$this->setData(['page', $parent, 'profil', 0]);
break;
}
} }
} }
$_SESSION['ZWII_CONTENT'] = $currentlanguage ;
// Mise à jour // Mise à jour
$this->setData(['core', 'dataVersion', 13000]); $this->setData(['core', 'dataVersion', 13000]);