From 9b5cc38c94692865bb23de2448606bdd0f501efb Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Tue, 12 Mar 2024 18:35:44 +0100 Subject: [PATCH 01/10] sharefolder WIP --- core/class/router.class.php | 3 +- module/sharefolder/sharefolder.php | 41 +++ .../sharefolder/vendor/php-dirlister/inc.json | 3 + .../vendor/php-dirlister/php-dirlister.php | 283 ++++++++++++++++++ module/sharefolder/view/config/config.php | 0 module/sharefolder/view/index/index.css | 151 ++++++++++ module/sharefolder/view/index/index.php | 66 ++++ 7 files changed, 546 insertions(+), 1 deletion(-) create mode 100644 module/sharefolder/sharefolder.php create mode 100644 module/sharefolder/vendor/php-dirlister/inc.json create mode 100644 module/sharefolder/vendor/php-dirlister/php-dirlister.php create mode 100644 module/sharefolder/view/config/config.php create mode 100644 module/sharefolder/view/index/index.css create mode 100644 module/sharefolder/view/index/index.php diff --git a/core/class/router.class.php b/core/class/router.class.php index 98e348d1..4517ef7a 100644 --- a/core/class/router.class.php +++ b/core/class/router.class.php @@ -761,8 +761,9 @@ class core extends common // Librairies if ($output['vendor'] !== $this->output['vendor']) { $this->addOutput([ - 'vendor' => array_merge($this->output['vendor'], $output['vendor']) + 'vendor' => array_merge($this->output['vendor'], $this->output['vendor']) ]); + } if ($output['title'] !== null) { diff --git a/module/sharefolder/sharefolder.php b/module/sharefolder/sharefolder.php new file mode 100644 index 00000000..bb06207f --- /dev/null +++ b/module/sharefolder/sharefolder.php @@ -0,0 +1,41 @@ + + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2024, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.fr/ + */ + +class sharefolder extends common +{ + + const VERSION = '4.2'; + const REALNAME = 'Dossier partagé'; + const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json) + + public static $actions = [ + 'config' => self::GROUP_EDITOR, + 'index' => self::GROUP_VISITOR, + ]; + + public function index() { + // Valeurs en sortie + $this->addOutput([ + 'showBarEditButton' => true, + 'showPageContent' => true, + 'view' => 'index', + 'vendor' => [ + 'php-dirlister' + ], + ]); + } + +} \ No newline at end of file diff --git a/module/sharefolder/vendor/php-dirlister/inc.json b/module/sharefolder/vendor/php-dirlister/inc.json new file mode 100644 index 00000000..4eba2988 --- /dev/null +++ b/module/sharefolder/vendor/php-dirlister/inc.json @@ -0,0 +1,3 @@ +[ + "php-dirlister.php" +] \ No newline at end of file diff --git a/module/sharefolder/vendor/php-dirlister/php-dirlister.php b/module/sharefolder/vendor/php-dirlister/php-dirlister.php new file mode 100644 index 00000000..d42ddb5e --- /dev/null +++ b/module/sharefolder/vendor/php-dirlister/php-dirlister.php @@ -0,0 +1,283 @@ + 'Index of [path]', + 'page_subtitle' => 'Total: [items] items, [size]', + 'browse_directories' => true, + 'show_breadcrumbs' => true, + 'show_directories' => true, + 'show_footer' => true, + 'show_parent' => false, + 'show_hidden' => false, + 'directory_first' => true, + 'content_alignment' => 'center', + 'date_format' => 'd M Y H:i', + 'timezone' => 'Asia/Jakarta', + 'ignore_list' => array( + '.DS_Store', + '.git', + '.gitmodules', + '.gitignore', + '.vscode', + 'vendor', + 'node_modules', + ), +); + + +/* +|-------------------------------------------------------------------------- +| ACTUAL PROGRAM STARTS HERE +|-------------------------------------------------------------------------- +*/ + +class PHPDirLister +{ + private $self; + private $path; + private $browse; + private $total; + private $totalSize; + private $config = array(); + + public function __construct(array $config = array()) + { + $this->config = $config; + $this->self = basename($_SERVER['PHP_SELF']); + $this->path = str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])); + $this->total = 0; + $this->totalSize = 0; + + if ($this->config['browse_directories']) { + $_GET['b'] = trim(str_replace('\\', '/', (string) isset($_GET['b']) ? $_GET['b'] : ''), '/ '); + $_GET['b'] = str_replace(array('/..', '../'), '', (string) isset($_GET['b']) ? $_GET['b'] : ''); + + if (!empty($_GET['b']) && $_GET['b'] !== '..' && is_dir($_GET['b'])) { + $ignored = false; + $names = explode('/', $_GET['b']); + + foreach ($names as $name) { + if (in_array($name, $this->config['ignore_list'])) { + $ignored = true; + break; + } + } + + if (!$ignored) { + $this->browse = $_GET['b']; + } + + if (!empty($this->browse)) { + $index = null; + + if (is_file($this->browse . '/index.htm')) { + $index = '/index.htm'; + } elseif (is_file($this->browse . '/index.html')) { + $index = '/index.html'; + } elseif (is_file($this->browse . '/index.php')) { + $index = '/index.php'; + } + + if (!is_null($index)) { + header('Location: ' . $this->browse . $index); + exit; + } + } + } + } + } + + public function getSelf() + { + return $this->self; + } + + public function getPath() + { + return $this->path; + } + + public function getBrowse() + { + return $this->browse; + } + + public function getTotal() + { + return $this->total; + } + + public function getTotalSize() + { + return $this->totalSize; + } + + public function getConfig($key, $default = null) + { + return array_key_exists($key, $this->config) ? $this->config[$key] : $default; + } + + public function getListings($path) + { + $ls = array(); + $lsDir = array(); + + if (($dh = @opendir($path)) === false) { + return $ls; + } + + $path .= (substr($path, -1) !== '/') ? '/' : ''; + + while (($file = readdir($dh)) !== false) { + if ( + $file === $this->self + || $file === '.' + || $file == '..' + || (!$this->config['show_hidden'] && substr($file, 0, 1) === '.') + || in_array($file, $this->config['ignore_list']) + ) { + continue; + } + + $isDir = is_dir($path . $file); + + if (!$this->config['show_directories'] && $isDir) { + continue; + } + + $item = array( + 'name' => $file, + 'is_dir' => $isDir, + 'size' => $isDir ? 0 : filesize($path . $file), + 'time' => filemtime($path . $file), + ); + + if ($isDir) { + $lsDir[] = $item; + } else { + $ls[] = $item; + } + + $this->total++; + $this->totalSize += $item['size']; + } + + return array_merge($lsDir, $ls); + } + + public function sortByName($a, $b) + { + return ( + ($a['is_dir'] === $b['is_dir']) + || ($this->config['directory_first']) ? ($a['is_dir'] < $b['is_dir']) : (strtolower($a['name']) > strtolower($b['name'])) + ) ? 1 : -1; + } + + public function sortBySize($a, $b) + { + return ( + ($a['is_dir'] === $b['is_dir']) ? ($a['size'] > $b['size']) : ($a['is_dir'] < $b['is_dir']) + ) ? 1 : -1; + } + + public function sortByTime($a, $b) + { + return ($a['time'] > $b['time']) ? 1 : -1; + } + + public function humanizeFilesize($val) + { + $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); + $power = min(floor(($val ? log($val) : 0) / log(1024)), count($units) - 1); + $val = sprintf('%.1f %s', round($val / pow(1024, $power), 1), $units[$power]); + + return str_replace('.0 ', ' ', $val); + } + + public function generateTitle($forSubtitle = false) + { + $path = htmlentities($this->path); + $title = htmlentities(str_replace( + array('[items]', '[size]'), + array($this->total, $this->humanizeFilesize($this->totalSize)), + $this->config[$forSubtitle ? 'page_subtitle' : 'page_title'] + )); + + if ($this->config['show_breadcrumbs']) { + $path = sprintf('%s', htmlentities($this->buildLink(array('b' => ''))), $path); + } + + if (!empty($this->getBrowse())) { + $path .= ($this->path !== '/') ? '/' : ''; + $items = explode('/', trim($this->browse, '/')); + + foreach ($items as $i => $item) { + $path .= $this->config['show_breadcrumbs'] + ? sprintf( + '%s', + htmlentities($this->buildLink(array('b' => implode('/', array_slice($items, 0, $i + 1))))), + htmlentities($item) + ) + : htmlentities($item); + $path .= (count($items) > ($i + 1)) ? '/' : ''; + } + } + + return str_replace('[path]', $path, $title); + } + + public function buildLink($changes) + { + $params = $_GET; + + foreach ($changes as $k => $v) { + if (is_null($v)) { + unset($params[$k]); + } else { + $params[$k] = $v; + } + } + + foreach ($params as $k => $v) { + $params[$k] = urlencode($k) . '=' . urlencode($v); + } + + return empty($params) ? $this->self : $this->self . '?' . implode('&', $params); + } +} + +$pdl = new PHPDirLister($config); +$items = $pdl->getListings('.' . (empty($pdl->getBrowse()) ? '' : '/' . $pdl->getBrowse())); +$sorting = isset($_GET['s']) ? $_GET['s'] : null; + +switch ($sorting) { + case 'size': + $sorting = 'size'; + usort($items, function ($a, $b) use ($pdl) { + return $pdl->sortBySize($a, $b); + }); + break; + + case 'time': + $sorting = 'time'; + usort($items, function ($a, $b) use ($pdl) { + return $pdl->sortByTime($a, $b); + }); + break; + + default: + $sorting = 'name'; + usort($items, function ($a, $b) use ($pdl) { + return $pdl->sortByName($a, $b); + }); + break; +} diff --git a/module/sharefolder/view/config/config.php b/module/sharefolder/view/config/config.php new file mode 100644 index 00000000..e69de29b diff --git a/module/sharefolder/view/index/index.css b/module/sharefolder/view/index/index.css new file mode 100644 index 00000000..9426ed9f --- /dev/null +++ b/module/sharefolder/view/index/index.css @@ -0,0 +1,151 @@ + +#wrapper { + width: 80%; + margin: 0 auto; + text-align: left; +} + +body#left { + text-align: left; +} + +body#left #wrapper { + margin: 0 20px; +} + +#wrapper > h1 { + font-size: 21px; + padding: 0 10px; + margin: 20px 0 0; + font-weight: bold; +} + +#wrapper > h2 { + font-size: 11px; + padding: 0 10px; + margin: 10px 0 0; + color: #98a6ad; + font-weight: normal; +} + +#wrapper > a { + color: #003399; + text-decoration: none; +} + +#wrapper > a:hover { + color: #0066cc; + text-decoration: underline; +} + +#wrapper > ul#header { + margin-top: 20px; +} + +#wrapper > ul li { + display: block; + list-style-type: none; + overflow: hidden; + padding: 10px; +} + +#wrapper > ul li:hover { + background-color: #f3f3f3; +} + +#wrapper > ul li .date { + text-align: center; + width: 120px; +} + +#wrapper > ul li .size { + text-align: right; + width: 90px; +} + +#wrapper > ul li .date, +#wrapper > ul li .size { + float: right; + font-size: 12px; + display: block; + color: #666666; +} + +#wrapper > ul#header li { + font-size: 11px; + font-weight: bold; + border-bottom: 1px solid #dee2e6; +} + +#wrapper > ul#header li:hover { + background-color: transparent; +} + +#wrapper > ul#header li * { + color: #888888; + font-size: 11px; +} + +#wrapper > ul#header li a:hover { + color: #333333; +} + +#wrapper > ul#header li .asc span, +#wrapper > ul#header li .desc span { + padding-right: 15px; + background-position: right center; + background-repeat: no-repeat; +} + +#wrapper > ul#header li .asc span { + background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABbSURBVCjPY/jPgB8yDCkFB/7v+r/5/+r/i/7P+N/3DYuC7V93/d//fydQ0Zz/9eexKFgtsejLiv8b/8/8X/WtUBGrGyZLdH6f8r/sW64cTkdWSRS+zpQbgiEJAI4UCqdRg1A6AAAAAElFTkSuQmCC'); +} + +#wrapper > ul#header li .desc span { + background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABbSURBVCjPY/jPgB8yDDkFmyVWv14kh1PBeoll31f/n/ytUw6rgtUSi76s+L/x/8z/Vd8KFbEomPt16f/1/1f+X/S/7X/qeSwK+v63/K/6X/g/83/S/5hvQywkAdMGCdCoabZeAAAAAElFTkSuQmCC'); +} + +#wrapper > ul li.item { + border-top: 1px solid #f3f3f3; +} + +#wrapper > ul li.item:first-child { + border-top: none; +} + +#wrapper > ul li.item .name { + font-weight: bold; +} + +#wrapper > ul li.item .dir, +#wrapper > ul li.item .file { + padding-left: 20px; + background-position: left center; + background-repeat: no-repeat; +} + +#wrapper > ul li.item .dir { + background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGrSURBVDjLxZO7ihRBFIa/6u0ZW7GHBUV0UQQTZzd3QdhMQxOfwMRXEANBMNQX0MzAzFAwEzHwARbNFDdwEd31Mj3X7a6uOr9BtzNjYjKBJ6nicP7v3KqcJFaxhBVtZUAK8OHlld2st7Xl3DJPVONP+zEUV4HqL5UDYHr5xvuQAjgl/Qs7TzvOOVAjxjlC+ePSwe6DfbVegLVuT4r14eTr6zvA8xSAoBLzx6pvj4l+DZIezuVkG9fY2H7YRQIMZIBwycmzH1/s3F8AapfIPNF3kQk7+kw9PWBy+IZOdg5Ug3mkAATy/t0usovzGeCUWTjCz0B+Sj0ekfdvkZ3abBv+U4GaCtJ1iEm6ANQJ6fEzrG/engcKw/wXQvEKxSEKQxRGKE7Izt+DSiwBJMUSm71rguMYhQKrBygOIRStf4TiFFRBvbRGKiQLWP29yRSHKBTtfdBmHs0BUpgvtgF4yRFR+NUKi0XZcYjCeCG2smkzLAHkbRBmP0/Uk26O5YnUActBp1GsAI+S5nRJJJal5K1aAMrq0d6Tm9uI6zjyf75dAe6tx/SsWeD//o2/Ab6IH3/h25pOAAAAAElFTkSuQmCC'); +} + +#wrapper > ul li.item .file { + background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAABVklEQVQYGQXBP0hUAQAH4O/dnaaSXhIY2Z/NDAoaanUNorHJpbHBotZwT2hpL4iioTjUqb0hh3AqwYgw4xITgtCOvLI73/v1fUUArCx0bu5NMr7TfDEzDyAiYnmi1UuSJGn1Xk5GRBSxstCZ3Tur1jRlWnzyVYdqfKv5amZetA6SJGlnKWtZy2LaSZKkdRD1S8/qV+K4+OxQ2w9jSidVPuo03k0XS/2Lja5C3YYbgGVT+rpKm4e1dE85rWnUhA2VyoYTBu3pGZduIxgy4LcBHevo23VgABGNICrDzvij8tNfoxoKpVI0yuGa6Cv1FSqHjoCeQqUcquXtqo4RdZWgEvHPmJpNWa1V17dvvfnyQWFMA6WeEUe1rX/bvZtrRfB8Ivcyd/7YOaVthR1b+3mSR3e+UwTw9ELmM3u5+GXb/nIe3H4PFAHA46u5n8E8nHsNQBEAAADAf9MfuSUN80DGAAAAAElFTkSuQmCC'); +} + +#wrapper > #footer { + color: #98a6ad; + font-size: 11px; + margin-top: 40px; + margin-bottom: 20px; + padding: 0 10px; + text-align: left; +} + +#wrapper > #footer a { + color: #98a6ad; + font-weight: bold; +} + +#wrapper > #footer a:hover { + color: #777777; +} \ No newline at end of file diff --git a/module/sharefolder/view/index/index.php b/module/sharefolder/view/index/index.php new file mode 100644 index 00000000..4fcbd0d1 --- /dev/null +++ b/module/sharefolder/view/index/index.php @@ -0,0 +1,66 @@ +getConfig('timezone', 'UTC')); + +$reverse = isset($_GET['r']) && $_GET['r'] === '1'; +$items = $reverse ? array_reverse($items) : $items; + + +if ($pdl->getConfig('show_parent') && $pdl->getPath() !== '/' && empty($pdl->getBrowse())) { + array_unshift($items, array('name' => '..', 'is_parent' => true, 'is_dir' => true, 'size' => 0, 'time' => 0)); +} +?> +getConfig('content_alignment') === 'left') echo 'id="left"' ?>> + +
+ +

generateTitle() ?>

+

generateTitle(true) ?>

+ + + +
    + +
  • + + humanizeFilesize($item['size']) ?> + + + getConfig('date_format'), $item['time']) ?> + + + getConfig('browse_directories') && (!isset($item['is_parent']) || !$item['is_parent'])) { + if ($item['name'] === '..') { + $link = $pdl->buildLink(array('b' => substr($pdl->getBrowse(), 0, strrpos($pdl->getBrowse(), '/')))); + } else { + $link = $pdl->buildLink(array('b' => (empty($pdl->getBrowse()) ? '' : (string) $pdl->getBrowse() . '/') . $item['name'])); + } + } else { + $link = (empty($pdl->getBrowse()) ? '' : str_replace(['%2F', '%2f'], '/', rawurlencode((string)$pdl->getBrowse())) . '/') . rawurlencode($item['name']); + } + ?> + +
  • + +
+ + getConfig('show_footer')) : ?> + + +
= + + + \ No newline at end of file From f3ae03a133d381626c9925723fb5922019ba972d Mon Sep 17 00:00:00 2001 From: F TEMPEZ Date: Wed, 13 Mar 2024 16:28:19 +0100 Subject: [PATCH 02/10] shareFolder --- module/sharefolder/sharefolder.php | 49 ++- .../sharefolder/vendor/php-dirlister/inc.json | 3 - .../vendor/php-dirlister/php-dirlister.php | 283 ------------------ module/sharefolder/view/index/index.css | 180 +++-------- module/sharefolder/view/index/index.php | 72 +---- 5 files changed, 88 insertions(+), 499 deletions(-) delete mode 100644 module/sharefolder/vendor/php-dirlister/inc.json delete mode 100644 module/sharefolder/vendor/php-dirlister/php-dirlister.php diff --git a/module/sharefolder/sharefolder.php b/module/sharefolder/sharefolder.php index bb06207f..3bbeca6b 100644 --- a/module/sharefolder/sharefolder.php +++ b/module/sharefolder/sharefolder.php @@ -26,16 +26,57 @@ class sharefolder extends common 'index' => self::GROUP_VISITOR, ]; + static $folders = ''; + public function index() { + + self::$folders = $this->listerSousDossier( self::FILE_DIR . 'source/partage'); + // Valeurs en sortie $this->addOutput([ 'showBarEditButton' => true, 'showPageContent' => true, - 'view' => 'index', - 'vendor' => [ - 'php-dirlister' - ], + 'view' => 'index' ]); } + private function listerSousDossier($chemin) { + // Vérifier si le chemin existe et est un dossier + if (is_dir($chemin)) { + // Ouvrir le dossier + if ($dh = opendir($chemin)) { + $items = isset($items) ? $items . '
    ' : '
      '; + //$items = '
        '; + // Parcourir les éléments du dossier + while (($element = readdir($dh)) !== false) { + // Exclure les éléments spéciaux + if ($element != '.' && $element != '..') { + // Construire le chemin complet de l'élément + $cheminComplet = $chemin . '/' . $element; + + // Vérifier si c'est un dossier + if (is_dir($cheminComplet)) { + // Afficher le nom du dossier + $items .= "
      • $element"; + // Appeler récursivement la fonction pour ce sous-dossier + $items .= $this->listerSousDossier($cheminComplet); + $items .= '
      • '; + } else { + // Afficher le nom du fichier comme un lien + $items .= '
      • ' . $element . '
      • '; + } + } + } + $items .= "
      "; + + // Fermer le dossier + closedir($dh); + } + return $items; + } else { + exit ('Erreur de chemin'); + } + + } + } \ No newline at end of file diff --git a/module/sharefolder/vendor/php-dirlister/inc.json b/module/sharefolder/vendor/php-dirlister/inc.json deleted file mode 100644 index 4eba2988..00000000 --- a/module/sharefolder/vendor/php-dirlister/inc.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "php-dirlister.php" -] \ No newline at end of file diff --git a/module/sharefolder/vendor/php-dirlister/php-dirlister.php b/module/sharefolder/vendor/php-dirlister/php-dirlister.php deleted file mode 100644 index d42ddb5e..00000000 --- a/module/sharefolder/vendor/php-dirlister/php-dirlister.php +++ /dev/null @@ -1,283 +0,0 @@ - 'Index of [path]', - 'page_subtitle' => 'Total: [items] items, [size]', - 'browse_directories' => true, - 'show_breadcrumbs' => true, - 'show_directories' => true, - 'show_footer' => true, - 'show_parent' => false, - 'show_hidden' => false, - 'directory_first' => true, - 'content_alignment' => 'center', - 'date_format' => 'd M Y H:i', - 'timezone' => 'Asia/Jakarta', - 'ignore_list' => array( - '.DS_Store', - '.git', - '.gitmodules', - '.gitignore', - '.vscode', - 'vendor', - 'node_modules', - ), -); - - -/* -|-------------------------------------------------------------------------- -| ACTUAL PROGRAM STARTS HERE -|-------------------------------------------------------------------------- -*/ - -class PHPDirLister -{ - private $self; - private $path; - private $browse; - private $total; - private $totalSize; - private $config = array(); - - public function __construct(array $config = array()) - { - $this->config = $config; - $this->self = basename($_SERVER['PHP_SELF']); - $this->path = str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])); - $this->total = 0; - $this->totalSize = 0; - - if ($this->config['browse_directories']) { - $_GET['b'] = trim(str_replace('\\', '/', (string) isset($_GET['b']) ? $_GET['b'] : ''), '/ '); - $_GET['b'] = str_replace(array('/..', '../'), '', (string) isset($_GET['b']) ? $_GET['b'] : ''); - - if (!empty($_GET['b']) && $_GET['b'] !== '..' && is_dir($_GET['b'])) { - $ignored = false; - $names = explode('/', $_GET['b']); - - foreach ($names as $name) { - if (in_array($name, $this->config['ignore_list'])) { - $ignored = true; - break; - } - } - - if (!$ignored) { - $this->browse = $_GET['b']; - } - - if (!empty($this->browse)) { - $index = null; - - if (is_file($this->browse . '/index.htm')) { - $index = '/index.htm'; - } elseif (is_file($this->browse . '/index.html')) { - $index = '/index.html'; - } elseif (is_file($this->browse . '/index.php')) { - $index = '/index.php'; - } - - if (!is_null($index)) { - header('Location: ' . $this->browse . $index); - exit; - } - } - } - } - } - - public function getSelf() - { - return $this->self; - } - - public function getPath() - { - return $this->path; - } - - public function getBrowse() - { - return $this->browse; - } - - public function getTotal() - { - return $this->total; - } - - public function getTotalSize() - { - return $this->totalSize; - } - - public function getConfig($key, $default = null) - { - return array_key_exists($key, $this->config) ? $this->config[$key] : $default; - } - - public function getListings($path) - { - $ls = array(); - $lsDir = array(); - - if (($dh = @opendir($path)) === false) { - return $ls; - } - - $path .= (substr($path, -1) !== '/') ? '/' : ''; - - while (($file = readdir($dh)) !== false) { - if ( - $file === $this->self - || $file === '.' - || $file == '..' - || (!$this->config['show_hidden'] && substr($file, 0, 1) === '.') - || in_array($file, $this->config['ignore_list']) - ) { - continue; - } - - $isDir = is_dir($path . $file); - - if (!$this->config['show_directories'] && $isDir) { - continue; - } - - $item = array( - 'name' => $file, - 'is_dir' => $isDir, - 'size' => $isDir ? 0 : filesize($path . $file), - 'time' => filemtime($path . $file), - ); - - if ($isDir) { - $lsDir[] = $item; - } else { - $ls[] = $item; - } - - $this->total++; - $this->totalSize += $item['size']; - } - - return array_merge($lsDir, $ls); - } - - public function sortByName($a, $b) - { - return ( - ($a['is_dir'] === $b['is_dir']) - || ($this->config['directory_first']) ? ($a['is_dir'] < $b['is_dir']) : (strtolower($a['name']) > strtolower($b['name'])) - ) ? 1 : -1; - } - - public function sortBySize($a, $b) - { - return ( - ($a['is_dir'] === $b['is_dir']) ? ($a['size'] > $b['size']) : ($a['is_dir'] < $b['is_dir']) - ) ? 1 : -1; - } - - public function sortByTime($a, $b) - { - return ($a['time'] > $b['time']) ? 1 : -1; - } - - public function humanizeFilesize($val) - { - $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); - $power = min(floor(($val ? log($val) : 0) / log(1024)), count($units) - 1); - $val = sprintf('%.1f %s', round($val / pow(1024, $power), 1), $units[$power]); - - return str_replace('.0 ', ' ', $val); - } - - public function generateTitle($forSubtitle = false) - { - $path = htmlentities($this->path); - $title = htmlentities(str_replace( - array('[items]', '[size]'), - array($this->total, $this->humanizeFilesize($this->totalSize)), - $this->config[$forSubtitle ? 'page_subtitle' : 'page_title'] - )); - - if ($this->config['show_breadcrumbs']) { - $path = sprintf('%s', htmlentities($this->buildLink(array('b' => ''))), $path); - } - - if (!empty($this->getBrowse())) { - $path .= ($this->path !== '/') ? '/' : ''; - $items = explode('/', trim($this->browse, '/')); - - foreach ($items as $i => $item) { - $path .= $this->config['show_breadcrumbs'] - ? sprintf( - '%s', - htmlentities($this->buildLink(array('b' => implode('/', array_slice($items, 0, $i + 1))))), - htmlentities($item) - ) - : htmlentities($item); - $path .= (count($items) > ($i + 1)) ? '/' : ''; - } - } - - return str_replace('[path]', $path, $title); - } - - public function buildLink($changes) - { - $params = $_GET; - - foreach ($changes as $k => $v) { - if (is_null($v)) { - unset($params[$k]); - } else { - $params[$k] = $v; - } - } - - foreach ($params as $k => $v) { - $params[$k] = urlencode($k) . '=' . urlencode($v); - } - - return empty($params) ? $this->self : $this->self . '?' . implode('&', $params); - } -} - -$pdl = new PHPDirLister($config); -$items = $pdl->getListings('.' . (empty($pdl->getBrowse()) ? '' : '/' . $pdl->getBrowse())); -$sorting = isset($_GET['s']) ? $_GET['s'] : null; - -switch ($sorting) { - case 'size': - $sorting = 'size'; - usort($items, function ($a, $b) use ($pdl) { - return $pdl->sortBySize($a, $b); - }); - break; - - case 'time': - $sorting = 'time'; - usort($items, function ($a, $b) use ($pdl) { - return $pdl->sortByTime($a, $b); - }); - break; - - default: - $sorting = 'name'; - usort($items, function ($a, $b) use ($pdl) { - return $pdl->sortByName($a, $b); - }); - break; -} diff --git a/module/sharefolder/view/index/index.css b/module/sharefolder/view/index/index.css index 9426ed9f..fc02cf04 100644 --- a/module/sharefolder/view/index/index.css +++ b/module/sharefolder/view/index/index.css @@ -1,151 +1,45 @@ -#wrapper { - width: 80%; + #dirindex article, + #dirindex footer { + display: block; margin: 0 auto; - text-align: left; -} + width: 480px; + } -body#left { - text-align: left; -} - -body#left #wrapper { - margin: 0 20px; -} - -#wrapper > h1 { - font-size: 21px; - padding: 0 10px; - margin: 20px 0 0; - font-weight: bold; -} - -#wrapper > h2 { - font-size: 11px; - padding: 0 10px; - margin: 10px 0 0; - color: #98a6ad; - font-weight: normal; -} - -#wrapper > a { - color: #003399; + #dirindex a { + color: #004466; text-decoration: none; -} - -#wrapper > a:hover { - color: #0066cc; + } + #dirindex a:hover { text-decoration: underline; -} - -#wrapper > ul#header { - margin-top: 20px; -} - -#wrapper > ul li { - display: block; - list-style-type: none; - overflow: hidden; - padding: 10px; -} - -#wrapper > ul li:hover { - background-color: #f3f3f3; -} - -#wrapper > ul li .date { - text-align: center; - width: 120px; -} - -#wrapper > ul li .size { - text-align: right; - width: 90px; -} - -#wrapper > ul li .date, -#wrapper > ul li .size { - float: right; - font-size: 12px; - display: block; + } + #dirindex a:visited { color: #666666; -} + } -#wrapper > ul#header li { - font-size: 11px; - font-weight: bold; - border-bottom: 1px solid #dee2e6; -} + #dirindex article { + background-color: #ffffff; + border: #cccccc solid 1px; + -moz-border-radius: 11px; + -webkit-border-radius: 11px; + border-radius: 11px; + padding: 0 1em; + } + #dirindex h1 { + font-size: 140%; + } + #dirindex ol { + line-height: 1.4em; + list-style-type: disc; + } + #dirindex li.directory a:before { + content: '[ '; + } + #dirindex li.directory a:after { + content: ' ]'; + } -#wrapper > ul#header li:hover { - background-color: transparent; -} - -#wrapper > ul#header li * { - color: #888888; - font-size: 11px; -} - -#wrapper > ul#header li a:hover { - color: #333333; -} - -#wrapper > ul#header li .asc span, -#wrapper > ul#header li .desc span { - padding-right: 15px; - background-position: right center; - background-repeat: no-repeat; -} - -#wrapper > ul#header li .asc span { - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABbSURBVCjPY/jPgB8yDCkFB/7v+r/5/+r/i/7P+N/3DYuC7V93/d//fydQ0Zz/9eexKFgtsejLiv8b/8/8X/WtUBGrGyZLdH6f8r/sW64cTkdWSRS+zpQbgiEJAI4UCqdRg1A6AAAAAElFTkSuQmCC'); -} - -#wrapper > ul#header li .desc span { - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABbSURBVCjPY/jPgB8yDDkFmyVWv14kh1PBeoll31f/n/ytUw6rgtUSi76s+L/x/8z/Vd8KFbEomPt16f/1/1f+X/S/7X/qeSwK+v63/K/6X/g/83/S/5hvQywkAdMGCdCoabZeAAAAAElFTkSuQmCC'); -} - -#wrapper > ul li.item { - border-top: 1px solid #f3f3f3; -} - -#wrapper > ul li.item:first-child { - border-top: none; -} - -#wrapper > ul li.item .name { - font-weight: bold; -} - -#wrapper > ul li.item .dir, -#wrapper > ul li.item .file { - padding-left: 20px; - background-position: left center; - background-repeat: no-repeat; -} - -#wrapper > ul li.item .dir { - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGrSURBVDjLxZO7ihRBFIa/6u0ZW7GHBUV0UQQTZzd3QdhMQxOfwMRXEANBMNQX0MzAzFAwEzHwARbNFDdwEd31Mj3X7a6uOr9BtzNjYjKBJ6nicP7v3KqcJFaxhBVtZUAK8OHlld2st7Xl3DJPVONP+zEUV4HqL5UDYHr5xvuQAjgl/Qs7TzvOOVAjxjlC+ePSwe6DfbVegLVuT4r14eTr6zvA8xSAoBLzx6pvj4l+DZIezuVkG9fY2H7YRQIMZIBwycmzH1/s3F8AapfIPNF3kQk7+kw9PWBy+IZOdg5Ug3mkAATy/t0usovzGeCUWTjCz0B+Sj0ekfdvkZ3abBv+U4GaCtJ1iEm6ANQJ6fEzrG/engcKw/wXQvEKxSEKQxRGKE7Izt+DSiwBJMUSm71rguMYhQKrBygOIRStf4TiFFRBvbRGKiQLWP29yRSHKBTtfdBmHs0BUpgvtgF4yRFR+NUKi0XZcYjCeCG2smkzLAHkbRBmP0/Uk26O5YnUActBp1GsAI+S5nRJJJal5K1aAMrq0d6Tm9uI6zjyf75dAe6tx/SsWeD//o2/Ab6IH3/h25pOAAAAAElFTkSuQmCC'); -} - -#wrapper > ul li.item .file { - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAABVklEQVQYGQXBP0hUAQAH4O/dnaaSXhIY2Z/NDAoaanUNorHJpbHBotZwT2hpL4iioTjUqb0hh3AqwYgw4xITgtCOvLI73/v1fUUArCx0bu5NMr7TfDEzDyAiYnmi1UuSJGn1Xk5GRBSxstCZ3Tur1jRlWnzyVYdqfKv5amZetA6SJGlnKWtZy2LaSZKkdRD1S8/qV+K4+OxQ2w9jSidVPuo03k0XS/2Lja5C3YYbgGVT+rpKm4e1dE85rWnUhA2VyoYTBu3pGZduIxgy4LcBHevo23VgABGNICrDzvij8tNfoxoKpVI0yuGa6Cv1FSqHjoCeQqUcquXtqo4RdZWgEvHPmJpNWa1V17dvvfnyQWFMA6WeEUe1rX/bvZtrRfB8Ivcyd/7YOaVthR1b+3mSR3e+UwTw9ELmM3u5+GXb/nIe3H4PFAHA46u5n8E8nHsNQBEAAADAf9MfuSUN80DGAAAAAElFTkSuQmCC'); -} - -#wrapper > #footer { - color: #98a6ad; - font-size: 11px; - margin-top: 40px; - margin-bottom: 20px; - padding: 0 10px; - text-align: left; -} - -#wrapper > #footer a { - color: #98a6ad; - font-weight: bold; -} - -#wrapper > #footer a:hover { - color: #777777; -} \ No newline at end of file + #dirindex footer { + font-size: 70%; + text-align: center; + } \ No newline at end of file diff --git a/module/sharefolder/view/index/index.php b/module/sharefolder/view/index/index.php index 4fcbd0d1..25607194 100644 --- a/module/sharefolder/view/index/index.php +++ b/module/sharefolder/view/index/index.php @@ -1,66 +1,6 @@ -getConfig('timezone', 'UTC')); - -$reverse = isset($_GET['r']) && $_GET['r'] === '1'; -$items = $reverse ? array_reverse($items) : $items; - - -if ($pdl->getConfig('show_parent') && $pdl->getPath() !== '/' && empty($pdl->getBrowse())) { - array_unshift($items, array('name' => '..', 'is_parent' => true, 'is_dir' => true, 'size' => 0, 'time' => 0)); -} -?> -getConfig('content_alignment') === 'left') echo 'id="left"' ?>> - -
      - -

      generateTitle() ?>

      -

      generateTitle(true) ?>

      - - - -
        - -
      • - - humanizeFilesize($item['size']) ?> - - - getConfig('date_format'), $item['time']) ?> - - - getConfig('browse_directories') && (!isset($item['is_parent']) || !$item['is_parent'])) { - if ($item['name'] === '..') { - $link = $pdl->buildLink(array('b' => substr($pdl->getBrowse(), 0, strrpos($pdl->getBrowse(), '/')))); - } else { - $link = $pdl->buildLink(array('b' => (empty($pdl->getBrowse()) ? '' : (string) $pdl->getBrowse() . '/') . $item['name'])); - } - } else { - $link = (empty($pdl->getBrowse()) ? '' : str_replace(['%2F', '%2f'], '/', rawurlencode((string)$pdl->getBrowse())) . '/') . rawurlencode($item['name']); - } - ?> - -
      • - -
      - - getConfig('show_footer')) : ?> - - -
      = - - - \ No newline at end of file +
      +
      +

      Répertoire

      + +
      +
      \ No newline at end of file From 69852c82bc8815999ed8f608e8002fbad9a542c7 Mon Sep 17 00:00:00 2001 From: F TEMPEZ Date: Wed, 13 Mar 2024 16:56:33 +0100 Subject: [PATCH 03/10] folder --- module/{sharefolder/sharefolder.php => folder/folder.php} | 6 +++--- module/{sharefolder => folder}/view/config/config.php | 0 module/{sharefolder => folder}/view/index/index.css | 5 ++++- module/{sharefolder => folder}/view/index/index.php | 0 4 files changed, 7 insertions(+), 4 deletions(-) rename module/{sharefolder/sharefolder.php => folder/folder.php} (92%) rename module/{sharefolder => folder}/view/config/config.php (100%) rename module/{sharefolder => folder}/view/index/index.css (98%) rename module/{sharefolder => folder}/view/index/index.php (100%) diff --git a/module/sharefolder/sharefolder.php b/module/folder/folder.php similarity index 92% rename from module/sharefolder/sharefolder.php rename to module/folder/folder.php index 3bbeca6b..36906d75 100644 --- a/module/sharefolder/sharefolder.php +++ b/module/folder/folder.php @@ -14,11 +14,11 @@ * @link http://zwiicms.fr/ */ -class sharefolder extends common +class folder extends common { const VERSION = '4.2'; - const REALNAME = 'Dossier partagé'; + const REALNAME = 'Dossier'; const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json) public static $actions = [ @@ -63,7 +63,7 @@ class sharefolder extends common $items .= ''; } else { // Afficher le nom du fichier comme un lien - $items .= '
    • ' . $element . '
    • '; + $items .= '
    • ' . $element . '
    • '; } } } diff --git a/module/sharefolder/view/config/config.php b/module/folder/view/config/config.php similarity index 100% rename from module/sharefolder/view/config/config.php rename to module/folder/view/config/config.php diff --git a/module/sharefolder/view/index/index.css b/module/folder/view/index/index.css similarity index 98% rename from module/sharefolder/view/index/index.css rename to module/folder/view/index/index.css index fc02cf04..95d5b869 100644 --- a/module/sharefolder/view/index/index.css +++ b/module/folder/view/index/index.css @@ -42,4 +42,7 @@ #dirindex footer { font-size: 70%; text-align: center; - } \ No newline at end of file + } + + + \ No newline at end of file diff --git a/module/sharefolder/view/index/index.php b/module/folder/view/index/index.php similarity index 100% rename from module/sharefolder/view/index/index.php rename to module/folder/view/index/index.php From 90a5a8a96aea4125eafa904981dca299b251c323 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Wed, 13 Mar 2024 18:45:06 +0100 Subject: [PATCH 04/10] folder config wip --- module/folder/folder.php | 85 ++++++++++++++++++++++++---- module/folder/view/config/config.css | 19 +++++++ module/folder/view/config/config.php | 33 +++++++++++ 3 files changed, 125 insertions(+), 12 deletions(-) create mode 100755 module/folder/view/config/config.css diff --git a/module/folder/folder.php b/module/folder/folder.php index 36906d75..ef7a281f 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -26,23 +26,52 @@ class folder extends common 'index' => self::GROUP_VISITOR, ]; - static $folders = ''; + // Contenu du chemin sélectionné + public static $folders = ''; - public function index() { + public static $sharePath = [ + '/site/file/source/' + ]; - self::$folders = $this->listerSousDossier( self::FILE_DIR . 'source/partage'); + public function index() + { - // Valeurs en sortie + self::$folders = $this->listerSousDossier(self::FILE_DIR . 'source/partage'); + + // Valeurs en sortie $this->addOutput([ 'showBarEditButton' => true, 'showPageContent' => true, 'view' => 'index' ]); - } + } - private function listerSousDossier($chemin) { + + public function config() + { + // Soumission du formulaire + if ( + $this->getUser('permission', __CLASS__, __FUNCTION__) === true && + $this->isPost() + ) { + $this->setData(['module', $this->getUrl(0), 'path', preg_replace('/^\\./', '', $this->getInput('folderEditPath')) ]); + + } + + self::$sharePath = $this->getSubdirectories('./site/file/source'); + self::$sharePath = array_flip(self::$sharePath); + + // Valeurs en sortie + $this->addOutput([ + 'view' => 'config' + ]); + } + + + private function listerSousDossier($chemin) + { // Vérifier si le chemin existe et est un dossier - if (is_dir($chemin)) { + if (is_dir($chemin)) { // Ouvrir le dossier if ($dh = opendir($chemin)) { $items = isset($items) ? $items . '
        ' : '
          '; @@ -53,7 +82,7 @@ class folder extends common if ($element != '.' && $element != '..') { // Construire le chemin complet de l'élément $cheminComplet = $chemin . '/' . $element; - + // Vérifier si c'est un dossier if (is_dir($cheminComplet)) { // Afficher le nom du dossier @@ -67,16 +96,48 @@ class folder extends common } } } - $items .= "
        "; - + $items .= "
      "; + // Fermer le dossier closedir($dh); } return $items; } else { - exit ('Erreur de chemin'); + exit('Erreur de chemin'); } - + + } + + /** + * Liste les dossier contenus dans RFM + */ + private function getSubdirectories($dir, $basePath = '') + { + $subdirs = array(); + // Ouvrez le répertoire spécifié + $dh = opendir($dir); + // Parcourez tous les fichiers et répertoires dans le répertoire + while (($file = readdir($dh)) !== false) { + // Ignorer les entrées de répertoire parent et actuel + if ($file == '.' || $file == '..') { + continue; + } + // Construisez le chemin complet du fichier ou du répertoire + $path = $dir . '/' . $file; + // Vérifiez si c'est un répertoire + if (is_dir($path)) { + // Construisez la clé et la valeur pour le tableau associatif + $key = $basePath === '' ? ucfirst($file) : $basePath . '/' . $file; + $value = $path . '/'; + // Ajouter la clé et la valeur au tableau associatif + $subdirs[$key] = $value; + // Appeler la fonction récursivement pour ajouter les sous-répertoires + $subdirs = array_merge($subdirs, $this->getSubdirectories($path, $key)); + } + } + // Fermez le gestionnaire de dossier + closedir($dh); + return $subdirs; } } \ No newline at end of file diff --git a/module/folder/view/config/config.css b/module/folder/view/config/config.css new file mode 100755 index 00000000..f3cc838d --- /dev/null +++ b/module/folder/view/config/config.css @@ -0,0 +1,19 @@ + +/** + * This file is part of Zwii. + * + * For full copyright and license information, please see the LICENSE + * file that was distributed with this source code. + * + * @author Rémi Jean + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2024, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.fr/ + */ + +/** NE PAS EFFACER +* admin.css +*/ + diff --git a/module/folder/view/config/config.php b/module/folder/view/config/config.php index e69de29b..71104a7e 100644 --- a/module/folder/view/config/config.php +++ b/module/folder/view/config/config.php @@ -0,0 +1,33 @@ + +
      +
      + 'buttonGrey', + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), + 'value' => template::ico('left') + ]); ?> +
      +
      + +
      +
      +
      +
      +
      +

      +
      +
      + 'Dossier', + 'class' => 'filemanager', + 'selected' => '.' . $this->getData(['module', $this->getUrl(0), 'path']) + ]); ?> +
      +
      +
      +
      +
      + +
      Version n° + +
      \ No newline at end of file From 25d6192e0e44e40bbc99b41881ea615034385223 Mon Sep 17 00:00:00 2001 From: F TEMPEZ Date: Thu, 14 Mar 2024 08:50:23 +0100 Subject: [PATCH 05/10] folder css okay --- module/folder/folder.php | 23 ++++++++-------- module/folder/view/index/index.css | 44 ++++++++++++------------------ 2 files changed, 29 insertions(+), 38 deletions(-) diff --git a/module/folder/folder.php b/module/folder/folder.php index ef7a281f..4d50b9d1 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -17,8 +17,8 @@ class folder extends common { - const VERSION = '4.2'; - const REALNAME = 'Dossier'; + const VERSION = '0.1'; + const REALNAME = 'Partage de dossier'; const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json) public static $actions = [ @@ -74,7 +74,7 @@ class folder extends common if (is_dir($chemin)) { // Ouvrir le dossier if ($dh = opendir($chemin)) { - $items = isset($items) ? $items . '
        ' : '
          '; + $items = isset($items) ? $items . '
            ' : '
              '; //$items = '
                '; // Parcourir les éléments du dossier while (($element = readdir($dh)) !== false) { @@ -82,31 +82,30 @@ class folder extends common if ($element != '.' && $element != '..') { // Construire le chemin complet de l'élément $cheminComplet = $chemin . '/' . $element; - + // Vérifier si c'est un dossier if (is_dir($cheminComplet)) { - // Afficher le nom du dossier - $items .= "
              • $element"; + // Afficher le nom du dossier avec un élément details + $items .= "
              • $element"; // Appeler récursivement la fonction pour ce sous-dossier $items .= $this->listerSousDossier($cheminComplet); - $items .= '
              • '; + $items .= ''; } else { // Afficher le nom du fichier comme un lien - $items .= '
              • ' . $element . '
              • '; + $items .= "
              • $element
              • "; } } } $items .= "
              "; - + // Fermer le dossier closedir($dh); } return $items; - } else { - exit('Erreur de chemin'); } - } + + /** * Liste les dossier contenus dans RFM diff --git a/module/folder/view/index/index.css b/module/folder/view/index/index.css index 95d5b869..24033c3b 100644 --- a/module/folder/view/index/index.css +++ b/module/folder/view/index/index.css @@ -1,6 +1,5 @@ - #dirindex article, - #dirindex footer { + #dirindex article{ display: block; margin: 0 auto; width: 480px; @@ -17,32 +16,25 @@ color: #666666; } - #dirindex article { - background-color: #ffffff; - border: #cccccc solid 1px; - -moz-border-radius: 11px; - -webkit-border-radius: 11px; - border-radius: 11px; - padding: 0 1em; - } - #dirindex h1 { - font-size: 140%; - } - #dirindex ol { - line-height: 1.4em; - list-style-type: disc; - } - #dirindex li.directory a:before { - content: '[ '; - } - #dirindex li.directory a:after { - content: ' ]'; + #dirindex details summary, #dirindex details summary::-webkit-details-marker { + list-style: none; + cursor: pointer; } - #dirindex footer { - font-size: 70%; - text-align: center; + #dirindex ul { + list-style: none; } +.directory { + background: url('data:image/svg+xml;base64,PHN2ZyBhcmlhLWhpZGRlbj0idHJ1ZSIgZm9jdXNhYmxlPSJmYWxzZSIgZGF0YS1wcmVmaXg9ImZhcyIgZGF0YS1pY29uPSJmb2xkZXIiIGNsYXNzPSJzdmctaW5saW5lLS1mYSBmYS1mb2xkZXIgZmEtdy0xNiIgcm9sZT0iaW1nIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSJjdXJyZW50Q29sb3IiIGQ9Ik00NjQgMTI4SDI3MmwtNjQtNjRINDhDMjEuNDkgNjQgMCA4NS40OSAwIDExMnYyODhjMCAyNi41MSAyMS40OSA0OCA0OCA0OGg0MTZjMjYuNTEgMCA0OC0yMS40OSA0OC00OFYxNzZjMC0yNi41MS0yMS40OS00OC00OC00OHoiPjwvcGF0aD48L3N2Zz4=') no-repeat left top; + height: 20px; + padding-top: 7px; + padding-left: 30px; + } - \ No newline at end of file +.file{ + background: url('data:image/svg+xml;base64,PHN2ZyBhcmlhLWhpZGRlbj0idHJ1ZSIgZm9jdXNhYmxlPSJmYWxzZSIgZGF0YS1wcmVmaXg9ImZhbCIgZGF0YS1pY29uPSJmaWxlIiByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDM4NCA1MTIiIGNsYXNzPSJzdmctaW5saW5lLS1mYSBmYS1maWxlIGZhLXctMTIgZmEtM3giPjxwYXRoIGZpbGw9ImN1cnJlbnRDb2xvciIgZD0iTTM2OS45IDk3LjlMMjg2IDE0QzI3NyA1IDI2NC44LS4xIDI1Mi4xLS4xSDQ4QzIxLjUgMCAwIDIxLjUgMCA0OHY0MTZjMCAyNi41IDIxLjUgNDggNDggNDhoMjg4YzI2LjUgMCA0OC0yMS41IDQ4LTQ4VjEzMS45YzAtMTIuNy01LjEtMjUtMTQuMS0zNHptLTIyLjYgMjIuN2MyLjEgMi4xIDMuNSA0LjYgNC4yIDcuNEgyNTZWMzIuNWMyLjguNyA1LjMgMi4xIDcuNCA0LjJsODMuOSA4My45ek0zMzYgNDgwSDQ4Yy04LjggMC0xNi03LjItMTYtMTZWNDhjMC04LjggNy4yLTE2IDE2LTE2aDE3NnYxMDRjMCAxMy4zIDEwLjcgMjQgMjQgMjRoMTA0djMwNGMwIDguOC03LjIgMTYtMTYgMTZ6IiBjbGFzcz0iIj48L3BhdGg+PC9zdmc+') no-repeat left top; + height: 20px; + padding-top: 7px; + padding-left: 30px; + } From d8525bf12322118f0b1bdfd196d620536bc1f289 Mon Sep 17 00:00:00 2001 From: F TEMPEZ Date: Thu, 14 Mar 2024 10:28:27 +0100 Subject: [PATCH 06/10] fix user path select --- module/folder/folder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/folder/folder.php b/module/folder/folder.php index 4d50b9d1..4cab1acb 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -58,7 +58,7 @@ class folder extends common } - self::$sharePath = $this->getSubdirectories('./site/file/source'); + self::$sharePath = $this->getSubdirectories('site/file/source'); self::$sharePath = array_flip(self::$sharePath); // Valeurs en sortie From 68d0aaff840d938b53e7cd603c2ba0420118c028 Mon Sep 17 00:00:00 2001 From: F TEMPEZ Date: Thu, 14 Mar 2024 13:33:37 +0100 Subject: [PATCH 07/10] Okay mais probleme de surimpressions --- module/folder/folder.php | 15 +++++++++++---- module/folder/view/config/config.php | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/module/folder/folder.php b/module/folder/folder.php index 4cab1acb..9abced3c 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -30,13 +30,13 @@ class folder extends common public static $folders = ''; public static $sharePath = [ - '/site/file/source/' + 'site/file/source/' ]; public function index() { - self::$folders = $this->listerSousDossier(self::FILE_DIR . 'source/partage'); + self::$folders = $this->getFolderContent($this->getData(['module', $this->getUrl(0), 'path'])); // Valeurs en sortie $this->addOutput([ @@ -56,6 +56,13 @@ class folder extends common ) { $this->setData(['module', $this->getUrl(0), 'path', preg_replace('/^\\./', '', $this->getInput('folderEditPath')) ]); + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0), + 'notification' => helper::translate('Modifications enregistrées'), + 'state' => true + ]); + } self::$sharePath = $this->getSubdirectories('site/file/source'); @@ -68,7 +75,7 @@ class folder extends common } - private function listerSousDossier($chemin) + private function getFolderContent($chemin) { // Vérifier si le chemin existe et est un dossier if (is_dir($chemin)) { @@ -88,7 +95,7 @@ class folder extends common // Afficher le nom du dossier avec un élément details $items .= "
            • $element"; // Appeler récursivement la fonction pour ce sous-dossier - $items .= $this->listerSousDossier($cheminComplet); + $items .= $this->getFolderContent($cheminComplet); $items .= '
            • '; } else { // Afficher le nom du fichier comme un lien diff --git a/module/folder/view/config/config.php b/module/folder/view/config/config.php index 71104a7e..b38dd561 100644 --- a/module/folder/view/config/config.php +++ b/module/folder/view/config/config.php @@ -20,7 +20,7 @@ 'Dossier', 'class' => 'filemanager', - 'selected' => '.' . $this->getData(['module', $this->getUrl(0), 'path']) + 'selected' => $this->getData(['module', $this->getUrl(0), 'path']) ]); ?> From f86f38d8b00b4a2cf1eeb9d32ac89cd00b1bda76 Mon Sep 17 00:00:00 2001 From: F TEMPEZ Date: Thu, 14 Mar 2024 14:30:49 +0100 Subject: [PATCH 08/10] Fix folder and icons --- module/folder/folder.php | 72 +++++++++++++++--------------- module/folder/view/index/index.css | 22 ++++----- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/module/folder/folder.php b/module/folder/folder.php index 9abced3c..38874056 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -75,42 +75,42 @@ class folder extends common } - private function getFolderContent($chemin) - { - // Vérifier si le chemin existe et est un dossier - if (is_dir($chemin)) { - // Ouvrir le dossier - if ($dh = opendir($chemin)) { - $items = isset($items) ? $items . '
                ' : '
                  '; - //$items = '
                    '; - // Parcourir les éléments du dossier - while (($element = readdir($dh)) !== false) { - // Exclure les éléments spéciaux - if ($element != '.' && $element != '..') { - // Construire le chemin complet de l'élément - $cheminComplet = $chemin . '/' . $element; - - // Vérifier si c'est un dossier - if (is_dir($cheminComplet)) { - // Afficher le nom du dossier avec un élément details - $items .= "
                  • $element"; - // Appeler récursivement la fonction pour ce sous-dossier - $items .= $this->getFolderContent($cheminComplet); - $items .= '
                  • '; - } else { - // Afficher le nom du fichier comme un lien - $items .= "
                  • $element
                  • "; - } - } - } - $items .= "
                  "; - - // Fermer le dossier - closedir($dh); - } - return $items; - } - } +private function getFolderContent($chemin) +{ + // Vérifier si le chemin existe et est un dossier + if (is_dir($chemin)) { + // Ouvrir le dossier + if ($dh = opendir($chemin)) { + $items = isset($items) ? $items . '
                    ' : '
                      '; + // Parcourir les éléments du dossier + while (($element = readdir($dh)) !== false) { + // Exclure les éléments spéciaux + if ($element != '.' && $element != '..') { + // Construire le chemin complet de l'élément + $cheminComplet = $chemin . $element; + + // Vérifier si c'est un dossier + if (is_dir($cheminComplet)) { + // Afficher le nom du dossier avec un élément details + $items .= "
                    • $element
                        "; + // Appeler récursivement la fonction pour ce sous-dossier + $items .= $this->getFolderContent($cheminComplet); + $items .= '
                    • '; + } else { + // Afficher le nom du fichier comme un lien + $items .= "
                    • $element
                    • "; + } + } + } + $items .= "
                    "; + + // Fermer le dossier + closedir($dh); + } + return $items; + } +} + diff --git a/module/folder/view/index/index.css b/module/folder/view/index/index.css index 24033c3b..cd23dace 100644 --- a/module/folder/view/index/index.css +++ b/module/folder/view/index/index.css @@ -21,20 +21,20 @@ cursor: pointer; } - #dirindex ul { + #dirindex { list-style: none; } -.directory { - background: url('data:image/svg+xml;base64,PHN2ZyBhcmlhLWhpZGRlbj0idHJ1ZSIgZm9jdXNhYmxlPSJmYWxzZSIgZGF0YS1wcmVmaXg9ImZhcyIgZGF0YS1pY29uPSJmb2xkZXIiIGNsYXNzPSJzdmctaW5saW5lLS1mYSBmYS1mb2xkZXIgZmEtdy0xNiIgcm9sZT0iaW1nIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSJjdXJyZW50Q29sb3IiIGQ9Ik00NjQgMTI4SDI3MmwtNjQtNjRINDhDMjEuNDkgNjQgMCA4NS40OSAwIDExMnYyODhjMCAyNi41MSAyMS40OSA0OCA0OCA0OGg0MTZjMjYuNTEgMCA0OC0yMS40OSA0OC00OFYxNzZjMC0yNi41MS0yMS40OS00OC00OC00OHoiPjwvcGF0aD48L3N2Zz4=') no-repeat left top; - height: 20px; - padding-top: 7px; - padding-left: 30px; + #dirindex .directory { + list-style-type: "\1F4C1"; } -.file{ - background: url('data:image/svg+xml;base64,PHN2ZyBhcmlhLWhpZGRlbj0idHJ1ZSIgZm9jdXNhYmxlPSJmYWxzZSIgZGF0YS1wcmVmaXg9ImZhbCIgZGF0YS1pY29uPSJmaWxlIiByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDM4NCA1MTIiIGNsYXNzPSJzdmctaW5saW5lLS1mYSBmYS1maWxlIGZhLXctMTIgZmEtM3giPjxwYXRoIGZpbGw9ImN1cnJlbnRDb2xvciIgZD0iTTM2OS45IDk3LjlMMjg2IDE0QzI3NyA1IDI2NC44LS4xIDI1Mi4xLS4xSDQ4QzIxLjUgMCAwIDIxLjUgMCA0OHY0MTZjMCAyNi41IDIxLjUgNDggNDggNDhoMjg4YzI2LjUgMCA0OC0yMS41IDQ4LTQ4VjEzMS45YzAtMTIuNy01LjEtMjUtMTQuMS0zNHptLTIyLjYgMjIuN2MyLjEgMi4xIDMuNSA0LjYgNC4yIDcuNEgyNTZWMzIuNWMyLjguNyA1LjMgMi4xIDcuNCA0LjJsODMuOSA4My45ek0zMzYgNDgwSDQ4Yy04LjggMC0xNi03LjItMTYtMTZWNDhjMC04LjggNy4yLTE2IDE2LTE2aDE3NnYxMDRjMCAxMy4zIDEwLjcgMjQgMjQgMjRoMTA0djMwNGMwIDguOC03LjIgMTYtMTYgMTZ6IiBjbGFzcz0iIj48L3BhdGg+PC9zdmc+') no-repeat left top; - height: 20px; - padding-top: 7px; - padding-left: 30px; + #dirindex .file { + list-style-type: "\1F4C4"; } + + #dirindex ul li { + margin-top: 5px; + } + + From 5846c111fe764b1eb0f2cf654e23b4d3ad7e6aba Mon Sep 17 00:00:00 2001 From: F TEMPEZ Date: Thu, 14 Mar 2024 15:46:31 +0100 Subject: [PATCH 09/10] CSS okay --- module/folder/folder.php | 6 +-- module/folder/view/index/index.css | 69 ++++++++++++++++-------------- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/module/folder/folder.php b/module/folder/folder.php index 38874056..f79022bf 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -81,7 +81,7 @@ private function getFolderContent($chemin) if (is_dir($chemin)) { // Ouvrir le dossier if ($dh = opendir($chemin)) { - $items = isset($items) ? $items . '
                      ' : '
                        '; + $items = isset($items) ? $items : '
                          '; // Parcourir les éléments du dossier while (($element = readdir($dh)) !== false) { // Exclure les éléments spéciaux @@ -92,10 +92,10 @@ private function getFolderContent($chemin) // Vérifier si c'est un dossier if (is_dir($cheminComplet)) { // Afficher le nom du dossier avec un élément details - $items .= "
                        • $element
                            "; + $items .= "
                          • $element"; // Appeler récursivement la fonction pour ce sous-dossier $items .= $this->getFolderContent($cheminComplet); - $items .= '
                        • '; + $items .= ''; } else { // Afficher le nom du fichier comme un lien $items .= "
                        • $element
                        • "; diff --git a/module/folder/view/index/index.css b/module/folder/view/index/index.css index cd23dace..ac52c9db 100644 --- a/module/folder/view/index/index.css +++ b/module/folder/view/index/index.css @@ -1,40 +1,45 @@ +#dirindex article { + display: block; + margin: 0 auto; + width: 480px; +} - #dirindex article{ - display: block; - margin: 0 auto; - width: 480px; - } +#dirindex a { + color: #004466; + text-decoration: none; +} - #dirindex a { - color: #004466; - text-decoration: none; - } - #dirindex a:hover { - text-decoration: underline; - } - #dirindex a:visited { - color: #666666; - } +#dirindex a:hover { + text-decoration: underline; +} - #dirindex details summary, #dirindex details summary::-webkit-details-marker { - list-style: none; - cursor: pointer; - } +#dirindex a:visited { + color: #666666; +} - #dirindex { - list-style: none; - } - - #dirindex .directory { - list-style-type: "\1F4C1"; - } +#dirindex details summary, +#dirindex details summary::-webkit-details-marker { + list-style: none; + cursor: pointer; +} - #dirindex .file { - list-style-type: "\1F4C4"; - } +#dirindex { + list-style: none; +} - #dirindex ul li { - margin-top: 5px; - } +#dirindex .directory { + list-style-type: "\1F4C1"; +} +#dirindex .file { + list-style-type: "\1F4C4"; +} +#dirindex ul li { + margin-top: 10px; +} + +#dirindex li { + padding-left: 5px; + list-style-position : outside; +} \ No newline at end of file From f924a2b2b3a8a6c53ce050da64e57ac76d388872 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Thu, 14 Mar 2024 19:09:00 +0100 Subject: [PATCH 10/10] stop on json data error --- core/class/jsondb/JsonDb.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/class/jsondb/JsonDb.class.php b/core/class/jsondb/JsonDb.class.php index 3e3b26cf..0061417b 100644 --- a/core/class/jsondb/JsonDb.class.php +++ b/core/class/jsondb/JsonDb.class.php @@ -129,7 +129,7 @@ class JsonDb extends \Prowebcraft\Dot } } $this->data = json_decode(file_get_contents($this->db), true); - if (!$this->data === null) { + if (!$this->data === null && json_last_error() !== JSON_ERROR_NONE) { throw new \InvalidArgumentException('Database file ' . $this->db . ' contains invalid json object. Please validate or remove file'); }