From e81a72757cddacaf75639cafcb11b214cd3fc7e1 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 3 Feb 2016 08:34:27 +0100 Subject: [PATCH] - [x] Configuration JSON du dispatcher - [x] Gestion des extensions/headers - [x] Gestion de l'arbre virtuel des fichiers --- config/dispatcher-extensions.json | 7 +++++++ config/dispatcher-tree.json | 8 +++++++ manager/Dispatcher.php | 35 ++++++++++++++++++++++++++----- todo.md | 6 +++++- 4 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 config/dispatcher-extensions.json create mode 100644 config/dispatcher-tree.json diff --git a/config/dispatcher-extensions.json b/config/dispatcher-extensions.json new file mode 100644 index 0000000..58ba435 --- /dev/null +++ b/config/dispatcher-extensions.json @@ -0,0 +1,7 @@ +{ + "extensions": { + "svg": "image/svg+xml", + "css": "text/css", + "js": "text/js" + } +} \ No newline at end of file diff --git a/config/dispatcher-tree.json b/config/dispatcher-tree.json new file mode 100644 index 0000000..b4469a1 --- /dev/null +++ b/config/dispatcher-tree.json @@ -0,0 +1,8 @@ +{ + "parents": { + "st" : "/src/static", + "dy" : "/src/dynamic", + "css" : "/css", + "js" : "/js" + } +} \ No newline at end of file diff --git a/manager/Dispatcher.php b/manager/Dispatcher.php index b5fa2bd..6a9560f 100755 --- a/manager/Dispatcher.php +++ b/manager/Dispatcher.php @@ -6,10 +6,13 @@ class Dispatcher{ // Constantes (a dispatcher dans un .conf) - public static $supported_extensions = array('svg'); - public static $supported_extensions_header = array('image/svg+xml'); - public static $supported_parents = array('st', 'dy'); - public static $supported_parents_folder = array('/src/static', '/src/dynamic'); + public static $extension_config_path = '/config/dispatcher-extensions.json'; + 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; @@ -27,6 +30,29 @@ * */ public function __construct($url){ + /* [0] On met a jour la configuration + =====================================================*/ + // 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); + } + + // 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(); + + 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 ==================================================*/ $serialFlags = array_slice( explode('/',$url), 1 ); @@ -47,7 +73,6 @@ $this->view(); - return true; } diff --git a/todo.md b/todo.md index 5763806..4296933 100644 --- a/todo.md +++ b/todo.md @@ -13,7 +13,8 @@ ############ # 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 @@ -23,6 +24,9 @@ ######## # FAIT # ######## +- [x] Configuration JSON du dispatcher + - [x] Gestion des extensions/headers + - [x] Gestion de l'arbre virtuel des fichiers - [x] Design de structure (layout navigation) - [x] Header - [x] Menu-side