From 42ec9e29b4a0152bfe8fd253ec8177982257732a Mon Sep 17 00:00:00 2001 From: Alan Garcia Date: Fri, 31 Jan 2014 17:46:09 +0000 Subject: [PATCH] Gere dans l'affichage le type attendu. --- bureau/admin/adm_var_edit.php | 99 +++++++++++++++++++++++++++++------ bureau/class/m_variables.php | 2 +- 2 files changed, 85 insertions(+), 16 deletions(-) diff --git a/bureau/admin/adm_var_edit.php b/bureau/admin/adm_var_edit.php index 3734c8fa..8a30c1c9 100644 --- a/bureau/admin/adm_var_edit.php +++ b/bureau/admin/adm_var_edit.php @@ -22,10 +22,57 @@ $fields = array ( getFields($fields); variable_get("aaa_test3", -array("ns1"=> array("ns"=>"ns1.%%FQDN%%", "ip"=>"%%PUBLIC_IP%%", "enabled"=>"%%ENABLED%%"), "ns2"=>array("ns"=>"fdsffsd", "ip"=>"fdsfdfds", "enabled"=>"fds"), 'ns55'=> 'arf' ), +array( + "ns1"=> + array( + "ns"=>"ns1.%%FQDN%%", + "ip"=>"%%PUBLIC_IP%%", + "enabled"=>"%%ENABLED%%"), + "ns2"=> + array( + "ns"=>"fdsffsd", + "ip"=>"fdsfdfds", + "enabled"=>"fds"), + 'ns55'=> 'arf' +), "This is a test!", -array("ns1"=> array("ns"=>"ns name", "ip"=>"ip address", "enabled"=>"enabled"), "ns2"=>array("ns"=>"ns name", "ip"=>"ip address", "enabled"=>"enabled"), 'ns3'=>'toto' ) -); +array( + "ns1"=> + array( + "ns"=> + array( + 'desc'=>"ns name", + 'type'=>'string'), + "ip"=> + array( + 'desc'=>"ip address", + 'type'=>'ip'), + "enabled"=> + array( + 'desc'=>"enabled", + 'type'=>"boolean"), + ), + "ns2"=>array( + "ns"=> + array( + 'desc'=>"ns name", + 'type'=>'string'), + "ip"=> + array( + 'desc'=>"ip address", + 'type'=>'ip'), + "enabled"=> + array( + 'desc'=>"enabled", + 'type'=>"boolean"), + ), + "ns3"=>array( + "desc"=>"here another", + "type"=>"integer", + ), +) + ); + if (empty($var)) { echo "

";__("Missing var name");echo "

"; @@ -69,27 +116,50 @@ echo ""; echo "
"; +function var_input($infotype, $name, $value='') { + $id = rand(); + echo ""; + switch(strtolower($infotype['type'])) { + case "string": + echo ""; + break; + case "integer": + echo ""; + break; + case "ip": + echo ""; + break; + case "boolean": + echo ""; // This way, there is allways something send, even if checkbox is unchecked + echo ""; + break; + default: + echo "WTF ? Dunno what to do with a ".$infotype['type']; + break; + } +} + function edit_var($var_arr) { global $allvars; echo "
"; echo ""; if (is_array( $allvars['DEFAULT'][null][$var_arr['name']]['type'] )) { echo "
    "; - foreach ($allvars['DEFAULT'][null][$var_arr['name']]['type'] as $kk => $vv) { + $infotype = $allvars['DEFAULT'][null][$var_arr['name']]['type']; + //foreach ($allvars['DEFAULT'][null][$var_arr['name']]['type'] as $kk => $vv) { + foreach ($var_arr['value'] as $kk => $vv) { echo "
  • "; if ( is_array($vv)) { echo $kk; echo "
      "; foreach ($vv as $ll => $mm ) { echo "
    • "; - echo ""; - echo ""; + var_input($infotype[$kk][$ll], "var_value_arr[$kk][$ll]", $var_arr['value'][$kk][$ll] ); echo "
    • "; } echo "
    "; } else { - echo ""; - echo ""; + var_input($infotype[$kk], "var_value_arr[$kk]", $var_arr['value'][$kk]); } echo "
  • "; } @@ -100,8 +170,8 @@ function edit_var($var_arr) { echo "
    "; echo ""; - echo ""; echo ""; + echo ""; echo "
"; echo ""; @@ -117,23 +187,22 @@ function add_var($stratatata, $stratatata_arr=null) { eoption($stratatata_arr, null); echo " "; } - if (is_array( $allvars['DEFAULT'][null][$var]['type'] )) { + $infotype = $allvars['DEFAULT'][null][$var]['type']; + if (is_array( $infotype )) { echo "