');
+}
+
sub editor {
- my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output)=@_;
+ my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$which)=@_;
my $errtext='';
my $fatal=0;
my $container='sequence';
if ($env{'form.pagepath'}) {
$container='page';
}
- ($errtext,$fatal)=
- &mapread($coursenum,$coursedom,$folder.'.'.$container);
+ ($errtext,$fatal) = &mapread($coursenum,$coursedom,$folder.'.'.$container);
if ($#LONCAPA::map::order<1) {
my $idx=&LONCAPA::map::getresidx();
if ($idx<=0) { $idx=1; }
$LONCAPA::map::order[0]=$idx;
$LONCAPA::map::resources[$idx]='';
}
- if (defined($env{'form.markcopy'})) {
-# Mark for copying
- my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
- $env{'form.markedcopy_title'}=$title;
- $env{'form.markedcopy_url'}=$url;
- }
+
my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain)=&breadcrumbs($folder);
$r->print($breadcrumbtrail);
if ($fatal) {
- $r->print('
'.$errtext.'
');
+ $r->print('
'.$errtext.'
');
} else {
# ------------------------------------------------------------ Process commands
@@ -1253,7 +1301,7 @@ sub editor {
# store the changed version
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
if ($fatal) {
- $r->print('
'.$errtext.'
');
+ $r->print('
'.$errtext.'
');
return;
}
}
@@ -1293,15 +1341,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{'form.markedcopy_url'};
- my $title=$env{'form.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;
@@ -1317,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);
@@ -1327,7 +1375,7 @@ sub editor {
# Store the result
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
if ($fatal) {
- $r->print('
'.$errtext.'
');
+ $r->print('
'.$errtext.'
');
return;
}
@@ -1384,27 +1432,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;
}
}
@@ -1421,15 +1467,16 @@ 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);
- }
+ }
# ---------------------------------------------------------------- End commands
# ---------------------------------------------------------------- Print screen
my $idx=0;
@@ -1444,7 +1491,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);
@@ -1460,37 +1507,9 @@ sub editor {
$r->print('
'.&mt('Currently no documents.').'
');
}
$r->print("\n
\n");
- if ($env{'form.markedcopy_url'}) {
- $r->print(<');
- }
+ &print_paste_buffer($r,$container);
+
}
}
@@ -1539,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);
@@ -1554,7 +1573,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') {
@@ -1562,7 +1581,7 @@ sub process_file_upload {
if ($total_embedded > 0) {
my $num = 0;
my $state = '
-
+
@@ -1650,46 +1669,74 @@ sub process_secondary_uploads {
return $filename;
}
+sub is_supplemental_title {
+ my ($title) = @_;
+ return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
+}
+
+sub parse_supplemental_title {
+ my ($title) = @_;
+
+ my ($foldertitle,$renametitle);
+ if ($title =~ /&&&/) {
+ $title = &HTML::Entites::decode($title);
+ }
+ if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) {
+ $renametitle=$4;
+ my ($time,$uname,$udom) = ($1,$2,$3);
+ $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
+ my $name = &Apache::loncommon::plainname($uname,$udom);
+ $name = &HTML::Entities::encode($name,'"<>&\'');
+ $title=''.&Apache::lonlocal::locallocaltime($time).' '.
+ $name.': '.$foldertitle;
+ }
+ if (wantarray) {
+ return ($title,$foldertitle,$renametitle);
+ }
+ return $title;
+}
+
# --------------------------------------------------------------- An entry line
sub entryline {
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
- $title=&HTML::Entities::encode($title,'"<>&\'');
- my $renametitle=$title;
- my $foldertitle=$title;
- my $pagetitle=$title;
- my $orderidx=$LONCAPA::map::order[$index];
- if ($title=~ /^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/ ) {
- $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
- $renametitle=$4;
- $title=''.&Apache::lonlocal::locallocaltime($1).' '.
- &Apache::loncommon::plainname($2,$3).': '.
- $foldertitle;
+
+ my ($foldertitle,$pagetitle,$renametitle);
+ if (&is_supplemental_title($title)) {
+ ($title,$foldertitle,$renametitle) = &parse_supplemental_title($title);
+ $pagetitle = $foldertitle;
+ } else {
+ $title=&HTML::Entities::encode($title,'"<>&\'');
+ $renametitle=$title;
+ $foldertitle=$title;
+ $pagetitle=$title;
}
+
+ my $orderidx=$LONCAPA::map::order[$index];
+
+
$renametitle=~s/\\/\\\\/g;
$renametitle=~s/\"\;/\\\"/g;
+ $renametitle=~s/ /%20/g;
my $line='
';
+ my ($form_start,$form_end);
# Edit commands
my $container;
- my $folderpath;
+ my ($container, $type, $esc_path, $path, $symb);
if ($env{'form.folderpath'}) {
+ $type = 'folder';
$container = 'sequence';
- $folderpath=&escape($env{'form.folderpath'});
+ $esc_path=&escape($env{'form.folderpath'});
+ $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
# $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
}
- my ($pagepath,$pagesymb);
if ($env{'form.pagepath'}) {
- $container = 'page';
- $pagepath=&escape($env{'form.pagepath'});
- $pagesymb=&escape($env{'form.pagesymb'});
+ $type = $container = 'page';
+ $esc_path=&escape($path = $env{'form.pagepath'});
+ $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
+ $symb=&escape($env{'form.pagesymb'});
}
my $cpinfo='';
- if ($env{'form.markedcopy_url'}) {
- $cpinfo='&markedcopy_url='.
- &escape($env{'form.markedcopy_url'}).
- '&markedcopy_title='.
- &escape($env{'form.markedcopy_title'});
- }
if ($allowed) {
my $incindex=$index+1;
my $selectbox='';
@@ -1737,82 +1784,53 @@ sub entryline {
}
my $copylink=' ';
my $cutlink=' ';
- if ($env{'form.pagepath'}) {
- if (!$nocopy) {
- $copylink=(<
-$lt{'cp'}
+
+ if (!$nocopy) {
+ $copylink=(<$lt{'cp'}
ENDCOPY
- }
- if (!$nocut) {
- $cutlink=(<
-$lt{'ct'}
+ }
+ if (!$nocut) {
+ $cutlink=(<$lt{'ct'}
ENDCUT
- }
- $line.=(<
-
-
-
-
-
-
-
');
my $lastold=1;
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
my $url=$root.'.'.$prevvers.'.'.$extension;
@@ -2309,7 +2345,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,
@@ -2322,7 +2358,7 @@ ENDHEADERS
'&versionone='.$prevvers.
'">'.&mt('Diffs').'');
}
- $r->print(' ');
+ $r->print(' ');
if (++$entries_count % $entries_per_col == 0) {
$r->print('');
if ($cols_output != 4) {
@@ -2384,14 +2420,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".
''."\n\n");
+$help{'Caching'}.''."\n\n");
}
# =========================================== Breadcrumbs for special functions
@@ -2473,8 +2509,7 @@ sub handler {
my $uploadtag;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['folderpath','pagepath',
- 'pagesymb','markedcopy_url',
- 'markedcopy_title']);
+ 'pagesymb']);
if ($env{'form.folderpath'}) {
my (@folderpath)=split('&',$env{'form.folderpath'});
$env{'form.foldername'}=&unescape(pop(@folderpath));
@@ -2486,8 +2521,8 @@ sub handler {
$env{'form.folder'}=pop(@pagepath);
$containertag = ''.
'';
- $uploadtag = ''.
- '';
+ $uploadtag = ''.
+ '';
}
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
$showdoc='/'.$1;
@@ -2649,6 +2684,7 @@ sub handler {
);
# -----------------------------------------------------------------------------
if ($allowed) {
+ &update_paste_buffer($coursenum,$coursedom);
my $dumpbut=&dumpbutton();
my $exportbut=&exportbutton();
my %lt=&Apache::lonlocal::texthash(
@@ -2668,43 +2704,50 @@ sub handler {
}
unless ($env{'form.pagepath'}) {
$containertag = '';
- $uploadtag = '';
+ $uploadtag = '';
}
$r->print(<
-
-
-
-$containertag
+
+
+
+
+ $containertag
+
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('