forked from ZwiiCMS-Team/ZwiiCMS
fonction getModules
This commit is contained in:
parent
4fb0528ea5
commit
dde3a1c6a2
@ -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
|
||||
|
@ -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){
|
||||
|
@ -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',
|
||||
@ -449,21 +441,7 @@ class page extends common {
|
||||
]);
|
||||
}
|
||||
}
|
||||
// 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)) {
|
||||
|
@ -54,7 +54,7 @@ echo template::formOpen('pageEditForm');
|
||||
]); ?>
|
||||
<?php echo template::hidden('pageEditModuleIdOld',['value' => $this->getData(['page', $this->getUrl(2), 'moduleId'])]); ?>
|
||||
<?php echo template::hidden('pageEditModuleIdOldText',[
|
||||
'value' => 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']))
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col3 verticalAlignBottom">
|
||||
|
@ -87,7 +87,8 @@ class blog extends common {
|
||||
|
||||
public static $users = [];
|
||||
|
||||
const BLOG_VERSION = '4.2';
|
||||
const VERSION = '4.2';
|
||||
const REALNAME = 'Blog';
|
||||
|
||||
/**
|
||||
* Flux RSS
|
||||
|
@ -47,6 +47,6 @@
|
||||
<?php echo template::speech('Aucun article.'); ?>
|
||||
<?php endif; ?>
|
||||
<div class="moduleVersion">Version n°
|
||||
<?php echo $module::BLOG_VERSION; ?>
|
||||
<?php echo $module::VERSION; ?>
|
||||
</div>
|
||||
|
||||
|
@ -32,7 +32,8 @@ class form extends common {
|
||||
|
||||
public static $pagination;
|
||||
|
||||
const FORM_VERSION = '2.7';
|
||||
const VERSION = '2.7';
|
||||
const REALNAME = 'Formulaire';
|
||||
|
||||
// Objets
|
||||
const TYPE_MAIL = 'mail';
|
||||
|
@ -164,5 +164,5 @@
|
||||
</div>
|
||||
<?php echo template::formClose(); ?>
|
||||
<div class="moduleVersion">Version n°
|
||||
<?php echo $module::FORM_VERSION; ?>
|
||||
<?php echo $module::VERSION; ?>
|
||||
</div>
|
||||
|
@ -26,5 +26,5 @@
|
||||
<?php echo template::table([11, 1], $module::$data, ['Données', '']); ?>
|
||||
<?php echo $module::$pagination; ?>
|
||||
<div class="moduleVersion">Version n°
|
||||
<?php echo $module::FORM_VERSION; ?>
|
||||
<?php echo $module::VERSION; ?>
|
||||
</div>
|
@ -19,7 +19,9 @@ class gallery extends common {
|
||||
const SORT_ASC = 'SORT_ASC';
|
||||
const SORT_DSC = 'SORT_DSC';
|
||||
const SORT_HAND = 'SORT_HAND';
|
||||
const GALLERY_VERSION = '2.5';
|
||||
|
||||
const VERSION = '2.5';
|
||||
const REALNAME = 'Galerie';
|
||||
|
||||
public static $directories = [];
|
||||
|
||||
|
@ -58,6 +58,6 @@
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="moduleVersion">Version n°
|
||||
<?php echo $module::GALLERY_VERSION; ?>
|
||||
<?php echo $module::VERSION; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -64,6 +64,6 @@
|
||||
</div>
|
||||
|
||||
<div class="moduleVersion">Version n°
|
||||
<?php echo $module::GALLERY_VERSION; ?>
|
||||
<?php echo $module::VERSION; ?>
|
||||
</div>
|
||||
<?php echo template::formClose(); ?>
|
||||
|
@ -139,7 +139,7 @@
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<div class="moduleVersion">Version n°
|
||||
<?php echo $module::GALLERY_VERSION; ?>
|
||||
<?php echo $module::VERSION; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -33,10 +33,12 @@ class news extends common {
|
||||
false => 'Brouillon',
|
||||
true => 'Publié'
|
||||
];
|
||||
const NEWS_VERSION = '2.0';
|
||||
|
||||
public static $users = [];
|
||||
|
||||
const VERSION = '2.0';
|
||||
const REALNAME = 'Nouvelles';
|
||||
|
||||
/**
|
||||
* Flux RSS
|
||||
*/
|
||||
|
@ -48,5 +48,5 @@
|
||||
<?php endif; ?>
|
||||
<?php echo template::formClose(); ?>
|
||||
<div class="moduleVersion">Version n°
|
||||
<?php echo $module::NEWS_VERSION; ?>
|
||||
<?php echo $module::VERSION; ?>
|
||||
</div>
|
@ -19,7 +19,8 @@ class redirection extends common {
|
||||
'index' => self::GROUP_VISITOR
|
||||
];
|
||||
|
||||
const REDIRECTION_VERSION = '1.4';
|
||||
const VERSION = '1.4';
|
||||
const REALNAME = 'Redirection';
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
|
@ -37,5 +37,5 @@
|
||||
</div>
|
||||
<?php echo template::formClose(); ?>
|
||||
<div class="moduleVersion">Version n°
|
||||
<?php echo $module::REDIRECTION_VERSION; ?>
|
||||
<?php echo $module::VERSION; ?>
|
||||
</div>
|
@ -38,7 +38,8 @@ class search extends common {
|
||||
400 => '400 caractères',
|
||||
];
|
||||
|
||||
const SEARCH_VERSION = '1.2';
|
||||
const VERSION = '1.2';
|
||||
const REALNAME = 'Recherche';
|
||||
|
||||
// Configuration vide
|
||||
public function config() {
|
||||
|
@ -68,5 +68,5 @@
|
||||
</div>
|
||||
<?php echo template::formClose(); ?>
|
||||
<div class="moduleVersion">Version n°
|
||||
<?php echo $module::SEARCH_VERSION; ?>
|
||||
<?php echo $module::VERSION; ?>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user