if ( !keys %cgiHash )
{ # if script is called without arguments: initialize the html structure
- initPage();
- exit;
+ initPage();
+ exit;
}
# end of global variables
if ( $cgiHash{'print'} eq 'fileSelection' ) {
- print "<div class='header'>File Selection</div>";
- print_fileSelection( $cgiHash{'configFile'} );
+ print "<div class='header'>File Selection</div>";
+ print_fileSelection( $cgiHash{'configFile'} );
}
if ( $cgiHash{'print'} eq 'spectree' ) {
- print "<div class='header'>Available Settings</div>\n";
- unless ( -e $confDir . "/" . $cgiHash{'configFile'} ) {
- print "<p>config file does not exist</p>";
- exit;
- }
- parseConfigAndSpec( $cgiHash{'configFile'} );
- print
+ print "<div class='header'>Available Settings</div>\n";
+ unless ( -e $confDir . "/" . $cgiHash{'configFile'} ) {
+ print "<p>config file does not exist</p>";
+ exit;
+ }
+ parseConfigAndSpec( $cgiHash{'configFile'} );
+ print
"<div class='ancestorInfo' align='center'>specifications loaded from $specFileName</div>";
- print_registers($specFile);
+ print_registers($specFile);
}
if ( $cgiHash{'print'} eq 'settree' ) {
- print "<div class='header'>Selected Settings</div>\n";
- unless ( -e $confDir . "/" . $cgiHash{'configFile'} ) {
- print "<p>config file does not exist</p>";
- exit;
- }
- parseConfigAndSpec( $cgiHash{'configFile'} );
-
-
-
+ print "<div class='header'>Selected Settings</div>\n";
+ unless ( -e $confDir . "/" . $cgiHash{'configFile'} ) {
+ print "<p>config file does not exist</p>";
+ exit;
+ }
+ parseConfigAndSpec( $cgiHash{'configFile'} );
+
+
+
## obsolete
-# buildAncestry( $configFileName, "" )
-# ; #arg1: target file, # arg2: recursion parent target file
+# buildAncestry( $configFileName, "" )
+# ; #arg1: target file, # arg2: recursion parent target file
#
-# $configTree = $ancestryTree; # not so elegant
+# $configTree = $ancestryTree; # not so elegant
## now use:
integrateAncestry();
-
- print_ancestorInfo();
+
+ print_ancestorInfo();
- print_registers($configFile);
+ print_registers($configFile);
}
if ( defined $cgiHash{'debuginput'} ) {
- print $cgiHash{'debuginput'};
+ print $cgiHash{'debuginput'};
}
if ( defined $cgiHash{'action'} ) {
- printHash( \%cgiHash );
- if ( $cgiHash{'action'} eq 'save' ) {
- parseConfig( $cgiHash{'configFile'} );
- save( $cgiHash{'register'}, $cgiHash{'field'}, $cgiHash{'value'} );
- }
- if ( $cgiHash{'action'} eq 'delete' ) {
- parseConfig( $cgiHash{'configFile'} );
- del( $cgiHash{'register'}, $cgiHash{'field'} );
- }
- if ( $cgiHash{'action'} eq 'copyDefaultRegister' ) {
- parseConfigAndSpec( $cgiHash{'configFile'} );
- del( $cgiHash{'register'}, "" ); # delete existing register from setfile
- copyDefaultRegister( $cgiHash{'register'} );
- }
- if ( $cgiHash{'action'} eq 'createFile' ) {
- createFile( $cgiHash{'configFile'}, $cgiHash{'specFile'} );
- }
-
- if ( $cgiHash{'action'} eq 'deleteFile' ) {
- deleteFile( $cgiHash{'configFile'} );
- }
-
- if ( $cgiHash{'action'} eq 'changeAncestor' ) {
- parseConfig( $cgiHash{'configFile'} );
- changeAncestor( $cgiHash{'newAncestor'} );
- }
+ printHash( \%cgiHash );
+ if ( $cgiHash{'action'} eq 'save' ) {
+ parseConfigFile( $cgiHash{'configFile'} );
+ save( $cgiHash{'register'}, $cgiHash{'field'}, $cgiHash{'value'} );
+ writeConfigFile();
+ }
+ if ( $cgiHash{'action'} eq 'delete' ) {
+ parseConfigFile( $cgiHash{'configFile'} );
+ del( $cgiHash{'register'}, $cgiHash{'field'} );
+ writeConfigFile();
+ }
+ if ( $cgiHash{'action'} eq 'copyDefaultRegister' ) {
+ parseConfigAndSpec( $cgiHash{'configFile'} );
+ del( $cgiHash{'register'}, "" ); # delete existing register from setfile
+ copyDefaultRegister( $cgiHash{'register'} );
+ writeConfigFile();
+ }
+ if ( $cgiHash{'action'} eq 'createFile' ) {
+ createConfigFile( $cgiHash{'configFile'}, $cgiHash{'specFile'} );
+ writeConfigFile();
+ }
+
+ if ( $cgiHash{'action'} eq 'deleteFile' ) {
+ deleteFile( $cgiHash{'configFile'} );
+ }
+
+ if ( $cgiHash{'action'} eq 'changeAncestor' ) {
+ parseConfigFile( $cgiHash{'configFile'} );
+ changeAncestor( $cgiHash{'newAncestor'} );
+ writeConfigFile();
+ }
}
}
#args:configFileName #globs:$confDir
-sub createFile {
- my $configFileName = $_[0];
+sub createConfigFile {
+ $configFileName = $_[0];
- my $specFileName = $_[1]; #config file is based on this specification!
- my $configFile = $confDir . "/" . $configFileName;
- my $specFile = $specDir . "/" . $specFileName;
+ $specFileName = $_[1]; #config file is based on this specification!
+ $configFile = $confDir . "/" . $configFileName;
+ $specFile = $specDir . "/" . $specFileName;
- my $configTree = XML::LibXML->createDocument;
- my $specTree = $parser->parse_file($specFile);
+ $configTree = XML::LibXML->createDocument;
+ $specTree = $parser->parse_file($specFile);
my $configMaps = $configTree->createElementNS( "", "MAPS" );
$configTree->setDocumentElement($configMaps);
$configMaps->setAttribute( "type", $mapsType );
$configMaps->setAttribute( "specDbFile", $specFileName );
- open( SCHREIBEN, "> $configFile" )
- or print "could not open file $configFile for writing: $!\n";
-
- print SCHREIBEN $configTree->toString();
- close SCHREIBEN;
-
}
-#args: configFileName,specFileName #globs:$confDir,$specDir,$parser
+# args: configFileName,specFileName
+# globs:$confDir,$specDir,$parser,$configFile,$specFile,$configFileName,$specFileName
+# description: create new configFileTree
sub parseConfigAndSpec {
- parseConfig( $_[0] );
+ parseConfigFile( $_[0] );
$specFileName = $configTree->findvalue("/MAPS/\@specDbFile");
$specFile = $specDir . "/" . $specFileName;
unless ( -e $specFile ) {
}
$specTree = $parser->parse_file($specFile);
}
-#args: configFileName #globs: $specFileName,$configTree,$specFile,$specDir,$specTree,$parser #calls: parseConfig()
+#args: configFileName #globs: $specFileName,$configTree,$specFile,$specDir,$specTree,$parser #calls: parseConfigFile()
-sub parseConfig {
+sub parseConfigFile {
$configFileName = $_[0];
$configFile = $confDir . "/" . $_[0];
$configTree = $parser->parse_file($configFile);
print "<p>The faulty include directive was removed.</p>";
print "<p><input type='button' onclick='loadFile()' value='back'></p>";
changeAncestor(""); # break the evil circle where it was closed!
+ writeConfigFile();
exit;
}
print
"<p><input type='button' onclick='loadFile()' value='back'></p>";
changeAncestor(""); # break the evil circle where it was closed!
+ writeConfigFile();
exit;
#die "no circular includes please! $!";
print "<p>The faulty include directive was removed.</p>";
print "<p><input type='button' onclick='loadFile()' value='back'></p>";
changeAncestor(""); # break the evil circle where it was closed!
+ writeConfigFile();
exit;
return;
}
print "<p>The faulty include directive was removed.</p>";
print "<p><input type='button' onclick='loadFile()' value='back'></p>";
changeAncestor(""); # break the evil circle where it was closed!
+ writeConfigFile();
exit;
}
print "<p>The faulty include directive was removed.</p>";
print "<p><input type='button' onclick='loadFile()' value='back'></p>";
changeAncestor(""); # break the evil circle where it was closed!
+ writeConfigFile();
exit;
}
unless ( $ancestorFileName eq "" ) {
# description: this function extends $configTree to include all information that is held
# by its ancestor (and ancestor's ancestor ... and so on)
+sub changeAncestor {
+ my $ancestorFileName = $_[0];
+ my $xmltree = $configTree;
+ my $xmlfile = $configFile;
+ my $maps = $xmltree->findnodes("/MAPS")->shift();
+
+ $maps->setAttribute( "inheritSettingsFrom", $ancestorFileName );
+
+# open( SCHREIBEN, "> $xmlfile" )
+# or print "could not open file $xmlfile for writing: $!\n";
+#
+# print SCHREIBEN $xmltree->toString();
+# close SCHREIBEN;
+
+}
+# args: ancestorFileName
+# globs: $configTree,$configFile
+# description: change the "inheritSettingsFrom" tag in the current configTree to "ancestorFileName"
+# make change permanent by calling writeConfigFile() hereafter.
+
sub del {
my $registerName = $_[0];
print "deleted register as well<br>";
}
}
- open( SCHREIBEN, "> $xmlfile" )
- or print "could not open file $xmlfile for writing: $!\n";
-
- print SCHREIBEN $xmltree->toString();
- close SCHREIBEN;
+# open( SCHREIBEN, "> $xmlfile" )
+# or print "could not open file $xmlfile for writing: $!\n";
+#
+# print SCHREIBEN $xmltree->toString();
+# close SCHREIBEN;
}
# args: registerName,fieldName,
# globs: $configFile,$configTree
-# description: deletes field "fieldName" in register "registerName" in $configFile
+# description: deletes field "fieldName" in register "registerName" in $configTree
+# make change permanent by calling writeConfigFile() hereafter.
sub save {
$field->setAttribute( "value", $newValue );
print $field->findvalue("./\@value");
- open( SCHREIBEN, "> $xmlfile" )
- or print "could not open file $xmlfile for writing: $!\n";
-
- print SCHREIBEN $xmltree->toString();
- close SCHREIBEN;
+# open( SCHREIBEN, "> $xmlfile" )
+# or print "could not open file $xmlfile for writing: $!\n";
+#
+# print SCHREIBEN $xmltree->toString();
+# close SCHREIBEN;
}
# args: registerName,fieldName,newValue
# globs: $configFile,$configTree,
-# description: saves value "newValue" in field "fieldName" in register "registerName" (in the $configFile)
+# description: saves value "newValue" in field "fieldName" in register "registerName" (in the $configTree)
# if field or register does not exist yet, it is created.
+# make change permanent by calling writeConfigFile() hereafter.
sub copyDefaultRegister {
my $registerName = $_[0];
$configField->setAttribute( "value", $fieldValue );
print $configField->findvalue("./\@value");
}
+
+ #writeConfigFile();
+}
+# args: registerName
+# globs: $configTree,$specTree,$configFile
+# description: copys register "registerName" from $specTree to $configTree
+# make change permanent by calling writeConfigFile() hereafter.
+
+sub writeConfigFile(){
open( SCHREIBEN, "> $configFile" )
or print "could not open file $configFile for writing: $!\n";
print SCHREIBEN $configTree->toString();
close SCHREIBEN;
}
-# args: registerName
-# globs: $config
-
+# globs: $configFile,$configTree
+# description: writes the current $configTree to $configFile
###############################
## subs generating html output
print "</p>";
-# print "<table>";
-# print "<tr><td>";
-# print "<table>";
-# print "<tr>";
-# print "<td>selected config file:<td>";
-# print "</tr>";
-#
-# print "<tr>";
-#
-# print "<td>";
-# print_fileSelector( $configFile, "fileSelector", "loadFile()" );
-# print "</td>";
-#
-# print "<td>";
-# print
-#"<input type='button' onclick='loadFile()' value='reload file' class='stdbutton'>";
-# print
-#"<input type='button' onclick='deleteFile()' value='delete file' class='stdbutton'>";
-# print "</td>";
-#
-# print "</tr>";
-#
-# print "</table>";
-#
-# print "</td>";
-#
-# print "<td style='border-right:1px solid #000000'><br></td>";
-#
-# print "<td>";
-# print "<table>";
-# print "<tr><td colspan=2>";
-# print "create new config file:";
-# print "</td></tr>";
-#
-# print "<tr><td>";
-# print "<input type='text' value='' id='newFileName'>";
-# print "</td><td>";
-# print_specSelector();
-# print "</td><td>";
-# print
-#"<input type='button' onclick='createFile()' value='create file' class='stdbutton'>";
-# print "</td></tr>";
-#
-# print "</table>";
-# print "</td>";
-# print "</tr></table>";
+
}
sub print_registers {
}
}
-sub changeAncestor {
- my $ancestorFileName = $_[0];
- my $xmltree = $configTree;
- my $xmlfile = $configFile;
- my $maps = $xmltree->findnodes("/MAPS")->shift();
- $maps->setAttribute( "inheritSettingsFrom", $ancestorFileName );
-
- open( SCHREIBEN, "> $xmlfile" )
- or print "could not open file $xmlfile for writing: $!\n";
-
- print SCHREIBEN $xmltree->toString();
- close SCHREIBEN;
-
-}
sub getAncestor {
my $xmltree = $configTree;
sub prepare_text {
- my $t = $_[0];
- chomp $t;
- $t = encode_entities($t);
- $t =~ s/^\s//;
- $t =~ s/^\n//;
- $t =~ s/\t//;
- return $t;
+ my $t = $_[0];
+ chomp $t;
+ $t = encode_entities($t);
+ $t =~ s/^\s//;
+ $t =~ s/^\n//;
+ $t =~ s/\t//;
+ return $t;
}
# a sorting directive for fields and registers
sub by_name {
- my $a_name = $a->findvalue("./\@name");
- my $b_name = $b->findvalue("./\@name");
+ my $a_name = $a->findvalue("./\@name");
+ my $b_name = $b->findvalue("./\@name");
- return $a_name cmp $b_name;
+ return $a_name cmp $b_name;
}
sub printHash {
- my $hashref = $_[0];
- for my $element ( keys %{$hashref} ) {
- print $element. "=" . $hashref->{$element} . "<br>\n";
- }
+ my $hashref = $_[0];
+ for my $element ( keys %{$hashref} ) {
+ print $element. "=" . $hashref->{$element} . "<br>\n";
+ }
}
sub read_input {
- my $buffer;
- my @pairs;
- my $pair;
- my $name;
- my $value;
- my %FORM;
-
- # Read in text
- $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
- if ( $ENV{'REQUEST_METHOD'} eq "POST" ) {
- read( STDIN, $buffer, $ENV{'CONTENT_LENGTH'} );
- }
- else {
- $buffer = $ENV{'QUERY_STRING'};
- }
-
- # Split information into name/value pairs
- @pairs = split( /&/, $buffer );
- foreach $pair (@pairs) {
- ( $name, $value ) = split( /=/, $pair );
- $value =~ tr/+/ /;
- $value =~ s/%(..)/pack("C", hex($1))/eg;
- $FORM{$name} = $value;
- }
- %FORM;
+ my $buffer;
+ my @pairs;
+ my $pair;
+ my $name;
+ my $value;
+ my %FORM;
+
+ # Read in text
+ $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
+ if ( $ENV{'REQUEST_METHOD'} eq "POST" ) {
+ read( STDIN, $buffer, $ENV{'CONTENT_LENGTH'} );
+ }
+ else {
+ $buffer = $ENV{'QUERY_STRING'};
+ }
+
+ # Split information into name/value pairs
+ @pairs = split( /&/, $buffer );
+ foreach $pair (@pairs) {
+ ( $name, $value ) = split( /=/, $pair );
+ $value =~ tr/+/ /;
+ $value =~ s/%(..)/pack("C", hex($1))/eg;
+ $FORM{$name} = $value;
+ }
+ %FORM;
}
# sub any2dec { # converts numeric expressions 0x, 0b or decimal to decimal
#
-# my $argument = $_[0];
+# my $argument = $_[0];
#
-# #print "any2dec input argument $argument\n";
+# #print "any2dec input argument $argument\n";
#
-# if ( $argument =~ m/0[bxBX]/ ) {
-# return oct $argument;
-# }
-# else {
-# return $argument;
-# }
+# if ( $argument =~ m/0[bxBX]/ ) {
+# return oct $argument;
+# }
+# else {
+# return $argument;
+# }
# }
sub printJavaScripts {
####### javascript function land ################
- print <<EOF ;
+ print <<EOF ;
<script language="javascript">
function changeAncestor(newAncestor){
- var file_ = encodeURIComponent(selectedConfigFile());
- var newAncestor_ = encodeURIComponent(newAncestor);
- getdata('$me?action=changeAncestor&configFile='+file_+'&newAncestor='+newAncestor_,false);
- reloadSetTree();
+ var file_ = encodeURIComponent(selectedConfigFile());
+ var newAncestor_ = encodeURIComponent(newAncestor);
+ getdata('$me?action=changeAncestor&configFile='+file_+'&newAncestor='+newAncestor_,false);
+ reloadSetTree();
}
function deleteFile(){
- var file_ = encodeURIComponent(selectedConfigFile());
- getdata('$me?action=deleteFile&configFile='+file_,false);
- loadFile();
+ var file_ = encodeURIComponent(selectedConfigFile());
+ getdata('$me?action=deleteFile&configFile='+file_,false);
+ loadFile();
}
return e.options[e.selectedIndex].text;
}
else {
- return "";
+ return "";
}
}
var e = document.getElementById("specSelector");
return e.options[e.selectedIndex].text;}
else {
- return "";
+ return "";
}
}
function newFileName(){
if(document.getElementById("newFileName")){
- var fileName = document.getElementById("newFileName").value;
- var patt = /\.xml/i;
- if(patt.test(fileName)){
- return fileName;
- } else {
- return fileName+".xml";
- }
+ var fileName = document.getElementById("newFileName").value;
+ var patt = /\.xml/i;
+ if(patt.test(fileName)){
+ return fileName;
+ } else {
+ return fileName+".xml";
+ }
} else {
- return "";
+ return "";
}
}
reloadSpecTree();
reloadSetTree();
reloadFileSelection();
-
+
}
function createFile(){
- debugOutput("NewFileName: "+newFileName());
- var configFile_ = encodeURIComponent(newFileName());
- var specFile_ = encodeURIComponent(selectedSpecFile());
- getdata("$me?action=createFile&configFile="+configFile_+"&specFile="+specFile_,"debug",false);
- getdata('$me?print=fileSelection&configFile='+configFile_,'fileSelection',false);
- loadFile();
+ debugOutput("NewFileName: "+newFileName());
+ var configFile_ = encodeURIComponent(newFileName());
+ var specFile_ = encodeURIComponent(selectedSpecFile());
+ getdata("$me?action=createFile&configFile="+configFile_+"&specFile="+specFile_,"debug",false);
+ getdata('$me?print=fileSelection&configFile='+configFile_,'fileSelection',false);
+ loadFile();
}
}
function writeToElementId(input,destId){
- if(document.getElementById(destId).innerHTML){
- document.getElementById(destId).innerHTML = input;
- }
+ if(document.getElementById(destId).innerHTML){
+ document.getElementById(destId).innerHTML = input;
+ }
}
function toggleVis(elementId,t) {
if(document.getElementById(elementId)){
if( document.getElementById(elementId).style.visibility == "visible") {
- document.getElementById(elementId).style.visibility = "collapse";
- visHash[elementId]=false;
- t.innerHTML = " + ";
+ document.getElementById(elementId).style.visibility = "collapse";
+ visHash[elementId]=false;
+ t.innerHTML = " + ";
} else {
- document.getElementById(elementId).style.visibility = "visible" ;
- visHash[elementId]=true;
+ document.getElementById(elementId).style.visibility = "visible" ;
+ visHash[elementId]=true;
t.innerHTML = " − ";
}
}
}
function showElement(elementId) {
- if(document.getElementById(elementId)){
- document.getElementById(elementId).style.visibility = "visible" ;
- visHash[elementId]=true;
- }
+ if(document.getElementById(elementId)){
+ document.getElementById(elementId).style.visibility = "visible" ;
+ visHash[elementId]=true;
+ }
}
function hideElement(elementId) {
- if(document.getElementById(elementId)){
- document.getElementById(elementId).style.visibility = "hidden" ;
- visHash[elementId]=false;
- }
+ if(document.getElementById(elementId)){
+ document.getElementById(elementId).style.visibility = "hidden" ;
+ visHash[elementId]=false;
+ }
}
function collapseElement(elementId) {
- if(document.getElementById(elementId)){
- document.getElementById(elementId).style.visibility = "collapse" ;
- visHash[elementId]=false;
- }
+ if(document.getElementById(elementId)){
+ document.getElementById(elementId).style.visibility = "collapse" ;
+ visHash[elementId]=false;
+ }
}
function hideThisFileLevel(classname,checked){
{
if(checked){
array[i].style.visibility = 'visible';
-
+
}else{
-
+
array[i].style.visibility = 'collapse';
}
//var cb = null;
xmlhttp=new XMLHttpRequest();
//cb = callback;
- var destId = dId;
+ var destId = dId;
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status==200) {
//if(cb)
- if(document.getElementById(destId).innerHTML){
- document.getElementById(destId).innerHTML = xmlhttp.responseText;
- }
+ if(document.getElementById(destId).innerHTML){
+ document.getElementById(destId).innerHTML = xmlhttp.responseText;
+ }
//cb(xmlhttp.responseText);
- //document.getElementById(destId).innerHTML = xmlhttp.responseText;
+ //document.getElementById(destId).innerHTML = xmlhttp.responseText;
}
}