From f35cd776b521bf3d8835f3cbb4b50ec7f30ca18f Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 3 Feb 2016 10:13:31 +0100 Subject: [PATCH] - [x] Configuration JSON du dispatcher - [x] Simplification de 2 tableaux lies par indice en 1 --- manager/ResourcesDispatcher.php | 41 +++++-------------- src/static/sub-menu-side/analytics.svg | 54 +++++++++++++++++++++++++ src/static/sub-menu-side/sync.svg | 55 ++++++++++++++++++++++++++ todo.md | 4 +- view/sync.php | 28 +++++-------- 5 files changed, 129 insertions(+), 53 deletions(-) create mode 100644 src/static/sub-menu-side/analytics.svg create mode 100644 src/static/sub-menu-side/sync.svg diff --git a/manager/ResourcesDispatcher.php b/manager/ResourcesDispatcher.php index c33fd5b..5c2dac8 100755 --- a/manager/ResourcesDispatcher.php +++ b/manager/ResourcesDispatcher.php @@ -10,9 +10,7 @@ public static $parents_config_path = '/config/dispatcher-tree.json'; public static $supported_extensions; - public static $supported_extensions_header; public static $supported_parents; - public static $supported_parents_folder; // Attributs prives utiles (initialisation) private $header; @@ -34,23 +32,12 @@ =====================================================*/ // Extensions supportees $extensions_conf = json_decode( file_get_contents('http://'.$_SERVER['HTTP_HOST'].self::$extension_config_path), true )['extensions']; - self::$supported_extensions = array(); - self::$supported_extensions_header = array(); - - foreach($extensions_conf as $ext=>$head){ - array_push(self::$supported_extensions, $ext); - array_push(self::$supported_extensions_header, $head); - } + self::$supported_extensions = $extensions_conf; // Dossiers supportes $parents_conf = json_decode( file_get_contents('http://'.$_SERVER['HTTP_HOST'].self::$parents_config_path), true )['parents']; - self::$supported_parents = array(); - self::$supported_parents_folder = array(); + self::$supported_parents = $parents_conf; - foreach($parents_conf as $alias=>$folder){ - array_push(self::$supported_parents, $alias); - array_push(self::$supported_parents_folder, $folder); - } /* [1] On recupere les donnees de l'URL @@ -96,13 +83,13 @@ $correct = $correct && count($serialFlags) >= 3; // Verification que l'extension est correcte - $correct = $correct && array_search($serialFlags[0], self::$supported_extensions) !== false; + $correct = $correct && array_key_exists($serialFlags[0], self::$supported_extensions); // Verification du filename $correct = $correct && preg_match('#^[\w_-]+$#i', $serialFlags[1]); // Verification du parent - $correct = $correct && array_search($serialFlags[2], self::$supported_parents) !== false; + $correct = $correct && array_key_exists($serialFlags[2], self::$supported_parents); // Verification du sous-parent (optionnel) $opt_subParent = count($serialFlags) >= 4; @@ -147,16 +134,11 @@ private function buildPath(){ /* [1] On recupere le HEADER associe a l'extension ==========================================================*/ - $index_header = array_search($this->flags['extension'], self::$supported_extensions); - - // Si l'extension n'est pas repertoriee, on retourne une erreur - if( $index_header === false ) return false; - - // Si aucun header pour cet indice, on retourne une erreur - if( !isset(self::$supported_extensions_header[$index_header]) ) return false; + // Si aucun header pour cet cle, on retourne une erreur + if( !isset(self::$supported_extensions[$this->flags['extension']]) ) return false; // On recupere le header associe - $header = self::$supported_extensions_header[$index_header]; + $header = self::$supported_extensions[$this->flags['extension']]; @@ -164,16 +146,11 @@ /* [2] On recupere le chemin associe au parent ==========================================================*/ - $index_parent = array_search($this->flags['parent'], self::$supported_parents); - - // Si le parent n'est pas repertorie, on retourne une erreur - if( $index_parent === false ) return false; - // Si aucun dossier pour cet indice, on retourne une erreur - if( !isset(self::$supported_parents_folder[$index_parent]) ) return false; + if( !isset(self::$supported_parents[$this->flags['parent']]) ) return false; // On recupere le dossier associe - $parent = self::$supported_parents_folder[$index_parent]; + $parent = self::$supported_parents[$this->flags['parent']]; /* [3] Gestion du sous-parent optionnel diff --git a/src/static/sub-menu-side/analytics.svg b/src/static/sub-menu-side/analytics.svg new file mode 100644 index 0000000..1d54037 --- /dev/null +++ b/src/static/sub-menu-side/analytics.svg @@ -0,0 +1,54 @@ + +image/svg+xml \ No newline at end of file diff --git a/src/static/sub-menu-side/sync.svg b/src/static/sub-menu-side/sync.svg new file mode 100644 index 0000000..e54a358 --- /dev/null +++ b/src/static/sub-menu-side/sync.svg @@ -0,0 +1,55 @@ + +image/svg+xml \ No newline at end of file diff --git a/todo.md b/todo.md index 4296933..6da5c72 100644 --- a/todo.md +++ b/todo.md @@ -13,8 +13,6 @@ ############ # EN COURS # ############ -- [ ] Configuration JSON du dispatcher - - [ ] Simplification de 2 tableaux lies par indice en 1 - [.] Gestion JS de la navigation - [x] Gestion de liens+URL du menu @@ -24,6 +22,8 @@ ######## # FAIT # ######## +- [x] Configuration JSON du dispatcher + - [x] Simplification de 2 tableaux lies par indice en 1 - [x] Configuration JSON du dispatcher - [x] Gestion des extensions/headers - [x] Gestion de l'arbre virtuel des fichiers diff --git a/view/sync.php b/view/sync.php index 3716622..64721cf 100644 --- a/view/sync.php +++ b/view/sync.php @@ -1,29 +1,19 @@