No table name specified. Please specify a table to edit.
\n"; exit; }
//echo "" . implode(',',array_keys($_SESSION)) . "
\n";
//if (array_key_exists("editable-$tab",$_SESSION)) { echo "count=".count($_SESSION["editable-$tab"])."
\n"; }
if(isset($_REQUEST['kill'])) {
unset($_SESSION["editable-$tab"]);
}
if(isset($_REQUEST['save'])) {
$rsp = doTabrestore($tab,$_SESSION["editable-$tab"]);
$errors = array();
if (getXmlErrors($rsp,$errors)) { echo "Tabrestore failed: ", implode(' ',$errors), "
\n"; }
else { echo "Changes have been saved.
\n"; }
}
// Get table contents
//$f = splitTableFields2('"node01","node02","5000","off",,'); echo ''; foreach ($f as $k => $v) { echo "$k=$v
"; } echo "
\n";
echo "$tab Table
";
echo "\n";
// Display the column names
$xml = docmd('tabdump','',array($tab));
$headers = getTabHeaders($xml);
if(!is_array($headers)){ die("Can't find header line in $tab
"); }
echo "\n";
echo "\n"; # close header row
// Save the width of the table for adding a new row when they click that button
$tableWidth = count($headers);
// Display table contents and remember its contents in a session variable.
$ooe = 0; // alternates the background of the table
$item = 0; // the column #
$line = 0;
$editable = array();
foreach ($xml->children() as $response) foreach ($response->children() as $arr){
$arr = (string) $arr;
if(ereg("^#", $arr)){ // handle the header specially
$editable[$line++][$item] = $arr;
continue;
}
$cl = "ListLine$ooe";
$values = splitTableFields($arr);
// If you change this line, be sure to change the formRow function in db.js
echo " | ";
foreach($values as $v){
//$v = preg_replace('/\"/','', $v);
echo "$v | ";
$editable[$line][$item++] = $v;
}
echo "
\n";
$line++;
$item = 0;
$ooe = 1 - $ooe;
}
echo "
\n";
$_SESSION["editable-$tab"] = & $editable; // save the array so we can access it in the next call of this file or change.php
//unset($_SESSION["editable-$tab"]);
insertButtons(array('label' => 'Add Row', 'id' => 'newrow'),
array('label' => 'Save', 'id' => 'saveit'),
array('label' => 'Cancel', 'id' => 'reset')
);
?>
children() as $response) foreach ($response->children() as $line) {
$line = (string) $line;
if (ereg("^#", $line)) {
$line = preg_replace('/^#/','', $line);
$headers = explode(',', $line);
return $headers;
}
}
// If we get here, we never found the header line
return NULL;
}
//-----------------------------------------------------------------------------
function getTabDescription($tab) {
$xml = docmd('tabdump','',array('-d'));
foreach ($xml->children() as $response) foreach ($response->children() as $line) {
$line = (string) $line;
if (ereg("^$tab:",$line)) {
$line = preg_replace("/^$tab:\s*/", '', $line);
return $line;
}
}
return '';
}
?>