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