Update of /cvsroot/twiki/twiki/bin
In directory usw-pr-cvs1:/tmp/cvs-serv11117/bin
Modified Files:
preview
Log Message:
Added strict.
Removed category code.
Major update to form code.
Index: preview
===================================================================
RCS file: /cvsroot/twiki/twiki/bin/preview,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** preview 2001/06/26 08:32:51 1.17
--- preview 2001/06/26 16:03:14 1.18
***************
*** 22,125 ****
use TWiki;
! $query= new CGI;
&main();
- sub buildCategoryItem
- {
- my ( $catitems ) = @_;
- my $catname = "", $scatname = "", $catvalue = "";
- my @cmd = split( /\|/, $catitems );
- my $param = "";
- my $len = @cmd;
- if( $len < "2" ) {
- return ( $catname, $catvalue )
- }
-
- if( $cmd[0] eq "select" ) {
- $catname = $cmd[1];
- $scatname = $catname;
- $scatname =~ s/[^a-zA-Z0-9]//g;
- $param = $query->param( "$scatname" );
- for( $i = 3; $i < $len; $i++ ) {
- my $value = $cmd[$i];
- my $svalue = $value;
- $svalue =~ s/[^a-zA-Z0-9]//g;
- if( $param eq $svalue ) {
- $catvalue = "$value";
- last;
- }
- }
- if( ! $catvalue ) {
- $catvalue = " ";
- }
- } elsif( $cmd[0] eq "checkbox" ) {
- $catname = $cmd[1];
- $scatname = $catname;
- $scatname =~ s/[^a-zA-Z0-9]//g;
- for( $i = 4; $i < $len; $i++ ) {
- my $value = $cmd[$i];
- my $svalue = $value;
- $svalue =~ s/[^a-zA-Z0-9]//g;
- $param = $query->param( "$scatname$svalue" );
- if( $param ) {
- $catvalue = "$catvalue, $value";
- }
- $catvalue =~ s/^,\s//;
- }
- if( ! $catvalue ) {
- $catvalue = " ";
- }
-
- } elsif( $cmd[0] eq "radio" ) {
- $catname = $cmd[1];
- $scatname = $catname;
- $scatname =~ s/[^a-zA-Z0-9]//g;
- $param = $query->param( "$scatname" );
- for( $i = 3; $i < $len; $i++ ) {
- my $value = $cmd[$i];
- my $svalue = $value;
- $svalue =~ s/[^a-zA-Z0-9]//g;
- if( $param eq $svalue ) {
- $catvalue = "$value";
- last;
- }
- }
- if( ! $catvalue ) {
- $catvalue = " ";
- }
- if( $scatname eq "UseCategory" ) {
- if( $catvalue eq "Yes" ) {
- # delete "UseCategory" entry if "UseCategory" is "Yes"
- $catname = "";
- } else {
- # delete whole category table
- $catname = "DELETE_ME";
- }
- }
-
- } elsif( $cmd[0] eq "text" ) {
- $catname = $cmd[1];
- $scatname = $catname;
- $scatname =~ s/[^a-zA-Z0-9]//g;
- $param = $query->param( "$scatname" );
- $catvalue = "<!---->$param<!----> ";
- }
-
- return ( $catname, $catvalue )
- }
-
sub main
{
my $thePathInfo = $query->path_info();
my $theRemoteUser = $query->remote_user();
my $theTopic = $query->param( 'topic' );
my $theUrl = $query->url;
! ( $topic, $webName ) =
&TWiki::initialize( $thePathInfo, $theRemoteUser, $theTopic, $theUrl, $query );
! my $tmpl = "", $atext = "", $text = "", $ptext = "", $tcat = "", $icat = "";
my $metaText = "";
if( ! &TWiki::Store::webExists( $webName ) ) {
--- 22,45 ----
use TWiki;
! use strict;
&main();
sub main
{
+ my $query = new CGI;
my $thePathInfo = $query->path_info();
my $theRemoteUser = $query->remote_user();
my $theTopic = $query->param( 'topic' );
my $theUrl = $query->url;
! my( $topic, $webName ) =
&TWiki::initialize( $thePathInfo, $theRemoteUser, $theTopic, $theUrl, $query );
! my $tmpl = "";
! my $text = "";
! my $ptext = "";
my $metaText = "";
+ my @meta = ();
if( ! &TWiki::Store::webExists( $webName ) ) {
***************
*** 141,148 ****
&TWiki::Store::lockTopic( $topic );
- # get view template, standard view or a view with a different skin
my $skin = $query->param( "skin" ) || &TWiki::Prefs::getPreferencesValue( "SKIN" );
$tmpl = &TWiki::Store::readTemplate( "preview", "", $skin );
- $icat = &TWiki::Store::readTemplate( "twikicatitems" );
my $dontNotify = $query->param( "dontnotify" ) || "";
$tmpl =~ s/%DONTNOTIFY%/$dontNotify/go;
--- 61,97 ----
&TWiki::Store::lockTopic( $topic );
my $skin = $query->param( "skin" ) || &TWiki::Prefs::getPreferencesValue( "SKIN" );
+
+ my $changeform = $query->param( 'submitChangeForm' );
+ TWiki::writeDebug( "================= edit, changeform $changeform" );
+ if( $changeform ) {
+ my $tmpl = &TWiki::Store::readTemplate( "changeform", "", $skin );
+ &TWiki::writeHeader( $query );
+ $tmpl =~ s/%TEXT%/$query->param( 'text' )/goe;
+ $tmpl = &TWiki::handleCommonTags( $tmpl, $topic );
+ my $listForms = TWiki::Prefs::getPreferencesValue( "WEBFORMS", "$webName" );
+ my @forms = split( /,\s*/, $listForms );
+ unshift @forms, "";
+ my( $tmp, @metat ) = &TWiki::Store::readWebTopicNew( $webName, $topic );
+ my $formName = &TWiki::Form::getFormName( @metat );
+
+ my $formList = "";
+ foreach my $form ( @forms ) {
+ my $selected = ( $form eq $formName ) ? "checked" : "";
+ $formList .= "\n<br>" if( $formList );
+ my $show = $form ? $form : "<none>";
+ my $value = $form ? $form : "none";
+ $formList .= "<input type=\"radio\" name=\"formtemplate\" value=\"$value\" $selected> $show";
+ }
+ $tmpl =~ s/%FORMLIST%/$formList/go;
+
+ #$tmpl = &TWiki::getRenderedVersion( $tmpl );
+ print $tmpl;
+ return;
+ }
+
+
+ # get view template, standard view or a view with a different skin
$tmpl = &TWiki::Store::readTemplate( "preview", "", $skin );
my $dontNotify = $query->param( "dontnotify" ) || "";
$tmpl =~ s/%DONTNOTIFY%/$dontNotify/go;
***************
*** 152,215 ****
}
$tmpl =~ s/%CMD%/$saveCmd/go;
!
! if( $icat ) {
! # get category items from parameters and build category section
! $tcat = &TWiki::Store::readTemplate( "twikicatview" );
! my $line = "", $ttext = "", $temp = "";
! ( $before, $line, $after) = split( /%REPEAT%/, $tcat );
! foreach( split( /\n/, $icat ) ) {
! my( $catname, $catvalue ) = buildCategoryItem( $_ );
! if( $catname ) {
! if( $catname eq "DELETE_ME" ) {
! $ttext = "";
! last;
! }
! $temp = $line;
! $temp =~ s/%CATNAME%/$catname/go;
! $temp =~ s/%CATMODIFIER%//go;
! $temp =~ s/%CATVALUE%/$catvalue/go;
! $ttext = "$ttext$temp";
! }
! }
! if( $ttext ) {
! $tcat = "$before$ttext$after";
! } else {
! $tcat = "";
! }
! }
!
if( $saveCmd ne "repRev" ) {
! ( $text, @meta ) = &TWiki::Store::readWebTopicNew( $webName, $topic );
! # get the edited text and combine text, category table and attachment for preview
! @meta = &TWiki::Classification::catVars2Meta( $webName, $query, @meta );
! $metaText = &TWiki::renderMetaData( $webName, $topic, \@meta );
$text = $query->param( "text" );
! $text .= $tcat; # text to save
! $ptext = $text; # text to preview
! my $catParams = &TWiki::Classification::categoryParams( @meta );
!
my $oldargsr;
! ( $oldargsr, @meta ) = &TWiki::Store::metaExtract( "CLASSIFICATION", "", "", @meta );
my @oldargs = @$oldargsr;
if( @oldargs ) {
! my %args = @oldargs;
! my $classification = $args{"name"};
! my @categoriesInfo = &TWiki::Classification::getCategoriesInfo( $webName, $classification );
! my $catInfo = &TWiki::Classification::renderCategoryInfo( "edit", $classification, \@meta, @categoriesInfo );
! my $catInfo = &TWiki::handleCommonTags( $catInfo, $topic, $webName );
! my $catInfo = &TWiki::getRenderedVersion( $catInfo, $webName );
! $tmpl =~ s/%CATEGORIES%/$catInfo/go;
! $tmpl =~ s/%CATEGORYPARAMS%/$catParams/go;
} else {
! $tmpl =~ s/%CATEGORIES%//go;
! $tmpl =~ s/%CATEGORYPARAMS%//go;
}
} else {
# for debug: Don't include attachment FIXME is this correct?
! $text = $query->param( "text" );
! # combine text and category table
! $text = "$before$after$tcat"; # text to save
! $ptext = $text; # text to preview
}
--- 101,144 ----
}
$tmpl =~ s/%CMD%/$saveCmd/go;
!
if( $saveCmd ne "repRev" ) {
! my $dummy = "";
! ( $dummy, @meta ) = &TWiki::Store::readWebTopicNew( $webName, $topic );
! my $formTemplate = $query->param( "formtemplate" );
! if( $formTemplate ) {
! # FIXME temporary because potentially shared fields
! my @args = ( name => $formTemplate );
! @meta = &TWiki::Store::metaRemove( "FORM", @meta );
! if( $formTemplate ne "none" ) {
! @meta = &TWiki::Store::metaUpdate( "FORM", \@args, "name", @meta);
! } else {
! $formTemplate = "";
! }
! $tmpl =~ s/%FORMTEMPLATE%/$formTemplate/go;
! } else {
! $tmpl =~ s/%FORMTEMPLATE%//go;
! }
!
! # get the edited text and combine text, form and attachments for preview
! @meta = &TWiki::Form::fieldVars2Meta( $webName, $query, @meta );
$text = $query->param( "text" );
! $ptext = $text;
! my $fieldParams = &TWiki::Form::getFieldParams( @meta );
!
! # FIXME overly verbose
my $oldargsr;
! ( $oldargsr, @meta ) = &TWiki::Store::metaExtract( "FORM", "", "", @meta );
my @oldargs = @$oldargsr;
if( @oldargs ) {
! $tmpl =~ s/%FORMFIELDS%/$fieldParams/go;
} else {
! $tmpl =~ s/%FORMFIELDS%//go;
}
} else {
# for debug: Don't include attachment FIXME is this correct?
! $text = $query->param( "text" ); # text to save
! # FIXME
! $ptext = $text; # text to preview
}
***************
*** 220,229 ****
# do not allow click on link before save:
$ptext =~ s@...;
- $ptext = &TWiki::handleCommonTags( $ptext, $topic );
$tmpl = &TWiki::handleCommonTags( $tmpl, $topic );
my( $head, $tag, $body ) = split( /(<body)/i, $tmpl, 3 );
$tmpl = join( "", $head, &TWiki::getRenderedVersion( "$tag$body" ) );
! $tmpl =~ s/%TEXT%/$ptext$metaText/go;
$text =~ s/&/%_A_%/go;
--- 149,158 ----
# do not allow click on link before save:
$ptext =~ s@...;
$tmpl = &TWiki::handleCommonTags( $tmpl, $topic );
+ $tmpl = &TWiki::handleMetaTags( $webName, $topic, $tmpl, \@meta );
my( $head, $tag, $body ) = split( /(<body)/i, $tmpl, 3 );
$tmpl = join( "", $head, &TWiki::getRenderedVersion( "$tag$body" ) );
! $tmpl =~ s/%TEXT%/$ptext/go;
$text =~ s/&/%_A_%/go;
|