Diff for /loncom/homework/edit.pm between versions 1.27 and 1.35

version 1.27, 2002/01/11 16:32:29 version 1.35, 2002/07/17 18:06:18
Line 27 Line 27
 #  #
 # 3/20 Guy  # 3/20 Guy
 # 01/10/02 Matthew  # 01/10/02 Matthew
   # 03/06/02 Matthew
 package Apache::edit;   package Apache::edit; 
   
 use strict;  use strict;
 use Apache::lonnet;  use Apache::lonnet();
   use HTML::Entities();
   
 # Global Vars  # Global Vars
 # default list of colors to use in editing  # default list of colors to use in editing
Line 163  sub get_insert_list { Line 165  sub get_insert_list {
     }      }
   }    }
   if (@tagnums) {    if (@tagnums) {
       my %options;
     foreach my $tagnum (@tagnums) {      foreach my $tagnum (@tagnums) {
       $result.='<option value="'.$tagnum.'">'.$Apache::lonxml::insertlist{"$tagnum.description"}."</option>\n";        my $descrip=$Apache::lonxml::insertlist{"$tagnum.description"};
         $options{$descrip} ="<option value=\"$tagnum\">".$descrip."</option>\n";
     }      }
       foreach my $option (sort(keys(%options))) { $result.=$options{$option}; }
     if ($result) { $result='<option selected="on"></option>'.$result; }      if ($result) { $result='<option selected="on"></option>'.$result; }
   }    }
   return $result;    return $result;
Line 300  sub textarea_sizes { Line 305  sub textarea_sizes {
   return ($rows,$cols);    return ($rows,$cols);
 }  }
   
   sub editline {
       my ($tag,$data,$description,$size)=@_;
       $data=&HTML::Entities::encode($data);
       if ($description) { $description="<br />".$description."<br />"; }
       my $result = <<"END";
   $description
   <input type="text" name="homework_edit_$Apache::lonxml::curdepth" 
          value="$data" size="$size" />
   END
       return $result;
   }
   
 sub editfield {  sub editfield {
   my ($tag,$data,$description,$minwidth,$minheight)=@_;    my ($tag,$data,$description,$minwidth,$minheight)=@_;
   
Line 308  sub editfield { Line 325  sub editfield {
   if ($cols < $minwidth ) { $cols = $minwidth; }    if ($cols < $minwidth ) { $cols = $minwidth; }
   if ($rows < $minheight) { $rows = $minheight; }    if ($rows < $minheight) { $rows = $minheight; }
   if ($description) { $description="<br />".$description."<br />"; }    if ($description) { $description="<br />".$description."<br />"; }
   return "$description\n&nbsp;&nbsp;&nbsp;<textarea rows=\"$rows\" cols=\"$cols\" name=\"homework_edit_".$Apache::lonxml::curdepth."\">$data</textarea>\n";    return $description."\n".'&nbsp;&nbsp;&nbsp;<textarea rows="'.$rows.
       '" cols="'.$cols.'" name="homework_edit_'.$Apache::lonxml::curdepth.'">'.
         &HTML::Entities::encode($data).'</textarea>'."\n";
 }  }
   
 sub modifiedfield {  sub modifiedfield {
Line 320  sub modifiedfield { Line 339  sub modifiedfield {
 #  &Apache::lonxml::debug("I want homework_edit_$Apache::lonxml::curdepth");  #  &Apache::lonxml::debug("I want homework_edit_$Apache::lonxml::curdepth");
 #  &Apache::lonxml::debug($ENV{"form.homework_edit_$Apache::lonxml::curdepth"});  #  &Apache::lonxml::debug($ENV{"form.homework_edit_$Apache::lonxml::curdepth"});
   $result=$ENV{"form.homework_edit_$Apache::lonxml::curdepth"};    $result=$ENV{"form.homework_edit_$Apache::lonxml::curdepth"};
   if (defined $token) {  
     if (defined $token->[4]) {  
       $result=$token->[4].$result;  
     } else {  
       $result=$result.$token->[2];  
     }  
   }  
   return $result;    return $result;
 }  }
   
Line 414  sub select_or_text_arg { Line 426  sub select_or_text_arg {
     }      }
   }    }
   $optionlist.="<option value=\"TYPEDINVALUE\">Type in value</option>\n";    $optionlist.="<option value=\"TYPEDINVALUE\">Type in value</option>\n";
   if ($found) {    if (($found) || (!$selected)) {
     $result.=$description.'<select name="'."$Apache::lonxml::curdepth.$name".'">      $result.=$description.'<select name="'."$Apache::lonxml::curdepth.$name".'">
        '.$optionlist.'         '.$optionlist.'
       </select>';        </select>';
Line 423  sub select_or_text_arg { Line 435  sub select_or_text_arg {
   }    }
   return $result;    return $result;
 }  }
   
   #----------------------------------------------------- browse
   sub browse {
       # insert a link to call up the filesystem browser (lonindexer)
       $_ = shift;
       my $form    = 'lonhomework';
       my $element = &Apache::lonnet::escape("$Apache::lonxml::curdepth.$_");
       my $result = <<"ENDBUTTON";
   <a href=\"javascript:openbrowser('$form','$element')\"\>Browse</a>
   ENDBUTTON
       return $result;
   }
   
   #----------------------------------------------------- browse
   sub search {
       # insert a link to call up the filesystem browser (lonindexer)
       $_ = shift;
       my $form    = 'lonhomework';
       my $element = &Apache::lonnet::escape("$Apache::lonxml::curdepth.$_");
       my $result = <<"ENDBUTTON";
   <a href=\"javascript:opensearcher('$form','$element')\"\>Search</a>
   ENDBUTTON
       return $result;
   }
   
   
 1;  1;
 __END__  __END__
   
Line 522  from lonxml; return a scalar string Line 560  from lonxml; return a scalar string
 get_insert_list($token) : provide an insertion list based on possibilities  get_insert_list($token) : provide an insertion list based on possibilities
 from lonxml; return a scalar string  from lonxml; return a scalar string
   
   =item *
   browse($elementname) : provide a link which will open up the filesystem
   browser (lonindexer) and, once a file is selected, place the result in
   the form element $elementname.
   
   =item *
   search($elementname) : provide a link which will open up the filesystem
   searcher (lonsearchcat) and, once a file is selected, place the result in
   the form element $elementname.
   
   =item *
   editline(tag,data,description,size): Provide a <input type="text" ../> for
   single-line text entry.  This is to be used for text enclosed by tags, not
   arguements/parameters associated with a tag.
   
 =back  =back
   
 incomplete...  incomplete...

Removed from v.1.27  
changed lines
  Added in v.1.35


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