config deux options
This commit is contained in:
parent
75203d6e8e
commit
c4fc466876
@ -36,7 +36,10 @@ class folder extends common
|
||||
public function index()
|
||||
{
|
||||
|
||||
self::$folders = $this->getFolderContent($this->getData(['module', $this->getUrl(0), 'path']));
|
||||
$config['showsubfolder'] = $this->getData(['module', $this->getUrl(0), 'subfolder']);
|
||||
$config['sort'] = $this->getData(['module', $this->getUrl(0), 'sort']);
|
||||
|
||||
self::$folders = $this->getFolderContent($this->getData(['module', $this->getUrl(0), 'path']), $config);
|
||||
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
@ -54,12 +57,18 @@ class folder extends common
|
||||
$this->getUser('permission', __CLASS__, __FUNCTION__) === true &&
|
||||
$this->isPost()
|
||||
) {
|
||||
$this->setData(['module',
|
||||
$this->getUrl(0),[
|
||||
$this->setData([
|
||||
'module',
|
||||
$this->getUrl(0),
|
||||
[
|
||||
'path' => preg_replace('/^\\./', '', $this->getInput('folderConfigPath')),
|
||||
'title' => $this->getInput('folderConfigTitle')
|
||||
'title' => $this->getInput('folderConfigTitle'),
|
||||
'sort' => $this->getInput('folderConfigSort', helper::FILTER_BOOLEAN),
|
||||
'subfolder' => $this->getInput('folderConfigSubfolder', helper::FILTER_BOOLEAN),
|
||||
'folder' => $this->getInput('folderConfigFolder', helper::FILTER_BOOLEAN),
|
||||
|
||||
]]);
|
||||
]
|
||||
]);
|
||||
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
@ -80,8 +89,11 @@ class folder extends common
|
||||
}
|
||||
|
||||
|
||||
private function getFolderContent($chemin)
|
||||
private function getFolderContent($chemin, $config = [])
|
||||
{
|
||||
$showSubFolder = isset($config['showsubfolder']) ? $config['showsubfolder'] : true;
|
||||
$sort = isset($config['sort']) ? $config['sort'] : true;
|
||||
|
||||
// Vérifier si le chemin existe et est un dossier
|
||||
if (is_dir($chemin)) {
|
||||
// Ouvrir le dossier
|
||||
@ -111,20 +123,24 @@ class folder extends common
|
||||
// Fermer le dossier
|
||||
closedir($dh);
|
||||
|
||||
// Trier les sous-dossiers et les fichiers
|
||||
// Trier les sous-dossiers et les fichiers si nécessaire
|
||||
if ($sort) {
|
||||
sort($subDirectories);
|
||||
sort($files);
|
||||
}
|
||||
|
||||
// Initialiser la liste des éléments
|
||||
$items = '<ul>';
|
||||
|
||||
// Ajouter les sous-dossiers à la liste
|
||||
// Ajouter les sous-dossiers à la liste si configuré pour les afficher
|
||||
if ($showSubFolder) {
|
||||
foreach ($subDirectories as $subDirectory) {
|
||||
$items .= "<li class='directory'>$subDirectory";
|
||||
// Appeler récursivement la fonction pour ce sous-dossier
|
||||
$items .= $this->getFolderContent($chemin . '/' . $subDirectory);
|
||||
$items .= $this->getFolderContent($chemin . '/' . $subDirectory, $config);
|
||||
$items .= '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
// Ajouter les fichiers à la liste
|
||||
foreach ($files as $file) {
|
||||
@ -145,6 +161,9 @@ class folder extends common
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Liste les dossier contenus dans RFM
|
||||
*/
|
||||
|
@ -14,7 +14,9 @@
|
||||
<div class='row'>
|
||||
<div class="col12">
|
||||
<div class="block">
|
||||
<h4><?php echo helper::translate('Paramètres'); ?></h4>
|
||||
<h4>
|
||||
<?php echo helper::translate('Paramètres'); ?>
|
||||
</h4>
|
||||
<div class="row">
|
||||
<div class="col6">
|
||||
<?php echo template::select('folderConfigPath', $module::$sharePath, [
|
||||
@ -31,6 +33,18 @@
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col4">
|
||||
<?php echo template::checkbox('folderConfigSort', true, 'Trier les dossiers et les fichiers', [
|
||||
'checked' => $this->getData(['module', $this->getUrl(0), 'sort'])
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col4">
|
||||
<?php echo template::checkbox('folderConfigSubfolder', true, 'Descendre dans l\'arboresence', [
|
||||
'checked' => $this->getData(['module', $this->getUrl(0), 'subfolder'])
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user