--- loncom/interface/londocs.pm 2007/07/02 23:43:36 1.282 +++ loncom/interface/londocs.pm 2007/07/12 01:04:36 1.288 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.282 2007/07/02 23:43:36 albertel Exp $ +# $Id: londocs.pm,v 1.288 2007/07/12 01:04:36 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -122,16 +122,17 @@ sub dumpbutton { my ($home,$other,%outhash)=&authorhosts(); my $type = &Apache::loncommon::course_type(); if ($home+$other==0) { return ''; } - my $output=''; if ($home) { - return ''. + return '
'. ''. - &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs'); + &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs'). + '
'; } else { - return''. + return '
'. &mt('Dump '.$type. - ' DOCS to Construction Space: available on other servers'); + ' DOCS to Construction Space: available on other servers'). + '
'; } } @@ -199,9 +200,9 @@ sub dumpcourse { $fail=1; } if ($fail) { - $r->print('fail'); + $r->print(''.&mt('fail').''); } else { - $r->print('ok'); + $r->print(''.&mt('ok').''); } } } else { @@ -257,10 +258,10 @@ sub dumpcourse { sub exportbutton { my $type = &Apache::loncommon::course_type(); - return ''. + return '
'. ''. - &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs'); + &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'
'; } sub exportcourse { @@ -907,9 +908,7 @@ sub group_import { my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_; while (@files) { - my $name = shift(@files); - my $url = shift(@files); - #FIXME check if file exists before overwriting, might be restoring it + my ($name, $url, $residx) = @{ shift(@files) }; if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) && ($caller eq 'londocs') && (!&Apache::lonnet::stat_file($url))) { @@ -933,14 +932,17 @@ sub group_import { } } if ($url) { - my $idx = &LONCAPA::map::getresidx($url); - $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx; + if (!$residx + || defined($LONCAPA::map::zombies[$residx])) { + $residx = &LONCAPA::map::getresidx($url,$residx); + push(@LONCAPA::map::order, $residx); + } my $ext = 'false'; if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; } $url = &LONCAPA::map::qtunescape($url); $name = &LONCAPA::map::qtunescape($name); - $LONCAPA::map::resources[$idx] = - join ':', ($name, $url, $ext, 'normal', 'res'); + $LONCAPA::map::resources[$residx] = + join(':', ($name, $url, $ext, 'normal', 'res')); } } return &storemap($coursenum, $coursedom, $folder.'.'.$container); @@ -1198,6 +1200,8 @@ sub update_paste_buffer { if (&is_supplemental_title($title)) { ($title) = &parse_supplemental_title($title); } + $url=~s{http(:|:)//https(:|:)//}{https$2//}; + &Apache::lonnet::appenv('docs.markedcopy_title' => $title, 'docs.markedcopy_url' => $url); delete($env{'form.markcopy'}); @@ -1208,32 +1212,34 @@ sub print_paste_buffer { return if (!defined($env{'docs.markedcopy_url'})); $r->print(<
+

ENDPASTE $r->print(' '); my $type; - if ($env{'docs.markedcopy_url'} =~ m{^/adm/wrapper/ext}) { + if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { $type = &mt('External Resource'); - $r->print($type.': '.&Apache::map::qtescape($env{'docs.markedcopy_title'})); + $r->print($type.': '. + &LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('. + &LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')'); } else { my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1]; my $type = &Apache::loncommon::filedescription($extension); my $icon = ''; - $r->print($icon.$type.': '. &parse_supplemental_title($env{'docs.markedcopy_title'})); + '" alt="" class="LC_icon" />'; + $r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}))); } if ($container eq 'page') { - $r->print(< - -PAGEINFO + $r->print(' + + +'); } else { - $r->print(< -FOLDERINFO + $r->print(' + +'); } - $r->print('

'); + $r->print('

'); } sub editor { @@ -1255,7 +1261,7 @@ sub editor { my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain)=&breadcrumbs($folder); $r->print($breadcrumbtrail); if ($fatal) { - $r->print('

'.$errtext.'

'); + $r->print('

'.$errtext.'

'); } else { # ------------------------------------------------------------ Process commands @@ -1296,7 +1302,7 @@ sub editor { # store the changed version ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); if ($fatal) { - $r->print('

'.$errtext.'

'); + $r->print('

'.$errtext.'

'); return; } } @@ -1336,15 +1342,15 @@ sub editor { # store the changed version ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); if ($fatal) { - $r->print('

'.$errtext.'

'); + $r->print('

'.$errtext.'

'); return; } } if ($env{'form.pastemarked'}) { # paste resource to end of list - my $url=$env{'docs.markedcopy_url'}; - my $title=$env{'docs.markedcopy_title'}; + my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}); + my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}); # Maps need to be copied first if (($url=~/\.(page|sequence)$/) || ($url=~/^\/uploaded\//)) { $title=&mt('Copy of').' '.$title; @@ -1360,7 +1366,7 @@ sub editor { } $title = &LONCAPA::map::qtunescape($title); my $ext='false'; - if ($url=~/^http\:\/\//) { $ext='true'; } + if ($url=~m{^http(|s)://}) { $ext='true'; } $url = &LONCAPA::map::qtunescape($url); # Now insert the URL at the bottom my $newidx=&LONCAPA::map::getresidx($url); @@ -1370,7 +1376,7 @@ sub editor { # Store the result ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); if ($fatal) { - $r->print('

'.$errtext.'

'); + $r->print('

'.$errtext.'

'); return; } @@ -1427,27 +1433,25 @@ sub editor { ($errtext,$fatal)=&storemap($coursenum,$coursedom, $folder.'.'.$container); if ($fatal) { - $r->print('

'.$errtext.'

'); + $r->print('

'.$errtext.'

'); return; } } # Group import/search if ($env{'form.importdetail'}) { my @imports; -# &Apache::lonnet::logthis("imp detail ".$env{'form.importdetail'}); foreach (split(/\&/,$env{'form.importdetail'})) { if (defined($_)) { - my ($name,$url)=split(/\=/,$_); - $name=&unescape($name); - $url=&unescape($url); - push @imports, $name, $url; + my ($name,$url,$residx)= + map {&unescape($_)} split(/\=/,$_); + push(@imports, [$name, $url, $residx]); } } # Store the changed version ($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder, $container,'londocs',@imports); if ($fatal) { - $r->print('

'.$errtext.'

'); + $r->print('

'.$errtext.'

'); return; } } @@ -1464,11 +1468,12 @@ sub editor { ($errtext,$fatal)=&storemap($coursenum,$coursedom, $folder.'.'.$container); if ($fatal) { - $r->print('

'.$errtext.'

'); + $r->print('

'.$errtext.'

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

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

'); + $r->print('

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

'); + } } &log_differences($plain); @@ -1487,7 +1492,7 @@ sub editor { if ($randompick>=0) { $r->print('

'.&mt('Caution: this folder is set to randomly pick a subset of resources. Adding or removing resources from this folder will change the set of resources that the students see, resulting in spurious or missing credit for completed problems, not limited to ones you modify. Do not modify the contents of this folder if it is in active student use.').'

'); } - $r->print(''); + $r->print('
'); foreach my $res (@LONCAPA::map::order) { my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); $name=&LONCAPA::map::qtescape($name); @@ -1554,7 +1559,7 @@ sub process_file_upload { $parseaction,$allfiles, $codebase); my $ext='false'; - if ($url=~/^http\:\/\//) { $ext='true'; } + if ($url=~m{^http://}) { $ext='true'; } $url = &LONCAPA::map::qtunescape($url); my $comment=$env{'form.comment'}; $comment = &LONCAPA::map::qtunescape($comment); @@ -1569,7 +1574,7 @@ sub process_file_upload { ($errtext,$fatal)=&storemap($coursenum,$coursedom, $folder.'.'.$container); if ($fatal) { - $$upload_output .= '

'.$errtext.'

'; + $$upload_output .= '

'.$errtext.'

'; return 'failed'; } else { if ($parseaction eq 'parse') { @@ -1713,7 +1718,9 @@ sub entryline { $renametitle=~s/\\/\\\\/g; $renametitle=~s/\"\;/\\\"/g; + $renametitle=~s/ /%20/g; my $line=''; + my ($form_start,$form_end); # Edit commands my $container; my ($container, $type, $esc_path, $path, $symb); @@ -1781,43 +1788,46 @@ sub entryline { if (!$nocopy) { $copylink=(< -$lt{'cp'} +$lt{'cp'} ENDCOPY } if (!$nocut) { $cutlink=(< -$lt{'ct'} +$lt{'ct'} ENDCUT } - $line.=(< + $form_start = (< +END + $form_end = ''; + $line.=(< -
+
- -
+ $lt{
+ $lt{
+ $form_start $selectbox + $form_end - - $lt{'rm'} + + $lt{'rm'} $cutlink - $lt{'rn'} + $lt{'rn'} $copylink END @@ -1849,7 +1859,9 @@ END &Apache::lonnet::allowuploaded('/adm/coursedoc',$url); } } - $url=~s-^http(\&colon\;|:)//-/adm/wrapper/ext/-; + + my $orig_url = $url; + my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/}); if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) { my $symb=&Apache::lonnet::symbclean( &Apache::lonnet::declutter('uploaded/'. @@ -1872,6 +1884,7 @@ END } } elsif ($url=~m|^/ext/|) { $url='/adm/wrapper'.$url; + $external = 1; } if (&Apache::lonnet::symbverify($symb,$url)) { $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); @@ -1904,7 +1917,7 @@ END (&LONCAPA::map::getparameter($orderidx, 'parameter_randompick'))[0]. '" />'. -''.&mt('Save').''; +''.&mt('Save').''; } if ($ispage) { @@ -1925,10 +1938,19 @@ END $url.='pagepath='.&escape($pagepath). '&pagesymb='.&escape($symb).$cpinfo; } - $line.=''. - "".($url?"":'').$title. - ($url?'':' '.&mt('(re-initialize course to access)').'').""; + if ($external) { + my $form = ($folder =~ /^default/)? 'newext' : 'supnewext'; + $external = ' '.&mt('Edit').''; + } else { + undef($external); + } + $line.=' + + '.($url?'':'').''.($url?'':'').' + + + '.($url?"":'').$title.($url?'':' '.&mt('(re-initialize course to access)').'').$external." + "; if (($allowed) && ($folder!~/^supplemental/)) { my %lt=&Apache::lonlocal::texthash( 'hd' => 'Hidden', @@ -1938,14 +1960,20 @@ END my $hidtext= ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':''); $line.=(< - - - -$parameterset + + $form_start + + $form_end + + + $form_start + + $form_end + + $form_start $parameterset $form_end ENDPARMS } - $line.=""; + $line.=""; return $line; } @@ -2011,17 +2039,17 @@ sub checkonthis { if (($errorcount) || ($warningcount)) { if ($errorcount) { - $r->print(''. + $r->print(''. $errorcount.' '. - &mt('error(s)').' '); + &mt('error(s)').' '); } if ($warningcount) { - $r->print(''. + $r->print(''. $warningcount.' '. - &mt('warning(s)').''); + &mt('warning(s)').''); } } else { - $r->print(''.&mt('ok').''); + $r->print(''.&mt('ok').''); } $r->rflush(); } @@ -2033,15 +2061,15 @@ sub checkonthis { } } } elsif ($result eq 'unavailable') { - $r->print(''.&mt('connection down').''); + $r->print(''.&mt('connection down').''); } elsif ($result eq 'not_found') { unless ($url=~/\$/) { - $r->print(''.&mt('not found').''); + $r->print(''.&mt('not found').''); } else { - $r->print(''.&mt('unable to verify variable URL').''); + $r->print(''.&mt('unable to verify variable URL').''); } } else { - $r->print(''.&mt('access denied').''); + $r->print(''.&mt('access denied').''); } } } @@ -2083,9 +2111,9 @@ sub verifycontent { foreach (keys %hash) { if ($hash{$_}=~/\.(page|sequence)$/) { if (($_=~/^src_/) && ($alreadyseen{&unescape($hash{$_})})) { - $r->print('
'. + $r->print('
'. &mt('The following sequence or page is included more than once in your '.$type.': '). - &unescape($hash{$_}).'

'. + &unescape($hash{$_}).'
'. &mt('Note that grading records for problems included in this sequence or folder will overlap.
')); } } @@ -2165,7 +2193,7 @@ sub checkversions { $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { $r->print('

'.&mt('Your Version Settings have been Saved').'

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

'.&mt('An Error Occured while Attempting to Save your Version Settings').'

'); + $r->print('

'.&mt('An Error Occured while Attempting to Save your Version Settings').'

'); } &mark_hash_old(); } @@ -2272,10 +2300,10 @@ ENDHEADERS 'lastrevisiondate') ). ''. - 'Most Recent: '. + 'Most Recent: '. ''.$currentversion.''. - ''. - 'In '.$type.': '. + ''. + 'In '.$type.': '. ''); # Used in course my $usedversion=$hash{'version_'.$linkurl}; @@ -2284,8 +2312,8 @@ ENDHEADERS } else { $r->print($currentversion); } - $r->print(''. - 'Use: '); + $r->print('
'. + 'Use: '); # Set version $r->print(&Apache::loncommon::select_form($setversions{$linkurl}, 'set_version_'.$linkurl, @@ -2294,7 +2322,7 @@ ENDHEADERS '' => '', 'mostrecent' => 'most recent', map {$_,$_} (1..$currentversion)))); - $r->print(''); + $r->print(''); my $lastold=1; for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { my $url=$root.'.'.$prevvers.'.'.$extension; @@ -2318,7 +2346,7 @@ ENDHEADERS my $cols_output = 1; for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) { my $url=$root.'.'.$prevvers.'.'.$extension; - $r->print(''.&mt('Version').' '.$prevvers.' ('. &Apache::lonlocal::locallocaltime( &Apache::lonnet::metadata($url, @@ -2331,7 +2359,7 @@ ENDHEADERS '&versionone='.$prevvers. '">'.&mt('Diffs').''); } - $r->print('
'); + $r->print('
'); if (++$entries_count % $entries_per_col == 0) { $r->print(''); if ($cols_output != 4) { @@ -2393,14 +2421,14 @@ sub changewarning { $message='Changes will become active for your current session after [_1], or the next time you log in.'; } $r->print("\n\n". -''."\n". +''."\n". '
'. '

'. +'" />

'. &mt($message,' '). -$help{'Caching'}.'

'."\n\n"); +$help{'Caching'}.'

'."\n\n"); } # =========================================== Breadcrumbs for special functions @@ -2682,39 +2710,45 @@ sub handler { $r->print(< - - - - -$containertag + + + + + $containertag
- -$uploadtag + + $uploadtag
- -
-$help{'Verify_Content'} - - $help{'Check_Resource_Versions'} -$dumpbut -$exportbut - - - - - -
+
+ +
+ $help{'Verify_Content'} +
+
+ $help{'Check_Resource_Versions'} +
+ $dumpbut + $exportbut +
+ +
+
+ + +
+
+
 
ENDCOURSEVERIFY $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', &mt('Editing the Table of Contents for your '.$type))); } # --------------------------------------------------------- Standard documents - $r->print(''); + $r->print('
');#border=2 cellspacing=4 cellpadding=4>'); if (($standard) && ($allowed) && (!$forcesupplement)) { - $r->print(' - - - +
'); + $r->print('
'); # '

'.&mt('Main Course Documents'). # ($allowed?' '.$help{'Main_Course_Documents'}:'').'

'); my $folder=$env{'form.folder'}; @@ -2724,7 +2758,7 @@ ENDCOURSEVERIFY } my $postexec=''; if ($folder eq 'default') { - $r->print(''); + $r->print(''); } else { #$postexec='self.close();'; } @@ -2744,54 +2778,56 @@ ENDCOURSEVERIFY } my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container; $r->print(<
$lt{'uplm'}$lt{'impp'}$lt{'spec'}
+ + + + - + - - - +
$lt{'uplm'}$lt{'impp'}$lt{'spec'}
+
$lt{'file'}:
- +
$lt{'title'}:
- + $uploadtag - +
- + - +

- - + + $help{'Uploading_From_Harddrive'} - +
+
$lt{'pubd'}
$uploadtag - +
- - + + $help{'Importing_LON-CAPA_Resource'} - +
- -

+


+

$lt{'copm'}

- -$help{'Load_Map'} +$help{'Load_Map'}


@@ -2805,10 +2841,10 @@ ENDFORM
$uploadtag - + $help{'Adding_External_Resource'} - +

@@ -2816,113 +2852,113 @@ value="$lt{'extr'}" /> $help{'Adding_Ext
ENDFORM } - $r->print('
'); + $r->print(''); unless ($env{'form.pagepath'}) { my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); $r->print(<
- + $help{'Adding_Folders'} - +

- + $help{'Adding_Pages'} - +

$uploadtag - + $help{'Syllabus'} - +

$uploadtag - + $help{'Navigate_Content'} - +

$uploadtag - + $help{'Simple Page'} - +

$uploadtag - + $help{'Simple Problem'} - +

$uploadtag - + - +

$uploadtag - + $help{'Score_Upload_Form'} - +

$uploadtag - + $help{'Bulletin Board'} - +

$uploadtag - + $help{'My Personal Info'} - +

$uploadtag - + - +

$uploadtag - + $help{'Group Files'} - +
ENDFORM } @@ -2931,19 +2967,19 @@ ENDFORM
$uploadtag - + $help{'Simple Problem'} - +

$uploadtag - + $help{'Score_Upload_Form'} - +
ENDBLOCK } @@ -2953,7 +2989,7 @@ ENDBLOCK } # ----------------------------------------------------- Supplemental documents if (!$forcestandard) { - $r->print('
'); + $r->print('
'); # '

'.&mt('Supplemental Course Documents'). # ($allowed?' '.$help{'Supplemental'}:'').'

'); my $folder=$env{'form.folder'}; @@ -2973,86 +3009,92 @@ ENDBLOCK my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); $r->print(<
$lt{'upls'}$lt{'spec'}
+ + - -
$lt{'upls'}$lt{'spec'}
+
- +

- + - +

$lt{'comment'}:

- - - + + + $help{'Uploading_From_Harddrive'} - +
+
- + $help{'Adding_Folders'} - +

- + $help{'Adding_External_Resource'} - +

- + $help{'Syllabus'} - +

- + $help{'My Personal Info'} - +
ENDSUPFORM } } + $r->print(''); if ($allowed) { - $r->print('
'); + $r->print(' +
+ + + + +
'); } - $r->print(''); } else { unless ($upload_result eq 'phasetwo') { # -------------------------------------------------------- This is showdoc mode $r->print("

".&mt('Uploaded Document').' - '. &Apache::lonnet::gettitle($r->uri).'

'. -&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."

". - &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'

'); +&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."

". + &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'
'); } } } @@ -3084,6 +3126,17 @@ function makenewpage(targetform,folderse function makenewext(targetname) { this.document.forms.extimport.useform.value=targetname; + this.document.forms.extimport.title.value=''; + this.document.forms.extimport.url.value=''; + this.document.forms.extimport.residx.value=''; + window.open('/adm/rat/extpickframe.html'); +} + +function edittext(targetname,residx,title,url) { + this.document.forms.extimport.useform.value=targetname; + this.document.forms.extimport.residx.value=residx; + this.document.forms.extimport.url.value=url; + this.document.forms.extimport.title.value=title; window.open('/adm/rat/extpickframe.html'); } @@ -3163,9 +3216,8 @@ 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();'); + var residx=this.document.forms.extimport.residx.value; + eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();'); } function changename(folderpath,index,oldtitle,container,pagesymb) {