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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 17 Mar 2006 00:06:55 -0000


This is a MIME encoded message

--albertel1142554015
Content-Type: text/plain

albertel		Thu Mar 16 19:06:55 2006 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - start_page work
  
  
--albertel1142554015
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20060316190655.txt"

Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.223 loncom/interface/londocs.pm:1.224
--- loncom/interface/londocs.pm:1.223	Mon Mar  6 12:15:29 2006
+++ loncom/interface/londocs.pm	Thu Mar 16 19:06:54 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.223 2006/03/06 17:15:29 www Exp $
+# $Id: londocs.pm,v 1.224 2006/03/17 00:06:54 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -140,10 +140,9 @@
 # -------------------------------------------------------- Actually dump course
 
 sub dumpcourse {
-    my $r=shift;
-    my $html=&Apache::lonxml::xmlbegin();
-    $r->print($html.'<head><title>Dump DOCS</title></head>'.
-        &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space').
+    my ($r) = @_;
+
+    $r->print(&Apache::loncommon::start_page('Dump Course DOCS to Construction Space').
 	      '<form name="dumpdoc" method="post">');
     my ($home,$other,%outhash)=&authorhosts();
     unless ($home) { return ''; }
@@ -308,11 +307,9 @@
                 $outcome = '<br />Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.<br />';
             }
         }
-	my $html=&Apache::lonxml::xmlbegin();
-        $r->print($html.'<head><title>Export Course</title></head>'.
-            &Apache::loncommon::bodytag('Export course to IMS content package'));
+        $r->print(&Apache::loncommon::start_page('Export course to IMS content package'));
         $r->print($outcome);
-        $r->print('</body></html>');
+        $r->print(&Apache::loncommon::end_page());
     } else {
         my $display;
         $display = '<form name="exportdoc" method="post">'."\n";
@@ -450,15 +447,13 @@
 
 </script>
         |;
-	my $html=&Apache::lonxml::xmlbegin();
-        $r->print($html.'<head><title>Export Course</title>'.$scripttag.'</head>'.
-            &Apache::loncommon::bodytag('Export course to IMS content package'
-));
-
-        $r->print($display.'</table>'.
+	$r->print(&Apache::loncommon::start_page('Export course to IMS content package',
+						 $scripttag));
+	$r->print($display.'</table>'.
                   '<p><input type="hidden" name="finishexport" value="1">'.
                   '<input type="submit" name="exportcourse" value="'.
-                  &mt('Export Course DOCS').'" /></p></form></body></html>');
+                  &mt('Export Course DOCS').'" /></p></form>'.
+		  &Apache::loncommon::end_page());
     }
 }
 
@@ -1750,17 +1745,16 @@
 # ----------------------------------------------------------------- List Symbs
 # 
 sub list_symbs {
-   my $r=shift; 
-   my $html=&Apache::lonxml::xmlbegin();
-   $r->print($html.'<head><title>Symb List</title></head>'.
-              &Apache::loncommon::bodytag('Symb List'));
-   my $navmap = Apache::lonnavmaps::navmap->new();
-   $r->print("<pre>\n");
-   foreach my $res ($navmap->retrieveResources()) {
-       $r->print($res->compTitle()."\t".$res->symb()."\n");
-   }
-   $r->print("\n</pre>\n");
-   $r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>');
+    my ($r) = @_;
+
+    $r->print(&Apache::loncommon::start_page('Symb List'));
+    my $navmap = Apache::lonnavmaps::navmap->new();
+    $r->print("<pre>\n");
+    foreach my $res ($navmap->retrieveResources()) {
+	$r->print($res->compTitle()."\t".$res->symb()."\n");
+    }
+    $r->print("\n</pre>\n");
+    $r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>');
 }
 
 
@@ -1768,12 +1762,10 @@
 # -------------------------------------------------------------- Verify Content
 # 
 sub verifycontent {
-   my $r=shift; 
+    my ($r) = @_;
    my $loaderror=&Apache::lonnet::overloaderror($r);
    if ($loaderror) { return $loaderror; }
-   my $html=&Apache::lonxml::xmlbegin();
-   $r->print($html.'<head><title>Verify Content</title></head>'.
-              &Apache::loncommon::bodytag('Verify Course Documents'));
+   $r->print(&Apache::loncommon::start_page('Verify Course Documents'));
    $hashtied=0;
    undef %alreadyseen;
    %alreadyseen=();
@@ -1806,10 +1798,8 @@
 }
 
 sub checkversions {
-    my $r=shift;
-    my $html=&Apache::lonxml::xmlbegin();
-    $r->print($html.'<head><title>Check Versions</title></head>'.
-              &Apache::loncommon::bodytag('Check Course Document Versions'));
+    my ($r) = @_;
+    $r->print(&Apache::loncommon::start_page('Check Course Document Versions'));
     my $header='';
     my $startsel='';
     my $monthsel='';
@@ -2154,7 +2144,9 @@
     my $containertag;
     my $uploadtag;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
-    ['folderpath','pagepath','pagesymb','markedcopy_url','markedcopy_title']);
+					    ['folderpath','pagepath',
+					     'pagesymb','markedcopy_url',
+					     'markedcopy_title']);
     if ($env{'form.folderpath'}) {
 	my (@folderpath)=split('&',$env{'form.folderpath'});
 	$env{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));
@@ -2186,8 +2178,8 @@
     } else { # got called in sequence from course
        $allowed=0;
        $script='</script>'.&Apache::lonmenu::registerurl(1,undef).'<script>';
-       $events='onLoad="'.&Apache::lonmenu::loadevents.
-           '" onUnload="'.&Apache::lonmenu::unloadevents.'"';
+       $events='onLoad="'.&Apache::lonmenu::loadevents().
+           '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
     }
 
 # get course data
@@ -2205,189 +2197,16 @@
 
     $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
 
-    my $now=time;
-
-# print screen
-       my $html=&Apache::lonxml::xmlbegin();
-    $r->print(<<ENDDOCUMENT);
-$html
-<head>
-<title>The LearningOnline Network with CAPA</title>
-<script>
-$script
-</script>
-ENDDOCUMENT
-   if ($allowed) {
-    $r->print(<<ENDNEWSCRIPT);
-<script>
-function makenewfolder(targetform,folderseq) {
-    var foldername=prompt('Name of New Folder','New Folder');
-    if (foldername) {
-	targetform.importdetail.value=foldername+"="+folderseq;
-        targetform.submit();
-    }
-}
-
-function makenewpage(targetform,folderseq) {
-    var pagename=prompt('Name of New Page','New Page');
-    if (pagename) {
-        targetform.importdetail.value=pagename+"="+folderseq;
-        targetform.submit();
-    }
-}
-
-function makenewext(targetname) {
-    this.document.forms.extimport.useform.value=targetname;
-    window.open('/adm/rat/extpickframe.html');
-}
-
-function makeexamupload() {
-   var title=prompt('Listed Title for the Uploaded Score');
-   if (title) { 
-    this.document.forms.newexamupload.importdetail.value=
-	title+'=/res/lib/templates/examupload.problem';
-    this.document.forms.newexamupload.submit();
-   }
-}
-
-function makesmppage() {
-   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 makesmpproblem() {
-   var title=prompt('Listed Title for the Problem');
-   if (title) { 
-    this.document.forms.newsmpproblem.importdetail.value=
-	title+'=/res/lib/templates/simpleproblem.problem';
-    this.document.forms.newsmpproblem.submit();
-   }
-}
-
-function makedropbox() {
-   var title=prompt('Listed Title for the Drop Box');
-   if (title) { 
-    this.document.forms.newdropbox.importdetail.value=
-        title+'=/res/lib/templates/DropBox.problem';
-    this.document.forms.newdropbox.submit();
-   }
-}
-
-function makebulboard() {
-   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 makeabout() {
-   var user=prompt("Enter user\@domain for User's 'About Me' Page");
-   if (user) {
-       var comp=new Array();
-       comp=user.split('\@');
-       if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
-	   if ((comp[0]) && (comp[1])) {
-	       this.document.forms.newaboutsomeone.importdetail.value=
-		   'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
-	       this.document.forms.newaboutsomeone.submit();
-	   } else {
-               alert("Not a valid user\@domain");
-           }
-       } else {
-           alert("Please enter both user and domain in the format user\@domain"); 
-       }
-   }
-}
-
-function makeims() {
-    var caller = document.forms.ims.folder.value;
-    var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
-    newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
-    newWindow.location.href = newlocation;
-}
-
-
-function finishpick() {
-    var title=this.document.forms.extimport.title.value;
-    var url=this.document.forms.extimport.url.value;
-    var form=this.document.forms.extimport.useform.value;
-    eval
-     ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
-    '";this.document.forms.'+form+'.submit();');
-}
-
-function changename(folderpath,index,oldtitle,container,pagesymb) {
-    var title=prompt('New Title',oldtitle);
-    if (title) {
-	this.document.forms.renameform.title.value=title;
-	this.document.forms.renameform.cmd.value='rename_'+index;
-        if (container == 'sequence') {
-	    this.document.forms.renameform.folderpath.value=folderpath;
-        }
-        if (container == 'page') {
-            this.document.forms.renameform.pagepath.value=folderpath;
-            this.document.forms.renameform.pagesymb.value=pagesymb;
-        }
-        this.document.forms.renameform.submit();
-    }
-}
-
-function removeres(folderpath,index,oldtitle,container,pagesymb) {
-    if (confirm('WARNING: Removing a resource makes associated grades and scores inaccessible!\\nRemove "'+oldtitle+'"?')) {
-	this.document.forms.renameform.cmd.value='del_'+index;
-        if (container == 'sequence') {
-            this.document.forms.renameform.folderpath.value=folderpath;
-        }
-        if (container == 'page') {
-            this.document.forms.renameform.pagepath.value=folderpath;
-            this.document.forms.renameform.pagesymb.value=pagesymb;
-        }
-        this.document.forms.renameform.submit();
-    }
-}
-
-function cutres(folderpath,index,oldtitle,container,pagesymb) {
-    if (confirm('WARNING: Cutting a resource makes associated grades and scores inaccessible!\\nGrades remain inaccessible if resource is pasted into another folder.\\nCut "'+oldtitle+'"?')) {
-	this.document.forms.renameform.cmd.value='cut_'+index;
-	this.document.forms.renameform.markcopy.value=index;
-        if (container == 'sequence') {
-            this.document.forms.renameform.folderpath.value=folderpath;
-        }
-        if (container == 'page') {
-            this.document.forms.renameform.pagepath.value=folderpath;
-            this.document.forms.renameform.pagesymb.value=pagesymb;
-        }
-        this.document.forms.renameform.submit();
-    }
-}
-
-function markcopy(folderpath,index,oldtitle,container,pagesymb) {
-    this.document.forms.renameform.markcopy.value=index;
-    if (container == 'sequence') {
-	this.document.forms.renameform.folderpath.value=folderpath;
-    }
-    if (container == 'page') {
-	this.document.forms.renameform.pagepath.value=folderpath;
-	this.document.forms.renameform.pagesymb.value=pagesymb;
+    if ($allowed) {
+	$script .= &editing_js($udom,$uname);
     }
-    this.document.forms.renameform.submit();
-}
-
-</script>
-
-ENDNEWSCRIPT
-  }
 # -------------------------------------------------------------------- Body tag
-  $r->print('</head>'.
-            &Apache::loncommon::bodytag('Course Documents','',$events,
-					'','',$showdoc).
-	    &Apache::loncommon::help_open_menu('','','','',273,'RAT'));
+    $script = '<script type="text/javascript">'."\n".$script."\n".'</script>';
+    $r->print(&Apache::loncommon::start_page('Course Documents', $script,
+					     {'add_entries'    => $events,
+					      'force_register' => $showdoc,}).
+	      &Apache::loncommon::help_open_menu('','','','',273,'RAT'));
+  
   my %allfiles = ();
   my %codebase = ();
   my ($upload_result,$upload_output);
@@ -2455,7 +2274,7 @@
                           $content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi; 
                       }
                       if (exists($codebase{$item})) {
-                          $content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i;
+                          $content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; #' stupid emacs
                       }
                   }
 # Save edited file.
@@ -2885,9 +2704,176 @@
       }
   }
  }
- $r->print('</body></html>');
+ $r->print(&Apache::loncommon::end_page());
  return OK;
 } 
 
+
+sub editing_js {
+    my ($udom,$uname) = @_;
+    my $now = time();
+
+    return <<ENDNEWSCRIPT;
+function makenewfolder(targetform,folderseq) {
+    var foldername=prompt('Name of New Folder','New Folder');
+    if (foldername) {
+       targetform.importdetail.value=foldername+"="+folderseq;
+        targetform.submit();
+    }
+}
+
+function makenewpage(targetform,folderseq) {
+    var pagename=prompt('Name of New Page','New Page');
+    if (pagename) {
+        targetform.importdetail.value=pagename+"="+folderseq;
+        targetform.submit();
+    }
+}
+
+function makenewext(targetname) {
+    this.document.forms.extimport.useform.value=targetname;
+    window.open('/adm/rat/extpickframe.html');
+}
+
+function makeexamupload() {
+   var title=prompt('Listed Title for the Uploaded Score');
+   if (title) { 
+    this.document.forms.newexamupload.importdetail.value=
+	title+'=/res/lib/templates/examupload.problem';
+    this.document.forms.newexamupload.submit();
+   }
+}
+
+function makesmppage() {
+   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 makesmpproblem() {
+   var title=prompt('Listed Title for the Problem');
+   if (title) { 
+    this.document.forms.newsmpproblem.importdetail.value=
+	title+'=/res/lib/templates/simpleproblem.problem';
+    this.document.forms.newsmpproblem.submit();
+   }
+}
+
+function makedropbox() {
+   var title=prompt('Listed Title for the Drop Box');
+   if (title) { 
+    this.document.forms.newdropbox.importdetail.value=
+        title+'=/res/lib/templates/DropBox.problem';
+    this.document.forms.newdropbox.submit();
+   }
+}
+
+function makebulboard() {
+   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 makeabout() {
+   var user=prompt("Enter user\@domain for User's 'About Me' Page");
+   if (user) {
+       var comp=new Array();
+       comp=user.split('\@');
+       if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
+	   if ((comp[0]) && (comp[1])) {
+	       this.document.forms.newaboutsomeone.importdetail.value=
+		   'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
+	       this.document.forms.newaboutsomeone.submit();
+	   } else {
+               alert("Not a valid user\@domain");
+           }
+       } else {
+           alert("Please enter both user and domain in the format user\@domain"); 
+       }
+   }
+}
+
+function makeims() {
+    var caller = document.forms.ims.folder.value;
+    var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
+    newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
+    newWindow.location.href = newlocation;
+}
+
+
+function finishpick() {
+    var title=this.document.forms.extimport.title.value;
+    var url=this.document.forms.extimport.url.value;
+    var form=this.document.forms.extimport.useform.value;
+    eval
+     ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
+    '";this.document.forms.'+form+'.submit();');
+}
+
+function changename(folderpath,index,oldtitle,container,pagesymb) {
+    var title=prompt('New Title',oldtitle);
+    if (title) {
+	this.document.forms.renameform.title.value=title;
+	this.document.forms.renameform.cmd.value='rename_'+index;
+        if (container == 'sequence') {
+	    this.document.forms.renameform.folderpath.value=folderpath;
+        }
+        if (container == 'page') {
+            this.document.forms.renameform.pagepath.value=folderpath;
+            this.document.forms.renameform.pagesymb.value=pagesymb;
+        }
+        this.document.forms.renameform.submit();
+    }
+}
+
+function removeres(folderpath,index,oldtitle,container,pagesymb) {
+    if (confirm('WARNING: Removing a resource makes associated grades and scores inaccessible!\\nRemove "'+oldtitle+'"?')) {
+	this.document.forms.renameform.cmd.value='del_'+index;
+        if (container == 'sequence') {
+            this.document.forms.renameform.folderpath.value=folderpath;
+        }
+        if (container == 'page') {
+            this.document.forms.renameform.pagepath.value=folderpath;
+            this.document.forms.renameform.pagesymb.value=pagesymb;
+        }
+        this.document.forms.renameform.submit();
+    }
+}
+
+function cutres(folderpath,index,oldtitle,container,pagesymb) {
+    if (confirm('WARNING: Cutting a resource makes associated grades and scores inaccessible!\\nGrades remain inaccessible if resource is pasted into another folder.\\nCut "'+oldtitle+'"?')) {
+	this.document.forms.renameform.cmd.value='cut_'+index;
+	this.document.forms.renameform.markcopy.value=index;
+        if (container == 'sequence') {
+            this.document.forms.renameform.folderpath.value=folderpath;
+        }
+        if (container == 'page') {
+            this.document.forms.renameform.pagepath.value=folderpath;
+            this.document.forms.renameform.pagesymb.value=pagesymb;
+        }
+        this.document.forms.renameform.submit();
+    }
+}
+
+function markcopy(folderpath,index,oldtitle,container,pagesymb) {
+    this.document.forms.renameform.markcopy.value=index;
+    if (container == 'sequence') {
+	this.document.forms.renameform.folderpath.value=folderpath;
+    }
+    if (container == 'page') {
+	this.document.forms.renameform.pagepath.value=folderpath;
+	this.document.forms.renameform.pagesymb.value=pagesymb;
+    }
+    this.document.forms.renameform.submit();
+}
+
+ENDNEWSCRIPT
+}
 1;
 __END__

--albertel1142554015--