--- loncom/interface/londocs.pm 2005/06/17 16:40:28 1.190 +++ 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.190 2005/06/17 16:40:28 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 ''; } @@ -166,7 +165,10 @@ sub dumpcourse { $crs=~s/\_/\//g; foreach (keys %replacehash) { my $newfilename=$title.'/'.$replacehash{$_}; + $newfilename=~s/\.(\w+)$//; + my $ext=$1; $newfilename=&clean($newfilename); + $newfilename.='.'.$ext; my @dirs=split(/\//,$newfilename); my $path='/home/'.$ca.'/public_html'; my $makepath=$path; @@ -219,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(); @@ -249,11 +251,10 @@ sub dumpcourse { # ------------------------------------------------------ Generate "export" button sub exportbutton { - return ''; return ''. ''. - &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs'); + &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs'); } sub exportcourse { @@ -306,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"; @@ -448,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()); } } @@ -491,10 +488,21 @@ sub create_ims_store { ' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'. ' xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'. ' http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n". +' + + + + '.$env{'request.course.id'}.' + + '.$env{'course.'.$env{'request.course.id'}.'.description'}.' + + + + '."\n". ' '."\n". ' '."\n". -' '.$env{'request.'.$env{'request.course.id'}.'.description'}.'' +' '.$env{'course.'.$env{'request.course.id'}.'.description'}.'' } else { $$outcome .= 'An error occurred opening the IMS manifest file.
' ; @@ -542,7 +550,6 @@ sub build_package { $count = 0; my $imsresources; my $pkgdepth; - my $included = 0; while ($curRes = $it->next()) { if ($curRes == $it->BEGIN_MAP()) { $prevdepth = $depth; @@ -565,10 +572,13 @@ sub build_package { unless ($curRes->is_sequence()) { $resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"'; } - if (($depth <= $prevdepth) && ($count > 1) && ($included)) { - print $ims_manifest "\n".' '."\n"; + my $step = $prevdepth - $depth; + if (($step >= 0) && ($count > 1)) { + while ($step >= 0) { + print $ims_manifest "\n".' '."\n"; + $step --; + } } - $included = 1; $prevdepth = $depth; my $itementry = @@ -610,8 +620,6 @@ sub build_package { } } $pkgdepth = $depth; - } else { - $included = 0; } } } @@ -646,7 +654,6 @@ sub process_content { my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_; my $content_type; my $message; -# find where user is author or co-author my @uploads = (); if ($curRes->is_sequence()) { $content_type = 'sequence'; @@ -700,6 +707,7 @@ sub process_content { if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'}) { $canedit= 1; } +# only include problem code where current user is author if ($canedit) { $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource'); } else { @@ -748,11 +756,13 @@ sub replicate_content { if ($copiedfile = Apache::File->new('>'.$destination)) { my $content; if ($caller eq 'resource') { - $content = &Apache::lonnet::getfile('/home/httpd/html/res/'.$url); + my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res'; + my $filepath = &Apache::lonnet::filelocation($respath,$url); + $content = &Apache::lonnet::getfile($filepath); if ($content eq -1) { $$message = 'Could not copy file '.$filename; } else { - &extract_media($content,$count,$tempexport,$href,'resource'); + &extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'resource'); $repstatus = 'ok'; } } elsif ($caller eq 'uploaded' || $caller eq 'templateupload') { @@ -760,10 +770,10 @@ sub replicate_content { $repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode); if ($repstatus eq 'ok') { if ($url =~ /\.html?$/i) { - &extract_media(\$content,$count,$tempexport,$href,'uploaded'); + &extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'uploaded'); } } else { - $$message = 'Could not render '.$url.' server message - '.$rtncode; + $$message = 'Could not render '.$url.' server message - '.$rtncode."
\n"; } } elsif ($caller eq 'noedit') { # Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this. @@ -775,23 +785,85 @@ sub replicate_content { } close($copiedfile); } else { - $$message = 'Could not open destination file for '.$filename."\n"; + $$message = 'Could not open destination file for '.$filename."
\n"; } } else { - $$message = 'Could not determine name of file for '.$symb."\n"; + $$message = 'Could not determine name of file for '.$symb."
\n"; } if ($repstatus eq 'ok') { - $content_name = $count.'/'.$filename; + $content_name = 'resources/'.$count.'/'.$filename; } return $content_name; } sub extract_media { - my ($content,$count,$tempexport,$href,$caller) = @_; -# @$href will contain path to any embedded resources in the content. -# For LON-CAPA problems this would be images. applets etc. -# For uploaded HTML files this would be images etc. -# paths will be in the form $count/res/$file, and urls in the $content will be rewritten with the new paths. + my ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_; + my ($dirpath,$container); + my %allfiles = (); + my %codebase = (); + if ($url =~ m-(.*/)([^/]+)$-) { + $dirpath = $1; + $container = $2; + } else { + $dirpath = $url; + $container = ''; + } + &Apache::lonnet::extract_embedded_items(undef,undef,\%allfiles,\%codebase,$content); + foreach my $embed_file (keys(%allfiles)) { + my $filename; + if ($embed_file =~ m#([^/]+)$#) { + $filename = $1; + } else { + $filename = $embed_file; + } + my $newname = 'res/'.$filename; + my ($rtncode,$embed_content,$repstatus); + my $embed_url; + if ($embed_file =~ m-^/-) { + $embed_url = $embed_file; # points to absolute path + } else { + if ($embed_file =~ m-https?://-) { + next; # points to url + } else { + $embed_url = $dirpath.$embed_file; # points to relative path + } + } + if ($caller eq 'resource') { + my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res'; + my $embed_path = &Apache::lonnet::filelocation($respath,$embed_url); + $embed_content = &Apache::lonnet::getfile($embed_path); + unless ($embed_content eq -1) { + $repstatus = 'ok'; + } + } elsif ($caller eq 'uploaded') { + + $repstatus = &Apache::lonnet::getuploaded('GET',$embed_url,$cdom,$cnum,\$embed_content,$rtncode); + } + if ($repstatus eq 'ok') { + my $destination = $tempexport.'/resources/'.$count.'/res'; + if (!-e "$destination") { + mkdir($destination,0755); + } + $destination .= '/'.$filename; + my $copiedfile; + if ($copiedfile = Apache::File->new('>'.$destination)) { + print $copiedfile $embed_content; + push @{$href}, 'resources/'.$count.'/res/'.$filename; + my $attrib_regexp = ''; + if (@{$allfiles{$embed_file}} > 1) { + $attrib_regexp = join('|',@{$allfiles{$embed_file}}); + } else { + $attrib_regexp = $allfiles{$embed_file}[0]; + } + $$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$embed_file\E(['"]?)#$1$newname$2#gi; + if ($caller eq 'resource' && $container =~ /\.(problem|library)$/) { + $$content =~ s#\Q$embed_file\E#$newname#gi; + } + } + } else { + $$message .= 'replication of embedded file - '.$embed_file.' in '.$url.' failed, reason -'.$rtncode."
\n"; + } + } return; } @@ -812,9 +884,9 @@ sub store_template { close($storetemplate); } if ($content_type eq 'external') { - return $count.'/'.$content_type.'.html'; + return 'resources/'.$count.'/'.$content_type.'.html'; } else { - return $count.'/'.$content_type.'.xml'; + return 'resources/'.$count.'/'.$content_type.'.xml'; } } } @@ -898,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 { @@ -1037,7 +1108,7 @@ sub editor { if ($cmd eq 'del') { my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]); if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) && - ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library)$/)) { + ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) { &Apache::lonnet::removeuploadedurl($url); } else { &Apache::lonratedt::makezombie($Apache::lonratedt::order[$idx]); @@ -1113,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 @@ -1138,6 +1212,8 @@ sub editor { $r->print(''); foreach (@Apache::lonratedt::order) { my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]); + $name=&Apache::lonratsrv::qtescape($name); + $url=&Apache::lonratsrv::qtescape($url); unless ($name) { $name=(split(/\//,$url))[-1]; } unless ($name) { $idx++; next; } $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum)); @@ -1175,7 +1251,7 @@ FOLDERINFO } sub process_file_upload { - my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase) = @_; + my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_; # upload a file, if present my $parseaction; if ($env{'form.parserflag'}) { @@ -1183,10 +1259,10 @@ sub process_file_upload { } my $phase_status; my $folder=$env{'form.folder'}; - if ($folder eq '' || $folder eq 'supplemental') { + if ($folder eq '') { $folder='default'; } - if ( ($folder=~/^$1/) || ($1 eq 'default') ) { + if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) { my $errtext=''; my $fatal=0; my $container='sequence'; @@ -1203,10 +1279,13 @@ sub process_file_upload { return 'failed'; } my $destination = 'docs/'; - if ($folder eq 'default') { + if ($folder =~ /^supplemental/) { + $destination = 'supplemental/'; + } + if (($folder eq 'default') || ($folder eq 'supplemental')) { $destination .= 'default/'; - } elsif ($folder =~ /^default_(\d+)$/) { - $destination .= $1.'/'; + } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { + $destination .= $2.'/'; } # this is for a course, not a user, so set coursedoc flag # probably the only place in the system where this should be "1" @@ -1285,10 +1364,13 @@ sub process_secondary_uploads { my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_; my $folder=$env{'form.folder'}; my $destination = 'docs/'; - if ($folder eq 'default') { + if ($folder =~ /^supplemental/) { + $destination = 'supplemental/'; + } + if (($folder eq 'default') || ($folder eq 'supplemental')) { $destination .= 'default/'; - } elsif ($folder =~ /^default_(\d+)$/) { - $destination .= $1.'/'; + } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { + $destination .= $2.'/'; } $destination .= $newidx; my ($url,$filename); @@ -1315,6 +1397,7 @@ sub entryline { &Apache::loncommon::plainname($2,$3).':
'. $foldertitle; } + $renametitle=~s/\\/\\\\/g; $renametitle=~s/\"\;/\\\"/g; my $line=''; # Edit commands @@ -1368,7 +1451,24 @@ sub entryline { 'ct' => 'Cut', 'rn' => 'Rename', 'cp' => 'Copy'); + my $nocopy=0; + if ($url=~/\.(page|sequence)$/) { + foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url))) { + my ($title,$url,$ext,$type)=split(/\:/,$_); + if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) { + $nocopy=1; + last; + } + } + } + my $copylink=' '; if ($env{'form.pagepath'}) { + unless ($nocopy) { + $copylink=(< +$lt{'cp'} +ENDCOPY + } $line.=(< @@ -1392,10 +1492,15 @@ sub entryline { $lt{'ct'} $lt{'rn'} - -$lt{'cp'} +$copylink END } else { + unless ($nocopy) { + $copylink=(< +$lt{'cp'} +ENDCOPY + } $line.=(< @@ -1418,8 +1523,7 @@ END $lt{'ct'} $lt{'rn'} - -$lt{'cp'} +$copylink END } } @@ -1449,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/'. @@ -1482,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.='&' }; @@ -1516,7 +1620,7 @@ END } $line.=''. - ""; + ""; if (($allowed) && ($folder!~/^supplemental/)) { my %lt=&Apache::lonlocal::texthash( 'hd' => 'Hidden', @@ -1560,6 +1664,7 @@ sub tiehash { sub untiehash { if ($hashtied) { untie %hash; } $hashtied=0; + return OK; } # --------------------------------------------------------------- check on this @@ -1636,15 +1741,30 @@ sub checkonthis { # +# ----------------------------------------------------------------- List Symbs +# +sub list_symbs { + 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').''); +} + + +# # -------------------------------------------------------------- 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=(); @@ -1667,13 +1787,18 @@ sub verifycontent { &mt('Return to DOCS').''); } + # -------------------------------------------------------------- Check Versions +sub devalidateversioncache { + my $src=shift; + &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'. + &Apache::lonnet::clutter($src)); +} + 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=''; @@ -1695,6 +1820,7 @@ sub checkversions { foreach (keys %hash) { if ($_=~/^ids\_(\/res\/.+)$/) { $newsetversions{$1}='mostrecent'; + &devalidateversioncache($1); } } } elsif ($env{'form.setcurrent'}) { @@ -1704,6 +1830,7 @@ sub checkversions { my $getvers=&Apache::lonnet::getversion($1); if ($getvers>0) { $newsetversions{$1}=$getvers; + &devalidateversioncache($1); } } } @@ -1714,6 +1841,7 @@ sub checkversions { my $src=$1; if (($env{$_}) && ($env{$_} ne $setversions{$src})) { $newsetversions{$src}=$env{$_}; + &devalidateversioncache($src); } } } @@ -1943,7 +2071,7 @@ sub changewarning { if (defined($env{'form.pagepath'})) { $pathvar='pagepath'; $path=&Apache::lonnet::escape($env{'form.pagepath'}); - $path.='&symb='.&Apache::lonnet::escape($env{'form.pagesymb'}); + $path.='&pagesymb='.&Apache::lonnet::escape($env{'form.pagesymb'}); } $url='/adm/coursedocs?'.$pathvar.'='.$path; } @@ -1969,14 +2097,14 @@ sub handler { return OK if $r->header_only; # --------------------------------------------- Initialize help topics for this - foreach ('Adding_Course_Doc','Main_Course_Documents', - 'Adding_External_Resource','Navigate_Content', - 'Adding_Folders','Docs_Overview', 'Load_Map', - 'Supplemental','Score_Upload_Form','Adding_Pages', - 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive', - 'Check_Resource_Versions','Verify_Content') { - $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_); - } + foreach ('Adding_Course_Doc','Main_Course_Documents', + 'Adding_External_Resource','Navigate_Content', + 'Adding_Folders','Docs_Overview', 'Load_Map', + 'Supplemental','Score_Upload_Form','Adding_Pages', + 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive', + 'Check_Resource_Versions','Verify_Content') { + $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_); + } # Composite help files $help{'Syllabus'} = &Apache::loncommon::help_open_topic( 'Docs_About_Syllabus,Docs_Editing_Templated_Pages'); @@ -1990,13 +2118,18 @@ sub handler { 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages'); $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); - if ($env{'form.verify'}) { +# does this user have privileges to modify docs + my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); + + if ($allowed && $env{'form.verify'}) { &verifycontent($r); - } elsif ($env{'form.versions'}) { + } elsif ($allowed && $env{'form.listsymbs'}) { + &list_symbs($r); + } elsif ($allowed && $env{'form.versions'}) { &checkversions($r); - } elsif ($env{'form.dumpcourse'}) { + } elsif ($allowed && $env{'form.dumpcourse'}) { &dumpcourse($r); - } elsif ($env{'form.exportcourse'}) { + } elsif ($allowed && $env{'form.exportcourse'}) { &exportcourse($r); } else { # is this a standard course? @@ -2005,13 +2138,13 @@ sub handler { my $forcestandard = 0; my $forcesupplement; my $script=''; - my $allowed; - 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)); @@ -2031,30 +2164,24 @@ sub handler { } unless ($showdoc) { # got called from remote if (($env{'form.folder'}=~/^default_/) || - ($env{'form.folder'} =~ m#^\d+/(pages|sequences)/#)) { + ($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) { $forcestandard = 1; } $forcesupplement=($env{'form.folder'}=~/^supplemental_/); -# does this user have privileges to post, etc? - $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); if ($allowed) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']); $script=&Apache::lonratedt::editscript('simple'); } } 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); @@ -2246,7 +2208,7 @@ ENDNEWSCRIPT # Process file upload - phase one - upload and parse primary file. $upload_result = &process_file_upload(\$upload_output,$coursenum, $coursedom,\%allfiles, - \%codebase); + \%codebase,$1); if ($upload_result eq 'phasetwo') { $r->print($upload_output); } @@ -2305,15 +2267,14 @@ 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. my $saveresult; my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; - my $docuhome=$env{'course.'.$env{'request.course.id'}.'.home'}; - my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,$docuhome,\$saveresult); + my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult); } else { &Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus); } @@ -2343,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', @@ -2360,6 +2322,7 @@ ENDNEWSCRIPT my %lt=&Apache::lonlocal::texthash( 'vc' => 'Verify Content', 'cv' => 'Check/Set Resource Versions', + 'ls' => 'List Symbs', ); my $folderpath=$env{'form.folderpath'}; @@ -2394,6 +2357,8 @@ $uploadtag $help{'Check_Resource_Versions'} $dumpbut $exportbut +
$title$title +
ENDCOURSEVERIFY @@ -2496,7 +2461,7 @@ $uploadtag value="$lt{'extr'}" /> $help{'Adding_External_Resource'} -
+
@@ -2506,7 +2471,7 @@ ENDFORM $r->print(''); unless ($env{'form.pagepath'}) { $r->print(< +
@@ -2515,7 +2480,7 @@ onClick="javascript:makenewfolder(this.f value="$lt{'newf'}" />$help{'Adding_Folders'} -
+
@@ -2524,7 +2489,7 @@ onClick="javascript:makenewpage(this.for value="$lt{'newp'}" />$help{'Adding_Pages'}
-
+
$uploadtag @@ -2533,7 +2498,7 @@ value="Syllabus=/public/$coursedom/$cour $help{'Syllabus'}
-
+
$uploadtag @@ -2542,7 +2507,7 @@ value="Navigate Content=/adm/navmaps"> $help{'Navigate_Content'}
-
+
$uploadtag @@ -2550,7 +2515,7 @@ $uploadtag onClick="javascript:makesmppage();" /> $help{'Simple Page'}
-
+
$uploadtag @@ -2558,7 +2523,15 @@ $uploadtag onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
-
+
+$uploadtag + + + + +
+
$uploadtag @@ -2567,7 +2540,7 @@ onClick="javascript:makeexamupload();" / $help{'Score_Upload_Form'}
-
+
$uploadtag @@ -2576,7 +2549,7 @@ onClick="javascript:makebulboard();" /> $help{'Bulletin Board'}
-
+
$uploadtag @@ -2585,7 +2558,7 @@ value="$plainname=/adm/$udom/$uname/abou $help{'My Personal Info'}
-
+
$uploadtag @@ -2605,7 +2578,7 @@ $uploadtag onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
-
+
$uploadtag @@ -2648,7 +2621,15 @@ ENDBLOCK -
$lt{'comment'}:
+
+
+
+ + +

+$lt{'comment'}:

@@ -2670,7 +2651,7 @@ onClick="javascript:makenewfolder(this.f value="$lt{'newf'}" /> $help{'Adding_Folders'}
-
+
@@ -2679,7 +2660,7 @@ onClick="javascript:makenewext('supnewex value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
-
+
@@ -2688,7 +2669,7 @@ value="Syllabus=/public/$coursedom/$cour $help{'Syllabus'}
-
+
@@ -2716,9 +2697,176 @@ ENDSUPFORM } } } - $r->print(''); + $r->print(&Apache::loncommon::end_page()); return OK; } + +sub editing_js { + my ($udom,$uname) = @_; + my $now = time(); + + return <