--- loncom/interface/Attic/lonwizard.pm 2003/02/07 19:30:43 1.4 +++ loncom/interface/Attic/lonwizard.pm 2003/02/20 22:10:06 1.10 @@ -24,6 +24,7 @@ All classes are in the Apache::lonwizard use strict; use HTML::Entities; +use Apache::loncommon; =pod @@ -45,6 +46,8 @@ use HTML::Entities; =item B: A boolean value, true if the wizard has completed. +=item B: The data the wizard is drawing from, which will be passed to Apache::loncommon::get_unprocessed_cgi, and may be used by states that do multi-selection. + =back =cut @@ -54,6 +57,11 @@ sub new { my $class = ref($proto) || $proto; my $self = {}; + $self->{TITLE} = shift; + $self->{DATA} = shift; + &Apache::loncommon::get_unprocessed_cgi($self->{DATA}); + + # If there is a state from the previous form, use that. If there is no # state, use the start state parameter. if (defined $ENV{"form.CURRENT_STATE"}) @@ -76,11 +84,11 @@ sub new { $self->{RETURN_PAGE} = $ENV{REFERER}; } - $self->{TITLE} = shift; $self->{STATES} = {}; $self->{VARS} = {}; $self->{HISTORY} = {}; $self->{DONE} = 0; + bless($self, $class); return $self; } @@ -93,16 +101,25 @@ sub new { =item * B(title): Returns a new instance of the given wizard type. "title" is the human-readable name of the wizard. A new wizard always starts on the B state name. -=item * B(varList): Call this function to declare the var names you want the wizard to maintain for you. The wizard will automatically output the hidden form fields and parse the values for you on the next call. This is a bulk declaration. +=item * B(varList): Call this function to declare the var names you want the wizard to maintain for you. The wizard will automatically output the hidden form fields and parse the values for you on the next call. =over 2 -=item Note that these variables are reserved for the wizard; if you output other form values in your state, you must use other names. For example, declaring "student" will cause the wizard to emit a form value with the name "student"; if your state emits form entries, do not name them "student". +=item * B: These form variables are reserved for the wizard; if you output other form values in your state, you must use other names. For example, declaring "student" will cause the wizard to emit a form value with the name "student"; if your state emits form entries, do not name them "student". If you use the variable name followed by '.forminput', the wizard will automatically store the user's choice in the appropriate form variable. + +=item * B: If you want to preserve incoming form values, such as ones from the remote, you can simply declare them and the wizard will automatically preserve them. For instance, you might want to store 'url' or 'postdata' from the remote; see lonprintout for example. =back =cut +# Sometimes the wizard writer will want to use the result of the previous +# state to change the text of the next state. In order to do that, it +# has to be done during the declaration of the states, or it won't be +# available. Therefore, basic form processing must occur before the +# actual display routine is called and the actual pre-process is called, +# or it won't be available. +# This also factors common code out of the preprocess calls. sub declareVars { my $self = shift; my $varlist = shift; @@ -119,6 +136,12 @@ sub declareVars { { $self->{VARS}->{$element} = $ENV{$envname}; } + + # If there's an incoming form submission, use that + $envname = "form." . $element . ".forminput"; + if (defined ($ENV{$envname})) { + $self->{VARS}->{$element} = $ENV{$envname}; + } } } @@ -230,7 +253,7 @@ sub display { $bodytag HEADER - if (!$state->overrideForm()) { $result.="
"; } + if (!$state->overrideForm()) { $result.=""; } $result .= <

$stateTitle

@@ -366,48 +389,46 @@ sub handler { $r->rflush(); my $mes = <This wizard will allow you to

- -
    -
  • Change assignment parameters, such as due date or open date...
  • -
  • ... for a whole class
  • -
  • ... for a whole section
  • -
  • ... for an individual student
  • -
  • ... by folder
  • -
  • ... by individual assignment
  • -
+

This wizard will allow you to set open, due, and answer dates for problems. You will be asked to select a problem, what kind of date you want to set, and for whom the date should be effective.

After the wizard is done, you will be shown where in the advanced interface you would have gone to change the parameter you have chosen, so in the future you can do it directly.

+ +

Press Next -> to begin, or select <- Previous to go back to the previous screen.

WIZBEGIN my $wizard = Apache::lonwizard->new("Course Parameter Wizard"); $wizard->declareVars(['ACTION_TYPE', 'GRANULARITY', 'TARGETS', 'PARM_DATE', 'RESOURCE_ID', 'USER_NAME', 'SECTION_NAME']); - my %dateTypeHash = ('open_date' => "Opening Date", - 'due_date' => "Due Date", - 'answer_date' => "Answer Date"); + my %dateTypeHash = ('open_date' => "opening date", + 'due_date' => "due date", + 'answer_date' => "answer date"); + my %levelTypeHash = ('whole_course' => "all problems in the course", + 'map' => 'the selected folder', + 'resource' => 'the selected problem'); - Apache::lonwizard::message_state->new($wizard, "START", "Welcome to the Assignment Parameter Wizard", $mes, "CHOOSE_ACTION"); - Apache::lonwizard::switch_state->new($wizard, "CHOOSE_ACTION", "What do you want to do?", "ACTION_TYPE", [ - ["open_date", "Set an Open Date for a problem", "CHOOSE_LEVEL"], - ["due_date", "Set a Due Date for a problem", "CHOOSE_LEVEL"], - ["answer_date", "Set an Answer Open Date for a problem", "CHOOSE_LEVEL" ] ]); - Apache::lonwizard::switch_state->new($wizard, "CHOOSE_LEVEL", "Parameter Granularity", "GRANULARITY", [ - ["whole_course", "Set for Whole Course", "CHOOSE_STUDENT_LEVEL"], - ["map", "Set for a Folder/Map", "CHOOSE_FOLDER"], - ["resource", "Set for a Particular Problem", "CHOOSE_RESOURCE"]], - "How general should this setting be?"); - Apache::lonwizard::resource_choice->new($wizard, "CHOOSE_FOLDER", "Select Folder", "", "", "CHOOSE_STUDENT_LEVEL", "RESOURCE_ID", sub {my $res = shift; return $res->is_map();}); - Apache::lonwizard::resource_choice->new($wizard, "CHOOSE_RESOURCE", "Select Resource", "", "", "CHOOSE_STUDENT_LEVEL", "RESOURCE_ID", sub {my $res = shift; return $res->is_map() || $res->is_problem();}, sub {my $res = shift; return $res->is_problem(); }); - Apache::lonwizard::switch_state->new($wizard, "CHOOSE_STUDENT_LEVEL", "Parameter Targets", "TARGETS", [ - ["course", "Set for All Students in Course", "CHOOSE_DATE"], - ["section", "Set for Section", "CHOOSE_SECTION"], - ["student", "Set for an Individual Student", "CHOOSE_STUDENT"]], - "Whom should this setting affect?"); - + Apache::lonwizard::message_state->new($wizard, "START", "Welcome to the Assignment Parameter Wizard", $mes, "CHOOSE_LEVEL"); + Apache::lonwizard::switch_state->new($wizard, "CHOOSE_LEVEL", "Which Problem or Problems?", "GRANULARITY", [ + ["whole_course", "Every problem in the course", "CHOOSE_ACTION"], + ["map", "Every problem in a particular folder", "CHOOSE_FOLDER"], + ["resource", "One particular problem", "CHOOSE_RESOURCE"]], + "Which problems do you wish to change a date for?"); + Apache::lonwizard::resource_choice->new($wizard, "CHOOSE_FOLDER", "Select Folder", "Select the folder you wish to set the date for:", "", "CHOOSE_ACTION", "RESOURCE_ID", sub {my $res = shift; return $res->is_map();}); + Apache::lonwizard::resource_choice->new($wizard, "CHOOSE_RESOURCE", "Select Resource", "", "", "CHOOSE_ACTION", "RESOURCE_ID", sub {my $res = shift; return $res->is_map() || $res->is_problem();}, sub {my $res = shift; return $res->is_problem(); }); + my $levelType = $levelTypeHash{$wizard->{VARS}->{GRANULARITY}}; + Apache::lonwizard::switch_state->new($wizard, "CHOOSE_ACTION", "Parameter Type", "ACTION_TYPE", [ + ["open_date", "Set an open date", "CHOOSE_DATE"], + ["due_date", "Set a due date", "CHOOSE_DATE"], + ["answer_date", "Set an answer open date", "CHOOSE_DATE" ] ], + "What parameters do you want to set for $levelType?"); my $dateType = $dateTypeHash{$wizard->{VARS}->{ACTION_TYPE}}; - Apache::lonwizard::choose_section->new($wizard, "CHOOSE_SECTION", "Select Section", "Please select the section you wish to set the $dateType for:", "", "CHOOSE_DATE", "SECTION_NAME"); - Apache::lonwizard::choose_student->new($wizard, "CHOOSE_STUDENT", "Select Student", "Please select the student you wish to set the $dateType for:", "", "CHOOSE_DATE", "USER_NAME"); - Apache::lonwizard::date_state->new($wizard, "CHOOSE_DATE", "Set Date", "PARM_DATE", "FINISH", "What should the $dateType be set to?"); + Apache::lonwizard::date_state->new($wizard, "CHOOSE_DATE", "Set Date", "PARM_DATE", "CHOOSE_STUDENT_LEVEL", "What should the $dateType be set to?"); + Apache::lonwizard::switch_state->new($wizard, "CHOOSE_STUDENT_LEVEL", "Students Affected", "TARGETS", [ + ["course", ". . . for all students in the course", "FINISH"], + ["section", ". . . for a particular section", "CHOOSE_SECTION"], + ["student", ". . . for an individual student", "CHOOSE_STUDENT"]], + "Set $dateType of $levelType for. . ."); + + Apache::lonwizard::choose_section->new($wizard, "CHOOSE_SECTION", "Select Section", "Please select the section you wish to set the $dateType for:", "", "FINISH", "SECTION_NAME"); + Apache::lonwizard::choose_student->new($wizard, "CHOOSE_STUDENT", "Select Student", "Please select the student you wish to set the $dateType for:", "", "FINISH", "USER_NAME"); Apache::lonwizard::parmwizfinal->new($wizard, "FINISH", "Confirm Selection"); $r->print($wizard->display()); @@ -429,6 +450,8 @@ It is importent to remember when constru None of the pre-packaged states correctly handle there being B input, as the wizard does not currently have any protection against errors in the states themselves. (The closest thing you can do is set the wizard to be done and display an error message, which should be adequate.) +By default, the wizard framework will take form elements of the form {VAR_NAME}.forminput and automatically insert the contents of that form element into the wizard variable {VAR_NAME}. You only need to use postprocess to do something fancy if that is not sufficient, for instance, processing a multi-element selection. (See resource choice for an example of that.) + =head2 lonwizstate methods These methods should be overridden in derived states, except B which may be sufficient. @@ -634,8 +657,7 @@ sub render { $result .= '' . $self->{ERROR_MSG} . '

'; } - if (defined $self->{MESSAGE_BEFORE}) - { + if (defined $self->{MESSAGE_BEFORE}) { $result .= $self->{MESSAGE_BEFORE} . '

'; } @@ -646,7 +668,7 @@ sub render { foreach (@keys) { $result .= "\n"; } $result .= "\n\n"; @@ -663,7 +685,7 @@ sub postprocess { my $wizard = $self->{WIZARD}; my $formvalue = $ENV{'form.' . $self->{VAR_NAME} . '.forminput'}; if ($formvalue) { - $wizard->setVar($self->{VAR_NAME}, $formvalue); + # Value already stored by Wizard $wizard->changeState($self->{NEXT_STATE}); } else { $self->{ERROR_MSG} = "Can't continue the wizard because you must make" @@ -745,11 +767,10 @@ sub render { } sub postprocess { + # Value already stored by wizard my $self = shift; my $wizard = $self->{WIZARD}; my $chosenValue = $ENV{"form." . $self->{VAR_NAME} . '.forminput'}; - $wizard->setVar($self->{VAR_NAME}, $chosenValue) - if (defined ($self->{VAR_NAME})); foreach my $choice (@{$self->{CHOICE_LIST}}) { @@ -858,7 +879,7 @@ sub render { } else { $result .= "\n"; } $result .= "\n"; @@ -870,7 +891,7 @@ sub render { } else { $result .= '\n"; } $result .= ",\n"; @@ -882,43 +903,50 @@ sub render { } else { $result .= "\n"; } $result .= ",\n"; # Display Hours and Minutes if they are called for if (!$self->{DISPLAY_JUST_DATE}) { + # Build hour $result .= " :\n"; $result .= "\n"; - - $result .= ""; } if (defined ($self->{MESSAGE_AFTER})) { @@ -997,7 +1025,7 @@ sub render { 'due_date' => "0_duedate", 'answer_date' => "0_answerdate"); - my $result = "\n"; + my $result = "\n"; $result .= '

Confirm that this information is correct, then click "Finish Wizard" to complete setting the parameter.

    '; my $affectedResourceId = ""; my $parm_name = $parmTypeHash{$wizvars->{ACTION_TYPE}}; @@ -1099,18 +1127,16 @@ package Apache::lonwizard::resource_choi =head2 Class: resource_choice -folder_choice gives the user an opportunity to select one resource from the current course, and will stick the ID of that choice (#.#) into the desired variable. +resource_choice gives the user an opportunity to select one resource from the current course, and will stick the ID of that choice (#.#) into the desired variable. Note this state will not automatically advance if there is only one choice, because it might confuse the user in this case. =over 4 -=item overriddent method B(parentLonWizReference, stateName, stateTitle, messageBefore, messageAfter, nextState, varName, filterFunction, choiceFunction, multichoice): messageBefore and messageAfter appear before and after the state choice, respectively. nextState is the state to proceed to after the choice. varName is the wizard variable to store the choice in. +=item overridden method B(parentLonWizReference, stateName, stateTitle, messageBefore, messageAfter, nextState, varName, filterFunction, choiceFunction): messageBefore and messageAfter appear before and after the state choice, respectively. nextState is the state to proceed to after the choice. varName is the wizard variable to store the choice in. filterFunction is a function reference that receives the current resource as an argument, and returns 1 if it should be displayed, and 0 if it should not be displayed. By default, the class will use sub {return 1;}, which will show all resources. choiceFunction is a reference to a function that receives the resource object as a parameter and returns 1 if it should be a *selectable choice*, and 0 if not. By default, this is the same as the filterFunction, which means all displayed choices will be choosable. See parm wizard for an example of this in the resource selection routines. -multichoice specifies whether the state should provide radio buttons, allowing the user one choice, or checkboxes, allowing the user multiple choices, and automatically including some convenience buttons the user can choose (like "Check All" and "Uncheck All"), implemented with Javascript. Defaults to false, allow just one choice. - =back =cut @@ -1136,10 +1162,6 @@ sub new { if (!defined($self->{CHOICE_FUNC})) { $self->{CHOICE_FUNC} = $self->{FILTER_FUNC}; } - $self->{MULTICHOICE} = shift; - if (!defined($self->{MULTICHOICE})) { - $self->{MULTICHOICE} = 0; - } } sub postprocess { @@ -1152,13 +1174,29 @@ sub postprocess { return; } - my $chosenValue = $ENV{"form." . $self->{VAR_NAME} . ".forminput"}; - $wizard->setVar($self->{VAR_NAME}, $chosenValue) - if (defined($self->{VAR_NAME})); - + if (!$ENV{'form.' . $self->{VAR_NAME} . '.forminput'}) { + $self->{ERROR_MSG} = "Can't continue wizard because you must ". + "select a resource."; + return; + } + + + # Value stored by wizard framework + $wizard->changeState($self->{NEXT_STATE}); } +# A note, in case I don't get to this before I leave. +# If someone complains about the "Back" button returning them +# to the previous folder state, instead of returning them to +# the previous wizard state, the *correct* answer is for the wizard +# to keep track of how many times the user has manipulated the folders, +# and feed that to the history.go() call in the wizard rendering routines. +# If done correctly, the wizard itself can keep track of how many times +# it renders the same states, so it doesn't go in just this state, and +# you can lean on the browser back button to make sure it all chains +# correctly. + sub render { my $self = shift; my $wizard = $self->{WIZARD}; @@ -1174,18 +1212,13 @@ sub render { $vals->{$curVal} = 1; } - $result .= $self->{MESSAGE_BEFORE} if (defined $self->{MESSAGE_BEFORE}); - - # Get the course nav map - my $navmap = Apache::lonnavmaps::navmap->new( - $ENV{"request.course.fn"}.".db", - $ENV{"request.course.fn"}."_parms.db", 0, 0); - - if (!defined($navmap)) { - return "Something has gone wrong with the map selection feature. Please contact your administrator."; + if (defined $self->{ERROR_MSG}) { + $result .= '' . $self->{ERROR_MSG} . '

    '; } - my $iterator = $navmap->getIterator(undef, undef, undef, 0, 0); + $result .= $self->{MESSAGE_BEFORE} . '

    ' + if (defined $self->{MESSAGE_BEFORE}); + my $filterFunc = $self->{FILTER_FUNC}; my $choiceFunc = $self->{CHOICE_FUNC}; @@ -1206,15 +1239,13 @@ sub render { }; $result .= - &Apache::lonnavmaps::render( { "iterator" => $iterator, - 'cols' => [$renderColFunc, + &Apache::lonnavmaps::render( { 'cols' => [$renderColFunc, Apache::lonnavmaps::resource()], 'showParts' => 0, 'queryString' => $wizard->queryStringVars() . '&folderManip=1', - 'url' => '/adm/wizard'} ); + 'url' => '/adm/wizard', + 'filterFunc' => $filterFunc } ); - $navmap->untieHashes(); - $result .= $self->{MESSAGE_AFTER} if (defined $self->{MESSAGE_AFTER}); return $result; @@ -1222,6 +1253,144 @@ sub render { 1; +package Apache::lonwizard::resource_multichoice; + +=pod + +=head2 Class: resource_multichoice + +resource_multichoice gives the user an opportunity to select multiple resources from some map in the current course, and will stick a list of the IDs of those choices in its variable. + +Note this state will not automatically advance if there is only one choice, because it might confuse the user. Also, the state will not advance until at least I choice is taken, because it is generally nonsense to select nothing when this state is used. + +This is generally intended for use on a specific sequence, not the entire course, as for technical reasons the user can't open and close folders, so they must all be shown as open. To fix this would require making the folders image form submitters and remembering the selected state of each resource, which is not impossible but is too much error-prone work to do until it seems many people will want that feature. + +=over 4 + +=item overridden method B(parentLonWizReference, stateName, stateTitle, messageBefore, messageAfter, nextState, varName, filterFunction, choiceFunction, map): Arguments like resource_choice. map is the ID number of a specific map that, if given is all that will be shown to the user, instead of the whole course. + +=back + +=cut + +no strict; +@ISA = ("Apache::lonwizard::state"); +use strict; + +sub new { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = bless $proto->SUPER::new(shift, shift, shift); + + $self->{MESSAGE_BEFORE} = shift; + $self->{MESSAGE_AFTER} = shift; + $self->{NEXT_STATE} = shift; + $self->{VAR_NAME} = shift; + $self->{FILTER_FUNC} = shift; + if (!defined($self->{FILTER_FUNC})) { + $self->{FILTER_FUNC} = sub {return 1;}; + } + $self->{CHOICE_FUNC} = shift; + if (!defined($self->{CHOICE_FUNC})) { + $self->{CHOICE_FUNC} = $self->{FILTER_FUNC}; + } + $self->{MAP} = shift; + if (!defined($self->{MAP})) { + $self->{MAP} = 1; # 0? trying to default to entire course + } +} + +sub postprocess { + my $self = shift; + my $wizard = $self->{WIZARD}; + + my $formvalue = $ENV{'form.' . $self->{VAR_NAME} . '.forminput'}; + if ($formvalue) { + # Must extract values from $wizard->{DATA} directly, as there + # may be more then one. + my @values; + for my $formparam (split (/&/, $wizard->{DATA})) { + my ($name, $value) = split(/=/, $formparam); + if ($name ne $self->{VAR_NAME} . '.forminput') { + next; + } + $value =~ tr/+/ /; + $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; + push @values, $value; + } + $wizard->setVar($self->{VAR_NAME}, join('|||', @values)); + } + + # If nothing was selected... + if (!$wizard->{VARS}->{$self->{VAR_NAME}}) { + $self->{ERROR_MSG} = "You must select one or more resources to continue."; + return; + } + + $wizard->changeState($self->{NEXT_STATE}); +} + +sub render { + my $self = shift; + my $wizard = $self->{WIZARD}; + my $var = $self->{VAR_NAME}; + my $result = < + function checkall(value) { + for (i=0; i +SCRIPT + + my $buttons = < + +
    +BUTTONS + + if (defined $self->{ERROR_MSG}) { + $result .= '' . $self->{ERROR_MSG} . '

    '; + } + + $result .= $self->{MESSAGE_BEFORE} . '

    ' + if (defined $self->{MESSAGE_BEFORE}); + + my $filterFunc = $self->{FILTER_FUNC}; + my $choiceFunc = $self->{CHOICE_FUNC}; + + # Create the composite function that renders the column on the nav map + my $renderColFunc = sub { + my ($resource, $part, $params) = @_; + + if (!&$choiceFunc($resource)) { + return ' '; + } else { + my $col = ""; + return $col; + } + }; + + $result .= $buttons; + + $result .= + &Apache::lonnavmaps::render( { 'cols' => [$renderColFunc, + Apache::lonnavmaps::resource()], + 'showParts' => 0, + 'filterFunc' => $filterFunc, + 'iterator_map' => $self->{MAP}, + 'resource_no_folder_link' => 1 } ); + + $result .= $buttons; + + $result .= $self->{MESSAGE_AFTER} if (defined $self->{MESSAGE_AFTER}); + + return $result; +} +1; + package Apache::lonwizard::choose_student; no strict; @@ -1281,3 +1450,154 @@ sub determineChoices { 1; +package Apache::lonwizard::choose_files; + +=pod + +=head2 Class: choose_file + +choose_file offers a choice of files from a given directory. It will store them as a triple-pipe delimited list in its given wizard variable, in the standard HTML multiple-selection tradition. A filter function can be passed, which will examine the filename and return 1 if it should be displayed, or 0 if not. + +=over 4 + +=item * overridden method B(parentLonWizReference, stateName, stateTitle, messageBefore, messageAfter, nextState, varName, subdir, filterFunc): As in previous states, where filterFunc is as described in choose_file. subdir is the name of the subdirectory to offer choices from. + +=back + +=cut + +no strict; +@ISA = ("Apache::lonwizard::state"); +use strict; + +sub new { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = bless $proto->SUPER::new(shift, shift, shift); + + $self->{MESSAGE_BEFORE} = shift; + $self->{MESSAGE_AFTER} = shift; + $self->{NEXT_STATE} = shift; + $self->{VAR_NAME} = shift; + $self->{SUB_DIR} = shift; + $self->{FILTER_FUNC} = shift; + + if (!defined($self->{FILTER_FUNC})) { + $self->{FILTER_FUNC} = sub {return 1;}; + } + + return $self; +} + +sub render { + my $self = shift; + my $result = ''; + my $var = $self->{VAR_NAME}; + my $subdir = $self->{SUB_DIR}; + my $filterFunc = $self->{FILTER_FUNC}; + + $result = < + function checkall(value) { + for (i=0; i +SCRIPT + + my $buttons = <   + + +
      +BUTTONS + + if (defined $self->{ERROR_MSG}) { + $result .= '' . $self->{ERROR_MSG} . '

    '; + } + + if ($self->{MESSAGE_BEFORE}) { + $result .= $self->{MESSAGE_BEFORE} . '
    '; + } + + # Get the list of files in this directory. + my @fileList; + + # If the subdirectory is in local CSTR space + if ($subdir =~ m|/home/([^/]+)/public_html|) { + my $user = $1; + my $domain = $Apache::lonnet::perlvar{'lonDefDomain'}; + @fileList = &Apache::lonnet::dirlist($subdir, $domain, $user, ''); + } else { + # local library server resource space + @fileList = &Apache::lonnet::dirlist($subdir, $ENV{'user.domain'}, $ENV{'user.name'}, ''); + } + + $result .= $buttons; + + $result .= ''; + + # Keeps track if there are no choices, prints appropriate error + # if there are none. + my $choices = 0; + # Print each legitimate file choice. + for my $file (@fileList) { + $file = (split(/&/, $file))[0]; + my $fileName = $subdir .'/'. $file; + if (&$filterFunc($file)) { + $result .= '\n"; + $choices++; + } + } + + $result .= "
    ' . + "" . $file . "
    \n"; + + if (!$choices) { + $result .= 'There are no files available to select in this directory. Please go back and select another option.

    '; + } + + $result .= $buttons; + + if ($self->{MESSAGE_AFTER}) { + $result .= "

    " . $self->{MESSAGE_AFTER}; + } + + return $result; +} + +sub postprocess { + my $self = shift; + print $self->{NEXT_STATE}; + my $wizard = $self->{WIZARD}; + my $formvalue = $ENV{'form.' . $self->{VAR_NAME} . '.forminput'}; + + if ($formvalue) { + # Must extract values from $wizard->{DATA} directly, as there + # may be more then one. + my @values; + for my $formparam (split (/&/, $wizard->{DATA})) { + my ($name, $value) = split(/=/, $formparam); + if ($name ne $self->{VAR_NAME} . '.forminput') { + next; + } + $value =~ tr/+/ /; + $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; + push @values, $value; + } + $wizard->setVar($self->{VAR_NAME}, join('|||', @values)); + $wizard->changeState($self->{NEXT_STATE}); + } else { + $self->{ERROR_MSG} = "Can't continue the wizard because you ". + "must make a selection to continue."; + } + return 1; +} + +1;