[LON-CAPA-cvs] cvs: loncom /interface londocs.pm
www
lon-capa-cvs@mail.lon-capa.org
Mon, 21 Feb 2005 00:32:46 -0000
This is a MIME encoded message
--www1108945966
Content-Type: text/plain
www Sun Feb 20 19:32:46 2005 EDT
Modified files:
/loncom/interface londocs.pm
Log:
* single item in folder is not number 2 anymore
* copy/paste for resources and folders
--www1108945966
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20050220193246.txt"
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.167 loncom/interface/londocs.pm:1.168
--- loncom/interface/londocs.pm:1.167 Thu Feb 17 03:29:42 2005
+++ loncom/interface/londocs.pm Sun Feb 20 19:32:45 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.167 2005/02/17 08:29:42 albertel Exp $
+# $Id: londocs.pm,v 1.168 2005/02/21 00:32:45 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -895,6 +895,14 @@
@folders=split('&',$ENV{'form.folderpath'});
}
my $folderpath;
+ my $cpinfo='';
+ if ($ENV{'form.markedcopy_url'}) {
+ &Apache::lonnet::logthis('Found '.$ENV{'form.markedcopy_url'});
+ $cpinfo='&markedcopy_url='.
+ &Apache::lonnet::escape($ENV{'form.markedcopy_url'}).
+ '&markedcopy_title='.
+ &Apache::lonnet::escape($ENV{'form.markedcopy_title'});
+ }
while (@folders) {
my $folder=shift(@folders);
my $foldername=shift(@folders);
@@ -903,7 +911,7 @@
my $url='/adm/coursedocs?folderpath='.
&Apache::lonnet::escape($folderpath);
&Apache::lonhtmlcommon::add_breadcrumb(
- {'href'=>$url,
+ {'href'=>$url.$cpinfo,
'title'=>&Apache::lonnet::unescape($foldername),
'text'=>'<font size="+1">'.
&Apache::lonnet::unescape($foldername).'</font>'
@@ -917,8 +925,6 @@
sub editor {
my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
-
- $r->print(&breadcrumbs($folder));
my $errtext='';
my $fatal=0;
my $container='sequence';
@@ -931,6 +937,13 @@
$Apache::lonratedt::order[0]=1;
$Apache::lonratedt::resources[1]='';
}
+ if (defined($ENV{'form.markcopy'})) {
+# Mark for copying
+ my ($title,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$ENV{'form.markcopy'}]]);
+ $ENV{'form.markedcopy_title'}=$title;
+ $ENV{'form.markedcopy_url'}=$url;
+ }
+ $r->print(&breadcrumbs($folder));
if ($fatal) {
$r->print('<p><font color="red">'.$errtext.'</font></p>');
} else {
@@ -1001,7 +1014,42 @@
}
}
+ if ($ENV{'form.pastemarked'}) {
+# paste resource to end of list
+ my $url=$ENV{'form.markedcopy_url'};
+ my $title=$ENV{'form.markedcopy_title'};
+# Maps need to be copied first
+ if (($url=~/\.(page|sequence)$/) || ($url=~/^\/uploaded\//)) {
+ $title=&mt('Copy of').' '.$title;
+ my $newid=$$.time;
+ $url=~/^(.+)\.(\w+)$/;
+ my $newurl=$1.$newid.'.'.$2;
+ my $storefn=$newurl;
+ $storefn=~s/^\/\w+\/\w+\/\w+\///;
+ &Apache::loncreatecourse::writefile
+ ($ENV{'request.course.id'},$storefn,
+ &Apache::lonnet::getfile($url));
+ $url=$newurl;
+ }
+ $title=~s/\</\<\;/g;
+ $title=~s/\>/\>\;/g;
+ $title=~s/\:/\:/g;
+ my $ext='false';
+ if ($url=~/^http\:\/\//) { $ext='true'; }
+ $url=~s/\:/\:/g;
+# Now insert the URL at the bottom
+ my $newidx=1+$#Apache::lonratedt::resources;
+ $Apache::lonratedt::resources[$newidx]=
+ $title.':'.$url.':'.$ext.':normal:res';
+ $Apache::lonratedt::order[1+$#Apache::lonratedt::order]=$newidx;
+# Store the result
+ ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
+ if ($fatal) {
+ $r->print('<p><font color="red">'.$errtext.'</font></p>');
+ return;
+ }
+ }
# upload a file, if present
if (($ENV{'form.uploaddoc.filename'}) &&
($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
@@ -1137,7 +1185,30 @@
unless ($shown) {
$r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
}
- $r->print('</table>');
+ $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').
+ '" /> '.&Apache::loncommon::filedescription(
+ (split(/\./,$ENV{'form.markedcopy_url'}))[-1]).': '.
+ $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>');
+ }
}
}
@@ -1175,10 +1246,24 @@
$pagepath=&Apache::lonnet::escape($ENV{'form.pagepath'});
$pagesymb=&Apache::lonnet::escape($ENV{'form.pagesymb'});
}
+ my $cpinfo='';
+ if ($ENV{'form.markedcopy_url'}) {
+ $cpinfo='&markedcopy_url='.
+ &Apache::lonnet::escape($ENV{'form.markedcopy_url'}).
+ '&markedcopy_title='.
+ &Apache::lonnet::escape($ENV{'form.markedcopy_title'});
+ }
if ($allowed) {
my $incindex=$index+1;
my $selectbox='';
- if ($folder!~/^supplemental/) {
+ if (($folder!~/^supplemental/) &&
+ ($#Apache::lonratedt::order>0) &&
+ ((split(/\:/,
+ $Apache::lonratedt::resources[$Apache::lonratedt::order[0]]))[1]
+ ne '') &&
+ ((split(/\:/,
+ $Apache::lonratedt::resources[$Apache::lonratedt::order[1]]))[1]
+ ne '')) {
$selectbox=
'<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
'<select name="newpos" onChange="this.form.submit()">';
@@ -1195,19 +1280,22 @@
'up' => 'Move Up',
'dw' => 'Move Down',
'rm' => 'Remove',
- 'rn' => 'Rename');
+ 'rn' => 'Rename',
+ 'cp' => 'Copy');
if ($ENV{'form.pagepath'}) {
$line.=(<<END);
<form name="entry_$index" action="/adm/coursedocs" method="post">
<input type="hidden" name="pagepath" value="$ENV{'form.pagepath'}" />
<input type="hidden" name="pagesymb" value="$ENV{'form.pagesymb'}" />
+<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" />
<td><table border='0' cellspacing='2' cellpadding='0'>
<tr><td bgcolor="#DDDDDD">
-<a href='/adm/coursedocs?cmd=up_$index&pagepath=$pagepath&pagesymb=$pagesymb'>
+<a href='/adm/coursedocs?cmd=up_$index&pagepath=$pagepath&pagesymb=$pagesymb$cpinfo'>
<img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
<tr><td bgcolor="#DDDDDD">
-<a href='/adm/coursedocs?cmd=down_$index&pagepath=$pagepath&pagesymb=$pagesymb'>
+<a href='/adm/coursedocs?cmd=down_$index&pagepath=$pagepath&pagesymb=$pagesymb$cpinfo'>
<img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
</table></td>
<td>$selectbox
@@ -1215,19 +1303,23 @@
<a href='javascript:removeres("$pagepath","$index","$renametitle","page","$pagesymb");'>
<font size="-2" color="#990000">$lt{'rm'}</font></a>
<a href='javascript:changename("$pagepath","$index","$renametitle","page","$pagesymb");'>
-<font size="-2" color="#009900">$lt{'rn'}</font></a></td>
+<font size="-2" color="#009900">$lt{'rn'}</font></a>
+<a href='javascript:markcopy("$pagepath","$index","$renametitle","page","$pagesymb");'>
+<font size="-2" color="#000099">$lt{'cp'}</font></a></td>
END
} else {
$line.=(<<END);
<form name="entry_$index" action="/adm/coursedocs" method="post">
<input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
+<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" />
<td><table border='0' cellspacing='2' cellpadding='0'>
<tr><td bgcolor="#DDDDDD">
-<a href='/adm/coursedocs?cmd=up_$index&folderpath=$folderpath'>
+<a href='/adm/coursedocs?cmd=up_$index&folderpath=$folderpath$cpinfo'>
<img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
<tr><td bgcolor="#DDDDDD">
-<a href='/adm/coursedocs?cmd=down_$index&folderpath=$folderpath'>
+<a href='/adm/coursedocs?cmd=down_$index&folderpath=$folderpath$cpinfo'>
<img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
</table></td>
<td>$selectbox
@@ -1235,7 +1327,9 @@
<a href='javascript:removeres("$folderpath","$index","$renametitle","sequence");'>
<font size="-2" color="#990000">$lt{'rm'}</font></a>
<a href='javascript:changename("$folderpath","$index","$renametitle","sequence");'>
-<font size="-2" color="#009900">$lt{'rn'}</font></a></td>
+<font size="-2" color="#009900">$lt{'rn'}</font></a>
+<a href='javascript:markcopy("$folderpath","$index","$renametitle","sequence");'>
+<font size="-2" color="#000099">$lt{'cp'}</font></a></td>
END
}
}
@@ -1303,7 +1397,7 @@
my $folderpath=$ENV{'form.folderpath'};
if ($folderpath) { $folderpath.='&' };
$folderpath.=$folderarg.'&'.$foldername;
- $url.='folderpath='.&Apache::lonnet::escape($folderpath);
+ $url.='folderpath='.&Apache::lonnet::escape($folderpath).$cpinfo;
$parameterset='<label>'.&mt('Randomly Pick: ').
'<input type="text" size="4" onChange="this.form.submit()" name="randpick_'.$orderidx.'" value="'.
(&Apache::lonratedt::getparameter($orderidx,
@@ -1328,7 +1422,7 @@
$path.$pagearg.'.page');
}
$url.='pagepath='.&Apache::lonnet::escape($pagepath).
- '&pagesymb='.&Apache::lonnet::escape($symb);
+ '&pagesymb='.&Apache::lonnet::escape($symb).$cpinfo;
}
$line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon.
'" border="0"></a></td>'.
@@ -1826,7 +1920,7 @@
my $containertag;
my $uploadtag;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['folderpath','pagepath','pagesymb']);
+ ['folderpath','pagepath','pagesymb','markedcopy_url','markedcopy_title']);
if ($ENV{'form.folderpath'}) {
my (@folderpath)=split('&',$ENV{'form.folderpath'});
$ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));
@@ -2017,6 +2111,18 @@
}
}
+function markcopy(folderpath,index,oldtitle,container,pagesymb) {
+ this.document.forms.renameform.markcopy.value=index;
+ if (container == 'sequence') {
+ this.document.forms.renameform.folderpath.value=folderpath;
+ }
+ if (container == 'page') {
+ this.document.forms.renameform.pagepath.value=folderpath;
+ this.document.forms.renameform.pagesymb.value=pagesymb;
+ }
+ this.document.forms.renameform.submit();
+}
+
</script>
ENDNEWSCRIPT
@@ -2031,7 +2137,9 @@
my %lt=&Apache::lonlocal::texthash(
'uplm' => 'Upload a new main course document',
'upls' => 'Upload a new supplemental course document',
- 'impp' => 'Import a published document',
+ 'impp' => 'Import a document',
+ 'pubd' => 'Published documents',
+ 'copm' => 'All documents out of a published map',
'spec' => 'Special documents',
'upld' => 'Upload Document',
'srch' => 'Search',
@@ -2080,6 +2188,7 @@
<form name="renameform" method="post" action="/adm/coursedocs">
<input type="hidden" name="title" />
<input type="hidden" name="cmd" />
+<input type="hidden" name="markcopy" />
$containertag
</form>
<form name="simpleedit" method="post" action="/adm/coursedocs">
@@ -2151,6 +2260,7 @@
</td>
<td bgcolor="#DDDDDD">
<form action="/adm/coursedocs" method="post" name="simpleeditdefault">
+$lt{'pubd'}<br />
$uploadtag
<input type=button onClick="javascript:groupsearch()" value="$lt{'srch'}">
<nobr>
@@ -2159,6 +2269,7 @@
</nobr>
<p>
<hr />
+$lt{'copm'}
<input type="text" size="20" name="importmap"><br />
<nobr><input type=button
onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
@@ -2166,10 +2277,27 @@
$help{'Load_Map'}</nobr>
</p>
</form>
-</td>
-<td bgcolor="#DDDDDD">
ENDFORM
unless ($ENV{'form.pagepath'}) {
+ $r->print(<<ENDFORM);
+<hr />
+<form action="/adm/coursedocs" method="post" name="newext">
+$uploadtag
+<input type=hidden name="importdetail" value="">
+<nobr>
+<input name="newext" type="button" onClick="javascript:makenewext('newext');"
+value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
+</nobr>
+</form>
+<form action="/adm/imsimportdocs" method="post" name="ims">
+<input type="hidden" name="folder" value="$folder" />
+<input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
+</nobr>
+</form>
+ENDFORM
+ }
+ $r->print('</td><td bgcolor="#DDDDDD">');
+ unless ($ENV{'form.pagepath'}) {
$r->print(<<ENDFORM);
<form action="/adm/coursedocs" method="post" name="newfolder">
<input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
@@ -2189,14 +2317,6 @@
value="$lt{'newp'}" />$help{'Adding_Pages'}
</nobr>
</form>
-<form action="/adm/coursedocs" method="post" name="newext">
-$uploadtag
-<input type=hidden name="importdetail" value="">
-<nobr>
-<input name="newext" type="button" onClick="javascript:makenewext('newext');"
-value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
-</nobr>
-</form>
<form action="/adm/coursedocs" method="post" name="newsyl">
$uploadtag
<input type=hidden name="importdetail"
@@ -2285,17 +2405,8 @@
onClick="javascript:makeexamupload();" />
$help{'Score_Upload_Form'}
</nobr>
-</form>
ENDBLOCK
- } else {
- $r->print(<<ENDFORM);
-</form>
-<form action="/adm/imsimportdocs" method="post" name="ims">
-<input type="hidden" name="folder" value="$folder" />
-<input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
-</nobr>
-</form>
-ENDFORM
+ $r->print('</form>');
}
$r->print('</td></tr>'."\n".
'</table>');
--www1108945966--