Annotation of loncom/interface/londocs.pm, revision 1.576
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.576 ! raeburn 4: # $Id: londocs.pm,v 1.575 2013/12/31 13:38:31 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: package Apache::londocs;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use Apache::imsexport;
34: use Apache::lonnet;
35: use Apache::loncommon;
1.383 tempelho 36: use Apache::lonhtmlcommon;
1.329 droeschl 37: use LONCAPA::map();
38: use Apache::lonratedt();
39: use Apache::lonxml;
40: use Apache::lonclonecourse;
41: use Apache::lonnavmaps;
1.472 raeburn 42: use Apache::lonnavdisplay();
1.510 raeburn 43: use Apache::lonextresedit();
1.567 raeburn 44: use Apache::lontemplate();
45: use Apache::lonsimplepage();
1.329 droeschl 46: use HTML::Entities;
1.488 raeburn 47: use HTML::TokeParser;
1.329 droeschl 48: use GDBM_File;
49: use Apache::lonlocal;
50: use Cwd;
51: use LONCAPA qw(:DEFAULT :match);
52:
53: my $iconpath;
54:
55: my %hash;
56:
57: my $hashtied;
58: my %alreadyseen=();
59:
60: my $hadchanges;
1.557 raeburn 61: my $suppchanges;
1.329 droeschl 62:
63:
64: my %help=();
65:
66:
67: sub mapread {
68: my ($coursenum,$coursedom,$map)=@_;
69: return
70: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
71: $map);
72: }
73:
74: sub storemap {
1.492 raeburn 75: my ($coursenum,$coursedom,$map,$contentchg)=@_;
76: my $report;
77: if (($contentchg) && ($map =~ /^default/)) {
78: $report = 1;
79: }
1.329 droeschl 80: my ($outtext,$errtext)=
81: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.492 raeburn 82: $map,1,$report);
1.329 droeschl 83: if ($errtext) { return ($errtext,2); }
1.364 bisitz 84:
1.557 raeburn 85: if ($map =~ /^default/) {
86: $hadchanges=1;
87: } else {
88: $suppchanges=1;
89: }
1.329 droeschl 90: return ($errtext,0);
91: }
92:
93:
94:
95: sub authorhosts {
96: my %outhash=();
97: my $home=0;
98: my $other=0;
99: foreach my $key (keys(%env)) {
100: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
101: my $role=$1;
102: my $realm=$2;
103: my ($start,$end)=split(/\./,$env{$key});
104: if (($start) && ($start>time)) { next; }
105: if (($end) && (time>$end)) { next; }
106: my ($ca,$cd);
107: if ($1 eq 'au') {
108: $ca=$env{'user.name'};
109: $cd=$env{'user.domain'};
110: } else {
111: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
112: }
113: my $allowed=0;
114: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
115: my @ids=&Apache::lonnet::current_machine_ids();
1.484 raeburn 116: foreach my $id (@ids) {
117: if ($id eq $myhome) {
118: $allowed=1;
119: last;
120: }
121: }
1.329 droeschl 122: if ($allowed) {
123: $home++;
1.484 raeburn 124: $outhash{'home_'.$ca.':'.$cd}=1;
1.329 droeschl 125: } else {
1.484 raeburn 126: $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329 droeschl 127: $other++;
128: }
129: }
130: }
131: return ($home,$other,%outhash);
132: }
133:
134:
135: sub clean {
136: my ($title)=@_;
137: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 138: return $title;
1.329 droeschl 139: }
140:
141:
142:
143: sub dumpcourse {
144: my ($r) = @_;
1.408 raeburn 145: my $crstype = &Apache::loncommon::course_type();
1.567 raeburn 146: my ($starthash,$js);
147: unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
148: $js = <<"ENDJS";
149: <script type="text/javascript">
150: // <![CDATA[
151:
152: function hide_searching() {
153: if (document.getElementById('searching')) {
154: document.getElementById('searching').style.display = 'none';
155: }
156: return;
157: }
158:
159: // ]]>
160: </script>
161: ENDJS
162: $starthash = {
163: add_entries => {'onload' => "hide_searching();"},
164: };
165: }
1.568 raeburn 166: $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
167: &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
1.484 raeburn 168: $r->print(&startContentScreen('tools'));
1.329 droeschl 169: my ($home,$other,%outhash)=&authorhosts();
1.484 raeburn 170: unless ($home) {
171: $r->print(&endContentScreen());
172: return '';
173: }
1.329 droeschl 174: my $origcrsid=$env{'request.course.id'};
175: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
176: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
177: # Do the dumping
1.484 raeburn 178: unless ($outhash{'home_'.$env{'form.authorspace'}}) {
179: $r->print(&endContentScreen());
180: return '';
181: }
1.531 raeburn 182: my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
1.329 droeschl 183: $r->print('<h3>'.&mt('Copying Files').'</h3>');
184: my $title=$env{'form.authorfolder'};
185: $title=&clean($title);
1.567 raeburn 186: my ($navmap,$errormsg) =
187: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
188: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
189: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
190: my (%maps,%resources,%titles);
191: if (!ref($navmap)) {
192: $r->print($errormsg.
193: &endContentScreen());
194: return '';
195: } else {
196: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
197: 'dumpdocs',$cdom,$cnum);
1.329 droeschl 198: }
1.567 raeburn 199: my @todump = &Apache::loncommon::get_env_multiple('form.archive');
200: my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
201: %newcontent,%has_simpleprobs);
202: foreach my $item (sort {$a <=> $b} (@todump)) {
203: my $name = $env{'form.namefor_'.$item};
204: if ($resources{$item}) {
205: my ($map,$id,$res) = &Apache::lonnet::decode_symb($resources{$item});
206: if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
207: $tocopy{$1} = $name;
208: $display{$item} = $1;
209: $lookup{$1} = $item;
210: } elsif ($res eq 'lib/templates/simpleproblem.problem') {
211: $simpleproblems{$item} = {
212: symb => $resources{$item},
213: name => $name,
214: };
215: $display{$item} = 'simpleproblem_'.$name;
216: if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(.+)$}) {
217: $has_simpleprobs{$1}{$id} = $item;
218: }
219: } elsif ($res =~ m{^adm/$match_domain/$match_username/(\d+)/smppg}) {
220: my $marker = $1;
221: my $db_name = &Apache::lonsimplepage::get_db_name($res,$marker,$cdom,$cnum);
222: $simplepages{$item} = {
223: res => $res,
224: title => $titles{$item},
225: db => $db_name,
226: marker => $marker,
227: symb => $resources{$item},
228: name => $name,
229: };
230: $display{$item} = '/'.$res;
231: }
232: } elsif ($maps{$item}) {
233: if ($maps{$item} =~ m{^\Quploaded/$cdom/$cnum/\E((?:default|supplemental)_\d+\.(?:sequence|page))$}) {
234: $tocopy{$1} = $name;
235: $display{$item} = $1;
236: $lookup{$1} = $item;
237: }
238: } else {
239: next;
240: }
241: }
1.329 droeschl 242: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
243: $crs=~s/\_/\//g;
1.567 raeburn 244: my $mm = new File::MMagic;
245: my $prefix = "/uploaded/$cdom/$cnum/";
246: %replacehash = %tocopy;
247: foreach my $item (sort(keys(%simpleproblems))) {
248: my $content = &Apache::imsexport::simpleproblem($simpleproblems{$item}{'symb'});
249: $newcontent{$display{$item}} = $content;
250: }
251: my $gateway = Apache::lonhtmlgateway->new('web');
252: foreach my $item (sort(keys(%simplepages))) {
253: if (ref($simplepages{$item}) eq 'HASH') {
254: my $pagetitle = $simplepages{$item}{'title'};
255: my %fields = &Apache::lonnet::dump($simplepages{$item}{'db'},$cdom,$cnum);
256: my %contents;
257: foreach my $field (keys(%fields)) {
258: if ($field =~ /^(?:aaa|bbb|ccc)_(\w+)$/) {
259: my $name = $1;
260: my $msg = $fields{$field};
261: if ($name eq 'webreferences') {
262: if ($msg =~ m{^https?://}) {
263: $contents{$name} = '<a href="'.$msg.'"><tt>'.$msg.'</tt></a>';
264: }
265: } else {
266: $msg = &Encode::decode('utf8',$msg);
267: $msg = $gateway->process_outgoing_html($msg,1);
268: $contents{$name} = $msg;
269: }
270: } elsif ($field eq 'uploaded.photourl') {
271: my $marker = $simplepages{$item}{marker};
272: if ($fields{$field} =~ m{^\Q$prefix\E(simplepage/$marker/.+)$}) {
273: my $filepath = $1;
274: my ($relpath,$fname) = ($filepath =~ m{^(.+/)([^/]+)$});
275: if ($fname ne '') {
276: $fname=~s/\.(\w+)$//;
277: my $ext=$1;
278: $fname = &clean($fname);
279: $fname.='.'.$ext;
280: $contents{image} = '<img src="'.$relpath.$fname.'" alt="Image" />';
281: $replacehash{$filepath} = $relpath.$fname;
282: $deps{$item}{$filepath} = 1;
283: }
284: }
285: }
286: }
287: $replacehash{'/'.$simplepages{$item}{'res'}} = $simplepages{$item}{'name'};
288: $lookup{'/'.$simplepages{$item}{'res'}} = $item;
289: my $content = '
290: <html>
291: <head>
292: <title>'.$pagetitle.'</title>
293: </head>
294: <body bgcolor="#ffffff">';
295: if ($contents{title}) {
296: $content .= "\n".'<h2>'.$contents{title}.'</h2>';
297: }
298: if ($contents{image}) {
299: $content .= "\n".$contents{image};
300: }
301: if ($contents{content}) {
302: $content .= '
303: <div class="LC_Box">
304: <h4 class="LC_hcell">Content</h4>'.
305: $contents{content}.'
306: </div>';
307: }
308: if ($contents{webreferences}) {
309: $content .= '
310: <div class="LC_Box">
311: <h4 class="LC_hcell">Web References</h4>'.
312: $contents{webreferences}.'
313: </div>';
314: }
315: $content .= '
316: </body>
317: </html>
318: ';
319: $newcontent{'/'.$simplepages{$item}{res}} = $content;
320: }
321: }
322: foreach my $item (keys(%tocopy)) {
323: unless ($item=~/\.(sequence|page)$/) {
324: my $currurlpath = $prefix.$item;
325: my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
326: &recurse_html($mm,$prefix,$currdirpath,$currurlpath,$item,$lookup{$item},\%replacehash,\%deps);
327: }
328: }
329: foreach my $num (sort {$a <=> $b} (@todump)) {
330: my $src = $display{$num};
331: next if ($src eq '');
332: my @needcopy = ();
333: if ($replacehash{$src}) {
334: push(@needcopy,$src);
335: if (ref($deps{$num}) eq 'HASH') {
336: foreach my $dep (sort(keys(%{$deps{$num}}))) {
337: if ($replacehash{$dep}) {
338: push(@needcopy,$dep);
339: }
340: }
341: }
342: } elsif ($src =~ /^simpleproblem_/) {
343: push(@needcopy,$src);
344: }
345: next if (@needcopy == 0);
346: my ($result,$depresult);
347: for (my $i=0; $i<@needcopy; $i++) {
348: my $item = $needcopy[$i];
349: my $newfilename;
350: if ($simpleproblems{$num}) {
351: $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
352: } else {
353: $newfilename=$title.'/'.$replacehash{$item};
354: }
355: $newfilename=~s/\.(\w+)$//;
356: my $ext=$1;
357: $newfilename=&clean($newfilename);
358: $newfilename.='.'.$ext;
359: my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});
360: if ($newrelpath ne $replacehash{$item}) {
361: $replacehash{$item} = $newrelpath;
362: }
363: my @dirs=split(/\//,$newfilename);
364: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
365: my $makepath=$path;
366: my $fail;
367: my $origin;
368: for (my $i=0;$i<$#dirs;$i++) {
369: $makepath.='/'.$dirs[$i];
370: unless (-e $makepath) {
371: unless(mkdir($makepath,0755)) {
372: $fail = &mt('Directory creation failed.');
373: }
374: }
375: }
376: if ($i == 0) {
377: $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
378: } else {
379: $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
380: '<span class="LC_fontsize_small" style="font-weight: bold;">'.
381: &mt('(dependency)').'</span>: ';
382: }
383: if (-e $path.'/'.$newfilename) {
384: $fail = &mt('Destination already exists -- not overwriting.');
385: } else {
386: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
387: if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
388: ($item =~ /^simpleproblem_/)) {
389: print $fh $newcontent{$item};
390: } else {
391: my $fileloc = &Apache::lonnet::filelocation('',$prefix.$item);
392: if (-e $fileloc) {
393: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
394: if ((($1 eq 'sequence') || ($1 eq 'page')) &&
395: (ref($has_simpleprobs{$item}) eq 'HASH')) {
396: my %changes = %{$has_simpleprobs{$item}};
397: my $content = &Apache::lonclonecourse::rewritefile(
398: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
399: (%replacehash,$crs => '')
400: );
401: my $updatedcontent = '';
402: my $parser = HTML::TokeParser->new(\$content);
403: $parser->attr_encoded(1);
404: while (my $token = $parser->get_token) {
405: if ($token->[0] eq 'S') {
406: if (($token->[1] eq 'resource') &&
407: ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&
408: ($changes{$token->[2]->{'id'}})) {
409: my $id = $token->[2]->{'id'};
410: $updatedcontent .= '<'.$token->[1];
411: foreach my $attrib (@{$token->[3]}) {
412: next unless ($attrib =~ /^(src|type|title|id)$/);
413: if ($attrib eq 'src') {
414: my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);
415: if ($file) {
416: $updatedcontent .= ' '.$attrib.'="'.$file.'"';
417: } else {
418: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
419: }
420: } else {
421: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
422: }
423: }
424: $updatedcontent .= ' />'."\n";
425: } else {
426: $updatedcontent .= $token->[4]."\n";
427: }
428: } else {
429: $updatedcontent .= $token->[2];
430: }
431: }
432: print $fh $updatedcontent;
433: } else {
434: print $fh &Apache::lonclonecourse::rewritefile(
435: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
436: (%replacehash,$crs => '')
437: );
438: }
439: } else {
440: print $fh
441: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
442: }
443: } else {
444: $fail = &mt('Source does not exist.');
445: }
446: }
447: $fh->close();
448: } else {
449: $fail = &mt('Could not write to destination.');
450: }
451: }
452: my $text;
453: if ($fail) {
454: $text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>';
455: } else {
456: $text = '<span class="LC_success">'.&mt('ok').'</span>';
457: }
458: if ($i == 0) {
459: $result .= $text;
460: } else {
461: $depresult .= $text.'</li>';
462: }
463: }
464: $r->print($result);
465: if ($depresult) {
466: $r->print('<ul>'.$depresult.'</ul>');
467: }
468: }
469: } else {
470: my ($navmap,$errormsg) =
471: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
472: if (!ref($navmap)) {
473: $r->print($errormsg);
474: } else {
475: $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
476: $r->rflush();
477: my ($preamble,$formname);
478: $formname = 'dumpdoc';
479: unless ($home==1) {
480: $preamble = '<div class="LC_left_float">'.
481: '<fieldset><legend>'.
482: &mt('Select the Authoring Space').
483: '</legend><select name="authorspace">';
1.329 droeschl 484: }
1.567 raeburn 485: my @orderspaces = ();
486: foreach my $key (sort(keys(%outhash))) {
487: if ($key=~/^home_(.+)$/) {
488: if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
489: unshift(@orderspaces,$1);
490: } else {
491: push(@orderspaces,$1);
492: }
493: }
494: }
1.569 raeburn 495: if ($home>1) {
496: $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';
497: }
1.567 raeburn 498: foreach my $user (@orderspaces) {
1.329 droeschl 499: if ($home==1) {
1.567 raeburn 500: $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
1.329 droeschl 501: } else {
1.567 raeburn 502: $preamble .= '<option value="'.$user.'">'.$user.' - '.
503: &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
504: }
1.329 droeschl 505: }
1.567 raeburn 506: unless ($home==1) {
507: $preamble .= '</select></fieldset></div>'."\n";
1.329 droeschl 508: }
1.567 raeburn 509: my $title=$origcrsdata{'description'};
510: $title=~s/[\/\s]+/\_/gs;
1.329 droeschl 511: $title=&clean($title);
1.567 raeburn 512: $preamble .= '<div class="LC_left_float">'.
513: '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
514: '<input type="text" size="50" name="authorfolder" value="'.
515: $title.'" />'.
516: '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
517: my %uploadedfiles;
518: &tiehash();
519: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
520: my ($ext)=($file=~/\.(\w+)$/);
521: # FIXME Check supplemental here
522: my $title=$hash{'title_'.$hash{
523: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
524: if (!$title) {
525: $title=$file;
526: } else {
527: $title=~s|/|_|g;
528: }
529: $title=~s/\.(\w+)$//;
530: $title=&clean($title);
531: $title.='.'.$ext;
532: # $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
533: $uploadedfiles{$file} = $title;
534: }
535: &untiehash();
536: $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
537: undef,undef,$preamble,$home,\%uploadedfiles));
538: }
1.329 droeschl 539: }
1.484 raeburn 540: $r->print(&endContentScreen());
1.329 droeschl 541: }
542:
1.567 raeburn 543: sub recurse_html {
544: my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
545: return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
546: my (%allfiles,%codebase);
547: if (&Apache::lonnet::extract_embedded_items($currdirpath,\%allfiles,\%codebase) eq 'ok') {
548: if (keys(%allfiles)) {
549: foreach my $dependency (keys(%allfiles)) {
550: next if (($dependency =~ m{^/(res|adm)/}) || ($dependency =~ m{^https?://}));
551: my ($depurl,$relfile,$newcontainer);
552: if ($dependency =~ m{^/}) {
553: if ($dependency =~ m{^\Q$currurlpath/\E(.+)$}) {
554: $relfile = $1;
555: if ($dependency =~ m{^\Q$prefix\E(.+)$}) {
556: $newcontainer = $1;
557: next if ($replacehash->{$newcontainer});
558: }
559: $depurl = $dependency;
560: } else {
561: next;
562: }
563: } else {
564: $relfile = $dependency;
565: $depurl = $currurlpath;
566: $depurl =~ s{[^/]+$}{};
567: $depurl .= $dependency;
568: ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});
569: }
570: next if ($relfile eq '');
571: my $newname = $replacehash->{$container};
572: $newname =~ s{[^/]+$}{};
573: $replacehash->{$newcontainer} = $newname.$relfile;
574: $deps->{$item}{$newcontainer} = 1;
575: my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});
576: my $depfile = &Apache::lonnet::filelocation('',$depurl);
577: my $type = $mm->checktype_filename($depfile);
578: if ($type eq 'text/html') {
579: &recurse_html($mm,$prefix,$depfile,$newurlpath,$newcontainer,$item,$replacehash,$deps);
580: }
581: }
582: }
583: }
584: return;
585: }
586:
1.329 droeschl 587: sub group_import {
588: my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
1.529 raeburn 589: my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
590: %removeparam,$importuploaded,$fixuperrors);
591: $allmaps = {};
1.329 droeschl 592: while (@files) {
593: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 594: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 595: && ($caller eq 'londocs')
596: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 597:
1.329 droeschl 598: my $errtext = '';
599: my $fatal = 0;
600: my $newmapstr = '<map>'."\n".
601: '<resource id="1" src="" type="start"></resource>'."\n".
602: '<link from="1" to="2" index="1"></link>'."\n".
603: '<resource id="2" src="" type="finish"></resource>'."\n".
604: '</map>';
605: $env{'form.output'}=$newmapstr;
606: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
607: 'output',$1.$2);
1.534 raeburn 608: if ($result !~ m{^/uploaded/}) {
1.329 droeschl 609: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
610: $fatal = 2;
611: }
612: if ($fatal) {
613: return ($errtext,$fatal);
614: }
615: }
616: if ($url) {
1.529 raeburn 617: if (($caller eq 'londocs') &&
618: ($folder =~ /^default/)) {
1.534 raeburn 619: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.529 raeburn 620: my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
621: my $cid = $coursedom.'_'.$coursenum;
622: $allmaps =
623: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
624: $chome,$cid);
625: $donechk = 1;
626: }
627: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
628: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,
629: \%addedmaps,\%hierarchy,\%titles,$allmaps);
630: $importuploaded = 1;
631: } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
632: next if ($allmaps->{$url});
633: }
634: }
1.344 bisitz 635: if (!$residx
1.329 droeschl 636: || defined($LONCAPA::map::zombies[$residx])) {
637: $residx = &LONCAPA::map::getresidx($url,$residx);
638: push(@LONCAPA::map::order, $residx);
639: }
640: my $ext = 'false';
641: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
642: $name = &LONCAPA::map::qtunescape($name);
1.534 raeburn 643: if ($name eq '') {
1.538 raeburn 644: $name = &LONCAPA::map::qtunescape(&mt('Web Page'));
1.534 raeburn 645: }
646: if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
647: my $filepath = $1;
648: my $fname = $name;
649: if ($fname =~ /^\W+$/) {
650: $fname = 'web';
651: } else {
652: $fname =~ s/\W/_/g;
653: }
654: if (length($fname > 15)) {
655: $fname = substr($fname,0,14);
656: }
657: my $initialtext = &mt('Replace with your own content.');
658: my $newhtml = <<END;
1.545 raeburn 659: <html>
1.534 raeburn 660: <head>
661: <title>$name</title>
662: </head>
663: <body bgcolor="#ffffff">
664: $initialtext
665: </body>
666: </html>
667: END
668: $env{'form.output'}=$newhtml;
669: my $result =
670: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
671: 'output',
672: "$filepath/$residx/$fname.html");
673: if ($result =~ m{^/uploaded/}) {
674: $url = $result;
675: if ($filepath =~ /^supplemental/) {
676: $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
677: $env{'user.domain'}.'___&&&___'.$name;
678: }
679: } else {
680: return (&mt('Failed to save new web page.'),1);
681: }
682: }
1.538 raeburn 683: $url = &LONCAPA::map::qtunescape($url);
1.344 bisitz 684: $LONCAPA::map::resources[$residx] =
1.329 droeschl 685: join(':', ($name, $url, $ext, 'normal', 'res'));
686: }
687: }
1.529 raeburn 688: if ($importuploaded) {
689: my %import_errors;
690: my %updated = (
691: removefrommap => \%removefrommap,
692: removeparam => \%removeparam,
693: );
1.533 raeburn 694: my ($result,$msgsarray,$lockerror) =
695: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.529 raeburn 696: if (keys(%import_errors) > 0) {
1.530 raeburn 697: $fixuperrors =
1.529 raeburn 698: '<p span class="LC_warning">'."\n".
699: &mt('The following files are either dependencies of a web page or references within a folder and/or composite page for which errors occurred during import:')."\n".
700: '<ul>'."\n";
701: foreach my $key (sort(keys(%import_errors))) {
702: $fixuperrors .= '<li>'.$key.'</li>'."\n";
703: }
704: $fixuperrors .= '</ul></p>'."\n";
705: }
1.533 raeburn 706: if (ref($msgsarray) eq 'ARRAY') {
707: if (@{$msgsarray} > 0) {
708: $fixuperrors .= '<p class="LC_info">'.
709: join('<br />',@{$msgsarray}).
710: '</p>';
711: }
712: }
713: if ($lockerror) {
714: $fixuperrors .= '<p class="LC_error">'.
715: $lockerror.
716: '</p>';
717: }
1.529 raeburn 718: }
719: my ($errtext,$fatal) =
720: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
1.557 raeburn 721: unless ($fatal) {
722: if ($folder =~ /^supplemental/) {
723: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
1.561 raeburn 724: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
725: $folder.'.'.$container);
1.557 raeburn 726: }
727: }
1.529 raeburn 728: return ($errtext,$fatal,$fixuperrors);
1.329 droeschl 729: }
730:
731: sub log_docs {
1.494 raeburn 732: return &Apache::lonnet::write_log('course','docslog',@_);
1.329 droeschl 733: }
734:
735: {
736: my @oldresources=();
737: my @oldorder=();
738: my $parmidx;
739: my %parmaction=();
740: my %parmvalue=();
741: my $changedflag;
742:
743: sub snapshotbefore {
744: @oldresources=@LONCAPA::map::resources;
745: @oldorder=@LONCAPA::map::order;
746: $parmidx=undef;
747: %parmaction=();
748: %parmvalue=();
749: $changedflag=0;
750: }
751:
752: sub remember_parms {
753: my ($idx,$parameter,$action,$value)=@_;
754: $parmidx=$idx;
755: $parmaction{$parameter}=$action;
756: $parmvalue{$parameter}=$value;
757: $changedflag=1;
758: }
759:
760: sub log_differences {
761: my ($plain)=@_;
762: my %storehash=('folder' => $plain,
763: 'currentfolder' => $env{'form.folder'});
764: if ($parmidx) {
765: $storehash{'parameter_res'}=$oldresources[$parmidx];
766: foreach my $parm (keys(%parmaction)) {
767: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
768: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
769: }
770: }
771: my $maxidx=$#oldresources;
772: if ($#LONCAPA::map::resources>$#oldresources) {
773: $maxidx=$#LONCAPA::map::resources;
774: }
775: for (my $idx=0; $idx<=$maxidx; $idx++) {
776: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
777: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
778: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
779: $changedflag=1;
780: }
781: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
782: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
783: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
784: $changedflag=1;
785: }
786: }
787: $storehash{'maxidx'}=$maxidx;
788: if ($changedflag) { &log_docs(\%storehash); }
789: }
790: }
791:
792: sub docs_change_log {
1.484 raeburn 793: my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath)=@_;
1.486 raeburn 794: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.483 raeburn 795: my $js = '<script type="text/javascript">'."\n".
796: '// <![CDATA['."\n".
797: &Apache::loncommon::display_filter_js('docslog')."\n".
1.486 raeburn 798: &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag)."\n".
1.483 raeburn 799: &history_tab_js()."\n".
1.484 raeburn 800: &Apache::lonratedt::editscript('simple')."\n".
1.483 raeburn 801: '// ]]>'."\n".
802: '</script>'."\n";
1.484 raeburn 803: $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
804: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
1.489 raeburn 805: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 806: my %orderhash;
807: my $container='sequence';
808: my $pathitem;
1.519 raeburn 809: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 810: $container='page';
811: }
1.519 raeburn 812: my $folderpath=$env{'form.folderpath'};
813: if ($folderpath eq '') {
1.548 raeburn 814: $folderpath = 'default&'.&escape(&mt('Main Content').':::::');
1.519 raeburn 815: }
816: $pathitem = '<input type="hidden" name="folderpath" value="'.
817: &HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 818: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
819: my $jumpto = $readfile;
820: $jumpto =~ s{^/}{};
821: my $tid = 1;
1.489 raeburn 822: if ($supplementalflag) {
823: $tid = 2;
824: }
1.509 raeburn 825: my ($breadcrumbtrail) =
826: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1.484 raeburn 827: $r->print($breadcrumbtrail.
828: &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
829: $readfile));
1.329 droeschl 830: my %docslog=&Apache::lonnet::dump('nohist_docslog',
831: $env{'course.'.$env{'request.course.id'}.'.domain'},
832: $env{'course.'.$env{'request.course.id'}.'.num'});
833:
834: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
835:
836: my %saveable_parameters = ('show' => 'scalar',);
837: &Apache::loncommon::store_course_settings('docs_log',
838: \%saveable_parameters);
839: &Apache::loncommon::restore_course_settings('docs_log',
840: \%saveable_parameters);
841: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452 www 842: # FIXME: internationalization seems wrong here
1.329 droeschl 843: my %lt=('hiddenresource' => 'Resources hidden',
844: 'encrypturl' => 'URL hidden',
845: 'randompick' => 'Randomly pick',
846: 'randomorder' => 'Randomly ordered',
847: 'set' => 'set to',
848: 'del' => 'deleted');
1.484 raeburn 849: my $filter = &Apache::loncommon::display_filter('docslog')."\n".
850: $pathitem."\n".
851: '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
852: (' 'x2).'<input type="submit" value="'.&mt('Display').'" />';
853: $r->print('<div class="LC_left_float">'.
854: '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
855: &makedocslogform($filter,1).
856: '</fieldset></div><br clear="all" />');
1.329 droeschl 857: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
858: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
859: &mt('After').'</th>'.
860: &Apache::loncommon::end_data_table_header_row());
861: my $shown=0;
862: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
863: if ($env{'form.displayfilter'} eq 'currentfolder') {
864: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
865: }
866: my @changes=keys(%{$docslog{$id}{'logentry'}});
867: if ($env{'form.displayfilter'} eq 'containing') {
868: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
869: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
870: foreach my $key (@changes) {
871: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
872: }
1.344 bisitz 873: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 874: }
875: my $count = 0;
876: my $time =
877: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
878: my $plainname =
879: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
880: $docslog{$id}{'exe_udom'});
881: my $about_me_link =
882: &Apache::loncommon::aboutmewrapper($plainname,
883: $docslog{$id}{'exe_uname'},
884: $docslog{$id}{'exe_udom'});
885: my $send_msg_link='';
886: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
887: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
888: $send_msg_link ='<br />'.
889: &Apache::loncommon::messagewrapper(&mt('Send message'),
890: $docslog{$id}{'exe_uname'},
891: $docslog{$id}{'exe_udom'});
892: }
893: $r->print(&Apache::loncommon::start_data_table_row());
894: $r->print('<td>'.$time.'</td>
895: <td>'.$about_me_link.
896: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
897: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
898: $send_msg_link.'</td><td>'.
899: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1.488 raeburn 900: my $is_supp = 0;
901: if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) {
902: $is_supp = 1;
903: }
1.329 droeschl 904: # Before
905: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
906: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
907: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
908: if ($oldname ne $newname) {
1.488 raeburn 909: my $shown = &LONCAPA::map::qtescape($oldname);
910: if ($is_supp) {
911: $shown = &Apache::loncommon::parse_supplemental_title($shown);
912: }
913: $r->print($shown);
1.329 droeschl 914: }
915: }
916: $r->print('<ul>');
917: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
918: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1.488 raeburn 919: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]);
920: if ($is_supp) {
921: $shown = &Apache::loncommon::parse_supplemental_title($shown);
922: }
923: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 924: }
925: }
926: $r->print('</ul>');
927: # After
928: $r->print('</td><td>');
929:
930: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
931: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
932: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
933: if ($oldname ne '' && $oldname ne $newname) {
1.488 raeburn 934: my $shown = &LONCAPA::map::qtescape($newname);
935: if ($is_supp) {
936: $shown = &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($newname));
937: }
938: $r->print($shown);
1.329 droeschl 939: }
1.364 bisitz 940: }
1.329 droeschl 941: $r->print('<ul>');
942: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
943: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1.488 raeburn 944: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]);
945: if ($is_supp) {
946: $shown = &Apache::loncommon::parse_supplemental_title($shown);
947: }
948: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 949: }
950: }
951: $r->print('</ul>');
952: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
953: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
954: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
955: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452 www 956: # FIXME: internationalization seems wrong here
1.329 droeschl 957: $r->print('<li>'.
958: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
959: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
960: .'</li>');
961: }
962: }
963: $r->print('</ul>');
964: }
965: # End
966: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
967: $shown++;
968: if (!($env{'form.show'} eq &mt('all')
969: || $shown<=$env{'form.show'})) { last; }
970: }
1.484 raeburn 971: $r->print(&Apache::loncommon::end_data_table()."\n".
972: &makesimpleeditform($pathitem)."\n".
973: '</div></div>');
974: $r->print(&endContentScreen());
1.329 droeschl 975: }
976:
977: sub update_paste_buffer {
1.492 raeburn 978: my ($coursenum,$coursedom,$folder) = @_;
1.538 raeburn 979: my (@possibles,%removals,%cuts);
980: if ($env{'form.multiremove'}) {
981: $env{'form.multiremove'} =~ s/,$//;
982: map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});
983: }
984: if (($env{'form.multicopy'}) || ($env{'form.multicut'})) {
985: if ($env{'form.multicut'}) {
986: $env{'form.multicut'} =~ s/,$//;
987: foreach my $item (split(/,/,$env{'form.multicut'})) {
988: unless ($removals{$item}) {
989: $cuts{$item} = 1;
990: push(@possibles,$item.':cut');
991: }
992: }
993: }
994: if ($env{'form.multicopy'}) {
995: $env{'form.multicopy'} =~ s/,$//;
996: foreach my $item (split(/,/,$env{'form.multicopy'})) {
997: unless ($removals{$item} || $cuts{$item}) {
998: push(@possibles,$item.':copy');
999: }
1000: }
1001: }
1002: } elsif ($env{'form.markcopy'}) {
1003: @possibles = split(/,/,$env{'form.markcopy'});
1004: }
1.329 droeschl 1005:
1.538 raeburn 1006: return if (@possibles == 0);
1.329 droeschl 1007: return if (!defined($env{'form.copyfolder'}));
1008:
1009: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1010: $env{'form.copyfolder'});
1.538 raeburn 1011: return if ($fatal);
1012:
1013: my %curr_groups = &Apache::longroup::coursegroups();
1.364 bisitz 1014:
1.538 raeburn 1015: # Retrieve current paste buffer suffixes.
1016: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1017: my (%pasteurls,@newpaste);
1018:
1019: # Construct identifiers for current contents of user's paste buffer
1020: if (@currpaste) {
1021: foreach my $suffix (@currpaste) {
1022: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1023: my $url = $env{'docs.markedcopy_url_'.$suffix};
1024: if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
1025: ($url ne '')) {
1.564 raeburn 1026: $pasteurls{$cid.'_'.$url} = 1;
1.538 raeburn 1027: }
1028: }
1029: }
1030:
1031: # Mark items for copying (skip any items already in user's paste buffer)
1032: my %addtoenv;
1033:
1034: foreach my $item (@possibles) {
1035: my ($orderidx,$cmd) = split(/:/,$item);
1036: next if ($orderidx =~ /\D/);
1037: next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove'));
1038: my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]);
1039: my %denied = &action_restrictions($coursenum,$coursedom,
1040: &LONCAPA::map::qtescape($url),
1041: $env{'form.folderpath'},\%curr_groups);
1042: next if ($denied{'copy'});
1043: $url=~s{http(:|:)//https(:|:)//}{https$2//};
1044: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url}));
1045: my ($suffix,$errortxt,$locknotfreed) =
1046: &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
1047: push(@newpaste,$suffix);
1048: if ($locknotfreed) {
1049: return $locknotfreed;
1050: last;
1051: }
1052: if (&is_supplemental_title($title)) {
1053: &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});
1054: ($title) = &Apache::loncommon::parse_supplemental_title($title);
1055: }
1.329 droeschl 1056:
1.538 raeburn 1057: $addtoenv{'docs.markedcopy_title_'.$suffix} = $title,
1058: $addtoenv{'docs.markedcopy_url_'.$suffix} = $url,
1059: $addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd,
1060: $addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'};
1061:
1062: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) {
1063: my $prefix = $1;
1064: my $subdir =$2;
1065: if ($subdir eq '') {
1066: $subdir = $prefix;
1.492 raeburn 1067: }
1.538 raeburn 1068: my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
1069: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,\%addedmaps,
1070: \%hierarchy,\%titles,\%allmaps);
1071: if (ref($hierarchy{$url}) eq 'HASH') {
1072: my ($nested,$nestednames);
1073: &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
1074: $nested =~ s/\&$//;
1075: $nestednames =~ s/\Q___&&&___\E$//;
1076: if ($nested ne '') {
1077: $addtoenv{'docs.markedcopy_nested_'.$suffix} = $nested;
1078: }
1079: if ($nestednames ne '') {
1080: $addtoenv{'docs.markedcopy_nestednames_'.$suffix} = $nestednames;
1081: }
1.492 raeburn 1082: }
1083: }
1084: }
1.538 raeburn 1085: if (@newpaste) {
1086: $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));
1087: }
1.492 raeburn 1088: &Apache::lonnet::appenv(\%addtoenv);
1.329 droeschl 1089: delete($env{'form.markcopy'});
1.576 ! raeburn 1090: return;
1.329 droeschl 1091: }
1092:
1.492 raeburn 1093: sub recurse_uploaded_maps {
1094: my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_;
1095: if (ref($hierarchy->{$url}) eq 'HASH') {
1096: my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}}));
1097: my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}}));
1098: my (@uploaded,@names,%shorter);
1099: for (my $i=0; $i<@maps; $i++) {
1100: my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$});
1101: if ($inner ne '') {
1102: push(@uploaded,$inner);
1103: push(@names,&escape($titles[$i]));
1104: $shorter{$maps[$i]} = $inner;
1105: }
1106: }
1107: $$nestref .= "$dir:".join(',',@uploaded).'&';
1108: $$namesref .= "$dir:".(join(',',@names)).'___&&&___';
1109: foreach my $map (@maps) {
1110: if ($shorter{$map} ne '') {
1111: &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref);
1112: }
1113: }
1114: }
1115: return;
1116: }
1117:
1.329 droeschl 1118: sub print_paste_buffer {
1.492 raeburn 1119: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.538 raeburn 1120: return if (!defined($env{'docs.markedcopies'}));
1.329 droeschl 1121:
1.538 raeburn 1122: unless (($env{'form.pastemarked'}) || ($env{'form.clearmarked'})) {
1123: return if ($env{'docs.markedcopies'} eq '');
1.488 raeburn 1124: }
1125:
1.538 raeburn 1126: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1127: my ($pasteitems,@pasteable);
1.575 raeburn 1128: my $clipboardcount = 0;
1.488 raeburn 1129:
1.538 raeburn 1130: # Construct identifiers for current contents of user's paste buffer
1131: foreach my $suffix (@currpaste) {
1132: next if ($suffix =~ /\D/);
1133: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1134: my $url = $env{'docs.markedcopy_url_'.$suffix};
1135: if (($cid =~ /^$match_domain\_$match_courseid$/) &&
1136: ($url ne '')) {
1.575 raeburn 1137: $clipboardcount ++;
1.538 raeburn 1138: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
1139: $canpaste,$nopaste,$othercrs,$areachange);
1140: my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
1141: if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1142: $is_external = 1;
1143: }
1144: if ($folder =~ /^supplemental/) {
1145: $canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix});
1146: unless ($canpaste) {
1147: $nopaste = &mt('Paste into Supplemental Content unavailable.');
1148: }
1149: } else {
1150: $canpaste = 1;
1151: }
1152: if ($canpaste) {
1153: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1154: my $srcdom = $1;
1155: my $srcnum = $2;
1156: my $rem = $3;
1157: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
1158: $othercourse = 1;
1159: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1160: if ($canpaste) {
1.539 raeburn 1161: $othercrs = '<br />'.&mt('(from another course)');
1.538 raeburn 1162: }
1163: } else {
1164: $canpaste = 0;
1165: $nopaste = &mt('Paste from another course unavailable.');
1166: }
1167: }
1168: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
1169: my $prefix = $1;
1170: $parent = $2;
1171: if ($folder !~ /^\Q$prefix\E/) {
1172: $areachange = 1;
1173: }
1174: $is_uploaded_map = 1;
1.492 raeburn 1175: }
1176: }
1177: }
1.538 raeburn 1178: if ($canpaste) {
1179: push(@pasteable,$suffix);
1180: }
1181: my $buffer;
1182: if ($is_external) {
1183: $buffer = &mt('External Resource').': '.
1184: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
1185: &LONCAPA::map::qtescape($url).')';
1186: } else {
1187: my $icon = &Apache::loncommon::icon($extension);
1188: if ($extension eq 'sequence' &&
1189: $url =~ m{/default_\d+\.sequence$}x) {
1190: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1191: $icon .= '/navmap.folder.closed.gif';
1192: }
1193: $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
1194: ': '.
1195: &Apache::loncommon::parse_supplemental_title(
1196: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}));
1197: }
1198: $pasteitems .= '<div class="LC_left_float">';
1199: my ($options,$onclick);
1200: if (($canpaste) && (!$areachange) && (!$othercourse) &&
1201: ($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) {
1202: if (($is_uploaded_map) ||
1203: ($url =~ /(bulletinboard|smppg)$/) ||
1204: ($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
1205: $options = &paste_options($suffix,$is_uploaded_map,$parent);
1206: $onclick= 'onclick="showOptions(this,'."'$suffix'".');" ';
1207: }
1208: }
1209: $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
1210: if ($nopaste) {
1211: $pasteitems .= $nopaste;
1212: } else {
1213: if ($othercrs) {
1214: $pasteitems .= $othercrs;
1215: }
1216: if ($options) {
1217: $pasteitems .= $options;
1.492 raeburn 1218: }
1219: }
1.538 raeburn 1220: $pasteitems .= '</div>';
1221: }
1222: }
1223: if ($pasteitems eq '') {
1224: &Apache::lonnet::delenv('docs.markedcopies');
1225: }
1226: my ($pasteform,$form_start,$buttons,$form_end);
1227: if ($pasteitems) {
1228: $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1.541 raeburn 1229: $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
1.538 raeburn 1230: if (@pasteable) {
1.575 raeburn 1231: my $value = &mt('Paste to current folder');
1232: if ($container eq 'page') {
1233: $value = &mt('Paste to current page');
1234: }
1235: $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2);
1236: }
1237: $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2);
1238: if ($clipboardcount > 1) {
1239: $buttons .=
1240: '<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2).
1241: '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
1242: (' 'x2).
1243: '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
1244: (' 'x2);
1.492 raeburn 1245: }
1.575 raeburn 1246: $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
1247: '</form>';
1.538 raeburn 1248: } else {
1249: $pasteitems = &mt('Clipboard is empty');
1.488 raeburn 1250: }
1.538 raeburn 1251: $r->print($form_start
1252: .'<fieldset>'
1253: .'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>'
1254: .$pasteitems
1255: .'</fieldset>'
1256: .$form_end);
1257: }
1258:
1259: sub paste_options {
1260: my ($suffix,$is_uploaded_map,$parent) = @_;
1261: my ($copytext,$movetext);
1262: if ($is_uploaded_map) {
1263: $copytext = &mt('Copy to new folder');
1264: $movetext = &mt('Move old');
1265: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) {
1266: $copytext = &mt('Copy to new board');
1267: $movetext = &mt('Move (not posts)');
1268: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) {
1269: $copytext = &mt('Copy to new page');
1270: $movetext = &mt('Move');
1.533 raeburn 1271: } else {
1.538 raeburn 1272: $copytext = &mt('Copy to new file');
1273: $movetext = &mt('Move');
1274: }
1275: my $output = '<br />'.
1276: '<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'.
1277: '<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4).
1278: '<label>'.
1279: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'.
1280: $copytext.'</label></span>'.(' 'x2).' '.
1281: '<span class="LC_nobreak"><label>'.
1282: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'.
1283: $movetext.'</label></span>';
1284: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) {
1285: $output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders').
1286: '</legend><table border="0">';
1287: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1288: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix});
1289: my $lastdir = $parent;
1290: my %depths = (
1291: $lastdir => 0,
1292: );
1293: my (%display,%deps);
1294: for (my $i=0; $i<@pastemaps; $i++) {
1295: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
1296: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
1297: my @subfolders = split(/,/,$subfolderstr);
1298: $deps{$lastdir} = \@subfolders;
1299: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
1300: my $depth = $depths{$lastdir} + 1;
1301: my $offset = int($depth * 4);
1302: my $indent = (' ' x $offset);
1303: for (my $j=0; $j<@subfolders; $j++) {
1304: $depths{$subfolders[$j]} = $depth;
1305: $display{$subfolders[$j]} =
1306: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
1307: '<td><label>'.
1308: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
1309: '<label>'.
1310: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'.
1311: &mt('Move old').'</label>'.
1312: '</td></tr>';
1313: }
1.492 raeburn 1314: }
1.538 raeburn 1315: &recurse_print(\$output,$parent,\%deps,\%display);
1316: $output .= '</table></fieldset>';
1.329 droeschl 1317: }
1.538 raeburn 1318: $output .= '</div>';
1319: return $output;
1.488 raeburn 1320: }
1321:
1.492 raeburn 1322: sub recurse_print {
1.538 raeburn 1323: my ($outputref,$dir,$deps,$display) = @_;
1324: $$outputref .= $display->{$dir}."\n";
1.492 raeburn 1325: if (ref($deps->{$dir}) eq 'ARRAY') {
1326: foreach my $subdir (@{$deps->{$dir}}) {
1.538 raeburn 1327: &recurse_print($outputref,$subdir,$deps,$display);
1.492 raeburn 1328: }
1329: }
1330: }
1331:
1.488 raeburn 1332: sub supp_pasteable {
1333: my ($url) = @_;
1334: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
1335: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
1336: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
1337: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
1338: ($url =~ m{^/public/$match_domain/$match_courseid/syllabus})) {
1339: return 1;
1340: }
1341: return;
1.329 droeschl 1342: }
1343:
1.492 raeburn 1344: sub paste_popup_js {
1345: my %lt = &Apache::lonlocal::texthash(
1.538 raeburn 1346: show => 'Show Options',
1347: hide => 'Hide Options',
1.541 raeburn 1348: none => 'No items selected from clipboard.',
1.492 raeburn 1349: );
1350: return <<"END";
1351:
1.538 raeburn 1352: function showPasteOptions(suffix) {
1353: document.getElementById('pasteoptions_'+suffix).style.display='block';
1354: document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$lt{'hide'}</a>';
1.492 raeburn 1355: return;
1356: }
1357:
1.538 raeburn 1358: function hidePasteOptions(suffix) {
1359: document.getElementById('pasteoptions_'+suffix).style.display='none';
1360: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$lt{'show'}</a>';
1361: return;
1362: }
1363:
1364: function showOptions(caller,suffix) {
1365: if (document.getElementById('pasteoptionstext_'+suffix)) {
1366: if (caller.checked) {
1367: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$lt{'show'}</a>';
1368: } else {
1369: document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
1370: }
1371: if (document.getElementById('pasteoptions_'+suffix)) {
1372: document.getElementById('pasteoptions_'+suffix).style.display='none';
1373: }
1374: }
1.492 raeburn 1375: return;
1376: }
1377:
1.541 raeburn 1378: function validateClipboard() {
1379: var numchk = 0;
1380: if (document.pasteform.pasting.length > 1) {
1381: for (var i=0; i<document.pasteform.pasting.length; i++) {
1382: if (document.pasteform.pasting[i].checked) {
1383: numchk ++;
1384: }
1385: }
1386: } else {
1387: if (document.pasteform.pasting.type == 'checkbox') {
1388: if (document.pasteform.pasting.checked) {
1389: numchk ++;
1390: }
1391: }
1392: }
1393: if (numchk > 0) {
1394: return true;
1395: } else {
1396: alert("$lt{'none'}");
1397: return false;
1398: }
1399: }
1400:
1.575 raeburn 1401: function checkClipboard() {
1402: if (document.pasteform.pasting.length > 1) {
1403: for (var i=0; i<document.pasteform.pasting.length; i++) {
1404: document.pasteform.pasting[i].checked = true;
1405: }
1406: }
1407: return;
1408: }
1409:
1410: function uncheckClipboard() {
1411: if (document.pasteform.pasting.length >1) {
1412: for (var i=0; i<document.pasteform.pasting.length; i++) {
1413: document.pasteform.pasting[i].checked = false;
1414: }
1415: }
1416: return;
1417: }
1418:
1.492 raeburn 1419: END
1420:
1421: }
1422:
1.329 droeschl 1423: sub do_paste_from_buffer {
1.492 raeburn 1424: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 1425:
1.538 raeburn 1426: # Array of items in paste buffer
1427: my (@currpaste,%pastebuffer,%allerrors);
1428: @currpaste = split(/,/,$env{'docs.markedcopies'});
1429:
1.492 raeburn 1430: # Early out if paste buffer is empty
1.538 raeburn 1431: if (@currpaste == 0) {
1.492 raeburn 1432: return ();
1.538 raeburn 1433: }
1434: map { $pastebuffer{$_} = 1; } @currpaste;
1435:
1436: # Array of items selected items to paste
1437: my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting');
1438:
1439: # Early out if nothing selected to paste
1440: if (@reqpaste == 0) {
1441: return();
1442: }
1443: my @topaste;
1444: foreach my $suffix (@reqpaste) {
1445: next if ($suffix =~ /\D/);
1446: next unless (exists($pastebuffer{$suffix}));
1447: push(@topaste,$suffix);
1448: }
1449:
1450: # Early out if nothing available to paste
1451: if (@topaste == 0) {
1452: return();
1.329 droeschl 1453: }
1454:
1.538 raeburn 1455: my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%duplicate,
1.564 raeburn 1456: %prefixchg,%srcdom,%srcnum,%marktomove,$save_err,$lockerrors,$allresult);
1.538 raeburn 1457:
1458: foreach my $suffix (@topaste) {
1459: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1.492 raeburn 1460: # Supplemental content may only include certain types of content
1461: # Early out if pasted content is not supported in Supplemental area
1.538 raeburn 1462: if ($folder =~ /^supplemental/) {
1463: unless (&supp_pasteable($url)) {
1464: $notinsupp{$suffix} = 1;
1465: next;
1466: }
1.492 raeburn 1467: }
1.538 raeburn 1468: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {
1469: my $srcd = $1;
1470: my $srcn = $2;
1.492 raeburn 1471: # When paste buffer was populated using an active role in a different course
1.538 raeburn 1472: # check for mdc privilege in the course from which the resource was pasted
1473: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1474: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1475: $notincrs{$suffix} = 1;
1476: next;
1477: }
1.491 raeburn 1478: }
1.538 raeburn 1479: $srcdom{$suffix} = $srcd;
1480: $srcnum{$suffix} = $srcn;
1.491 raeburn 1481: }
1.538 raeburn 1482:
1483: push(@dopaste,$suffix);
1484: if ($url=~/\.(page|sequence)$/) {
1485: $is_map{$suffix} = 1;
1486: }
1487:
1488: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {
1489: my $oldprefix = $1;
1.492 raeburn 1490: # When pasting content from Main Content to Supplemental Content and vice versa
1491: # URLs will contain different paths (which depend on whether pasted item is
1492: # a folder/page or a document.
1.538 raeburn 1493: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
1494: $prefixchg{$suffix} = 'docstosupp';
1495: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
1496: $prefixchg{$suffix} = 'supptodocs';
1497: }
1.491 raeburn 1498:
1.492 raeburn 1499: # If pasting an uploaded map, get list of contained uploaded maps.
1.538 raeburn 1500: if ($env{'docs.markedcopy_nested_'.$suffix}) {
1501: my @nested;
1502: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
1503: my @items = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1504: my @deps = map { /\d+:([\d,]+$)/ } @items;
1505: foreach my $dep (@deps) {
1506: if ($dep =~ /,/) {
1507: push(@nested,split(/,/,$dep));
1508: } else {
1509: push(@nested,$dep);
1510: }
1.492 raeburn 1511: }
1.538 raeburn 1512: foreach my $item (@nested) {
1513: if ($env{'form.docs.markedcopy_'.$suffix.'_'.$item} eq 'move') {
1514: push(@{$marktomove{$suffix}},$type.'_'.$item);
1515: }
1.492 raeburn 1516: }
1517: }
1.488 raeburn 1518: }
1519: }
1520:
1.538 raeburn 1521: # Early out if nothing available to paste
1522: if (@dopaste == 0) {
1523: return ();
1524: }
1525:
1526: # Populate message hash and hashes used for main content <=> supplemental content
1527: # changes
1528:
1529: %msgs = &Apache::lonlocal::texthash (
1530: notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
1531: notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
1532: duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
1533: );
1534:
1535: %before = (
1536: docstosupp => {
1537: map => 'default',
1538: doc => 'docs',
1539: },
1540: supptodocs => {
1541: map => 'supplemental',
1542: doc => 'supplemental',
1543: },
1544: );
1545:
1546: %after = (
1547: docstosupp => {
1548: map => 'supplemental',
1549: doc => 'supplemental'
1550: },
1551: supptodocs => {
1552: map => 'default',
1553: doc => 'docs',
1554: },
1555: );
1556:
1557: # Retrieve information about all course maps in main content area
1558:
1559: my $allmaps = {};
1560: if ($folder =~ /^default/) {
1561: $allmaps =
1562: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1563: $env{"course.$env{'request.course.id'}.home"},
1564: $env{'request.course.id'});
1565: }
1566:
1567: my (@toclear,%mapurls,%lockerrs,%msgerrs,%results);
1568:
1569: # Loop over the items to paste
1570: foreach my $suffix (@dopaste) {
1.329 droeschl 1571: # Maps need to be copied first
1.538 raeburn 1572: my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1573: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir,
1574: %newurls,%tomove);
1575: if (ref($marktomove{$suffix}) eq 'ARRAY') {
1576: map { $tomove{$_} = 1; } @{$marktomove{$suffix}};
1577: }
1578: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1579: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1580: my $oldurl = $url;
1581: if ($is_map{$suffix}) {
1.491 raeburn 1582: # If pasting a map, check if map contains other maps
1.538 raeburn 1583: my (%hierarchy,%titles);
1584: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,
1585: \%addedmaps,\%hierarchy,\%titles,$allmaps);
1586: if ($url=~ m{^/uploaded/}) {
1587: my $newurl;
1588: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1589: ($newurl,my $error) =
1590: &get_newmap_url($url,$folder,$prefixchg{$suffix},$coursedom,
1591: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1592: \$title,$allmaps,\%newurls);
1593: if ($error) {
1594: $allerrors{$suffix} = $error;
1595: next;
1596: }
1597: if ($newurl ne '') {
1598: if ($newurl ne $url) {
1599: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
1600: $newsubdir{$url} = $1;
1601: }
1602: $mapchanges{$url} = 1;
1.492 raeburn 1603: }
1.538 raeburn 1604: }
1605: }
1606: if (($srcdom{$suffix} ne $coursedom) ||
1607: ($srcnum{$suffix} ne $coursenum) ||
1608: ($prefixchg{$suffix}) || (($newurl ne '') && ($newurl ne $url))) {
1609: unless (&url_paste_fixups($url,$folder,$prefixchg{$suffix},
1610: $coursedom,$coursenum,$srcdom{$suffix},
1611: $srcnum{$suffix},$allmaps,\%rewrites,
1612: \%retitles,\%copies,\%dbcopies,
1613: \%zombies,\%params,\%mapmoves,
1614: \%mapchanges,\%tomove,\%newsubdir,
1615: \%newurls)) {
1616: $mapmoves{$url} = 1;
1617: }
1618: $url = $newurl;
1619: } elsif ($env{'docs.markedcopy_nested_'.$suffix}) {
1620: &url_paste_fixups($url,$folder,$prefixchg{$suffix},$coursedom,
1621: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1622: $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
1623: \%zombies,\%params,\%mapmoves,\%mapchanges,
1624: \%tomove,\%newsubdir,\%newurls);
1625: }
1626: } elsif ($url=~m {^/res/}) {
1627: # published map can only exists once, so remove from paste buffer when done
1628: push(@toclear,$suffix);
1629: # if pasting published map (main content area only) check map not already in course
1630: if ($folder =~ /^default/) {
1631: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1632: $duplicate{$suffix} = 1;
1633: next;
1.492 raeburn 1634: }
1.491 raeburn 1635: }
1636: }
1.538 raeburn 1637: }
1638: if ($url=~ m{/(bulletinboard|smppg)$}) {
1639: my $prefix = $1;
1640: #need to copy the db contents to a new one, unless this is a move.
1641: my %info = (
1642: src => $url,
1643: cdom => $coursedom,
1644: cnum => $coursenum,
1645: );
1646: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1647: my (%lockerr,$msg);
1648: my ($newurl,$result,$errtext) =
1649: &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
1650: if ($result eq 'ok') {
1651: $url = $newurl;
1652: $title=&mt('Copy of').' '.$title;
1653: } else {
1654: if ($prefix eq 'smppg') {
1655: $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext;
1656: } elsif ($prefix eq 'bulletinboard') {
1.565 bisitz 1657: $msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext;
1.538 raeburn 1658: }
1659: $results{$suffix} = $result;
1660: $msgerrs{$suffix} = $msg;
1661: $lockerrs{$suffix} = $lockerr{$prefix};
1662: next;
1663: }
1664: if ($lockerr{$prefix}) {
1665: $lockerrs{$suffix} = $lockerr{$prefix};
1.491 raeburn 1666: }
1.489 raeburn 1667: }
1668: }
1.538 raeburn 1669: $title = &LONCAPA::map::qtunescape($title);
1670: my $ext='false';
1671: if ($url=~m{^http(|s)://}) { $ext='true'; }
1672: if ($env{'docs.markedcopy_supplemental_'.$suffix}) {
1673: if ($folder !~ /^supplemental/) {
1674: (undef,undef,$title) =
1675: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix});
1676: }
1677: } else {
1678: if ($folder=~/^supplemental/) {
1679: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1680: $env{'user.domain'}.'___&&&___'.$title;
1.491 raeburn 1681: }
1.533 raeburn 1682: }
1.491 raeburn 1683:
1684: # For uploaded files (excluding pages/sequences) path in copied file is changed
1685: # if paste is from Main to Supplemental (or vice versa), or if pasting between
1686: # courses.
1687:
1.538 raeburn 1688: unless ($is_map{$suffix}) {
1689: my $newidx;
1.492 raeburn 1690: # Now insert the URL at the bottom
1.538 raeburn 1691: $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1692: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
1693: my $relpath = $1;
1694: if ($relpath ne '') {
1695: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
1696: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
1697: my $newprefix = $newloc;
1698: if ($newloc eq 'default') {
1699: $newprefix = 'docs';
1700: }
1701: if ($newdocsdir eq '') {
1702: $newdocsdir = 'default';
1703: }
1704: if (($prefixchg{$suffix}) ||
1705: ($srcdom{$suffix} ne $coursedom) ||
1706: ($srcnum{$suffix} ne $coursenum) ||
1707: ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
1708: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
1709: $url =
1710: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
1711: &Apache::lonnet::getfile($oldurl));
1712: if ($url eq '/adm/notfound.html') {
1713: $msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.');
1714: next;
1715: } else {
1716: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
1717: $newsubpath =~ s{/+$}{/};
1718: $docmoves{$oldurl} = $newsubpath;
1719: }
1.491 raeburn 1720: }
1721: }
1722: }
1.538 raeburn 1723: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1724: ':'.$ext.':normal:res';
1725: push(@LONCAPA::map::order,$newidx);
1726: # Store the result
1727: my ($errtext,$fatal) =
1728: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1729: if ($fatal) {
1730: $save_err .= $errtext;
1731: $allresult = 'fail';
1732: }
1.488 raeburn 1733: }
1.538 raeburn 1734:
1.492 raeburn 1735: # Apply any changes to maps, or copy dependencies for uploaded HTML pages
1.538 raeburn 1736: unless ($allresult eq 'fail') {
1737: my %updated = (
1738: rewrites => \%rewrites,
1739: zombies => \%zombies,
1740: removefrommap => \%removefrommap,
1741: removeparam => \%removeparam,
1742: dbcopies => \%dbcopies,
1743: retitles => \%retitles,
1744: );
1745: my %info = (
1746: newsubdir => \%newsubdir,
1747: params => \%params,
1748: );
1749: if ($prefixchg{$suffix}) {
1750: $info{'before'} = $before{$prefixchg{$suffix}};
1751: $info{'after'} = $after{$prefixchg{$suffix}};
1752: }
1753: my %moves = (
1754: copies => \%copies,
1755: docmoves => \%docmoves,
1756: mapmoves => \%mapmoves,
1757: );
1758: (my $result,$msgs{$suffix},my $lockerror) =
1759: &apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors,
1760: \%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl,
1761: $url,'paste');
1762: $lockerrors .= $lockerror;
1763: if ($result eq 'ok') {
1764: if ($is_map{$suffix}) {
1765: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1766: $folder.'.'.$container);
1767: if ($fatal) {
1768: $allresult = 'failread';
1769: } else {
1770: if ($#LONCAPA::map::order<1) {
1771: my $idx=&LONCAPA::map::getresidx();
1772: if ($idx<=0) { $idx=1; }
1773: $LONCAPA::map::order[0]=$idx;
1774: $LONCAPA::map::resources[$idx]='';
1775: }
1776: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1777: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1778: ':'.$ext.':normal:res';
1779: push(@LONCAPA::map::order,$newidx);
1.492 raeburn 1780:
1781: # Store the result
1.538 raeburn 1782: my ($errtext,$fatal) =
1783: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1784: if ($fatal) {
1785: $save_err .= $errtext;
1786: $allresult = 'failstore';
1787: }
1788: }
1789: }
1790: if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1791: push(@toclear,$suffix);
1792: }
1793: }
1.492 raeburn 1794: }
1795: }
1.538 raeburn 1796: &clear_from_buffer(\@toclear,\@currpaste);
1797: my $msgsarray;
1798: foreach my $suffix (keys(%msgs)) {
1799: if (ref($msgs{$suffix}) eq 'ARRAY') {
1800: $msgsarray .= join(',',@{$msgs{$suffix}});
1801: }
1802: }
1803: return ($allresult,$save_err,$msgsarray,$lockerrors);
1804: }
1.533 raeburn 1805:
1.538 raeburn 1806: sub do_buffer_empty {
1807: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1808: if (@currpaste == 0) {
1809: return &mt('Clipboard is already empty');
1810: }
1811: my @toclear = &Apache::loncommon::get_env_multiple('form.pasting');
1812: if (@toclear == 0) {
1813: return &mt('Nothing selected to clear from clipboard');
1814: }
1815: my $numdel = &clear_from_buffer(\@toclear,\@currpaste);
1816: if ($numdel) {
1817: return &mt('[quant,_1,item] cleared from clipboard',$numdel);
1818: } else {
1819: return &mt('Clipboard unchanged');
1.492 raeburn 1820: }
1.538 raeburn 1821: return;
1822: }
1823:
1824: sub clear_from_buffer {
1825: my ($toclear,$currpaste) = @_;
1826: return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY'));
1827: my %pastebuffer;
1828: map { $pastebuffer{$_} = 1; } @{$currpaste};
1829: my $numdel = 0;
1830: foreach my $suffix (@{$toclear}) {
1831: next if ($suffix =~ /\D/);
1832: next unless (exists($pastebuffer{$suffix}));
1833: my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix;
1834: if (&Apache::lonnet::delenv($regexp,1) eq 'ok') {
1835: delete($pastebuffer{$suffix});
1836: $numdel ++;
1837: }
1838: }
1839: my $newbuffer = join(',',sort(keys(%pastebuffer)));
1840: &Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer});
1841: return $numdel;
1.492 raeburn 1842: }
1843:
1844: sub get_newmap_url {
1845: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
1846: $titleref,$allmaps,$newurls) = @_;
1847: my $newurl;
1848: if ($url=~ m{^/uploaded/}) {
1849: $$titleref=&mt('Copy of').' '.$$titleref;
1850: }
1851: my $now = time;
1852: my $suffix=$$.int(rand(100)).$now;
1853: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
1854: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
1855: my $path = $1;
1856: my $prefix = $2;
1857: my $ancestor = $3;
1858: if (length($ancestor) > 10) {
1859: $ancestor = substr($ancestor,-10,10);
1860: }
1861: my $newid;
1862: if ($prefixchg) {
1863: if ($folder =~ /^supplemental/) {
1864: $prefix =~ s/^default/supplemental/;
1865: } else {
1866: $prefix =~ s/^supplemental/default/;
1867: }
1868: }
1869: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
1870: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
1871: } else {
1872: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
1873: }
1874: my $counter = 0;
1875: my $is_unique = &uniqueness_check($newurl);
1876: if ($folder =~ /^default/) {
1877: if ($allmaps->{$newurl}) {
1878: $is_unique = 0;
1879: }
1880: }
1881: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
1882: $counter ++;
1883: $suffix ++;
1884: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
1885: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
1886: } else {
1887: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
1888: }
1889: $is_unique = &uniqueness_check($newurl);
1890: }
1891: if ($is_unique) {
1892: $newurls->{$newurl} = 1;
1893: } else {
1894: if ($url=~/\.page$/) {
1895: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
1896: } else {
1897: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
1898: }
1899: }
1.329 droeschl 1900: }
1.492 raeburn 1901: return ($newurl);
1.329 droeschl 1902: }
1903:
1.488 raeburn 1904: sub dbcopy {
1.533 raeburn 1905: my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
1906: my ($url,$result,$errtext);
1.564 raeburn 1907: $url = $dbref->{'src'};
1.533 raeburn 1908: if (ref($dbref) eq 'HASH') {
1909: if ($url =~ m{/(smppg|bulletinboard)$}) {
1910: my $prefix = $1;
1911: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
1912: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
1913: my $db_name;
1914: my $marker = (split(m{/},$url))[4];
1915: $marker=~s/\D//g;
1916: if ($dbref->{'src'} =~ m{/smppg$}) {
1917: $db_name =
1918: &Apache::lonsimplepage::get_db_name($url,$marker,
1919: $dbref->{'cdom'},
1920: $dbref->{'cnum'});
1921: } else {
1922: $db_name = 'bulletinpage_'.$marker;
1923: }
1924: my ($suffix,$freedlock,$error) =
1925: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
1926: $coursedom,$coursenum,
1927: 'concat');
1928: if (!$suffix) {
1929: if ($prefix eq 'smppg') {
1930: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
1931: } else {
1.565 bisitz 1932: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
1.533 raeburn 1933: }
1934: if ($error) {
1935: $errtext .= '<br />'.$error;
1936: }
1937: } else {
1938: #need to copy the db contents to a new one.
1939: my %contents=&Apache::lonnet::dump($db_name,
1940: $dbref->{'cdom'},
1941: $dbref->{'cnum'});
1942: if (exists($contents{'uploaded.photourl'})) {
1943: my $photo = $contents{'uploaded.photourl'};
1944: my ($subdir,$fname) =
1945: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
1946: my $newphoto;
1947: if ($fname ne '') {
1948: my $content = &Apache::lonnet::getfile($photo);
1949: unless ($content eq '-1') {
1950: $env{'form.'.$suffix.'.photourl'} = $content;
1951: $newphoto =
1952: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
1953: delete($env{'form.'.$suffix.'.photourl'});
1954: }
1955: }
1956: if ($newphoto =~ m{^/uploaded/}) {
1957: $contents{'uploaded.photourl'} = $newphoto;
1958: }
1959: }
1960: $db_name =~ s{_\d*$ }{_$suffix}x;
1961: $result=&Apache::lonnet::put($db_name,\%contents,
1962: $coursedom,$coursenum);
1963: if ($result eq 'ok') {
1964: $url =~ s{/(\d*)/(smppg|bulletinboard)$}{/$suffix/$2}x;
1965: }
1966: }
1967: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
1.559 raeburn 1968: $lockerrorsref->{$prefix} =
1.533 raeburn 1969: '<div class="LC_error">'.
1970: &mt('There was a problem removing a lockfile.');
1971: if ($prefix eq 'smppg') {
1.560 raeburn 1972: $lockerrorsref->{$prefix} .=
1.559 raeburn 1973: ' '.&mt('This will prevent creation of additional simple pages in this course.');
1.533 raeburn 1974: } else {
1.565 bisitz 1975: $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
1.533 raeburn 1976: }
1.560 raeburn 1977: $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
1978: '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
1979: '</div>';
1.533 raeburn 1980: }
1981: }
1982: } elsif ($url =~ m{/syllabus$}) {
1983: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
1984: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
1985: if (($dbref->{'cdom'} ne $coursedom) ||
1986: ($dbref->{'cnum'} ne $coursenum)) {
1987: my %contents=&Apache::lonnet::dump('syllabus',
1988: $dbref->{'cdom'},
1989: $dbref->{'cnum'});
1990: $result=&Apache::lonnet::put('syllabus',\%contents,
1991: $coursedom,$coursenum);
1992: }
1993: }
1.488 raeburn 1994: }
1995: }
1.533 raeburn 1996: return ($url,$result,$errtext);
1.488 raeburn 1997: }
1998:
1.329 droeschl 1999: sub uniqueness_check {
2000: my ($newurl) = @_;
2001: my $unique = 1;
2002: foreach my $res (@LONCAPA::map::order) {
2003: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2004: $url=&LONCAPA::map::qtescape($url);
2005: if ($newurl eq $url) {
2006: $unique = 0;
1.344 bisitz 2007: last;
1.329 droeschl 2008: }
2009: }
2010: return $unique;
2011: }
2012:
1.488 raeburn 2013: sub contained_map_check {
1.492 raeburn 2014: my ($url,$folder,$removefrommap,$removeparam,$addedmaps,$hierarchy,$titles,
2015: $allmaps) = @_;
1.488 raeburn 2016: my $content = &Apache::lonnet::getfile($url);
2017: unless ($content eq '-1') {
2018: my $parser = HTML::TokeParser->new(\$content);
2019: $parser->attr_encoded(1);
2020: while (my $token = $parser->get_token) {
2021: next if ($token->[0] ne 'S');
2022: if ($token->[1] eq 'resource') {
2023: next if ($token->[2]->{'type'} eq 'zombie');
2024: my $ressrc = $token->[2]->{'src'};
2025: if ($folder =~ /^supplemental/) {
2026: unless (&supp_pasteable($ressrc)) {
1.492 raeburn 2027: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.488 raeburn 2028: next;
2029: }
2030: }
1.492 raeburn 2031: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
2032: if ($1 eq 'uploaded') {
2033: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
2034: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
1.488 raeburn 2035: } else {
1.492 raeburn 2036: if ($allmaps->{$ressrc}) {
1.529 raeburn 2037: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.492 raeburn 2038: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
2039: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2040: } else {
2041: $addedmaps->{$ressrc} = [$url];
2042: }
1.488 raeburn 2043: }
1.492 raeburn 2044: &contained_map_check($ressrc,$folder,$removefrommap,$removeparam,
2045: $addedmaps,$hierarchy,$titles,$allmaps);
1.488 raeburn 2046: }
1.492 raeburn 2047: } elsif ($token->[1] eq 'param') {
1.488 raeburn 2048: if ($folder =~ /^supplemental/) {
1.492 raeburn 2049: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
2050: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
2051: } else {
2052: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
2053: }
1.488 raeburn 2054: }
2055: }
2056: }
2057: }
2058: return;
2059: }
2060:
2061: sub url_paste_fixups {
1.533 raeburn 2062: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
2063: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
2064: $mapchanges,$tomove,$newsubdir,$newurls) = @_;
1.491 raeburn 2065: my $checktitle;
2066: if (($prefixchg) &&
1.492 raeburn 2067: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
1.491 raeburn 2068: $checktitle = 1;
2069: }
1.492 raeburn 2070: my $skip;
2071: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
2072: my $mapid = $1.$2;
2073: if ($tomove->{$mapid}) {
2074: $skip = 1;
2075: }
2076: }
1.491 raeburn 2077: my $file = &Apache::lonnet::getfile($oldurl);
1.488 raeburn 2078: return if ($file eq '-1');
2079: my $parser = HTML::TokeParser->new(\$file);
2080: $parser->attr_encoded(1);
1.491 raeburn 2081: my $changed = 0;
1.488 raeburn 2082: while (my $token = $parser->get_token) {
2083: next if ($token->[0] ne 'S');
2084: if ($token->[1] eq 'resource') {
2085: my $ressrc = $token->[2]->{'src'};
2086: next if ($ressrc eq '');
1.491 raeburn 2087: my $id = $token->[2]->{'id'};
1.492 raeburn 2088: my $title = $token->[2]->{'title'};
1.491 raeburn 2089: if ($checktitle) {
2090: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.532 raeburn 2091: $retitles->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2092: }
2093: }
1.488 raeburn 2094: next if ($token->[2]->{'type'} eq 'external');
2095: if ($token->[2]->{'type'} eq 'zombie') {
1.492 raeburn 2096: next if ($skip);
1.532 raeburn 2097: $zombies->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2098: $changed = 1;
2099: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 2100: my $srcdom = $1;
2101: my $srcnum = $2;
1.488 raeburn 2102: my $rem = $3;
1.492 raeburn 2103: my $newurl;
2104: my $mapname;
2105: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
2106: my $prefix = $1;
2107: $mapname = $prefix.$2;
2108: if ($tomove->{$mapname}) {
1.533 raeburn 2109: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
2110: $srcdom,$srcnum,$allmaps,$rewrites,
2111: $retitles,$copies,$dbcopies,$zombies,
2112: $params,$mapmoves,$mapchanges,$tomove,
2113: $newsubdir,$newurls);
1.492 raeburn 2114: next;
2115: } else {
2116: ($newurl,my $error) =
2117: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
2118: $srcdom,$srcnum,\$title,$allmaps,$newurls);
2119: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
2120: $newsubdir->{$ressrc} = $1;
2121: }
2122: if ($error) {
2123: next;
2124: }
2125: }
2126: }
2127: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
2128: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
2129:
1.488 raeburn 2130: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.532 raeburn 2131: $rewrites->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2132: $mapchanges->{$ressrc} = 1;
1.533 raeburn 2133: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
2134: $cnum,$srcdom,$srcnum,$allmaps,
2135: $rewrites,$retitles,$copies,$dbcopies,
2136: $zombies,$params,$mapmoves,$mapchanges,
2137: $tomove,$newsubdir,$newurls)) {
1.491 raeburn 2138: $mapmoves->{$ressrc} = 1;
2139: }
2140: $changed = 1;
1.488 raeburn 2141: } else {
1.532 raeburn 2142: $rewrites->{$oldurl}{$id} = $ressrc;
1.488 raeburn 2143: $copies->{$oldurl}{$ressrc} = $id;
1.491 raeburn 2144: $changed = 1;
1.488 raeburn 2145: }
2146: }
1.533 raeburn 2147: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
2148: next if ($skip);
1.492 raeburn 2149: my $srcdom = $1;
2150: my $srcnum = $2;
2151: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.532 raeburn 2152: $rewrites->{$oldurl}{$id} = $ressrc;
1.533 raeburn 2153: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2154: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2155: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2156: $changed = 1;
2157: }
2158: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
2159: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
2160: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2161: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2162: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
2163: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.491 raeburn 2164: $changed = 1;
1.488 raeburn 2165: }
2166: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 2167: next if ($skip);
2168: my $srcdom = $1;
2169: my $srcnum = $2;
2170: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.533 raeburn 2171: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2172: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2173: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.491 raeburn 2174: $changed = 1;
1.488 raeburn 2175: }
2176: }
2177: } elsif ($token->[1] eq 'param') {
1.492 raeburn 2178: next if ($skip);
1.488 raeburn 2179: my $to = $token->[2]->{'to'};
2180: if ($to ne '') {
2181: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
1.492 raeburn 2182: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
1.488 raeburn 2183: } else {
2184: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
2185: }
2186: }
2187: }
2188: }
1.491 raeburn 2189: return $changed;
1.488 raeburn 2190: }
2191:
2192: sub apply_fixups {
1.529 raeburn 2193: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
2194: $oldurl,$url,$caller) = @_;
2195: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.533 raeburn 2196: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
2197: %lockerrors,$lockmsg);
1.529 raeburn 2198: if (ref($updated) eq 'HASH') {
2199: if (ref($updated->{'rewrites'}) eq 'HASH') {
2200: %rewrites = %{$updated->{'rewrites'}};
2201: }
2202: if (ref($updated->{'zombies'}) eq 'HASH') {
2203: %zombies = %{$updated->{'zombies'}};
2204: }
2205: if (ref($updated->{'removefrommap'}) eq 'HASH') {
2206: %removefrommap = %{$updated->{'removefrommap'}};
2207: }
2208: if (ref($updated->{'removeparam'}) eq 'HASH') {
2209: %removeparam = %{$updated->{'removeparam'}};
2210: }
2211: if (ref($updated->{'dbcopies'}) eq 'HASH') {
2212: %dbcopies = %{$updated->{'dbcopies'}};
2213: }
2214: if (ref($updated->{'retitles'}) eq 'HASH') {
2215: %retitles = %{$updated->{'retitles'}};
2216: }
2217: }
2218: if (ref($info) eq 'HASH') {
2219: if (ref($info->{'newsubdir'}) eq 'HASH') {
2220: %newsubdir = %{$info->{'newsubdir'}};
2221: }
2222: if (ref($info->{'params'}) eq 'HASH') {
2223: %params = %{$info->{'params'}};
2224: }
2225: if (ref($info->{'before'}) eq 'HASH') {
2226: %before = %{$info->{'before'}};
2227: }
2228: if (ref($info->{'after'}) eq 'HASH') {
2229: %after = %{$info->{'after'}};
2230: }
2231: }
2232: if (ref($moves) eq 'HASH') {
2233: if (ref($moves->{'copies'}) eq 'HASH') {
2234: %copies = %{$moves->{'copies'}};
2235: }
2236: if (ref($moves->{'docmoves'}) eq 'HASH') {
2237: %docmoves = %{$moves->{'docmoves'}};
2238: }
2239: if (ref($moves->{'mapmoves'}) eq 'HASH') {
2240: %mapmoves = %{$moves->{'mapmoves'}};
2241: }
2242: }
2243: foreach my $key (keys(%copies),keys(%docmoves)) {
1.491 raeburn 2244: my @allcopies;
1.529 raeburn 2245: if (exists($copies{$key})) {
2246: if (ref($copies{$key}) eq 'HASH') {
2247: my %added;
2248: foreach my $innerkey (keys(%{$copies{$key}})) {
2249: if (($innerkey ne '') && (!$added{$innerkey})) {
2250: push(@allcopies,$innerkey);
2251: $added{$innerkey} = 1;
2252: }
1.491 raeburn 2253: }
1.529 raeburn 2254: undef(%added);
1.491 raeburn 2255: }
2256: }
2257: if ($key eq $oldurl) {
1.529 raeburn 2258: if ((exists($docmoves{$key}))) {
1.532 raeburn 2259: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.491 raeburn 2260: push(@allcopies,$oldurl);
2261: }
2262: }
2263: }
2264: if (@allcopies > 0) {
2265: foreach my $item (@allcopies) {
1.492 raeburn 2266: my ($relpath,$oldsubdir,$fname) =
2267: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
1.491 raeburn 2268: if ($fname ne '') {
2269: my $content = &Apache::lonnet::getfile($item);
2270: unless ($content eq '-1') {
2271: my $storefn;
1.529 raeburn 2272: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
2273: $storefn = $docmoves{$key};
1.491 raeburn 2274: } else {
2275: $storefn = $relpath;
2276: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2277: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
2278: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.491 raeburn 2279: }
1.529 raeburn 2280: if ($newsubdir{$key}) {
1.532 raeburn 2281: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.491 raeburn 2282: }
2283: }
2284: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
2285: my $copyurl =
2286: &Apache::lonclonecourse::writefile($env{'request.course.id'},
2287: $storefn.$fname,$content);
2288: if ($copyurl eq '/adm/notfound.html') {
1.529 raeburn 2289: if (exists($docmoves{$oldurl})) {
1.491 raeburn 2290: return &mt('Paste failed: an error occurred copying the file.');
2291: } elsif (ref($errors) eq 'HASH') {
2292: $errors->{$item} = 1;
1.489 raeburn 2293: }
2294: }
1.488 raeburn 2295: }
2296: }
1.491 raeburn 2297: }
2298: }
2299: }
1.529 raeburn 2300: foreach my $key (keys(%mapmoves)) {
1.491 raeburn 2301: my $storefn=$key;
2302: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2303: if ($prefixchg && $before{'map'} && $after{'map'}) {
2304: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.491 raeburn 2305: }
1.529 raeburn 2306: if ($newsubdir{$key}) {
2307: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.492 raeburn 2308: }
1.491 raeburn 2309: my $mapcontent = &Apache::lonnet::getfile($key);
2310: if ($mapcontent eq '-1') {
2311: if (ref($errors) eq 'HASH') {
2312: $errors->{$key} = 1;
2313: }
2314: } else {
2315: my $newmap =
2316: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
2317: $mapcontent);
2318: if ($newmap eq '/adm/notfound.html') {
2319: if (ref($errors) eq 'HASH') {
2320: $errors->{$key} = 1;
1.489 raeburn 2321: }
1.488 raeburn 2322: }
2323: }
2324: }
1.491 raeburn 2325: my %updates;
2326: if ($is_map) {
1.529 raeburn 2327: if (ref($updated) eq 'HASH') {
2328: foreach my $type (keys(%{$updated})) {
2329: if (ref($updated->{$type}) eq 'HASH') {
2330: foreach my $key (keys(%{$updated->{$type}})) {
2331: $updates{$key} = 1;
2332: }
2333: }
2334: }
1.491 raeburn 2335: }
2336: foreach my $key (keys(%updates)) {
1.492 raeburn 2337: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.529 raeburn 2338: if (ref($rewrites{$key}) eq 'HASH') {
2339: %torewrite = %{$rewrites{$key}};
1.491 raeburn 2340: }
1.529 raeburn 2341: if (ref($retitles{$key}) eq 'HASH') {
2342: %toretitle = %{$retitles{$key}};
1.491 raeburn 2343: }
1.529 raeburn 2344: if (ref($removefrommap{$key}) eq 'HASH') {
2345: %toremove = %{$removefrommap{$key}};
1.491 raeburn 2346: }
1.529 raeburn 2347: if (ref($removeparam{$key}) eq 'HASH') {
2348: %remparam = %{$removeparam{$key}};
1.492 raeburn 2349: }
1.529 raeburn 2350: if (ref($zombies{$key}) eq 'HASH') {
2351: %zombie = %{$zombies{$key}};
1.491 raeburn 2352: }
1.529 raeburn 2353: if (ref($dbcopies{$key}) eq 'HASH') {
1.533 raeburn 2354: foreach my $idx (keys(%{$dbcopies{$key}})) {
2355: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
2356: my ($newurl,$result,$errtext) =
2357: &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
2358: if ($result eq 'ok') {
2359: $newdb{$idx} = $newurl;
2360: } elsif (ref($errors) eq 'HASH') {
2361: $errors->{$key} = 1;
2362: }
2363: push(@msgs,$errtext);
2364: }
1.491 raeburn 2365: }
2366: }
1.529 raeburn 2367: if (ref($params{$key}) eq 'HASH') {
2368: %currparam = %{$params{$key}};
1.492 raeburn 2369: }
2370: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
2371: if ($fatal) {
1.533 raeburn 2372: return ($errtext);
1.492 raeburn 2373: }
2374: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
2375: if (defined($LONCAPA::map::zombies[$i])) {
2376: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.532 raeburn 2377: if ($zombie{$i} eq $src) {
1.492 raeburn 2378: undef($LONCAPA::map::zombies[$i]);
2379: }
2380: }
2381: }
1.529 raeburn 2382: for (my $i=0; $i<@LONCAPA::map::order; $i++) {
2383: my $idx = $LONCAPA::map::order[$i];
2384: if (defined($LONCAPA::map::resources[$idx])) {
1.492 raeburn 2385: my $changed;
1.529 raeburn 2386: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1.538 raeburn 2387: if ((exists($toremove{$idx})) &&
2388: ($toremove{$idx} eq &LONCAPA::map::qtescape($src))) {
1.492 raeburn 2389: splice(@LONCAPA::map::order,$i,1);
1.529 raeburn 2390: if (ref($currparam{$idx}) eq 'ARRAY') {
2391: foreach my $name (@{$currparam{$idx}}) {
2392: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.492 raeburn 2393: }
2394: }
2395: next;
2396: }
2397: my $origsrc = $src;
1.532 raeburn 2398: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.492 raeburn 2399: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
2400: $changed = 1;
1.491 raeburn 2401: }
1.492 raeburn 2402: }
1.532 raeburn 2403: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.492 raeburn 2404: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
2405: if ($origsrc =~ m{^/uploaded/}) {
1.529 raeburn 2406: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.492 raeburn 2407: if ($src =~ /\.(page|sequence)$/) {
1.529 raeburn 2408: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.492 raeburn 2409: } else {
1.529 raeburn 2410: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.488 raeburn 2411: }
1.491 raeburn 2412: }
1.532 raeburn 2413: if ($origsrc =~ /\.(page|sequence)$/) {
2414: if ($newsubdir{$origsrc}) {
1.529 raeburn 2415: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.491 raeburn 2416: }
1.532 raeburn 2417: } elsif ($newsubdir{$key}) {
2418: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.488 raeburn 2419: }
2420: }
1.492 raeburn 2421: $changed = 1;
1.533 raeburn 2422: } elsif ($newdb{$idx} ne '') {
2423: $src = $newdb{$idx};
1.492 raeburn 2424: $changed = 1;
2425: }
2426: if ($changed) {
1.538 raeburn 2427: $LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type));
1.492 raeburn 2428: }
2429: }
2430: }
2431: foreach my $idx (keys(%remparam)) {
2432: if (ref($remparam{$idx}) eq 'ARRAY') {
2433: foreach my $name (@{$remparam{$idx}}) {
2434: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.491 raeburn 2435: }
2436: }
2437: }
1.533 raeburn 2438: if (values(%lockerrors) > 0) {
2439: $lockmsg = join('<br />',values(%lockerrors));
2440: }
1.491 raeburn 2441: my $storefn;
2442: if ($key eq $oldurl) {
2443: $storefn = $url;
2444: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
2445: } else {
2446: $storefn = $key;
2447: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2448: if ($prefixchg && $before{'map'} && $after{'map'}) {
2449: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.491 raeburn 2450: }
1.529 raeburn 2451: if ($newsubdir{$key}) {
2452: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.492 raeburn 2453: }
1.491 raeburn 2454: }
1.492 raeburn 2455: my $report;
2456: if ($folder !~ /^supplemental/) {
2457: $report = 1;
2458: }
1.527 raeburn 2459: (my $outtext,$errtext) =
1.492 raeburn 2460: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
2461: if ($errtext) {
1.529 raeburn 2462: if ($caller eq 'paste') {
1.533 raeburn 2463: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.529 raeburn 2464: }
1.491 raeburn 2465: }
2466: }
2467: }
1.533 raeburn 2468: return ('ok',\@msgs,$lockmsg);
1.491 raeburn 2469: }
2470:
2471: sub copy_dependencies {
2472: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
2473: my $content;
2474: if (ref($contentref)) {
2475: $content = $$contentref;
2476: } else {
2477: $content = &Apache::lonnet::getfile($item);
2478: }
2479: unless ($content eq '-1') {
2480: my $mm = new File::MMagic;
2481: my $mimetype = $mm->checktype_contents($content);
2482: if ($mimetype eq 'text/html') {
2483: my (%allfiles,%codebase,$state);
2484: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
2485: if ($res eq 'ok') {
2486: my ($numexisting,$numpathchanges,$existing);
2487: (undef,$numexisting,$numpathchanges,$existing) =
2488: &Apache::loncommon::ask_for_embedded_content(
2489: '/adm/coursedocs',$state,\%allfiles,\%codebase,
2490: {'error_on_invalid_names' => 1,
2491: 'ignore_remote_references' => 1,
2492: 'docs_url' => $item,
2493: 'context' => 'paste'});
2494: if ($numexisting > 0) {
2495: if (ref($existing) eq 'HASH') {
2496: foreach my $dep (keys(%{$existing})) {
2497: my $depfile = $dep;
2498: unless ($depfile =~ m{^\Q$relpath\E}) {
2499: $depfile = $relpath.$dep;
2500: }
2501: my $depcontent = &Apache::lonnet::getfile($depfile);
2502: unless ($depcontent eq '-1') {
2503: my $storedep = $dep;
2504: $storedep =~ s{^\Q$relpath\E}{};
2505: my $dep_url =
2506: &Apache::lonclonecourse::writefile(
2507: $env{'request.course.id'},
2508: $storefn.$storedep,$depcontent);
2509: if ($dep_url eq '/adm/notfound.html') {
2510: if (ref($errors) eq 'HASH') {
2511: $errors->{$depfile} = 1;
2512: }
2513: } else {
2514: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
2515: }
2516: }
2517: }
1.488 raeburn 2518: }
2519: }
2520: }
2521: }
2522: }
2523: return;
2524: }
2525:
1.329 droeschl 2526: my %parameter_type = ( 'randompick' => 'int_pos',
2527: 'hiddenresource' => 'string_yesno',
2528: 'encrypturl' => 'string_yesno',
2529: 'randomorder' => 'string_yesno',);
2530: my $valid_parameters_re = join('|',keys(%parameter_type));
2531: # set parameters
2532: sub update_parameter {
1.537 raeburn 2533: if ($env{'form.changeparms'} eq 'all') {
2534: my (@allidx,@allmapidx,%allchecked,%currchecked);
2535: %allchecked = (
2536: 'hiddenresource' => {},
2537: 'encrypturl' => {},
2538: 'randompick' => {},
2539: 'randomorder' => {},
2540: );
2541: foreach my $which (keys(%allchecked)) {
2542: $env{'form.all'.$which} =~ s/,$//;
2543: if ($which eq 'randompick') {
2544: foreach my $item (split(/,/,$env{'form.all'.$which})) {
2545: my ($res,$value) = split(/:/,$item);
2546: if ($value =~ /^\d+$/) {
2547: $allchecked{$which}{$res} = $value;
2548: }
2549: }
2550: } else {
1.539 raeburn 2551: if ($env{'form.all'.$which}) {
2552: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
2553: }
1.537 raeburn 2554: }
2555: }
2556: my $haschanges = 0;
2557: foreach my $res (@LONCAPA::map::order) {
2558: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2559: $name=&LONCAPA::map::qtescape($name);
2560: $url=&LONCAPA::map::qtescape($url);
2561: next unless ($name && $url);
2562: my $is_map;
2563: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
2564: $is_map = 1;
2565: }
2566: foreach my $which (keys(%allchecked)) {
2567: if (($which eq 'randompick' || $which eq 'randomorder')) {
2568: next if (!$is_map);
2569: }
2570: my $oldvalue = 0;
2571: my $newvalue = 0;
2572: if ($allchecked{$which}{$res}) {
2573: $newvalue = $allchecked{$which}{$res};
2574: }
2575: my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
2576: if ($which eq 'randompick') {
2577: if ($current =~ /^(\d+)$/) {
2578: $oldvalue = $1;
2579: }
2580: } else {
2581: if ($current =~ /^yes$/i) {
2582: $oldvalue = 1;
2583: }
2584: }
2585: if ($oldvalue ne $newvalue) {
2586: $haschanges = 1;
2587: if ($newvalue) {
2588: my $storeval = 'yes';
2589: if ($which eq 'randompick') {
2590: $storeval = $newvalue;
2591: }
2592: &LONCAPA::map::storeparameter($res,'parameter_'.$which,
2593: $storeval,
2594: $parameter_type{$which});
2595: &remember_parms($res,$which,'set',$storeval);
2596: } elsif ($oldvalue) {
2597: &LONCAPA::map::delparameter($res,'parameter_'.$which);
2598: &remember_parms($res,$which,'del');
2599: }
2600: }
2601: }
2602: }
2603: return $haschanges;
2604: } else {
2605: return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1.329 droeschl 2606:
1.537 raeburn 2607: my $which = $env{'form.changeparms'};
2608: my $idx = $env{'form.setparms'};
2609: if ($env{'form.'.$which.'_'.$idx}) {
2610: my $value = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
2611: : 'yes';
2612: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
2613: $parameter_type{$which});
2614: &remember_parms($idx,$which,'set',$value);
2615: } else {
2616: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
1.329 droeschl 2617:
1.537 raeburn 2618: &remember_parms($idx,$which,'del');
2619: }
2620: return 1;
1.329 droeschl 2621: }
2622: }
2623:
2624:
2625: sub handle_edit_cmd {
2626: my ($coursenum,$coursedom) =@_;
1.543 raeburn 2627: if ($env{'form.cmd'} eq '') {
2628: return 0;
2629: }
1.329 droeschl 2630: my ($cmd,$idx)=split('_',$env{'form.cmd'});
2631:
2632: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
2633: my ($title, $url, @rrest) = split(':', $ratstr);
2634:
1.538 raeburn 2635: if ($cmd eq 'remove') {
1.329 droeschl 2636: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 2637: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 2638: &Apache::lonnet::removeuploadedurl($url);
2639: } else {
2640: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2641: }
2642: splice(@LONCAPA::map::order, $idx, 1);
2643:
2644: } elsif ($cmd eq 'cut') {
2645: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2646: splice(@LONCAPA::map::order, $idx, 1);
2647:
1.344 bisitz 2648: } elsif ($cmd eq 'up'
1.329 droeschl 2649: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
2650: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
2651:
2652: } elsif ($cmd eq 'down'
2653: && defined($LONCAPA::map::order[$idx+1])) {
2654: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
2655:
2656: } elsif ($cmd eq 'rename') {
2657: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
2658: if ($comment=~/\S/) {
2659: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
2660: $comment.':'.join(':', $url, @rrest);
2661: }
2662: # Devalidate title cache
2663: my $renamed_url=&LONCAPA::map::qtescape($url);
2664: &Apache::lonnet::devalidate_title_cache($renamed_url);
1.538 raeburn 2665:
1.329 droeschl 2666: } else {
2667: return 0;
2668: }
2669: return 1;
2670: }
2671:
2672: sub editor {
1.458 raeburn 2673: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.508 raeburn 2674: $supplementalflag,$orderhash,$iconpath,$pathitem)=@_;
1.519 raeburn 2675: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
1.510 raeburn 2676: if ($allowed) {
1.519 raeburn 2677: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
2678: $is_random_order,$container) =
1.510 raeburn 2679: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
2680: $r->print($breadcrumbtrail);
1.519 raeburn 2681: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
2682: $container = 'page';
2683: } else {
2684: $container = 'sequence';
1.510 raeburn 2685: }
1.484 raeburn 2686:
1.525 raeburn 2687: my $jumpto;
2688:
2689: unless ($supplementalflag) {
1.546 raeburn 2690: $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1.525 raeburn 2691: }
1.484 raeburn 2692:
2693: unless ($allowed) {
2694: $randompick = -1;
2695: }
2696:
1.329 droeschl 2697: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
2698: $folder.'.'.$container);
2699: return $errtext if ($fatal);
2700:
2701: if ($#LONCAPA::map::order<1) {
2702: my $idx=&LONCAPA::map::getresidx();
2703: if ($idx<=0) { $idx=1; }
2704: $LONCAPA::map::order[0]=$idx;
2705: $LONCAPA::map::resources[$idx]='';
2706: }
1.364 bisitz 2707:
1.329 droeschl 2708: # ------------------------------------------------------------ Process commands
2709:
2710: # ---------------- if they are for this folder and user allowed to make changes
2711: if (($allowed) && ($env{'form.folder'} eq $folder)) {
2712: # set parameters and change order
2713: &snapshotbefore();
2714:
2715: if (&update_parameter()) {
2716: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
2717: return $errtext if ($fatal);
2718: }
2719:
2720: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
2721: # change order
2722: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
2723: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
2724:
2725: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
2726: return $errtext if ($fatal);
2727: }
1.364 bisitz 2728:
1.329 droeschl 2729: if ($env{'form.pastemarked'}) {
1.491 raeburn 2730: my %paste_errors;
1.533 raeburn 2731: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.492 raeburn 2732: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
2733: \%paste_errors);
1.541 raeburn 2734: if (ref($pastemsgarray) eq 'ARRAY') {
2735: if (@{$pastemsgarray} > 0) {
2736: $r->print('<p class="LC_info">'.
2737: join('<br />',@{$pastemsgarray}).
1.533 raeburn 2738: '</p>');
2739: }
1.541 raeburn 2740: }
2741: if ($lockerror) {
2742: $r->print('<p class="LC_error">'.
2743: $lockerror.
2744: '</p>');
2745: }
2746: if ($save_error ne '') {
2747: return $save_error;
2748: }
2749: if ($paste_res) {
2750: my %errortext = &Apache::lonlocal::texthash (
2751: fail => 'Storage of folder contents failed',
2752: failread => 'Reading folder contents failed',
2753: failstore => 'Storage of folder contents failed',
2754: );
2755: if ($errortext{$paste_res}) {
2756: $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
1.492 raeburn 2757: }
1.329 droeschl 2758: }
1.491 raeburn 2759: if (keys(%paste_errors) > 0) {
1.538 raeburn 2760: $r->print('<p class="LC_warning">'."\n".
1.491 raeburn 2761: &mt('The following files are either dependencies of a web page or references within a folder and/or composite page which could not be copied during the paste operation:')."\n".
2762: '<ul>'."\n");
2763: foreach my $key (sort(keys(%paste_errors))) {
2764: $r->print('<li>'.$key.'</li>'."\n");
2765: }
2766: $r->print('</ul></p>'."\n");
2767: }
1.538 raeburn 2768: } elsif ($env{'form.clearmarked'}) {
2769: my $output = &do_buffer_empty();
2770: if ($output) {
2771: $r->print('<p class="LC_info">'.$output.'</p>');
2772: }
2773: }
1.329 droeschl 2774:
2775: $r->print($upload_output);
2776:
1.538 raeburn 2777: # Rename, cut, copy or remove a single resource
1.329 droeschl 2778: if (&handle_edit_cmd()) {
1.492 raeburn 2779: my $contentchg;
1.538 raeburn 2780: if ($env{'form.cmd'} =~ m{^(del|cut)_}) {
1.492 raeburn 2781: $contentchg = 1;
2782: }
2783: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 2784: return $errtext if ($fatal);
2785: }
1.538 raeburn 2786:
2787: # Cut, copy and/or remove multiple resources
2788: if ($env{'form.multichange'}) {
2789: my %allchecked = (
2790: cut => {},
2791: remove => {},
2792: );
2793: my $needsupdate;
2794: foreach my $which (keys(%allchecked)) {
2795: $env{'form.multi'.$which} =~ s/,$//;
2796: if ($env{'form.multi'.$which}) {
2797: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which});
2798: if (ref($allchecked{$which}) eq 'HASH') {
2799: $needsupdate += scalar(keys(%{$allchecked{$which}}));
2800: }
2801: }
2802: }
2803: if ($needsupdate) {
2804: my $haschanges = 0;
2805: my %curr_groups = &Apache::longroup::coursegroups();
2806: my $total = scalar(@LONCAPA::map::order) - 1;
2807: for (my $i=$total; $i>=0; $i--) {
2808: my $res = $LONCAPA::map::order[$i];
2809: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2810: $name=&LONCAPA::map::qtescape($name);
2811: $url=&LONCAPA::map::qtescape($url);
2812: next unless ($name && $url);
2813: my %denied =
2814: &action_restrictions($coursenum,$coursedom,$url,
2815: $env{'form.folderpath'},\%curr_groups);
2816: foreach my $which (keys(%allchecked)) {
2817: next if ($denied{$which});
2818: next unless ($allchecked{$which}{$res});
2819: if ($which eq 'remove') {
2820: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
2821: ($url!~/$LONCAPA::assess_page_seq_re/)) {
2822: &Apache::lonnet::removeuploadedurl($url);
2823: } else {
2824: &LONCAPA::map::makezombie($res);
2825: }
2826: splice(@LONCAPA::map::order,$i,1);
2827: $haschanges ++;
2828: } elsif ($which eq 'cut') {
2829: &LONCAPA::map::makezombie($res);
2830: splice(@LONCAPA::map::order,$i,1);
2831: $haschanges ++;
2832: }
2833: }
2834: }
2835: if ($haschanges) {
2836: ($errtext,$fatal) =
2837: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
2838: return $errtext if ($fatal);
2839: }
2840: }
2841: }
2842:
1.329 droeschl 2843: # Group import/search
2844: if ($env{'form.importdetail'}) {
2845: my @imports;
2846: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
2847: if (defined($item)) {
2848: my ($name,$url,$residx)=
1.533 raeburn 2849: map { &unescape($_); } split(/\=/,$item);
2850: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
2851: my ($suffix,$errortxt,$locknotfreed) =
2852: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.504 raeburn 2853: if ($locknotfreed) {
2854: $r->print($locknotfreed);
2855: }
2856: if ($suffix) {
2857: $url =~ s/_new\./_$suffix./;
2858: } else {
2859: return $errortxt;
2860: }
1.533 raeburn 2861: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
2862: my $type = $1;
2863: my ($suffix,$errortxt,$locknotfreed) =
2864: &new_timebased_suffix($coursedom,$coursenum,$type);
2865: if ($locknotfreed) {
2866: $r->print($locknotfreed);
2867: }
2868: if ($suffix) {
2869: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
2870: } else {
2871: return $errortxt;
2872: }
1.534 raeburn 2873: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
2874: if ($supplementalflag) {
2875: next unless ($1 eq 'supplemental');
2876: if ($folder eq 'supplemental') {
2877: next unless ($2 eq 'default');
2878: } else {
2879: next unless ($folder eq 'supplemental_'.$2);
2880: }
2881: } else {
2882: next unless ($1 eq 'docs');
2883: if ($folder eq 'default') {
2884: next unless ($2 eq 'default');
2885: } else {
2886: next unless ($folder eq 'default_'.$2);
2887: }
2888: }
1.504 raeburn 2889: }
1.329 droeschl 2890: push(@imports, [$name, $url, $residx]);
2891: }
2892: }
1.530 raeburn 2893: ($errtext,$fatal,my $fixuperrors) =
1.529 raeburn 2894: &group_import($coursenum, $coursedom, $folder,$container,
2895: 'londocs',@imports);
1.329 droeschl 2896: return $errtext if ($fatal);
1.529 raeburn 2897: if ($fixuperrors) {
2898: $r->print($fixuperrors);
2899: }
1.329 droeschl 2900: }
2901: # Loading a complete map
2902: if ($env{'form.loadmap'}) {
2903: if ($env{'form.importmap'}=~/\w/) {
2904: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
2905: my ($title,$url,$ext,$type)=split(/\:/,$res);
2906: my $idx=&LONCAPA::map::getresidx($url);
2907: $LONCAPA::map::resources[$idx]=$res;
2908: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
2909: }
2910: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 2911: $folder.'.'.$container,1);
1.329 droeschl 2912: return $errtext if ($fatal);
2913: } else {
2914: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 2915:
1.329 droeschl 2916: }
2917: }
2918: &log_differences($plain);
2919: }
2920: # ---------------------------------------------------------------- End commands
2921: # ---------------------------------------------------------------- Print screen
2922: my $idx=0;
2923: my $shown=0;
2924: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 2925: $r->print('<div class="LC_Box">'.
1.432 raeburn 2926: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
2927: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
2928: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
2929: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
2930: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 2931: '</ol>');
1.381 bisitz 2932: if ($randompick>=0) {
2933: $r->print('<p class="LC_warning">'
2934: .&mt('Caution: this folder is set to randomly pick a subset'
2935: .' of resources. Adding or removing resources from this'
2936: .' folder will change the set of resources that the'
2937: .' students see, resulting in spurious or missing credit'
2938: .' for completed problems, not limited to ones you'
2939: .' modify. Do not modify the contents of this folder if'
2940: .' it is in active student use.')
2941: .'</p>'
2942: );
2943: }
2944: if ($is_random_order) {
2945: $r->print('<p class="LC_warning">'
2946: .&mt('Caution: this folder is set to randomly order its'
2947: .' contents. Adding or removing resources from this folder'
2948: .' will change the order of resources shown.')
2949: .'</p>'
2950: );
2951: }
2952: $r->print('</div>');
1.364 bisitz 2953: }
1.381 bisitz 2954:
1.538 raeburn 2955: my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
2956: %filters = (
1.543 raeburn 2957: canremove => [],
2958: cancut => [],
2959: cancopy => [],
2960: hiddenresource => [],
2961: encrypturl => [],
2962: randomorder => [],
2963: randompick => [],
1.538 raeburn 2964: );
2965: %curr_groups = &Apache::longroup::coursegroups();
1.424 onken 2966: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 2967: foreach my $res (@LONCAPA::map::order) {
2968: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2969: $name=&LONCAPA::map::qtescape($name);
2970: $url=&LONCAPA::map::qtescape($url);
2971: unless ($name) { $name=(split(/\//,$url))[-1]; }
2972: unless ($name) { $idx++; next; }
1.537 raeburn 2973: push(@allidx,$res);
2974: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
2975: push(@allmapidx,$res);
2976: }
1.381 bisitz 2977: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.501 raeburn 2978: $coursenum,$coursedom,$crstype,
1.538 raeburn 2979: $pathitem,$supplementalflag,$container,
2980: \%filters,\%curr_groups);
1.381 bisitz 2981: $idx++;
2982: $shown++;
1.329 droeschl 2983: }
1.424 onken 2984: &Apache::loncommon::end_data_table_count();
1.510 raeburn 2985:
1.538 raeburn 2986: my $need_save;
1.510 raeburn 2987: if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) {
1.544 raeburn 2988: my $toolslink;
2989: if ($allowed || &Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
2990: $toolslink = '<table><tr><td>'
1.520 raeburn 2991: .&Apache::loncommon::help_open_menu('Navigation Screen',
2992: 'Navigation_Screen',undef,'RAT')
2993: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
2994: .'<td align="left"><ul id="LC_toolbar">'
1.525 raeburn 2995: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.520 raeburn 2996: .'id="LC_content_toolbar_edittoplevel" '
2997: .'class="LC_toolbarItem" '
2998: .'title="'.&mt('Supplemental Content Editor').'">'
2999: .'</a></li></ul></td></tr></table><br />';
1.544 raeburn 3000: }
1.510 raeburn 3001: if ($shown) {
3002: if ($allowed) {
3003: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
3004: .&Apache::loncommon::start_data_table(undef,'contentlist')
3005: .&Apache::loncommon::start_data_table_header_row()
3006: .'<th colspan="2">'.&mt('Move').'</th>'
1.538 raeburn 3007: .'<th colspan="2">'.&mt('Actions').'</th>'
3008: .'<th>'.&mt('Document').'</th>';
1.510 raeburn 3009: if ($folder !~ /^supplemental/) {
3010: $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
3011: }
1.537 raeburn 3012: $to_show .= &Apache::loncommon::end_data_table_header_row();
3013: if ($folder !~ /^supplemental/) {
1.538 raeburn 3014: $lists{'canhide'} = join(',',@allidx);
3015: $lists{'canrandomlyorder'} = join(',',@allmapidx);
1.543 raeburn 3016: my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
3017: 'randomorder','randompick');
3018: foreach my $item (@possfilters) {
1.538 raeburn 3019: if (ref($filters{$item}) eq 'ARRAY') {
1.543 raeburn 3020: if (@{$filters{$item}} > 0) {
3021: $lists{$item} = join(',',@{$filters{$item}});
3022: }
1.538 raeburn 3023: }
3024: }
1.537 raeburn 3025: if (@allidx > 0) {
3026: my $path;
3027: if ($env{'form.folderpath'}) {
3028: $path =
3029: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3030: }
1.538 raeburn 3031: if (@allidx > 1) {
3032: $to_show .=
3033: &Apache::loncommon::continue_data_table_row().
3034: '<td colspan="2"> </td>'.
3035: '<td>'.
3036: &multiple_check_form('actions',\%lists).
3037: '</td>'.
3038: '<td> </td>'.
3039: '<td> </td>'.
3040: '<td colspan="4">'.
3041: &multiple_check_form('settings',\%lists).
3042: '</td>'.
3043: &Apache::loncommon::end_data_table_row();
3044: $need_save = 1;
3045: }
1.537 raeburn 3046: }
3047: }
3048: $to_show .= $output.' '
1.510 raeburn 3049: .&Apache::loncommon::end_data_table()
3050: .'<br style="line-height:2px;" />'
3051: .&Apache::loncommon::end_scrollbox();
3052: } else {
1.520 raeburn 3053: $to_show .= $toolslink
1.510 raeburn 3054: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3055: .$output.' '
3056: .&Apache::loncommon::end_data_table();
1.393 raeburn 3057: }
1.510 raeburn 3058: } else {
1.520 raeburn 3059: if (!$allowed) {
3060: $to_show .= $toolslink;
3061: }
1.510 raeburn 3062: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
3063: .'<div class="LC_info" id="contentlist">'
1.550 raeburn 3064: .&mt('Currently empty')
1.510 raeburn 3065: .'</div>'
3066: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 3067: }
3068: } else {
1.510 raeburn 3069: if ($shown) {
3070: $to_show = '<div>'
3071: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3072: .$output
3073: .&Apache::loncommon::end_data_table()
3074: .'</div>';
3075: } else {
3076: $to_show = '<div class="LC_info" id="contentlist">'
1.550 raeburn 3077: .&mt('Currently empty')
1.510 raeburn 3078: .'</div>'
3079: }
1.458 raeburn 3080: }
3081: my $tid = 1;
3082: if ($supplementalflag) {
3083: $tid = 2;
1.329 droeschl 3084: }
3085: if ($allowed) {
1.484 raeburn 3086: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1.538 raeburn 3087: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
3088: $jumpto,$readfile,$need_save,"$folder.$container"));
1.492 raeburn 3089: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
1.460 raeburn 3090: } else {
3091: $r->print($to_show);
1.329 droeschl 3092: }
3093: return;
3094: }
3095:
1.538 raeburn 3096: sub multiple_check_form {
3097: my ($caller,$listsref) = @_;
3098: return unless (ref($listsref) eq 'HASH');
3099: my $output =
3100: '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
3101: '<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
3102: '<label><input type="radio" name="showmultpick" value="0" onclick="javascript:togglePick('."'$caller','0'".');" checked="checked" />'.&mt('one').'</label>'.(' 'x2).'<label><input type="radio" name="showmultpick" value="1" onclick="javascript:togglePick('."'$caller','1'".');" />'.&mt('multiple').'</label></span><span id="more'.$caller.'" class="LC_nobreak LC_docs_ext_edit"></span></form>'.
3103: '<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'.
3104: '<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n".
3105: '<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n";
3106: if ($caller eq 'settings') {
3107: $output .=
3108: '<table><tr>'.
3109: '<td class="LC_docs_entry_parameter">'.
3110: '<span class="LC_nobreak"><label>'.
3111: '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')" />'.&mt('Hidden').
3112: '</label></span></td>'.
3113: '<td class="LC_docs_entry_parameter">'.
3114: '<span class="LC_nobreak"><label><input type="checkbox" name="randompickall" id="randompickall" onclick="updatePick(this.form,'."'all','check'".');propagateState(this.form,'."'randompick'".');propagateState(this.form,'."'rpicknum'".');" />'.&mt('Randomly Pick').'</label><span id="rpicktextall"></span><input type="hidden" name="rpicknumall" id="rpicknumall" value="" />'.
3115: '</span></td>'.
3116: '</tr>'."\n".
3117: '<tr>'.
3118: '<td class="LC_docs_entry_parameter">'.
3119: '<span class="LC_nobreak"><label><input type="checkbox" name="encrypturlall" id="encrypturlall" onclick="propagateState(this.form,'."'encrypturl'".')" />'.&mt('URL hidden').'</label></span></td><td class="LC_docs_entry_parameter"><span class="LC_nobreak"><label><input type="checkbox" name="randomorderall" id="randomorderall" onclick="propagateState(this.form,'."'randomorder'".')" />'.&mt('Random Order').
3120: '</label></span>'.
3121: '</td></tr></table>'."\n";
3122: } else {
3123: $output .=
3124: '<table><tr>'.
3125: '<td class="LC_docs_entry_parameter">'.
3126: '<span class="LC_nobreak LC_docs_remove">'.
3127: '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')" />'.&mt('Remove').
3128: '</label></span></td>'.
3129: '<td class="LC_docs_entry_parameter">'.
3130: '<span class="LC_nobreak LC_docs_cut">'.
3131: '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');" />'.&mt('Cut').
3132: '</label></span></td>'."\n".
3133: '<td class="LC_docs_entry_parameter">'.
3134: '<span class="LC_nobreak LC_docs_copy">'.
3135: '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')" />'.&mt('Copy').
3136: '</label></span></td>'.
3137: '</tr></table>'."\n";
3138: }
3139: $output .=
3140: '</fieldset>'.
3141: '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
3142: if ($caller eq 'settings') {
3143: $output .=
1.543 raeburn 3144: '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
3145: '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
3146: '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
3147: '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
3148: '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
1.538 raeburn 3149: } elsif ($caller eq 'actions') {
3150: $output .=
3151: '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
3152: '<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'.
3153: '<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />';
3154: }
3155: $output .=
3156: '</form>'.
3157: '</div>';
3158: return $output;
3159: }
3160:
1.329 droeschl 3161: sub process_file_upload {
1.552 raeburn 3162: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
1.329 droeschl 3163: # upload a file, if present
1.552 raeburn 3164: my $filesize = length($env{'form.uploaddoc'});
3165: if (!$filesize) {
3166: $$upload_output = '<div class="LC_error">'.
3167: &mt('Unable to upload [_1]. (size = [_2] bytes)',
3168: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
3169: $filesize).'<br />'.
3170: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
3171: '</div>';
3172: return;
3173: }
3174: my $quotatype = 'unofficial';
3175: if ($crstype eq 'Community') {
3176: $quotatype = 'community';
3177: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) {
3178: $quotatype = 'official';
1.573 raeburn 3179: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
3180: $quotatype = 'textbook';
1.552 raeburn 3181: }
3182: if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
3183: $filesize = int($filesize/1000); #expressed in kb
3184: $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
3185: $env{'form.uploaddoc.filename'},$filesize,'upload');
3186: return if ($$upload_output);
3187: }
1.440 raeburn 3188: my ($parseaction,$showupload,$nextphase,$mimetype);
3189: if ($env{'form.parserflag'}) {
1.329 droeschl 3190: $parseaction = 'parse';
3191: }
3192: my $folder=$env{'form.folder'};
3193: if ($folder eq '') {
3194: $folder='default';
3195: }
3196: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
3197: my $errtext='';
3198: my $fatal=0;
3199: my $container='sequence';
1.519 raeburn 3200: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 3201: $container='page';
3202: }
3203: ($errtext,$fatal)=
1.534 raeburn 3204: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 3205: if ($#LONCAPA::map::order<1) {
3206: $LONCAPA::map::order[0]=1;
3207: $LONCAPA::map::resources[1]='';
3208: }
3209: my $destination = 'docs/';
3210: if ($folder =~ /^supplemental/) {
3211: $destination = 'supplemental/';
3212: }
3213: if (($folder eq 'default') || ($folder eq 'supplemental')) {
3214: $destination .= 'default/';
3215: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
3216: $destination .= $2.'/';
3217: }
1.534 raeburn 3218: if ($fatal) {
3219: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</div>';
3220: return;
3221: }
1.440 raeburn 3222: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 3223: my $newidx=&LONCAPA::map::getresidx();
3224: $destination .= $newidx;
1.439 raeburn 3225: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 3226: $parseaction,$allfiles,
1.440 raeburn 3227: $codebase,undef,undef,undef,undef,
3228: undef,undef,\$mimetype);
3229: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
3230: my $stored = $1;
3231: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
3232: $stored.'</span>').'</p>';
3233: } else {
3234: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
3235:
1.457 raeburn 3236: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 3237: return;
3238: }
1.329 droeschl 3239: my $ext='false';
3240: if ($url=~m{^http://}) { $ext='true'; }
3241: $url = &LONCAPA::map::qtunescape($url);
3242: my $comment=$env{'form.comment'};
3243: $comment = &LONCAPA::map::qtunescape($comment);
3244: if ($folder=~/^supplemental/) {
3245: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
3246: $env{'user.domain'}.'___&&&___'.$comment;
3247: }
3248:
3249: $LONCAPA::map::resources[$newidx]=
3250: $comment.':'.$url.':'.$ext.':normal:res';
3251: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
3252: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 3253: $folder.'.'.$container,1);
1.329 droeschl 3254: if ($fatal) {
1.457 raeburn 3255: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 3256: return;
1.329 droeschl 3257: } else {
1.440 raeburn 3258: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
3259: $$upload_output = $showupload;
1.384 raeburn 3260: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 3261: if ($total_embedded > 0) {
1.440 raeburn 3262: my $uploadphase = 'upload_embedded';
3263: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
3264: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
3265: my ($embedded,$num) =
3266: &Apache::loncommon::ask_for_embedded_content(
3267: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
3268: if ($embedded) {
3269: if ($num) {
3270: $$upload_output .=
3271: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
3272: $nextphase = $uploadphase;
3273: } else {
3274: $$upload_output .= $embedded;
3275: }
3276: } else {
3277: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
3278: }
1.329 droeschl 3279: } else {
1.440 raeburn 3280: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 3281: }
1.457 raeburn 3282: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.476 raeburn 3283: } elsif (&Apache::loncommon::is_archive_file($mimetype)) {
3284: $nextphase = 'decompress_uploaded';
3285: my $position = scalar(@LONCAPA::map::order)-1;
3286: my $noextract = &return_to_editor();
3287: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
3288: my %archiveitems = (
3289: folderpath => $env{'form.folderpath'},
3290: cmd => $nextphase,
3291: newidx => $newidx,
3292: position => $position,
3293: phase => $nextphase,
1.477 raeburn 3294: comment => $comment,
1.480 raeburn 3295: );
3296: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
3297: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 3298: $$upload_output = $showupload.
3299: &Apache::loncommon::decompress_form($mimetype,
3300: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 3301: \%archiveitems,\@current);
1.329 droeschl 3302: }
3303: }
3304: }
1.440 raeburn 3305: return $nextphase;
1.329 droeschl 3306: }
3307:
1.480 raeburn 3308: sub get_dir_list {
3309: my ($url,$coursenum,$coursedom,$newidx) = @_;
3310: my ($destination,$dir_root) = &embedded_destination();
3311: my ($dirlistref,$listerror) =
3312: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
3313: my @dir_lines;
3314: my $dirptr=16384;
3315: if (ref($dirlistref) eq 'ARRAY') {
3316: foreach my $dir_line (sort
3317: {
3318: my ($afile)=split('&',$a,2);
3319: my ($bfile)=split('&',$b,2);
3320: return (lc($afile) cmp lc($bfile));
3321: } (@{$dirlistref})) {
3322: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
3323: $filename =~ s/\s+$//;
3324: next if ($filename =~ /^\.\.?$/);
3325: my $isdir = 0;
3326: if ($dirptr&$testdir) {
3327: $isdir = 1;
3328: }
3329: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
3330: }
3331: }
3332: return @dir_lines;
3333: }
3334:
1.329 droeschl 3335: sub is_supplemental_title {
3336: my ($title) = @_;
3337: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
3338: }
3339:
3340: # --------------------------------------------------------------- An entry line
3341:
3342: sub entryline {
1.501 raeburn 3343: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.538 raeburn 3344: $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups)=@_;
1.519 raeburn 3345: my ($foldertitle,$renametitle);
1.329 droeschl 3346: if (&is_supplemental_title($title)) {
1.488 raeburn 3347: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 3348: } else {
3349: $title=&HTML::Entities::encode($title,'"<>&\'');
3350: $renametitle=$title;
3351: $foldertitle=$title;
3352: }
3353:
3354: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 3355:
1.329 droeschl 3356: $renametitle=~s/\\/\\\\/g;
3357: $renametitle=~s/\"\;/\\\"/g;
1.576 ! raeburn 3358: $renametitle=~s/\'/\\\'/g;
1.329 droeschl 3359: $renametitle=~s/ /%20/g;
1.379 bisitz 3360: my $line=&Apache::loncommon::start_data_table_row();
1.538 raeburn 3361: my ($form_start,$form_end,$form_common,$form_param);
1.329 droeschl 3362: # Edit commands
1.535 raeburn 3363: my ($esc_path, $path, $symb);
1.329 droeschl 3364: if ($env{'form.folderpath'}) {
3365: $esc_path=&escape($env{'form.folderpath'});
3366: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3367: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
3368: }
1.505 raeburn 3369: my $isexternal;
1.510 raeburn 3370: if ($residx) {
1.501 raeburn 3371: my $currurl = $url;
3372: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.505 raeburn 3373: if ($currurl =~ m{^/adm/wrapper/ext/}) {
3374: $isexternal = 1;
3375: }
1.510 raeburn 3376: if (!$supplementalflag) {
3377: my $path = 'uploaded/'.
3378: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
3379: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
3380: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
3381: $residx,
3382: &Apache::lonnet::declutter($currurl));
3383: }
1.501 raeburn 3384: }
1.538 raeburn 3385: my ($renamelink,%lt,$ishash);
3386: if (ref($filtersref) eq 'HASH') {
3387: $ishash = 1;
3388: }
3389:
1.329 droeschl 3390: if ($allowed) {
1.538 raeburn 3391: $form_start = '
3392: <form action="/adm/coursedocs" method="post">
3393: ';
3394: $form_common=(<<END);
3395: <input type="hidden" name="folderpath" value="$path" />
3396: <input type="hidden" name="symb" value="$symb" />
3397: END
3398: $form_param=(<<END);
3399: <input type="hidden" name="setparms" value="$orderidx" />
3400: <input type="hidden" name="changeparms" value="0" />
3401: END
3402: $form_end = '</form>';
3403:
1.329 droeschl 3404: my $incindex=$index+1;
3405: my $selectbox='';
1.471 raeburn 3406: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 3407: ((split(/\:/,
1.344 bisitz 3408: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
3409: ne '') &&
1.329 droeschl 3410: ((split(/\:/,
1.344 bisitz 3411: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 3412: ne '')) {
3413: $selectbox=
3414: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.373 bisitz 3415: '<select name="newpos" onchange="this.form.submit()">';
1.329 droeschl 3416: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
3417: if ($i==$incindex) {
1.358 bisitz 3418: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 3419: } else {
3420: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
3421: }
3422: }
3423: $selectbox.='</select>';
3424: }
1.501 raeburn 3425: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 3426: 'up' => 'Move Up',
3427: 'dw' => 'Move Down',
3428: 'rm' => 'Remove',
3429: 'ct' => 'Cut',
3430: 'rn' => 'Rename',
1.501 raeburn 3431: 'cp' => 'Copy',
3432: 'ex' => 'External Resource',
3433: 'ed' => 'Edit',
3434: 'pr' => 'Preview',
3435: 'sv' => 'Save',
3436: 'ul' => 'URL',
3437: 'ti' => 'Title',
3438: );
1.538 raeburn 3439: my %denied = &action_restrictions($coursenum,$coursedom,$url,
3440: $env{'form.folderpath'},
3441: $currgroups);
1.517 raeburn 3442: my ($copylink,$cutlink,$removelink);
1.329 droeschl 3443: my $skip_confirm = 0;
3444: if ( $folder =~ /^supplemental/
3445: || ($url =~ m{( /smppg$
3446: |/syllabus$
3447: |/aboutme$
3448: |/navmaps$
3449: |/bulletinboard$
1.505 raeburn 3450: |\.html$)}x)
3451: || $isexternal) {
1.329 droeschl 3452: $skip_confirm = 1;
3453: }
3454:
1.538 raeburn 3455: if ($denied{'copy'}) {
1.543 raeburn 3456: $copylink=(<<ENDCOPY)
1.507 raeburn 3457: <span style="visibility: hidden;">$lt{'cp'}</span>
3458: ENDCOPY
3459: } else {
1.538 raeburn 3460: my $formname = 'edit_copy_'.$orderidx;
3461: my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.329 droeschl 3462: $copylink=(<<ENDCOPY);
1.538 raeburn 3463: <form name="$formname" method="post" action="/adm/coursedocs">
3464: $form_common
1.540 raeburn 3465: <input type="checkbox" name="copy" id="copy_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','copy');" class="LC_hidden" /><a href="$js" class="LC_docs_copy">$lt{'cp'}</a>
1.538 raeburn 3466: $form_end
1.329 droeschl 3467: ENDCOPY
1.538 raeburn 3468: if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
3469: push(@{$filtersref->{'cancopy'}},$orderidx);
3470: }
1.329 droeschl 3471: }
1.538 raeburn 3472: if ($denied{'cut'}) {
1.507 raeburn 3473: $cutlink=(<<ENDCUT);
3474: <span style="visibility: hidden;">$lt{'ct'}</span>
3475: ENDCUT
3476: } else {
1.538 raeburn 3477: my $formname = 'edit_cut_'.$orderidx;
3478: my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.329 droeschl 3479: $cutlink=(<<ENDCUT);
1.538 raeburn 3480: <form name="$formname" method="post" action="/adm/coursedocs">
3481: $form_common
1.542 raeburn 3482: <input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
1.540 raeburn 3483: <input type="checkbox" name="cut" id="cut_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','cut');" class="LC_hidden" /><a href="$js" class="LC_docs_cut">$lt{'ct'}</a>
1.538 raeburn 3484: $form_end
1.329 droeschl 3485: ENDCUT
1.538 raeburn 3486: if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
3487: push(@{$filtersref->{'cancut'}},$orderidx);
3488: }
1.329 droeschl 3489: }
1.538 raeburn 3490: if ($denied{'remove'}) {
1.507 raeburn 3491: $removelink=(<<ENDREM);
3492: <span style="visibility: hidden;">$lt{'rm'}</a>
3493: ENDREM
3494: } else {
1.538 raeburn 3495: my $formname = 'edit_remove_'.$orderidx;
3496: my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm);";
1.497 raeburn 3497: $removelink=(<<ENDREM);
1.538 raeburn 3498: <form name="$formname" method="post" action="/adm/coursedocs">
3499: $form_common
1.542 raeburn 3500: <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
1.540 raeburn 3501: <input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a>
1.538 raeburn 3502: $form_end
1.497 raeburn 3503: ENDREM
1.538 raeburn 3504: if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
3505: push(@{$filtersref->{'canremove'}},$orderidx);
3506: }
1.497 raeburn 3507: }
1.551 raeburn 3508: $renamelink=(<<ENDREN);
1.519 raeburn 3509: <a href='javascript:changename("$esc_path","$index","$renametitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.507 raeburn 3510: ENDREN
1.329 droeschl 3511: $line.=(<<END);
3512: <td>
1.379 bisitz 3513: <div class="LC_docs_entry_move">
1.535 raeburn 3514: <a href='/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb'>
1.501 raeburn 3515: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 3516: </a>
3517: </div>
3518: <div class="LC_docs_entry_move">
1.536 raeburn 3519: <a href='/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb'>
1.501 raeburn 3520: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 3521: </a>
3522: </div>
1.329 droeschl 3523: </td>
3524: <td>
3525: $form_start
1.538 raeburn 3526: $form_param
1.478 raeburn 3527: $form_common
1.329 droeschl 3528: $selectbox
3529: $form_end
3530: </td>
1.540 raeburn 3531: <td class="LC_docs_entry_commands LC_nobreak">
1.497 raeburn 3532: $removelink
1.329 droeschl 3533: $cutlink
3534: $copylink
3535: </td>
3536: END
3537: }
3538: # Figure out what kind of a resource this is
3539: my ($extension)=($url=~/\.(\w+)$/);
3540: my $uploaded=($url=~/^\/*uploaded\//);
3541: my $icon=&Apache::loncommon::icon($url);
1.519 raeburn 3542: my $isfolder;
3543: my $ispage;
3544: my $containerarg;
1.329 droeschl 3545: if ($uploaded) {
1.472 raeburn 3546: if (($extension eq 'sequence') || ($extension eq 'page')) {
3547: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.519 raeburn 3548: $containerarg = $1;
1.472 raeburn 3549: if ($extension eq 'sequence') {
3550: $icon=$iconpath.'navmap.folder.closed.gif';
3551: $isfolder=1;
3552: } else {
3553: $icon=$iconpath.'page.gif';
3554: $ispage=1;
3555: }
3556: if ($allowed) {
3557: $url='/adm/coursedocs?';
3558: } else {
3559: $url='/adm/supplemental?';
3560: }
1.329 droeschl 3561: } else {
3562: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
3563: }
3564: }
1.364 bisitz 3565:
1.518 raeburn 3566: my ($editlink,$extresform);
1.329 droeschl 3567: my $orig_url = $url;
1.340 raeburn 3568: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.510 raeburn 3569: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.501 raeburn 3570: if (!$supplementalflag && $residx && $symb) {
3571: if ((!$isfolder) && (!$ispage)) {
3572: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
3573: $url=&Apache::lonnet::clutter($url);
3574: if ($url=~/^\/*uploaded\//) {
3575: $url=~/\.(\w+)$/;
3576: my $embstyle=&Apache::loncommon::fileembstyle($1);
3577: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
3578: $url='/adm/wrapper'.$url;
3579: } elsif ($embstyle eq 'ssi') {
3580: #do nothing with these
3581: } elsif ($url!~/\.(sequence|page)$/) {
3582: $url='/adm/coursedocs/showdoc'.$url;
3583: }
3584: } elsif ($url=~m|^/ext/|) {
3585: $url='/adm/wrapper'.$url;
1.329 droeschl 3586: }
1.501 raeburn 3587: if (&Apache::lonnet::symbverify($symb,$url)) {
3588: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
3589: } else {
3590: $url='';
3591: }
1.329 droeschl 3592: }
3593: }
1.478 raeburn 3594: my ($rand_pick_text,$rand_order_text);
1.519 raeburn 3595: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 3596: my $foldername=&escape($foldertitle);
3597: my $folderpath=$env{'form.folderpath'};
3598: if ($folderpath) { $folderpath.='&' };
1.510 raeburn 3599: if (!$allowed && $supplementalflag) {
1.519 raeburn 3600: $folderpath.=$containerarg.'&'.$foldername;
1.510 raeburn 3601: $url.='folderpath='.&escape($folderpath);
3602: } else {
1.344 bisitz 3603: # Append randompick number, hidden, and encrypted with ":" to foldername,
1.329 droeschl 3604: # so it gets transferred between levels
1.519 raeburn 3605: $folderpath.=$containerarg.'&'.$foldername.
1.510 raeburn 3606: ':'.(&LONCAPA::map::getparameter($orderidx,
1.329 droeschl 3607: 'parameter_randompick'))[0]
3608: .':'.((&LONCAPA::map::getparameter($orderidx,
3609: 'parameter_hiddenresource'))[0]=~/^yes$/i)
3610: .':'.((&LONCAPA::map::getparameter($orderidx,
3611: 'parameter_encrypturl'))[0]=~/^yes$/i)
3612: .':'.((&LONCAPA::map::getparameter($orderidx,
1.519 raeburn 3613: 'parameter_randomorder'))[0]=~/^yes$/i)
3614: .':'.$ispage;
1.510 raeburn 3615: $url.='folderpath='.&escape($folderpath);
3616: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
3617: 'parameter_randompick'))[0];
3618: my $rpckchk;
3619: if ($rpicknum) {
3620: $rpckchk = ' checked="checked"';
1.543 raeburn 3621: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
3622: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
3623: }
1.510 raeburn 3624: }
1.537 raeburn 3625: my $formname = 'edit_randompick_'.$orderidx;
1.510 raeburn 3626: $rand_pick_text =
1.478 raeburn 3627: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.538 raeburn 3628: $form_param."\n".
1.478 raeburn 3629: $form_common."\n".
1.537 raeburn 3630: '<span class="LC_nobreak"><label><input type="checkbox" name="randompick_'.$orderidx.'" id="randompick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="rpicknum_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" /><span id="randompicknum_'.$orderidx.'">';
1.510 raeburn 3631: if ($rpicknum ne '') {
3632: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
3633: }
1.537 raeburn 3634: $rand_pick_text .= '</span></span>'.
3635: $form_end;
1.543 raeburn 3636: my $ro_set;
3637: if ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i) {
3638: $ro_set = 'checked="checked"';
3639: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
3640: push(@{$filtersref->{'randomorder'}},$orderidx);
3641: }
3642: }
1.564 raeburn 3643: $formname = 'edit_rorder_'.$orderidx;
1.510 raeburn 3644: $rand_order_text =
1.537 raeburn 3645: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.538 raeburn 3646: $form_param."\n".
1.537 raeburn 3647: $form_common."\n".
1.538 raeburn 3648: '<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.' /> '.&mt('Random Order').' </label></span>'.
1.537 raeburn 3649: $form_end;
1.510 raeburn 3650: }
1.509 raeburn 3651: } elsif ($supplementalflag && !$allowed) {
1.510 raeburn 3652: $url .= ($url =~ /\?/) ? '&':'?';
1.509 raeburn 3653: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.510 raeburn 3654: if ($title) {
3655: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
3656: }
1.511 raeburn 3657: if ($isexternal && $orderidx) {
1.510 raeburn 3658: $url .= '&idx='.$orderidx;
3659: }
1.329 droeschl 3660: }
1.519 raeburn 3661: my ($tdalign,$tdwidth);
1.501 raeburn 3662: if ($allowed) {
3663: my $fileloc =
3664: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.510 raeburn 3665: if ($isexternal) {
1.518 raeburn 3666: ($editlink,$extresform) =
1.510 raeburn 3667: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem);
1.511 raeburn 3668: } elsif (!$isfolder && !$ispage) {
1.503 raeburn 3669: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
3670: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.511 raeburn 3671: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.501 raeburn 3672: my $jscall =
3673: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
3674: $switchserver,
1.503 raeburn 3675: $forceedit,
1.511 raeburn 3676: undef,$symb,
3677: &escape($env{'form.folderpath'}),
1.524 raeburn 3678: $renametitle,'','',1);
1.501 raeburn 3679: if ($jscall) {
1.518 raeburn 3680: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
3681: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.501 raeburn 3682: }
3683: }
3684: }
1.519 raeburn 3685: $tdalign = ' align="right" valign="top"';
3686: $tdwidth = ' width="80%"';
1.329 droeschl 3687: }
1.408 raeburn 3688: my $reinit;
3689: if ($crstype eq 'Community') {
3690: $reinit = &mt('(re-initialize community to access)');
3691: } else {
3692: $reinit = &mt('(re-initialize course to access)');
1.519 raeburn 3693: }
3694: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.472 raeburn 3695: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 3696: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
3697: } elsif ($url) {
1.484 raeburn 3698: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1.470 raeburn 3699: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
1.469 www 3700: } else {
3701: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
3702: }
1.519 raeburn 3703: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 3704: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 3705: $line.='<a href="'.$url.'">'.$title.'</a>';
3706: } elsif ($url) {
1.484 raeburn 3707: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1.470 raeburn 3708: $title,600,500);
1.469 www 3709: } else {
3710: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
3711: }
1.518 raeburn 3712: $line.="$extresform</td>";
1.478 raeburn 3713: $rand_pick_text = ' ' if ($rand_pick_text eq '');
3714: $rand_order_text = ' ' if ($rand_order_text eq '');
1.329 droeschl 3715: if (($allowed) && ($folder!~/^supplemental/)) {
3716: my %lt=&Apache::lonlocal::texthash(
3717: 'hd' => 'Hidden',
3718: 'ec' => 'URL hidden');
1.543 raeburn 3719: my ($enctext,$hidtext);
3720: if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
3721: $enctext = ' checked="checked"';
3722: if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
3723: push(@{$filtersref->{'encrypturl'}},$orderidx);
3724: }
3725: }
3726: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
3727: $hidtext = ' checked="checked"';
3728: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
3729: push(@{$filtersref->{'hiddenresource'}},$orderidx);
3730: }
3731: }
1.537 raeburn 3732: my $formhidden = 'edit_hiddenresource_'.$orderidx;
3733: my $formurlhidden = 'edit_encrypturl_'.$orderidx;
1.329 droeschl 3734: $line.=(<<ENDPARMS);
3735: <td class="LC_docs_entry_parameter">
1.537 raeburn 3736: <form action="/adm/coursedocs" method="post" name="$formhidden">
1.538 raeburn 3737: $form_param
1.478 raeburn 3738: $form_common
1.538 raeburn 3739: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext /> $lt{'hd'}</label>
1.329 droeschl 3740: $form_end
1.458 raeburn 3741: <br />
1.537 raeburn 3742: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.538 raeburn 3743: $form_param
1.478 raeburn 3744: $form_common
1.538 raeburn 3745: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext /> $lt{'ec'}</label>
1.329 droeschl 3746: $form_end
3747: </td>
1.478 raeburn 3748: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
3749: $rand_order_text</td>
1.329 droeschl 3750: ENDPARMS
3751: }
1.379 bisitz 3752: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 3753: return $line;
3754: }
3755:
1.538 raeburn 3756: sub action_restrictions {
3757: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
3758: my %denied = (
3759: cut => 0,
3760: copy => 0,
3761: remove => 0,
3762: );
3763: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
3764: # no copy for published maps
3765: $denied{'copy'} = 1;
3766: } elsif ($url=~m{^/res/lib/templates/}) {
3767: $denied{'copy'} = 1;
3768: $denied{'cut'} = 1;
3769: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
3770: if ($folderpath =~ /^default&[^\&]+$/) {
3771: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
3772: $denied{'remove'} = 1;
3773: }
3774: $denied{'cut'} = 1;
3775: $denied{'copy'} = 1;
3776: }
3777: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
3778: my $group = $1;
3779: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
3780: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
3781: $denied{'remove'} = 1;
3782: }
3783: }
3784: $denied{'cut'} = 1;
3785: $denied{'copy'} = 1;
3786: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
3787: my $group = $1;
3788: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
3789: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
3790: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
3791: if (keys(%groupsettings) > 0) {
3792: $denied{'remove'} = 1;
3793: }
3794: $denied{'cut'} = 1;
3795: $denied{'copy'} = 1;
3796: }
3797: }
3798: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
3799: my $group = $1;
3800: if ($url =~ /group_boards_\Q$group\E/) {
3801: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
3802: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
3803: if (keys(%groupsettings) > 0) {
3804: if (ref($groupsettings{'functions'}) eq 'HASH') {
3805: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
3806: $denied{'remove'} = 1;
3807: }
3808: }
3809: }
3810: $denied{'cut'} = 1;
3811: $denied{'copy'} = 1;
3812: }
3813: }
3814: }
3815: return %denied;
3816: }
3817:
1.533 raeburn 3818: sub new_timebased_suffix {
1.538 raeburn 3819: my ($dom,$num,$type,$area,$container) = @_;
1.533 raeburn 3820: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.538 raeburn 3821: if ($type eq 'paste') {
3822: $prefix = $type;
3823: $namespace = 'courseeditor';
3824: } elsif ($type eq 'map') {
1.533 raeburn 3825: $prefix = 'docs';
3826: if ($area eq 'supplemental') {
3827: $prefix = 'supp';
3828: }
3829: $prefix .= $container;
3830: $namespace = 'uploadedmaps';
3831: } else {
3832: $prefix = $type;
3833: $namespace = 'templated';
1.504 raeburn 3834: }
3835: $idtype = 'concat';
3836: my ($suffix,$freedlock,$error) =
1.538 raeburn 3837: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num);
1.504 raeburn 3838: if (!$suffix) {
1.538 raeburn 3839: if ($type eq 'paste') {
3840: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
3841: } elsif ($type eq 'map') {
1.533 raeburn 3842: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
3843: } elsif ($type eq 'smppg') {
3844: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
3845: } else {
1.565 bisitz 3846: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.533 raeburn 3847: }
1.504 raeburn 3848: if ($error) {
3849: $errtext .= '<br />'.$error;
3850: }
3851: }
3852: if ($freedlock ne 'ok') {
1.533 raeburn 3853: $locknotfreed =
3854: '<div class="LC_error">'.
3855: &mt('There was a problem removing a lockfile.').' ';
1.538 raeburn 3856: if ($type eq 'paste') {
3857: &mt('This will prevent use of the paste buffer until th next log-in.');
3858: } elsif ($type eq 'map') {
1.533 raeburn 3859: &mt('This will prevent creation of additional folders or composite pages in this course.');
3860: } elsif ($type eq 'smppg') {
3861: $locknotfreed .=
3862: &mt('This will prevent creation of additional simple pages in this course.');
3863: } else {
3864: $locknotfreed .=
1.565 bisitz 3865: &mt('This will prevent creation of additional discussion boards in this course.');
1.533 raeburn 3866: }
1.538 raeburn 3867: unless ($type eq 'paste') {
3868: $locknotfreed .=
1.560 raeburn 3869: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
3870: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.538 raeburn 3871: }
3872: $locknotfreed .= '</div>';
1.504 raeburn 3873: }
3874: return ($suffix,$errtext,$locknotfreed);
3875: }
3876:
1.329 droeschl 3877: =pod
3878:
3879: =item tiehash()
3880:
3881: tie the hash
3882:
3883: =cut
3884:
3885: sub tiehash {
3886: my ($mode)=@_;
3887: $hashtied=0;
3888: if ($env{'request.course.fn'}) {
3889: if ($mode eq 'write') {
3890: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
3891: &GDBM_WRCREAT(),0640)) {
3892: $hashtied=2;
3893: }
3894: } else {
3895: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
3896: &GDBM_READER(),0640)) {
3897: $hashtied=1;
3898: }
3899: }
1.364 bisitz 3900: }
1.329 droeschl 3901: }
3902:
3903: sub untiehash {
3904: if ($hashtied) { untie %hash; }
3905: $hashtied=0;
3906: return OK;
3907: }
3908:
3909:
3910:
3911:
3912: sub checkonthis {
3913: my ($r,$url,$level,$title)=@_;
3914: $url=&unescape($url);
3915: $alreadyseen{$url}=1;
3916: $r->rflush();
3917: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
3918: $r->print("\n<br />");
3919: if ($level==0) {
3920: $r->print("<br />");
3921: }
3922: for (my $i=0;$i<=$level*5;$i++) {
3923: $r->print(' ');
3924: }
3925: $r->print('<a href="'.$url.'" target="cat">'.
3926: ($title?$title:$url).'</a> ');
3927: if ($url=~/^\/res\//) {
3928: my $result=&Apache::lonnet::repcopy(
3929: &Apache::lonnet::filelocation('',$url));
3930: if ($result eq 'ok') {
3931: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
3932: $r->rflush();
3933: &Apache::lonnet::countacc($url);
3934: $url=~/\.(\w+)$/;
3935: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
3936: $r->print('<br />');
3937: $r->rflush();
3938: for (my $i=0;$i<=$level*5;$i++) {
3939: $r->print(' ');
3940: }
3941: $r->print('- '.&mt('Rendering:').' ');
3942: my ($errorcount,$warningcount)=split(/:/,
3943: &Apache::lonnet::ssi_body($url,
3944: ('grade_target'=>'web',
3945: 'return_only_error_and_warning_counts' => 1)));
3946: if (($errorcount) ||
3947: ($warningcount)) {
3948: if ($errorcount) {
1.369 bisitz 3949: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 3950: &mt('[quant,_1,error]',$errorcount).'</span>');
3951: }
3952: if ($warningcount) {
3953: $r->print('<span class="LC_warning">'.
3954: &mt('[quant,_1,warning]',$warningcount).'</span>');
3955: }
3956: } else {
3957: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
3958: }
3959: $r->rflush();
3960: }
3961: my $dependencies=
3962: &Apache::lonnet::metadata($url,'dependencies');
3963: foreach my $dep (split(/\,/,$dependencies)) {
3964: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
3965: &checkonthis($r,$dep,$level+1);
3966: }
3967: }
3968: } elsif ($result eq 'unavailable') {
3969: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
3970: } elsif ($result eq 'not_found') {
3971: unless ($url=~/\$/) {
1.521 bisitz 3972: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 3973: } else {
1.366 bisitz 3974: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 3975: }
3976: } else {
3977: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
3978: }
3979: }
3980: }
3981: }
3982:
3983:
3984:
3985: =pod
3986:
3987: =item list_symbs()
3988:
1.485 raeburn 3989: List Content Identifiers
1.329 droeschl 3990:
3991: =cut
3992:
3993: sub list_symbs {
3994: my ($r) = @_;
3995:
1.408 raeburn 3996: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 3997: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
3998: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
3999: $r->print(&startContentScreen('tools'));
1.329 droeschl 4000: my $navmap = Apache::lonnavmaps::navmap->new();
4001: if (!defined($navmap)) {
4002: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
4003: '<div class="LC_error">'.
4004: &mt('Unable to retrieve information about course contents').
4005: '</div>');
1.408 raeburn 4006: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 4007: } else {
1.484 raeburn 4008: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
4009: &Apache::loncommon::start_data_table().
4010: &Apache::loncommon::start_data_table_header_row().
4011: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
4012: &Apache::loncommon::end_data_table_header_row()."\n");
4013: my $count;
1.329 droeschl 4014: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 4015: $r->print(&Apache::loncommon::start_data_table_row().
4016: '<td>'.$res->compTitle().'</td>'.
4017: '<td>'.$res->symb().'</td>'.
1.521 bisitz 4018: &Apache::loncommon::end_data_table_row());
1.484 raeburn 4019: $count ++;
4020: }
4021: if (!$count) {
4022: $r->print(&Apache::loncommon::start_data_table_row().
4023: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
4024: &Apache::loncommon::end_data_table_row());
1.329 droeschl 4025: }
1.484 raeburn 4026: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 4027: }
1.521 bisitz 4028: $r->print(&endContentScreen());
1.329 droeschl 4029: }
4030:
4031:
4032: sub verifycontent {
4033: my ($r) = @_;
1.408 raeburn 4034: my $crstype = &Apache::loncommon::course_type();
1.549 raeburn 4035: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
4036: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 4037: $r->print(&startContentScreen('tools'));
4038: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 4039: $hashtied=0;
4040: undef %alreadyseen;
4041: %alreadyseen=();
4042: &tiehash();
1.484 raeburn 4043:
1.329 droeschl 4044: foreach my $key (keys(%hash)) {
4045: if ($hash{$key}=~/\.(page|sequence)$/) {
4046: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
4047: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 4048: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 4049: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 4050: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 4051: }
4052: }
4053: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
4054: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
4055: }
4056: }
4057: &untiehash();
1.442 www 4058: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.521 bisitz 4059: $r->print(&endContentScreen());
1.329 droeschl 4060: }
4061:
4062:
4063: sub devalidateversioncache {
4064: my $src=shift;
4065: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
4066: &Apache::lonnet::clutter($src));
4067: }
4068:
4069: sub checkversions {
4070: my ($r) = @_;
1.408 raeburn 4071: my $crstype = &Apache::loncommon::course_type();
1.571 raeburn 4072: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
4073: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 4074: $r->print(&startContentScreen('tools'));
1.442 www 4075:
1.329 droeschl 4076: my $header='';
4077: my $startsel='';
4078: my $monthsel='';
4079: my $weeksel='';
4080: my $daysel='';
4081: my $allsel='';
4082: my %changes=();
4083: my $starttime=0;
4084: my $haschanged=0;
4085: my %setversions=&Apache::lonnet::dump('resourceversions',
4086: $env{'course.'.$env{'request.course.id'}.'.domain'},
4087: $env{'course.'.$env{'request.course.id'}.'.num'});
4088:
4089: $hashtied=0;
4090: &tiehash();
4091: my %newsetversions=();
4092: if ($env{'form.setmostrecent'}) {
4093: $haschanged=1;
4094: foreach my $key (keys(%hash)) {
4095: if ($key=~/^ids\_(\/res\/.+)$/) {
4096: $newsetversions{$1}='mostrecent';
4097: &devalidateversioncache($1);
4098: }
4099: }
4100: } elsif ($env{'form.setcurrent'}) {
4101: $haschanged=1;
4102: foreach my $key (keys(%hash)) {
4103: if ($key=~/^ids\_(\/res\/.+)$/) {
4104: my $getvers=&Apache::lonnet::getversion($1);
4105: if ($getvers>0) {
4106: $newsetversions{$1}=$getvers;
4107: &devalidateversioncache($1);
4108: }
4109: }
4110: }
4111: } elsif ($env{'form.setversions'}) {
4112: $haschanged=1;
4113: foreach my $key (keys(%env)) {
4114: if ($key=~/^form\.set_version_(.+)$/) {
4115: my $src=$1;
4116: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
4117: $newsetversions{$src}=$env{$key};
4118: &devalidateversioncache($src);
4119: }
4120: }
4121: }
4122: }
4123: if ($haschanged) {
4124: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
4125: $env{'course.'.$env{'request.course.id'}.'.domain'},
1.344 bisitz 4126: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
1.479 golterma 4127: $r->print(&Apache::loncommon::confirmwrapper(
4128: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
1.329 droeschl 4129: } else {
1.479 golterma 4130: $r->print(&Apache::loncommon::confirmwrapper(
4131: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
1.329 droeschl 4132: }
4133: &mark_hash_old();
4134: }
4135: &changewarning($r,'');
4136: if ($env{'form.timerange'} eq 'all') {
4137: # show all documents
1.549 raeburn 4138: $header=&mt('All content in '.$crstype);
1.521 bisitz 4139: $allsel=' selected="selected"';
1.329 droeschl 4140: foreach my $key (keys(%hash)) {
4141: if ($key=~/^ids\_(\/res\/.+)$/) {
4142: my $src=$1;
4143: $changes{$src}=1;
4144: }
4145: }
4146: } else {
4147: # show documents which changed
4148: %changes=&Apache::lonnet::dump
4149: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
4150: $env{'course.'.$env{'request.course.id'}.'.num'});
4151: my $firstkey=(keys(%changes))[0];
4152: unless ($firstkey=~/^error\:/) {
4153: unless ($env{'form.timerange'}) {
4154: $env{'form.timerange'}=604800;
4155: }
4156: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
4157: .&mt('seconds');
4158: if ($env{'form.timerange'}==-1) {
4159: $seltext='since start of course';
1.521 bisitz 4160: $startsel=' selected="selected"';
1.329 droeschl 4161: $env{'form.timerange'}=time;
4162: }
4163: $starttime=time-$env{'form.timerange'};
4164: if ($env{'form.timerange'}==2592000) {
4165: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 4166: $monthsel=' selected="selected"';
1.329 droeschl 4167: } elsif ($env{'form.timerange'}==604800) {
4168: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 4169: $weeksel=' selected="selected"';
1.329 droeschl 4170: } elsif ($env{'form.timerange'}==86400) {
4171: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 4172: $daysel=' selected="selected"';
1.329 droeschl 4173: }
4174: $header=&mt('Content changed').' '.$seltext;
4175: } else {
4176: $header=&mt('No content modifications yet.');
4177: }
4178: }
4179: %setversions=&Apache::lonnet::dump('resourceversions',
4180: $env{'course.'.$env{'request.course.id'}.'.domain'},
4181: $env{'course.'.$env{'request.course.id'}.'.num'});
4182: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 4183: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 4184: 'lm' => 'Version changes since last Month',
4185: 'lw' => 'Version changes since last Week',
4186: 'sy' => 'Version changes since Yesterday',
4187: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 4188: 'cd' => 'Change display',
1.329 droeschl 4189: 'sd' => 'Display',
4190: 'fi' => 'File',
4191: 'md' => 'Modification Date',
4192: 'mr' => 'Most recently published Version',
1.408 raeburn 4193: 've' => 'Version used in '.$crstype,
4194: 'vu' => 'Set Version to be used in '.$crstype,
4195: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 4196: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
4197: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 4198: 'di' => 'Differences',
1.484 raeburn 4199: 'save' => 'Save changes',
4200: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 4201: 'act' => 'Actions');
1.329 droeschl 4202: $r->print(<<ENDHEADERS);
1.484 raeburn 4203: <h4 class="LC_info">$header</h4>
1.329 droeschl 4204: <form action="/adm/coursedocs" method="post">
4205: <input type="hidden" name="versions" value="1" />
1.484 raeburn 4206: <div class="LC_left_float">
1.479 golterma 4207: <fieldset>
1.484 raeburn 4208: <legend>$lt{'cd'}</legend>
1.329 droeschl 4209: <select name="timerange">
1.521 bisitz 4210: <option value='all'$allsel>$lt{'al'}</option>
4211: <option value="-1"$startsel>$lt{'st'}</option>
4212: <option value="2592000"$monthsel>$lt{'lm'}</option>
4213: <option value="604800"$weeksel>$lt{'lw'}</option>
4214: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 4215: </select>
4216: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 4217: </fieldset>
4218: </div>
4219: <div class="LC_left_float">
4220: <fieldset>
4221: <legend>$lt{'act'}</legend>
4222: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" /><br />
4223: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" />
4224: </fieldset>
4225: </div>
4226: <br clear="all" />
4227: <hr />
4228: <h4>$lt{'vers'}</h4>
1.329 droeschl 4229: ENDHEADERS
1.479 golterma 4230: #number of columns for version history
1.571 raeburn 4231: my %changedbytime;
4232: foreach my $key (keys(%changes)) {
4233: #excludes not versionable problems from resource version history:
4234: next if ($key =~ /^\/res\/lib\/templates/);
4235: my $chg;
4236: if ($env{'form.timerange'} eq 'all') {
4237: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4238: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
4239: } else {
4240: $chg = $changes{$key};
4241: next if ($chg < $starttime);
4242: }
4243: push(@{$changedbytime{$chg}},$key);
4244: }
4245: if (keys(%changedbytime) == 0) {
4246: &untiehash();
4247: $r->print(&mt('No content changes in imported content in specified time frame').
4248: &endContentScreen());
4249: return;
4250: }
1.479 golterma 4251: $r->print(
1.571 raeburn 4252: '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.
1.521 bisitz 4253: &Apache::loncommon::start_data_table().
4254: &Apache::loncommon::start_data_table_header_row().
4255: '<th>'.&mt('Resources').'</th>'.
4256: "<th>$lt{'mr'}</th>".
4257: "<th>$lt{'ve'}</th>".
4258: "<th>$lt{'vu'}</th>".
4259: '<th>'.&mt('History').'</th>'.
4260: &Apache::loncommon::end_data_table_header_row()
4261: );
1.571 raeburn 4262: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
4263: foreach my $key (sort(@{$changedbytime{$chg}})) {
4264: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4265: my $currentversion=&Apache::lonnet::getversion($key);
4266: if ($currentversion<0) {
4267: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
4268: }
4269: my $linkurl=&Apache::lonnet::clutter($key);
4270: $r->print(
4271: &Apache::loncommon::start_data_table_row().
4272: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
4273: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
4274: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
4275: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
4276: '<td align="right">'
4277: );
4278: # Used in course
4279: my $usedversion=$hash{'version_'.$linkurl};
4280: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.521 bisitz 4281: if ($usedversion != $currentversion) {
1.479 golterma 4282: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.521 bisitz 4283: } else {
1.479 golterma 4284: $r->print($usedversion);
4285: }
1.329 droeschl 4286: } else {
1.521 bisitz 4287: $r->print($currentversion);
1.329 droeschl 4288: }
1.571 raeburn 4289: $r->print('</td><td title="'.$lt{'vu'}.'">');
4290: # Set version
4291: $r->print(&Apache::loncommon::select_form(
4292: $setversions{$linkurl},
4293: 'set_version_'.$linkurl,
4294: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
4295: '' => '',
4296: 'mostrecent' => &mt('most recent'),
4297: map {$_,$_} (1..$currentversion)}));
4298: my $lastold=1;
4299: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
4300: my $url=$root.'.'.$prevvers.'.'.$extension;
4301: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
4302: $lastold=$prevvers;
4303: }
4304: }
4305: $r->print('</td>');
4306: # List all available versions
4307: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
4308: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
4309: my $url=$root.'.'.$prevvers.'.'.$extension;
4310: $r->print(
4311: '<span class="LC_nobreak">'
4312: .'<a href="'.&Apache::lonnet::clutter($url).'">'
4313: .&mt('Version [_1]',$prevvers).'</a>'
4314: .' ('.&Apache::lonlocal::locallocaltime(
1.521 bisitz 4315: &Apache::lonnet::metadata($url,'lastrevisiondate'))
1.571 raeburn 4316: .')');
4317: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
4318: $r->print(
4319: ' <a href="/adm/diff?filename='.
4320: &Apache::lonnet::clutter($root.'.'.$extension).
4321: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
4322: '" target="diffs">'.&mt('Diffs').'</a>');
4323: }
4324: $r->print('</span><br />');
1.329 droeschl 4325: }
1.571 raeburn 4326: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.521 bisitz 4327: }
1.329 droeschl 4328: }
1.521 bisitz 4329: $r->print(
4330: &Apache::loncommon::end_data_table().
4331: '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.
4332: '</form>'
4333: );
1.329 droeschl 4334:
4335: &untiehash();
1.521 bisitz 4336: $r->print(&endContentScreen());
1.571 raeburn 4337: return;
1.329 droeschl 4338: }
4339:
4340: sub mark_hash_old {
4341: my $retie_hash=0;
4342: if ($hashtied) {
4343: $retie_hash=1;
4344: &untiehash();
4345: }
4346: &tiehash('write');
4347: $hash{'old'}=1;
4348: &untiehash();
4349: if ($retie_hash) { &tiehash(); }
4350: }
4351:
4352: sub is_hash_old {
4353: my $untie_hash=0;
4354: if (!$hashtied) {
4355: $untie_hash=1;
4356: &tiehash();
4357: }
4358: my $return=$hash{'old'};
4359: if ($untie_hash) { &untiehash(); }
4360: return $return;
4361: }
4362:
4363: sub changewarning {
4364: my ($r,$postexec,$message,$url)=@_;
4365: if (!&is_hash_old()) { return; }
4366: my $pathvar='folderpath';
4367: my $path=&escape($env{'form.folderpath'});
4368: if (!defined($url)) {
4369: $url='/adm/coursedocs?'.$pathvar.'='.$path;
4370: }
4371: my $course_type = &Apache::loncommon::course_type();
4372: if (!defined($message)) {
4373: $message='Changes will become active for your current session after [_1], or the next time you log in.';
4374: }
4375: $r->print("\n\n".
1.372 bisitz 4376: '<script type="text/javascript">'."\n".
4377: '// <![CDATA['."\n".
4378: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
4379: '// ]]>'."\n".
1.369 bisitz 4380: '</script>'."\n".
1.375 tempelho 4381: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.329 droeschl 4382: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 4383: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 4384: &mt($message,' <input type="hidden" name="'.
4385: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 4386: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 4387: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 4388: }
4389:
4390:
4391: sub init_breadcrumbs {
1.571 raeburn 4392: my ($form,$text,$help)=@_;
1.329 droeschl 4393: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 4394: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 4395: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 4396: faq=>273,
4397: bug=>'Instructor Interface',
1.571 raeburn 4398: help => $help});
1.329 droeschl 4399: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
4400: text=>$text,
4401: faq=>273,
4402: bug=>'Instructor Interface'});
4403: }
4404:
1.441 www 4405: # subroutine to list form elements
4406: sub create_list_elements {
4407: my @formarr = @_;
4408: my $list = '';
1.501 raeburn 4409: foreach my $button (@formarr){
4410: foreach my $picture (keys(%{$button})) {
4411: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 4412: }
4413: }
4414: return $list;
4415: }
1.329 droeschl 4416:
1.441 www 4417: # subroutine to create ul from list elements
4418: sub create_form_ul {
4419: my $list = shift;
4420: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
4421: return $ul;
4422: }
1.329 droeschl 4423:
1.442 www 4424: #
4425: # Start tabs
4426: #
4427:
4428: sub startContentScreen {
1.484 raeburn 4429: my ($mode) = @_;
4430: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 4431: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 4432: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
4433: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
4434: $output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'."\n";
4435: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
4436: } else {
1.549 raeburn 4437: $output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Main Content Editor').' </b></a></li>'."\n";
1.484 raeburn 4438: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
4439: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
4440: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
4441: }
4442: $output .= "\n".'</ul>'."\n";
4443: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
4444: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
4445: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
4446: return $output;
1.442 www 4447: }
4448:
4449: #
4450: # End tabs
4451: #
4452:
4453: sub endContentScreen {
1.484 raeburn 4454: return '</div></div></div>';
1.442 www 4455: }
1.329 droeschl 4456:
1.446 www 4457: sub supplemental_base {
1.548 raeburn 4458: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 4459: }
4460:
1.329 droeschl 4461: sub handler {
4462: my $r = shift;
4463: &Apache::loncommon::content_type($r,'text/html');
4464: $r->send_http_header;
4465: return OK if $r->header_only;
1.484 raeburn 4466:
4467: # get course data
1.408 raeburn 4468: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4469: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
4470: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4471:
4472: # graphics settings
4473: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 4474:
1.443 www 4475: #
1.329 droeschl 4476: # --------------------------------------------- Initialize help topics for this
4477: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
4478: 'Adding_External_Resource','Navigate_Content',
4479: 'Adding_Folders','Docs_Overview', 'Load_Map',
4480: 'Supplemental','Score_Upload_Form','Adding_Pages',
1.501 raeburn 4481: 'Importing_LON-CAPA_Resource','Importing_IMS_Course',
1.571 raeburn 4482: 'Uploading_From_Harddrive','Course_Roster','Web_Page',
1.572 raeburn 4483: 'Dropbox','Simple_Problem') {
1.329 droeschl 4484: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
4485: }
4486: # Composite help files
4487: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
4488: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
4489: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
4490: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
4491: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
4492: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 4493: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 4494: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 4495: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 4496: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.534 raeburn 4497:
1.472 raeburn 4498: my $allowed;
4499: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
4500: unless ($r->uri eq '/adm/supplemental') {
4501: # does this user have privileges to modify content.
4502: $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
4503: }
4504:
1.484 raeburn 4505: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chooseserver',
4506: 'inhibitmenu']);
4507: if ($allowed && $env{'form.chooseserver'}) {
4508: &choose_dump_server($r);
4509: return OK;
4510: } elsif ($allowed && $env{'form.verify'}) {
1.571 raeburn 4511: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.329 droeschl 4512: &verifycontent($r);
4513: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 4514: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 4515: &list_symbs($r);
4516: } elsif ($allowed && $env{'form.docslog'}) {
4517: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 4518: my $folder = $env{'form.folder'};
4519: if ($folder eq '') {
4520: $folder='default';
4521: }
4522: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath);
1.329 droeschl 4523: } elsif ($allowed && $env{'form.versions'}) {
1.571 raeburn 4524: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.329 droeschl 4525: &checkversions($r);
4526: } elsif ($allowed && $env{'form.dumpcourse'}) {
1.568 raeburn 4527: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 4528: &dumpcourse($r);
4529: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 4530: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 4531: &Apache::imsexport::exportcourse($r);
1.329 droeschl 4532: } else {
1.445 www 4533: #
4534: # Done catching special calls
1.484 raeburn 4535: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 4536: # Get the parameters that may be needed
4537: #
4538: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.519 raeburn 4539: ['folderpath',
4540: 'forcesupplement','forcestandard',
1.510 raeburn 4541: 'tools','symb','command','supppath']);
1.445 www 4542:
4543: # standard=1: this is a "new-style" course with an uploaded map as top level
4544: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 4545:
4546: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 4547:
1.484 raeburn 4548: # Decide whether this should display supplemental or main content or utilities
1.445 www 4549: # supplementalflag=1: show supplemental documents
4550: # supplementalflag=0: show standard documents
1.484 raeburn 4551: # toolsflag=1: show utilities
1.445 www 4552:
1.561 raeburn 4553: my $unesc_folderpath = &unescape($env{'form.folderpath'});
4554: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
4555: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 4556: $supplementalflag=0;
4557: }
4558: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
4559: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
4560: unless ($allowed) { $supplementalflag=1; }
4561: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 4562: my $toolsflag=0;
4563: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 4564:
1.329 droeschl 4565: my $script='';
4566: my $showdoc=0;
1.457 raeburn 4567: my $addentries = {};
1.475 raeburn 4568: my $container;
1.329 droeschl 4569: my $containertag;
1.508 raeburn 4570: my $pathitem;
1.329 droeschl 4571:
1.464 www 4572: # Do we directly jump somewhere?
1.466 www 4573:
1.525 raeburn 4574: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 4575: if ($env{'form.symb'} ne '') {
1.522 raeburn 4576: $env{'form.folderpath'}=
4577: &Apache::loncommon::symb_to_docspath($env{'form.symb'});
1.530 raeburn 4578: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.525 raeburn 4579: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 4580: } elsif ($env{'form.supppath'} ne '') {
4581: $env{'form.folderpath'}=$env{'form.supppath'};
1.530 raeburn 4582: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.525 raeburn 4583: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 4584: }
1.472 raeburn 4585: } elsif ($env{'form.command'} eq 'editdocs') {
1.525 raeburn 4586: $env{'form.folderpath'} = 'default&'.
1.548 raeburn 4587: &escape(&mt('Main Content').':::::');
1.525 raeburn 4588: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 4589: } elsif ($env{'form.command'} eq 'editsupp') {
1.525 raeburn 4590: $env{'form.folderpath'} = 'supplemental&'.
1.538 raeburn 4591: &escape('Supplemental Content');
1.525 raeburn 4592: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
4593: } elsif ($env{'form.command'} eq 'contents') {
4594: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
4595: } elsif ($env{'form.command'} eq 'home') {
4596: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 4597: }
4598:
1.525 raeburn 4599:
1.445 www 4600: # Where do we store these for when we come back?
4601: my $stored_folderpath='docs_folderpath';
4602: if ($supplementalflag) {
4603: $stored_folderpath='docs_sup_folderpath';
4604: }
1.464 www 4605:
1.519 raeburn 4606: # No folderpath, and in edit mode, see if we have something stored
4607: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 4608: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.510 raeburn 4609: {'folderpath' => 'scalar'});
1.523 raeburn 4610: unless (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
4611: undef($env{'form.folderpath'});
4612: }
1.329 droeschl 4613: }
1.446 www 4614:
4615: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 4616: if (!$allowed) {
1.446 www 4617: unless ($env{'form.folderpath'} =~ /^supplemental/) {
4618: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 4619: }
4620: }
1.446 www 4621: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 4622: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 4623: $env{'form.folderpath'} = &supplemental_base()
4624: .'&'.
1.329 droeschl 4625: $env{'form.folderpath'};
4626: }
1.446 www 4627: # If after all of this, we still don't have any paths, make them
1.519 raeburn 4628: unless ($env{'form.folderpath'}) {
1.446 www 4629: if ($supplementalflag) {
4630: $env{'form.folderpath'}=&supplemental_base();
4631: } else {
1.548 raeburn 4632: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content').
1.538 raeburn 4633: ':::::');
1.446 www 4634: }
1.472 raeburn 4635: }
1.446 www 4636:
1.445 www 4637: # Store this
1.484 raeburn 4638: unless ($toolsflag) {
1.510 raeburn 4639: if ($allowed) {
4640: &Apache::loncommon::store_course_settings($stored_folderpath,
1.519 raeburn 4641: {'folderpath' => 'scalar'});
1.510 raeburn 4642: }
1.519 raeburn 4643: my $folderpath;
1.484 raeburn 4644: if ($env{'form.folderpath'}) {
1.519 raeburn 4645: $folderpath = $env{'form.folderpath'};
4646: my (@folders)=split('&',$env{'form.folderpath'});
4647: $env{'form.foldername'}=&unescape(pop(@folders));
4648: if ($env{'form.foldername'} =~ /\:1$/) {
4649: $container = 'page';
4650: } else {
4651: $container = 'sequence';
4652: }
4653: $env{'form.folder'}=pop(@folders);
1.484 raeburn 4654: } else {
1.519 raeburn 4655: if ($env{'form.folder'} eq '' ||
4656: $env{'form.folder'} eq 'supplemental') {
4657: $folderpath='default&'.
1.548 raeburn 4658: &escape(&mt('Main Content').':::::');
1.484 raeburn 4659: }
4660: }
1.519 raeburn 4661: $containertag = '<input type="hidden" name="folderpath" value="" />';
4662: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 4663: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
4664: $showdoc='/'.$1;
4665: }
4666: if ($showdoc) { # got called in sequence from course
4667: $allowed=0;
4668: } else {
4669: if ($allowed) {
4670: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
4671: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 4672: }
4673: }
1.329 droeschl 4674: }
4675:
1.344 bisitz 4676: # get personal data
1.329 droeschl 4677: my $uname=$env{'user.name'};
4678: my $udom=$env{'user.domain'};
4679: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
4680:
4681: if ($allowed) {
1.484 raeburn 4682: if ($toolsflag) {
4683: $script .= &inject_data_js();
4684: my ($home,$other,%outhash)=&authorhosts();
4685: if (!$home && $other) {
4686: my @hosts;
4687: foreach my $aurole (keys(%outhash)) {
4688: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
4689: push(@hosts,$outhash{$aurole});
4690: }
4691: }
4692: $script .= &dump_switchserver_js(@hosts);
4693: }
1.458 raeburn 4694: } else {
1.570 raeburn 4695: my $tid = 1;
1.484 raeburn 4696: my @tabids;
4697: if ($supplementalflag) {
4698: @tabids = ('002','ee2','ff2');
1.570 raeburn 4699: $tid = 2;
1.484 raeburn 4700: } else {
4701: @tabids = ('aa1','bb1','cc1','ff1');
1.519 raeburn 4702: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 4703: unshift(@tabids,'001');
4704: push(@tabids,('dd1','ee1'));
4705: }
1.458 raeburn 4706: }
1.484 raeburn 4707: my $tabidstr = join("','",@tabids);
4708: $script .= &editing_js($udom,$uname,$supplementalflag).
4709: &history_tab_js().
4710: &inject_data_js().
1.570 raeburn 4711: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.510 raeburn 4712: &Apache::lonextresedit::extedit_javascript();
1.484 raeburn 4713: $addentries = {
1.485 raeburn 4714: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 4715: };
1.458 raeburn 4716: }
1.538 raeburn 4717: $script .= &paste_popup_js();
1.501 raeburn 4718: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
4719: &mt('Switch server?');
4720:
4721:
1.329 droeschl 4722: }
4723: # -------------------------------------------------------------------- Body tag
1.369 bisitz 4724: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 4725: .'// <![CDATA['."\n"
4726: .$script."\n"
4727: .'// ]]>'."\n"
4728: .'</script>'."\n";
1.385 bisitz 4729:
4730: # Breadcrumbs
4731: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.510 raeburn 4732:
4733: if ($showdoc) {
4734: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
4735: {'force_register' => $showdoc,}));
1.571 raeburn 4736: } elsif ($toolsflag) {
4737: &Apache::lonhtmlcommon::add_breadcrumb({
4738: href=>"/adm/coursedocs",text=>"$crstype Contents"});
4739: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
4740: .&Apache::loncommon::help_open_menu('','',273,'RAT')
4741: .&Apache::lonhtmlcommon::breadcrumbs(
4742: 'Editing Course Contents')
4743: );
1.510 raeburn 4744: } elsif ($r->uri eq '/adm/supplemental') {
4745: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
4746: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
4747: {'bread_crumbs' => $brcrum,}));
4748: } else {
1.392 raeburn 4749: &Apache::lonhtmlcommon::add_breadcrumb({
1.446 www 4750: href=>"/adm/coursedocs",text=>"$crstype Contents"});
4751: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.510 raeburn 4752: {'add_entries' => $addentries}
4753: )
1.392 raeburn 4754: .&Apache::loncommon::help_open_menu('','',273,'RAT')
4755: .&Apache::lonhtmlcommon::breadcrumbs(
1.484 raeburn 4756: 'Editing '.$crstype.' Contents',
1.392 raeburn 4757: 'Docs_Adding_Course_Doc')
4758: );
4759: }
1.364 bisitz 4760:
1.329 droeschl 4761: my %allfiles = ();
4762: my %codebase = ();
1.440 raeburn 4763: my ($upload_result,$upload_output,$uploadphase);
1.329 droeschl 4764: if ($allowed) {
4765: if (($env{'form.uploaddoc.filename'}) &&
4766: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 4767: my $context = $1;
4768: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 4769: undef($hadchanges);
1.440 raeburn 4770: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.552 raeburn 4771: \%allfiles,\%codebase,$context,$crstype);
1.329 droeschl 4772: if ($hadchanges) {
4773: &mark_hash_old();
4774: }
1.440 raeburn 4775: $r->print($upload_output);
4776: } elsif ($env{'form.phase'} eq 'upload_embedded') {
4777: # Process file upload - phase two - upload embedded objects
4778: $uploadphase = 'check_embedded';
4779: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
4780: my $state = &embedded_form_elems($uploadphase,$primaryurl,
4781: $env{'form.newidx'});
4782: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
4783: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4784: my ($destination,$dir_root) = &embedded_destination();
4785: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
4786: my $actionurl = '/adm/coursedocs';
4787: my ($result,$flag) =
4788: &Apache::loncommon::upload_embedded('coursedoc',$destination,
4789: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
4790: $actionurl);
4791: $r->print($result.&return_to_editor());
4792: } elsif ($env{'form.phase'} eq 'check_embedded') {
4793: # Process file upload - phase three - modify references in HTML file
4794: $uploadphase = 'modified_orightml';
4795: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
4796: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4797: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 4798: my $result =
4799: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
4800: $docuname,$docudom,undef,
4801: $dir_root);
4802: $r->print($result.&return_to_editor());
1.476 raeburn 4803: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
4804: $uploadphase = 'decompress_phase_one';
4805: $r->print(&decompression_phase_one().
4806: &return_to_editor());
4807: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
4808: $uploadphase = 'decompress_phase_two';
4809: $r->print(&decompression_phase_two().
4810: &return_to_editor());
1.329 droeschl 4811: }
4812: }
4813:
1.484 raeburn 4814: if ($allowed && $toolsflag) {
4815: $r->print(&startContentScreen('tools'));
4816: $r->print(&generate_admin_menu($crstype));
4817: $r->print(&endContentScreen());
4818: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 4819: # -----------------------------------------------------------------------------
4820: my %lt=&Apache::lonlocal::texthash(
4821: 'copm' => 'All documents out of a published map into this folder',
1.501 raeburn 4822: 'upfi' => 'Upload File',
1.553 raeburn 4823: 'upld' => 'Upload Content',
1.329 droeschl 4824: 'srch' => 'Search',
4825: 'impo' => 'Import',
1.487 raeburn 4826: 'lnks' => 'Import from Stored Links',
1.502 raeburn 4827: 'impm' => 'Import from Assembled Map',
1.329 droeschl 4828: 'selm' => 'Select Map',
4829: 'load' => 'Load Map',
4830: 'newf' => 'New Folder',
4831: 'newp' => 'New Composite Page',
4832: 'syll' => 'Syllabus',
1.425 raeburn 4833: 'navc' => 'Table of Contents',
1.343 biermanm 4834: 'sipa' => 'Simple Course Page',
1.329 droeschl 4835: 'sipr' => 'Simple Problem',
1.534 raeburn 4836: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 4837: 'drbx' => 'Drop Box',
1.451 www 4838: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 4839: 'bull' => 'Discussion Board',
1.347 weissno 4840: 'mypi' => 'My Personal Information Page',
1.353 weissno 4841: 'grpo' => 'Group Portfolio',
1.329 droeschl 4842: 'rost' => 'Course Roster',
1.528 raeburn 4843: 'abou' => 'Personal Information Page for a User',
1.553 raeburn 4844: 'imsf' => 'IMS Upload',
4845: 'imsl' => 'Upload IMS package',
1.501 raeburn 4846: 'cms' => 'Origin of IMS package',
4847: 'se' => 'Select',
1.329 droeschl 4848: 'file' => 'File',
4849: 'title' => 'Title',
4850: 'comment' => 'Comment',
1.403 raeburn 4851: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.329 droeschl 4852: );
4853: # -----------------------------------------------------------------------------
4854: my $fileupload=(<<FIUP);
4855: $lt{'file'}:<br />
4856: <input type="file" name="uploaddoc" size="40" />
4857: FIUP
4858:
4859: my $checkbox=(<<CHBO);
4860: <!-- <label>$lt{'parse'}?
4861: <input type="checkbox" name="parserflag" />
4862: </label> -->
4863: <label>
4864: <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
4865: </label>
4866: CHBO
1.501 raeburn 4867: my $imsfolder = $env{'form.folder'};
4868: if ($imsfolder eq '') {
4869: $imsfolder = 'default';
4870: }
4871: my $imspform=(<<IMSFORM);
4872: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
4873: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
4874: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.516 raeburn 4875: <fieldset id="uploadimsform" style="display: none;">
1.501 raeburn 4876: <legend>$lt{'imsf'}</legend>
4877: $fileupload
4878: <br />
4879: <p>
4880: $lt{'cms'}:
4881: <select name="source">
4882: <option value="-1" selected="selected">$lt{'se'}</option>
4883: <option value="bb5">Blackboard 5</option>
4884: <option value="bb6">Blackboard 6</option>
4885: <option value="angel5">ANGEL 5.5</option>
4886: <option value="webctce4">WebCT 4 Campus Edition</option>
4887: </select>
4888: <input type="hidden" name="folder" value="$imsfolder" />
4889: </p>
4890: <input type="hidden" name="phase" value="one" />
4891: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" />
4892: </fieldset>
4893: </form>
4894: IMSFORM
1.329 droeschl 4895:
4896: my $fileuploadform=(<<FUFORM);
1.501 raeburn 4897: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
4898: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
4899: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.516 raeburn 4900: <fieldset id="uploaddocform" style="display: none;">
1.501 raeburn 4901: <legend>$lt{'upfi'}</legend>
1.371 tempelho 4902: <input type="hidden" name="active" value="aa" />
1.329 droeschl 4903: $fileupload
4904: <br />
4905: $lt{'title'}:<br />
1.458 raeburn 4906: <input type="text" size="60" name="comment" />
1.508 raeburn 4907: $pathitem
1.329 droeschl 4908: <input type="hidden" name="cmd" value="upload_default" />
4909: <br />
1.458 raeburn 4910: <span class="LC_nobreak" style="float:left">
1.329 droeschl 4911: $checkbox
4912: </span>
1.501 raeburn 4913: <br clear="all" />
4914: <input type="submit" value="$lt{'upld'}" />
4915: </fieldset>
4916: </form>
1.383 tempelho 4917: FUFORM
1.329 droeschl 4918:
1.502 raeburn 4919: my $importpubform=(<<SEDFFORM);
1.514 raeburn 4920: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.502 raeburn 4921: $lt{'impm'}</a>$help{'Load_Map'}
4922: <form action="/adm/coursedocs" method="post" name="mapimportform">
1.516 raeburn 4923: <fieldset id="importmapform" style="display: none;">
1.502 raeburn 4924: <legend>$lt{'impm'}</legend>
1.371 tempelho 4925: <input type="hidden" name="active" value="bb" />
1.502 raeburn 4926: $lt{'copm'}<br />
4927: <span class="LC_nobreak">
4928: <input type="text" name="importmap" size="40" value=""
4929: onfocus="this.blur();openbrowser('mapimportform','importmap','sequence,page','');" />
1.516 raeburn 4930: <a href="javascript:openbrowser('mapimportform','importmap','sequence,page','');">$lt{'selm'}</a></span><br />
1.502 raeburn 4931: <input type="submit" name="loadmap" value="$lt{'load'}" />
4932: </fieldset>
4933: </form>
4934:
1.383 tempelho 4935: SEDFFORM
1.502 raeburn 4936: my @importpubforma = (
1.508 raeburn 4937: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => $pathitem."<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" },
1.423 onken 4938: { '<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'}" },
1.487 raeburn 4939: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:open_StoredLinks_Import();" />' => "<a class='LC_menubuttons_link' href='javascript:open_StoredLinks_Import();'>$lt{'lnks'}</a>" },
1.514 raeburn 4940: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
1.383 tempelho 4941: );
1.502 raeburn 4942: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
1.510 raeburn 4943: my $extresourcesform =
4944: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
4945: $help{'Adding_External_Resource'});
1.329 droeschl 4946: if ($allowed) {
1.492 raeburn 4947: my $folder = $env{'form.folder'};
4948: if ($folder eq '') {
4949: $folder='default';
4950: }
1.538 raeburn 4951: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
4952: if ($output) {
4953: $r->print($output);
4954: }
1.337 ehlerst 4955: $r->print(<<HIDDENFORM);
4956: <form name="renameform" method="post" action="/adm/coursedocs">
4957: <input type="hidden" name="title" />
4958: <input type="hidden" name="cmd" />
4959: <input type="hidden" name="markcopy" />
4960: <input type="hidden" name="copyfolder" />
4961: $containertag
4962: </form>
1.484 raeburn 4963:
1.337 ehlerst 4964: HIDDENFORM
1.508 raeburn 4965: $r->print(&makesimpleeditform($pathitem)."\n".
4966: &makedocslogform($pathitem."\n".
1.484 raeburn 4967: '<input type="hidden" name="folder" value="'.
4968: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 4969: }
1.442 www 4970:
4971: # Generate the tabs
1.510 raeburn 4972: my ($mode,$needs_end);
1.472 raeburn 4973: if (($supplementalflag) && (!$allowed)) {
1.510 raeburn 4974: my @folders = split('&',$env{'form.folderpath'});
4975: unless (@folders > 2) {
4976: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
4977: $needs_end = 1;
4978: }
1.472 raeburn 4979: } else {
1.484 raeburn 4980: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.510 raeburn 4981: $needs_end = 1;
1.472 raeburn 4982: }
1.443 www 4983:
1.442 www 4984: #
4985:
4986: my $savefolderpath;
4987:
1.395 raeburn 4988: if ($allowed) {
1.329 droeschl 4989: my $folder=$env{'form.folder'};
1.443 www 4990: if ($folder eq '' || $supplementalflag) {
1.329 droeschl 4991: $folder='default';
1.356 tempelho 4992: $savefolderpath = $env{'form.folderpath'};
1.548 raeburn 4993: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.508 raeburn 4994: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 4995: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
4996: }
4997: my $postexec='';
4998: if ($folder eq 'default') {
1.372 bisitz 4999: $r->print('<script type="text/javascript">'."\n"
5000: .'// <![CDATA['."\n"
5001: .'this.window.name="loncapaclient";'."\n"
5002: .'// ]]>'."\n"
5003: .'</script>'."\n"
1.369 bisitz 5004: );
1.329 droeschl 5005: } else {
5006: #$postexec='self.close();';
5007: }
1.504 raeburn 5008: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
5009: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 5010: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
5011:
5012: my $newnavform=(<<NNFORM);
5013: <form action="/adm/coursedocs" method="post" name="newnav">
1.570 raeburn 5014: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5015: $pathitem
1.329 droeschl 5016: <input type="hidden" name="importdetail"
5017: value="$lt{'navc'}=/adm/navmaps" />
1.423 onken 5018: <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
1.329 droeschl 5019: $help{'Navigate_Content'}
5020: </form>
5021: NNFORM
5022: my $newsmppageform=(<<NSPFORM);
5023: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.570 raeburn 5024: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5025: $pathitem
1.329 droeschl 5026: <input type="hidden" name="importdetail" value="" />
1.423 onken 5027: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 5028: $help{'Simple Page'}
1.329 droeschl 5029: </form>
5030: NSPFORM
5031:
5032: my $newsmpproblemform=(<<NSPROBFORM);
5033: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 5034: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5035: $pathitem
1.329 droeschl 5036: <input type="hidden" name="importdetail" value="" />
1.423 onken 5037: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.572 raeburn 5038: $help{'Simple_Problem'}
1.329 droeschl 5039: </form>
5040:
5041: NSPROBFORM
5042:
5043: my $newdropboxform=(<<NDBFORM);
5044: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 5045: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5046: $pathitem
1.329 droeschl 5047: <input type="hidden" name="importdetail" value="" />
1.423 onken 5048: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.554 raeburn 5049: $help{'Dropbox'}
1.344 bisitz 5050: </form>
1.329 droeschl 5051: NDBFORM
5052:
5053: my $newexuploadform=(<<NEXUFORM);
5054: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 5055: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5056: $pathitem
1.329 droeschl 5057: <input type="hidden" name="importdetail" value="" />
1.423 onken 5058: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 5059: $help{'Score_Upload_Form'}
5060: </form>
5061: NEXUFORM
5062:
5063: my $newbulform=(<<NBFORM);
5064: <form action="/adm/coursedocs" method="post" name="newbul">
1.570 raeburn 5065: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5066: $pathitem
1.329 droeschl 5067: <input type="hidden" name="importdetail" value="" />
1.423 onken 5068: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 5069: $help{'Bulletin Board'}
5070: </form>
5071: NBFORM
5072:
5073: my $newaboutmeform=(<<NAMFORM);
5074: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.570 raeburn 5075: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5076: $pathitem
1.329 droeschl 5077: <input type="hidden" name="importdetail"
5078: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 5079: <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 5080: $help{'My Personal Information Page'}
1.329 droeschl 5081: </form>
5082: NAMFORM
5083:
5084: my $newaboutsomeoneform=(<<NASOFORM);
5085: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.570 raeburn 5086: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5087: $pathitem
1.329 droeschl 5088: <input type="hidden" name="importdetail" value="" />
1.423 onken 5089: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 5090: </form>
5091: NASOFORM
5092:
5093: my $newrosterform=(<<NROSTFORM);
5094: <form action="/adm/coursedocs" method="post" name="newroster">
1.570 raeburn 5095: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5096: $pathitem
1.329 droeschl 5097: <input type="hidden" name="importdetail"
5098: value="$lt{'rost'}=/adm/viewclasslist" />
1.423 onken 5099: <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
1.556 raeburn 5100: $help{'Course_Roster'}
1.329 droeschl 5101: </form>
5102: NROSTFORM
5103:
1.534 raeburn 5104: my $newwebpage;
5105: if ($folder =~ /^default_?(\d*)$/) {
5106: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
5107: if ($1) {
5108: $newwebpage .= $1;
5109: } else {
5110: $newwebpage .= 'default';
5111: }
5112: $newwebpage .= '/new.html';
5113: }
5114: my $newwebpageform =(<<NWEBFORM);
5115: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.570 raeburn 5116: <input type="hidden" name="active" value="ee" />
1.534 raeburn 5117: $pathitem
5118: <input type="hidden" name="importdetail" value="$newwebpage" />
5119: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.556 raeburn 5120: $help{'Web_Page'}
1.534 raeburn 5121: </form>
5122: NWEBFORM
5123:
5124:
1.342 ehlerst 5125: my $specialdocumentsform;
1.383 tempelho 5126: my @specialdocumentsforma;
1.451 www 5127: my $gradingform;
5128: my @gradingforma;
5129: my $communityform;
5130: my @communityforma;
1.351 ehlerst 5131: my $newfolderform;
1.390 tempelho 5132: my $newfolderb;
1.342 ehlerst 5133:
1.451 www 5134: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 5135:
1.329 droeschl 5136: my $newpageform=(<<NPFORM);
5137: <form action="/adm/coursedocs" method="post" name="newpage">
5138: <input type="hidden" name="folderpath" value="$path" />
5139: <input type="hidden" name="importdetail" value="" />
1.570 raeburn 5140: <input type="hidden" name="active" value="ee" />
1.423 onken 5141: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 5142: $help{'Adding_Pages'}
1.329 droeschl 5143: </form>
5144: NPFORM
1.390 tempelho 5145:
5146:
1.351 ehlerst 5147: $newfolderform=(<<NFFORM);
1.329 droeschl 5148: <form action="/adm/coursedocs" method="post" name="newfolder">
1.508 raeburn 5149: $pathitem
1.329 droeschl 5150: <input type="hidden" name="importdetail" value="" />
1.570 raeburn 5151: <input type="hidden" name="active" value="" />
1.422 onken 5152: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 5153: </form>
5154: NFFORM
5155:
5156: my $newsylform=(<<NSYLFORM);
5157: <form action="/adm/coursedocs" method="post" name="newsyl">
1.570 raeburn 5158: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5159: $pathitem
1.329 droeschl 5160: <input type="hidden" name="importdetail"
5161: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 5162: <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 5163: $help{'Syllabus'}
1.383 tempelho 5164:
1.329 droeschl 5165: </form>
5166: NSYLFORM
1.364 bisitz 5167:
1.329 droeschl 5168: my $newgroupfileform=(<<NGFFORM);
5169: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.570 raeburn 5170: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5171: $pathitem
1.329 droeschl 5172: <input type="hidden" name="importdetail"
5173: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.423 onken 5174: <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
1.353 weissno 5175: $help{'Group Portfolio'}
1.329 droeschl 5176: </form>
5177: NGFFORM
1.383 tempelho 5178: @specialdocumentsforma=(
1.421 onken 5179: {'<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 5180: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
1.451 www 5181: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
5182: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.534 raeburn 5183: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.451 www 5184: );
5185: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
5186:
1.434 raeburn 5187:
5188: my @importdoc = (
1.519 raeburn 5189: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
5190: );
5191: unless ($container eq 'page') {
5192: push(@importdoc,
5193: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
5194: );
5195: }
5196: push(@importdoc,
1.558 raeburn 5197: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform}
1.519 raeburn 5198: );
1.501 raeburn 5199: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 5200:
1.451 www 5201: @gradingforma=(
5202: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
5203: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
5204: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
5205:
5206: );
5207: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
5208:
5209: @communityforma=(
5210: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
5211: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
5212: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
5213: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},
5214: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
5215: );
5216: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 5217:
1.330 tempelho 5218: my %orderhash = (
1.553 raeburn 5219: 'aa' => ['Upload',$fileuploadform],
5220: 'bb' => ['Import',$importpubform],
5221: 'cc' => ['Grading',$gradingform],
1.330 tempelho 5222: );
1.519 raeburn 5223: unless ($container eq 'page') {
1.434 raeburn 5224: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 5225: $orderhash{'dd'} = ['Collaboration',$communityform];
1.553 raeburn 5226: $orderhash{'ee'} = ['Other',$specialdocumentsform];
1.434 raeburn 5227: }
5228:
1.341 ehlerst 5229: $hadchanges=0;
1.484 raeburn 5230: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 5231: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.508 raeburn 5232: $supplementalflag,\%orderhash,$iconpath,$pathitem);
1.443 www 5233: if ($error) {
5234: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
5235: }
5236: if ($hadchanges) {
5237: &mark_hash_old();
5238: }
1.341 ehlerst 5239:
1.443 www 5240: &changewarning($r,'');
5241: }
1.458 raeburn 5242: }
1.442 www 5243:
1.443 www 5244: # Supplemental documents start here
5245:
1.329 droeschl 5246: my $folder=$env{'form.folder'};
1.443 www 5247: unless ($supplementalflag) {
1.329 droeschl 5248: $folder='supplemental';
5249: }
5250: if ($folder =~ /^supplemental$/ &&
5251: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 5252: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 5253: } elsif ($allowed) {
1.356 tempelho 5254: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 5255: }
1.508 raeburn 5256: $pathitem = '<input type="hidden" name="folderpath" value="'.
5257: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 5258: if ($allowed) {
5259: my $folderseq=
1.504 raeburn 5260: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 5261:
5262: my $supupdocform=(<<SUPDOCFORM);
1.501 raeburn 5263: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
5264: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 5265: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.516 raeburn 5266: <fieldset id="uploadsuppdocform" style="display: none;">
1.501 raeburn 5267: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5268: <input type="hidden" name="active" value="ee" />
1.329 droeschl 5269: $fileupload
5270: <br />
5271: <br />
5272: <span class="LC_nobreak">
5273: $checkbox
5274: </span>
5275: <br /><br />
5276: $lt{'comment'}:<br />
1.383 tempelho 5277: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 5278: <br />
1.508 raeburn 5279: $pathitem
1.329 droeschl 5280: <input type="hidden" name="cmd" value="upload_supplemental" />
1.501 raeburn 5281: <input type='submit' value="$lt{'upld'}" />
5282: </form>
1.329 droeschl 5283: SUPDOCFORM
5284:
5285: my $supnewfolderform=(<<SNFFORM);
5286: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.570 raeburn 5287: <input type="hidden" name="active" value="" />
1.508 raeburn 5288: $pathitem
1.329 droeschl 5289: <input type="hidden" name="importdetail" value="" />
1.423 onken 5290: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 5291: $help{'Adding_Folders'}
1.329 droeschl 5292: </form>
5293: SNFFORM
1.383 tempelho 5294:
1.510 raeburn 5295: my $supextform =
5296: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
5297: $help{'Adding_External_Resource'});
1.329 droeschl 5298:
5299: my $supnewsylform=(<<SNSFORM);
5300: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 5301: <input type="hidden" name="active" value="ff" />
1.508 raeburn 5302: $pathitem
1.329 droeschl 5303: <input type="hidden" name="importdetail"
5304: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 5305: <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 5306: $help{'Syllabus'}
5307: </form>
5308: SNSFORM
5309:
5310: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 5311: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 5312: <input type="hidden" name="active" value="ff" />
1.508 raeburn 5313: $pathitem
1.329 droeschl 5314: <input type="hidden" name="importdetail"
5315: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 5316: <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 5317: $help{'My Personal Information Page'}
1.329 droeschl 5318: </form>
5319: SNAMFORM
5320:
1.534 raeburn 5321: my $supwebpage;
5322: if ($folder =~ /^supplemental_?(\d*)$/) {
5323: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
5324: if ($1) {
5325: $supwebpage .= $1;
5326: } else {
5327: $supwebpage .= 'default';
5328: }
5329: $supwebpage .= '/new.html';
5330: }
5331: my $supwebpageform =(<<SWEBFORM);
5332: <form action="/adm/coursedocs" method="post" name="supwebpage">
5333: <input type="hidden" name="active" value="cc" />
5334: $pathitem
5335: <input type="hidden" name="importdetail" value="$supwebpage" />
5336: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.556 raeburn 5337: $help{'Web_Page'}
1.534 raeburn 5338: </form>
5339: SWEBFORM
5340:
1.333 muellerd 5341:
1.383 tempelho 5342: my @specialdocs = (
1.417 droeschl 5343: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
5344: =>$supnewsylform},
5345: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
5346: =>$supnewaboutmeform},
1.534 raeburn 5347: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
5348:
1.383 tempelho 5349: );
1.417 droeschl 5350: my @supimportdoc = (
1.515 raeburn 5351: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />'
1.501 raeburn 5352: =>$supextform},
5353: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
5354: =>$supupdocform},
5355: );
5356:
5357: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 5358: my %suporderhash = (
1.390 tempelho 5359: '00' => ['Supnewfolder', $supnewfolderform],
1.553 raeburn 5360: 'ee' => ['Upload',$supupdocform],
5361: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 5362: );
1.443 www 5363: if ($supplementalflag) {
1.458 raeburn 5364: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.508 raeburn 5365: $supplementalflag,\%suporderhash,$iconpath,$pathitem);
1.443 www 5366: if ($error) {
5367: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.557 raeburn 5368: } else {
5369: if ($suppchanges) {
5370: my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
5371: my @ids=&Apache::lonnet::current_machine_ids();
5372: foreach my $server (keys(%servers)) {
5373: next if (grep(/^\Q$server\E$/,@ids));
5374: my $hashid=$coursenum.':'.$coursedom;
1.566 raeburn 5375: my $cachekey = &escape('suppcount').':'.&escape($hashid);
5376: &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
1.557 raeburn 5377: }
5378: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
5379: undef($suppchanges);
5380: }
5381: }
1.393 raeburn 5382: }
1.443 www 5383: } elsif ($supplementalflag) {
1.458 raeburn 5384: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.508 raeburn 5385: $supplementalflag,'',$iconpath,$pathitem);
1.393 raeburn 5386: if ($error) {
5387: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 5388: }
1.393 raeburn 5389: }
1.389 tempelho 5390:
1.510 raeburn 5391: if ($needs_end) {
5392: $r->print(&endContentScreen());
5393: }
1.383 tempelho 5394:
1.329 droeschl 5395: if ($allowed) {
5396: $r->print('
5397: <form method="post" name="extimport" action="/adm/coursedocs">
5398: <input type="hidden" name="title" />
5399: <input type="hidden" name="url" />
5400: <input type="hidden" name="useform" />
5401: <input type="hidden" name="residx" />
5402: </form>');
5403: }
1.484 raeburn 5404: } elsif ($showdoc) {
1.329 droeschl 5405: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 5406: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.498 bisitz 5407: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 5408: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 5409: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 5410: }
5411: }
5412: $r->print(&Apache::loncommon::end_page());
5413: return OK;
1.364 bisitz 5414: }
1.329 droeschl 5415:
1.440 raeburn 5416: sub embedded_form_elems {
5417: my ($phase,$primaryurl,$newidx) = @_;
5418: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
5419: return <<STATE;
5420: <input type="hidden" name="folderpath" value="$folderpath" />
5421: <input type="hidden" name="cmd" value="upload_embedded" />
5422: <input type="hidden" name="newidx" value="$newidx" />
5423: <input type="hidden" name="phase" value="$phase" />
5424: <input type="hidden" name="primaryurl" value="$primaryurl" />
5425: STATE
5426: }
5427:
5428: sub embedded_destination {
5429: my $folder=$env{'form.folder'};
5430: my $destination = 'docs/';
5431: if ($folder =~ /^supplemental/) {
5432: $destination = 'supplemental/';
5433: }
5434: if (($folder eq 'default') || ($folder eq 'supplemental')) {
5435: $destination .= 'default/';
5436: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
5437: $destination .= $2.'/';
5438: }
5439: $destination .= $env{'form.newidx'};
5440: my $dir_root = '/userfiles';
5441: return ($destination,$dir_root);
5442: }
5443:
5444: sub return_to_editor {
5445: my $actionurl = '/adm/coursedocs';
5446: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
5447: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
5448: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
5449: '</a></p>';
5450: }
5451:
1.476 raeburn 5452: sub decompression_info {
5453: my ($destination,$dir_root) = &embedded_destination();
5454: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
5455: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5456: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5457: my $container='sequence';
1.480 raeburn 5458: my ($pathitem,$hiddenelem);
1.519 raeburn 5459: my @hiddens = ('newidx','comment','position','folderpath');
5460: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 5461: $container='page';
5462: }
1.480 raeburn 5463: unshift(@hiddens,$pathitem);
5464: foreach my $item (@hiddens) {
5465: if ($env{'form.'.$item}) {
5466: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
5467: $env{'form.'.$item}.'" />'."\n";
5468: }
1.477 raeburn 5469: }
1.476 raeburn 5470: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
5471: $hiddenelem);
5472: }
5473:
5474: sub decompression_phase_one {
5475: my ($dir,$file,$warning,$error,$output);
5476: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
5477: &decompression_info();
1.490 raeburn 5478: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 5479: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
5480: } else {
5481: my $file = $1;
1.481 raeburn 5482: $output =
5483: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
5484: $destination,$dir_root,
5485: $hiddenelem);
5486: if ($env{'form.autoextract_camtasia'}) {
5487: $output .= &remove_archive($docudom,$docuname,$container);
5488: }
1.476 raeburn 5489: }
5490: if ($error) {
5491: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
5492: $error.'</p>'."\n";
5493: }
5494: if ($warning) {
5495: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
5496: }
5497: return $output;
5498: }
5499:
5500: sub decompression_phase_two {
5501: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
5502: &decompression_info();
1.481 raeburn 5503: my $output;
1.480 raeburn 5504: if ($env{'form.archivedelete'}) {
1.481 raeburn 5505: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 5506: }
5507: $output .=
1.481 raeburn 5508: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 5509: $destination,$dir_root,$hiddenelem);
5510: return $output;
5511: }
5512:
1.480 raeburn 5513: sub remove_archive {
5514: my ($docudom,$docuname,$container) = @_;
5515: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 5516: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 5517: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
5518: if ($fatal) {
5519: if ($container eq 'page') {
5520: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
5521: } else {
5522: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
5523: }
5524: $delwarning .= &mt('As a result the archive file has not been removed.');
5525: } else {
5526: my $currcmd = $env{'form.cmd'};
5527: my $position = $env{'form.position'};
1.563 raeburn 5528: if ($position > 0) {
5529: $env{'form.cmd'} = 'remove_'.$position;
1.480 raeburn 5530: my ($title,$url,@rrest) =
5531: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);
5532: if (&handle_edit_cmd($docuname,$docudom)) {
1.492 raeburn 5533: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
1.480 raeburn 5534: if ($fatal) {
5535: if ($container eq 'page') {
5536: $delwarning = &mt('An error occurred updating the contents of the current page.');
5537: } else {
5538: $delwarning = &mt('An error occurred updating the contents of the current folder.');
5539: }
5540: } else {
1.481 raeburn 5541: $delresult = &mt('Archive file removed.');
1.480 raeburn 5542: }
5543: }
5544: }
5545: $env{'form.cmd'} = $currcmd;
5546: }
5547: if ($delwarning) {
5548: $output = '<p class="LC_warning">'.
5549: $delwarning.
5550: '</p>';
5551: }
5552: if ($delresult) {
5553: $output .= '<p class="LC_info">'.
5554: $delresult.
5555: '</p>';
5556: }
1.481 raeburn 5557: return $output;
1.480 raeburn 5558: }
5559:
1.484 raeburn 5560: sub generate_admin_menu {
5561: my ($crstype) = @_;
5562: my $lc_crstype = lc($crstype);
5563: my ($home,$other,%outhash)=&authorhosts();
1.562 bisitz 5564: my %lt= ( # do not translate here
1.484 raeburn 5565: 'vc' => 'Verify Content',
5566: 'cv' => 'Check/Set Resource Versions',
5567: 'ls' => 'List Resource Identifiers',
5568: 'imse' => 'Export contents to IMS Archive',
1.568 raeburn 5569: 'dcd' => "Copy $crstype Content to Authoring Space",
1.562 bisitz 5570: );
1.484 raeburn 5571: my ($candump,$dumpurl);
5572: if ($home + $other > 0) {
5573: $candump = 'F';
5574: if ($home) {
5575: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
5576: } else {
5577: my @hosts;
5578: foreach my $aurole (keys(%outhash)) {
5579: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
5580: push(@hosts,$outhash{$aurole});
1.538 raeburn 5581: }
1.484 raeburn 5582: }
5583: if (@hosts == 1) {
5584: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
5585: '&role='.
5586: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
5587: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
5588: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
5589: } else {
5590: $dumpurl = "javascript:choose_switchserver_window()";
5591: }
5592: }
5593: }
5594: my @menu=
5595: ({ categorytitle=>'Administration',
5596: items =>[
5597: { linktext => $lt{'vc'},
5598: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
5599: permission => 'F',
1.571 raeburn 5600: help => 'Docs_Verify_Content',
1.484 raeburn 5601: icon => 'verify.png',
5602: linktitle => 'Verify contents can be retrieved/rendered',
5603: },
5604: { linktext => $lt{'cv'},
5605: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
5606: permission => 'F',
1.571 raeburn 5607: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 5608: icon => 'resversion.png',
5609: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
5610: },
5611: { linktext => $lt{'ls'},
5612: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
5613: permission => 'F',
5614: #help => '',
5615: icon => 'symbs.png',
5616: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
5617: },
5618: ]
5619: },
5620: { categorytitle=>'Export',
5621: items =>[
5622: { linktext => $lt{'imse'},
5623: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
5624: permission => 'F',
5625: help => 'Docs_Export_Course_Docs',
5626: icon => 'imsexport.png',
5627: linktitle => $lt{'imse'},
5628: },
5629: { linktext => $lt{'dcd'},
5630: url => $dumpurl,
5631: permission => $candump,
1.571 raeburn 5632: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 5633: icon => 'dump.png',
5634: linktitle => $lt{'dcd'},
5635: },
5636: ]
5637: });
5638: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
5639: '<input type="hidden" id="dummy" />'."\n".
5640: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
5641: '</form>';
1.329 droeschl 5642: }
5643:
5644: sub generate_edit_table {
1.538 raeburn 5645: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
5646: $need_save,$copyfolder) = @_;
1.406 raeburn 5647: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 5648: my %orderhash = %{$orderhash_ref};
1.344 bisitz 5649: my $form;
1.371 tempelho 5650: my $activetab;
5651: my $active;
1.570 raeburn 5652: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 5653: $activetab = $env{'form.active'};
5654: }
1.472 raeburn 5655: my $backicon = $iconpath.'clickhere.gif';
1.525 raeburn 5656: my $backtext = &mt('Exit Editor');
1.458 raeburn 5657: $form = '<div class="LC_Box" style="margin:0;">'.
1.488 raeburn 5658: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
5659: '<li class="goback">'.
1.546 raeburn 5660: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.488 raeburn 5661: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
5662: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
5663: '<li>'.
5664: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
5665: &mt('Undo Delete').'</a></li>'."\n";
5666: if ($env{'form.docslog'}) {
5667: $form .= '<li class="active">';
5668: } else {
5669: $form .= '<li>';
5670: }
5671: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
5672: &mt('History').'</a></li>'."\n";
5673: if ($env{'form.docslog'}) {
5674: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
5675: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 5676: }
1.458 raeburn 5677: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 5678: if($name ne '00'){
1.371 tempelho 5679: if($activetab eq '' || $activetab ne $name){
5680: $active = '';
5681: }elsif($activetab eq $name){
5682: $active = 'class="active"';
5683: }
1.458 raeburn 5684: $form .= '<li style="float:right" '.$active
1.484 raeburn 5685: .' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>'."\n";
1.390 tempelho 5686: } else {
1.570 raeburn 5687: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 5688:
5689: }
1.329 droeschl 5690: }
1.484 raeburn 5691: $form .= '</ul>'."\n";
5692: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 5693:
5694: if ($to_show ne '') {
1.538 raeburn 5695: my $saveform;
5696: if ($need_save) {
5697: my $button = &mt('Make changes');
5698: my $path;
5699: if ($env{'form.folderpath'}) {
5700: $path =
5701: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
5702: }
5703: $saveform = <<"END";
5704: <div id="multisave" style="display:none; clear:both;" >
5705: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
5706: <input type="hidden" name="folderpath" value="$path" />
5707: <input type="hidden" name="symb" value="$env{'form.symb'}" />
5708: <input type="hidden" name="allhiddenresource" value="" />
5709: <input type="hidden" name="allencrypturl" value="" />
5710: <input type="hidden" name="allrandompick" value="" />
5711: <input type="hidden" name="allrandomorder" value="" />
5712: <input type="hidden" name="changeparms" value="" />
5713: <input type="hidden" name="multiremove" value="" />
5714: <input type="hidden" name="multicut" value="" />
5715: <input type="hidden" name="multicopy" value="" />
5716: <input type="hidden" name="multichange" value="" />
5717: <input type="hidden" name="copyfolder" value="$copyfolder" />
5718: <input type="submit" name="savemultiples" value="$button" />
5719: </form>
5720: </div>
5721: END
5722: }
5723: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 5724: }
1.363 ehlerst 5725: foreach my $field (keys(%orderhash)){
1.390 tempelho 5726: if($field ne '00'){
1.422 onken 5727: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 5728: $active = 'style="display: none;float:left"';
1.422 onken 5729: }elsif($activetab eq $field){
1.458 raeburn 5730: $active = 'style="display:block;float:left"';
1.422 onken 5731: }
5732: $form .= '<div id="'.$field.$tid.'"'
5733: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 5734: .'</div>'."\n";
1.363 ehlerst 5735: }
5736: }
1.484 raeburn 5737: unless ($env{'form.docslog'}) {
5738: $form .= '</div></div>'."\n";
5739: }
1.329 droeschl 5740: return $form;
5741: }
5742:
5743: sub editing_js {
1.472 raeburn 5744: my ($udom,$uname,$supplementalflag) = @_;
1.329 droeschl 5745: my %lt = &Apache::lonlocal::texthash(
5746: p_mnf => 'Name of New Folder',
5747: t_mnf => 'New Folder',
5748: p_mnp => 'Name of New Page',
5749: t_mnp => 'New Page',
1.451 www 5750: p_mxu => 'Title for the External Score',
1.349 biermanm 5751: p_msp => 'Name of Simple Course Page',
1.329 droeschl 5752: p_msb => 'Title for the Problem',
5753: p_mdb => 'Title for the Drop Box',
1.336 schafran 5754: p_mbb => 'Title for the Discussion Board',
1.534 raeburn 5755: p_mwp => 'Title for Web Page',
1.348 weissno 5756: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 5757: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 5758: p_mab_alrt1 => 'Not a valid user:domain',
5759: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
5760: p_chn => 'New Title',
5761: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
5762: p_rmr2a => 'Remove[_99]',
5763: p_rmr2b => '?[_99]',
1.542 raeburn 5764: p_rmr3a => 'Remove those [_2]',
5765: p_rmr3b => 'items?[_2]',
1.329 droeschl 5766: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
5767: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
5768: p_ctr2a => 'Cut[_98]',
1.478 raeburn 5769: p_ctr2b => '?[_98]',
1.542 raeburn 5770: p_ctr3a => 'Cut those[_2]',
5771: p_ctr3b => 'items?[_2]',
1.478 raeburn 5772: rpck => 'Enter number to pick (e.g., 3)',
1.501 raeburn 5773: imsfile => 'You must choose an IMS package for import',
5774: imscms => 'You must select which Course Management System was the source of the IMS package',
5775: invurl => 'Invalid URL',
5776: titbl => 'Title is blank',
1.538 raeburn 5777: more => '(More ...)',
5778: less => '(Less ...)',
1.543 raeburn 5779: noor => 'No actions selected or changes to settings specified.',
5780: noch => 'No changes to settings specified.',
5781: noac => 'No actions selected.',
1.329 droeschl 5782: );
5783:
1.433 raeburn 5784: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 5785: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
5786: my $main_container_page;
1.519 raeburn 5787: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
5788: $main_container_page = 1;
1.434 raeburn 5789: }
1.538 raeburn 5790: my $toplevelmain =
1.548 raeburn 5791: &escape(&mt('Main Content').':::::');
1.446 www 5792: my $toplevelsupp = &supplemental_base();
1.433 raeburn 5793:
1.525 raeburn 5794: my $backtourl;
1.530 raeburn 5795: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
5796: my $caller = $1;
1.525 raeburn 5797: if ($caller =~ /^supplemental/) {
5798: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
5799: } else {
5800: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
5801: $res = &Apache::lonnet::clutter($res);
5802: if (&Apache::lonnet::is_on_map($res)) {
5803: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='.
5804: &HTML::Entities::encode($caller,'<>&"');
1.544 raeburn 5805: } else {
5806: $backtourl = '/adm/navmaps';
1.525 raeburn 5807: }
5808: }
5809: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
5810: $backtourl = '/adm/menu';
5811: } elsif ($supplementalflag) {
1.472 raeburn 5812: $backtourl = '/adm/supplemental';
1.525 raeburn 5813: } else {
5814: $backtourl = '/adm/navmaps';
1.472 raeburn 5815: }
5816:
1.519 raeburn 5817: my $fieldsets = "'ext','doc'";
5818: unless ($main_container_page) {
5819: $fieldsets .=",'ims'";
5820: }
1.501 raeburn 5821: if ($supplementalflag) {
5822: $fieldsets = "'suppext','suppdoc'";
5823: }
5824:
1.329 droeschl 5825: return <<ENDNEWSCRIPT;
5826: function makenewfolder(targetform,folderseq) {
5827: var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
5828: if (foldername) {
5829: targetform.importdetail.value=escape(foldername)+"="+folderseq;
5830: targetform.submit();
5831: }
5832: }
5833:
5834: function makenewpage(targetform,folderseq) {
5835: var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
5836: if (pagename) {
5837: targetform.importdetail.value=escape(pagename)+"="+folderseq;
5838: targetform.submit();
5839: }
5840: }
5841:
5842: function makeexamupload() {
5843: var title=prompt('$lt{"p_mxu"}');
1.344 bisitz 5844: if (title) {
1.329 droeschl 5845: this.document.forms.newexamupload.importdetail.value=
5846: escape(title)+'=/res/lib/templates/examupload.problem';
5847: this.document.forms.newexamupload.submit();
5848: }
5849: }
5850:
5851: function makesmppage() {
5852: var title=prompt('$lt{"p_msp"}');
1.344 bisitz 5853: if (title) {
1.329 droeschl 5854: this.document.forms.newsmppg.importdetail.value=
1.533 raeburn 5855: escape(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 5856: this.document.forms.newsmppg.submit();
5857: }
5858: }
5859:
1.534 raeburn 5860: function makewebpage(type) {
5861: var title=prompt('$lt{"p_mwp"}');
5862: var formname;
5863: if (type == 'supp') {
5864: formname = this.document.forms.supwebpage;
5865: } else {
5866: formname = this.document.forms.newwebpage;
5867: }
5868: if (title) {
5869: var webpage = formname.importdetail.value;
5870: formname.importdetail.value = escape(title)+'='+webpage;
5871: formname.submit();
5872: }
5873: }
5874:
1.329 droeschl 5875: function makesmpproblem() {
5876: var title=prompt('$lt{"p_msb"}');
1.344 bisitz 5877: if (title) {
1.329 droeschl 5878: this.document.forms.newsmpproblem.importdetail.value=
5879: escape(title)+'=/res/lib/templates/simpleproblem.problem';
5880: this.document.forms.newsmpproblem.submit();
5881: }
5882: }
5883:
5884: function makedropbox() {
5885: var title=prompt('$lt{"p_mdb"}');
1.344 bisitz 5886: if (title) {
1.329 droeschl 5887: this.document.forms.newdropbox.importdetail.value=
5888: escape(title)+'=/res/lib/templates/DropBox.problem';
5889: this.document.forms.newdropbox.submit();
5890: }
5891: }
5892:
5893: function makebulboard() {
5894: var title=prompt('$lt{"p_mbb"}');
5895: if (title) {
5896: this.document.forms.newbul.importdetail.value=
1.533 raeburn 5897: escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 5898: this.document.forms.newbul.submit();
5899: }
5900: }
5901:
5902: function makeabout() {
5903: var user=prompt("$lt{'p_mab'}");
5904: if (user) {
5905: var comp=new Array();
5906: comp=user.split(':');
5907: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
5908: if ((comp[0]) && (comp[1])) {
5909: this.document.forms.newaboutsomeone.importdetail.value=
5910: '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.335 ehlerst 5911: this.document.forms.newaboutsomeone.submit();
5912: } else {
5913: alert("$lt{'p_mab_alrt1'}");
1.329 droeschl 5914: }
1.335 ehlerst 5915: } else {
5916: alert("$lt{'p_mab_alrt2'}");
5917: }
5918: }
1.329 droeschl 5919: }
5920:
1.501 raeburn 5921: function toggleUpload(caller) {
5922: var blocks = Array($fieldsets);
5923: for (var i=0; i<blocks.length; i++) {
5924: var disp = 'none';
5925: if (caller == blocks[i]) {
5926: var curr = document.getElementById('upload'+caller+'form').style.display;
5927: if (curr == 'none') {
5928: disp='block';
5929: }
5930: }
5931: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
5932: }
1.502 raeburn 5933: resize_scrollbox('contentscroll','1','1');
5934: return;
5935: }
5936:
1.514 raeburn 5937: function toggleMap(caller) {
1.502 raeburn 5938: var disp = 'none';
1.510 raeburn 5939: if (document.getElementById('importmapform')) {
1.514 raeburn 5940: if (caller == 'map') {
5941: var curr = document.getElementById('importmapform').style.display;
5942: if (curr == 'none') {
5943: disp='block';
5944: }
1.510 raeburn 5945: }
5946: document.getElementById('importmapform').style.display=disp;
5947: resize_scrollbox('contentscroll','1','1');
1.502 raeburn 5948: }
1.501 raeburn 5949: return;
1.329 droeschl 5950: }
5951:
1.501 raeburn 5952: function makeims(imsform) {
5953: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
5954: alert("$lt{'imsfile'}");
5955: return;
5956: }
5957: if (imsform.source.selectedIndex == 0) {
5958: alert("$lt{'imscms'}");
5959: return;
5960: }
5961: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
5962: imsform.submit();
5963: }
5964:
1.519 raeburn 5965: function changename(folderpath,index,oldtitle) {
1.335 ehlerst 5966: var title=prompt('$lt{"p_chn"}',oldtitle);
5967: if (title) {
1.538 raeburn 5968: this.document.forms.renameform.markcopy.value='';
1.335 ehlerst 5969: this.document.forms.renameform.title.value=title;
5970: this.document.forms.renameform.cmd.value='rename_'+index;
1.519 raeburn 5971: this.document.forms.renameform.folderpath.value=folderpath;
1.335 ehlerst 5972: this.document.forms.renameform.submit();
5973: }
1.329 droeschl 5974: }
5975:
1.478 raeburn 5976: function updatePick(targetform,index,caller) {
1.537 raeburn 5977: var pickitem;
5978: var picknumitem;
5979: var picknumtext;
5980: if (index == 'all') {
5981: pickitem = document.getElementById('randompickall');
5982: picknumitem = document.getElementById('rpicknumall');
5983: picknumtext = document.getElementById('rpicktextall');
5984: } else {
5985: pickitem = document.getElementById('randompick_'+index);
5986: picknumitem = document.getElementById('rpicknum_'+index);
5987: picknumtext = document.getElementById('randompicknum_'+index);
5988: }
1.478 raeburn 5989: if (pickitem.checked) {
5990: var picknum=prompt('$lt{"rpck"}',picknumitem.value);
5991: if (picknum == '' || picknum == null) {
5992: if (caller == 'check') {
5993: pickitem.checked=false;
1.537 raeburn 5994: if (index == 'all') {
5995: picknumtext.innerHTML = '';
5996: if (caller == 'link') {
5997: propagateState(targetform,'rpicknum');
5998: }
5999: } else {
1.538 raeburn 6000: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6001: }
1.478 raeburn 6002: }
6003: } else {
6004: picknum.toString();
6005: var regexdigit=/^\\d+\$/;
6006: if (regexdigit.test(picknum)) {
6007: picknumitem.value = picknum;
1.537 raeburn 6008: if (index == 'all') {
1.538 raeburn 6009: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.537 raeburn 6010: if (caller == 'link') {
6011: propagateState(targetform,'rpicknum');
6012: }
6013: } else {
6014: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.538 raeburn 6015: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6016: }
1.478 raeburn 6017: } else {
6018: if (caller == 'check') {
1.537 raeburn 6019: if (index == 'all') {
6020: picknumtext.innerHTML = '';
6021: if (caller == 'link') {
6022: propagateState(targetform,'rpicknum');
6023: }
6024: } else {
6025: pickitem.checked=false;
1.538 raeburn 6026: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6027: }
1.478 raeburn 6028: }
6029: return;
6030: }
6031: }
6032: } else {
1.537 raeburn 6033: picknumitem.value = '';
6034: picknumtext.innerHTML = '';
6035: if (index == 'all') {
6036: if (caller == 'link') {
6037: propagateState(targetform,'rpicknum');
6038: }
6039: } else {
1.538 raeburn 6040: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6041: }
6042: }
6043: }
6044:
6045: function propagateState(form,param) {
6046: if (document.getElementById(param+'all')) {
6047: var setcheck = 0;
6048: var rpick = 0;
6049: if (param == 'rpicknum') {
6050: if (document.getElementById('randompickall')) {
6051: if (document.getElementById('randompickall').checked) {
6052: if (document.getElementById('rpicknumall')) {
6053: rpick = document.getElementById('rpicknumall').value;
6054: }
6055: }
6056: }
6057: } else {
6058: if (document.getElementById(param+'all').checked) {
6059: setcheck = 1;
6060: }
6061: }
1.538 raeburn 6062: var allidxlist;
6063: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6064: if (document.getElementById('all'+param+'idx')) {
6065: allidxlist = document.getElementById('all'+param+'idx').value;
6066: }
6067: var actions = new Array ('remove','cut','copy');
6068: for (var i=0; i<actions.length; i++) {
6069: if (actions[i] != param) {
6070: if (document.getElementById(actions[i]+'all')) {
6071: document.getElementById(actions[i]+'all').checked = false;
6072: }
6073: }
6074: }
6075: }
1.537 raeburn 6076: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.538 raeburn 6077: allidxlist = form.allidx.value;
6078: }
6079: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
6080: allidxlist = form.allmapidx.value;
6081: }
6082: if ((allidxlist != '') && (allidxlist != null)) {
6083: var allidxs = allidxlist.split(',');
6084: if (allidxs.length > 1) {
6085: for (var i=0; i<allidxs.length; i++) {
6086: if (document.getElementById(param+'_'+allidxs[i])) {
6087: if (param == 'rpicknum') {
6088: if (document.getElementById('randompick_'+allidxs[i])) {
6089: if (document.getElementById('randompick_'+allidxs[i]).checked) {
6090: document.getElementById(param+'_'+allidxs[i]).value = rpick;
6091: if (rpick > 0) {
6092: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
6093: } else {
6094: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6095: }
6096: }
6097: }
6098: } else {
1.537 raeburn 6099: if (setcheck == 1) {
6100: document.getElementById(param+'_'+allidxs[i]).checked = true;
6101: } else {
6102: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.538 raeburn 6103: if (param == 'randompick') {
6104: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6105: }
1.537 raeburn 6106: }
6107: }
6108: }
6109: }
1.538 raeburn 6110: if (setcheck == 1) {
6111: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6112: var actions = new Array('copy','cut','remove');
6113: for (var i=0; i<actions.length; i++) {
6114: var otheractions;
6115: var otheridxs;
6116: if (actions[i] === param) {
6117: continue;
6118: } else {
6119: if (document.getElementById('all'+actions[i]+'idx')) {
6120: otheractions = document.getElementById('all'+actions[i]+'idx').value;
6121: otheridxs = otheractions.split(',');
6122: if (otheridxs.length > 1) {
6123: for (var j=0; j<otheridxs.length; j++) {
6124: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
6125: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
6126: }
1.537 raeburn 6127: }
6128: }
6129: }
1.538 raeburn 6130: }
6131: }
6132: }
6133: }
6134: }
6135: }
6136: }
6137: return;
6138: }
6139:
6140: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder) {
1.539 raeburn 6141: var dosettings;
6142: var doaction;
1.538 raeburn 6143: var control = document.togglemultsettings;
6144: if (context == 'actions') {
6145: control = document.togglemultactions;
1.539 raeburn 6146: doaction = 1;
6147: } else {
6148: dosettings = 1;
1.538 raeburn 6149: }
1.539 raeburn 6150: if (control) {
6151: if (control.showmultpick.length) {
6152: for (var i=0; i<control.showmultpick.length; i++) {
6153: if (control.showmultpick[i].checked) {
6154: if (control.showmultpick[i].value == 1) {
6155: if (context == 'settings') {
6156: dosettings = 0;
6157: } else {
6158: doaction = 0;
1.538 raeburn 6159: }
6160: }
6161: }
1.537 raeburn 6162: }
6163: }
1.539 raeburn 6164: }
6165: if (context == 'settings') {
6166: if (dosettings == 1) {
1.538 raeburn 6167: targetform.changeparms.value=param;
6168: targetform.submit();
6169: }
1.537 raeburn 6170: }
1.539 raeburn 6171: if (context == 'actions') {
6172: if (doaction == 1) {
6173: targetform.cmd.value=param+'_'+index;
6174: targetform.folderpath.value=folderpath;
6175: targetform.markcopy.value=idx+':'+param;
6176: targetform.copyfolder.value=folder+'.'+container;
6177: if (param == 'remove') {
6178: if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
6179: targetform.markcopy.value='';
6180: targetform.copyfolder.value='';
6181: targetform.submit();
6182: }
6183: }
6184: if (param == 'cut') {
6185: if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
6186: targetform.submit();
6187: return;
6188: }
6189: }
6190: if (param == 'copy') {
6191: targetform.submit();
6192: return;
6193: }
6194: targetform.markcopy.value='';
6195: targetform.copyfolder.value='';
6196: targetform.cmd.value='';
6197: targetform.folderpath.value='';
6198: return;
6199: } else {
6200: if (document.getElementById(param+'_'+idx)) {
6201: item = document.getElementById(param+'_'+idx);
6202: if (item.type == 'checkbox') {
6203: if (item.checked) {
6204: item.checked = false;
6205: } else {
6206: item.checked = true;
6207: singleCheck(item,idx,param);
6208: }
6209: }
6210: }
6211: }
6212: }
1.537 raeburn 6213: return;
6214: }
6215:
1.538 raeburn 6216: function singleCheck(caller,idx,action) {
6217: actions = new Array('cut','copy','remove');
6218: if (caller.checked) {
6219: for (var i=0; i<actions.length; i++) {
6220: if (actions[i] != action) {
6221: if (document.getElementById(actions[i]+'_'+idx)) {
6222: if (document.getElementById(actions[i]+'_'+idx).checked) {
6223: document.getElementById(actions[i]+'_'+idx).checked = false;
6224: }
1.537 raeburn 6225: }
6226: }
6227: }
1.478 raeburn 6228: }
1.537 raeburn 6229: return;
1.478 raeburn 6230: }
6231:
1.334 muellerd 6232: function unselectInactive(nav) {
1.335 ehlerst 6233: currentNav = document.getElementById(nav);
6234: currentLis = currentNav.getElementsByTagName('LI');
6235: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 6236: if (currentLis[i].className == 'goback') {
6237: currentLis[i].className = 'goback';
6238: } else {
6239: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 6240: currentLis[i].className = 'right';
1.472 raeburn 6241: } else {
1.374 tempelho 6242: currentLis[i].className = 'i';
1.472 raeburn 6243: }
6244: }
1.335 ehlerst 6245: }
1.332 tempelho 6246: }
6247:
1.334 muellerd 6248: function hideAll(current, nav, data) {
1.335 ehlerst 6249: unselectInactive(nav);
1.570 raeburn 6250: if (current) {
6251: if (current.className == 'right'){
6252: current.className = 'right active'
6253: } else {
6254: current.className = 'active';
6255: }
1.374 tempelho 6256: }
1.335 ehlerst 6257: currentData = document.getElementById(data);
6258: currentDivs = currentData.getElementsByTagName('DIV');
6259: for (i = 0; i < currentDivs.length; i++) {
6260: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 6261: currentDivs[i].style.display = 'none';
1.330 tempelho 6262: }
6263: }
1.335 ehlerst 6264: }
1.330 tempelho 6265:
1.374 tempelho 6266: function openTabs(pageId) {
6267: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 6268: if(tabnav.length > 2 ){
1.389 tempelho 6269: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 6270: currentLis = currentNav.getElementsByTagName('LI');
6271: for(i = 0; i< currentLis.length; i++){
6272: if(currentLis[i].className == 'active') {
1.375 tempelho 6273: funcString = currentLis[i].onclick.toString();
6274: tab = funcString.split('"');
1.420 onken 6275: if(tab.length < 2) {
6276: tab = funcString.split("'");
6277: }
1.375 tempelho 6278: currentData = document.getElementById(tab[1]);
6279: currentData.style.display = 'block';
1.374 tempelho 6280: }
6281: }
6282: }
6283: }
6284:
1.334 muellerd 6285: function showPage(current, pageId, nav, data) {
1.570 raeburn 6286: currstate = current.className;
1.334 muellerd 6287: hideAll(current, nav, data);
1.375 tempelho 6288: openTabs(pageId);
1.334 muellerd 6289: unselectInactive(nav);
1.570 raeburn 6290: if ((currstate == 'active') || (currstate == 'right active')) {
6291: if (currstate == 'active') {
6292: current.className = '';
6293: } else {
6294: current.className = 'right';
6295: }
6296: activeTab = '';
6297: toggleUpload();
6298: toggleMap();
6299: resize_scrollbox('contentscroll','1','0');
6300: return;
6301: } else {
6302: current.className = 'active';
6303: }
1.330 tempelho 6304: currentData = document.getElementById(pageId);
6305: currentData.style.display = 'block';
1.458 raeburn 6306: activeTab = pageId;
1.501 raeburn 6307: toggleUpload();
1.503 raeburn 6308: toggleMap();
1.433 raeburn 6309: if (nav == 'mainnav') {
6310: var storedpath = "$docs_folderpath";
1.434 raeburn 6311: var storedpage = "$main_container_page";
1.433 raeburn 6312: var reg = new RegExp("^supplemental");
6313: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 6314: if (storedpage == 1) {
6315: document.simpleedit.folderpath.value = '';
6316: document.uploaddocument.folderpath.value = '';
6317: } else {
6318: if (reg.test(storedpath)) {
6319: document.simpleedit.folderpath.value = '$toplevelmain';
6320: document.uploaddocument.folderpath.value = '$toplevelmain';
6321: document.newext.folderpath.value = '$toplevelmain';
6322: } else {
6323: document.simpleedit.folderpath.value = storedpath;
6324: document.uploaddocument.folderpath.value = storedpath;
6325: document.newext.folderpath.value = storedpath;
6326: }
1.433 raeburn 6327: }
6328: } else {
1.434 raeburn 6329: if (reg.test(storedpath)) {
6330: document.simpleedit.folderpath.value = storedpath;
6331: document.supuploaddocument.folderpath.value = storedpath;
6332: document.supnewext.folderpath.value = storedpath;
6333: } else {
1.433 raeburn 6334: document.simpleedit.folderpath.value = '$toplevelsupp';
6335: document.supuploaddocument.folderpath.value = '$toplevelsupp';
6336: document.supnewext.folderpath.value = '$toplevelsupp';
6337: }
6338: }
6339: }
1.485 raeburn 6340: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 6341: return false;
6342: }
1.329 droeschl 6343:
1.472 raeburn 6344: function toContents(jumpto) {
6345: var newurl = '$backtourl';
1.525 raeburn 6346: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 6347: newurl = newurl+'?postdata='+jumpto;
6348: }
6349: location.href=newurl;
6350: }
6351:
1.538 raeburn 6352: function togglePick(caller,value) {
6353: var disp = 'none';
6354: if (document.getElementById('multi'+caller)) {
6355: var curr = document.getElementById('multi'+caller).style.display;
6356: if (value == 1) {
6357: disp='block';
6358: }
6359: if (curr == disp) {
6360: return;
6361: }
6362: document.getElementById('multi'+caller).style.display=disp;
6363: if (value == 1) {
6364: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$lt{'more'}</a>';
6365: } else {
6366: document.getElementById('more'+caller).innerHTML = '';
6367: }
6368: if (caller == 'actions') {
6369: setClass(value);
6370: setBoxes(value);
6371: }
6372: }
6373: var showButton = multiSettings();
6374: if (showButton != 1) {
6375: showButton = multiActions();
6376: }
6377: if (document.getElementById('multisave')) {
6378: if (showButton == 1) {
6379: document.getElementById('multisave').style.display='block';
6380: } else {
6381: document.getElementById('multisave').style.display='none';
6382: }
6383: }
6384: resize_scrollbox('contentscroll','1','1');
6385: return;
6386: }
6387:
6388: function toggleCheckUncheck(caller,more) {
6389: if (more == 1) {
6390: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$lt{'less'}</a>';
6391: document.getElementById('allfields'+caller).style.display='block';
6392: } else {
6393: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$lt{'more'}</a>';
6394: document.getElementById('allfields'+caller).style.display='none';
6395: }
6396: resize_scrollbox('contentscroll','1','1');
6397: }
6398:
6399: function multiSettings() {
6400: var inuse = 0;
6401: var settingsform = document.togglemultsettings;
6402: if (settingsform.showmultpick.length > 1) {
6403: for (var i=0; i<settingsform.showmultpick.length; i++) {
6404: if (settingsform.showmultpick[i].checked) {
6405: if (settingsform.showmultpick[i].value == 1) {
6406: inuse = 1;
6407: }
6408: }
6409: }
6410: }
6411: return inuse;
6412: }
6413:
6414: function multiActions() {
6415: var inuse = 0;
6416: var actionsform = document.togglemultactions;
6417: if (actionsform.showmultpick.length > 1) {
6418: for (var i=0; i<actionsform.showmultpick.length; i++) {
6419: if (actionsform.showmultpick[i].checked) {
6420: if (actionsform.showmultpick[i].value == 1) {
6421: inuse = 1;
6422: }
6423: }
6424: }
6425: }
6426: return inuse;
6427: }
6428:
6429: function checkSubmits() {
6430: var numchanges = 0;
6431: var form = document.saveactions;
6432: var doactions = multiActions();
1.542 raeburn 6433: var cutwarnings = 0;
6434: var remwarnings = 0;
1.538 raeburn 6435: if (doactions == 1) {
6436: var remidxlist = document.cumulativeactions.allremoveidx.value;
6437: if ((remidxlist != '') && (remidxlist != null)) {
6438: var remidxs = remidxlist.split(',');
6439: for (var i=0; i<remidxs.length; i++) {
6440: if (document.getElementById('remove_'+remidxs[i])) {
6441: if (document.getElementById('remove_'+remidxs[i]).checked) {
6442: form.multiremove.value += remidxs[i]+',';
6443: numchanges ++;
1.542 raeburn 6444: if (document.getElementById('skip_remove_'+remidxs[i])) {
6445: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
6446: remwarnings ++;
6447: }
6448: }
1.537 raeburn 6449: }
6450: }
1.538 raeburn 6451: }
6452: }
6453: var cutidxlist = document.cumulativeactions.allcutidx.value;
6454: if ((cutidxlist != '') && (cutidxlist != null)) {
6455: var cutidxs = cutidxlist.split(',');
6456: for (var i=0; i<cutidxs.length; i++) {
6457: if (document.getElementById('cut_'+cutidxs[i])) {
6458: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
6459: form.multicut.value += cutidxs[i]+',';
6460: numchanges ++;
1.542 raeburn 6461: if (document.getElementById('skip_cut_'+cutidxs[i])) {
6462: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
6463: cutwarnings ++;
6464: }
6465: }
1.537 raeburn 6466: }
6467: }
6468: }
6469: }
1.538 raeburn 6470: var copyidxlist = document.cumulativeactions.allcopyidx.value;
6471: if ((copyidxlist != '') && (copyidxlist != null)) {
6472: var copyidxs = copyidxlist.split(',');
6473: for (var i=0; i<copyidxs.length; i++) {
6474: if (document.getElementById('copy_'+copyidxs[i])) {
6475: if (document.getElementById('copy_'+copyidxs[i]).checked) {
6476: form.multicopy.value += copyidxs[i]+',';
6477: numchanges ++;
6478: }
6479: }
6480: }
6481: }
6482: if (numchanges > 0) {
6483: form.multichange.value = numchanges;
6484: }
1.537 raeburn 6485: }
1.538 raeburn 6486: var dosettings = multiSettings();
1.543 raeburn 6487: var haschanges = 0;
1.538 raeburn 6488: if (dosettings == 1) {
6489: form.allencrypturl.value = '';
6490: form.allhiddenresource.value = '';
1.543 raeburn 6491: form.changeparms.value = 'all';
6492: var patt=new RegExp(",\$");
1.538 raeburn 6493: var allidxlist = document.cumulativesettings.allidx.value;
6494: if ((allidxlist != '') && (allidxlist != null)) {
6495: var allidxs = allidxlist.split(',');
6496: if (allidxs.length > 1) {
6497: for (var i=0; i<allidxs.length; i++) {
6498: if (document.getElementById('hiddenresource_'+allidxs[i])) {
6499: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
6500: form.allhiddenresource.value += allidxs[i]+',';
6501: }
6502: }
6503: if (document.getElementById('encrypturl_'+allidxs[i])) {
6504: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
6505: form.allencrypturl.value += allidxs[i]+',';
6506: }
6507: }
6508: }
1.543 raeburn 6509: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
6510: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
1.537 raeburn 6511: }
1.538 raeburn 6512: }
6513: form.allrandompick.value = '';
6514: form.allrandomorder.value = '';
6515: var allmapidxlist = document.cumulativesettings.allmapidx.value;
6516: if ((allmapidxlist != '') && (allmapidxlist != null)) {
6517: var allmapidxs = allmapidxlist.split(',');
6518: for (var i=0; i<allmapidxs.length; i++) {
6519: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
6520: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
6521: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
6522: if ((randompick.checked) && (rpicknum.value != '')) {
6523: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
6524: }
6525: if (randorder.checked) {
6526: form.allrandomorder.value += allmapidxs[i]+',';
6527: }
1.537 raeburn 6528: }
1.543 raeburn 6529: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
6530: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
6531: }
6532: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
6533: haschanges = 1;
6534: }
6535: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
6536: haschanges = 1;
6537: }
6538: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
6539: haschanges = 1;
6540: }
6541: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
6542: haschanges = 1;
1.537 raeburn 6543: }
6544: }
1.543 raeburn 6545: if (doactions == 1) {
1.542 raeburn 6546: if (numchanges > 0) {
6547: if ((cutwarnings > 0) || (remwarnings > 0)) {
6548: if (remwarnings > 0) {
6549: if (!confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr3a"} '+remwarnings+' $lt{"p_rmr3b"}')) {
6550: return false;
6551: }
6552: }
6553: if (cutwarnings > 0) {
6554: if (!confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr3a"} '+cutwarnings+' $lt{"p_ctr3b"}')) {
6555: return false;
6556: }
6557: }
6558: }
6559: form.submit();
6560: return true;
1.543 raeburn 6561: }
6562: }
6563: if (dosettings == 1) {
6564: if (haschanges == 1) {
1.542 raeburn 6565: form.submit();
6566: return true;
6567: }
1.543 raeburn 6568: }
6569: if ((dosettings == 1) && (doactions == 1)) {
6570: alert("$lt{'noor'}");
6571: } else {
6572: if (dosettings == 1) {
6573: alert("$lt{'noch'}");
6574: } else {
6575: alert("$lt{'noac'}");
6576: }
6577: }
1.538 raeburn 6578: return false;
6579: }
6580:
6581: function setClass(value) {
6582: var cutclass = 'LC_docs_cut';
6583: var copyclass = 'LC_docs_copy';
6584: var removeclass = 'LC_docs_remove';
6585: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
6586: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
6587: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
6588: var links = document.getElementsByTagName('a');
6589: for (var i=0; i<links.length; i++) {
6590: var classes = links[i].className;
6591: if (cutreg.test(classes)) {
6592: links[i].className = cutclass;
6593: if (value == 1) {
6594: links[i].className += " LC_menubuttons_link";
6595: }
6596: } else {
6597: if (copyreg.test(classes)) {
6598: links[i].className = copyclass;
6599: if (value == 1) {
6600: links[i].className += " LC_menubuttons_link";
6601: }
6602: } else {
6603: if (removereg.test(classes)) {
6604: links[i].className = removeclass;
6605: if (value == 1) {
6606: links[i].className += " LC_menubuttons_link";
6607: }
6608: }
6609: }
6610: }
6611: }
6612: return;
1.537 raeburn 6613: }
6614:
1.538 raeburn 6615: function setBoxes(value) {
6616: var remidxlist = document.cumulativeactions.allremoveidx.value;
6617: if ((remidxlist != '') && (remidxlist != null)) {
6618: var remidxs = remidxlist.split(',');
6619: for (var i=0; i<remidxs.length; i++) {
6620: if (document.getElementById('remove_'+remidxs[i])) {
6621: var item = document.getElementById('remove_'+remidxs[i]);
6622: if (value == 1) {
6623: item.className = 'LC_docs_remove';
6624: } else {
6625: item.className = 'LC_hidden';
6626: }
6627: }
6628: }
6629: }
6630: var cutidxlist = document.cumulativeactions.allcutidx.value;
6631: if ((cutidxlist != '') && (cutidxlist != null)) {
6632: var cutidxs = cutidxlist.split(',');
6633: for (var i=0; i<cutidxs.length; i++) {
6634: if (document.getElementById('cut_'+cutidxs[i])) {
6635: var item = document.getElementById('cut_'+cutidxs[i]);
6636: if (value == 1) {
6637: item.className = 'LC_docs_cut';
6638: } else {
6639: item.className = 'LC_hidden';
6640: }
6641: }
1.537 raeburn 6642: }
6643: }
1.538 raeburn 6644: var copyidxlist = document.cumulativeactions.allcopyidx.value;
6645: if ((copyidxlist != '') && (copyidxlist != null)) {
6646: var copyidxs = copyidxlist.split(',');
6647: for (var i=0; i<copyidxs.length; i++) {
6648: if (document.getElementById('copy_'+copyidxs[i])) {
6649: var item = document.getElementById('copy_'+copyidxs[i]);
6650: if (value == 1) {
6651: item.className = 'LC_docs_copy';
6652: } else {
6653: item.className = 'LC_hidden';
6654: }
6655: }
1.537 raeburn 6656: }
6657: }
6658: return;
6659: }
6660:
1.329 droeschl 6661: ENDNEWSCRIPT
6662: }
1.457 raeburn 6663:
1.483 raeburn 6664: sub history_tab_js {
6665: return <<"ENDHIST";
6666: function toggleHistoryDisp(choice) {
6667: document.docslogform.docslog.value = choice;
6668: document.docslogform.submit();
6669: return;
6670: }
6671:
6672: ENDHIST
6673: }
6674:
1.484 raeburn 6675: sub inject_data_js {
6676: return <<ENDINJECT;
6677:
6678: function injectData(current, hiddenField, name, value) {
6679: currentElement = document.getElementById(hiddenField);
6680: currentElement.name = name;
6681: currentElement.value = value;
6682: current.submit();
6683: }
6684:
6685: ENDINJECT
6686: }
6687:
6688: sub dump_switchserver_js {
6689: my @hosts = @_;
6690: my %lt = &Apache::lonlocal::texthash(
1.574 raeburn 6691: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 6692: swit => 'Switch server?',
1.568 raeburn 6693: duco => 'Copying Content to Authoring Space',
1.484 raeburn 6694: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
6695: chos => 'Choose server',
6696: );
6697: my $role = $env{'request.role'};
6698: my $js = <<"ENDSWJS";
6699: <script type="text/javascript">
6700: function write_switchserver() {
6701: var server;
6702: if (document.setserver.posshosts.length > 0) {
6703: for (var i=0; i<document.setserver.posshosts.length; i++) {
6704: if (document.setserver.posshosts[i].checked) {
6705: server = document.setserver.posshosts[i].value;
6706: }
6707: }
6708: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
6709: }
6710: window.close();
6711: }
6712: </script>
6713:
6714: ENDSWJS
6715:
6716: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
6717: {'only_body' => 1,
6718: 'js_ready' => 1,});
6719: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
6720:
6721: my $hostpicker;
6722: my $count = 0;
6723: foreach my $host (sort(@hosts)) {
6724: my $checked;
6725: if ($count == 0) {
6726: $checked = ' checked="checked"';
6727: }
6728: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
6729: $host.'"'.$checked.' />'.$host.'</label> ';
6730: $count++;
6731: }
6732:
6733: return <<"ENDSWITCHJS";
6734:
6735: function dump_needs_switchserver(url) {
6736: if (url!='' && url!= null) {
6737: if (confirm("$lt{'dump'}\\n$lt{'swit'}")) {
6738: go(url);
6739: }
6740: }
6741: return;
6742: }
6743:
6744: function choose_switchserver_window() {
6745: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
6746: newWindow.document.open();
6747: newWindow.document.writeln('$startpage');
6748: newWindow.document.write('<h3>$lt{'duco'}<\\/h3>\\n'+
6749: '<p>$lt{'yone'}<\\/p>\\n'+
6750: '<div class="LC_left_float"><fieldset><legend>$lt{'chos'}<\\/legend>\\n'+
6751: '<form name="setserver" method="post" action="" \\/>\\n'+
6752: '$hostpicker\\n'+
6753: '<br \\/><br \\/>\\n'+
6754: '<input type="button" name="makeswitch" value="$lt{'swit'}" '+
6755: 'onclick="write_switchserver();" \\/>\\n'+
6756: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
6757: newWindow.document.writeln('$endpage');
6758: newWindow.document.close();
6759: newWindow.focus();
6760: }
6761:
6762: ENDSWITCHJS
6763: }
6764:
6765: sub makedocslogform {
6766: my ($formelems,$docslog) = @_;
6767: return <<"LOGSFORM";
6768: <form action="/adm/coursedocs" method="post" name="docslogform">
6769: <input type="hidden" name="docslog" value="$docslog" />
6770: $formelems
6771: </form>
6772: LOGSFORM
6773: }
6774:
6775: sub makesimpleeditform {
6776: my ($formelems) = @_;
6777: return <<"SIMPFORM";
6778: <form name="simpleedit" method="post" action="/adm/coursedocs">
6779: <input type="hidden" name="importdetail" value="" />
6780: $formelems
6781: </form>
6782: SIMPFORM
6783: }
6784:
1.329 droeschl 6785: 1;
6786: __END__
6787:
6788:
6789: =head1 NAME
6790:
6791: Apache::londocs.pm
6792:
6793: =head1 SYNOPSIS
6794:
6795: This is part of the LearningOnline Network with CAPA project
6796: described at http://www.lon-capa.org.
6797:
6798: =head1 SUBROUTINES
6799:
6800: =over
6801:
6802: =item %help=()
6803:
6804: Available help topics
6805:
6806: =item mapread()
6807:
1.344 bisitz 6808: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 6809: @order and @resources, determines status
6810: sets @order - pointer to resources in right order
6811: sets @resources - array with the resources with correct idx
6812:
6813: =item authorhosts()
6814:
6815: Return hash with valid author names
6816:
6817: =item clean()
6818:
6819: =item dumpcourse()
6820:
6821: Actually dump course
6822:
6823: =item group_import()
6824:
6825: Imports the given (name, url) resources into the course
6826: coursenum, coursedom, and folder must precede the list
6827:
6828: =item breadcrumbs()
6829:
6830: =item log_docs()
6831:
6832: =item docs_change_log()
6833:
6834: =item update_paste_buffer()
6835:
6836: =item print_paste_buffer()
6837:
6838: =item do_paste_from_buffer()
6839:
1.538 raeburn 6840: =item do_buffer_empty()
6841:
6842: =item clear_from_buffer()
6843:
1.492 raeburn 6844: =item get_newmap_url()
6845:
6846: =item dbcopy()
6847:
6848: =item uniqueness_check()
6849:
6850: =item contained_map_check()
6851:
6852: =item url_paste_fixups()
6853:
6854: =item apply_fixups()
6855:
6856: =item copy_dependencies()
6857:
1.329 droeschl 6858: =item update_parameter()
6859:
6860: =item handle_edit_cmd()
6861:
6862: =item editor()
6863:
6864: =item process_file_upload()
6865:
6866: =item process_secondary_uploads()
6867:
6868: =item is_supplemental_title()
6869:
6870: =item entryline()
6871:
6872: =item tiehash()
6873:
6874: =item untiehash()
6875:
6876: =item checkonthis()
6877:
6878: check on this
6879:
6880: =item verifycontent()
6881:
6882: Verify Content
6883:
6884: =item devalidateversioncache() & checkversions()
6885:
6886: Check Versions
6887:
6888: =item mark_hash_old()
6889:
6890: =item is_hash_old()
6891:
6892: =item changewarning()
6893:
6894: =item init_breadcrumbs()
6895:
6896: Breadcrumbs for special functions
6897:
1.484 raeburn 6898: =item create_list_elements()
6899:
6900: =item create_form_ul()
6901:
6902: =item startContentScreen()
6903:
6904: =item endContentScreen()
6905:
6906: =item supplemental_base()
6907:
6908: =item embedded_form_elems()
6909:
6910: =item embedded_destination()
6911:
6912: =item return_to_editor()
6913:
6914: =item decompression_info()
6915:
6916: =item decompression_phase_one()
6917:
6918: =item decompression_phase_two()
6919:
6920: =item remove_archive()
6921:
6922: =item generate_admin_menu()
6923:
6924: =item generate_edit_table()
6925:
6926: =item editing_js()
6927:
6928: =item history_tab_js()
6929:
6930: =item inject_data_js()
6931:
6932: =item dump_switchserver_js()
6933:
1.485 raeburn 6934: =item resize_scrollbox_js()
1.484 raeburn 6935:
6936: =item makedocslogform()
6937:
1.485 raeburn 6938: =item makesimpleeditform()
6939:
1.329 droeschl 6940: =back
6941:
6942: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>