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'); } 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/folder/folder.php b/module/folder/folder.php new file mode 100644 index 00000000..f79022bf --- /dev/null +++ b/module/folder/folder.php @@ -0,0 +1,149 @@ + + * @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 folder extends common +{ + + 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 = [ + 'config' => self::GROUP_EDITOR, + 'index' => self::GROUP_VISITOR, + ]; + + // Contenu du chemin sélectionné + public static $folders = ''; + + public static $sharePath = [ + 'site/file/source/' + ]; + + public function index() + { + + self::$folders = $this->getFolderContent($this->getData(['module', $this->getUrl(0), 'path'])); + + // Valeurs en sortie + $this->addOutput([ + 'showBarEditButton' => true, + 'showPageContent' => true, + 'view' => 'index' + ]); + } + + + 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')) ]); + + // 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'); + self::$sharePath = array_flip(self::$sharePath); + + // Valeurs en sortie + $this->addOutput([ + 'view' => 'config' + ]); + } + + +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 : '"; + + // Fermer le dossier + closedir($dh); + } + return $items; + } +} + + + + + /** + * 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 new file mode 100644 index 00000000..b38dd561 --- /dev/null +++ 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 diff --git a/module/folder/view/index/index.css b/module/folder/view/index/index.css new file mode 100644 index 00000000..ac52c9db --- /dev/null +++ b/module/folder/view/index/index.css @@ -0,0 +1,45 @@ +#dirindex article { + display: block; + margin: 0 auto; + width: 480px; +} + +#dirindex a { + color: #004466; + text-decoration: none; +} + +#dirindex a:hover { + text-decoration: underline; +} + +#dirindex a:visited { + color: #666666; +} + +#dirindex details summary, +#dirindex details summary::-webkit-details-marker { + list-style: none; + cursor: pointer; +} + +#dirindex { + list-style: none; +} + +#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 diff --git a/module/folder/view/index/index.php b/module/folder/view/index/index.php new file mode 100644 index 00000000..25607194 --- /dev/null +++ b/module/folder/view/index/index.php @@ -0,0 +1,6 @@ +
+
+

Répertoire

+ +
+
\ No newline at end of file