--- loncom/interface/londocs.pm 2012/12/12 23:12:27 1.484.2.11
+++ loncom/interface/londocs.pm 2012/12/13 00:51:34 1.484.2.12
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.484.2.11 2012/12/12 23:12:27 raeburn Exp $
+# $Id: londocs.pm,v 1.484.2.12 2012/12/13 00:51:34 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1743,7 +1743,7 @@ sub handle_edit_cmd {
sub editor {
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
- $supplementalflag,$orderhash,$iconpath)=@_;
+ $supplementalflag,$orderhash,$iconpath,$uploadtag)=@_;
my $container= ($env{'form.pagepath'}) ? 'page'
: 'sequence';
@@ -1899,7 +1899,8 @@ sub editor {
unless ($name) { $name=(split(/\//,$url))[-1]; }
unless ($name) { $idx++; next; }
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
- $coursenum,$crstype);
+ $coursenum,$coursedom,$crstype,
+ $uploadtag,$supplementalflag);
$idx++;
$shown++;
}
@@ -2116,7 +2117,8 @@ sub is_supplemental_title {
# --------------------------------------------------------------- An entry line
sub entryline {
- my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_;
+ my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
+ $crstype,$uploadtag,$supplementalflag)=@_;
my ($foldertitle,$pagetitle,$renametitle);
if (&is_supplemental_title($title)) {
($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
@@ -2130,7 +2132,6 @@ sub entryline {
my $orderidx=$LONCAPA::map::order[$index];
-
$renametitle=~s/\\/\\\\/g;
$renametitle=~s/\"\;/\\\"/g;
$renametitle=~s/ /%20/g;
@@ -2149,8 +2150,18 @@ sub entryline {
$type = $container = 'page';
$esc_path=&escape($env{'form.pagepath'});
$path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
- $symb=&escape($env{'form.pagesymb'});
}
+ if (!$supplementalflag && $residx) {
+ my $currurl = $url;
+ $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
+ my $path = 'uploaded/'.
+ $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
+ $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
+ $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
+ $residx,
+ &Apache::lonnet::declutter($currurl));
+ }
+ my %lt;
if ($allowed) {
my $incindex=$index+1;
my $selectbox='';
@@ -2173,13 +2184,20 @@ sub entryline {
}
$selectbox.='';
}
- my %lt=&Apache::lonlocal::texthash(
+ %lt=&Apache::lonlocal::texthash(
'up' => 'Move Up',
'dw' => 'Move Down',
'rm' => 'Remove',
'ct' => 'Cut',
'rn' => 'Rename',
- 'cp' => 'Copy');
+ 'cp' => 'Copy',
+ 'ex' => 'External Resource',
+ 'ed' => 'Edit',
+ 'pr' => 'Preview',
+ 'sv' => 'Save',
+ 'ul' => 'URL',
+ 'ti' => 'Title',
+ );
my $nocopy=0;
my $nocut=0;
my $noremove=0;
@@ -2285,12 +2303,12 @@ END
|
@@ -2341,44 +2359,38 @@ END
}
}
+ my $editlink;
my $orig_url = $url;
$orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
- if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
- my $symb=&Apache::lonnet::symbclean(
- &Apache::lonnet::declutter('uploaded/'.
- $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
- $env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
- '.sequence').
- '___'.$residx.'___'.
- &Apache::lonnet::declutter($url));
- (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
- $url=&Apache::lonnet::clutter($url);
- if ($url=~/^\/*uploaded\//) {
- $url=~/\.(\w+)$/;
- my $embstyle=&Apache::loncommon::fileembstyle($1);
- if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
- $url='/adm/wrapper'.$url;
- } elsif ($embstyle eq 'ssi') {
- #do nothing with these
- } elsif ($url!~/\.(sequence|page)$/) {
- $url='/adm/coursedocs/showdoc'.$url;
- }
- } elsif ($url=~m|^/ext/|) {
- $url='/adm/wrapper'.$url;
- $external = 1;
- }
- if (&Apache::lonnet::symbverify($symb,$url)) {
- $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
- } else {
- $url='';
+ if (!$supplementalflag && $residx && $symb) {
+ if ($container eq 'page') {
+ $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
+ $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
+ }
+ if ((!$isfolder) && (!$ispage)) {
+ (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
+ $url=&Apache::lonnet::clutter($url);
+ if ($url=~/^\/*uploaded\//) {
+ $url=~/\.(\w+)$/;
+ my $embstyle=&Apache::loncommon::fileembstyle($1);
+ if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
+ $url='/adm/wrapper'.$url;
+ } elsif ($embstyle eq 'ssi') {
+ #do nothing with these
+ } elsif ($url!~/\.(sequence|page)$/) {
+ $url='/adm/coursedocs/showdoc'.$url;
+ }
+ } elsif ($url=~m|^/ext/|) {
+ $url='/adm/wrapper'.$url;
+ $external = 1;
+ }
+ if (&Apache::lonnet::symbverify($symb,$url)) {
+ $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
+ } else {
+ $url='';
+ }
}
- if ($container eq 'page') {
- my $symb=$env{'form.pagesymb'};
-
- $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
- $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
- }
}
my ($rand_pick_text,$rand_order_text);
if ($isfolder || $extension eq 'sequence') {
@@ -2424,23 +2436,50 @@ $form_common.'
my $folderpath=$env{'form.folderpath'};
if ($folderpath) { $pagepath = $folderpath.'&' };
$pagepath.=$pagearg.'&'.$pagename;
- my $symb=$env{'form.pagesymb'};
- if (!$symb) {
- my $path='uploaded/'.
- $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
- $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
- $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
- $residx,
- $path.$pagearg.'.page');
- }
$url.='pagepath='.&escape($pagepath).
'&pagesymb='.&escape($symb);
}
- if (($external) && ($allowed)) {
- my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
- $external = ' '.&mt('Edit').'';
- } else {
- undef($external);
+ if ($allowed) {
+ my $fileloc =
+ &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
+
+ if ($external) {
+ $editlink = <<"EXTLNK";
+
+
+ $lt{'ed'}
+
+EXTLNK
+ } else {
+ my ($cfile,$home,$switchserver,$uploaded) =
+ &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom);
+ if (($cfile ne '') && ($symb ne '')) {
+ my $jscall =
+ &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
+ $switchserver,
+ $uploaded,$symb);
+ if ($jscall) {
+ $editlink = ' '.&mt('Edit').'';
+ }
+ }
+ }
}
my $reinit;
if ($crstype eq 'Community') {
@@ -2466,7 +2505,7 @@ $form_common.'
} else {
$line.=$title.' '.$reinit.'';
}
- $line.=$external."";
+ $line.=$editlink."";
$rand_pick_text = ' ' if ($rand_pick_text eq '');
$rand_order_text = ' ' if ($rand_order_text eq '');
if (($allowed) && ($folder!~/^supplemental/)) {
@@ -3029,9 +3068,9 @@ sub init_breadcrumbs {
sub create_list_elements {
my @formarr = @_;
my $list = '';
- for my $button (@formarr){
- for my $picture(keys %$button) {
- $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'});
+ foreach my $button (@formarr){
+ foreach my $picture (keys(%{$button})) {
+ $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
}
}
return $list;
@@ -3100,7 +3139,8 @@ sub handler {
'Adding_External_Resource','Navigate_Content',
'Adding_Folders','Docs_Overview', 'Load_Map',
'Supplemental','Score_Upload_Form','Adding_Pages',
- 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
+ 'Importing_LON-CAPA_Resource','Importing_IMS_Course',
+ 'Uploading_From_Harddrive',
'Check_Resource_Versions','Verify_Content') {
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
}
@@ -3394,6 +3434,8 @@ sub handler {
if ($env{'docs.markedcopy_url'}) {
$script .= &paste_popup_js();
}
+ my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
+ &mt('Switch server?');
}
# -------------------------------------------------------------------- Body tag
$script = '