[LON-CAPA-cvs] cvs: loncom /interface londocs.pm

www lon-capa-cvs@mail.lon-capa.org
Wed, 04 Dec 2002 14:02:49 -0000


www		Wed Dec  4 09:02:49 2002 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  Bug Fixes
  Bug #879  - ":" in titles
  Bug #1013 - moving down last resource, moving up first resource
  Bug #1016 - renaming a supplemental document
  Bug #1021 - click "Cancel" on creation of Simple Page or Bulletin Board
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.37 loncom/interface/londocs.pm:1.38
--- loncom/interface/londocs.pm:1.37	Mon Nov 18 10:21:31 2002
+++ loncom/interface/londocs.pm	Wed Dec  4 09:02:49 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.37 2002/11/18 15:21:31 www Exp $
+# $Id: londocs.pm,v 1.38 2002/12/04 14:02:49 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -35,6 +35,7 @@
 use Apache::lonratedt;
 use Apache::lonratsrv;
 use Apache::lonxml;
+use HTML::Entities;
 use GDBM_File;
 
 my $iconpath;
@@ -118,20 +119,25 @@
                     }
                     $#Apache::lonratedt::order--;
                 } elsif ($cmd eq 'up') {
+		  if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) {
                     my $i=$Apache::lonratedt::order[$idx-1];
                     $Apache::lonratedt::order[$idx-1]=
 			$Apache::lonratedt::order[$idx];
                     $Apache::lonratedt::order[$idx]=$i;
+		   }
                 } elsif ($cmd eq 'down') {
+		   if (defined($Apache::lonratedt::order[$idx+1])) {
                     my $i=$Apache::lonratedt::order[$idx+1];
                     $Apache::lonratedt::order[$idx+1]=
 			$Apache::lonratedt::order[$idx];
                     $Apache::lonratedt::order[$idx]=$i;
+		   }
                 } elsif ($cmd eq 'rename') {
                     my ($rtitle,@rrest)=split(/\:/,
                        $Apache::lonratedt::resources[
 				       $Apache::lonratedt::order[$idx]]);
-                    my $comment=$ENV{'form.title'};
+                    my $comment=
+                     &HTML::Entities::decode($ENV{'form.title'});
                     $comment=~s/\</\&lt\;/g;
                     $comment=~s/\>/\&gt\;/g;
                     $comment=~s/\:/\&colon;/g;
@@ -185,6 +191,21 @@
 
 sub entryline {
     my ($index,$title,$url,$folder,$allowed)=@_;
+    $title=~s/\&colon\;/\:/g;
+    $title=&HTML::Entities::encode(&HTML::Entities::decode(
+     &Apache::lonnet::unescape($title)),'\"\<\>\&\'');
+    my $renametitle=$title;
+    my $foldertitle=$title;
+    if ($title=~
+ /^(\d+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(\w+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(\w+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(.*)$/
+	) { 
+            $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
+            $renametitle=$4;
+            $title='<i>'.localtime($1).'</i> '.
+                &Apache::loncommon::plainname($2,$3).': <br>'.
+		$foldertitle;
+	}
+    $renametitle=~s/\&quot\;/\\\"/g;
     my $line='<tr>';
 # Edit commands
     if ($allowed) {
@@ -197,7 +218,7 @@
 </table></td><td>
 <a href='/adm/coursedocs?folder=$folder&cmd=del_$index'>
 <font size="-2">Remove</font></a>
-<a href='javascript:changename("$folder","$index","$title");'>
+<a href='javascript:changename("$folder","$index","$renametitle");'>
 <font size="-2">Rename</font></a></td>
 END
     }
@@ -220,17 +241,6 @@
        } 
     }
     $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
-# Title
-    $title=&Apache::lonnet::unescape($title);
-    my $foldertitle=$title;
-    if ($title=~
- /^(\d+)\_\_\_\&\&\&\_\_\_(\w+)\_\_\_\&\&\&\_\_\_(\w+)\_\_\_\&\&\&\_\_\_(.*)$/
-	) { 
-            $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
-            $title='<i>'.localtime($1).'</i> '.
-                &Apache::loncommon::plainname($2,$3).': <br>'.
-		$foldertitle;
-	}
     if ($isfolder) { $url.='&foldername='.$foldertitle; }
     $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'" target="cat_'.$folder.
 '"><img src="/adm/lonIcons/'.
@@ -511,17 +521,21 @@
 }
 
 function makesmppage() {
-    var title=prompt('Listed Title for the Page');
+   var title=prompt('Listed Title for the Page');
+   if (title) { 
     this.document.forms.newsmppg.importdetail.value=
 	title+'=/adm/$udom/$uname/$now/smppg';
     this.document.forms.newsmppg.submit();
+   }
 }
 
 function makebulboard() {
-    var title=prompt('Listed Title for the Bulletin Board');
+   var title=prompt('Listed Title for the Bulletin Board');
+   if (title) {
     this.document.forms.newbul.importdetail.value=
 	title+'=/adm/$udom/$uname/$now/bulletinboard';
     this.document.forms.newbul.submit();
+   }
 }
 
 function finishpick() {