From 058e6c4974ebf64c2c7e0cce5d2da6d27b6bf346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tempez?= Date: Mon, 4 Apr 2022 20:05:13 +0200 Subject: [PATCH 1/7] install nettoyage pb de droit ? --- core/module/addon/addon.php | 99 ++----------------------------------- 1 file changed, 4 insertions(+), 95 deletions(-) diff --git a/core/module/addon/addon.php b/core/module/addon/addon.php index 7cb5792d..b436d932 100644 --- a/core/module/addon/addon.php +++ b/core/module/addon/addon.php @@ -93,104 +93,13 @@ class addon extends common { * Fonction utilisée par upload et storeUpload */ private function install ($moduleName, $checkValid){ - $tempFolder = 'datamodules';//uniqid(); $zip = new ZipArchive(); if ($zip->open($moduleName) === TRUE) { - $notification = 'Archive ouverte'; - mkdir (self::TEMP_DIR . $tempFolder, 0755); - $zip->extractTo(self::TEMP_DIR . $tempFolder ); - // Archive de module ? - $success = false; - $notification = 'Ce n\'est pas l\'archive d\'un module !'; - $moduleDir = self::TEMP_DIR . $tempFolder . '/module'; - $moduleName = ''; - if ( is_dir( $moduleDir )) { - // Lire le nom du module - if ($dh = opendir( $moduleDir )) { - while ( false !== ($file = readdir($dh)) ) { - if ($file != "." && $file != "..") { - $moduleName = $file; - } - } - closedir($dh); - } - // Module normalisé ? - if( is_file( $moduleDir.'/'.$moduleName.'/'.$moduleName.'.php' ) AND is_file( $moduleDir.'/'.$moduleName.'/view/index/index.php' ) ){ - - // Lecture de la version et de la validation d'update du module pour validation de la mise à jour - // Pour une version <= version installée l'utilisateur doit cocher 'Mise à jour forcée' - $version = '0.0'; - $update = '0.0'; - $valUpdate = false; - $file = file_get_contents( $moduleDir.'/'.$moduleName.'/'.$moduleName.'.php'); - $file = str_replace(' ','',$file); - $file = str_replace("\t",'',$file); - $pos1 = strpos($file, 'constVERSION'); - if( $pos1 !== false){ - $posdeb = strpos($file, "'", $pos1); - $posend = strpos($file, "'", $posdeb + 1); - $version = substr($file, $posdeb + 1, $posend - $posdeb - 1); - } - $pos1 = strpos($file, 'constUPDATE'); - if( $pos1 !== false){ - $posdeb = strpos($file, "'", $pos1); - $posend = strpos($file, "'", $posdeb + 1); - $update = substr($file, $posdeb + 1, $posend - $posdeb - 1); - } - // Si version actuelle >= version indiquée dans UPDATE la mise à jour est validée - $infoModules = helper::getModules(); - if( $infoModules[$moduleName]['update'] >= $update ) $valUpdate = true; - - // Module déjà installé ? - $moduleInstal = false; - foreach($infoModules as $key=>$value ){ - if($moduleName === $key){ - $moduleInstal = true; - } - } - - // Validation de la maj si autorisation du concepteur du module ET - // ( Version plus récente OU Check de forçage ) - $valNewVersion = floatval($version); - $valInstalVersion = floatval( $infoModules[$moduleName]['version'] ); - $newVersion = false; - if( $valNewVersion > $valInstalVersion ) $newVersion = true; - $validMaj = $valUpdate && ( $newVersion || $checkValid); - - // Nouvelle installation ou mise à jour du module - if( ! $moduleInstal || $validMaj ){ - // Copie récursive des dossiers - $this->copyDir( self::TEMP_DIR . $tempFolder, './' ); - $success = true; - if( ! $moduleInstal ){ - $notification = 'Module '.$moduleName.' installé'; - } - else{ - $notification = 'Module '.$moduleName.' mis à jour'; - } - } - else{ - $success = false; - if( $valNewVersion == $valInstalVersion){ - $notification = ' Version détectée '.$version.' = à celle installée '.$infoModules[$moduleName]['version']; - } - else{ - $notification = ' Version détectée '.$version.' < à celle installée '.$infoModules[$moduleName]['version']; - } - if( $valUpdate === false){ - if( $infoModules[$moduleName]['update'] === $update ){ - $notification = ' Mise à jour par ce procédé interdite par le concepteur du module'; - } - else{ - $notification = ' Mise à jour par ce procédé interdite, votre version est trop ancienne'; - } - } - } - } - } - // Supprimer le dossier temporaire même si le module est invalide - $this->removeDir(self::TEMP_DIR . $tempFolder); + $u = uniqid(); + $zip->extractTo( self::TEMP_DIR . $u ); + $success = $this->copyDir(self::TEMP_DIR . $u, '/'); $zip->close(); + } else { // erreur à l'ouverture $success = false; From 4ab22842316e30c16cf5f0bb86f808c178635ffd Mon Sep 17 00:00:00 2001 From: fredtempez Date: Tue, 5 Apr 2022 11:04:56 +0200 Subject: [PATCH 2/7] Revert "install nettoyage pb de droit ?" This reverts commit 058e6c4974ebf64c2c7e0cce5d2da6d27b6bf346. --- core/module/addon/addon.php | 99 +++++++++++++++++++++++++++++++++++-- 1 file changed, 95 insertions(+), 4 deletions(-) diff --git a/core/module/addon/addon.php b/core/module/addon/addon.php index b436d932..7cb5792d 100644 --- a/core/module/addon/addon.php +++ b/core/module/addon/addon.php @@ -93,13 +93,104 @@ class addon extends common { * Fonction utilisée par upload et storeUpload */ private function install ($moduleName, $checkValid){ + $tempFolder = 'datamodules';//uniqid(); $zip = new ZipArchive(); if ($zip->open($moduleName) === TRUE) { - $u = uniqid(); - $zip->extractTo( self::TEMP_DIR . $u ); - $success = $this->copyDir(self::TEMP_DIR . $u, '/'); - $zip->close(); + $notification = 'Archive ouverte'; + mkdir (self::TEMP_DIR . $tempFolder, 0755); + $zip->extractTo(self::TEMP_DIR . $tempFolder ); + // Archive de module ? + $success = false; + $notification = 'Ce n\'est pas l\'archive d\'un module !'; + $moduleDir = self::TEMP_DIR . $tempFolder . '/module'; + $moduleName = ''; + if ( is_dir( $moduleDir )) { + // Lire le nom du module + if ($dh = opendir( $moduleDir )) { + while ( false !== ($file = readdir($dh)) ) { + if ($file != "." && $file != "..") { + $moduleName = $file; + } + } + closedir($dh); + } + // Module normalisé ? + if( is_file( $moduleDir.'/'.$moduleName.'/'.$moduleName.'.php' ) AND is_file( $moduleDir.'/'.$moduleName.'/view/index/index.php' ) ){ + // Lecture de la version et de la validation d'update du module pour validation de la mise à jour + // Pour une version <= version installée l'utilisateur doit cocher 'Mise à jour forcée' + $version = '0.0'; + $update = '0.0'; + $valUpdate = false; + $file = file_get_contents( $moduleDir.'/'.$moduleName.'/'.$moduleName.'.php'); + $file = str_replace(' ','',$file); + $file = str_replace("\t",'',$file); + $pos1 = strpos($file, 'constVERSION'); + if( $pos1 !== false){ + $posdeb = strpos($file, "'", $pos1); + $posend = strpos($file, "'", $posdeb + 1); + $version = substr($file, $posdeb + 1, $posend - $posdeb - 1); + } + $pos1 = strpos($file, 'constUPDATE'); + if( $pos1 !== false){ + $posdeb = strpos($file, "'", $pos1); + $posend = strpos($file, "'", $posdeb + 1); + $update = substr($file, $posdeb + 1, $posend - $posdeb - 1); + } + // Si version actuelle >= version indiquée dans UPDATE la mise à jour est validée + $infoModules = helper::getModules(); + if( $infoModules[$moduleName]['update'] >= $update ) $valUpdate = true; + + // Module déjà installé ? + $moduleInstal = false; + foreach($infoModules as $key=>$value ){ + if($moduleName === $key){ + $moduleInstal = true; + } + } + + // Validation de la maj si autorisation du concepteur du module ET + // ( Version plus récente OU Check de forçage ) + $valNewVersion = floatval($version); + $valInstalVersion = floatval( $infoModules[$moduleName]['version'] ); + $newVersion = false; + if( $valNewVersion > $valInstalVersion ) $newVersion = true; + $validMaj = $valUpdate && ( $newVersion || $checkValid); + + // Nouvelle installation ou mise à jour du module + if( ! $moduleInstal || $validMaj ){ + // Copie récursive des dossiers + $this->copyDir( self::TEMP_DIR . $tempFolder, './' ); + $success = true; + if( ! $moduleInstal ){ + $notification = 'Module '.$moduleName.' installé'; + } + else{ + $notification = 'Module '.$moduleName.' mis à jour'; + } + } + else{ + $success = false; + if( $valNewVersion == $valInstalVersion){ + $notification = ' Version détectée '.$version.' = à celle installée '.$infoModules[$moduleName]['version']; + } + else{ + $notification = ' Version détectée '.$version.' < à celle installée '.$infoModules[$moduleName]['version']; + } + if( $valUpdate === false){ + if( $infoModules[$moduleName]['update'] === $update ){ + $notification = ' Mise à jour par ce procédé interdite par le concepteur du module'; + } + else{ + $notification = ' Mise à jour par ce procédé interdite, votre version est trop ancienne'; + } + } + } + } + } + // Supprimer le dossier temporaire même si le module est invalide + $this->removeDir(self::TEMP_DIR . $tempFolder); + $zip->close(); } else { // erreur à l'ouverture $success = false; From 81ed0a5cacd405ff3051d8233ae4e808a74deb23 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Tue, 5 Apr 2022 11:10:39 +0200 Subject: [PATCH 3/7] suspension l'option d'installation d'un module --- CHANGES.md | 1 + core/module/addon/view/index/index.help.html | 8 -------- core/module/addon/view/index/index.php | 8 +------- 3 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 core/module/addon/view/index/index.help.html diff --git a/CHANGES.md b/CHANGES.md index 7bbf7bde..93f41a6b 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ - Prise en charge des fontes Web Safe. Les fontes initiales sont transférées dans les fontes optionnelles, donc effaçables. - Toutes les fontes en ligne sont désormais acceptées quel que soit le CDN, Google Fonte (avec preconnect), CDN Fontes ou autre. - Désormais, les URL internes sont relatives, cela signifie qu'elles ne contiendront plus le domaine et le chemin d'accès au site. Cela permettra le déplacement d'un site d'un hébergement à un autre, d'un dossier d'hébergement à un autre, sans avoir à convertir les adresses internes. Les données d'un site mis à jour et importées d'une version antérieures sont automatiquement converties. En conséquence, le bloc de conversion de la fenêtre d'import est supprimé. +- Suppression temporaire de l'option d'installation d'un module, il faudra passer par une connexion FTP pour cela. Cette fonctionnalité a été réécriter dans 11.2 à venir. ### Améliorations : - Configuration de la bannière, modalité d'affichage de la taille d'image recommandée et affichage des dimensions de l'image. - Edition d'une page, le nom court se complète automatiquement. diff --git a/core/module/addon/view/index/index.help.html b/core/module/addon/view/index/index.help.html deleted file mode 100644 index 8af49c96..00000000 --- a/core/module/addon/view/index/index.help.html +++ /dev/null @@ -1,8 +0,0 @@ -

MODULES INSTALLES

-Les modules installés sont listés dans le tableau avec leur nom usuel (alias) et leur numéro de version. -Si le module est utilisé le nom de la page ou des pages apparaît, dans le cas contraire une icône permet de le supprimer. -

EXPORTER IMPORTER

-

Exporter produit une archive au nom du module contenant les pages concernées ainsi que les données et ressources utilisées par le module dans ces pages.

-

Vous pouvez vous en servir comme d'une sauvegarde partielle ou pour transférer les pages et les données du module vers un autre site.

-

Une fois le module installé l'import permet de restaurer les pages et les données sauvegardées. Vous devrez avoir au préalable transféré le fichier zip d'un export sur votre serveur par 'Gérer les fichiers'. -Si une page de même nom existe sur votre site vous serez invité à modifier son nom.

diff --git a/core/module/addon/view/index/index.php b/core/module/addon/view/index/index.php index e1e9c61f..1c4475c1 100644 --- a/core/module/addon/view/index/index.php +++ b/core/module/addon/view/index/index.php @@ -16,18 +16,12 @@ 'class' => 'buttonHelp' ]); ?> -
+
helper::baseUrl() . 'addon/store', 'value' => 'Catalogue en ligne' ]); ?>
-
- helper::baseUrl() . 'addon/upload', - 'value' => 'Installer' - ]); ?> -
From a263ebc2a4fb0ca3e9e4e6929ac06ee6aaa45ea0 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Tue, 5 Apr 2022 11:11:30 +0200 Subject: [PATCH 4/7] sotre renvoie vers addon et non install --- core/module/addon/view/store/store.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/module/addon/view/store/store.php b/core/module/addon/view/store/store.php index e1324a6a..ae029aff 100644 --- a/core/module/addon/view/store/store.php +++ b/core/module/addon/view/store/store.php @@ -2,7 +2,7 @@
'buttonGrey', - 'href' => helper::baseUrl() . 'addon/upload', + 'href' => helper::baseUrl() . 'addon', 'ico' => 'left', 'value' => 'Retour' ]); ?> From c10149eb422ddd39bcb4aef3120c3533d6ce4a66 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Wed, 6 Apr 2022 09:38:58 +0200 Subject: [PATCH 5/7] =?UTF-8?q?Compatibilit=C3=A9=20arrayColumn=20et=20arr?= =?UTF-8?q?ayCollumn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/class/helper.class.php | 8 ++++++++ core/core.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/class/helper.class.php b/core/class/helper.class.php index fc623eab..43bb9a53 100644 --- a/core/class/helper.class.php +++ b/core/class/helper.class.php @@ -104,6 +104,14 @@ class helper { return $newArray; } + /** + * Compatibilité avec les anciens modules + */ + public static function arrayCollumn($array, $column, $sort = null) { + return (helper::arrayColumn($array, $column, $sort)); + } + + /** * Génère un backup des données de site diff --git a/core/core.php b/core/core.php index 86d53c7b..1a5dc92f 100644 --- a/core/core.php +++ b/core/core.php @@ -346,7 +346,7 @@ class common { // Construit la liste des pages parents/enfants if($this->hierarchy['all'] === []) { - $pages = helper::arrayColumn($this->getData(['page']), 'position', 'SORT_ASC'); + $pages = helper::arrayCollumn($this->getData(['page']), 'position', 'SORT_ASC'); // Parents foreach($pages as $pageId => $pagePosition) { if( From 19aa822c8e7389235b0231d052969606825dd5b3 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Wed, 6 Apr 2022 09:46:28 +0200 Subject: [PATCH 6/7] =?UTF-8?q?collum=20devient=20column=20compatibilit?= =?UTF-8?q?=C3=A9=20assur=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/class/helper.class.php | 2 +- core/core.php | 6 +--- core/include/update.inc.php | 2 +- core/module/config/view/locale/locale.php | 12 ++++---- core/module/install/install.php | 2 +- core/module/page/page.php | 2 +- core/module/plugin/plugin.php | 7 ++--- core/module/sitemap/sitemap.php | 8 ++--- core/module/theme/view/footer/footer.php | 4 +-- core/module/user/user.php | 4 +-- module/blog/blog.php | 24 +++++++-------- module/download/download.php | 36 +++++++++++------------ module/form/form.php | 4 +-- module/form/view/config/config.js.php | 2 +- module/gallery/gallery.php | 4 +-- module/news/news.php | 16 +++++----- 16 files changed, 64 insertions(+), 71 deletions(-) diff --git a/core/class/helper.class.php b/core/class/helper.class.php index fc8bb552..e8199c05 100644 --- a/core/class/helper.class.php +++ b/core/class/helper.class.php @@ -86,7 +86,7 @@ class helper { * @param string $sort Type de tri à appliquer au tableau (SORT_ASC, SORT_DESC, ou null) * @return array */ - public static function arraycollumn($array, $column, $sort = null) { + public static function arraycolumn($array, $column, $sort = null) { $newArray = []; if(empty($array) === false) { $newArray = array_map(function($element) use($column) { diff --git a/core/core.php b/core/core.php index e2640a76..58bfcc8f 100644 --- a/core/core.php +++ b/core/core.php @@ -342,11 +342,7 @@ class common { // Construit la liste des pages parents/enfants if($this->hierarchy['all'] === []) { -<<<<<<< HEAD - $pages = helper::arraycollumn($this->getData(['page']), 'position', 'SORT_ASC'); -======= - $pages = helper::arrayCollumn($this->getData(['page']), 'position', 'SORT_ASC'); ->>>>>>> 114_dev + $pages = helper::arrayColumn($this->getData(['page']), 'position', 'SORT_ASC'); // Parents foreach($pages as $pageId => $pagePosition) { if( diff --git a/core/include/update.inc.php b/core/include/update.inc.php index f76b5558..654f0e73 100644 --- a/core/include/update.inc.php +++ b/core/include/update.inc.php @@ -481,7 +481,7 @@ if ($this->getData(['core', 'dataVersion']) < 10400) { foreach ($pageList as $parentKey => $parent) { //La page est un blog if ($this->getData(['page',$parent,'moduleId']) === 'blog' ) { - $articleIds = array_keys(helper::arraycollumn($this->getData(['module', $parent, 'posts']), 'publishedOn', 'SORT_DESC')); + $articleIds = array_keys(helper::arrayColumn($this->getData(['module', $parent, 'posts']), 'publishedOn', 'SORT_DESC')); foreach ($articleIds as $key => $article) { // Droits les deux groupes $this->setData(['module', $parent, 'posts', $article,'editConsent', 3]); diff --git a/core/module/config/view/locale/locale.php b/core/module/config/view/locale/locale.php index 2dc866bc..5e099c1a 100644 --- a/core/module/config/view/locale/locale.php +++ b/core/module/config/view/locale/locale.php @@ -57,21 +57,21 @@
- 'Accueil du site', 'selected' =>$this->getData(['locale', 'homePageId']), 'help' => 'La première page que vos visiteurs verront.' ]); ?>
- 'Page par défaut'],helper::arraycollumn($module::$orphansList, 'title', 'SORT_ASC')), [ + 'Page par défaut'],helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [ 'label' => 'Accès interdit, erreur 403', 'selected' =>$this->getData(['locale', 'page403']), 'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.' ]); ?>
- 'Page par défaut'],helper::arraycollumn($module::$orphansList, 'title', 'SORT_ASC')), [ + 'Page par défaut'],helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [ 'label' => 'Page inexistante, erreur 404', 'selected' =>$this->getData(['locale', 'page404']), 'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.' @@ -80,14 +80,14 @@
- 'Aucune'] , helper::arraycollumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ + 'Aucune'] , helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ 'label' => 'Mentions légales', 'selected' => $this->getData(['locale', 'legalPageId']), 'help' => 'Les mentions légales sont obligatoires en France. Une option du pied de page ajoute un lien discret vers cette page.' ]); ?>
- 'Aucune'] , helper::arraycollumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ + 'Aucune'] , helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ 'label' => 'Recherche dans le site', 'selected' => $this->getData(['locale', 'searchPageId']), 'help' => 'Sélectionnez une page contenant le module \'Recherche\'. Une option du pied de page ajoute un lien discret vers cette page.' @@ -95,7 +95,7 @@
'Page par défaut'],helper::arraycollumn($module::$orphansList, 'title', 'SORT_ASC')), [ + echo template::select('localePage302', array_merge(['none' => 'Page par défaut'],helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [ 'label' => 'Site en maintenance', 'selected' =>$this->getData(['locale', 'page302']), 'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.' diff --git a/core/module/install/install.php b/core/module/install/install.php index ac63212e..afa59bd7 100644 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -153,7 +153,7 @@ class install extends common { // Récupération de la liste des thèmes $dataThemes = file_get_contents('core/module/install/ressource/themes/themes.json'); $dataThemes = json_decode($dataThemes, true); - self::$themes = helper::arraycollumn($dataThemes, 'name'); + self::$themes = helper::arrayColumn($dataThemes, 'name'); // Valeurs en sortie $this->addOutput([ diff --git a/core/module/page/page.php b/core/module/page/page.php index 09753d60..fb09dfe3 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -525,7 +525,7 @@ class page extends common { } } } - self::$moduleIds = array_merge( ['' => 'Aucun'] , helper::arraycollumn(helper::getModules(),'realName','SORT_ASC')); // Pages sans parent + self::$moduleIds = array_merge( ['' => 'Aucun'] , helper::arrayColumn(helper::getModules(),'realName','SORT_ASC')); // Pages sans parent foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) { if($parentPageId !== $this->getUrl(2)) { self::$pagesNoParentId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']); diff --git a/core/module/plugin/plugin.php b/core/module/plugin/plugin.php index 37608af9..553acb81 100644 --- a/core/module/plugin/plugin.php +++ b/core/module/plugin/plugin.php @@ -171,9 +171,6 @@ class plugin extends common { $versionInstalled = $c[$moduleName]['version']; } } - echo $versionInstalled; - - die(); // Si version actuelle >= version indiquée dans UPDATE la mise à jour est validée $infoModules = helper::getModules(); if( $infoModules[$moduleName]['update'] >= $update ) $valUpdate = true; @@ -329,7 +326,7 @@ class plugin extends common { // Modules installés $infoModules = helper::getModules(); // Clés moduleIds dans les pages - $inPages = helper::arraycollumn($this->getData(['page']),'moduleId', 'SORT_DESC'); + $inPages = helper::arrayColumn($this->getData(['page']),'moduleId', 'SORT_DESC'); foreach( $inPages as $key=>$value){ $pagesInfos[ $this->getData(['page', $key, 'title' ]) ] = $value; } @@ -414,7 +411,7 @@ class plugin extends common { $pages = json_decode(file_get_contents(self::DATA_DIR . $keyi18n . '/' . 'page.json'), true); // Extraire les clés des modules - $pagesModules [$keyi18n] = array_filter(helper::arraycollumn($pages['page'],'moduleId', 'SORT_DESC'), 'strlen'); + $pagesModules [$keyi18n] = array_filter(helper::arrayColumn($pages['page'],'moduleId', 'SORT_DESC'), 'strlen'); // Générer ls liste des pages avec module pour la sauvegarde ou le backup foreach( $pagesModules [$keyi18n] as $key=>$value ) { diff --git a/core/module/sitemap/sitemap.php b/core/module/sitemap/sitemap.php index 1ec4d51d..0537f648 100644 --- a/core/module/sitemap/sitemap.php +++ b/core/module/sitemap/sitemap.php @@ -42,8 +42,8 @@ class sitemap extends common !empty($this->getData(['module',$parentId, 'posts' ]))) { $items .= '
    '; // Ids des articles par ordre de publication - $articleIdsPublishedOns = helper::arraycollumn($this->getData(['module', $parentId,'posts']), 'publishedOn', 'SORT_DESC'); - $articleIdsStates = helper::arraycollumn($this->getData(['module', $parentId, 'posts']), 'state', 'SORT_DESC'); + $articleIdsPublishedOns = helper::arrayColumn($this->getData(['module', $parentId,'posts']), 'publishedOn', 'SORT_DESC'); + $articleIdsStates = helper::arrayColumn($this->getData(['module', $parentId, 'posts']), 'state', 'SORT_DESC'); $articleIds = []; foreach ($articleIdsPublishedOns as $articleId => $articlePublishedOn) { if ($articlePublishedOn <= time() and $articleIdsStates[$articleId]) { @@ -78,8 +78,8 @@ class sitemap extends common !empty($this->getData(['module', $childId, 'posts' ]))) { $items .= '
      '; // Ids des articles par ordre de publication - $articleIdsPublishedOns = helper::arraycollumn($this->getData(['module', $childId,'posts']), 'publishedOn', 'SORT_DESC'); - $articleIdsStates = helper::arraycollumn($this->getData(['module', $childId, 'posts']), 'state', 'SORT_DESC'); + $articleIdsPublishedOns = helper::arrayColumn($this->getData(['module', $childId,'posts']), 'publishedOn', 'SORT_DESC'); + $articleIdsStates = helper::arrayColumn($this->getData(['module', $childId, 'posts']), 'state', 'SORT_DESC'); $articleIds = []; foreach ($articleIdsPublishedOns as $articleId => $articlePublishedOn) { if ($articlePublishedOn <= time() and $articleIdsStates[$articleId]) { diff --git a/core/module/theme/view/footer/footer.php b/core/module/theme/view/footer/footer.php index e59b15ec..f5e3af4a 100644 --- a/core/module/theme/view/footer/footer.php +++ b/core/module/theme/view/footer/footer.php @@ -133,7 +133,7 @@ ]); ?>
- 'Aucune'] , helper::arraycollumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ + 'Aucune'] , helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ 'label' => 'Page "Mentions légales" ' . template::flag('site', '20px'), 'selected' => $this->getData(['locale', 'legalPageId']) ]); ?> @@ -147,7 +147,7 @@ ]); ?>
- 'Aucune'] , helper::arraycollumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ + 'Aucune'] , helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ 'label' => 'Page "Rechercher" ' . template::flag('site', '20px'), 'selected' => $this->getData(['locale', 'searchPageId']) ]); ?> diff --git a/core/module/user/user.php b/core/module/user/user.php index 81c6cc7c..c9682de1 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -336,7 +336,7 @@ class user extends common { * Liste des utilisateurs */ public function index() { - $userIdsFirstnames = helper::arraycollumn($this->getData(['user']), 'firstname'); + $userIdsFirstnames = helper::arrayColumn($this->getData(['user']), 'firstname'); ksort($userIdsFirstnames); foreach($userIdsFirstnames as $userId => $userFirstname) { if ($this->getData(['user', $userId, 'group'])) { @@ -399,7 +399,7 @@ class user extends common { ] ]); // Verrouillage des IP - $ipBlackList = helper::arraycollumn($this->getData(['blacklist']), 'ip'); + $ipBlackList = helper::arrayColumn($this->getData(['blacklist']), 'ip'); if ( $this->getData(['blacklist',$userId,'connectFail']) >= $this->getData(['config', 'connect', 'attempt']) AND in_array($this->getData(['blacklist',$userId,'ip']),$ipBlackList) ) { $logStatus = 'Compte inconnu verrouillé'; diff --git a/module/blog/blog.php b/module/blog/blog.php index ec5112b4..54d338d0 100644 --- a/module/blog/blog.php +++ b/module/blog/blog.php @@ -166,8 +166,8 @@ class blog extends common { $feeds->setDate(date('r',time())); $feeds->addGenerator(); // Corps des articles - $articleIdsPublishedOns = helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC'); - $articleIdsStates = helper::arraycollumn($this->getData(['module', $this->getUrl(0),'posts']), 'state', 'SORT_DESC'); + $articleIdsPublishedOns = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC'); + $articleIdsStates = helper::arrayColumn($this->getData(['module', $this->getUrl(0),'posts']), 'state', 'SORT_DESC'); foreach( $articleIdsPublishedOns as $articleId => $articlePublishedOn ) { if( $articlePublishedOn <= time() AND $articleIdsStates[$articleId] ) { // Miniature @@ -256,7 +256,7 @@ class blog extends common { ]); } // Liste des utilisateurs - self::$users = helper::arraycollumn($this->getData(['user']), 'firstname'); + self::$users = helper::arrayColumn($this->getData(['user']), 'firstname'); ksort(self::$users); foreach(self::$users as $userId => &$userFirstname) { $userFirstname = $userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']); @@ -286,7 +286,7 @@ class blog extends common { 'value' => 'Tout effacer' ]); // Ids des commentaires par ordre de création - $commentIds = array_keys(helper::arraycollumn($comments, 'createdOn', 'SORT_DESC')); + $commentIds = array_keys(helper::arrayColumn($comments, 'createdOn', 'SORT_DESC')); // Pagination $pagination = helper::pagination($commentIds, $this->getUrl(),$this->getData(['module', $this->getUrl(0), 'config', 'itemsperPage']) ); // Liste des pages @@ -427,7 +427,7 @@ class blog extends common { public function config() { // Ids des articles par ordre de publication - $articleIds = array_keys(helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC')); + $articleIds = array_keys(helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC')); // Gestion des droits d'accès $filterData=[]; foreach ($articleIds as $key => $value) { @@ -459,7 +459,7 @@ class blog extends common { // Articles en fonction de la pagination for($i = $pagination['first']; $i < $pagination['last']; $i++) { // Nombre de commentaires à approuver et approuvés - $approvals = helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'comment' ]),'approval', 'SORT_DESC'); + $approvals = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'comment' ]),'approval', 'SORT_DESC'); if ( is_array($approvals) ) { $a = array_values($approvals); $toApprove = count(array_keys($a,false)); @@ -528,7 +528,7 @@ class blog extends common { ]); } else { // Ids des articles par ordre de publication - $articleIds = array_keys(helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC')); + $articleIds = array_keys(helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC')); // Gestion des droits d'accès $filterData=[]; foreach ($articleIds as $key => $value) { @@ -560,7 +560,7 @@ class blog extends common { // Articles en fonction de la pagination for($i = $pagination['first']; $i < $pagination['last']; $i++) { // Nombre de commentaires à approuver et approuvés - $approvals = helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'comment' ]),'approval', 'SORT_DESC'); + $approvals = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'comment' ]),'approval', 'SORT_DESC'); if ( is_array($approvals) ) { $a = array_values($approvals); $toApprove = count(array_keys($a,false)); @@ -708,7 +708,7 @@ class blog extends common { ]); } // Liste des utilisateurs - self::$users = helper::arraycollumn($this->getData(['user']), 'firstname'); + self::$users = helper::arrayColumn($this->getData(['user']), 'firstname'); ksort(self::$users); foreach(self::$users as $userId => &$userFirstname) { // Les membres ne sont pas éditeurs, les exclure de la liste @@ -823,7 +823,7 @@ class blog extends common { // Ligne suivante si affichage du nombre total de commentaires approuvés sous l'article self::$nbCommentsApproved = count($commentsApproved); } - $commentIds = array_keys(helper::arraycollumn($commentsApproved, 'createdOn', 'SORT_DESC')); + $commentIds = array_keys(helper::arrayColumn($commentsApproved, 'createdOn', 'SORT_DESC')); // Pagination $pagination = helper::pagination($commentIds, $this->getUrl(), $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage']),'#comment'); // Liste des pages @@ -863,8 +863,8 @@ class blog extends common { // Liste des articles else { // Ids des articles par ordre de publication - $articleIdsPublishedOns = helper::arraycollumn($this->getData(['module', $this->getUrl(0),'posts']), 'publishedOn', 'SORT_DESC'); - $articleIdsStates = helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'state', 'SORT_DESC'); + $articleIdsPublishedOns = helper::arrayColumn($this->getData(['module', $this->getUrl(0),'posts']), 'publishedOn', 'SORT_DESC'); + $articleIdsStates = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts']), 'state', 'SORT_DESC'); $articleIds = []; foreach($articleIdsPublishedOns as $articleId => $articlePublishedOn) { if($articlePublishedOn <= time() AND $articleIdsStates[$articleId]) { diff --git a/module/download/download.php b/module/download/download.php index f615f2b4..4df9dc84 100644 --- a/module/download/download.php +++ b/module/download/download.php @@ -165,8 +165,8 @@ class download extends common { $feeds->setDate(date('r',time())); $feeds->addGenerator(); // Corps des items - $itemIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items']), 'publishedOn', 'SORT_DESC'); - $itemIdsStates = helper::arrayCollumn($this->getData(['module', $this->getUrl(0),'items']), 'state', 'SORT_DESC'); + $itemIdsPublishedOns = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'items']), 'publishedOn', 'SORT_DESC'); + $itemIdsStates = helper::arrayColumn($this->getData(['module', $this->getUrl(0),'items']), 'state', 'SORT_DESC'); foreach($itemIdsPublishedOns as $itemId => $itemPublishedOn) { if($itemPublishedOn <= time() AND $itemIdsStates[$itemId]) { // Miniature @@ -259,7 +259,7 @@ class download extends common { ]); } // Liste des utilisateurs - self::$users = helper::arrayCollumn($this->getData(['user']), 'firstname'); + self::$users = helper::arrayColumn($this->getData(['user']), 'firstname'); ksort(self::$users); foreach(self::$users as $userId => &$userFirstname) { $userFirstname = $userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']); @@ -310,7 +310,7 @@ class download extends common { 'value' => 'Tout effacer' ]); // Ids des commentaires par ordre de création - $commentIds = array_keys(helper::arrayCollumn($comments, 'createdOn', 'SORT_DESC')); + $commentIds = array_keys(helper::arrayColumn($comments, 'createdOn', 'SORT_DESC')); // Pagination $pagination = helper::pagination($commentIds, $this->getUrl(), $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage'])); // Liste des pages @@ -467,7 +467,7 @@ class download extends common { ]); } else { // Ids des items par ordre de publication - $itemIds = array_keys(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items']), 'publishedOn', 'SORT_DESC')); + $itemIds = array_keys(helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'items']), 'publishedOn', 'SORT_DESC')); // Gestion des droits d'accès $filterData=[]; foreach ($itemIds as $key => $value) { @@ -511,7 +511,7 @@ class download extends common { // items en fonction de la pagination for($i = $pagination['first']; $i < $pagination['last']; $i++) { // Nombre de commentaires à approuver et approuvés - $approvals = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'comment' ]),'approval', 'SORT_DESC'); + $approvals = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'comment' ]),'approval', 'SORT_DESC'); if ( is_array($approvals) ) { $a = array_values($approvals); $toApprove = count(array_keys($a,false)); @@ -527,10 +527,10 @@ class download extends common { //$heure = mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'versionDate'])), 'UTF-8', true) // ? strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'versionDate'])) // : utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'versionDate']))); - $stat = count(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i],'stats']), 'time') ) === 0 + $stat = count(helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i],'stats']), 'time') ) === 0 ? '0' : '' . - count(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i],'stats']), 'time') ) . + count(helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i],'stats']), 'time') ) . ''; // Lien toutes les catégories quand le filtre est actif if ($this->getUrl(2)) { @@ -680,7 +680,7 @@ class download extends common { ]); } // Liste des utilisateurs - self::$users = helper::arrayCollumn($this->getData(['user']), 'firstname'); + self::$users = helper::arrayColumn($this->getData(['user']), 'firstname'); ksort(self::$users); foreach(self::$users as $userId => &$userFirstname) { // Les membres ne sont pas éditeurs, les exclure de la liste @@ -799,13 +799,13 @@ class download extends common { // Ligne suivante si affichage du nombre total de commentaires approuvés sous l'item self::$nbCommentsApproved = count($commentsApproved); } - $commentIds = array_keys(helper::arrayCollumn($commentsApproved, 'createdOn', 'SORT_DESC')); + $commentIds = array_keys(helper::arrayColumn($commentsApproved, 'createdOn', 'SORT_DESC')); // Pagination $pagination = helper::pagination($commentIds, $this->getUrl(), $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage']),'#comment'); // Nombre de téléchargements - self::$statSum = count(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items',$this->getUrl(1),'stats']), 'time') ) === 0 + self::$statSum = count(helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'items',$this->getUrl(1),'stats']), 'time') ) === 0 ? '0' - : count(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(1),'stats']), 'time') ) ; + : count(helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(1),'stats']), 'time') ) ; // Liste des pages self::$pages = $pagination['pages']; // Signature de l'item @@ -842,8 +842,8 @@ class download extends common { // Liste des items else { // Ids des items par ordre de publication - $itemIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0),'items']), 'publishedOn', 'SORT_DESC'); - $itemIdsStates = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items']), 'state', 'SORT_DESC'); + $itemIdsPublishedOns = helper::arrayColumn($this->getData(['module', $this->getUrl(0),'items']), 'publishedOn', 'SORT_DESC'); + $itemIdsStates = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'items']), 'state', 'SORT_DESC'); $itemIds = []; foreach($itemIdsPublishedOns as $itemId => $itemPublishedOn) { if($itemPublishedOn <= time() AND $itemIdsStates[$itemId]) { @@ -1025,8 +1025,8 @@ class download extends common { * Retourne une chaîne json contenant la liste des téléchargements disponibles */ public function list() { - $itemIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0),'items']), 'publishedOn', 'SORT_DESC'); - $itemIdsStates = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items']), 'state', 'SORT_DESC'); + $itemIdsPublishedOns = helper::arrayColumn($this->getData(['module', $this->getUrl(0),'items']), 'publishedOn', 'SORT_DESC'); + $itemIdsStates = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'items']), 'state', 'SORT_DESC'); $itemIds = []; foreach($itemIdsPublishedOns as $itemId => $itemPublishedOn) { if($itemPublishedOn <= time() AND $itemIdsStates[$itemId]) { @@ -1157,7 +1157,7 @@ class download extends common { if ($oldItemId !== $itemId) { $i = 0; // Mettre à jour les catégories dans items - $itemIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items']), 'publishedOn', 'SORT_DESC'); + $itemIdsPublishedOns = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'items']), 'publishedOn', 'SORT_DESC'); foreach ($itemIdsPublishedOns as $key => $value) { if ($this->getData(['module', $this->getUrl(0), 'items', $key, 'category']) === $oldItemId) { $this->setData(['module', $this->getUrl(0), 'items', $key, 'category', $itemId]); @@ -1204,7 +1204,7 @@ class download extends common { ]); } else { // Mettre à jour les catégories dans items - $itemIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items']), 'publishedOn', 'SORT_DESC'); + $itemIdsPublishedOns = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'items']), 'publishedOn', 'SORT_DESC'); $success = true; $i = 0; foreach ($itemIdsPublishedOns as $key => $value) { diff --git a/module/form/form.php b/module/form/form.php index cc48dae5..976b1d69 100644 --- a/module/form/form.php +++ b/module/form/form.php @@ -107,7 +107,7 @@ class form extends common { */ public function config() { // Liste des utilisateurs - $userIdsFirstnames = helper::arraycollumn($this->getData(['user']), 'firstname'); + $userIdsFirstnames = helper::arrayColumn($this->getData(['user']), 'firstname'); ksort($userIdsFirstnames); self::$listUsers [] = ''; foreach($userIdsFirstnames as $userId => $userFirstname) { @@ -159,7 +159,7 @@ class form extends common { public function option() { // Liste des utilisateurs - $userIdsFirstnames = helper::arraycollumn($this->getData(['user']), 'firstname'); + $userIdsFirstnames = helper::arrayColumn($this->getData(['user']), 'firstname'); ksort($userIdsFirstnames); self::$listUsers [] = ''; foreach ($userIdsFirstnames as $userId => $userFirstname) { diff --git a/module/form/view/config/config.js.php b/module/form/view/config/config.js.php index dc421ffd..c0873314 100644 --- a/module/form/view/config/config.js.php +++ b/module/form/view/config/config.js.php @@ -78,7 +78,7 @@ function position() { var inputUid = 0; var inputs = getData(['module', $this->getUrl(0), 'input'])); ?>; if(inputs) { - var inputsPerPosition = getData(['module', $this->getUrl(0), 'input']), 'position', 'SORT_ASC')); ?>; + var inputsPerPosition = getData(['module', $this->getUrl(0), 'input']), 'position', 'SORT_ASC')); ?>; $.each(inputsPerPosition, function(id) { add(inputUid, inputs[id]); inputUid++; diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index e68623e4..5548ac45 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -336,7 +336,7 @@ class gallery extends common { //Affichage de la galerie triée $g = $this->getData(['module', $this->getUrl(0), 'content']); - $p = helper::arraycollumn(helper::arraycollumn($g,'config'),'position'); + $p = helper::arrayColumn(helper::arrayColumn($g,'config'),'position'); asort($p,SORT_NUMERIC); $galleries = []; foreach ($p as $positionId => $item) { @@ -760,7 +760,7 @@ class gallery extends common { else { // Tri des galeries suivant l'ordre défini $g = $this->getData(['module', $this->getUrl(0), 'content']); - $p = helper::arraycollumn(helper::arraycollumn($g,'config'),'position'); + $p = helper::arrayColumn(helper::arrayColumn($g,'config'),'position'); asort($p,SORT_NUMERIC); $galleries = []; foreach ($p as $positionId => $item) { diff --git a/module/news/news.php b/module/news/news.php index 32b1e2a8..e9d51626 100644 --- a/module/news/news.php +++ b/module/news/news.php @@ -110,8 +110,8 @@ class news extends common { $feeds->setDate(date('r',time())); $feeds->addGenerator(); // Corps des articles - $newsIdsPublishedOns = helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC'); - $newsIdsStates = helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'state', 'SORT_DESC'); + $newsIdsPublishedOns = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC'); + $newsIdsStates = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts']), 'state', 'SORT_DESC'); foreach($newsIdsPublishedOns as $newsId => $newsPublishedOn) { if($newsPublishedOn <= time() AND $newsIdsStates[$newsId]) { $newsArticle = $feeds->createNewItem(); @@ -162,7 +162,7 @@ class news extends common { ]); } // Liste des utilisateurs - self::$users = helper::arraycollumn($this->getData(['user']), 'firstname'); + self::$users = helper::arrayColumn($this->getData(['user']), 'firstname'); ksort(self::$users); foreach(self::$users as $userId => &$userFirstname) { $userFirstname = $userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']); @@ -188,7 +188,7 @@ class news extends common { $this->update(); // Ids des news par ordre de publication - $newsIds = array_keys(helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC')); + $newsIds = array_keys(helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC')); // Pagination fixe $pagination = helper::pagination($newsIds, $this->getUrl(),self::$itemsperPage ); // Liste des pages @@ -288,7 +288,7 @@ class news extends common { ]); } else { // Ids des news par ordre de publication - $newsIds = array_keys(helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC')); + $newsIds = array_keys(helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC')); // Pagination $pagination = helper::pagination($newsIds, $this->getUrl(),$this->getData(['module', $this->getUrl(0), 'config', 'itemsperPage']) ); // Liste des pages @@ -421,7 +421,7 @@ class news extends common { ]); } // Liste des utilisateurs - self::$users = helper::arraycollumn($this->getData(['user']), 'firstname'); + self::$users = helper::arrayColumn($this->getData(['user']), 'firstname'); ksort(self::$users); foreach(self::$users as $userId => &$userFirstname) { $userFirstname = $userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']); @@ -474,8 +474,8 @@ class news extends common { } else { // Affichage index // Ids des news par ordre de publication - $newsIdsPublishedOns = helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC'); - $newsIdsStates = helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'state', 'SORT_DESC'); + $newsIdsPublishedOns = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC'); + $newsIdsStates = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts']), 'state', 'SORT_DESC'); $newsIds = []; foreach($newsIdsPublishedOns as $newsId => $newsPublishedOn) { $newsIdsPublishedOff = $this->getData(['module', $this->getUrl(0), 'posts', $newsId, 'publishedOff']); From b23d9f8c9b4c263de0e20a8b682cc133d76445fb Mon Sep 17 00:00:00 2001 From: fredtempez Date: Fri, 8 Apr 2022 09:47:35 +0200 Subject: [PATCH 7/7] plugin okay + new copyDir --- core/core.php | 79 +++++--- core/module/plugin/plugin.php | 239 +++++++++++++----------- core/module/plugin/view/index/index.php | 13 +- core/module/plugin/view/store/store.php | 6 - module/version/version.php | 36 ++++ module/version/view/index/index.php | 1 + 6 files changed, 224 insertions(+), 150 deletions(-) create mode 100644 module/version/version.php create mode 100644 module/version/view/index/index.php diff --git a/core/core.php b/core/core.php index 58bfcc8f..e184e4a0 100644 --- a/core/core.php +++ b/core/core.php @@ -35,6 +35,7 @@ class common { const DATA_DIR = 'site/data/'; const FILE_DIR = 'site/file/'; const TEMP_DIR = 'site/tmp/'; + const MODULE_DIR = 'module/'; // Miniatures de la galerie const THUMBS_SEPARATOR = 'mini_'; @@ -180,7 +181,7 @@ class common { ]; public static $fontsWebSafe = [ - 'arial' => [ + 'arial' => [ 'name' => 'Arial', 'font-family' => 'Arial, Helvetica, sans-serif', 'resource' => 'websafe' @@ -1137,30 +1138,52 @@ class common { * @param string $dst dossier destination * @return bool */ - public function copyDir($src, $dst) { - // Ouvrir le dossier source - $dir = opendir($src); - // Créer le dossier de destination - if (!is_dir($dst)) - $success = mkdir($dst, 0755, true); - else - $success = true; + function copyDir( string $sourceDirectory, string $destinationDirectory, string $childFolder = '') { - // Boucler dans le dossier source en l'absence d'échec de lecture écriture - while( $success - AND $file = readdir($dir) ) { - if (( $file != '.' ) && ( $file != '..' )) { - if ( is_dir($src . '/' . $file) ){ - // Appel récursif des sous-dossiers - $success = $success OR $this->copyDir($src . '/' . $file, $dst . '/' . $file); + $success = true; + $directory = opendir($sourceDirectory); + + if (is_dir($destinationDirectory) === false) { + mkdir($destinationDirectory); + } + + if ($childFolder !== '') { + if (is_dir("$destinationDirectory/$childFolder") === false) { + mkdir("$destinationDirectory/$childFolder"); + } + + while (($file = readdir($directory)) !== false) { + if ($file === '.' || $file === '..') { + continue; } - else { - $success = $success OR copy($src . '/' . $file, $dst . '/' . $file); + + if (is_dir("$sourceDirectory/$file") === true) { + $success = $success && $this->copyDir("$sourceDirectory/$file", "$destinationDirectory/$childFolder/$file"); + } else { + $success = $success && copy("$sourceDirectory/$file", "$destinationDirectory/$childFolder/$file"); } } + + closedir($directory); + + return; } - closedir($dir); - return $success; + + while (($file = readdir($directory)) !== false) { + if ($file === '.' || $file === '..') { + continue; + } + + if (is_dir("$sourceDirectory/$file") === true) { + $success = $success && $this->copyDir("$sourceDirectory/$file", "$destinationDirectory/$file"); + } + else { + $success = $success && copy("$sourceDirectory/$file", "$destinationDirectory/$file"); + } + } + + closedir($directory); + return($success); } @@ -2160,9 +2183,9 @@ class common { elseif( $moduleId AND in_array($moduleId, self::$coreModuleIds) === false - AND file_exists('module/' . $moduleId . '/vendor/' . $vendorName . '/inc.json') + AND file_exists(self::MODULE_DIR . $moduleId . '/vendor/' . $vendorName . '/inc.json') ) { - $vendorPath = 'module/' . $moduleId . '/vendor/' . $vendorName . '/'; + $vendorPath = self::MODULE_DIR . $moduleId . '/vendor/' . $vendorName . '/'; } // Sinon continue else { @@ -2660,8 +2683,8 @@ class core extends common { require 'core/module/' . $classPath; } // Module - elseif(is_readable('module/' . $classPath)) { - require 'module/' . $classPath; + elseif(is_readable(self::MODULE_DIR . $classPath)) { + require self::MODULE_DIR . $classPath; } // Librairie elseif(is_readable('core/vendor/' . $classPath)) { @@ -2810,7 +2833,7 @@ class core extends common { 'title' => $title, 'content' => $this->getPage($this->getUrl(0), self::$i18n) . // Concatène avec les paramètres avancés. - $this->getData(['page', $this->getUrl(0), 'css']) . + $this->getData(['page', $this->getUrl(0), 'css']) . $this->getData(['page', $this->getUrl(0), 'js']), 'metaDescription' => $this->getData(['page', $this->getUrl(0), 'metaDescription']), 'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']), @@ -2945,7 +2968,7 @@ class core extends common { // Chemin en fonction d'un module du coeur ou d'un module $modulePath = in_array($moduleId, self::$coreModuleIds) ? 'core/' : ''; // CSS - $stylePath = $modulePath . 'module/' . $moduleId . '/view/' . $output['view'] . '/' . $output['view'] . '.css'; + $stylePath = $modulePath . self::MODULE_DIR . $moduleId . '/view/' . $output['view'] . '/' . $output['view'] . '.css'; if(file_exists($stylePath)) { $this->addOutput([ 'style' => file_get_contents($stylePath) @@ -2958,7 +2981,7 @@ class core extends common { } // JS - $scriptPath = $modulePath . 'module/' . $moduleId . '/view/' . $output['view'] . '/' . $output['view'] . '.js.php'; + $scriptPath = $modulePath . self::MODULE_DIR . $moduleId . '/view/' . $output['view'] . '/' . $output['view'] . '.js.php'; if(file_exists($scriptPath)) { ob_start(); include $scriptPath; @@ -2967,7 +2990,7 @@ class core extends common { ]); } // Vue - $viewPath = $modulePath . 'module/' . $moduleId . '/view/' . $output['view'] . '/' . $output['view'] . '.php'; + $viewPath = $modulePath . self::MODULE_DIR . $moduleId . '/view/' . $output['view'] . '/' . $output['view'] . '.php'; if(file_exists($viewPath)) { ob_start(); include $viewPath; diff --git a/core/module/plugin/plugin.php b/core/module/plugin/plugin.php index 553acb81..510a9f6b 100644 --- a/core/module/plugin/plugin.php +++ b/core/module/plugin/plugin.php @@ -31,7 +31,7 @@ class plugin extends common { // URL des modules const BASEURL_STORE = 'https://store.zwiicms.fr/'; - const MODULE_STORE = '?modules/'; + const MODULE_STORE = 'modules-pour-zwii-v12/'; // Gestion des modules public static $modulesData = []; @@ -100,14 +100,9 @@ class plugin extends common { */ private function install($moduleFileName, $checkValid){ - /** - * Initialisation des variables - */ - //$tempFolder = uniqid() . '/'; - $tempFolder = 'truc/'; - $notification = ''; - // Numéro de version du module déjà installé - $versionInstalled = ''; + // Dossier temporaire + $tempFolder = uniqid() . '/'; + //$tempFolder = 'truc/'; /** * Désarchivage @@ -115,123 +110,143 @@ class plugin extends common { $zip = new ZipArchive(); if ($zip->open($moduleFileName) === TRUE) { - /** - * Création du dossier temporaire - */ + + //Création du dossier temporaire et extraction if (!is_dir (self::TEMP_DIR . $tempFolder) ) { mkdir (self::TEMP_DIR . $tempFolder, 0755); } - $zip->extractTo(self::TEMP_DIR . $tempFolder ); - // Lecture du descripteur de ressource - $modulePath = self::TEMP_DIR . $tempFolder . 'module'; - if (file_exists(self::TEMP_DIR . $tempFolder . 'desc.json') - ) { - $res = json_decode(file_get_contents(self::TEMP_DIR . $tempFolder . 'desc.json'), true); - } else { - return([ - 'success' => false, - 'notification'=> 'Cette archive est invalide' - ]); - } + /** - * Structure lue - * $res ['name'] = id du module, correspond à la classe - * $res ['realname'] = Nom complet du module - * $res ['version'] = version du module - * $res ['dirs'] @array + * Lecture du descripteur de ressource + * $module ['name'] = id du module, correspond à la classe + * $module ['realname'] = Nom complet du module + * $module ['version'] = version du module + * $module ['dirs'] @array * 'dossier' => 'destination', * 'download" => 'module/download' - * - * Attention le dossier source est celui dans l'archive, la destination correspond à l’arborescence cible */ - echo "
";
-			// Affectation
-			$moduleName = $res ['name'];
-			$modulePath = $res ['name'] . '/';
-			$moduleFile = $res ['name'] . '.php' ;
+
+			if (file_exists(self::TEMP_DIR . $tempFolder . 'desc.json')
+				) {
+					$module = json_decode(file_get_contents(self::TEMP_DIR . $tempFolder . 'desc.json'), true);
+				} else {
+					// Message de retour
+					$this->removeDir(self::TEMP_DIR . $tempFolder);
+					$zip->close();
+					return([
+						'success' => false,
+						'notification'=> 'Archive invalide, le descripteur est absent.'
+					]);
+			}
 
 			/**
 			 * Validation des informations du descripteur
 			 */
-			if ( !is_dir ( self::TEMP_DIR . $tempFolder . $modulePath) ||
-				 !is_file (self::TEMP_DIR . $tempFolder . $modulePath . $moduleFile)
-				) {
+			foreach ($module['dirs'] as $src => $dest) {
+				// Vérification de la présence des dossier décrits
+				if ( !is_dir (self::TEMP_DIR . $tempFolder . $src )) {
+					// Message de retour
+					$this->removeDir(self::TEMP_DIR . $tempFolder);
+					$zip->close();
 					return([
 						'success' => false,
-						'notification'=> 'Cette archive est invalide'
+						'notification'=> 'Archive invalide, les dossiers ne correspondent pas au descripteur.'
 					]);
+				}
+				// Interdire l'écriture dans le dossier core
+				if ( strstr($dest, 'core') !== false ) {
+					// Message de retour
+					$this->removeDir(self::TEMP_DIR . $tempFolder);
+					$zip->close();
+					return([
+						'success' => false,
+						'notification'=> 'Archive invalide, l\'écriture dans le dossier core est interdite'
+					]);
+				}
 			}
+
 			/**
-			 * Le module est-il installé ? Lire le numéro de version
+			 * Validation de la présence du fichier de base du module
 			 */
-			if (is_file( 'module/' . $modulePath . $moduleFile) ) {
+			if ( !file_exists(self::TEMP_DIR . $tempFolder . $module['name'] . '/' . $module['name'] . '.php')) {
+				// Message de retour
+				$this->removeDir(self::TEMP_DIR . $tempFolder);
+				$zip->close();
+				return([
+					'success' => false,
+					'notification'=> 'Cette archive est invalide, le fichier de classe est absent.'
+				]);
+			}
+
+
+			/**
+			 * Le module est-il déjà installé ?
+			 * Si oui lire le numéro de version et le stocker dans $versionInstalled
+			 */
+			if (is_file( self::MODULE_DIR .  $module['name'] . '/' .  $module['name'] . '.php') ) {
 				$c = helper::getModules();
-				if (array_key_exists($moduleName, $c)) {
-					$versionInstalled = $c[$moduleName]['version'];
+				if (array_key_exists($module['name'], $c)) {
+					$versionInstalled = $c[$module['name']]['version'];
 				}
 			}
-					// Si version actuelle >= version indiquée dans UPDATE la mise à jour est validée
-					$infoModules = helper::getModules();
-					if( $infoModules[$moduleName]['update'] >= $update ) $valUpdate = true;
 
-					// Module déjà installé ?
-					$moduleInstal = false;
-					foreach($infoModules as $key=>$value ){
-						if($moduleName === $key){
-							$moduleInstal = true;
-						}
-					}
-
-					// Validation de la maj si autorisation du concepteur du module ET
-					// ( Version plus récente OU Check de forçage )
-					$valNewVersion = floatval($version);
-					$valInstalVersion = floatval( $infoModules[$moduleName]['version'] );
-					$newVersion = false;
-					if( $valNewVersion > $valInstalVersion ) $newVersion = true;
-					$validMaj = $valUpdate && ( $newVersion || $checkValid);
-
-					// Nouvelle installation ou mise à jour du module
-					if( ! $moduleInstal ||  $validMaj ){
-						// Copie récursive des dossiers
-						$this->copyDir( self::TEMP_DIR . $tempFolder, './' );
-						$success = true;
-						if( ! $moduleInstal ){
-							$notification = 'Module '.$moduleName.' installé';
-						}
-						else{
-							$notification = 'Module '.$moduleName.' mis à jour';
-						}
-					}
-					else{
-						$success = false;
-						if( $valNewVersion == $valInstalVersion){
-							$notification = ' Version détectée '.$version.' = à celle installée '.$infoModules[$moduleName]['version'];
-						}
-						else{
-							$notification = ' Version détectée '.$version.' < à celle installée '.$infoModules[$moduleName]['version'];
-						}
-						if( $valUpdate === false){
-							if( $infoModules[$moduleName]['update'] === $update ){
-								$notification = ' Mise à jour par ce procédé interdite par le concepteur du module';
-							}
-							else{
-								$notification = ' Mise à jour par ce procédé interdite, votre version est trop ancienne';
-							}
-						}
+			// Le module est installé, contrôle de la version
+			$installOk = false;
+			if ( isset($versionInstalled) === false ) {
+				$installOk = true;
+			} elseif (	version_compare($module['version'], $versionInstalled) >= 0 ) {
+				$installOk = true;
+			} else {
+				if (version_compare($module['version'], $versionInstalled) === -1 ) {
+					// Contrôle du forçage
+					if ($this->getInput('configModulesCheck', helper::FILTER_BOOLEAN) === true) {
+						$installOk = true;
+					} else {
+						// Message de retour
+						$this->removeDir(self::TEMP_DIR . $tempFolder);
+						$zip->close();
+						return([
+							'success' => false,
+							'notification'=> 'La version installée est plus récente, la mise à jour peut être forcée en cochant l\'option.'
+						]);
 					}
 				}
-			// Supprimer le dossier temporaire même si le module est invalide
-			$this->removeDir(self::TEMP_DIR . $tempFolder);
-			$zip->close();
+			}
+
+			// Installation ou mise à jour du module valides
+			if ($installOk) {
+				// Copie récursive des dossiers
+				foreach ($module['dirs'] as $src => $dest) {
+					if (!is_dir (self::TEMP_DIR . $tempFolder . $src)) {
+						mkdir(self::TEMP_DIR . $tempFolder . $src);
+					}
+					$success = $this->copyDir( self::TEMP_DIR . $tempFolder . $src, $dest );
+				}
+				// Message de retour
+				$t = isset($versionInstalled) ? ' actualisé' : 'installé';
+				$this->removeDir(self::TEMP_DIR . $tempFolder);
+				$zip->close();
+				return(['success' => $success,
+						'notification'=> $success ? 'Le module '.$module['name'].' a été ' . $t
+												  : 'Erreur inconnue, le module n\'est pas installé'
+				]);
+			} else {
+				return([
+					'success' => false,
+					'notification'=> 'Une erreur inconnue s\est produite !'
+				]);
+				// Supprimer le dossier temporaire
+				$this->removeDir(self::TEMP_DIR . $tempFolder);
+				$zip->close();
+			}
 		} else {
-			// erreur à l'ouverture
-			$success = false;
-			$notification = 'Impossible d\'ouvrir l\'archive';
+			// Message de retour
+			return(['success' => $success,
+					'notification'=> 'Impossible d\'ouvrir l\'archive'
+			]);
 		}
-		return(['success' => $success,
-				'notification'=> $notification
-		]);
+
 	}
 
 	/***
@@ -294,21 +309,19 @@ class plugin extends common {
 			// Sauver les données du fichiers
 			file_put_contents(self::FILE_DIR . 'source/modules/' . $moduleFile, $moduleData);
 
-			/**
-			* $if( $moduleFile !== ''){
-			*	$success = [
-			*		'success' => false,
-			*		'notification'=> ''
-			*	];
-			*	$state = $this->install(self::FILE_DIR.'source/modules/'.$moduleFile, false);
-			*}
-			*/
+			// Installation directe
+			if ( file_exists(self::FILE_DIR . 'source/modules/' . $moduleFile) ) {
+				$r = $this->install(self::FILE_DIR . 'source/modules/' . $moduleFile, false);
+			} else {
+				$r['notification'] = 'Un problème est survenu, le module n\'est pas installé';
+				$r['success'] = false;
+			}
+			// Valeurs en sortie
 			$this->addOutput([
 				'redirect' => helper::baseUrl()  . 'plugin/store',
-				'notification' => $moduleFile . ' téléchargé dans le dossier modules du gestionnaire de fichiers',
-				'state' => true
+				'notification' => $r['notification'],
+				'state' => $r['success']
 			]);
-
 		}
 		// Valeurs en sortie
 		$this->addOutput([
@@ -548,7 +561,7 @@ class plugin extends common {
 
 			//Nom de l'archive
 			$fileName =  $this->getUrl(3) . '.zip';
-			$this->makeZip ($tmpFolder . '/' . $fileName, 'module/' .  $this->getUrl(3));
+			$this->makeZip ($tmpFolder . '/' . $fileName, self::MODULE_DIR .  $this->getUrl(3));
 
 			switch ($this->getUrl(2)) {
 				case 'filemanager':
diff --git a/core/module/plugin/view/index/index.php b/core/module/plugin/view/index/index.php
index 30939f06..0c33f68d 100644
--- a/core/module/plugin/view/index/index.php
+++ b/core/module/plugin/view/index/index.php
@@ -15,11 +15,18 @@
 			'help' => 'Consulter l\'aide en ligne'
 		]); ?>
 	
-
+
helper::baseUrl() . 'plugin/store', - 'ico' => 'shopping-basket', - 'value' => 'Catalogue en ligne' + 'value' => template::ico('shopping-basket'), + 'help' => 'Installer depuis le catalogue en ligne' + ]); ?> +
+
+ helper::baseUrl() . 'plugin/upload', + 'value' => template::ico('file-archive'), + 'help' => 'Installer depuis une archive' ]); ?>
diff --git a/core/module/plugin/view/store/store.php b/core/module/plugin/view/store/store.php index 8134b91c..f06bf536 100644 --- a/core/module/plugin/view/store/store.php +++ b/core/module/plugin/view/store/store.php @@ -6,12 +6,6 @@ 'value' => template::ico('left') ]); ?>
-
- helper::baseUrl() . 'plugin/upload', - 'value' => 'Installer' - ]); ?> -
diff --git a/module/version/version.php b/module/version/version.php new file mode 100644 index 00000000..284675e6 --- /dev/null +++ b/module/version/version.php @@ -0,0 +1,36 @@ + * + * @copyright Copyright (C) 2018-2020, Frédéric Tempez + * @link http://zwiicms.com/ + */ + +class version extends common { + + const VERSION = '1.0'; + const REALNAME = 'Version'; + const DELETE = true; + const UPDATE = '0.0'; + const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json) + + public static $actions = [ + 'index'=> self::GROUP_VISITOR + + ]; + + /** + * Retourne le numéro de version + */ + + public function index() { + exit( common::ZWII_VERSION); + } + +} diff --git a/module/version/view/index/index.php b/module/version/view/index/index.php new file mode 100644 index 00000000..2263730f --- /dev/null +++ b/module/version/view/index/index.php @@ -0,0 +1 @@ +