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

raeburn raeburn@source.lon-capa.org
Mon, 16 Aug 2010 03:49:34 -0000


This is a MIME encoded message

--raeburn1281930574
Content-Type: text/plain

raeburn		Mon Aug 16 03:49:34 2010 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - Bug 6229.
    - External Resource doesn't work in .page so don't offer it.
    - .page has performance issues when it contains too many resources,
       so (in common with 2.9 and earlier) don't offer IMS import in .page.
  - Bug 6228.
    - set folderpath form elements to null, in case Supplemental Tab was
       active since last page submission, and item is being added to .page.
  
  
--raeburn1281930574
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20100816034934.txt"

Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.433 loncom/interface/londocs.pm:1.434
--- loncom/interface/londocs.pm:1.433	Mon Aug 16 00:30:47 2010
+++ loncom/interface/londocs.pm	Mon Aug 16 03:49:33 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.433 2010/08/16 00:30:47 raeburn Exp $
+# $Id: londocs.pm,v 1.434 2010/08/16 03:49:33 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2718,9 +2718,11 @@
         $env{'form.pagename'}=&unescape(pop(@pagepath));
         $env{'form.folder'}=pop(@pagepath);
         $containertag = '<input type="hidden" name="pagepath" value="" />'.
-	    '<input type="hidden" name="pagesymb" value="" />';
-        $uploadtag = '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
-	    '<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />';
+	                '<input type="hidden" name="pagesymb" value="" />';
+        $uploadtag = 
+            '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
+	    '<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />'.
+            '<input type="hidden" name="folderpath" value="" />';
     } else {
         my $folderpath=$env{'form.folderpath'};
         if (!$folderpath) {
@@ -3276,9 +3278,13 @@
 	{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'"  onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform},
 	{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
 	{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
-	); 
-	
-      }
+	);
+
+        my @importdoc = (
+        {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'newext\');" />'=>$extresourcesform},
+        {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:makeims();" />'=>$imspform},);
+        $fileuploadform =  create_form_ul(create_list_elements(@importdoc)) . '<hr/>' . $fileuploadform;
+
 	push @specialdocumentsforma, ({'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
 	{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
 	{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
@@ -3290,6 +3296,7 @@
 	{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},);
 
 	$specialdocumentsform = create_form_ul(create_list_elements(@specialdocumentsforma));
+      }
 
 if($env{'form.pagepath'}) {
 	
@@ -3306,18 +3313,16 @@
 	{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/recover.png" alt="'.$lt{reco}.'" onclick="javascript:groupopen(\''.$readfile.'\',1,0)" />'=>$recoverform},
 	);
 
-my @importdoc = (
-    {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'newext\');" />'=>$extresourcesform},
-    {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:makeims();" />'=>$imspform}, 
-);
-$fileuploadform =  create_form_ul(create_list_elements(@importdoc)) . '<hr/>' . $fileuploadform;
 my %orderhash = (
-		'00' => ['Newfolder',$newfolderform],
                 'aa' => ['Import Documents',$fileuploadform],
                 'bb' => ['Published Resources',$simpleeditdefaultform],
                 'cc' => ['Special Documents',$specialdocumentsform],
-		'dd' => ['Tools', create_form_ul(create_list_elements(@tools)).&generate_admin_options($containertag,$uploadtag,\%help,\%env)],
+		'dd' => ['Tools', create_form_ul(create_list_elements(@tools)).&generate_admin_options(\%help,\%env)],
                 );
+unless($env{'form.pagepath'}) {
+    $orderhash{'00'} = ['Newfolder',$newfolderform];
+}
+
 my $tid='1';
  $hadchanges=0;
         my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype);
@@ -3333,8 +3338,6 @@
 
 $r->print('</div>');
 	}
-       if ($env{'form.pagepath'}) {
-       }
 # ----------------------------------------------------- Supplemental documents
        $active = 'style="display: none;"';
        if($activeClass == 1){
@@ -3481,8 +3484,8 @@
 }
 
 sub generate_admin_options {
-  my ($containertag,$uploadtag,$help_ref,$env_ref) = @_;
- my %lt=&Apache::lonlocal::texthash(
+  my ($help_ref,$env_ref) = @_;
+  my %lt=&Apache::lonlocal::texthash(
                                          'vc' => 'Verify Content',
                                          'cv' => 'Check/Set Resource Versions',
                                          'ls' => 'List Symbs',
@@ -3589,8 +3592,14 @@
                                         );
 
     my $crstype = &Apache::loncommon::course_type();
-    my $docs_folderpath = $env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'};
-    my $docs_pagepath = $env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.pagepath'};
+    my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
+    my $docs_pagepath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.pagepath'},'<>&"');
+    my $main_container_page;
+    if ($docs_folderpath eq '') {
+        if ($docs_pagepath ne '') {
+            $main_container_page = 1;
+        }
+    }
     my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents';
     my $toplevelsupp = 'supplemental&Supplemental%20'.$crstype.'%20Documents';
 
@@ -3827,15 +3836,29 @@
             if (storedpath == '') {
                 storedpath = "$docs_pagepath";
             }
+            var storedpage = "$main_container_page";
             var reg = new RegExp("^supplemental");
             if (pageId == 'mainCourseDocuments') {
-                if (reg.test(storedpath)) {
-                    document.simpleedit.folderpath.value = '$toplevelmain';
-                    document.uploaddocument.folderpath.value = '$toplevelmain';
-                    document.newext.folderpath.value = '$toplevelmain';
+                if (storedpage == 1) {
+                    document.simpleedit.folderpath.value = '';
+                    document.uploaddocument.folderpath.value = '';
+                } else {
+                    if (reg.test(storedpath)) {
+                        document.simpleedit.folderpath.value = '$toplevelmain';
+                        document.uploaddocument.folderpath.value = '$toplevelmain';
+                        document.newext.folderpath.value = '$toplevelmain';
+                    } else {
+                        document.simpleedit.folderpath.value = storedpath;
+                        document.uploaddocument.folderpath.value = storedpath;
+                        document.newext.folderpath.value = storedpath;
+                    }
                 }
             } else {
-                if (!reg.test(storedpath)) {
+                if (reg.test(storedpath)) {
+                    document.simpleedit.folderpath.value = storedpath;
+                    document.supuploaddocument.folderpath.value = storedpath;
+                    document.supnewext.folderpath.value = storedpath;
+                } else {
                     document.simpleedit.folderpath.value = '$toplevelsupp';
                     document.supuploaddocument.folderpath.value = '$toplevelsupp';
                     document.supnewext.folderpath.value = '$toplevelsupp';

--raeburn1281930574--