Gere les tableaux de tableaux dans les variables.

This commit is contained in:
Alan Garcia 2014-01-31 15:21:36 +00:00
parent 2c5c290f22
commit b2d4200034
2 changed files with 56 additions and 7 deletions

View File

@ -21,6 +21,11 @@ $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' ),
"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' )
);
if (empty($var)) {
echo "<p class='error'>";__("Missing var name");echo "</p>";
@ -72,8 +77,20 @@ function edit_var($var_arr) {
echo "<ul>";
foreach ($allvars['DEFAULT'][null][$var_arr['name']]['type'] as $kk => $vv) {
echo "<li>";
if ( is_array($vv)) {
echo $kk;
echo "<ul>";
foreach ($vv as $ll => $mm ) {
echo "<li>";
echo "<label for='add_for_${ll}_$mm'>$mm</label>";
echo "<input type='text' class='int' id='add_for_${ll}_$mm' name='var_value_arr[$kk][$ll]' value='";ehe($var_arr['value'][$kk][$ll]); echo "' size='30' />";
echo "</li>";
}
echo "</ul>";
} else {
echo "<label for='edit_for_${var_arr['id']}'>".$vv."</label>";
echo "<input type='text' class='int' id='edit_for_${var_arr['id']}' name='var_value_arr[$kk]' value='";ehe($var_arr['value'][$kk]); echo "' size='30' />";
}
echo "</li>";
}
echo "</ul>";
@ -104,8 +121,20 @@ function add_var($stratatata, $stratatata_arr=null) {
echo "<ul>";
foreach ($allvars['DEFAULT'][null][$var]['type'] as $kk => $vv) {
echo "<li>";
if ( is_array($vv)) {
echo $kk;
echo "<ul>";
foreach ($vv as $ll => $mm ) {
echo "<li>";
echo "<label for='add_for_${ll}_$mm'>$mm</label>";
echo "<input type='text' class='int' id='add_for_${ll}_$mm' name='var_value_arr[$kk][$ll]' value='' size='30' />";
echo "</li>";
}
echo "</ul>";
} else {
echo "<label for='add_for_$var'>$vv</label>";
echo "<input type='text' class='int' id='add_for_$var' name='var_value_arr[$kk]' value='' size='30' />";
}
echo "</li>";
}
echo "</ul>";

View File

@ -245,12 +245,32 @@ class m_variables {
echo "<li>";
if (! is_numeric($k)) {
if (is_null($varname)) {
echo "$k =>";
echo "$k";
} else {
echo $this->variables_list()['DEFAULT'][null][$varname]['type'][$k]. " => ";
if ( !isset($this->variables_list()['DEFAULT'][null][$varname]['type'][$k]) || is_array( $this->variables_list()['DEFAULT'][null][$varname]['type'][$k] ) ) {
echo $k;
} else {
echo $this->variables_list()['DEFAULT'][null][$varname]['type'][$k];
}
}
echo "$l</li>";
}
if (is_array($l)) {
echo "<ul>";
foreach ($l as $m => $n ) {
echo "<li>";
if ( is_numeric($m)) {
echo "$m";
} else {
echo $this->variables_list()['DEFAULT'][null][$varname]['type'][$k][$m];
}
echo " => $n";
echo "</li>";
}
echo "</ul>";
} else {
echo " => $l";
}
echo "</li>";
}
echo "</ul>";
} // empty $v