Diff for /loncom/interface/lonhelper.pm between versions 1.159 and 1.160

version 1.159, 2006/12/12 20:41:08 version 1.160, 2006/12/18 21:48:47
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 1100  sub render { Line 1114  sub render {
   
     my $text;      my $text;
     if ( $self->{HELP_TEXT} ne '') {      if ( $self->{HELP_TEXT} ne '') {
  $text=&mtn($text);   $text=&mtn($self->{HELP_TEXT});
     }      }
   
     return &Apache::loncommon::help_open_topic($self->{HELP_FILE},      return &Apache::loncommon::help_open_topic($self->{HELP_FILE},
        $text);         $text);
 }  }
   sub postprocess {
       my $self = shift;
       if (defined($self->{NEXTSTATE})) {
           $helper->changeState($self->{NEXTSTATE});
       }
   
       return 1;
   }
   
 1;  1;
   
 package Apache::lonhelper::skip;  package Apache::lonhelper::skip;
Line 3500  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 .

Removed from v.1.159  
changed lines
  Added in v.1.160


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>