--- loncom/interface/londocs.pm 2005/11/17 19:37:30 1.213 +++ loncom/interface/londocs.pm 2006/05/12 16:47:35 1.227 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.213 2005/11/17 19:37:30 albertel Exp $ +# $Id: londocs.pm,v 1.227 2006/05/12 16:47:35 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.'Dump DOCS'. - &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space'). + my ($r) = @_; + + $r->print(&Apache::loncommon::start_page('Dump Course DOCS to Construction Space'). '
'); my ($home,$other,%outhash)=&authorhosts(); unless ($home) { return ''; } @@ -222,7 +221,7 @@ sub dumpcourse { $r->print(''); } my $title=$origcrsdata{'description'}; - $title=~s/\s+/\_/gs; + $title=~s/[\/\s]+/\_/gs; $title=&clean($title); $r->print('

'.&mt('Folder in Construction Space').'


'); &tiehash(); @@ -308,11 +307,9 @@ sub exportcourse { $outcome = '
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.
'; } } - my $html=&Apache::lonxml::xmlbegin(); - $r->print($html.'Export Course'. - &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(''); + $r->print(&Apache::loncommon::end_page()); } else { my $display; $display = ''."\n"; @@ -450,15 +447,13 @@ function containerCheck(item) { |; - my $html=&Apache::lonxml::xmlbegin(); - $r->print($html.'Export Course'.$scripttag.''. - &Apache::loncommon::bodytag('Export course to IMS content package' -)); - - $r->print($display.''. + $r->print(&Apache::loncommon::start_page('Export course to IMS content package', + $scripttag)); + $r->print($display.''. '

'. '

'); + &mt('Export Course DOCS').'" />

'. + &Apache::loncommon::end_page()); } } @@ -975,8 +970,7 @@ sub breadcrumbs { } - return &Apache::lonhtmlcommon::breadcrumbs(undef,undef,undef,undef,undef, - 0,'nohelp'); + return &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp'); } sub editor { @@ -1190,22 +1184,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('

'.$errtext.'

'); - return; - } + if ($fatal) { + $r->print('

'.$errtext.'

'); + return; + } + } else { + $r->print('

'.&mt('No map selected.').'

'); + } } } # ---------------------------------------------------------------- End commands @@ -1373,7 +1370,7 @@ sub process_secondary_uploads { if (($folder eq 'default') || ($folder eq 'supplemental')) { $destination .= 'default/'; } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { - $destination .= $1.'/'; + $destination .= $2.'/'; } $destination .= $newidx; my ($url,$filename); @@ -1400,6 +1397,7 @@ sub entryline { &Apache::loncommon::plainname($2,$3).':
'. $foldertitle; } + $renametitle=~s/\\/\\\\/g; $renametitle=~s/\"\;/\\\"/g; my $line=''; # Edit commands @@ -1555,7 +1553,7 @@ END &Apache::lonnet::allowuploaded('/adm/coursedoc',$url); } } - $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//; + $url=~s-^http(\&colon\;|:)//-/adm/wrapper/ext/-; if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) { my $symb=&Apache::lonnet::symbclean( &Apache::lonnet::declutter('uploaded/'. @@ -1588,7 +1586,7 @@ END } } my $parameterset=' '; - if ($isfolder) { + if ($isfolder || $extension eq 'sequence') { my $foldername=&Apache::lonnet::escape($foldertitle); my $folderpath=$env{'form.folderpath'}; if ($folderpath) { $folderpath.='&' }; @@ -1666,6 +1664,7 @@ sub tiehash { sub untiehash { if ($hashtied) { untie %hash; } $hashtied=0; + return OK; } # --------------------------------------------------------------- check on this @@ -1745,17 +1744,16 @@ sub checkonthis { # ----------------------------------------------------------------- List Symbs # sub list_symbs { - my $r=shift; - my $html=&Apache::lonxml::xmlbegin(); - $r->print($html.'Symb List'. - &Apache::loncommon::bodytag('Symb List')); - my $navmap = Apache::lonnavmaps::navmap->new(); - $r->print("
\n");
-   foreach my $res ($navmap->retrieveResources()) {
-       $r->print($res->compTitle()."\t".$res->symb()."\n");
-   }
-   $r->print("\n
\n"); - $r->print(''.&mt('Return to DOCS').''); + my ($r) = @_; + + $r->print(&Apache::loncommon::start_page('Symb List')); + my $navmap = Apache::lonnavmaps::navmap->new(); + $r->print("
\n");
+    foreach my $res ($navmap->retrieveResources()) {
+	$r->print($res->compTitle()."\t".$res->symb()."\n");
+    }
+    $r->print("\n
\n"); + $r->print(''.&mt('Return to DOCS').''); } @@ -1763,12 +1761,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.'Verify Content'. - &Apache::loncommon::bodytag('Verify Course Documents')); + $r->print(&Apache::loncommon::start_page('Verify Course Documents')); $hashtied=0; undef %alreadyseen; %alreadyseen=(); @@ -1801,10 +1797,8 @@ sub devalidateversioncache { } sub checkversions { - my $r=shift; - my $html=&Apache::lonxml::xmlbegin(); - $r->print($html.'Check Versions'. - &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=''; @@ -2144,12 +2138,13 @@ sub handler { my $forcestandard = 0; my $forcesupplement; my $script=''; - my $events=''; my $showdoc=0; 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)); @@ -2180,17 +2175,13 @@ sub handler { } } else { # got called in sequence from course $allowed=0; - $script=''.&Apache::lonmenu::registerurl(1,undef).' -ENDDOCUMENT - if ($allowed) { - $r->print(< -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 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(); -} - - - -ENDNEWSCRIPT - } # -------------------------------------------------------------------- Body tag - $r->print(''. - &Apache::loncommon::bodytag('Course Documents','',$events, - '','',$showdoc). - &Apache::loncommon::help_open_menu('','','','',273,'RAT')); + $script = ''; + $r->print(&Apache::loncommon::start_page('Course Documents', $script, + {'force_register' => $showdoc,}). + &Apache::loncommon::help_open_menu('','','','',273,'RAT')); + my %allfiles = (); my %codebase = (); my ($upload_result,$upload_output); @@ -2441,7 +2267,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. @@ -2478,6 +2304,7 @@ ENDNEWSCRIPT 'navc' => 'Navigate Contents', 'sipa' => 'Simple Page', 'sipr' => 'Simple Problem', + 'drbx' => 'Drop Box', 'scuf' => 'Score Upload Form', 'bull' => 'Bulletin Board', 'mypi' => 'My Personal Info', @@ -2530,9 +2357,9 @@ $uploadtag $help{'Check_Resource_Versions'} $dumpbut $exportbut - + ENDCOURSEVERIFY $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', @@ -2634,7 +2461,7 @@ $uploadtag value="$lt{'extr'}" /> $help{'Adding_External_Resource'} -
+
@@ -2644,7 +2471,7 @@ ENDFORM $r->print(''); unless ($env{'form.pagepath'}) { $r->print(< +
@@ -2653,7 +2480,7 @@ onClick="javascript:makenewfolder(this.f value="$lt{'newf'}" />$help{'Adding_Folders'} -
+
@@ -2662,7 +2489,7 @@ onClick="javascript:makenewpage(this.for value="$lt{'newp'}" />$help{'Adding_Pages'}
-
+
$uploadtag @@ -2671,7 +2498,7 @@ value="Syllabus=/public/$coursedom/$cour $help{'Syllabus'}
-
+
$uploadtag @@ -2680,7 +2507,7 @@ value="Navigate Content=/adm/navmaps"> $help{'Navigate_Content'}
-
+
$uploadtag @@ -2688,7 +2515,7 @@ $uploadtag onClick="javascript:makesmppage();" /> $help{'Simple Page'}
-
+
$uploadtag @@ -2696,7 +2523,15 @@ $uploadtag onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
-
+
+$uploadtag + + + + +
+
$uploadtag @@ -2705,7 +2540,7 @@ onClick="javascript:makeexamupload();" / $help{'Score_Upload_Form'}
-
+
$uploadtag @@ -2714,7 +2549,7 @@ onClick="javascript:makebulboard();" /> $help{'Bulletin Board'}
-
+
$uploadtag @@ -2723,7 +2558,7 @@ value="$plainname=/adm/$udom/$uname/abou $help{'My Personal Info'}
-
+
$uploadtag @@ -2743,7 +2578,7 @@ $uploadtag onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
-
+
$uploadtag @@ -2816,7 +2651,7 @@ onClick="javascript:makenewfolder(this.f value="$lt{'newf'}" /> $help{'Adding_Folders'}
-
+
@@ -2825,7 +2660,7 @@ onClick="javascript:makenewext('supnewex value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
-
+
@@ -2834,7 +2669,7 @@ value="Syllabus=/public/$coursedom/$cour $help{'Syllabus'}
-
+
@@ -2862,9 +2697,176 @@ ENDSUPFORM } } } - $r->print(''); + $r->print(&Apache::loncommon::end_page()); return OK; } + +sub editing_js { + my ($udom,$uname) = @_; + my $now = time(); + + return <