--- loncom/homework/edit.pm 2003/02/07 22:03:21 1.45
+++ loncom/homework/edit.pm 2003/11/05 21:53:48 1.71
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# edit mode helpers
#
-# $Id: edit.pm,v 1.45 2003/02/07 22:03:21 albertel Exp $
+# $Id: edit.pm,v 1.71 2003/11/05 21:53:48 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,6 +33,7 @@ package Apache::edit;
use strict;
use Apache::lonnet();
use HTML::Entities();
+use Apache::lonlocal;
# Global Vars
# default list of colors to use in editing
@@ -40,311 +41,347 @@ use HTML::Entities();
# depth of nesting of edit
$Apache::edit::colordepth=0;
@Apache::edit::inserttag=();
+# image-type responses: active background image and curdepth at definition
+$Apache::edit::bgimgsrc='';
+$Apache::edit::bgimgsrccurdepth='';
sub initialize_edit {
- $Apache::edit::colordepth=0;
- @Apache::edit::inserttag=();
+ $Apache::edit::colordepth=0;
+ @Apache::edit::inserttag=();
}
sub tag_start {
- my ($target,$token,$description) = @_;
- my $result='';
- if ($target eq "edit") {
- my $tag=$token->[1];
- if (!$description) {
- $description=&Apache::lonxml::description($token);
- if (!$description) { $description="<$tag>"; }
- }
- $result.= &start_table($token)."
$description |
-Delete".
- &deletelist($target,$token)
- ." |
-".
- &insertlist($target,$token).&end_row().&start_spanning_row();
+ my ($target,$token,$description) = @_;
+ my $result='';
+ if ($target eq "edit") {
+ my $tag=$token->[1];
+ if (!$description) {
+ $description=&Apache::lonxml::description($token);
+ if (!$description) { $description="<$tag>"; }
+ }
+ $result.= &start_table($token)." |
$description |
+ Delete".
+ &deletelist($target,$token)
+ ." |
+ ".
+ &insertlist($target,$token);
# | ".
# &movebuttons($target,$token).
# " |
\n";
- }
- return $result;
+ my @help = Apache::lonxml::helpinfo($token);
+ if ($help[0]) {
+ $result .= ' | ' .
+ Apache::loncommon::help_open_topic(@help) .
+ ' | ';
+ } else { $result .= " | "; }
+ $result .= &end_row().&start_spanning_row();
+ }
+ return $result;
}
sub tag_end {
- my ($target,$token,$description) = @_;
- my $result='';
- if ($target eq 'edit') {
- my $tag=$token->[1];
- if (!defined($description)) {
- $result.="
</$tag> | | ";
- } else {
- if ($description ne '') { $result.="
$description | | "; }
+ my ($target,$token,$description) = @_;
+ my $result='';
+ if ($target eq 'edit') {
+ $result.="
".&end_table()."\n";
}
- $result.="".&end_table()."\n";
- }
- return $result;
+ return $result;
}
sub start_table {
- my ($token)=@_;
- my $tag = $token->[1];
- my $tagnum;
- foreach my $namespace (reverse @Apache::lonxml::namespace) {
- my $testtag=$namespace.'::'.$tag;
- $tagnum=$Apache::lonxml::insertlist{"$testtag.num"};
- if (defined($tagnum)) { last; }
- }
- if (!defined ($tagnum)) { $tagnum=$Apache::lonxml::insertlist{"$tag.num"}; }
- my $color = $Apache::lonxml::insertlist{"$tagnum.color"};
- if (!defined($color)) {
- $color = $Apache::edit::colorlist[$Apache::edit::colordepth];
- }
- $Apache::edit::colordepth++;
- push(@Apache::edit::inserttag,$token->[1]);
- my $result='';
- $result.='
';
- return $result;
+ my ($token)=@_;
+ my $tag = $token->[1];
+ my $tagnum;
+ foreach my $namespace (reverse @Apache::lonxml::namespace) {
+ my $testtag=$namespace.'::'.$tag;
+ $tagnum=$Apache::lonxml::insertlist{"$testtag.num"};
+ if (defined($tagnum)) { last; }
+ }
+ if (!defined ($tagnum)) {$tagnum=$Apache::lonxml::insertlist{"$tag.num"};}
+ my $color = $Apache::lonxml::insertlist{"$tagnum.color"};
+ if (!defined($color)) {
+ $color = $Apache::edit::colorlist[$Apache::edit::colordepth];
+ }
+ $Apache::edit::colordepth++;
+ push(@Apache::edit::inserttag,$token->[1]);
+ my $result='';
+ $result.='
';
+ return $result;
}
sub end_table {
- $Apache::edit::colordepth--;
- my $result='
';
- $result.="";
-
- my ($tagname,$closingtag);
- if (defined($Apache::edit::inserttag[-2])) {
- $tagname=$Apache::edit::inserttag[-2];
- } else {$tagname='problem';}
- if (defined($Apache::edit::inserttag[-1])) {
- $closingtag=$Apache::edit::inserttag[-1];
- }
- $result.=&innerinsertlist('edit',$tagname,$closingtag).
- " |
";
- pop(@Apache::edit::inserttag);
- return $result;
+ $Apache::edit::colordepth--;
+ my $result='
';
+ $result.="";
+
+ my ($tagname,$closingtag);
+ if (defined($Apache::edit::inserttag[-2])) {
+ $tagname=$Apache::edit::inserttag[-2];
+ } else {$tagname='problem';}
+ if (defined($Apache::edit::inserttag[-1])) {
+ $closingtag=$Apache::edit::inserttag[-1];
+ }
+ $result.=&innerinsertlist('edit',$tagname,$closingtag).
+ " |
";
+ pop(@Apache::edit::inserttag);
+ return $result;
}
-sub start_spanning_row { return '';}
+sub start_spanning_row { return ' |
';}
sub start_row { return ' |
'; }
sub end_row { return ' |
'; }
sub movebuttons {
- my ($target,$token) = @_;
- my $result='';
- $result.='';
- return $result;
+ my ($target,$token) = @_;
+ my $result='';
+ $result.='';
+ return $result;
}
sub deletelist {
- my ($target,$token) = @_;
- my $result = "