'
+ }
}
my $tid = 1;
if ($supplementalflag) {
@@ -1940,19 +1928,6 @@ sub editor {
$readfile));
&print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
} else {
- if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
- #Function Box for Supplemental Content for users with mdc priv.
- my $funcname = &mt('Folder Editor');
- $r->print(
- &Apache::loncommon::head_subbox(
- &Apache::lonhtmlcommon::start_funclist().
- &Apache::lonhtmlcommon::add_item_funclist(
- ''.
- ''.
- ''.$funcname.'').
- &Apache::lonhtmlcommon::end_funclist()));
- }
$r->print($to_show);
}
return;
@@ -2117,7 +2092,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,$pathitem,$supplementalflag)=@_;
my ($foldertitle,$pagetitle,$renametitle);
if (&is_supplemental_title($title)) {
($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
@@ -2131,7 +2107,6 @@ sub entryline {
my $orderidx=$LONCAPA::map::order[$index];
-
$renametitle=~s/\\/\\\\/g;
$renametitle=~s/\"\;/\\\"/g;
$renametitle=~s/ /%20/g;
@@ -2150,9 +2125,24 @@ sub entryline {
$type = $container = 'page';
$esc_path=&escape($env{'form.pagepath'});
$path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
- $symb=&escape($env{'form.pagesymb'});
}
- my $cpinfo='';
+ my $isexternal;
+ if ($residx) {
+ my $currurl = $url;
+ $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
+ if ($currurl =~ m{^/adm/wrapper/ext/}) {
+ $isexternal = 1;
+ }
+ if (!$supplementalflag) {
+ 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='';
@@ -2175,13 +2165,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;
@@ -2242,10 +2239,7 @@ sub entryline {
$nocopy=1;
}
}
- my $copylink=' ';
- my $cutlink=' ';
- my $removelink=' ';
-
+ my ($copylink,$cutlink,$removelink,$renamelink);
my $skip_confirm = 0;
if ( $folder =~ /^supplemental/
|| ($url =~ m{( /smppg$
@@ -2253,26 +2247,41 @@ sub entryline {
|/aboutme$
|/navmaps$
|/bulletinboard$
- |\.html$
- |^/adm/wrapper/ext)}x)) {
+ |\.html$)}x)
+ || $isexternal) {
$skip_confirm = 1;
}
- if (!$nocopy) {
+ if ($nocopy) {
+ $copylink=(<$lt{'cp'}
+ENDCOPY
+ } else {
$copylink=(<$lt{'cp'}
ENDCOPY
}
- if (!$nocut) {
+ if ($nocut) {
+ $cutlink=(<$lt{'ct'}
+ENDCUT
+ } else {
$cutlink=(<$lt{'ct'}
ENDCUT
}
- if (!$noremove) {
+ if ($noremove) {
+ $removelink=(<$lt{'rm'}
+ENDREM
+ } else {
$removelink=(<$lt{'rm'}
ENDREM
}
+ $renamelink=(<$lt{'rn'}
+ENDREN
$form_start = '
';
+ my $ro_set=
+ ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
+ $rand_order_text =
$form_start.
$form_common.'
';
+ }
+ } elsif ($supplementalflag && !$allowed) {
+ $url .= ($url =~ /\?/) ? '&':'?';
+ $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
+ if ($title) {
+ $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
+ }
+ if ($isexternal && $orderidx) {
+ $url .= '&idx='.$orderidx;
+ }
}
if ($ispage) {
my $pagename=&escape($pagetitle);
@@ -2426,23 +2444,32 @@ $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).$cpinfo;
+ '&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 ($isexternal) {
+ $editlink = ' '.
+ &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem);
+ } elsif (!$isfolder && !$ispage) {
+ my ($cfile,$home,$switchserver,$forceedit,$forceview) =
+ &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
+ if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
+ my $jscall =
+ &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
+ $switchserver,
+ $forceedit,
+ undef,$symb,
+ &escape($env{'form.folderpath'}),
+ $renametitle);
+ if ($jscall) {
+ $editlink = ' '.&mt('Edit').'';
+ }
+ }
+ }
}
my $reinit;
if ($crstype eq 'Community') {
@@ -2468,7 +2495,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/)) {
@@ -2499,6 +2526,30 @@ ENDPARMS
return $line;
}
+sub newmap_suffix {
+ my ($area,$container,$coursedom,$coursenum) = @_;
+ my ($prefix,$idtype,$errtext,$locknotfreed);
+ $prefix = 'docs';
+ if ($area eq 'supplemental') {
+ $prefix = 'supp';
+ }
+ $prefix .= $container;
+ $idtype = 'concat';
+ my ($suffix,$freedlock,$error) =
+ &Apache::lonnet::get_timebased_id($prefix,'num','uploadedmaps',
+ $coursedom,$coursenum);
+ if (!$suffix) {
+ $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
+ if ($error) {
+ $errtext .= ' '.$error;
+ }
+ }
+ if ($freedlock ne 'ok') {
+ $locknotfreed = '
'.&mt('There was a problem removing a lockfile. This will prevent creation of additional folders or composite pages in this course. Please contact the domain coordinator for your LON-CAPA domain.').'
';
+ }
+ return ($suffix,$errtext,$locknotfreed);
+}
+
=pod
=item tiehash()
@@ -3031,9 +3082,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;
@@ -3103,7 +3154,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);
}
@@ -3165,7 +3217,7 @@ sub handler {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['folderpath','pagepath',
'pagesymb','forcesupplement','forcestandard',
- 'tools','symb','command']);
+ 'tools','symb','command','supppath']);
# standard=1: this is a "new-style" course with an uploaded map as top level
# standard=2: this is a "old-style" course, and there is nothing we can do
@@ -3194,7 +3246,7 @@ sub handler {
my $addentries = {};
my $container;
my $containertag;
- my $uploadtag;
+ my $pathitem;
# Do we directly jump somewhere?
@@ -3235,21 +3287,31 @@ sub handler {
}
}
}
- $path .= '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
- &Apache::lonhtmlcommon::entity_encode($mapresobj->title()).
+ $path =~ s/^\&//;
+ my $maptitle = $mapresobj->title();
+ if ($mapurl eq 'default') {
+ $maptitle = 'Main Course Documents';
+ }
+ $path .= (($path ne '')? '&' : '').
+ &Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
+ &Apache::lonhtmlcommon::entity_encode($maptitle).
':'.$mapresobj->randompick().
':'.$mapresobj->randomout().
':'.$mapresobj->encrypted().
':'.$mapresobj->randomorder();
} else {
my $maptitle = &Apache::lonnet::gettitle($mapurl);
- $path = '&default&...::::'.
- '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
- &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
+ if ($mapurl eq 'default') {
+ $maptitle = 'Main Course Documents';
+ }
+ $path = &Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
+ &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
+ }
+ unless ($mapurl eq 'default') {
+ $path = 'default&'.
+ &Apache::lonhtmlcommon::entity_encode('Main Course Documents').
+ '::::&'.$path;
}
- $path = 'default&'.
- &Apache::lonhtmlcommon::entity_encode('Main Course Documents').
- $path;
if ($type eq 'sequence') {
$env{'form.folderpath'}=$path;
$env{'form.pagepath'}='';
@@ -3276,10 +3338,10 @@ sub handler {
$stored_folderpath='docs_sup_folderpath';
}
-# No folderpath, no pagepath, see if we have something stored
- if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
+# No folderpath, no pagepath, and in edit mode, see if we have something stored
+ if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'}) && $allowed) {
&Apache::loncommon::restore_course_settings($stored_folderpath,
- {'folderpath' => 'scalar'});
+ {'folderpath' => 'scalar'});
}
# If we are not allowed to make changes, all we can see are supplemental docs
@@ -3311,9 +3373,11 @@ sub handler {
# Store this
unless ($toolsflag) {
- &Apache::loncommon::store_course_settings($stored_folderpath,
- {'pagepath' => 'scalar',
- 'folderpath' => 'scalar'});
+ if ($allowed) {
+ &Apache::loncommon::store_course_settings($stored_folderpath,
+ {'pagepath' => 'scalar',
+ 'folderpath' => 'scalar'});
+ }
if ($env{'form.folderpath'}) {
my (@folderpath)=split('&',$env{'form.folderpath'});
$env{'form.foldername'}=&unescape(pop(@folderpath));
@@ -3327,7 +3391,7 @@ sub handler {
$container='page';
$containertag = ''.
'';
- $uploadtag =
+ $pathitem =
''.
''.
'';
@@ -3341,7 +3405,7 @@ sub handler {
}
}
$containertag = '';
- $uploadtag = '';
+ $pathitem = '';
}
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
$showdoc='/'.$1;
@@ -3389,7 +3453,8 @@ sub handler {
$script .= &editing_js($udom,$uname,$supplementalflag).
&history_tab_js().
&inject_data_js().
- &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr);
+ &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr).
+ &Apache::lonextresedit::extedit_javascript();
$addentries = {
onload => "javascript:resize_scrollbox('contentscroll','1','1');",
};
@@ -3397,6 +3462,10 @@ 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 = '