[LON-CAPA-cvs] cvs: loncom /interface londocs.pm
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Fri, 29 Jun 2007 23:25:32 -0000
This is a MIME encoded message
--albertel1183159532
Content-Type: text/plain
albertel Fri Jun 29 19:25:32 2007 EDT
Modified files:
/loncom/interface londocs.pm
Log:
- paste buffer works better
- re-init no longer clears it (BUG#4982)
- properly handles copy/cut from both main and supp docs (can copy
paste between the two too)
- clicking on paths in docs no longer clears it (BUG#4983)
- remove and rename no longer populate Paste buffer with first resource
BUG#4260
--albertel1183159532
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20070629192532.txt"
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.280 loncom/interface/londocs.pm:1.281
--- loncom/interface/londocs.pm:1.280 Fri Jun 29 17:08:07 2007
+++ loncom/interface/londocs.pm Fri Jun 29 19:25:30 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.280 2007/06/29 21:08:07 albertel Exp $
+# $Id: londocs.pm,v 1.281 2007/06/29 23:25:30 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -958,12 +958,6 @@
my $folderpath;
my $cpinfo='';
my $plain='';
- if ($env{'form.markedcopy_url'}) {
- $cpinfo='&markedcopy_url='.
- &escape($env{'form.markedcopy_url'}).
- '&markedcopy_title='.
- &escape($env{'form.markedcopy_title'});
- }
my $randompick=-1;
my $isencrypted=0;
my $ishidden=0;
@@ -1187,28 +1181,77 @@
$r->print(&Apache::loncommon::end_data_table());
}
+sub update_paste_buffer {
+ my ($coursenum,$coursedom) = @_;
+
+ return if (!defined($env{'form.markcopy'}));
+ return if (!defined($env{'form.copyfolder'}));
+ return if ($env{'form.markcopy'} < 0);
+
+ my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
+ $env{'form.copyfolder'});
+
+ return if ($fatal);
+
+# Mark for copying
+ my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
+ if (&is_supplemental_title($title)) {
+ ($title) = &parse_supplemental_title($title);
+ }
+ &Apache::lonnet::appenv('docs.markedcopy_title' => $title,
+ 'docs.markedcopy_url' => $url);
+ delete($env{'form.markcopy'});
+}
+
+sub print_paste_buffer {
+ my ($r,$container) = @_;
+ return if (!defined($env{'docs.markedcopy_url'}));
+
+ $r->print(<<ENDPASTE);
+<p><form name="pasteform" action="/adm/coursedocs" method="post">
+ENDPASTE
+ $r->print('<input type="submit" name="pastemarked" value="'.&mt('Paste').'" /> ');
+
+ my $type;
+ if ($env{'docs.markedcopy_url'} =~ m{^/adm/wrapper/ext}) {
+ $type = &mt('External Resource');
+ $r->print($type.': '.&Apache::map::qtescape($env{'docs.markedcopy_title'}));
+ } else {
+ my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
+ my $type = &Apache::loncommon::filedescription($extension);
+ my $icon = '<img src="'.&Apache::loncommon::icon($extension).
+ '" class="LC_icon" />';
+ $r->print($icon.$type.': '. &parse_supplemental_title($env{'docs.markedcopy_title'}));
+ }
+ if ($container eq 'page') {
+ $r->print(<<PAGEINFO);
+ <input type="hidden" name="pagepath" value="$env{'form.pagepath'}" />
+ <input type="hidden" name="pagesymb" value="$env{'form.pagesymb'}" />
+PAGEINFO
+ } else {
+ $r->print(<<FOLDERINFO);
+ <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
+FOLDERINFO
+ }
+ $r->print('</form></p>');
+}
+
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) {
@@ -1297,11 +1340,11 @@
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=$env{'docs.markedcopy_url'};
+ my $title=$env{'docs.markedcopy_title'};
# Maps need to be copied first
if (($url=~/\.(page|sequence)$/) || ($url=~/^\/uploaded\//)) {
$title=&mt('Copy of').' '.$title;
@@ -1429,7 +1472,7 @@
}
}
&log_differences($plain);
- }
+ }
# ---------------------------------------------------------------- End commands
# ---------------------------------------------------------------- Print screen
my $idx=0;
@@ -1460,37 +1503,9 @@
$r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
}
$r->print("\n</table>\n");
- if ($env{'form.markedcopy_url'}) {
- $r->print(<<ENDPASTE);
-<p><form name="pasteform" action="/adm/coursedocs" method="post">
-<input type="hidden" name="markedcopy_url" value="$env{'form.markedcopy_url'}" />
-<input type="hidden" name="markedcopy_title" value="$env{'form.markedcopy_title'}" />
-ENDPASTE
- $r->print('<input type="submit" name="pastemarked" value="'.&mt('Paste').'" /> ');
- my $type;
- if ($env{'form.markedcopy_url'} =~ m{^/adm/wrapper/ext}) {
- $type = &mt('External Resource');
- $r->print($type.': '. $env{'form.markedcopy_title'});
- } else {
- my $extension = (split(/\./,$env{'form.markedcopy_url'}))[-1];
- my $type = &Apache::loncommon::filedescription($extension);
- my $icon = '<img src="'.&Apache::loncommon::icon($extension).
- '" class="LC_icon" />';
- $r->print($icon.$type.': '. $env{'form.markedcopy_title'});
- }
- if ($container eq 'page') {
- $r->print(<<PAGEINFO);
-<input type="hidden" name="pagepath" value="$env{'form.pagepath'}" />
-<input type="hidden" name="pagesymb" value="$env{'form.pagesymb'}" />
-PAGEINFO
- } else {
- $r->print(<<FOLDERINFO);
-<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
-FOLDERINFO
- }
- $r->print('</form></p>');
- }
+ &print_paste_buffer($r,$container);
+
}
}
@@ -1650,22 +1665,52 @@
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='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '.
+ $name.': <br />'.$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='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '.
- &Apache::loncommon::plainname($2,$3).': <br />'.
- $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;
my $line='<tr>';
@@ -1684,12 +1729,6 @@
$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='';
@@ -1740,13 +1779,13 @@
if (!$nocopy) {
$copylink=(<<ENDCOPY);
-<a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb");'>
+<a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");'>
<font size="-2" color="#000099">$lt{'cp'}</font></a>
ENDCOPY
}
if (!$nocut) {
$cutlink=(<<ENDCUT);
-<a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb");'>
+<a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder");'>
<font size="-2" color="#550044">$lt{'ct'}</font></a>
ENDCUT
}
@@ -1754,8 +1793,6 @@
<form name="entry_$index" action="/adm/coursedocs" method="post">
<input type="hidden" name="${type}path" value="$path" />
<input type="hidden" name="${type}symb" value="$symb" />
- <input type="hidden" name="markedcopy_url" value="$env{'form.markedcopy_url'}" />
- <input type="hidden" name="markedcopy_title" value="$env{'form.markedcopy_title'}" />
<input type="hidden" name="setparms" value="$orderidx" />
<input type="hidden" name="changeparms" value="0" />
<td>
@@ -2443,8 +2480,7 @@
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));
@@ -2619,6 +2655,7 @@
);
# -----------------------------------------------------------------------------
if ($allowed) {
+ &update_paste_buffer($coursenum,$coursedom);
my $dumpbut=&dumpbutton();
my $exportbut=&exportbutton();
my %lt=&Apache::lonlocal::texthash(
@@ -2646,6 +2683,7 @@
<input type="hidden" name="title" />
<input type="hidden" name="cmd" />
<input type="hidden" name="markcopy" />
+<input type="hidden" name="copyfolder" />
$containertag
</form>
<form name="simpleedit" method="post" action="/adm/coursedocs">
@@ -3130,6 +3168,7 @@
function changename(folderpath,index,oldtitle,container,pagesymb) {
var title=prompt('New Title',oldtitle);
if (title) {
+ this.document.forms.renameform.markcopy.value=-1;
this.document.forms.renameform.title.value=title;
this.document.forms.renameform.cmd.value='rename_'+index;
if (container == 'sequence') {
@@ -3145,6 +3184,7 @@
function removeres(folderpath,index,oldtitle,container,pagesymb) {
if (confirm('WARNING: Removing a resource makes associated grades and scores inaccessible!\\nRemove "'+oldtitle+'"?')) {
+ this.document.forms.renameform.markcopy.value=-1;
this.document.forms.renameform.cmd.value='del_'+index;
if (container == 'sequence') {
this.document.forms.renameform.folderpath.value=folderpath;
@@ -3157,10 +3197,11 @@
}
}
-function cutres(folderpath,index,oldtitle,container,pagesymb) {
+function cutres(folderpath,index,oldtitle,container,pagesymb,folder) {
if (confirm('WARNING: Cutting a resource makes associated grades and scores inaccessible!\\nGrades remain inaccessible if resource is pasted into another folder.\\nCut "'+oldtitle+'"?')) {
this.document.forms.renameform.cmd.value='cut_'+index;
this.document.forms.renameform.markcopy.value=index;
+ this.document.forms.renameform.copyfolder.value=folder+'.'+container;
if (container == 'sequence') {
this.document.forms.renameform.folderpath.value=folderpath;
}
@@ -3172,8 +3213,9 @@
}
}
-function markcopy(folderpath,index,oldtitle,container,pagesymb) {
+function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) {
this.document.forms.renameform.markcopy.value=index;
+ this.document.forms.renameform.copyfolder.value=folder+'.'+container;
if (container == 'sequence') {
this.document.forms.renameform.folderpath.value=folderpath;
}
--albertel1183159532--