Browse Source

fonction getModules

10504
Prof Langues 6 months ago
parent
commit
dde3a1c6a2
  1. 35
      core/class/helper.class.php
  2. 13
      core/module/config/config.php
  3. 28
      core/module/page/page.php
  4. 2
      core/module/page/view/edit/edit.php
  5. 3
      module/blog/blog.php
  6. 2
      module/blog/view/config/config.php
  7. 3
      module/form/form.php
  8. 2
      module/form/view/config/config.php
  9. 2
      module/form/view/data/data.php
  10. 4
      module/gallery/gallery.php
  11. 2
      module/gallery/view/config/config.php
  12. 2
      module/gallery/view/edit/edit.php
  13. 2
      module/gallery/view/theme/theme.php
  14. 4
      module/news/news.php
  15. 2
      module/news/view/config/config.php
  16. 3
      module/redirection/redirection.php
  17. 2
      module/redirection/view/config/config.php
  18. 3
      module/search/search.php
  19. 2
      module/search/view/config/config.php

35
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

13
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){

28
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)) {

2
core/module/page/view/edit/edit.php

@ -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">

3
module/blog/blog.php

@ -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

2
module/blog/view/config/config.php

@ -47,6 +47,6 @@
<?php echo template::speech('Aucun article.'); ?>
<?php endif; ?>
<div class="moduleVersion">Version
<?php echo $module::BLOG_VERSION; ?>
<?php echo $module::VERSION; ?>
</div>

3
module/form/form.php

@ -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';

2
module/form/view/config/config.php

@ -164,5 +164,5 @@
</div>
<?php echo template::formClose(); ?>
<div class="moduleVersion">Version
<?php echo $module::FORM_VERSION; ?>
<?php echo $module::VERSION; ?>
</div>

2
module/form/view/data/data.php

@ -26,5 +26,5 @@
<?php echo template::table([11, 1], $module::$data, ['Données', '']); ?>
<?php echo $module::$pagination; ?>
<div class="moduleVersion">Version
<?php echo $module::FORM_VERSION; ?>
<?php echo $module::VERSION; ?>
</div>

4
module/gallery/gallery.php

@ -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 = [];

2
module/gallery/view/config/config.php

@ -58,6 +58,6 @@
<?php endif; ?>
</div>
<div class="moduleVersion">Version
<?php echo $module::GALLERY_VERSION; ?>
<?php echo $module::VERSION; ?>
</div>
</div>

2
module/gallery/view/edit/edit.php

@ -64,6 +64,6 @@
</div>
<div class="moduleVersion">Version
<?php echo $module::GALLERY_VERSION; ?>
<?php echo $module::VERSION; ?>
</div>
<?php echo template::formClose(); ?>

2
module/gallery/view/theme/theme.php

@ -139,7 +139,7 @@
<div class="row">
<div class="col12">
<div class="moduleVersion">Version
<?php echo $module::GALLERY_VERSION; ?>
<?php echo $module::VERSION; ?>
</div>
</div>
</div>

4
module/news/news.php

@ -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
*/

2
module/news/view/config/config.php

@ -48,5 +48,5 @@
<?php endif; ?>
<?php echo template::formClose(); ?>
<div class="moduleVersion">Version
<?php echo $module::NEWS_VERSION; ?>
<?php echo $module::VERSION; ?>
</div>

3
module/redirection/redirection.php

@ -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

2
module/redirection/view/config/config.php

@ -37,5 +37,5 @@
</div>
<?php echo template::formClose(); ?>
<div class="moduleVersion">Version
<?php echo $module::REDIRECTION_VERSION; ?>
<?php echo $module::VERSION; ?>
</div>

3
module/search/search.php

@ -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() {

2
module/search/view/config/config.php

@ -68,5 +68,5 @@
</div>
<?php echo template::formClose(); ?>
<div class="moduleVersion">Version
<?php echo $module::SEARCH_VERSION; ?>
<?php echo $module::VERSION; ?>
</div>
Loading…
Cancel
Save