--- loncom/interface/londocs.pm 2006/02/07 19:46:30 1.221 +++ loncom/interface/londocs.pm 2006/03/17 00:06:54 1.224 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.221 2006/02/07 19:46:30 albertel 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 @@ sub clean { # -------------------------------------------------------- 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 @@ sub exportcourse { $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 @@ function containerCheck(item) { </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()); } } @@ -1190,22 +1185,25 @@ sub editor { } } # Loading a complete map - if (($env{'form.importmap'}) && ($env{'form.loadmap'})) { - foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) { - my ($title,$url,$ext,$type)=split(/\:/,$_); - my $idx=&Apache::lonratedt::getresidx($url); - $Apache::lonratedt::resources[$idx]=$_; - $Apache::lonratedt::order - [$#Apache::lonratedt::order+1]=$idx; - } - + if ($env{'form.loadmap'}) { + if ($env{'form.importmap'}=~/\w/) { + foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) { + my ($title,$url,$ext,$type)=split(/\:/,$_); + my $idx=&Apache::lonratedt::getresidx($url); + $Apache::lonratedt::resources[$idx]=$_; + $Apache::lonratedt::order + [$#Apache::lonratedt::order+1]=$idx; + } # Store the changed version - ($errtext,$fatal)=&storemap($coursenum,$coursedom, + ($errtext,$fatal)=&storemap($coursenum,$coursedom, $folder.'.'.$container); - if ($fatal) { - $r->print('<p><font color="red">'.$errtext.'</font></p>'); - return; - } + if ($fatal) { + $r->print('<p><font color="red">'.$errtext.'</font></p>'); + return; + } + } else { + $r->print('<p><font color="red">'.&mt('No map selected.').'</font></p>'); + } } } # ---------------------------------------------------------------- End commands @@ -1400,8 +1398,8 @@ sub entryline { &Apache::loncommon::plainname($2,$3).': <br />'. $foldertitle; } - $renametitle=~s/\"\;/\\\"/g; $renametitle=~s/\\/\\\\/g; + $renametitle=~s/\"\;/\\\"/g; my $line='<tr>'; # Edit commands my $container; @@ -1747,17 +1745,16 @@ sub checkonthis { # ----------------------------------------------------------------- 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>'); } @@ -1765,12 +1762,10 @@ sub list_symbs { # -------------------------------------------------------------- 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=(); @@ -1803,10 +1798,8 @@ sub devalidateversioncache { } 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=''; @@ -2151,7 +2144,9 @@ sub handler { 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)); @@ -2183,8 +2178,8 @@ sub handler { } 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 @@ -2202,189 +2197,16 @@ sub handler { $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); @@ -2452,7 +2274,7 @@ ENDNEWSCRIPT $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. @@ -2882,9 +2704,176 @@ ENDSUPFORM } } } - $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__