diff --git a/core/class/helper.class.php b/core/class/helper.class.php index 396208ec..4ce97ef5 100755 --- a/core/class/helper.class.php +++ b/core/class/helper.class.php @@ -127,6 +127,41 @@ class helper { return ($fileName); } + + + /** + * Retourne la liste des modules installés dans un tableau composé + * du nom réel + * du numéro de version + */ + public static function getModules() { + $dirs = array_diff(scandir('module'), array('..', '.')); + foreach ($dirs as $key => $value) { + // Lire les constantes + $class_reflex = new \ReflectionClass($value); + $class_constants = $class_reflex->getConstants(); + // Constante REALNAME + if (array_key_exists('REALNAME', $class_constants)) { + $realName = $value::REALNAME; + } else { + $realName = ucfirst($value); + } + // Constante VERSION + if (array_key_exists('VERSION', $class_constants)) { + $version = $value::VERSION; + } else { + $version = '0.0'; + } + // Affection + $modules [$value] = [ + 'realName' => $realName, + 'version' => $version + ]; + } + return($modules); + } + + /** * Retourne true si le protocole est en TLS * @return bool diff --git a/core/module/config/config.php b/core/module/config/config.php index 5036f1de..79c03d23 100755 --- a/core/module/config/config.php +++ b/core/module/config/config.php @@ -604,6 +604,7 @@ class config extends common { */ public function modules() { + helper::getModules(); // Préparation du tableau des modules installés // Liste des modules installés (répertoire de module/) if ($dh = opendir( 'module/' )) { @@ -613,12 +614,12 @@ class config extends common { self::$modInstal[$i][0] = $dirmodule; self::$modInstal[$i][1] = page::$moduleNames[$dirmodule]; // Lecture de la version pour les modules officiels et distribués - $blogversion = blog::BLOG_VERSION; - $formversion = form::FORM_VERSION; - $galleryversion = gallery::GALLERY_VERSION; - $newsversion = news::NEWS_VERSION; - $redirectionversion = redirection::REDIRECTION_VERSION; - $searchversion = search::SEARCH_VERSION; + $blogversion = blog::VERSION; + $formversion = form::VERSION; + $galleryversion = gallery::VERSION; + $newsversion = news::VERSION; + $redirectionversion = redirection::VERSION; + $searchversion = search::VERSION; self::$str = $dirmodule.'version'; self::$modInstal[$i][2] = '?'; if( ${self::$str} !== null){ diff --git a/core/module/page/page.php b/core/module/page/page.php index 88e6b37f..f59c79b5 100755 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -29,15 +29,7 @@ class page extends common { '' => 'Aucune' ]; public static $moduleIds = []; - // Nom des modules - public static $moduleNames = [ - 'news' => 'Nouvelles', - 'blog' => 'Blog', - 'form' => 'Formulaire', - 'gallery' => 'Galerie', - 'redirection' => 'Redirection', - 'search' => 'Recherche' - ]; + public static $typeMenu = [ 'text' => 'Texte', 'icon' => 'Icône', @@ -448,22 +440,8 @@ class page extends common { 'state' => true ]); } - } - // Liste des modules - $moduleIds = []; - $iterator = new DirectoryIterator('module/'); - foreach($iterator as $fileInfos) { - if(is_file($fileInfos->getPathname() . '/' . $fileInfos->getFilename() . '.php')) { - if (array_key_exists($fileInfos->getBasename(),self::$moduleNames)) { - $moduleIds[$fileInfos->getBasename()] = self::$moduleNames[$fileInfos->getBasename()]; - } else { - $moduleIds[$fileInfos->getBasename()] = ucfirst($fileInfos->getBasename()); - } - } - } - self::$moduleIds = $moduleIds; - asort(self::$moduleIds); - self::$moduleIds = array_merge( ['' => 'Aucun'] , self::$moduleIds); + } + self::$moduleIds = array_merge( ['' => 'Aucun'] , helper::arrayCollumn(helper::getModules(),'realName','SORT_ASC')); // Pages sans parent foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) { if($parentPageId !== $this->getUrl(2)) { diff --git a/core/module/page/view/edit/edit.php b/core/module/page/view/edit/edit.php index cac97d04..be3941f2 100755 --- a/core/module/page/view/edit/edit.php +++ b/core/module/page/view/edit/edit.php @@ -54,7 +54,7 @@ echo template::formOpen('pageEditForm'); ]); ?> $this->getData(['page', $this->getUrl(2), 'moduleId'])]); ?> array_key_exists($this->getData(['page', $this->getUrl(2), 'moduleId']),$module::$moduleNames)? $module::$moduleNames[$this->getData(['page', $this->getUrl(2), 'moduleId'])] : ucfirst($this->getData(['page', $this->getUrl(2), 'moduleId'])) + 'value' => array_key_exists($this->getData(['page', $this->getUrl(2), 'moduleId']),$module::$moduleIds)? $module::$moduleIds[$this->getData(['page', $this->getUrl(2), 'moduleId'])] : ucfirst($this->getData(['page', $this->getUrl(2), 'moduleId'])) ]); ?>