Diff for /loncom/homework/edit.pm between versions 1.37 and 1.38

version 1.37, 2002/10/25 19:02:38 version 1.38, 2002/11/03 19:16:19
Line 39  use HTML::Entities(); Line 39  use HTML::Entities();
 @Apache::edit::colorlist=('#ffffff','#ff0000','#00ff00','#0000ff','#0ff000','#000ff0','#f0000f');  @Apache::edit::colorlist=('#ffffff','#ff0000','#00ff00','#0000ff','#0ff000','#000ff0','#f0000f');
 # depth of nesting of edit  # depth of nesting of edit
 $Apache::edit::colordepth=0;  $Apache::edit::colordepth=0;
   @Apache::edit::inserttag=();
   
 sub initialize_edit {  sub initialize_edit {
   $Apache::edit::colordepth=0;    $Apache::edit::colordepth=0;
     @Apache::edit::inserttag=();
 }  }
   
 sub tag_start {  sub tag_start {
Line 96  sub start_table { Line 98  sub start_table {
     $color = $Apache::edit::colorlist[$Apache::edit::colordepth];      $color = $Apache::edit::colorlist[$Apache::edit::colordepth];
   }    }
   $Apache::edit::colordepth++;    $Apache::edit::colordepth++;
   my $result="<table bgcolor=\"$color\" width=\"100%\" border=\"5\">";    push(@Apache::edit::inserttag,$token->[1]);
     my $result="<p align=\"right\"><table bgcolor=\"$color\" width=\"95%\" border=\"2\">";
   return $result;    return $result;
 }  }
   
 sub end_table {  sub end_table {
   $Apache::edit::colordepth--;    $Apache::edit::colordepth--;
   my $result="</table>";    my $result="</table></p>";
     $result.=
    "<p><table width=\"100%\"><tr><td>".
           &innerinsertlist('edit',
    (defined($Apache::edit::inserttag[-2])?$Apache::edit::inserttag[-2]:'problem')
   ,
    (defined($Apache::edit::inserttag[-1])?$Apache::edit::inserttag[-1]:'')).
           "</td></tr></table></p>";
     pop(@Apache::edit::inserttag);
   return $result;    return $result;
 }  }
   
Line 152  sub handle_delete { Line 163  sub handle_delete {
 }  }
   
 sub get_insert_list {  sub get_insert_list {
   my ($token) = @_;    my ($tagname) = @_;
   my $result='';    my $result='';
   my @tagnums= ();    my @tagnums= ();
   #&Apache::lonxml::debug("keys ".join("\n",sort(keys(%Apache::lonxml::insertlist))));    #&Apache::lonxml::debug("keys ".join("\n",sort(keys(%Apache::lonxml::insertlist))));
   if ($Apache::lonxml::insertlist{"$token->[1].which"}) {    if ($Apache::lonxml::insertlist{"$tagname.which"}) {
     push (@tagnums, @{ $Apache::lonxml::insertlist{"$token->[1].which"} });      push (@tagnums, @{ $Apache::lonxml::insertlist{"$tagname.which"} });
   }    }
   foreach my $namespace (@Apache::lonxml::namespace) {    foreach my $namespace (@Apache::lonxml::namespace) {
     if ($Apache::lonxml::insertlist{"$namespace".'::'."$token->[1].which"}) {      if ($Apache::lonxml::insertlist{"$namespace".'::'."$tagname.which"}) {
       push (@tagnums, @{ $Apache::lonxml::insertlist{"$namespace".'::'."$token->[1].which"} });        push (@tagnums, @{ $Apache::lonxml::insertlist{"$namespace".'::'."$tagname.which"} });
     }      }
   }    }
   if (@tagnums) {    if (@tagnums) {
Line 178  sub get_insert_list { Line 189  sub get_insert_list {
   
 sub insertlist {  sub insertlist {
   my ($target,$token) = @_;    my ($target,$token) = @_;
     return &innerinsertlist($target,$token->[1]);
   }
   
   sub innerinsertlist {
     my ($target,$tagname,$closingtag) = @_;
   my $result;    my $result;
     my $after='';
     if ($closingtag) {
        $after='_after_'.$closingtag; 
     }
   if ($target eq 'edit') {    if ($target eq 'edit') {
     my $optionlist= &get_insert_list($token);      my $optionlist= &get_insert_list($tagname);
     if ($optionlist) {      if ($optionlist) {
       $result = "Insert:        $result = "Insert:
 <select name=\"insert_$Apache::lonxml::curdepth\">  <select name=\"insert$after\_$Apache::lonxml::curdepth\">
 $optionlist  $optionlist
 </select>"  </select>"
     } else {      } else {
Line 215  sub handle_insert { Line 235  sub handle_insert {
     }      }
   }    }
   return $result;    return $result;
   }
   
   sub handle_insertafter {
     my $tagname=shift;
     if ($ENV{"form.insert_after_$tagname\_$Apache::lonxml::curdepth"} eq '')
        { return ''; }
     my $result;
     my $tagnum =$ENV{"form.insert_after_$tagname\_$Apache::lonxml::curdepth"};
     my $func=$Apache::lonxml::insertlist{"$tagnum.function"};
     if ($func eq 'default') {
       my $newtag=$Apache::lonxml::insertlist{"$tagnum.tag"};
       my $namespace;
       if ($newtag =~ /::/) { ($namespace,$newtag) = split(/::/,$newtag); }
       $result.="\n<$newtag>\n</$newtag>";
     } else {
       if (defined(&$func)) {
         {
    no strict 'refs';
    $result.=&$func();
         }
       } else {
         my $newtag=$Apache::lonxml::insertlist{"$tagnum.tag"};
         &Apache::lonxml::error("Unable to insert (after) tag $newtag, $func was not defined. ($tagname $tagnum)");
       }
     }
     return $result;
 }  }
   
 sub insert_responseparam {  sub insert_responseparam {

Removed from v.1.37  
changed lines
  Added in v.1.38


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