version 1.158, 2006/08/01 15:12:32
|
version 1.161.2.1, 2007/10/02 00:33:02
|
Line 81 State tags are also required to have an
|
Line 81 State tags are also required to have an
|
human name of the state, and will be displayed as the header on top of |
human name of the state, and will be displayed as the header on top of |
the screen for the user. |
the screen for the user. |
|
|
|
State tags may also optionally have an attribute "help" which should be |
|
the filename of a help file, this will add a blue ? to the title. |
|
|
=head2 Example Helper Skeleton |
=head2 Example Helper Skeleton |
|
|
An example of the tags so far: |
An example of the tags so far: |
|
|
<helper title="Example Helper"> |
<helper title="Example Helper"> |
<state name="START" title="Demonstrating the Example Helper"> |
<state name="START" title="Demonstrating the Example Helper"> |
<!-- notice this is the START state the wizard requires --> |
<!-- notice this is the START state the helper requires --> |
</state> |
</state> |
<state name="GET_NAME" title="Enter Student Name"> |
<state name="GET_NAME" title="Enter Student Name"> |
</state> |
</state> |
</helper> |
</helper> |
|
|
Of course this does nothing. In order for the wizard to do something, it is |
Of course this does nothing. In order for the helper to do something, it is |
necessary to put actual elements into the wizard. Documentation for each |
necessary to put actual elements into the helper. Documentation for each |
of these elements follows. |
of these elements follows. |
|
|
=head1 Creating a Helper With Code, Not XML |
=head1 Creating a Helper With Code, Not XML |
|
|
In some situations, such as the printing wizard (see lonprintout.pm), |
In some situations, such as the printing helper (see lonprintout.pm), |
writing the helper in XML would be too complicated, because of scope |
writing the helper in XML would be too complicated, because of scope |
issues or the fact that the code actually outweighs the XML. It is |
issues or the fact that the code actually outweighs the XML. It is |
possible to create a helper via code, though it is a little odd. |
possible to create a helper via code, though it is a little odd. |
Line 334 sub start_state {
|
Line 337 sub start_state {
|
} |
} |
|
|
Apache::lonhelper::state->new($token->[2]{'name'}, |
Apache::lonhelper::state->new($token->[2]{'name'}, |
$token->[2]{'title'}); |
$token->[2]{'title'}, |
|
$token->[2]{'help'}); |
return ''; |
return ''; |
} |
} |
|
|
Line 577 sub display {
|
Line 581 sub display {
|
|
|
# Phase 4: Display. |
# Phase 4: Display. |
my $stateTitle=&mt($state->title()); |
my $stateTitle=&mt($state->title()); |
|
my $stateHelp= $state->help(); |
my $browser_searcher_js = |
my $browser_searcher_js = |
'<script type="text/javascript">'."\n". |
'<script type="text/javascript">'."\n". |
&Apache::loncommon::browser_and_searcher_javascript(). |
&Apache::loncommon::browser_and_searcher_javascript(). |
Line 591 sub display {
|
Line 596 sub display {
|
|
|
|
|
if (!$state->overrideForm()) { $result.="<form name='helpform' method='POST'>"; } |
if (!$state->overrideForm()) { $result.="<form name='helpform' method='POST'>"; } |
|
if ($stateHelp) { |
|
$stateHelp = &Apache::loncommon::help_open_topic($stateHelp); |
|
} |
$result .= <<HEADER; |
$result .= <<HEADER; |
<table border="0" width='100%'><tr><td> |
<table border="0" width='100%'><tr><td> |
<h2><i>$stateTitle</i></h2> |
<h2><i>$stateTitle</i>$stateHelp</h2> |
HEADER |
HEADER |
|
|
$result .= "<table cellpadding='10' width='100%'><tr><td rowspan='2' valign='top'>"; |
$result .= "<table cellpadding='10' width='100%'><tr><td rowspan='2' valign='top'>"; |
Line 680 sub new {
|
Line 688 sub new {
|
|
|
$self->{NAME} = shift; |
$self->{NAME} = shift; |
$self->{TITLE} = shift; |
$self->{TITLE} = shift; |
|
$self->{HELP} = shift; |
$self->{ELEMENTS} = []; |
$self->{ELEMENTS} = []; |
|
|
bless($self, $class); |
bless($self, $class); |
Line 701 sub title {
|
Line 710 sub title {
|
return $self->{TITLE}; |
return $self->{TITLE}; |
} |
} |
|
|
|
sub help { |
|
my $self = shift; |
|
return $self->{HELP}; |
|
} |
|
|
sub preprocess { |
sub preprocess { |
my $self = shift; |
my $self = shift; |
for my $element (@{$self->{ELEMENTS}}) { |
for my $element (@{$self->{ELEMENTS}}) { |
Line 792 the element. How this value is interpret
|
Line 806 the element. How this value is interpret
|
the element itself, and possibly the settings the element has (such as |
the element itself, and possibly the settings the element has (such as |
multichoice vs. single choice for <choices> tags). |
multichoice vs. single choice for <choices> tags). |
|
|
This is also intended for things like the course initialization wizard, where the |
This is also intended for things like the course initialization helper, where the |
user is setting various parameters. By correctly grabbing current settings |
user is setting various parameters. By correctly grabbing current settings |
and including them into the helper, it allows the user to come back to the |
and including them into the helper, it allows the user to come back to the |
helper later and re-execute it, without needing to worry about overwriting |
helper later and re-execute it, without needing to worry about overwriting |
Line 1010 sub end_message {
|
Line 1024 sub end_message {
|
sub render { |
sub render { |
my $self = shift; |
my $self = shift; |
|
|
return &mtn($self->{MESSAGE_TEXT}); |
return $self->{MESSAGE_TEXT}; |
} |
} |
# If a NEXTSTATE was given, switch to it |
# If a NEXTSTATE was given, switch to it |
sub postprocess { |
sub postprocess { |
Line 1023 sub postprocess {
|
Line 1037 sub postprocess {
|
} |
} |
1; |
1; |
|
|
|
package Apache::lonhelper::helpicon; |
|
|
|
=pod |
|
|
|
=head1 Elements |
|
|
|
=head2 Element: helpiconX<helpicon, helper element> |
|
|
|
Helpicon elements add a help icon at the current location. |
|
Example: |
|
|
|
<helpicon file="Help"> |
|
General Help |
|
</helpicon> |
|
|
|
In this example will generate a help icon to the Help.hlp url with a |
|
description of 'General Help'. The description is not required and if |
|
left out (Example: <helpicon file="Help" /> only the icon will be |
|
added.) |
|
|
|
=head3 Localization |
|
|
|
The description text will be run through the normalize_string function |
|
and that will be used as a call to &mt. |
|
|
|
=cut |
|
|
|
no strict; |
|
@ISA = ("Apache::lonhelper::element"); |
|
use strict; |
|
use Apache::lonlocal; |
|
|
|
BEGIN { |
|
&Apache::lonhelper::register('Apache::lonhelper::helpicon', |
|
('helpicon')); |
|
} |
|
|
|
sub new { |
|
my $ref = Apache::lonhelper::element->new(); |
|
bless($ref); |
|
} |
|
|
|
# CONSTRUCTION: Construct the message element from the XML |
|
sub start_helpicon { |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
|
|
if ($target ne 'helper') { |
|
return ''; |
|
} |
|
|
|
$paramHash->{HELP_TEXT} = &mtn(&Apache::lonxml::get_all_text('/helpicon', |
|
$parser)); |
|
|
|
$paramHash->{HELP_TEXT} =~s/^\s+//; |
|
$paramHash->{HELP_TEXT} =~s/\s+$//; |
|
|
|
if (defined($token->[2]{'file'})) { |
|
$paramHash->{HELP_FILE} = $token->[2]{'file'}; |
|
} |
|
return ''; |
|
} |
|
|
|
sub end_helpicon { |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
|
|
if ($target ne 'helper') { |
|
return ''; |
|
} |
|
Apache::lonhelper::helpicon->new(); |
|
return ''; |
|
} |
|
|
|
sub render { |
|
my $self = shift; |
|
|
|
my $text; |
|
if ( $self->{HELP_TEXT} ne '') { |
|
$text=&mtn($self->{HELP_TEXT}); |
|
} |
|
|
|
return &Apache::loncommon::help_open_topic($self->{HELP_FILE}, |
|
$text); |
|
} |
|
sub postprocess { |
|
my $self = shift; |
|
if (defined($self->{NEXTSTATE})) { |
|
$helper->changeState($self->{NEXTSTATE}); |
|
} |
|
|
|
return 1; |
|
} |
|
|
|
1; |
|
|
package Apache::lonhelper::skip; |
package Apache::lonhelper::skip; |
|
|
=pod |
=pod |
Line 1369 BUTTONS
|
Line 1477 BUTTONS
|
$choiceLabel = &$choiceLabel($helper, $self); |
$choiceLabel = &$choiceLabel($helper, $self); |
} |
} |
$result .= "/></td><td> ".qq{<label for="id$id">}. |
$result .= "/></td><td> ".qq{<label for="id$id">}. |
$choiceLabel. "</label></td>"; |
$choiceLabel. "</label></td>"; |
if ($choice->[4]) { |
if ($choice->[4]) { |
$result .='<td><input type="text" size="5" name="' |
$result .='<td><input type="text" size="5" name="' |
.$choice->[4].'_forminput" value="' |
.$choice->[4].'_forminput" value="' |
Line 3415 sub overrideForm {
|
Line 3523 sub overrideForm {
|
|
|
package Apache::lonhelper::parmwizfinal; |
package Apache::lonhelper::parmwizfinal; |
|
|
# This is the final state for the parmwizard. It is not generally useful, |
# This is the final state for the parm helper. It is not generally useful, |
# so it is not perldoc'ed. It does its own processing. |
# so it is not perldoc'ed. It does its own processing. |
# It is represented with <parmwizfinal />, and |
# It is represented with <parmwizfinal />, and |
# should later be moved to lonparmset.pm . |
# should later be moved to lonparmset.pm . |