Index: ossp-pkg/tabea/tabea.cgi RCS File: /v/ossp/cvs/ossp-pkg/tabea/tabea.cgi,v rcsdiff -q -kk '-r1.13' '-r1.14' -u '/v/ossp/cvs/ossp-pkg/tabea/tabea.cgi,v' 2>/dev/null --- tabea.cgi 2002/05/13 13:05:56 1.13 +++ tabea.cgi 2002/05/13 16:28:28 1.14 @@ -150,15 +150,14 @@ $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) . $cgi->hidden(-name => 'form', -default => ['']) . # Begin with templates part - "
Active User: $username
\n" . - "Templates:

\n" . - "" . + "
Active User: $username

\n" . +# "Templates:

\n" . " " . "
" . " " . $cgi->scrolling_list( -name => 'templatelist', -value => [@templatesarray], - -size => 2 + -size => 3 ) . " " . @@ -182,14 +181,13 @@ "
" . # Now the configuration part - $page .= "Configuration:

\n". - "" . - " " . + $page .= "
" . + "" . "
Configuration
" . " " . $cgi->scrolling_list( -name => 'configslist', -value => [@configsarray], - -size => 5 + -size => 10 ) . " " . @@ -221,8 +219,7 @@ "
" . " " . - - " " . + "" . "" ; @@ -231,31 +228,11 @@ } elsif ($dialog eq 'Edit') { # enter Edit form -# &validpassword($username, $password, $pwdfile) || print STDOUT $cgi->redirect(-uri => $cgi->url(-full => 1), -type => "text/html"); - if ($cgi->param('configslist')) { - my $filename = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $username . "/" . $cgi->param('configslist'); - &editconfig($filename, 'w', $username); - } else { - $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) . - "Missing filename

\n" . - $cgi->submit(-name => 'dialog', -value => 'Back') . - $cgi->endform; - } - + $page .= &edit($cgi->param('configslist')); } elsif ($dialog eq 'View') { # enter View form -# &validpassword($username, $password, $pwdfile) || print STDOUT $cgi->redirect(-uri => $cgi->url(-full => 1), -type => "text/html"); - if ($cgi->param('templatelist')) { - my $filename = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $cfghash{'TabeaUser'} . "/" . $cgi->param('templatelist'); - &editconfig($filename, 'r', $username); - } else { - $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) . - "Missing filename

\n" . - $cgi->submit(-name => 'dialog', -value => 'Back') . - $cgi->endform; - } - + $page .= &view($cgi->param('templatelist')); } else { die "invalid dialog \"$dialog\""; } @@ -272,6 +249,48 @@ exit (0); + +######################################################################################## +sub edit { +######################################################################################## + my ($file) = @_; + my $text; + # enter Edit form + if($file) { + my $filename = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $username . "/" . $file; + &editconfig($filename, 'w', $username); + } else { + $text = $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) . + "Missing filename

\n" . + $cgi->submit(-name => 'dialog', -value => 'Back') . + $cgi->endform; + } + return $text; +} +######################################################################################## + + +######################################################################################## +sub view { +######################################################################################## + my ($file) = @_; + my $text; + # enter View form + if ($file) { + my $filename = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $cfghash{'TabeaUser'} . "/" . $cgi->param('templatelist'); + &editconfig($filename, 'r', $username); + } else { + $text .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) . + "Missing filename

\n" . + $cgi->submit(-name => 'dialog', -value => 'Back') . + $cgi->endform; + } + return $text; +} +######################################################################################## + + + ######################################################################################## sub read_config { ######################################################################################## @@ -368,23 +387,37 @@ my ($file, $mode, $user) = @_; my $text = ''; my $filein ; - + my $readonly ; + my $titletext ; $filein = IO::File->new("<$file"); while(<$filein>) { $text .= $_; } $filein->close; + + + if ($mode eq 'w') { + $titletext = "Edit window"; + } elsif ($mode eq 'r') { + $titletext = "View window"; + } + + my $textahash ={ -name => 'editwindow', + -default => $text, + -rows => 40, + -columns => 80 + }; + if ($mode eq 'r') { + $textahash->{readonly}=""; + } $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) . - "Edit window:

\n" ; - $page .= "Username: $username

\n" . + "" . + $titletext . ":

\n" . + "
" . + "Username: $username

\n" . "File: $file

\n" . "Mode: $mode

\n" . - $cgi->textarea( - -name => 'editwindow', - -default => $text, - -rows => 40, - -columns => 80 - ); - $page .= "

\n" . + $cgi->textarea($textahash). + "

\n" . "" . "
" . " " . @@ -401,7 +434,5 @@ $cgi->endform; - - } ########################################################################################