File:
[LON-CAPA] /
loncom /
interface /
londocs.pm
Revision
1.309:
download - view:
text,
annotated -
select for diffs
Thu Sep 4 17:07:28 2008 UTC (15 years, 11 months ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
- Bug 5781.
- $env{'form.folderpath'} now set for users viewing Top level of Supplemental Documents.
- For users without edit privs who previously accessed Supplemental Docs folders below the top level, and as a result have incomplete $env{'form.folderpath'} stored for the course in environment.db, prepend the folder and title for the top level.
- Set text in breadcrumbs for top level folder in Supplemental Docs to "Course Documents" for users without edit privs, for consistency with the rest of the interface.
1: # The LearningOnline Network
2: # Documents
3: #
4: # $Id: londocs.pm,v 1.309 2008/09/04 17:07:28 raeburn Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::londocs;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use Apache::imsexport;
34: use Apache::lonnet;
35: use Apache::loncommon;
36: use LONCAPA::map();
37: use Apache::lonratedt();
38: use Apache::lonxml;
39: use Apache::lonclonecourse;
40: use Apache::lonnavmaps;
41: use HTML::Entities;
42: use GDBM_File;
43: use Apache::lonlocal;
44: use Cwd;
45: use LONCAPA qw(:DEFAULT :match);
46:
47: my $iconpath;
48:
49: my %hash;
50:
51: my $hashtied;
52: my %alreadyseen=();
53:
54: my $hadchanges;
55:
56: # Available help topics
57:
58: my %help=();
59:
60: # Mapread read maps into LONCAPA::map:: global arrays
61: # @order and @resources, determines status
62: # sets @order - pointer to resources in right order
63: # sets @resources - array with the resources with correct idx
64: #
65:
66: sub mapread {
67: my ($coursenum,$coursedom,$map)=@_;
68: return
69: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
70: $map);
71: }
72:
73: sub storemap {
74: my ($coursenum,$coursedom,$map)=@_;
75: my ($outtext,$errtext)=
76: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
77: $map,1);
78: if ($errtext) { return ($errtext,2); }
79:
80: $hadchanges=1;
81: return ($errtext,0);
82: }
83:
84: # ----------------------------------------- Return hash with valid author names
85:
86: sub authorhosts {
87: my %outhash=();
88: my $home=0;
89: my $other=0;
90: foreach (keys %env) {
91: if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
92: my $role=$1;
93: my $realm=$2;
94: my ($start,$end)=split(/\./,$env{$_});
95: if (($start) && ($start>time)) { next; }
96: if (($end) && (time>$end)) { next; }
97: my $ca; my $cd;
98: if ($1 eq 'au') {
99: $ca=$env{'user.name'};
100: $cd=$env{'user.domain'};
101: } else {
102: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
103: }
104: my $allowed=0;
105: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
106: my @ids=&Apache::lonnet::current_machine_ids();
107: foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } }
108: if ($allowed) {
109: $home++;
110: $outhash{'home_'.$ca.'@'.$cd}=1;
111: } else {
112: $outhash{'otherhome_'.$ca.'@'.$cd}=$myhome;
113: $other++;
114: }
115: }
116: }
117: return ($home,$other,%outhash);
118: }
119: # ------------------------------------------------------ Generate "dump" button
120:
121: sub dumpbutton {
122: my ($home,$other,%outhash)=&authorhosts();
123: my $type = &Apache::loncommon::course_type();
124: if ($home+$other==0) { return ''; }
125: if ($home) {
126: return '<div>'.
127: '<input type="submit" name="dumpcourse" value="'.
128: &mt('Dump '.$type.' DOCS to Construction Space').'" />'.
129: &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs').
130: '</div>';
131: } else {
132: return '<div>'.
133: &mt('Dump '.$type.
134: ' DOCS to Construction Space: available on other servers').
135: '</div>';
136: }
137: }
138:
139: sub clean {
140: my ($title)=@_;
141: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
142: return $title;
143: }
144: # -------------------------------------------------------- Actually dump course
145:
146: sub dumpcourse {
147: my ($r) = @_;
148: my $type = &Apache::loncommon::course_type();
149: $r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space').
150: '<form name="dumpdoc" method="post">');
151: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$type.' DOCS to Construction Space'));
152: my ($home,$other,%outhash)=&authorhosts();
153: unless ($home) { return ''; }
154: my $origcrsid=$env{'request.course.id'};
155: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
156: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
157: # Do the dumping
158: unless ($outhash{'home_'.$env{'form.authorspace'}}) { return ''; }
159: my ($ca,$cd)=split(/\@/,$env{'form.authorspace'});
160: $r->print('<h3>'.&mt('Copying Files').'</h3>');
161: my $title=$env{'form.authorfolder'};
162: $title=&clean($title);
163: my %replacehash=();
164: foreach (keys %env) {
165: if ($_=~/^form\.namefor\_(.+)/) {
166: $replacehash{$1}=$env{$_};
167: }
168: }
169: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
170: $crs=~s/\_/\//g;
171: foreach (keys %replacehash) {
172: my $newfilename=$title.'/'.$replacehash{$_};
173: $newfilename=~s/\.(\w+)$//;
174: my $ext=$1;
175: $newfilename=&clean($newfilename);
176: $newfilename.='.'.$ext;
177: my @dirs=split(/\//,$newfilename);
178: my $path='/home/'.$ca.'/public_html';
179: my $makepath=$path;
180: my $fail=0;
181: for (my $i=0;$i<$#dirs;$i++) {
182: $makepath.='/'.$dirs[$i];
183: unless (-e $makepath) {
184: unless(mkdir($makepath,0777)) { $fail=1; }
185: }
186: }
187: $r->print('<br /><tt>'.$_.'</tt> => <tt>'.$newfilename.'</tt>: ');
188: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
189: if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
190: print $fh &Apache::lonclonecourse::rewritefile(
191: &Apache::lonclonecourse::readfile($env{'request.course.id'},$_),
192: (%replacehash,$crs => '')
193: );
194: } else {
195: print $fh
196: &Apache::lonclonecourse::readfile($env{'request.course.id'},$_);
197: }
198: $fh->close();
199: } else {
200: $fail=1;
201: }
202: if ($fail) {
203: $r->print('<span class="LC_error">'.&mt('fail').'</span>');
204: } else {
205: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
206: }
207: }
208: } else {
209: # Input form
210: unless ($home==1) {
211: $r->print(
212: '<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
213: }
214: foreach (sort keys %outhash) {
215: if ($_=~/^home_(.+)$/) {
216: if ($home==1) {
217: $r->print(
218: '<input type="hidden" name="authorspace" value="'.$1.'" />');
219: } else {
220: $r->print('<option value="'.$1.'">'.$1.' - '.
221: &Apache::loncommon::plainname(split(/\@/,$1)).'</option>');
222: }
223: }
224: }
225: unless ($home==1) {
226: $r->print('</select>');
227: }
228: my $title=$origcrsdata{'description'};
229: $title=~s/[\/\s]+/\_/gs;
230: $title=&clean($title);
231: $r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
232: &tiehash();
233: $r->print('<h3>'.&mt('Filenames in Construction Space').'</h3><table border="2"><tr><th>'.&mt('Internal Filename').'</th><th>'.&mt('Title').'</th><th>'.&mt('Save as ...').'</th></tr>');
234: foreach (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
235: $r->print('<tr><td>'.$_.'</td>');
236: my ($ext)=($_=~/\.(\w+)$/);
237: my $title=$hash{'title_'.$hash{
238: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
239: $r->print('<td>'.($title?$title:' ').'</td>');
240: if (!$title) {
241: $title=$_;
242: } else {
243: $title=~s|/|_|g;
244: }
245: $title=~s/\.(\w+)$//;
246: $title=&clean($title);
247: $title.='.'.$ext;
248: $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
249: }
250: $r->print("</table>\n");
251: &untiehash();
252: $r->print(
253: '<p><input type="submit" name="dumpcourse" value="'.&mt('Dump [_1] DOCS',$type).'" /></p></form>');
254: }
255: }
256:
257: # ------------------------------------------------------ Generate "export" button
258:
259: sub exportbutton {
260: my $type = &Apache::loncommon::course_type();
261: return '<div>'.
262: '<input type="submit" name="exportcourse" value="'.
263: &mt('Export '.$type.' to IMS').'" />'.
264: &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'</div>';
265: }
266:
267: sub exportcourse {
268: my $r=shift;
269: my $type = &Apache::loncommon::course_type();
270: my %discussiontime = &Apache::lonnet::dump('discussiontimes',
271: $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
272: my $numdisc = keys %discussiontime;
273: my $navmap = Apache::lonnavmaps::navmap->new();
274: my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
275: my $curRes;
276: my $outcome;
277:
278: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
279: ['finishexport']);
280: if ($env{'form.finishexport'}) {
281: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
282: ['archive','discussion']);
283:
284: my @exportitems = &Apache::loncommon::get_env_multiple('form.archive');
285: my @discussions = &Apache::loncommon::get_env_multiple('form.discussion');
286: if (@exportitems == 0 && @discussions == 0) {
287: $outcome = '<br />As you did not select any content items or discussions for export, an IMS package has not been created. Please <a href="javascript:history.go(-1)">go back</a> to select either content items or discussions for export';
288: } else {
289: my $now = time;
290: my %symbs;
291: my $manifestok = 0;
292: my $imsresources;
293: my $tempexport;
294: my $copyresult;
295: my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport);
296: if ($manifestok) {
297: &build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,$tempexport,\$copyresult,$ims_manifest);
298: close($ims_manifest);
299:
300: #Create zip file in prtspool
301: my $imszipfile = '/prtspool/'.
302: $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
303: time.'_'.rand(1000000000).'.zip';
304: my $cwd = &Cwd::getcwd();
305: my $imszip = '/home/httpd/'.$imszipfile;
306: chdir $tempexport;
307: open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
308: close(OUTPUT);
309: chdir $cwd;
310: $outcome .= &mt('Download the zip file from <a href="[_1]">IMS '.lc($type).' archive</a><br />',$imszipfile,);
311: if ($copyresult) {
312: $outcome .= 'The following errors occurred during export - '.$copyresult;
313: }
314: } else {
315: $outcome = '<br />Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.<br />';
316: }
317: }
318: $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'));
319: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
320: $r->print($outcome);
321: $r->print(&Apache::loncommon::end_page());
322: } else {
323: my $display;
324: $display = '<form name="exportdoc" method="post">'."\n";
325: $display .= &mt('Choose which items you wish to export from your '.$type.'.<br /><br />');
326: $display .= '<table border="0" cellspacing="0" cellpadding="3">'.
327: '<tr><td><fieldset><legend> <b>Content items</b></legend>'.
328: '<input type="button" value="check all" '.
329: 'onclick="javascript:checkAll(document.exportdoc.archive)" />'.
330: ' <input type="button" value="uncheck all"'.
331: ' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset></td>'.
332: '<td> </td><td> </td>'.
333: '<td align="right"><fieldset><legend> <b>Discussion posts'.
334: '</b></legend><input type="button" value="check all"'.
335: ' onclick="javascript:checkAll(document.exportdoc.discussion)" />'.
336: ' <input type="button" value="uncheck all"'.
337: ' onclick="javascript:uncheckAll(document.exportdoc.discussion)" /></fieldset></td>'.
338: '</tr></table>';
339: my $curRes;
340: my $depth = 0;
341: my $count = 0;
342: my $boards = 0;
343: my $startcount = 5;
344: my %parent = ();
345: my %children = ();
346: my $lastcontainer = $startcount;
347: my @bgcolors = ('#F6F6F6','#FFFFFF');
348: $display .= '<table cellspacing="0"><tr>'.
349: '<td><b>Export content item?<br /></b></td><td> </td><td align="right">'."\n";
350: if ($numdisc > 0) {
351: $display.='<b>Export discussion posts?</b>'."\n";
352: }
353: $display.=' </td></tr>';
354: while ($curRes = $it->next()) {
355: if (ref($curRes)) {
356: $count ++;
357: }
358: if ($curRes == $it->BEGIN_MAP()) {
359: $depth++;
360: $parent{$depth} = $lastcontainer;
361: }
362: if ($curRes == $it->END_MAP()) {
363: $depth--;
364: $lastcontainer = $parent{$depth};
365: }
366: if (ref($curRes)) {
367: my $symb = $curRes->symb();
368: my $ressymb = $symb;
369: if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
370: unless ($ressymb =~ m|adm/wrapper/adm|) {
371: $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
372: }
373: }
374: my $color = $count%2;
375: $display .='<tr bgcolor='.$bgcolors[$color].'><td>'."\n".
376: '<input type="checkbox" name="archive" value="'.$count.'" ';
377: if (($curRes->is_sequence()) || ($curRes->is_page())) {
378: my $checkitem = $count + $boards + $startcount;
379: $display .= 'onClick="javascript:propagateCheck('."'$checkitem'".')"';
380: }
381: $display .= ' />'."\n";
382: for (my $i=0; $i<$depth; $i++) {
383: $display .= '<img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" /><img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" />'."\n";
384: }
385: if ($curRes->is_sequence()) {
386: $display .= '<img src="/adm/lonIcons/navmap.folder.open.gif"> '."\n";
387: $lastcontainer = $count + $startcount + $boards;
388: } elsif ($curRes->is_page()) {
389: $display .= '<img src="/adm/lonIcons/navmap.page.open.gif"> '."\n";
390: $lastcontainer = $count + $startcount + $boards;
391: }
392: my $currelem = $count+$boards+$startcount;
393: $children{$parent{$depth}} .= $currelem.':';
394: $display .= ' '.$curRes->title().'</td>';
395: if ($discussiontime{$ressymb} > 0) {
396: $boards ++;
397: $currelem = $count+$boards+$startcount;
398: $display .= '<td> </td><td align="right"><input type="checkbox" name="discussion" value="'.$count.'" /> </td>'."\n";
399: } else {
400: $display .= '<td colspan="2"> </td>'."\n";
401: }
402: }
403: }
404: my $scripttag = qq|
405: <script>
406:
407: function checkAll(field) {
408: if (field.length > 0) {
409: for (i = 0; i < field.length; i++) {
410: field[i].checked = true ;
411: }
412: } else {
413: field.checked = true
414: }
415: }
416:
417: function uncheckAll(field) {
418: if (field.length > 0) {
419: for (i = 0; i < field.length; i++) {
420: field[i].checked = false ;
421: }
422: } else {
423: field.checked = false ;
424: }
425: }
426:
427: function propagateCheck(item) {
428: if (document.exportdoc.elements[item].checked == true) {
429: containerCheck(item)
430: }
431: }
432:
433: function containerCheck(item) {
434: document.exportdoc.elements[item].checked = true
435: var numitems = $count + $boards + $startcount
436: var parents = new Array(numitems)
437: for (var i=$startcount; i<numitems; i++) {
438: parents[i] = new Array
439: }
440: |;
441:
442: foreach my $container (sort { $a <=> $b } keys %children) {
443: my @contents = split/:/,$children{$container};
444: for (my $i=0; $i<@contents; $i ++) {
445: $scripttag .= ' parents['.$container.']['.$i.'] = '.$contents[$i]."\n";
446: }
447: }
448:
449: $scripttag .= qq|
450: if (parents[item].length > 0) {
451: for (var j=0; j<parents[item].length; j++) {
452: containerCheck(parents[item][j])
453: }
454: }
455: }
456:
457: </script>
458: |;
459: $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package',
460: $scripttag));
461: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
462: $r->print($display.'</table>'.
463: '<p><input type="hidden" name="finishexport" value="1">'.
464: '<input type="submit" name="exportcourse" value="'.
465: &mt('Export '.$type.' DOCS').'" /></p></form>'.
466: &Apache::loncommon::end_page());
467: }
468: }
469:
470: sub create_ims_store {
471: my ($now,$manifestok,$outcome,$tempexport) = @_;
472: $$tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports';
473: my $ims_manifest;
474: if (!-e $$tempexport) {
475: mkdir($$tempexport,0700);
476: }
477: $$tempexport .= '/'.$now;
478: if (!-e $$tempexport) {
479: mkdir($$tempexport,0700);
480: }
481: $$tempexport .= '/'.$env{'user.domain'}.'_'.$env{'user.name'};
482: if (!-e $$tempexport) {
483: mkdir($$tempexport,0700);
484: }
485: if (!-e "$$tempexport/resources") {
486: mkdir("$$tempexport/resources",0700);
487: }
488: # open manifest file
489: my $manifest = '/imsmanifest.xml';
490: my $manifestfilename = $$tempexport.$manifest;
491: if ($ims_manifest = Apache::File->new('>'.$manifestfilename)) {
492: $$manifestok=1;
493: print $ims_manifest
494: '<?xml version="1.0" encoding="UTF-8"?>'."\n".
495: '<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"'.
496: ' xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"'.
497: ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'.
498: ' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'.
499: ' xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'.
500: ' http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n".
501: ' <metadata>
502: <schema></schema>
503: <imsmd:lom>
504: <imsmd:general>
505: <imsmd:identifier>'.$env{'request.course.id'}.'</imsmd:identifier>
506: <imsmd:title>
507: <imsmd:langstring xml:lang="en">'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</imsmd:langstring>
508: </imsmd:title>
509: </imsmd:general>
510: </imsmd:lom>
511: </metadata>'."\n".
512: ' <organizations default="ORG-'.$env{'request.course.id'}.'-'.$now.'">'."\n".
513: ' <organization identifier="ORG-'.$env{'request.course.id'}.'-'.$now.'"'.
514: ' structure="hierarchical">'."\n".
515: ' <title>'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</title>'
516: } else {
517: $$outcome .= 'An error occurred opening the IMS manifest file.<br />'
518: ;
519: }
520: return $ims_manifest;
521: }
522:
523: sub build_package {
524: my ($now,$navmap,$exportitems,$discussions,$outcome,$tempexport,$copyresult,$ims_manifest) = @_;
525: # first iterator to look for dependencies
526: my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
527: my $curRes;
528: my $count = 0;
529: my $depth = 0;
530: my $lastcontainer = 0;
531: my %parent = ();
532: my @dependencies = ();
533: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
534: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
535: while ($curRes = $it->next()) {
536: if (ref($curRes)) {
537: $count ++;
538: }
539: if ($curRes == $it->BEGIN_MAP()) {
540: $depth++;
541: $parent{$depth} = $lastcontainer;
542: }
543: if ($curRes == $it->END_MAP()) {
544: $depth--;
545: $lastcontainer = $parent{$depth};
546: }
547: if (ref($curRes)) {
548: if ($curRes->is_sequence() || $curRes->is_page()) {
549: $lastcontainer = $count;
550: }
551: if (grep/^$count$/,@$exportitems) {
552: &get_dependencies($exportitems,\%parent,$depth,\@dependencies);
553: }
554: }
555: }
556: # second iterator to build manifest and store resources
557: $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
558: $depth = 0;
559: my $prevdepth;
560: $count = 0;
561: my $imsresources;
562: my $pkgdepth;
563: while ($curRes = $it->next()) {
564: if ($curRes == $it->BEGIN_MAP()) {
565: $prevdepth = $depth;
566: $depth++;
567: }
568: if ($curRes == $it->END_MAP()) {
569: $prevdepth = $depth;
570: $depth--;
571: }
572:
573: if (ref($curRes)) {
574: $count ++;
575: if ((grep/^$count$/,@$exportitems) || (grep/^$count$/,@dependencies)) {
576: my $symb = $curRes->symb();
577: my $isvisible = 'true';
578: my $resourceref;
579: if ($curRes->randomout()) {
580: $isvisible = 'false';
581: }
582: unless ($curRes->is_sequence()) {
583: $resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"';
584: }
585: my $step = $prevdepth - $depth;
586: if (($step >= 0) && ($count > 1)) {
587: while ($step >= 0) {
588: print $ims_manifest "\n".' </item>'."\n";
589: $step --;
590: }
591: }
592: $prevdepth = $depth;
593:
594: my $itementry =
595: '<item identifier="ITEM-'.$env{'request.course.id'}.'-'.$count.
596: '" isvisible="'.$isvisible.'" '.$resourceref.'>'.
597: '<title>'.$curRes->title().'</title>';
598: print $ims_manifest "\n".$itementry;
599:
600: unless ($curRes->is_sequence()) {
601: my $content_file;
602: my @hrefs = ();
603: &process_content($count,$curRes,$cdom,$cnum,$symb,\$content_file,\@hrefs,$copyresult,$tempexport);
604: if ($content_file) {
605: $imsresources .= "\n".
606: ' <resource identifier="RES-'.$env{'request.course.id'}.'-'.$count.
607: '" type="webcontent" href="'.$content_file.'">'."\n".
608: ' <file href="'.$content_file.'" />'."\n";
609: foreach (@hrefs) {
610: $imsresources .=
611: ' <file href="'.$_.'" />'."\n";
612: }
613: if (grep/^$count$/,@$discussions) {
614: my $ressymb = $symb;
615: my $mode;
616: if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
617: unless ($ressymb =~ m|adm/wrapper/adm|) {
618: $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
619: }
620: $mode = 'board';
621: }
622: my %extras = (
623: caller => 'imsexport',
624: tempexport => $tempexport.'/resources',
625: count => $count
626: );
627: my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras);
628: }
629: $imsresources .= ' </resource>'."\n";
630: }
631: }
632: $pkgdepth = $depth;
633: }
634: }
635: }
636: while ($pkgdepth > 0) {
637: print $ims_manifest " </item>\n";
638: $pkgdepth --;
639: }
640: my $resource_text = qq|
641: </organization>
642: </organizations>
643: <resources>
644: $imsresources
645: </resources>
646: </manifest>
647: |;
648: print $ims_manifest $resource_text;
649: }
650:
651: sub get_dependencies {
652: my ($exportitems,$parent,$depth,$dependencies) = @_;
653: if ($depth > 1) {
654: if ((!grep/^$$parent{$depth}$/,@$exportitems) && (!grep/^$$parent{$depth}$/,@$dependencies)) {
655: push @$dependencies, $$parent{$depth};
656: if ($depth > 2) {
657: &get_dependencies($exportitems,$parent,$depth-1,$dependencies);
658: }
659: }
660: }
661: }
662:
663: sub process_content {
664: my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_;
665: my $content_type;
666: my $message;
667: my @uploads = ();
668: if ($curRes->is_sequence()) {
669: $content_type = 'sequence';
670: } elsif ($curRes->is_page()) {
671: $content_type = 'page'; # need to handle individual items in pages.
672: } elsif ($symb =~ m-public/$cdom/$cnum/syllabus$-) {
673: $content_type = 'syllabus';
674: my $contents = &Apache::imsexport::templatedpage($content_type);
675: if ($contents) {
676: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
677: }
678: } elsif ($symb =~ m-\.sequence___\d+___ext-) {
679: $content_type = 'external';
680: my $title = $curRes->title;
681: my $contents = &Apache::imsexport::external($symb,$title);
682: if ($contents) {
683: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
684: }
685: } elsif ($symb =~ m-adm/navmaps$-) {
686: $content_type = 'navmap';
687: } elsif ($symb =~ m-adm/[^/]+/[^/]+/(\d+)/smppg$-) {
688: $content_type = 'simplepage';
689: my $contents = &Apache::imsexport::templatedpage($content_type,$1,$count,\@uploads);
690: if ($contents) {
691: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
692: }
693: } elsif ($symb =~ m-lib/templates/simpleproblem\.problem$-) {
694: $content_type = 'simpleproblem';
695: my $contents = &Apache::imsexport::simpleproblem($symb);
696: if ($contents) {
697: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
698: }
699: } elsif ($symb =~ m-lib/templates/examupload\.problem$-) {
700: $content_type = 'examupload';
701: } elsif ($symb =~ m-adm/($match_domain)/($match_username)/(\d+)/bulletinboard$-) {
702: $content_type = 'bulletinboard';
703: my $contents = &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2);
704: if ($contents) {
705: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
706: }
707: } elsif ($symb =~ m-adm/([^/]+)/([^/]+)/aboutme$-) {
708: $content_type = 'aboutme';
709: my $contents = &Apache::imsexport::templatedpage($content_type,undef,$count,\@uploads,$1,$2);
710: if ($contents) {
711: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
712: }
713: } elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) {
714: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
715: } elsif ($symb =~ m-\.(sequence|page)___\d+___([^/]+)/([^/]+)-) {
716: my $canedit = 0;
717: if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'}) {
718: $canedit= 1;
719: }
720: # only include problem code where current user is author
721: if ($canedit) {
722: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource');
723: } else {
724: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit');
725: }
726: } elsif ($symb =~ m-uploaded/$cdom/$cnum-) {
727: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
728: }
729: if (@uploads > 0) {
730: foreach my $item (@uploads) {
731: my $uploadmsg = '';
732: &replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'templateupload');
733: if ($uploadmsg) {
734: $$copyresult .= $uploadmsg."\n";
735: }
736: }
737: }
738: if ($message) {
739: $$copyresult .= $message."\n";
740: }
741: }
742:
743: sub replicate_content {
744: my ($cdom,$cnum,$tempexport,$symb,$count,$message,$href,$caller) = @_;
745: my ($map,$ind,$url);
746: if ($caller eq 'templateupload') {
747: $url = $symb;
748: $url =~ s#//#/#g;
749: } else {
750: ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
751: }
752: my $content;
753: my $filename;
754: my $repstatus;
755: my $content_name;
756: if ($url =~ m-/([^/]+)$-) {
757: $filename = $1;
758: if (!-e $tempexport.'/resources') {
759: mkdir($tempexport.'/resources',0700);
760: }
761: if (!-e $tempexport.'/resources/'.$count) {
762: mkdir($tempexport.'/resources/'.$count,0700);
763: }
764: my $destination = $tempexport.'/resources/'.$count.'/'.$filename;
765: my $copiedfile;
766: if ($copiedfile = Apache::File->new('>'.$destination)) {
767: my $content;
768: if ($caller eq 'resource') {
769: my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';
770: my $filepath = &Apache::lonnet::filelocation($respath,$url);
771: $content = &Apache::lonnet::getfile($filepath);
772: if ($content eq -1) {
773: $$message = 'Could not copy file '.$filename;
774: } else {
775: &extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'resource');
776: $repstatus = 'ok';
777: }
778: } elsif ($caller eq 'uploaded' || $caller eq 'templateupload') {
779: my $rtncode;
780: $repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode);
781: if ($repstatus eq 'ok') {
782: if ($url =~ /\.html?$/i) {
783: &extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'uploaded');
784: }
785: } else {
786: $$message = 'Could not render '.$url.' server message - '.$rtncode."<br />\n";
787: }
788: } elsif ($caller eq 'noedit') {
789: # Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this.
790: $repstatus = 'ok';
791: $content = 'Not the owner of this resource';
792: }
793: if ($repstatus eq 'ok') {
794: print $copiedfile $content;
795: }
796: close($copiedfile);
797: } else {
798: $$message = 'Could not open destination file for '.$filename."<br />\n";
799: }
800: } else {
801: $$message = 'Could not determine name of file for '.$symb."<br />\n";
802: }
803: if ($repstatus eq 'ok') {
804: $content_name = 'resources/'.$count.'/'.$filename;
805: }
806: return $content_name;
807: }
808:
809: sub extract_media {
810: my ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_;
811: my ($dirpath,$container);
812: my %allfiles = ();
813: my %codebase = ();
814: if ($url =~ m-(.*/)([^/]+)$-) {
815: $dirpath = $1;
816: $container = $2;
817: } else {
818: $dirpath = $url;
819: $container = '';
820: }
821: &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,$content);
822: foreach my $embed_file (keys(%allfiles)) {
823: my $filename;
824: if ($embed_file =~ m#([^/]+)$#) {
825: $filename = $1;
826: } else {
827: $filename = $embed_file;
828: }
829: my $newname = 'res/'.$filename;
830: my ($rtncode,$embed_content,$repstatus);
831: my $embed_url;
832: if ($embed_file =~ m-^/-) {
833: $embed_url = $embed_file; # points to absolute path
834: } else {
835: if ($embed_file =~ m-https?://-) {
836: next; # points to url
837: } else {
838: $embed_url = $dirpath.$embed_file; # points to relative path
839: }
840: }
841: if ($caller eq 'resource') {
842: my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';
843: my $embed_path = &Apache::lonnet::filelocation($respath,$embed_url);
844: $embed_content = &Apache::lonnet::getfile($embed_path);
845: unless ($embed_content eq -1) {
846: $repstatus = 'ok';
847: }
848: } elsif ($caller eq 'uploaded') {
849:
850: $repstatus = &Apache::lonnet::getuploaded('GET',$embed_url,$cdom,$cnum,\$embed_content,$rtncode);
851: }
852: if ($repstatus eq 'ok') {
853: my $destination = $tempexport.'/resources/'.$count.'/res';
854: if (!-e "$destination") {
855: mkdir($destination,0755);
856: }
857: $destination .= '/'.$filename;
858: my $copiedfile;
859: if ($copiedfile = Apache::File->new('>'.$destination)) {
860: print $copiedfile $embed_content;
861: push @{$href}, 'resources/'.$count.'/res/'.$filename;
862: my $attrib_regexp = '';
863: if (@{$allfiles{$embed_file}} > 1) {
864: $attrib_regexp = join('|',@{$allfiles{$embed_file}});
865: } else {
866: $attrib_regexp = $allfiles{$embed_file}[0];
867: }
868: $$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$embed_file\E(['"]?)#$1$newname$2#gi;
869: if ($caller eq 'resource' && $container =~ /\.(problem|library)$/) {
870: $$content =~ s#\Q$embed_file\E#$newname#gi;
871: }
872: }
873: } else {
874: $$message .= 'replication of embedded file - '.$embed_file.' in '.$url.' failed, reason -'.$rtncode."<br />\n";
875: }
876: }
877: return;
878: }
879:
880: sub store_template {
881: my ($contents,$tempexport,$count,$content_type) = @_;
882: if ($contents) {
883: if ($tempexport) {
884: if (!-e $tempexport.'/resources') {
885: mkdir($tempexport.'/resources',0700);
886: }
887: if (!-e $tempexport.'/resources/'.$count) {
888: mkdir($tempexport.'/resources/'.$count,0700);
889: }
890: my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml';
891: my $storetemplate;
892: if ($storetemplate = Apache::File->new('>'.$destination)) {
893: print $storetemplate $contents;
894: close($storetemplate);
895: }
896: if ($content_type eq 'external') {
897: return 'resources/'.$count.'/'.$content_type.'.html';
898: } else {
899: return 'resources/'.$count.'/'.$content_type.'.xml';
900: }
901: }
902: }
903: }
904:
905: # Imports the given (name, url) resources into the course
906: # coursenum, coursedom, and folder must precede the list
907: sub group_import {
908: my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
909:
910: while (@files) {
911: my ($name, $url, $residx) = @{ shift(@files) };
912: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
913: && ($caller eq 'londocs')
914: && (!&Apache::lonnet::stat_file($url))) {
915:
916: my $errtext = '';
917: my $fatal = 0;
918: my $newmapstr = '<map>'."\n".
919: '<resource id="1" src="" type="start"></resource>'."\n".
920: '<link from="1" to="2" index="1"></link>'."\n".
921: '<resource id="2" src="" type="finish"></resource>'."\n".
922: '</map>';
923: $env{'form.output'}=$newmapstr;
924: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
925: 'output',$1.$2);
926: if ($result != m|^/uploaded/|) {
927: $errtext.='Map not saved: A network error occured when trying to save the new map. ';
928: $fatal = 2;
929: }
930: if ($fatal) {
931: return ($errtext,$fatal);
932: }
933: }
934: if ($url) {
935: if (!$residx
936: || defined($LONCAPA::map::zombies[$residx])) {
937: $residx = &LONCAPA::map::getresidx($url,$residx);
938: push(@LONCAPA::map::order, $residx);
939: }
940: my $ext = 'false';
941: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
942: $url = &LONCAPA::map::qtunescape($url);
943: $name = &LONCAPA::map::qtunescape($name);
944: $LONCAPA::map::resources[$residx] =
945: join(':', ($name, $url, $ext, 'normal', 'res'));
946: }
947: }
948: return &storemap($coursenum, $coursedom, $folder.'.'.$container);
949: }
950:
951: sub breadcrumbs {
952: my ($where,$allowed,$type)=@_;
953: &Apache::lonhtmlcommon::clear_breadcrumbs();
954: my (@folders);
955: if ($env{'form.pagepath'}) {
956: @folders = split('&',$env{'form.pagepath'});
957: } else {
958: @folders=split('&',$env{'form.folderpath'});
959: }
960: my $folderpath;
961: my $cpinfo='';
962: my $plain='';
963: my $randompick=-1;
964: my $isencrypted=0;
965: my $ishidden=0;
966: my $is_random_order=0;
967: while (@folders) {
968: my $folder=shift(@folders);
969: my $foldername=shift(@folders);
970: if ($folderpath) {$folderpath.='&';}
971: $folderpath.=$folder.'&'.$foldername;
972: my $url='/adm/coursedocs?folderpath='.
973: &escape($folderpath);
974: my $name=&unescape($foldername);
975: # randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername
976: $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;
977: if ($1 ne '') {
978: $randompick=$1;
979: } else {
980: $randompick=-1;
981: }
982: if ($2) { $ishidden=1; }
983: if ($3) { $isencrypted=1; }
984: if ($4 ne '') { $is_random_order = 1; }
985: if ($folder eq 'supplemental') {
986: if ($allowed) {
987: $name = &mt('Supplemental '.$type.' Documents');
988: } else {
989: $name = &mt($type.' Documents');
990: }
991: }
992: &Apache::lonhtmlcommon::add_breadcrumb(
993: {'href'=>$url.$cpinfo,
994: 'title'=>$name,
995: 'text'=>'<font size="+1">'.
996: $name.'</font>',
997: 'no_mt'=>1,
998: });
999: $plain.=$name.' > ';
1000: }
1001: $plain=~s/\>\;\s*$//;
1002: return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
1003: 'LC_docs_path'),$randompick,$ishidden,$isencrypted,$plain,$is_random_order);
1004: }
1005:
1006: sub log_docs {
1007: return &Apache::lonnet::instructor_log('docslog',@_);
1008: }
1009:
1010: {
1011: my @oldresources=();
1012: my @oldorder=();
1013: my $parmidx;
1014: my %parmaction=();
1015: my %parmvalue=();
1016: my $changedflag;
1017:
1018: sub snapshotbefore {
1019: @oldresources=@LONCAPA::map::resources;
1020: @oldorder=@LONCAPA::map::order;
1021: $parmidx=undef;
1022: %parmaction=();
1023: %parmvalue=();
1024: $changedflag=0;
1025: }
1026:
1027: sub remember_parms {
1028: my ($idx,$parameter,$action,$value)=@_;
1029: $parmidx=$idx;
1030: $parmaction{$parameter}=$action;
1031: $parmvalue{$parameter}=$value;
1032: $changedflag=1;
1033: }
1034:
1035: sub log_differences {
1036: my ($plain)=@_;
1037: my %storehash=('folder' => $plain,
1038: 'currentfolder' => $env{'form.folder'});
1039: if ($parmidx) {
1040: $storehash{'parameter_res'}=$oldresources[$parmidx];
1041: foreach my $parm (keys %parmaction) {
1042: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
1043: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
1044: }
1045: }
1046: my $maxidx=$#oldresources;
1047: if ($#LONCAPA::map::resources>$#oldresources) {
1048: $maxidx=$#LONCAPA::map::resources;
1049: }
1050: for (my $idx=0; $idx<=$maxidx; $idx++) {
1051: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
1052: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
1053: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
1054: $changedflag=1;
1055: }
1056: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
1057: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
1058: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
1059: $changedflag=1;
1060: }
1061: }
1062: $storehash{'maxidx'}=$maxidx;
1063: if ($changedflag) { &log_docs(\%storehash); }
1064: }
1065: }
1066:
1067:
1068: #
1069: # Docs Change Log
1070: #
1071: sub docs_change_log {
1072: my ($r)=@_;
1073: my $folder=$env{'form.folder'};
1074: $r->print(&Apache::loncommon::start_page('Course Document Change Log'));
1075: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log'));
1076: my %docslog=&Apache::lonnet::dump('nohist_docslog',
1077: $env{'course.'.$env{'request.course.id'}.'.domain'},
1078: $env{'course.'.$env{'request.course.id'}.'.num'});
1079:
1080: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
1081:
1082: $r->print('<form action="/adm/coursedocs" method="post" name="docslog">'.
1083: '<input type="hidden" name="docslog" value="1" />');
1084:
1085: my %saveable_parameters = ('show' => 'scalar',);
1086: &Apache::loncommon::store_course_settings('docs_log',
1087: \%saveable_parameters);
1088: &Apache::loncommon::restore_course_settings('docs_log',
1089: \%saveable_parameters);
1090: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1091: my %lt=('hiddenresource' => 'Resources hidden',
1092: 'encrypturl' => 'URL hidden',
1093: 'randompick' => 'Randomly pick',
1094: 'randomorder' => 'Randomly ordered',
1095: 'set' => 'set to',
1096: 'del' => 'deleted');
1097: $r->print(&Apache::loncommon::display_filter().
1098: '<input type="hidden" name="folder" value="'.$folder.'" />'.
1099: '<input type="submit" value="'.&mt('Display').'" /></form>');
1100: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1101: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
1102: &mt('After').'</th>'.
1103: &Apache::loncommon::end_data_table_header_row());
1104: my $shown=0;
1105: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
1106: if ($env{'form.displayfilter'} eq 'currentfolder') {
1107: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
1108: }
1109: my @changes=keys(%{$docslog{$id}{'logentry'}});
1110: if ($env{'form.displayfilter'} eq 'containing') {
1111: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
1112: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
1113: foreach my $key (@changes) {
1114: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
1115: }
1116: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1117: }
1118: my $count = 0;
1119: my $time =
1120: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
1121: my $plainname =
1122: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
1123: $docslog{$id}{'exe_udom'});
1124: my $about_me_link =
1125: &Apache::loncommon::aboutmewrapper($plainname,
1126: $docslog{$id}{'exe_uname'},
1127: $docslog{$id}{'exe_udom'});
1128: my $send_msg_link='';
1129: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
1130: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1131: $send_msg_link ='<br />'.
1132: &Apache::loncommon::messagewrapper(&mt('Send message'),
1133: $docslog{$id}{'exe_uname'},
1134: $docslog{$id}{'exe_udom'});
1135: }
1136: $r->print(&Apache::loncommon::start_data_table_row());
1137: $r->print('<td>'.$time.'</td>
1138: <td>'.$about_me_link.
1139: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
1140: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
1141: $send_msg_link.'</td><td>'.
1142: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1143: # Before
1144: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1145: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1146: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1147: if ($oldname ne $newname) {
1148: $r->print(&LONCAPA::map::qtescape($oldname));
1149: }
1150: }
1151: $r->print('<ul>');
1152: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1153: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1154: $r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]).'</li>');
1155: }
1156: }
1157: $r->print('</ul>');
1158: # After
1159: $r->print('</td><td>');
1160:
1161: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1162: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1163: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1164: if ($oldname ne '' && $oldname ne $newname) {
1165: $r->print(&LONCAPA::map::qtescape($newname));
1166: }
1167: }
1168: $r->print('<ul>');
1169: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1170: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1171: $r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]).'</li>');
1172: }
1173: }
1174: $r->print('</ul>');
1175: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
1176: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
1177: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
1178: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1179: $r->print('<li>'.
1180: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
1181: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
1182: .'</li>');
1183: }
1184: }
1185: $r->print('</ul>');
1186: }
1187: # End
1188: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1189: $shown++;
1190: if (!($env{'form.show'} eq &mt('all')
1191: || $shown<=$env{'form.show'})) { last; }
1192: }
1193: $r->print(&Apache::loncommon::end_data_table());
1194: }
1195:
1196: sub update_paste_buffer {
1197: my ($coursenum,$coursedom) = @_;
1198:
1199: return if (!defined($env{'form.markcopy'}));
1200: return if (!defined($env{'form.copyfolder'}));
1201: return if ($env{'form.markcopy'} < 0);
1202:
1203: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1204: $env{'form.copyfolder'});
1205:
1206: return if ($fatal);
1207:
1208: # Mark for copying
1209: my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
1210: if (&is_supplemental_title($title)) {
1211: ($title) = &parse_supplemental_title($title);
1212: }
1213: $url=~s{http(:|:)//https(:|:)//}{https$2//};
1214:
1215: &Apache::lonnet::appenv({'docs.markedcopy_title' => $title,
1216: 'docs.markedcopy_url' => $url});
1217: delete($env{'form.markcopy'});
1218: }
1219:
1220: sub print_paste_buffer {
1221: my ($r,$container) = @_;
1222: return if (!defined($env{'docs.markedcopy_url'}));
1223:
1224: $r->print(<<ENDPASTE);
1225: <form name="pasteform" action="/adm/coursedocs" method="post"><p>
1226: ENDPASTE
1227: $r->print('<input type="submit" name="pastemarked" value="'.&mt('Paste').'" /> ');
1228:
1229: my $type;
1230: if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1231: $type = &mt('External Resource');
1232: $r->print($type.': '.
1233: &LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('.
1234: &LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')');
1235: } else {
1236: my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
1237: my $icon = &Apache::loncommon::icon($extension);
1238: if ($extension eq 'sequence' &&
1239: $env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) {
1240: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1241: $icon .= '/folder_closed.gif';
1242: }
1243: $icon = '<img src="'.$icon.'" alt="" class="LC_icon" />';
1244: $r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'})));
1245: }
1246: if ($container eq 'page') {
1247: $r->print('
1248: <input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />
1249: <input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />
1250: ');
1251: } else {
1252: $r->print('
1253: <input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
1254: ');
1255: }
1256: $r->print('</p></form>');
1257: }
1258:
1259: sub do_paste_from_buffer {
1260: my ($coursenum,$coursedom) = @_;
1261:
1262: return 0 if (!$env{'form.pastemarked'});
1263:
1264: # paste resource to end of list
1265: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
1266: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});
1267: # Maps need to be copied first
1268: if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {
1269: $title=&mt('Copy of').' '.$title;
1270: my $newid=$$.time;
1271: $url=~/^(.+)\.(\w+)$/;
1272: my $newurl=$1.$newid.'.'.$2;
1273: my $storefn=$newurl;
1274: $storefn=~s{^/\w+/$match_domain/$match_username/}{};
1275: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
1276: &Apache::lonnet::getfile($url));
1277: $url = $newurl;
1278: }
1279: # published maps can only exists once, so remove it from paste buffer when done
1280: if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) {
1281: &Apache::lonnet::delenv('docs\\.markedcopy');
1282: }
1283: if ($url=~ m{/smppg$}) {
1284: my $db_name = &Apache::lonsimplepage::get_db_name($url);
1285: if ($db_name =~ /^smppage_/) {
1286: #simple pages, need to copy the db contents to a new one.
1287: my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum);
1288: my $now = time();
1289: $db_name =~ s{_\d*$ }{_$now}x;
1290: my $result=&Apache::lonnet::put($db_name,\%contents,
1291: $coursedom,$coursenum);
1292: $url =~ s{/(\d*)/smppg$ }{/$now/smppg}x;
1293: $title=&mt('Copy of').' '.$title;
1294: }
1295: }
1296: $title = &LONCAPA::map::qtunescape($title);
1297: my $ext='false';
1298: if ($url=~m{^http(|s)://}) { $ext='true'; }
1299: $url = &LONCAPA::map::qtunescape($url);
1300: # Now insert the URL at the bottom
1301: my $newidx = &LONCAPA::map::getresidx($url);
1302: $LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
1303: push(@LONCAPA::map::order, $newidx);
1304: # Store the result
1305: }
1306:
1307: my %parameter_type = ( 'randompick' => 'int_pos',
1308: 'hiddenresource' => 'string_yesno',
1309: 'encrypturl' => 'string_yesno',
1310: 'randomorder' => 'string_yesno',);
1311: my $valid_parameters_re = join('|',keys(%parameter_type));
1312: # set parameters
1313: sub update_parameter {
1314:
1315: return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1316:
1317: my $which = $env{'form.changeparms'};
1318: my $idx = $env{'form.setparms'};
1319: if ($env{'form.'.$which.'_'.$idx}) {
1320: my $value = ($which eq 'randompick') ? $env{'form.'.$which.'_'.$idx}
1321: : 'yes';
1322: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
1323: $parameter_type{$which});
1324: &remember_parms($idx,$which,'set',$value);
1325: } else {
1326: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
1327:
1328: &remember_parms($idx,$which,'del');
1329: }
1330: return 1;
1331: }
1332:
1333:
1334: sub handle_edit_cmd {
1335: my ($coursenum,$coursedom) =@_;
1336:
1337: my ($cmd,$idx)=split('_',$env{'form.cmd'});
1338:
1339: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
1340: my ($title, $url, @rrest) = split(':', $ratstr);
1341:
1342: if ($cmd eq 'del') {
1343: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1344: ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) {
1345: &Apache::lonnet::removeuploadedurl($url);
1346: } else {
1347: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
1348: }
1349: splice(@LONCAPA::map::order, $idx, 1);
1350:
1351: } elsif ($cmd eq 'cut') {
1352: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
1353: splice(@LONCAPA::map::order, $idx, 1);
1354:
1355: } elsif ($cmd eq 'up'
1356: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
1357: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
1358:
1359: } elsif ($cmd eq 'down'
1360: && defined($LONCAPA::map::order[$idx+1])) {
1361: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
1362:
1363: } elsif ($cmd eq 'rename') {
1364:
1365: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
1366: if ($comment=~/\S/) {
1367: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
1368: $comment.':'.join(':', $url, @rrest);
1369: }
1370: # Devalidate title cache
1371: my $renamed_url=&LONCAPA::map::qtescape($url);
1372: &Apache::lonnet::devalidate_title_cache($renamed_url);
1373: } else {
1374: return 0;
1375: }
1376: return 1;
1377: }
1378:
1379: sub editor {
1380: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_;
1381:
1382: my $container= ($env{'form.pagepath'}) ? 'page'
1383: : 'sequence';
1384:
1385: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1386: $folder.'.'.$container);
1387: return $errtext if ($fatal);
1388:
1389: if ($#LONCAPA::map::order<1) {
1390: my $idx=&LONCAPA::map::getresidx();
1391: if ($idx<=0) { $idx=1; }
1392: $LONCAPA::map::order[0]=$idx;
1393: $LONCAPA::map::resources[$idx]='';
1394: }
1395:
1396: my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=
1397: &breadcrumbs($folder,$allowed,$type);
1398: $r->print($breadcrumbtrail);
1399:
1400: # ------------------------------------------------------------ Process commands
1401:
1402: # ---------------- if they are for this folder and user allowed to make changes
1403: if (($allowed) && ($env{'form.folder'} eq $folder)) {
1404: # set parameters and change order
1405: &snapshotbefore();
1406:
1407: if (&update_parameter()) {
1408: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
1409: return $errtext if ($fatal);
1410: }
1411:
1412: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
1413: # change order
1414: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
1415: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
1416:
1417: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
1418: return $errtext if ($fatal);
1419: }
1420:
1421: if ($env{'form.pastemarked'}) {
1422: &do_paste_from_buffer($coursenum,$coursedom);
1423: ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
1424: return $errtext if ($fatal);
1425: }
1426:
1427: $r->print($upload_output);
1428:
1429: if (&handle_edit_cmd()) {
1430: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
1431: return $errtext if ($fatal);
1432: }
1433: # Group import/search
1434: if ($env{'form.importdetail'}) {
1435: my @imports;
1436: foreach (split(/\&/,$env{'form.importdetail'})) {
1437: if (defined($_)) {
1438: my ($name,$url,$residx)=
1439: map {&unescape($_)} split(/\=/,$_);
1440: push(@imports, [$name, $url, $residx]);
1441: }
1442: }
1443: ($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder,
1444: $container,'londocs',@imports);
1445: return $errtext if ($fatal);
1446: }
1447: # Loading a complete map
1448: if ($env{'form.loadmap'}) {
1449: if ($env{'form.importmap'}=~/\w/) {
1450: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
1451: my ($title,$url,$ext,$type)=split(/\:/,$res);
1452: my $idx=&LONCAPA::map::getresidx($url);
1453: $LONCAPA::map::resources[$idx]=$res;
1454: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
1455: }
1456: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1457: $folder.'.'.$container);
1458: return $errtext if ($fatal);
1459: } else {
1460: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1461:
1462: }
1463: }
1464: &log_differences($plain);
1465: }
1466: # ---------------------------------------------------------------- End commands
1467: # ---------------------------------------------------------------- Print screen
1468: my $idx=0;
1469: my $shown=0;
1470: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1471: $r->print('<p>'.&mt('Parameters').':<ul>'.
1472: ($randompick>=0?'<li>'.&mt('randomly pick [_1] resources',$randompick).'</li>':'').
1473: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
1474: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
1475: '</ul></p>');
1476: }
1477: if ($randompick>=0) {
1478: $r->print('<p>'.&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.').'</p>');
1479: }
1480: if ($is_random_order) {
1481: $r->print('<p>'.&mt('Caution: this folder is set to randomly order its contents. Adding or removing resources from this folder will change the order of resources shown.').'</p>');
1482: }
1483: $r->print('<table class="LC_docs_editor">');
1484: foreach my $res (@LONCAPA::map::order) {
1485: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
1486: $name=&LONCAPA::map::qtescape($name);
1487: $url=&LONCAPA::map::qtescape($url);
1488: unless ($name) { $name=(split(/\//,$url))[-1]; }
1489: unless ($name) { $idx++; next; }
1490: $r->print(&entryline($idx,$name,$url,$folder,$allowed,$res,
1491: $coursenum));
1492: $idx++;
1493: $shown++;
1494: }
1495: unless ($shown) {
1496: $r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
1497: }
1498: $r->print("\n</table>\n");
1499: &print_paste_buffer($r,$container);
1500: return;
1501: }
1502:
1503: sub process_file_upload {
1504: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
1505: # upload a file, if present
1506: my $parseaction;
1507: if ($env{'form.parserflag'}) {
1508: $parseaction = 'parse';
1509: }
1510: my $phase_status;
1511: my $folder=$env{'form.folder'};
1512: if ($folder eq '') {
1513: $folder='default';
1514: }
1515: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
1516: my $errtext='';
1517: my $fatal=0;
1518: my $container='sequence';
1519: if ($env{'form.pagepath'}) {
1520: $container='page';
1521: }
1522: ($errtext,$fatal)=
1523: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1524: if ($#LONCAPA::map::order<1) {
1525: $LONCAPA::map::order[0]=1;
1526: $LONCAPA::map::resources[1]='';
1527: }
1528: if ($fatal) {
1529: return 'failed';
1530: }
1531: my $destination = 'docs/';
1532: if ($folder =~ /^supplemental/) {
1533: $destination = 'supplemental/';
1534: }
1535: if (($folder eq 'default') || ($folder eq 'supplemental')) {
1536: $destination .= 'default/';
1537: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
1538: $destination .= $2.'/';
1539: }
1540: # this is for a course, not a user, so set coursedoc flag
1541: # probably the only place in the system where this should be "1"
1542: my $newidx=&LONCAPA::map::getresidx();
1543: $destination .= $newidx;
1544: my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination,
1545: $parseaction,$allfiles,
1546: $codebase);
1547: my $ext='false';
1548: if ($url=~m{^http://}) { $ext='true'; }
1549: $url = &LONCAPA::map::qtunescape($url);
1550: my $comment=$env{'form.comment'};
1551: $comment = &LONCAPA::map::qtunescape($comment);
1552: if ($folder=~/^supplemental/) {
1553: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1554: $env{'user.domain'}.'___&&&___'.$comment;
1555: }
1556:
1557: $LONCAPA::map::resources[$newidx]=
1558: $comment.':'.$url.':'.$ext.':normal:res';
1559: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
1560: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1561: $folder.'.'.$container);
1562: if ($fatal) {
1563: $$upload_output .= '<p><span class="LC_error">'.$errtext.'</span></p>';
1564: return 'failed';
1565: } else {
1566: if ($parseaction eq 'parse') {
1567: my $total_embedded = keys(%{$allfiles});
1568: if ($total_embedded > 0) {
1569: my $num = 0;
1570: my $state = '
1571: <input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
1572: <input type="hidden" name="cmd" value="upload_embedded" />
1573: <input type="hidden" name="newidx" value="'.$newidx.'" />
1574: <input type="hidden" name="primaryurl" value="'.&escape($url).'" />
1575: <input type="hidden" name="phasetwo" value="'.$total_embedded.'" />';
1576: $phase_status = 'phasetwo';
1577:
1578: $$upload_output .=
1579: 'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />'.
1580: &Apache::loncommon::ask_for_embedded_content(
1581: '/adm/coursedocs',$state,$allfiles,$codebase);
1582: } else {
1583: $$upload_output .= 'No embedded items identified<br />';
1584: }
1585: }
1586: }
1587: }
1588: return $phase_status;
1589: }
1590:
1591: sub process_secondary_uploads {
1592: my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
1593: my $folder=$env{'form.folder'};
1594: my $destination = 'docs/';
1595: if ($folder =~ /^supplemental/) {
1596: $destination = 'supplemental/';
1597: }
1598: if (($folder eq 'default') || ($folder eq 'supplemental')) {
1599: $destination .= 'default/';
1600: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
1601: $destination .= $2.'/';
1602: }
1603: $destination .= $newidx;
1604: my ($url,$filename);
1605: $url=&Apache::lonnet::userfileupload($formname.$num,1,$destination);
1606: ($filename) = ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/\Q$destination\E/(.+)$});
1607: return $filename;
1608: }
1609:
1610: sub is_supplemental_title {
1611: my ($title) = @_;
1612: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
1613: }
1614:
1615: sub parse_supplemental_title {
1616: my ($title) = @_;
1617:
1618: my ($foldertitle,$renametitle);
1619: if ($title =~ /&&&/) {
1620: $title = &HTML::Entites::decode($title);
1621: }
1622: if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) {
1623: $renametitle=$4;
1624: my ($time,$uname,$udom) = ($1,$2,$3);
1625: $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
1626: my $name = &Apache::loncommon::plainname($uname,$udom);
1627: $name = &HTML::Entities::encode($name,'"<>&\'');
1628: $title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '.
1629: $name.': <br />'.$foldertitle;
1630: }
1631: if (wantarray) {
1632: return ($title,$foldertitle,$renametitle);
1633: }
1634: return $title;
1635: }
1636:
1637: # --------------------------------------------------------------- An entry line
1638:
1639: sub entryline {
1640: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
1641:
1642: my ($foldertitle,$pagetitle,$renametitle);
1643: if (&is_supplemental_title($title)) {
1644: ($title,$foldertitle,$renametitle) = &parse_supplemental_title($title);
1645: $pagetitle = $foldertitle;
1646: } else {
1647: $title=&HTML::Entities::encode($title,'"<>&\'');
1648: $renametitle=$title;
1649: $foldertitle=$title;
1650: $pagetitle=$title;
1651: }
1652:
1653: my $orderidx=$LONCAPA::map::order[$index];
1654:
1655:
1656: $renametitle=~s/\\/\\\\/g;
1657: $renametitle=~s/\"\;/\\\"/g;
1658: $renametitle=~s/ /%20/g;
1659: my $line='<tr>';
1660: my ($form_start,$form_end);
1661: # Edit commands
1662: my ($container, $type, $esc_path, $path, $symb);
1663: if ($env{'form.folderpath'}) {
1664: $type = 'folder';
1665: $container = 'sequence';
1666: $esc_path=&escape($env{'form.folderpath'});
1667: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1668: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
1669: }
1670: if ($env{'form.pagepath'}) {
1671: $type = $container = 'page';
1672: $esc_path=&escape($path = $env{'form.pagepath'});
1673: $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
1674: $symb=&escape($env{'form.pagesymb'});
1675: }
1676: my $cpinfo='';
1677: if ($allowed) {
1678: my $incindex=$index+1;
1679: my $selectbox='';
1680: if (($folder!~/^supplemental/) &&
1681: ($#LONCAPA::map::order>0) &&
1682: ((split(/\:/,
1683: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
1684: ne '') &&
1685: ((split(/\:/,
1686: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1687: ne '')) {
1688: $selectbox=
1689: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1690: '<select name="newpos" onChange="this.form.submit()">';
1691: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
1692: if ($i==$incindex) {
1693: $selectbox.='<option value="" selected="1">('.$i.')</option>';
1694: } else {
1695: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
1696: }
1697: }
1698: $selectbox.='</select>';
1699: }
1700: my %lt=&Apache::lonlocal::texthash(
1701: 'up' => 'Move Up',
1702: 'dw' => 'Move Down',
1703: 'rm' => 'Remove',
1704: 'ct' => 'Cut',
1705: 'rn' => 'Rename',
1706: 'cp' => 'Copy');
1707: my $nocopy=0;
1708: my $nocut=0;
1709: if ($url=~/\.(page|sequence)$/) {
1710: if ($url =~ m{/res/}) {
1711: # no copy for published maps
1712: $nocopy = 1;
1713: } else {
1714: foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
1715: my ($title,$url,$ext,$type)=split(/\:/,$_);
1716: if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
1717: $nocopy=1;
1718: last;
1719: }
1720: }
1721: }
1722: }
1723: if ($url=~/^\/res\/lib\/templates\//) {
1724: $nocopy=1;
1725: $nocut=1;
1726: }
1727: my $copylink=' ';
1728: my $cutlink=' ';
1729:
1730: my $skip_confirm = 0;
1731: if ( $folder =~ /^supplemental/
1732: || ($url =~ m{( /smppg$
1733: |/syllabus$
1734: |/aboutme$
1735: |/navmaps$
1736: |/bulletinboard$
1737: |\.html$
1738: |^/adm/wrapper/ext)}x)) {
1739: $skip_confirm = 1;
1740: }
1741:
1742: if (!$nocopy) {
1743: $copylink=(<<ENDCOPY);
1744: <a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_copy">$lt{'cp'}</a>
1745: ENDCOPY
1746: }
1747: if (!$nocut) {
1748: $cutlink=(<<ENDCUT);
1749: <a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder",$skip_confirm);' class="LC_docs_cut">$lt{'ct'}</a>
1750: ENDCUT
1751: }
1752: $form_start = (<<END);
1753: <form action="/adm/coursedocs" method="post">
1754: <input type="hidden" name="${type}path" value="$path" />
1755: <input type="hidden" name="${type}symb" value="$symb" />
1756: <input type="hidden" name="setparms" value="$orderidx" />
1757: <input type="hidden" name="changeparms" value="0" />
1758: END
1759: $form_end = '</form>';
1760: $line.=(<<END);
1761: <td>
1762: <table class="LC_docs_entry_move">
1763: <tr>
1764: <td>
1765: <a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'><img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" /></a>
1766: </td>
1767: </tr>
1768: <tr>
1769: <td>
1770: <a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'><img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" /></a>
1771: </td>
1772: </tr>
1773: </table>
1774: </td>
1775: <td>
1776: $form_start
1777: $selectbox
1778: $form_end
1779: </td>
1780: <td class="LC_docs_entry_commands">
1781: <a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
1782: $cutlink
1783: <a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>
1784: $copylink
1785: </td>
1786: END
1787:
1788: }
1789: # Figure out what kind of a resource this is
1790: my ($extension)=($url=~/\.(\w+)$/);
1791: my $uploaded=($url=~/^\/*uploaded\//);
1792: my $icon=&Apache::loncommon::icon($url);
1793: my $isfolder=0;
1794: my $ispage=0;
1795: my $folderarg;
1796: my $pagearg;
1797: my $pagefile;
1798: if ($uploaded) {
1799: if ($extension eq 'sequence') {
1800: $icon=$iconpath.'/folder_closed.gif';
1801: $url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/;
1802: $url='/adm/coursedocs?';
1803: $folderarg=$1;
1804: $isfolder=1;
1805: } elsif ($extension eq 'page') {
1806: $icon=$iconpath.'/page.gif';
1807: $url=~/\Q$coursenum\E\/([\/\w]+)\.page$/;
1808: $pagearg=$1;
1809: $url='/adm/coursedocs?';
1810: $ispage=1;
1811: } else {
1812: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
1813: }
1814: }
1815:
1816: my $orig_url = $url;
1817: my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
1818: if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
1819: my $symb=&Apache::lonnet::symbclean(
1820: &Apache::lonnet::declutter('uploaded/'.
1821: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
1822: $env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
1823: '.sequence').
1824: '___'.$residx.'___'.
1825: &Apache::lonnet::declutter($url));
1826: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
1827: $url=&Apache::lonnet::clutter($url);
1828: if ($url=~/^\/*uploaded\//) {
1829: $url=~/\.(\w+)$/;
1830: my $embstyle=&Apache::loncommon::fileembstyle($1);
1831: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
1832: $url='/adm/wrapper'.$url;
1833: } elsif ($embstyle eq 'ssi') {
1834: #do nothing with these
1835: } elsif ($url!~/\.(sequence|page)$/) {
1836: $url='/adm/coursedocs/showdoc'.$url;
1837: }
1838: } elsif ($url=~m|^/ext/|) {
1839: $url='/adm/wrapper'.$url;
1840: $external = 1;
1841: }
1842: if (&Apache::lonnet::symbverify($symb,$url)) {
1843: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
1844: } else {
1845: $url='';
1846: }
1847: if ($container eq 'page') {
1848: my $symb=$env{'form.pagesymb'};
1849:
1850: $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
1851: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
1852: }
1853: }
1854: my ($parameterset,$rand_order_text) = (' ', ' ');
1855: if ($isfolder || $extension eq 'sequence') {
1856: my $foldername=&escape($foldertitle);
1857: my $folderpath=$env{'form.folderpath'};
1858: if ($folderpath) { $folderpath.='&' };
1859: # Append randompick number, hidden, and encrypted with ":" to foldername,
1860: # so it gets transferred between levels
1861: $folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx,
1862: 'parameter_randompick'))[0]
1863: .':'.((&LONCAPA::map::getparameter($orderidx,
1864: 'parameter_hiddenresource'))[0]=~/^yes$/i)
1865: .':'.((&LONCAPA::map::getparameter($orderidx,
1866: 'parameter_encrypturl'))[0]=~/^yes$/i)
1867: .':'.((&LONCAPA::map::getparameter($orderidx,
1868: 'parameter_randomorder'))[0]=~/^yes$/i);
1869: $url.='folderpath='.&escape($folderpath).$cpinfo;
1870: $parameterset='<label>'.&mt('Randomly Pick: ').
1871: '<input type="text" size="4" onChange="this.form.changeparms.value='."'randompick'".';this.form.submit()" name="randompick_'.$orderidx.'" value="'.
1872: (&LONCAPA::map::getparameter($orderidx,
1873: 'parameter_randompick'))[0].
1874: '" />'.
1875: '<a href="javascript:void(0)">'.&mt('Save').'</a></label>';
1876: my $ro_set=
1877: ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
1878: $rand_order_text ='
1879: <nobr><label><input type="checkbox" name="randomorder_'.$orderidx.'" onClick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></nobr>';
1880: }
1881: if ($ispage) {
1882: my $pagename=&escape($pagetitle);
1883: my $pagepath;
1884: my $folderpath=$env{'form.folderpath'};
1885: if ($folderpath) { $pagepath = $folderpath.'&' };
1886: $pagepath.=$pagearg.'&'.$pagename;
1887: my $symb=$env{'form.pagesymb'};
1888: if (!$symb) {
1889: my $path='uploaded/'.
1890: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
1891: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
1892: $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
1893: $residx,
1894: $path.$pagearg.'.page');
1895: }
1896: $url.='pagepath='.&escape($pagepath).
1897: '&pagesymb='.&escape($symb).$cpinfo;
1898: }
1899: if ($external) {
1900: my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
1901: $external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>';
1902: } else {
1903: undef($external);
1904: }
1905: $line.='
1906: <td class="LC_docs_entry_icon">
1907: '.($url?'<a href="'.$url.'">':'').'<img src="'.$icon.'" alt="" class="LC_icon" />'.($url?'</a>':'').'
1908: </td>
1909: <td class="LC_docs_entry_title">
1910: '.($url?"<a href=\"$url\">":'').$title.($url?'</a>':' <span class="LC_docs_reinit_warn">'.&mt('(re-initialize course to access)').'</span>').$external."
1911: </td>";
1912: if (($allowed) && ($folder!~/^supplemental/)) {
1913: my %lt=&Apache::lonlocal::texthash(
1914: 'hd' => 'Hidden',
1915: 'ec' => 'URL hidden');
1916: my $enctext=
1917: ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':'');
1918: my $hidtext=
1919: ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':'');
1920: $line.=(<<ENDPARMS);
1921: <td class="LC_docs_entry_parameter">
1922: $form_start
1923: <label><input type="checkbox" name="hiddenresource_$orderidx" onClick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
1924: $form_end
1925: </td>
1926: <td class="LC_docs_entry_parameter">
1927: $form_start
1928: <label><input type="checkbox" name="encrypturl_$orderidx" onClick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
1929: $form_end
1930: </td>
1931: <td class="LC_docs_entry_parameter">$form_start $rand_order_text $form_end</td>
1932: <td class="LC_docs_entry_parameter">$form_start $parameterset $form_end</td>
1933: ENDPARMS
1934: }
1935: $line.="</tr>";
1936: return $line;
1937: }
1938:
1939: # ---------------------------------------------------------------- tie the hash
1940:
1941: sub tiehash {
1942: my ($mode)=@_;
1943: $hashtied=0;
1944: if ($env{'request.course.fn'}) {
1945: if ($mode eq 'write') {
1946: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
1947: &GDBM_WRCREAT(),0640)) {
1948: $hashtied=2;
1949: }
1950: } else {
1951: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
1952: &GDBM_READER(),0640)) {
1953: $hashtied=1;
1954: }
1955: }
1956: }
1957: }
1958:
1959: sub untiehash {
1960: if ($hashtied) { untie %hash; }
1961: $hashtied=0;
1962: return OK;
1963: }
1964:
1965: # --------------------------------------------------------------- check on this
1966:
1967: sub checkonthis {
1968: my ($r,$url,$level,$title)=@_;
1969: $url=&unescape($url);
1970: $alreadyseen{$url}=1;
1971: $r->rflush();
1972: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
1973: $r->print("\n<br />");
1974: for (my $i=0;$i<=$level*5;$i++) {
1975: $r->print(' ');
1976: }
1977: $r->print('<a href="'.$url.'" target="cat">'.
1978: ($title?$title:$url).'</a> ');
1979: if ($url=~/^\/res\//) {
1980: my $result=&Apache::lonnet::repcopy(
1981: &Apache::lonnet::filelocation('',$url));
1982: if ($result eq 'ok') {
1983: $r->print('<font color="green">'.&mt('ok').'</font>');
1984: $r->rflush();
1985: &Apache::lonnet::countacc($url);
1986: $url=~/\.(\w+)$/;
1987: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
1988: $r->print('<br />');
1989: $r->rflush();
1990: for (my $i=0;$i<=$level*5;$i++) {
1991: $r->print(' ');
1992: }
1993: $r->print('- '.&mt('Rendering').': ');
1994: my ($errorcount,$warningcount)=split(/:/,
1995: &Apache::lonnet::ssi_body($url,
1996: ('grade_target'=>'web',
1997: 'return_only_error_and_warning_counts' => 1)));
1998: if (($errorcount) ||
1999: ($warningcount)) {
2000: if ($errorcount) {
2001: $r->print('<img src="/adm/lonMisc/bomb.gif" /><span class="LC_error">'.
2002: $errorcount.' '.
2003: &mt('error(s)').'</span> ');
2004: }
2005: if ($warningcount) {
2006: $r->print('<span class="LC_warning">'.
2007: $warningcount.' '.
2008: &mt('warning(s)').'</span>');
2009: }
2010: } else {
2011: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
2012: }
2013: $r->rflush();
2014: }
2015: my $dependencies=
2016: &Apache::lonnet::metadata($url,'dependencies');
2017: foreach (split(/\,/,$dependencies)) {
2018: if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
2019: &checkonthis($r,$_,$level+1);
2020: }
2021: }
2022: } elsif ($result eq 'unavailable') {
2023: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
2024: } elsif ($result eq 'not_found') {
2025: unless ($url=~/\$/) {
2026: $r->print('<span class="LC_error">'.&mt('not found').'</b></font>');
2027: } else {
2028: $r->print('<span class="LC_unknown">'.&mt('unable to verify variable URL').'</span>');
2029: }
2030: } else {
2031: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
2032: }
2033: }
2034: }
2035: }
2036:
2037:
2038: #
2039: # ----------------------------------------------------------------- List Symbs
2040: #
2041: sub list_symbs {
2042: my ($r) = @_;
2043:
2044: $r->print(&Apache::loncommon::start_page('Symb List'));
2045: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List'));
2046: my $navmap = Apache::lonnavmaps::navmap->new();
2047: $r->print("<pre>\n");
2048: foreach my $res ($navmap->retrieveResources()) {
2049: $r->print($res->compTitle()."\t".$res->symb()."\n");
2050: }
2051: $r->print("\n</pre>\n");
2052: $r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>');
2053: }
2054:
2055:
2056: #
2057: # -------------------------------------------------------------- Verify Content
2058: #
2059: sub verifycontent {
2060: my ($r) = @_;
2061: my $type = &Apache::loncommon::course_type();
2062: my $loaderror=&Apache::lonnet::overloaderror($r);
2063: if ($loaderror) { return $loaderror; }
2064: $r->print(&Apache::loncommon::start_page('Verify '.$type.' Documents'));
2065: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$type.' Documents'));
2066: $hashtied=0;
2067: undef %alreadyseen;
2068: %alreadyseen=();
2069: &tiehash();
2070: foreach (keys %hash) {
2071: if ($hash{$_}=~/\.(page|sequence)$/) {
2072: if (($_=~/^src_/) && ($alreadyseen{&unescape($hash{$_})})) {
2073: $r->print('<hr /><span class="LC_error">'.
2074: &mt('The following sequence or page is included more than once in your '.$type.': ').
2075: &unescape($hash{$_}).'</span><br />'.
2076: &mt('Note that grading records for problems included in this sequence or folder will overlap.<hr />'));
2077: }
2078: }
2079: if (($_=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$_})})) {
2080: &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
2081: }
2082: }
2083: &untiehash();
2084: $r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'.
2085: &mt('Return to DOCS').'</a>');
2086: }
2087:
2088:
2089: # -------------------------------------------------------------- Check Versions
2090:
2091: sub devalidateversioncache {
2092: my $src=shift;
2093: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
2094: &Apache::lonnet::clutter($src));
2095: }
2096:
2097: sub checkversions {
2098: my ($r) = @_;
2099: my $type = &Apache::loncommon::course_type();
2100: $r->print(&Apache::loncommon::start_page("Check $type Document Versions"));
2101: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $type Document Versions"));
2102: my $header='';
2103: my $startsel='';
2104: my $monthsel='';
2105: my $weeksel='';
2106: my $daysel='';
2107: my $allsel='';
2108: my %changes=();
2109: my $starttime=0;
2110: my $haschanged=0;
2111: my %setversions=&Apache::lonnet::dump('resourceversions',
2112: $env{'course.'.$env{'request.course.id'}.'.domain'},
2113: $env{'course.'.$env{'request.course.id'}.'.num'});
2114:
2115: $hashtied=0;
2116: &tiehash();
2117: my %newsetversions=();
2118: if ($env{'form.setmostrecent'}) {
2119: $haschanged=1;
2120: foreach (keys %hash) {
2121: if ($_=~/^ids\_(\/res\/.+)$/) {
2122: $newsetversions{$1}='mostrecent';
2123: &devalidateversioncache($1);
2124: }
2125: }
2126: } elsif ($env{'form.setcurrent'}) {
2127: $haschanged=1;
2128: foreach (keys %hash) {
2129: if ($_=~/^ids\_(\/res\/.+)$/) {
2130: my $getvers=&Apache::lonnet::getversion($1);
2131: if ($getvers>0) {
2132: $newsetversions{$1}=$getvers;
2133: &devalidateversioncache($1);
2134: }
2135: }
2136: }
2137: } elsif ($env{'form.setversions'}) {
2138: $haschanged=1;
2139: foreach (keys %env) {
2140: if ($_=~/^form\.set_version_(.+)$/) {
2141: my $src=$1;
2142: if (($env{$_}) && ($env{$_} ne $setversions{$src})) {
2143: $newsetversions{$src}=$env{$_};
2144: &devalidateversioncache($src);
2145: }
2146: }
2147: }
2148: }
2149: if ($haschanged) {
2150: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
2151: $env{'course.'.$env{'request.course.id'}.'.domain'},
2152: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
2153: $r->print('<h1>'.&mt('Your Version Settings have been Saved').'</h1>');
2154: } else {
2155: $r->print('<h1><span class="LC_error">'.&mt('An Error Occured while Attempting to Save your Version Settings').'</span></h1>');
2156: }
2157: &mark_hash_old();
2158: }
2159: &changewarning($r,'');
2160: if ($env{'form.timerange'} eq 'all') {
2161: # show all documents
2162: $header=&mt('All Documents in '.$type);
2163: $allsel=1;
2164: foreach (keys %hash) {
2165: if ($_=~/^ids\_(\/res\/.+)$/) {
2166: my $src=$1;
2167: $changes{$src}=1;
2168: }
2169: }
2170: } else {
2171: # show documents which changed
2172: %changes=&Apache::lonnet::dump
2173: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
2174: $env{'course.'.$env{'request.course.id'}.'.num'});
2175: my $firstkey=(keys %changes)[0];
2176: unless ($firstkey=~/^error\:/) {
2177: unless ($env{'form.timerange'}) {
2178: $env{'form.timerange'}=604800;
2179: }
2180: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
2181: .&mt('seconds');
2182: if ($env{'form.timerange'}==-1) {
2183: $seltext='since start of course';
2184: $startsel='selected';
2185: $env{'form.timerange'}=time;
2186: }
2187: $starttime=time-$env{'form.timerange'};
2188: if ($env{'form.timerange'}==2592000) {
2189: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
2190: $monthsel='selected';
2191: } elsif ($env{'form.timerange'}==604800) {
2192: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
2193: $weeksel='selected';
2194: } elsif ($env{'form.timerange'}==86400) {
2195: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
2196: $daysel='selected';
2197: }
2198: $header=&mt('Content changed').' '.$seltext;
2199: } else {
2200: $header=&mt('No content modifications yet.');
2201: }
2202: }
2203: %setversions=&Apache::lonnet::dump('resourceversions',
2204: $env{'course.'.$env{'request.course.id'}.'.domain'},
2205: $env{'course.'.$env{'request.course.id'}.'.num'});
2206: my %lt=&Apache::lonlocal::texthash
2207: ('st' => 'Version changes since start of '.$type,
2208: 'lm' => 'Version changes since last Month',
2209: 'lw' => 'Version changes since last Week',
2210: 'sy' => 'Version changes since Yesterday',
2211: 'al' => 'All Resources (possibly large output)',
2212: 'sd' => 'Display',
2213: 'fi' => 'File',
2214: 'md' => 'Modification Date',
2215: 'mr' => 'Most recently published Version',
2216: 've' => 'Version used in '.$type,
2217: 'vu' => 'Set Version to be used in '.$type,
2218: 'sv' => 'Set Versions to be used in '.$type.' according to Selections below',
2219: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
2220: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
2221: 'di' => 'Differences');
2222: $r->print(<<ENDHEADERS);
2223: <form action="/adm/coursedocs" method="post">
2224: <input type="hidden" name="versions" value="1" />
2225: <input type="submit" name="setmostrecent" value="$lt{'sm'}" />
2226: <input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
2227: <select name="timerange">
2228: <option value='all' $allsel>$lt{'al'}</option>
2229: <option value="-1" $startsel>$lt{'st'}</option>
2230: <option value="2592000" $monthsel>$lt{'lm'}</option>
2231: <option value="604800" $weeksel>$lt{'lw'}</option>
2232: <option value="86400" $daysel>$lt{'sy'}</option>
2233: </select>
2234: <input type="submit" name="display" value="$lt{'sd'}" />
2235: <h3>$header</h3>
2236: <input type="submit" name="setversions" value="$lt{'sv'}" />
2237: <table border="0">
2238: ENDHEADERS
2239: foreach (sort keys %changes) {
2240: if ($changes{$_}>$starttime) {
2241: my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
2242: my $currentversion=&Apache::lonnet::getversion($_);
2243: if ($currentversion<0) {
2244: $currentversion=&mt('Could not be determined.');
2245: }
2246: my $linkurl=&Apache::lonnet::clutter($_);
2247: $r->print(
2248: '<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
2249: &Apache::lonnet::gettitle($linkurl).
2250: '</b></font></td></tr>'.
2251: '<tr><td> </td>'.
2252: '<td colspan="4">'.
2253: '<a href="'.$linkurl.'" target="cat">'.$linkurl.
2254: '</a></td></tr>'.
2255: '<tr><td></td>'.
2256: '<td title="'.$lt{'md'}.'">'.
2257: &Apache::lonlocal::locallocaltime(
2258: &Apache::lonnet::metadata($root.'.'.$extension,
2259: 'lastrevisiondate')
2260: ).
2261: '</td>'.
2262: '<td title="'.$lt{'mr'}.'"><span class="LC_nobreak">Most Recent: '.
2263: '<font size="+1">'.$currentversion.'</font>'.
2264: '</span></td>'.
2265: '<td title="'.$lt{'ve'}.'"><span class="LC_nobreak">In '.$type.': '.
2266: '<font size="+1">');
2267: # Used in course
2268: my $usedversion=$hash{'version_'.$linkurl};
2269: if (($usedversion) && ($usedversion ne 'mostrecent')) {
2270: $r->print($usedversion);
2271: } else {
2272: $r->print($currentversion);
2273: }
2274: $r->print('</font></span></td><td title="'.$lt{'vu'}.'">'.
2275: '<span class="LC_nobreak">Use: ');
2276: # Set version
2277: $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
2278: 'set_version_'.$linkurl,
2279: ('select_form_order' =>
2280: ['',1..$currentversion,'mostrecent'],
2281: '' => '',
2282: 'mostrecent' => 'most recent',
2283: map {$_,$_} (1..$currentversion))));
2284: $r->print('</span></td></tr><tr><td></td>');
2285: my $lastold=1;
2286: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
2287: my $url=$root.'.'.$prevvers.'.'.$extension;
2288: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
2289: $starttime) {
2290: $lastold=$prevvers;
2291: }
2292: }
2293: #
2294: # Code to figure out how many version entries should go in
2295: # each of the four columns
2296: my $entries_per_col = 0;
2297: my $num_entries = ($currentversion-$lastold);
2298: if ($num_entries % 4 == 0) {
2299: $entries_per_col = $num_entries/4;
2300: } else {
2301: $entries_per_col = $num_entries/4 + 1;
2302: }
2303: my $entries_count = 0;
2304: $r->print('<td valign="top"><font size="-2">');
2305: my $cols_output = 1;
2306: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
2307: my $url=$root.'.'.$prevvers.'.'.$extension;
2308: $r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url).
2309: '">'.&mt('Version').' '.$prevvers.'</a> ('.
2310: &Apache::lonlocal::locallocaltime(
2311: &Apache::lonnet::metadata($url,
2312: 'lastrevisiondate')
2313: ).
2314: ')');
2315: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
2316: $r->print(' <a href="/adm/diff?filename='.
2317: &Apache::lonnet::clutter($root.'.'.$extension).
2318: '&versionone='.$prevvers.
2319: '">'.&mt('Diffs').'</a>');
2320: }
2321: $r->print('</span><br />');
2322: if (++$entries_count % $entries_per_col == 0) {
2323: $r->print('</font></td>');
2324: if ($cols_output != 4) {
2325: $r->print('<td valign="top"><font size="-2">');
2326: $cols_output++;
2327: }
2328: }
2329: }
2330: while($cols_output++ < 4) {
2331: $r->print('</font></td><td><font>')
2332: }
2333: $r->print('</font></td></tr>'."\n");
2334: }
2335: }
2336: $r->print('</table></form>');
2337: $r->print('<h1>'.&mt('Done').'.</h1>');
2338:
2339: &untiehash();
2340: }
2341:
2342: sub mark_hash_old {
2343: my $retie_hash=0;
2344: if ($hashtied) {
2345: $retie_hash=1;
2346: &untiehash();
2347: }
2348: &tiehash('write');
2349: $hash{'old'}=1;
2350: &untiehash();
2351: if ($retie_hash) { &tiehash(); }
2352: }
2353:
2354: sub is_hash_old {
2355: my $untie_hash=0;
2356: if (!$hashtied) {
2357: $untie_hash=1;
2358: &tiehash();
2359: }
2360: my $return=$hash{'old'};
2361: if ($untie_hash) { &untiehash(); }
2362: return $return;
2363: }
2364:
2365: sub changewarning {
2366: my ($r,$postexec,$message,$url)=@_;
2367: if (!&is_hash_old()) { return; }
2368: my $pathvar='folderpath';
2369: my $path=&escape($env{'form.folderpath'});
2370: if (!defined($url)) {
2371: if (defined($env{'form.pagepath'})) {
2372: $pathvar='pagepath';
2373: $path=&escape($env{'form.pagepath'});
2374: $path.='&pagesymb='.&escape($env{'form.pagesymb'});
2375: }
2376: $url='/adm/coursedocs?'.$pathvar.'='.$path;
2377: }
2378: my $course_type = &Apache::loncommon::course_type();
2379: if (!defined($message)) {
2380: $message='Changes will become active for your current session after [_1], or the next time you log in.';
2381: }
2382: $r->print("\n\n".
2383: '<script type="text/javascript">function reinit(tf) { tf.submit();'.$postexec.' }</script>'."\n".
2384: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
2385: '<input type="hidden" name="orgurl" value="'.$url.
2386: '" /><input type="hidden" name="selectrole" value="1" /><h3><span class="LC_warning">'.
2387: &mt($message,' <input type="hidden" name="'.
2388: $env{'request.role'}.'" value="1" /><input type="button" value="'.
2389: &mt('re-initializing '.$course_type).'" onClick="reinit(this.form)" />').
2390: $help{'Caching'}.'</span></h3></form>'."\n\n");
2391: }
2392:
2393: # =========================================== Breadcrumbs for special functions
2394:
2395: sub init_breadcrumbs {
2396: my ($form,$text)=@_;
2397: &Apache::lonhtmlcommon::clear_breadcrumbs();
2398: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs",
2399: text=>"Edit ".&Apache::loncommon::course_type(),
2400: faq=>273,
2401: bug=>'Instructor Interface',
2402: help => 'Docs_Adding_Course_Doc'});
2403: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
2404: text=>$text,
2405: faq=>273,
2406: bug=>'Instructor Interface'});
2407: }
2408:
2409: # ================================================================ Main Handler
2410: sub handler {
2411: my $r = shift;
2412: &Apache::loncommon::content_type($r,'text/html');
2413: $r->send_http_header;
2414: return OK if $r->header_only;
2415: my $type = &Apache::loncommon::course_type();
2416:
2417: # --------------------------------------------- Initialize help topics for this
2418: foreach ('Adding_Course_Doc','Main_Course_Documents',
2419: 'Adding_External_Resource','Navigate_Content',
2420: 'Adding_Folders','Docs_Overview', 'Load_Map',
2421: 'Supplemental','Score_Upload_Form','Adding_Pages',
2422: 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
2423: 'Check_Resource_Versions','Verify_Content') {
2424: $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
2425: }
2426: # Composite help files
2427: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
2428: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
2429: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
2430: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
2431: $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
2432: 'Option_Response_Simple');
2433: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
2434: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
2435: $help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
2436: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
2437: $help{'Group Files'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
2438: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
2439:
2440: # does this user have privileges to modify docs
2441: my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
2442: if ($allowed && $env{'form.verify'}) {
2443: &init_breadcrumbs('verify','Verify Content');
2444: &verifycontent($r);
2445: } elsif ($allowed && $env{'form.listsymbs'}) {
2446: &init_breadcrumbs('listsymbs','List Symbs');
2447: &list_symbs($r);
2448: } elsif ($allowed && $env{'form.docslog'}) {
2449: &init_breadcrumbs('docslog','Show Log');
2450: &docs_change_log($r);
2451: } elsif ($allowed && $env{'form.versions'}) {
2452: &init_breadcrumbs('versions','Check/Set Resource Versions');
2453: &checkversions($r);
2454: } elsif ($allowed && $env{'form.dumpcourse'}) {
2455: &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' DOCS to Construction Space');
2456: &dumpcourse($r);
2457: } elsif ($allowed && $env{'form.exportcourse'}) {
2458: &init_breadcrumbs('exportcourse','Export '.&Apache::loncommon::course_type().' to IMS');
2459: &exportcourse($r);
2460: } else {
2461: # is this a standard course?
2462:
2463: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
2464: my $forcestandard = 0;
2465: my $forcesupplement;
2466: my $script='';
2467: my $showdoc=0;
2468: my $containertag;
2469: my $uploadtag;
2470: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
2471: ['folderpath','pagepath',
2472: 'pagesymb']);
2473: # No folderpath, no pagepath, see if we have something stored
2474: if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
2475: &Apache::loncommon::restore_course_settings('docs_folderpath',
2476: {'folderpath' => 'scalar'});
2477: }
2478: if (!$env{'form.folderpath'}) {
2479: &Apache::loncommon::restore_course_settings('docs_folderpath',
2480: {'pagepath' => 'scalar'});
2481: }
2482: if ($env{'form.pagepath'}) {
2483: $env{'form.folderpath'}='';
2484: }
2485: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
2486: $env{'form.folderpath'} = 'supplemental&'.
2487: &escape(&mt('Supplemental '.$type.' Documents')).'&'.
2488: $env{'form.folderpath'};
2489: }
2490: &Apache::loncommon::store_course_settings('docs_folderpath',
2491: {'pagepath' => 'scalar',
2492: 'folderpath' => 'scalar'});
2493: if ($env{'form.folderpath'}) {
2494: my (@folderpath)=split('&',$env{'form.folderpath'});
2495: $env{'form.foldername'}=&unescape(pop(@folderpath));
2496: $env{'form.folder'}=pop(@folderpath);
2497: }
2498: if ($env{'form.pagepath'}) {
2499: my (@pagepath)=split('&',$env{'form.pagepath'});
2500: $env{'form.pagename'}=&unescape(pop(@pagepath));
2501: $env{'form.folder'}=pop(@pagepath);
2502: $containertag = '<input type="hidden" name="pagepath" value="" />'.
2503: '<input type="hidden" name="pagesymb" value="" />';
2504: $uploadtag = '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
2505: '<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />';
2506: }
2507: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
2508: $showdoc='/'.$1;
2509: }
2510: unless ($showdoc) { # got called from remote
2511: if (($env{'form.folder'}=~/^(?:group|default)_/) ||
2512: ($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) {
2513: $forcestandard = 1;
2514: }
2515: $forcesupplement=($env{'form.folder'}=~/^supplemental_/);
2516:
2517: if ($allowed) {
2518: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
2519: $script=&Apache::lonratedt::editscript('simple');
2520: }
2521: } else { # got called in sequence from course
2522: $allowed=0;
2523: }
2524:
2525: # get course data
2526: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
2527: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
2528:
2529: # get personal data
2530: my $uname=$env{'user.name'};
2531: my $udom=$env{'user.domain'};
2532: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
2533:
2534: # graphics settings
2535:
2536: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
2537:
2538: if ($allowed) {
2539: $script .= &editing_js($udom,$uname);
2540: }
2541: # -------------------------------------------------------------------- Body tag
2542: $script = '<script type="text/javascript">'."\n".$script."\n".'</script>';
2543: $r->print(&Apache::loncommon::start_page("$type Documents", $script,
2544: {'force_register' => $showdoc,}).
2545: &Apache::loncommon::help_open_menu('','',273,'RAT'));
2546:
2547: my %allfiles = ();
2548: my %codebase = ();
2549: my ($upload_result,$upload_output);
2550: if ($allowed) {
2551: if (($env{'form.uploaddoc.filename'}) &&
2552: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
2553: # Process file upload - phase one - upload and parse primary file.
2554: undef($hadchanges);
2555: $upload_result = &process_file_upload(\$upload_output,$coursenum,
2556: $coursedom,\%allfiles,
2557: \%codebase,$1);
2558: if ($hadchanges) {
2559: &mark_hash_old();
2560: }
2561: if ($upload_result eq 'phasetwo') {
2562: $r->print($upload_output);
2563: }
2564: } elsif ($env{'form.phasetwo'}) {
2565: my %newname = ();
2566: my %origname = ();
2567: my %attribs = ();
2568: my $updateflag = 0;
2569: my $residx = $env{'form.newidx'};
2570: my $primary_url = &unescape($env{'form.primaryurl'});
2571: # Process file upload - phase two - gather secondary files.
2572: for (my $i=0; $i<$env{'form.phasetwo'}; $i++) {
2573: if ($env{'form.embedded_item_'.$i.'.filename'}) {
2574: my $javacodebase;
2575: $newname{$i} = &process_secondary_uploads(\$upload_output,$coursedom,$coursenum,'embedded_item_',$i,$residx);
2576: $origname{$i} = &unescape($env{'form.embedded_orig_'.$i});
2577: if (exists($env{'form.embedded_codebase_'.$i})) {
2578: $javacodebase = &unescape($env{'form.embedded_codebase_'.$i});
2579: $origname{$i} =~ s#^\Q$javacodebase\E/##;
2580: }
2581: my @attributes = ();
2582: if ($env{'form.embedded_attrib_'.$i} =~ /:/) {
2583: @attributes = split/:/,$env{'form.embedded_attrib_'.$i};
2584: } else {
2585: @attributes = ($env{'form.embedded_attrib_'.$i});
2586: }
2587: foreach (@attributes) {
2588: push(@{$attribs{$i}},&unescape($_));
2589: }
2590: if ($javacodebase) {
2591: $codebase{$i} = $javacodebase;
2592: $codebase{$i} =~ s#/$##;
2593: $updateflag = 1;
2594: }
2595: }
2596: unless ($newname{$i} eq $origname{$i}) {
2597: $updateflag = 1;
2598: }
2599: }
2600: # Process file upload - phase three - modify primary file
2601: if ($updateflag) {
2602: my ($content,$rtncode);
2603: my $updateflag = 0;
2604: my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode);
2605: if ($getstatus eq 'ok') {
2606: foreach my $item (keys %newname) {
2607: if ($newname{$item} ne $origname{$item}) {
2608: my $attrib_regexp = '';
2609: if (@{$attribs{$item}} > 1) {
2610: $attrib_regexp = join('|',@{$attribs{$item}});
2611: } else {
2612: $attrib_regexp = $attribs{$item}[0];
2613: }
2614: if ($content =~ m#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#) {
2615: }
2616: $content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi;
2617: }
2618: if (exists($codebase{$item})) {
2619: $content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; #' stupid emacs
2620: }
2621: }
2622: # Save edited file.
2623: my $saveresult;
2624: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
2625: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
2626: my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult);
2627: } else {
2628: &Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus);
2629: }
2630: }
2631: }
2632: }
2633:
2634: unless ($showdoc || $upload_result eq 'phasetwo') {
2635: # -----------------------------------------------------------------------------
2636: my %lt=&Apache::lonlocal::texthash(
2637: 'uplm' => 'Upload a new main '.lc($type).' document',
2638: 'upls' => 'Upload a new supplemental '.lc($type).' document',
2639: 'impp' => 'Import a document',
2640: 'pubd' => 'Published documents',
2641: 'copm' => 'All documents out of a published map into this folder',
2642: 'spec' => 'Special documents',
2643: 'upld' => 'Upload Document',
2644: 'srch' => 'Search',
2645: 'impo' => 'Import',
2646: 'book' => 'Import Bookmarks',
2647: 'selm' => 'Select Map',
2648: 'load' => 'Load Map',
2649: 'reco' => 'Recover Deleted Resources',
2650: 'newf' => 'New Folder',
2651: 'newp' => 'New Composite Page',
2652: 'extr' => 'External Resource',
2653: 'syll' => 'Syllabus',
2654: 'navc' => 'Navigate Contents',
2655: 'sipa' => 'Simple Page',
2656: 'sipr' => 'Simple Problem',
2657: 'drbx' => 'Drop Box',
2658: 'scuf' => 'Score Upload Form',
2659: 'bull' => 'Bulletin Board',
2660: 'mypi' => 'My Personal Info',
2661: 'grpo' => 'Group Files',
2662: 'rost' => 'Course Roster',
2663: 'abou' => 'About User',
2664: 'imsf' => 'Import IMS package',
2665: 'file' => 'File',
2666: 'title' => 'Title',
2667: 'comment' => 'Comment',
2668: 'parse' => 'If HTML file, upload embedded images/multimedia files'
2669: );
2670: # -----------------------------------------------------------------------------
2671: if ($allowed) {
2672: &update_paste_buffer($coursenum,$coursedom);
2673: my $dumpbut=&dumpbutton();
2674: my $exportbut=&exportbutton();
2675: my %lt=&Apache::lonlocal::texthash(
2676: 'vc' => 'Verify Content',
2677: 'cv' => 'Check/Set Resource Versions',
2678: 'ls' => 'List Symbs',
2679: 'sl' => 'Show Log'
2680: );
2681:
2682: my $folderpath=$env{'form.folderpath'};
2683: if (!$folderpath) {
2684: if ($env{'form.folder'} eq '' ||
2685: $env{'form.folder'} eq 'supplemental') {
2686: $folderpath='default&'.
2687: &escape(&mt('Main '.$type.' Documents'));
2688: }
2689: }
2690: unless ($env{'form.pagepath'}) {
2691: $containertag = '<input type="hidden" name="folderpath" value="" />';
2692: $uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
2693: }
2694:
2695: $r->print(<<ENDCOURSEVERIFY);
2696: <form name="renameform" method="post" action="/adm/coursedocs">
2697: <input type="hidden" name="title" />
2698: <input type="hidden" name="cmd" />
2699: <input type="hidden" name="markcopy" />
2700: <input type="hidden" name="copyfolder" />
2701: $containertag
2702: </form>
2703: <form name="simpleedit" method="post" action="/adm/coursedocs">
2704: <input type="hidden" name="importdetail" value="" />
2705: $uploadtag
2706: </form>
2707: <form action="/adm/coursedocs" method="post" name="courseverify">
2708: <div class="LC_docs_course_commands">
2709:
2710: <div>
2711: <input type="submit" name="verify" value="$lt{'vc'}" />$help{'Verify_Content'}
2712: </div>
2713: <div>
2714: <input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'}
2715: </div>
2716: $dumpbut
2717: $exportbut
2718: <div>
2719: <input type="submit" name="listsymbs" value="$lt{'ls'}" />
2720: </div>
2721: <div>
2722: <input type="hidden" name="folder" value="$env{'form.folder'}" />
2723: <input type="submit" name="docslog" value="$lt{'sl'}" />
2724: </div>
2725: </div>
2726: </form>
2727: <div style="clear: both; height: 0px;"> </div>
2728: ENDCOURSEVERIFY
2729: $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
2730: &mt('Editing the Table of Contents for your '.$type)));
2731: }
2732: # --------------------------------------------------------- Standard documents
2733: $r->print('<table class="LC_docs_documents">');
2734:
2735: if (($standard) && ($allowed) && (!$forcesupplement)) {
2736: $r->print('<tr><td class="LC_docs_document">');
2737: # '<h2>'.&mt('Main Course Documents').
2738: # ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
2739: my $folder=$env{'form.folder'};
2740: if ($folder eq '' || $folder eq 'supplemental') {
2741: $folder='default';
2742: $env{'form.folderpath'}='default&'.&escape(&mt('Main '.$type.' Documents'));
2743: $uploadtag = '<input type="hidden" name="folderpath" value="'.
2744: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
2745: }
2746: my $postexec='';
2747: if ($folder eq 'default') {
2748: $r->print('<script type="text/javascript">this.window.name="loncapaclient";</script>');
2749: } else {
2750: #$postexec='self.close();';
2751: }
2752: $hadchanges=0;
2753: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,
2754: $upload_output,$type);
2755: if ($error) {
2756: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
2757: }
2758: if ($hadchanges) {
2759: &mark_hash_old()
2760: }
2761: &changewarning($r,$postexec);
2762: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
2763: '.sequence';
2764: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
2765: '.page';
2766: my $container='sequence';
2767: if ($env{'form.pagepath'}) {
2768: $container='page';
2769: }
2770: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
2771: $r->print(<<ENDFORM);
2772: <table class="LC_docs_adddocs">
2773: <tr>
2774: <th>$lt{'uplm'}</th>
2775: <th>$lt{'impp'}</th>
2776: <th>$lt{'spec'}</th>
2777: </tr>
2778: <tr>
2779: <td>
2780: $lt{'file'}:<br />
2781: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
2782: <input type="file" name="uploaddoc" size="40" />
2783: <br />
2784: $lt{'title'}:<br />
2785: <input type="text" size="50" name="comment" />
2786: $uploadtag
2787: <input type="hidden" name="cmd" value="upload_default" />
2788: <br />
2789: <span class="LC_nobreak">
2790: <label>$lt{'parse'}?
2791: <input type="checkbox" name="parserflag" checked="checked" />
2792: </label>
2793: </span>
2794: <br />
2795: <br />
2796: <span class="LC_nobreak">
2797: <input type="submit" value="$lt{'upld'}" />
2798: $help{'Uploading_From_Harddrive'}
2799: </span>
2800: </form>
2801: </td>
2802: <td>
2803: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
2804: $lt{'pubd'}<br />
2805: $uploadtag
2806: <input type="button" onClick="javascript:groupsearch()" value="$lt{'srch'}" />
2807: <br />
2808: <span class="LC_nobreak">
2809: <input type="button" onClick="javascript:groupimport();" value="$lt{'impo'}" />
2810: $help{'Importing_LON-CAPA_Resource'}
2811: </span>
2812: <br />
2813: <input type="button" onClick="javascript:groupopen(0,1,1);" value="$lt{'book'}" />
2814: <hr />
2815: <p>
2816: $lt{'copm'}<br />
2817: <input type="text" size="40" name="importmap" /><br />
2818: <span class="LC_nobreak"><input type="button"
2819: onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
2820: value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
2821: $help{'Load_Map'}</span>
2822: </p>
2823: </form>
2824: <hr />
2825: <form action="/adm/groupsort" method="post" name="recover">
2826: <input type="button" name="recovermap" onClick="javascript:groupopen('$readfile',1,0)" value="$lt{'reco'}" />
2827: </form>
2828: ENDFORM
2829: unless ($env{'form.pagepath'}) {
2830: $r->print(<<ENDFORM);
2831: <hr />
2832: <form action="/adm/coursedocs" method="post" name="newext">
2833: $uploadtag
2834: <input type="hidden" name="importdetail" value="" />
2835: <span class="LC_nobreak">
2836: <input name="newext" type="button" onClick="javascript:makenewext('newext');"
2837: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
2838: </span>
2839: </form>
2840: <br /><form action="/adm/imsimportdocs" method="post" name="ims">
2841: <input type="hidden" name="folder" value="$folder" />
2842: <input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
2843: </form>
2844: ENDFORM
2845: }
2846: $r->print('</td><td>');
2847: unless ($env{'form.pagepath'}) {
2848: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
2849: $r->print(<<ENDFORM);
2850: <br /><form action="/adm/coursedocs" method="post" name="newfolder">
2851: <input type="hidden" name="folderpath" value="$path" />
2852: <input type="hidden" name="importdetail" value="" />
2853: <span class="LC_nobreak">
2854: <input name="newfolder" type="button"
2855: onClick="javascript:makenewfolder(this.form,'$folderseq');"
2856: value="$lt{'newf'}" />$help{'Adding_Folders'}
2857: </span>
2858: </form>
2859: <br /><form action="/adm/coursedocs" method="post" name="newpage">
2860: <input type="hidden" name="folderpath" value="$path" />
2861: <input type="hidden" name="importdetail" value="" />
2862: <span class="LC_nobreak">
2863: <input name="newpage" type="button"
2864: onClick="javascript:makenewpage(this.form,'$pageseq');"
2865: value="$lt{'newp'}" />$help{'Adding_Pages'}
2866: </span>
2867: </form>
2868: <br /><form action="/adm/coursedocs" method="post" name="newsyl">
2869: $uploadtag
2870: <input type="hidden" name="importdetail"
2871: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
2872: <span class="LC_nobreak">
2873: <input name="newsyl" type="submit" value="$lt{'syll'}" />
2874: $help{'Syllabus'}
2875: </span>
2876: </form>
2877: <br /><form action="/adm/coursedocs" method="post" name="newnav">
2878: $uploadtag
2879: <input type="hidden" name="importdetail"
2880: value="$lt{'navc'}=/adm/navmaps" />
2881: <span class="LC_nobreak">
2882: <input name="newnav" type="submit" value="$lt{'navc'}" />
2883: $help{'Navigate_Content'}
2884: </span>
2885: </form>
2886: <br /><form action="/adm/coursedocs" method="post" name="newsmppg">
2887: $uploadtag
2888: <input type="hidden" name="importdetail" value="" />
2889: <span class="LC_nobreak">
2890: <input name="newsmppg" type="button" value="$lt{'sipa'}"
2891: onClick="javascript:makesmppage();" /> $help{'Simple Page'}
2892: </span>
2893: </form>
2894: <br /><form action="/adm/coursedocs" method="post" name="newsmpproblem">
2895: $uploadtag
2896: <input type="hidden" name="importdetail" value="" />
2897: <span class="LC_nobreak">
2898: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
2899: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
2900: </span>
2901: </form>
2902: <br /><form action="/adm/coursedocs" method="post" name="newdropbox">
2903: $uploadtag
2904: <input type="hidden" name="importdetail" value="" />
2905: <span class="LC_nobreak">
2906: <input name="newdropbox" type="button" value="$lt{'drbx'}"
2907: onClick="javascript:makedropbox();" />
2908: </span>
2909: </form>
2910: <br /><form action="/adm/coursedocs" method="post" name="newexamupload">
2911: $uploadtag
2912: <input type="hidden" name="importdetail" value="" />
2913: <span class="LC_nobreak">
2914: <input name="newexamupload" type="button" value="$lt{'scuf'}"
2915: onClick="javascript:makeexamupload();" />
2916: $help{'Score_Upload_Form'}
2917: </span>
2918: </form>
2919: <br /><form action="/adm/coursedocs" method="post" name="newbul">
2920: $uploadtag
2921: <input type="hidden" name="importdetail" value="" />
2922: <span class="LC_nobreak">
2923: <input name="newbulletin" type="button" value="$lt{'bull'}"
2924: onClick="javascript:makebulboard();" />
2925: $help{'Bulletin Board'}
2926: </span>
2927: </form>
2928: <br /><form action="/adm/coursedocs" method="post" name="newaboutme">
2929: $uploadtag
2930: <input type="hidden" name="importdetail"
2931: value="$plainname=/adm/$udom/$uname/aboutme" />
2932: <span class="LC_nobreak">
2933: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
2934: $help{'My Personal Info'}
2935: </span>
2936: </form>
2937: <br /><form action="/adm/coursedocs" method="post" name="newaboutsomeone">
2938: $uploadtag
2939: <input type="hidden" name="importdetail" value="" />
2940: <span class="LC_nobreak">
2941: <input name="newaboutsomeone" type="button" value="$lt{'abou'}"
2942: onClick="javascript:makeabout();" />
2943: </span>
2944: </form>
2945: <br /><form action="/adm/coursedocs" method="post" name="newgroupfiles">
2946: $uploadtag
2947: <input type="hidden" name="importdetail"
2948: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
2949: <span class="LC_nobreak">
2950: <input name="newgroupfiles" type="submit" value="$lt{'grpo'}" />
2951: $help{'Group Files'}
2952: </span>
2953: </form>
2954: <br /><form action="/adm/coursedocs" method="post" name="newroster">
2955: $uploadtag
2956: <input type="hidden" name="importdetail"
2957: value="$lt{'rost'}=/adm/viewclasslist" />
2958: <span class="LC_nobreak">
2959: <input name="newroster" type="submit" value="$lt{'rost'}" />
2960: $help{'Course Roster'}
2961: </span>
2962: </form>
2963: ENDFORM
2964: }
2965: if ($env{'form.pagepath'}) {
2966: $r->print(<<ENDBLOCK);
2967: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
2968: $uploadtag
2969: <input type="hidden" name="importdetail" value="" />
2970: <span class="LC_nobreak">
2971: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
2972: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
2973: </span>
2974: </form>
2975: <br /><form action="/adm/coursedocs" method="post" name="newexamupload">
2976: $uploadtag
2977: <input type="hidden" name="importdetail" value="" />
2978: <span class="LC_nobreak">
2979: <input name="newexamupload" type="button" value="$lt{'scuf'}"
2980: onClick="javascript:makeexamupload();" />
2981: $help{'Score_Upload_Form'}
2982: </span>
2983: </form>
2984: ENDBLOCK
2985: }
2986: $r->print('</td></tr>'."\n".
2987: '</table>');
2988: $r->print('</td></tr>');
2989: }
2990: # ----------------------------------------------------- Supplemental documents
2991: if (!$forcestandard) {
2992: $r->print('<tr><td class="LC_docs_document">');
2993: # '<h2>'.&mt('Supplemental Course Documents').
2994: # ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
2995: my $folder=$env{'form.folder'};
2996: unless ($folder=~/^supplemental/) {
2997: $folder='supplemental';
2998: }
2999: if ($folder =~ /^supplemental$/ &&
3000: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
3001: $env{'form.folderpath'} = 'supplemental&'.
3002: &escape(&mt('Supplemental '.$type.' Documents'));
3003: }
3004: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
3005: if ($error) {
3006: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
3007: }
3008: if ($allowed) {
3009: my $folderseq=
3010: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
3011: '.sequence';
3012:
3013: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3014: $r->print(<<ENDSUPFORM);
3015: <table class="LC_docs_adddocs"><tr>
3016: <th>$lt{'upls'}</th>
3017: <th>$lt{'spec'}</th>
3018: </tr>
3019: <tr><td>
3020: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
3021: <input type="file" name="uploaddoc" size="40" />
3022: <br />
3023: <br />
3024: <span class="LC_nobreak">
3025: <label>$lt{'parse'}?
3026: <input type="checkbox" name="parserflag" />
3027: </label>
3028: </span>
3029: <br /><br />
3030: $lt{'comment'}:<br />
3031: <textarea cols=50 rows=4 name='comment'>
3032: </textarea>
3033: <br />
3034: <input type="hidden" name="folderpath" value="$path" />
3035: <input type="hidden" name="cmd" value="upload_supplemental" />
3036: <span class="LC_nobreak">
3037: <input type="submit" value="$lt{'upld'}" />
3038: $help{'Uploading_From_Harddrive'}
3039: </span>
3040: </form>
3041: </td>
3042: <td>
3043: <form action="/adm/coursedocs" method="post" name="supnewfolder">
3044: <input type="hidden" name="folderpath" value="$path" />
3045: <input type="hidden" name="importdetail" value="" />
3046: <span class="LC_nobreak">
3047: <input name="newfolder" type="button"
3048: onClick="javascript:makenewfolder(this.form,'$folderseq');"
3049: value="$lt{'newf'}" /> $help{'Adding_Folders'}
3050: </span>
3051: </form>
3052: <br /><form action="/adm/coursedocs" method="post" name="supnewext">
3053: <input type="hidden" name="folderpath" value="$path" />
3054: <input type="hidden" name="importdetail" value="" />
3055: <span class="LC_nobreak">
3056: <input name="newext" type="button"
3057: onClick="javascript:makenewext('supnewext');"
3058: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
3059: </span>
3060: </form>
3061: <br /><form action="/adm/coursedocs" method="post" name="supnewsyl">
3062: <input type="hidden" name="folderpath" value="$path" />
3063: <input type="hidden" name="importdetail"
3064: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
3065: <span class="LC_nobreak">
3066: <input name="newsyl" type="submit" value="$lt{'syll'}" />
3067: $help{'Syllabus'}
3068: </span>
3069: </form>
3070: <br /><form action="/adm/coursedocs" method="post" name="subnewaboutme">
3071: <input type="hidden" name="folderpath" value="$path" />
3072: <input type="hidden" name="importdetail"
3073: value="$plainname=/adm/$udom/$uname/aboutme" />
3074: <span class="LC_nobreak">
3075: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
3076: $help{'My Personal Info'}
3077: </span>
3078: </form>
3079: </td></tr>
3080: </table></td></tr>
3081: ENDSUPFORM
3082: }
3083: }
3084: $r->print('</table>');
3085: if ($allowed) {
3086: $r->print('
3087: <form method="post" name="extimport" action="/adm/coursedocs">
3088: <input type="hidden" name="title" />
3089: <input type="hidden" name="url" />
3090: <input type="hidden" name="useform" />
3091: <input type="hidden" name="residx" />
3092: </form>');
3093: }
3094: } else {
3095: unless ($upload_result eq 'phasetwo') {
3096: # -------------------------------------------------------- This is showdoc mode
3097: $r->print("<h1>".&mt('Uploaded Document').' - '.
3098: &Apache::lonnet::gettitle($r->uri).'</h1><p>'.
3099: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
3100: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
3101: }
3102: }
3103: }
3104: $r->print(&Apache::loncommon::end_page());
3105: return OK;
3106: }
3107:
3108:
3109: sub editing_js {
3110: my ($udom,$uname) = @_;
3111: my $now = time();
3112: my %lt = &Apache::lonlocal::texthash(
3113: p_mnf => 'Name of New Folder',
3114: t_mnf => 'New Folder',
3115: p_mnp => 'Name of New Page',
3116: t_mnp => 'New Page',
3117: p_mxu => 'Title for the Uploaded Score',
3118: p_msp => 'Title for the Page',
3119: p_msb => 'Title for the Problem',
3120: p_mdb => 'Title for the Drop Box',
3121: p_mbb => 'Title for the Bulletin Board',
3122: p_mab => "Enter user:domain for User's 'About Me' Page",
3123: p_mab2 => "About [_99]",
3124: p_mab_alrt1 => 'Not a valid user:domain',
3125: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
3126: p_chn => 'New Title',
3127: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
3128: p_rmr2a => 'Remove[_99]',
3129: p_rmr2b => '?[_99]',
3130: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
3131: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
3132: p_ctr2a => 'Cut[_98]',
3133: p_ctr2b => '?[_98]'
3134: );
3135:
3136: return <<ENDNEWSCRIPT;
3137: function makenewfolder(targetform,folderseq) {
3138: var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
3139: if (foldername) {
3140: targetform.importdetail.value=escape(foldername)+"="+folderseq;
3141: targetform.submit();
3142: }
3143: }
3144:
3145: function makenewpage(targetform,folderseq) {
3146: var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
3147: if (pagename) {
3148: targetform.importdetail.value=escape(pagename)+"="+folderseq;
3149: targetform.submit();
3150: }
3151: }
3152:
3153: function makenewext(targetname) {
3154: this.document.forms.extimport.useform.value=targetname;
3155: this.document.forms.extimport.title.value='';
3156: this.document.forms.extimport.url.value='';
3157: this.document.forms.extimport.residx.value='';
3158: window.open('/adm/rat/extpickframe.html');
3159: }
3160:
3161: function edittext(targetname,residx,title,url) {
3162: this.document.forms.extimport.useform.value=targetname;
3163: this.document.forms.extimport.residx.value=residx;
3164: this.document.forms.extimport.url.value=url;
3165: this.document.forms.extimport.title.value=title;
3166: window.open('/adm/rat/extpickframe.html');
3167: }
3168:
3169: function makeexamupload() {
3170: var title=prompt('$lt{"p_mxu"}');
3171: if (title) {
3172: this.document.forms.newexamupload.importdetail.value=
3173: escape(title)+'=/res/lib/templates/examupload.problem';
3174: this.document.forms.newexamupload.submit();
3175: }
3176: }
3177:
3178: function makesmppage() {
3179: var title=prompt('$lt{"p_msp"}');
3180: if (title) {
3181: this.document.forms.newsmppg.importdetail.value=
3182: escape(title)+'=/adm/$udom/$uname/$now/smppg';
3183: this.document.forms.newsmppg.submit();
3184: }
3185: }
3186:
3187: function makesmpproblem() {
3188: var title=prompt('$lt{"p_msb"}');
3189: if (title) {
3190: this.document.forms.newsmpproblem.importdetail.value=
3191: escape(title)+'=/res/lib/templates/simpleproblem.problem';
3192: this.document.forms.newsmpproblem.submit();
3193: }
3194: }
3195:
3196: function makedropbox() {
3197: var title=prompt('$lt{"p_mdb"}');
3198: if (title) {
3199: this.document.forms.newdropbox.importdetail.value=
3200: escape(title)+'=/res/lib/templates/DropBox.problem';
3201: this.document.forms.newdropbox.submit();
3202: }
3203: }
3204:
3205: function makebulboard() {
3206: var title=prompt('$lt{"p_mbb"}');
3207: if (title) {
3208: this.document.forms.newbul.importdetail.value=
3209: escape(title)+'=/adm/$udom/$uname/$now/bulletinboard';
3210: this.document.forms.newbul.submit();
3211: }
3212: }
3213:
3214: function makeabout() {
3215: var user=prompt("$lt{'p_mab'}");
3216: if (user) {
3217: var comp=new Array();
3218: comp=user.split(':');
3219: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
3220: if ((comp[0]) && (comp[1])) {
3221: this.document.forms.newaboutsomeone.importdetail.value=
3222: '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
3223: this.document.forms.newaboutsomeone.submit();
3224: } else {
3225: alert("$lt{'p_mab_alrt1'}");
3226: }
3227: } else {
3228: alert("$lt{'p_mab_alrt2'}");
3229: }
3230: }
3231: }
3232:
3233: function makeims() {
3234: var caller = document.forms.ims.folder.value;
3235: var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
3236: newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
3237: newWindow.location.href = newlocation;
3238: }
3239:
3240:
3241: function finishpick() {
3242: var title=this.document.forms.extimport.title.value;
3243: var url=this.document.forms.extimport.url.value;
3244: var form=this.document.forms.extimport.useform.value;
3245: var residx=this.document.forms.extimport.residx.value;
3246: eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();');
3247: }
3248:
3249: function changename(folderpath,index,oldtitle,container,pagesymb) {
3250: var title=prompt('$lt{"p_chn"}',oldtitle);
3251: if (title) {
3252: this.document.forms.renameform.markcopy.value=-1;
3253: this.document.forms.renameform.title.value=title;
3254: this.document.forms.renameform.cmd.value='rename_'+index;
3255: if (container == 'sequence') {
3256: this.document.forms.renameform.folderpath.value=folderpath;
3257: }
3258: if (container == 'page') {
3259: this.document.forms.renameform.pagepath.value=folderpath;
3260: this.document.forms.renameform.pagesymb.value=pagesymb;
3261: }
3262: this.document.forms.renameform.submit();
3263: }
3264: }
3265:
3266: function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) {
3267: if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
3268: this.document.forms.renameform.markcopy.value=-1;
3269: this.document.forms.renameform.cmd.value='del_'+index;
3270: if (container == 'sequence') {
3271: this.document.forms.renameform.folderpath.value=folderpath;
3272: }
3273: if (container == 'page') {
3274: this.document.forms.renameform.pagepath.value=folderpath;
3275: this.document.forms.renameform.pagesymb.value=pagesymb;
3276: }
3277: this.document.forms.renameform.submit();
3278: }
3279: }
3280:
3281: function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) {
3282: if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
3283: this.document.forms.renameform.cmd.value='cut_'+index;
3284: this.document.forms.renameform.markcopy.value=index;
3285: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
3286: if (container == 'sequence') {
3287: this.document.forms.renameform.folderpath.value=folderpath;
3288: }
3289: if (container == 'page') {
3290: this.document.forms.renameform.pagepath.value=folderpath;
3291: this.document.forms.renameform.pagesymb.value=pagesymb;
3292: }
3293: this.document.forms.renameform.submit();
3294: }
3295: }
3296:
3297: function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) {
3298: this.document.forms.renameform.markcopy.value=index;
3299: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
3300: if (container == 'sequence') {
3301: this.document.forms.renameform.folderpath.value=folderpath;
3302: }
3303: if (container == 'page') {
3304: this.document.forms.renameform.pagepath.value=folderpath;
3305: this.document.forms.renameform.pagesymb.value=pagesymb;
3306: }
3307: this.document.forms.renameform.submit();
3308: }
3309:
3310: ENDNEWSCRIPT
3311: }
3312: 1;
3313: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>