--- loncom/interface/londocs.pm 2007/07/03 23:02:53 1.285 +++ loncom/interface/londocs.pm 2007/07/07 00:53:24 1.287 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.285 2007/07/03 23:02:53 albertel Exp $ +# $Id: londocs.pm,v 1.287 2007/07/07 00:53:24 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -908,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))) { @@ -934,14 +932,16 @@ sub group_import { } } if ($url) { - my $idx = &LONCAPA::map::getresidx($url); - $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx; + if (!$residx) { + $residx = &LONCAPA::map::getresidx($url); + $LONCAPA::map::order[$#LONCAPA::map::order+1]=$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); @@ -1199,6 +1199,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'}); @@ -1209,32 +1211,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 { @@ -1344,8 +1348,8 @@ sub editor { 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; @@ -1361,7 +1365,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); @@ -1435,13 +1439,11 @@ sub editor { # 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 @@ -1556,7 +1558,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); @@ -1715,7 +1717,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); @@ -1791,12 +1795,15 @@ ENDCOPY $lt{'ct'} ENDCUT } - $line.=(< + $form_start = (< +END + $form_end = ''; + $line.=(< @@ -1812,7 +1819,9 @@ ENDCUT
+ $form_start $selectbox + $form_end $lt{'rm'} @@ -1849,7 +1858,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 +1883,7 @@ END } } elsif ($url=~m|^/ext/|) { $url='/adm/wrapper'.$url; + $external = 1; } if (&Apache::lonnet::symbverify($symb,$url)) { $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); @@ -1925,12 +1937,18 @@ END $url.='pagepath='.&escape($pagepath). '&pagesymb='.&escape($symb).$cpinfo; } + 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)').'')." + '.($url?"":'').$title.($url?'':' '.&mt('(re-initialize course to access)').'').$external." "; if (($allowed) && ($folder!~/^supplemental/)) { my %lt=&Apache::lonlocal::texthash( @@ -1942,15 +1960,19 @@ END ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':''); $line.=(< + $form_start + $form_end + $form_start + $form_end - $parameterset + $form_start $parameterset $form_end ENDPARMS } - $line.=""; + $line.=""; return $line; } @@ -2398,7 +2420,7 @@ 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". '
'. '

'. @@ -2735,7 +2757,7 @@ ENDCOURSEVERIFY } my $postexec=''; if ($folder eq 'default') { - $r->print(''); + $r->print(''); } else { #$postexec='self.close();'; } @@ -2765,12 +2787,12 @@ ENDCOURSEVERIFY $lt{'file'}:
- +
$lt{'title'}:
- + $uploadtag - +