Annotation of loncom/interface/londocs.pm, revision 1.577
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.577 ! bisitz 4: # $Id: londocs.pm,v 1.576 2014/01/12 22:34:51 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">
1.577 ! bisitz 304: <h4 class="LC_hcell">'.&mt('Content').'</h4>'.
1.567 raeburn 305: $contents{content}.'
306: </div>';
307: }
308: if ($contents{webreferences}) {
309: $content .= '
310: <div class="LC_Box">
1.577 ! bisitz 311: <h4 class="LC_hcell">'.&mt('Web References').'</h4>'.
1.567 raeburn 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.577 ! bisitz 4852: 'bb5' => 'Blackboard 5',
! 4853: 'bb6' => 'Blackboard 6',
! 4854: 'angel5' => 'ANGEL 5.5',
! 4855: 'webctce4' => 'WebCT 4 Campus Edition',
! 4856: );
1.329 droeschl 4857: # -----------------------------------------------------------------------------
4858: my $fileupload=(<<FIUP);
4859: $lt{'file'}:<br />
4860: <input type="file" name="uploaddoc" size="40" />
4861: FIUP
4862:
4863: my $checkbox=(<<CHBO);
4864: <!-- <label>$lt{'parse'}?
4865: <input type="checkbox" name="parserflag" />
4866: </label> -->
4867: <label>
4868: <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
4869: </label>
4870: CHBO
1.501 raeburn 4871: my $imsfolder = $env{'form.folder'};
4872: if ($imsfolder eq '') {
4873: $imsfolder = 'default';
4874: }
4875: my $imspform=(<<IMSFORM);
4876: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
4877: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
4878: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.516 raeburn 4879: <fieldset id="uploadimsform" style="display: none;">
1.501 raeburn 4880: <legend>$lt{'imsf'}</legend>
4881: $fileupload
4882: <br />
4883: <p>
4884: $lt{'cms'}:
4885: <select name="source">
4886: <option value="-1" selected="selected">$lt{'se'}</option>
1.577 ! bisitz 4887: <option value="bb5">$lt{'bb5'}</option>
! 4888: <option value="bb6">$lt{'bb6'}</option>
! 4889: <option value="angel5">$lt{'angel5'}</option>
! 4890: <option value="webctce4">$lt{'webctce4'}</option>
1.501 raeburn 4891: </select>
4892: <input type="hidden" name="folder" value="$imsfolder" />
4893: </p>
4894: <input type="hidden" name="phase" value="one" />
4895: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" />
4896: </fieldset>
4897: </form>
4898: IMSFORM
1.329 droeschl 4899:
4900: my $fileuploadform=(<<FUFORM);
1.501 raeburn 4901: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
4902: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
4903: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.516 raeburn 4904: <fieldset id="uploaddocform" style="display: none;">
1.501 raeburn 4905: <legend>$lt{'upfi'}</legend>
1.371 tempelho 4906: <input type="hidden" name="active" value="aa" />
1.329 droeschl 4907: $fileupload
4908: <br />
4909: $lt{'title'}:<br />
1.458 raeburn 4910: <input type="text" size="60" name="comment" />
1.508 raeburn 4911: $pathitem
1.329 droeschl 4912: <input type="hidden" name="cmd" value="upload_default" />
4913: <br />
1.458 raeburn 4914: <span class="LC_nobreak" style="float:left">
1.329 droeschl 4915: $checkbox
4916: </span>
1.501 raeburn 4917: <br clear="all" />
4918: <input type="submit" value="$lt{'upld'}" />
4919: </fieldset>
4920: </form>
1.383 tempelho 4921: FUFORM
1.329 droeschl 4922:
1.502 raeburn 4923: my $importpubform=(<<SEDFFORM);
1.514 raeburn 4924: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.502 raeburn 4925: $lt{'impm'}</a>$help{'Load_Map'}
4926: <form action="/adm/coursedocs" method="post" name="mapimportform">
1.516 raeburn 4927: <fieldset id="importmapform" style="display: none;">
1.502 raeburn 4928: <legend>$lt{'impm'}</legend>
1.371 tempelho 4929: <input type="hidden" name="active" value="bb" />
1.502 raeburn 4930: $lt{'copm'}<br />
4931: <span class="LC_nobreak">
4932: <input type="text" name="importmap" size="40" value=""
4933: onfocus="this.blur();openbrowser('mapimportform','importmap','sequence,page','');" />
1.516 raeburn 4934: <a href="javascript:openbrowser('mapimportform','importmap','sequence,page','');">$lt{'selm'}</a></span><br />
1.502 raeburn 4935: <input type="submit" name="loadmap" value="$lt{'load'}" />
4936: </fieldset>
4937: </form>
4938:
1.383 tempelho 4939: SEDFFORM
1.502 raeburn 4940: my @importpubforma = (
1.508 raeburn 4941: { '<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 4942: { '<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 4943: { '<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 4944: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
1.383 tempelho 4945: );
1.502 raeburn 4946: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
1.510 raeburn 4947: my $extresourcesform =
4948: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
4949: $help{'Adding_External_Resource'});
1.329 droeschl 4950: if ($allowed) {
1.492 raeburn 4951: my $folder = $env{'form.folder'};
4952: if ($folder eq '') {
4953: $folder='default';
4954: }
1.538 raeburn 4955: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
4956: if ($output) {
4957: $r->print($output);
4958: }
1.337 ehlerst 4959: $r->print(<<HIDDENFORM);
4960: <form name="renameform" method="post" action="/adm/coursedocs">
4961: <input type="hidden" name="title" />
4962: <input type="hidden" name="cmd" />
4963: <input type="hidden" name="markcopy" />
4964: <input type="hidden" name="copyfolder" />
4965: $containertag
4966: </form>
1.484 raeburn 4967:
1.337 ehlerst 4968: HIDDENFORM
1.508 raeburn 4969: $r->print(&makesimpleeditform($pathitem)."\n".
4970: &makedocslogform($pathitem."\n".
1.484 raeburn 4971: '<input type="hidden" name="folder" value="'.
4972: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 4973: }
1.442 www 4974:
4975: # Generate the tabs
1.510 raeburn 4976: my ($mode,$needs_end);
1.472 raeburn 4977: if (($supplementalflag) && (!$allowed)) {
1.510 raeburn 4978: my @folders = split('&',$env{'form.folderpath'});
4979: unless (@folders > 2) {
4980: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
4981: $needs_end = 1;
4982: }
1.472 raeburn 4983: } else {
1.484 raeburn 4984: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.510 raeburn 4985: $needs_end = 1;
1.472 raeburn 4986: }
1.443 www 4987:
1.442 www 4988: #
4989:
4990: my $savefolderpath;
4991:
1.395 raeburn 4992: if ($allowed) {
1.329 droeschl 4993: my $folder=$env{'form.folder'};
1.443 www 4994: if ($folder eq '' || $supplementalflag) {
1.329 droeschl 4995: $folder='default';
1.356 tempelho 4996: $savefolderpath = $env{'form.folderpath'};
1.548 raeburn 4997: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.508 raeburn 4998: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 4999: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
5000: }
5001: my $postexec='';
5002: if ($folder eq 'default') {
1.372 bisitz 5003: $r->print('<script type="text/javascript">'."\n"
5004: .'// <![CDATA['."\n"
5005: .'this.window.name="loncapaclient";'."\n"
5006: .'// ]]>'."\n"
5007: .'</script>'."\n"
1.369 bisitz 5008: );
1.329 droeschl 5009: } else {
5010: #$postexec='self.close();';
5011: }
1.504 raeburn 5012: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
5013: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 5014: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
5015:
5016: my $newnavform=(<<NNFORM);
5017: <form action="/adm/coursedocs" method="post" name="newnav">
1.570 raeburn 5018: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5019: $pathitem
1.329 droeschl 5020: <input type="hidden" name="importdetail"
5021: value="$lt{'navc'}=/adm/navmaps" />
1.423 onken 5022: <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
1.329 droeschl 5023: $help{'Navigate_Content'}
5024: </form>
5025: NNFORM
5026: my $newsmppageform=(<<NSPFORM);
5027: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.570 raeburn 5028: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5029: $pathitem
1.329 droeschl 5030: <input type="hidden" name="importdetail" value="" />
1.423 onken 5031: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 5032: $help{'Simple Page'}
1.329 droeschl 5033: </form>
5034: NSPFORM
5035:
5036: my $newsmpproblemform=(<<NSPROBFORM);
5037: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 5038: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5039: $pathitem
1.329 droeschl 5040: <input type="hidden" name="importdetail" value="" />
1.423 onken 5041: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.572 raeburn 5042: $help{'Simple_Problem'}
1.329 droeschl 5043: </form>
5044:
5045: NSPROBFORM
5046:
5047: my $newdropboxform=(<<NDBFORM);
5048: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 5049: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5050: $pathitem
1.329 droeschl 5051: <input type="hidden" name="importdetail" value="" />
1.423 onken 5052: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.554 raeburn 5053: $help{'Dropbox'}
1.344 bisitz 5054: </form>
1.329 droeschl 5055: NDBFORM
5056:
5057: my $newexuploadform=(<<NEXUFORM);
5058: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 5059: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5060: $pathitem
1.329 droeschl 5061: <input type="hidden" name="importdetail" value="" />
1.423 onken 5062: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 5063: $help{'Score_Upload_Form'}
5064: </form>
5065: NEXUFORM
5066:
5067: my $newbulform=(<<NBFORM);
5068: <form action="/adm/coursedocs" method="post" name="newbul">
1.570 raeburn 5069: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5070: $pathitem
1.329 droeschl 5071: <input type="hidden" name="importdetail" value="" />
1.423 onken 5072: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 5073: $help{'Bulletin Board'}
5074: </form>
5075: NBFORM
5076:
5077: my $newaboutmeform=(<<NAMFORM);
5078: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.570 raeburn 5079: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5080: $pathitem
1.329 droeschl 5081: <input type="hidden" name="importdetail"
5082: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 5083: <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 5084: $help{'My Personal Information Page'}
1.329 droeschl 5085: </form>
5086: NAMFORM
5087:
5088: my $newaboutsomeoneform=(<<NASOFORM);
5089: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.570 raeburn 5090: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5091: $pathitem
1.329 droeschl 5092: <input type="hidden" name="importdetail" value="" />
1.423 onken 5093: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 5094: </form>
5095: NASOFORM
5096:
5097: my $newrosterform=(<<NROSTFORM);
5098: <form action="/adm/coursedocs" method="post" name="newroster">
1.570 raeburn 5099: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5100: $pathitem
1.329 droeschl 5101: <input type="hidden" name="importdetail"
5102: value="$lt{'rost'}=/adm/viewclasslist" />
1.423 onken 5103: <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
1.556 raeburn 5104: $help{'Course_Roster'}
1.329 droeschl 5105: </form>
5106: NROSTFORM
5107:
1.534 raeburn 5108: my $newwebpage;
5109: if ($folder =~ /^default_?(\d*)$/) {
5110: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
5111: if ($1) {
5112: $newwebpage .= $1;
5113: } else {
5114: $newwebpage .= 'default';
5115: }
5116: $newwebpage .= '/new.html';
5117: }
5118: my $newwebpageform =(<<NWEBFORM);
5119: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.570 raeburn 5120: <input type="hidden" name="active" value="ee" />
1.534 raeburn 5121: $pathitem
5122: <input type="hidden" name="importdetail" value="$newwebpage" />
5123: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.556 raeburn 5124: $help{'Web_Page'}
1.534 raeburn 5125: </form>
5126: NWEBFORM
5127:
5128:
1.342 ehlerst 5129: my $specialdocumentsform;
1.383 tempelho 5130: my @specialdocumentsforma;
1.451 www 5131: my $gradingform;
5132: my @gradingforma;
5133: my $communityform;
5134: my @communityforma;
1.351 ehlerst 5135: my $newfolderform;
1.390 tempelho 5136: my $newfolderb;
1.342 ehlerst 5137:
1.451 www 5138: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 5139:
1.329 droeschl 5140: my $newpageform=(<<NPFORM);
5141: <form action="/adm/coursedocs" method="post" name="newpage">
5142: <input type="hidden" name="folderpath" value="$path" />
5143: <input type="hidden" name="importdetail" value="" />
1.570 raeburn 5144: <input type="hidden" name="active" value="ee" />
1.423 onken 5145: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 5146: $help{'Adding_Pages'}
1.329 droeschl 5147: </form>
5148: NPFORM
1.390 tempelho 5149:
5150:
1.351 ehlerst 5151: $newfolderform=(<<NFFORM);
1.329 droeschl 5152: <form action="/adm/coursedocs" method="post" name="newfolder">
1.508 raeburn 5153: $pathitem
1.329 droeschl 5154: <input type="hidden" name="importdetail" value="" />
1.570 raeburn 5155: <input type="hidden" name="active" value="" />
1.422 onken 5156: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 5157: </form>
5158: NFFORM
5159:
5160: my $newsylform=(<<NSYLFORM);
5161: <form action="/adm/coursedocs" method="post" name="newsyl">
1.570 raeburn 5162: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5163: $pathitem
1.329 droeschl 5164: <input type="hidden" name="importdetail"
5165: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 5166: <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 5167: $help{'Syllabus'}
1.383 tempelho 5168:
1.329 droeschl 5169: </form>
5170: NSYLFORM
1.364 bisitz 5171:
1.329 droeschl 5172: my $newgroupfileform=(<<NGFFORM);
5173: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.570 raeburn 5174: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5175: $pathitem
1.329 droeschl 5176: <input type="hidden" name="importdetail"
5177: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.423 onken 5178: <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
1.353 weissno 5179: $help{'Group Portfolio'}
1.329 droeschl 5180: </form>
5181: NGFFORM
1.383 tempelho 5182: @specialdocumentsforma=(
1.421 onken 5183: {'<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 5184: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
1.451 www 5185: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
5186: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.534 raeburn 5187: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.451 www 5188: );
5189: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
5190:
1.434 raeburn 5191:
5192: my @importdoc = (
1.519 raeburn 5193: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
5194: );
5195: unless ($container eq 'page') {
5196: push(@importdoc,
5197: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
5198: );
5199: }
5200: push(@importdoc,
1.558 raeburn 5201: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform}
1.519 raeburn 5202: );
1.501 raeburn 5203: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 5204:
1.451 www 5205: @gradingforma=(
5206: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
5207: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
5208: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
5209:
5210: );
5211: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
5212:
5213: @communityforma=(
5214: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
5215: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
5216: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
5217: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},
5218: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
5219: );
5220: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 5221:
1.330 tempelho 5222: my %orderhash = (
1.553 raeburn 5223: 'aa' => ['Upload',$fileuploadform],
5224: 'bb' => ['Import',$importpubform],
5225: 'cc' => ['Grading',$gradingform],
1.330 tempelho 5226: );
1.519 raeburn 5227: unless ($container eq 'page') {
1.434 raeburn 5228: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 5229: $orderhash{'dd'} = ['Collaboration',$communityform];
1.553 raeburn 5230: $orderhash{'ee'} = ['Other',$specialdocumentsform];
1.434 raeburn 5231: }
5232:
1.341 ehlerst 5233: $hadchanges=0;
1.484 raeburn 5234: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 5235: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.508 raeburn 5236: $supplementalflag,\%orderhash,$iconpath,$pathitem);
1.443 www 5237: if ($error) {
5238: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
5239: }
5240: if ($hadchanges) {
5241: &mark_hash_old();
5242: }
1.341 ehlerst 5243:
1.443 www 5244: &changewarning($r,'');
5245: }
1.458 raeburn 5246: }
1.442 www 5247:
1.443 www 5248: # Supplemental documents start here
5249:
1.329 droeschl 5250: my $folder=$env{'form.folder'};
1.443 www 5251: unless ($supplementalflag) {
1.329 droeschl 5252: $folder='supplemental';
5253: }
5254: if ($folder =~ /^supplemental$/ &&
5255: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 5256: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 5257: } elsif ($allowed) {
1.356 tempelho 5258: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 5259: }
1.508 raeburn 5260: $pathitem = '<input type="hidden" name="folderpath" value="'.
5261: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 5262: if ($allowed) {
5263: my $folderseq=
1.504 raeburn 5264: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 5265:
5266: my $supupdocform=(<<SUPDOCFORM);
1.501 raeburn 5267: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
5268: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 5269: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.516 raeburn 5270: <fieldset id="uploadsuppdocform" style="display: none;">
1.501 raeburn 5271: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5272: <input type="hidden" name="active" value="ee" />
1.329 droeschl 5273: $fileupload
5274: <br />
5275: <br />
5276: <span class="LC_nobreak">
5277: $checkbox
5278: </span>
5279: <br /><br />
5280: $lt{'comment'}:<br />
1.383 tempelho 5281: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 5282: <br />
1.508 raeburn 5283: $pathitem
1.329 droeschl 5284: <input type="hidden" name="cmd" value="upload_supplemental" />
1.501 raeburn 5285: <input type='submit' value="$lt{'upld'}" />
5286: </form>
1.329 droeschl 5287: SUPDOCFORM
5288:
5289: my $supnewfolderform=(<<SNFFORM);
5290: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.570 raeburn 5291: <input type="hidden" name="active" value="" />
1.508 raeburn 5292: $pathitem
1.329 droeschl 5293: <input type="hidden" name="importdetail" value="" />
1.423 onken 5294: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 5295: $help{'Adding_Folders'}
1.329 droeschl 5296: </form>
5297: SNFFORM
1.383 tempelho 5298:
1.510 raeburn 5299: my $supextform =
5300: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
5301: $help{'Adding_External_Resource'});
1.329 droeschl 5302:
5303: my $supnewsylform=(<<SNSFORM);
5304: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 5305: <input type="hidden" name="active" value="ff" />
1.508 raeburn 5306: $pathitem
1.329 droeschl 5307: <input type="hidden" name="importdetail"
5308: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 5309: <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 5310: $help{'Syllabus'}
5311: </form>
5312: SNSFORM
5313:
5314: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 5315: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 5316: <input type="hidden" name="active" value="ff" />
1.508 raeburn 5317: $pathitem
1.329 droeschl 5318: <input type="hidden" name="importdetail"
5319: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 5320: <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 5321: $help{'My Personal Information Page'}
1.329 droeschl 5322: </form>
5323: SNAMFORM
5324:
1.534 raeburn 5325: my $supwebpage;
5326: if ($folder =~ /^supplemental_?(\d*)$/) {
5327: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
5328: if ($1) {
5329: $supwebpage .= $1;
5330: } else {
5331: $supwebpage .= 'default';
5332: }
5333: $supwebpage .= '/new.html';
5334: }
5335: my $supwebpageform =(<<SWEBFORM);
5336: <form action="/adm/coursedocs" method="post" name="supwebpage">
5337: <input type="hidden" name="active" value="cc" />
5338: $pathitem
5339: <input type="hidden" name="importdetail" value="$supwebpage" />
5340: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.556 raeburn 5341: $help{'Web_Page'}
1.534 raeburn 5342: </form>
5343: SWEBFORM
5344:
1.333 muellerd 5345:
1.383 tempelho 5346: my @specialdocs = (
1.417 droeschl 5347: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
5348: =>$supnewsylform},
5349: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
5350: =>$supnewaboutmeform},
1.534 raeburn 5351: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
5352:
1.383 tempelho 5353: );
1.417 droeschl 5354: my @supimportdoc = (
1.515 raeburn 5355: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />'
1.501 raeburn 5356: =>$supextform},
5357: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
5358: =>$supupdocform},
5359: );
5360:
5361: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 5362: my %suporderhash = (
1.390 tempelho 5363: '00' => ['Supnewfolder', $supnewfolderform],
1.553 raeburn 5364: 'ee' => ['Upload',$supupdocform],
5365: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 5366: );
1.443 www 5367: if ($supplementalflag) {
1.458 raeburn 5368: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.508 raeburn 5369: $supplementalflag,\%suporderhash,$iconpath,$pathitem);
1.443 www 5370: if ($error) {
5371: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.557 raeburn 5372: } else {
5373: if ($suppchanges) {
5374: my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
5375: my @ids=&Apache::lonnet::current_machine_ids();
5376: foreach my $server (keys(%servers)) {
5377: next if (grep(/^\Q$server\E$/,@ids));
5378: my $hashid=$coursenum.':'.$coursedom;
1.566 raeburn 5379: my $cachekey = &escape('suppcount').':'.&escape($hashid);
5380: &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
1.557 raeburn 5381: }
5382: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
5383: undef($suppchanges);
5384: }
5385: }
1.393 raeburn 5386: }
1.443 www 5387: } elsif ($supplementalflag) {
1.458 raeburn 5388: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.508 raeburn 5389: $supplementalflag,'',$iconpath,$pathitem);
1.393 raeburn 5390: if ($error) {
5391: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 5392: }
1.393 raeburn 5393: }
1.389 tempelho 5394:
1.510 raeburn 5395: if ($needs_end) {
5396: $r->print(&endContentScreen());
5397: }
1.383 tempelho 5398:
1.329 droeschl 5399: if ($allowed) {
5400: $r->print('
5401: <form method="post" name="extimport" action="/adm/coursedocs">
5402: <input type="hidden" name="title" />
5403: <input type="hidden" name="url" />
5404: <input type="hidden" name="useform" />
5405: <input type="hidden" name="residx" />
5406: </form>');
5407: }
1.484 raeburn 5408: } elsif ($showdoc) {
1.329 droeschl 5409: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 5410: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.498 bisitz 5411: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 5412: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 5413: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 5414: }
5415: }
5416: $r->print(&Apache::loncommon::end_page());
5417: return OK;
1.364 bisitz 5418: }
1.329 droeschl 5419:
1.440 raeburn 5420: sub embedded_form_elems {
5421: my ($phase,$primaryurl,$newidx) = @_;
5422: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
5423: return <<STATE;
5424: <input type="hidden" name="folderpath" value="$folderpath" />
5425: <input type="hidden" name="cmd" value="upload_embedded" />
5426: <input type="hidden" name="newidx" value="$newidx" />
5427: <input type="hidden" name="phase" value="$phase" />
5428: <input type="hidden" name="primaryurl" value="$primaryurl" />
5429: STATE
5430: }
5431:
5432: sub embedded_destination {
5433: my $folder=$env{'form.folder'};
5434: my $destination = 'docs/';
5435: if ($folder =~ /^supplemental/) {
5436: $destination = 'supplemental/';
5437: }
5438: if (($folder eq 'default') || ($folder eq 'supplemental')) {
5439: $destination .= 'default/';
5440: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
5441: $destination .= $2.'/';
5442: }
5443: $destination .= $env{'form.newidx'};
5444: my $dir_root = '/userfiles';
5445: return ($destination,$dir_root);
5446: }
5447:
5448: sub return_to_editor {
5449: my $actionurl = '/adm/coursedocs';
5450: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
5451: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
5452: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
5453: '</a></p>';
5454: }
5455:
1.476 raeburn 5456: sub decompression_info {
5457: my ($destination,$dir_root) = &embedded_destination();
5458: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
5459: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5460: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5461: my $container='sequence';
1.480 raeburn 5462: my ($pathitem,$hiddenelem);
1.519 raeburn 5463: my @hiddens = ('newidx','comment','position','folderpath');
5464: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 5465: $container='page';
5466: }
1.480 raeburn 5467: unshift(@hiddens,$pathitem);
5468: foreach my $item (@hiddens) {
5469: if ($env{'form.'.$item}) {
5470: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
5471: $env{'form.'.$item}.'" />'."\n";
5472: }
1.477 raeburn 5473: }
1.476 raeburn 5474: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
5475: $hiddenelem);
5476: }
5477:
5478: sub decompression_phase_one {
5479: my ($dir,$file,$warning,$error,$output);
5480: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
5481: &decompression_info();
1.490 raeburn 5482: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 5483: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
5484: } else {
5485: my $file = $1;
1.481 raeburn 5486: $output =
5487: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
5488: $destination,$dir_root,
5489: $hiddenelem);
5490: if ($env{'form.autoextract_camtasia'}) {
5491: $output .= &remove_archive($docudom,$docuname,$container);
5492: }
1.476 raeburn 5493: }
5494: if ($error) {
5495: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
5496: $error.'</p>'."\n";
5497: }
5498: if ($warning) {
5499: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
5500: }
5501: return $output;
5502: }
5503:
5504: sub decompression_phase_two {
5505: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
5506: &decompression_info();
1.481 raeburn 5507: my $output;
1.480 raeburn 5508: if ($env{'form.archivedelete'}) {
1.481 raeburn 5509: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 5510: }
5511: $output .=
1.481 raeburn 5512: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 5513: $destination,$dir_root,$hiddenelem);
5514: return $output;
5515: }
5516:
1.480 raeburn 5517: sub remove_archive {
5518: my ($docudom,$docuname,$container) = @_;
5519: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 5520: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 5521: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
5522: if ($fatal) {
5523: if ($container eq 'page') {
5524: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
5525: } else {
5526: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
5527: }
5528: $delwarning .= &mt('As a result the archive file has not been removed.');
5529: } else {
5530: my $currcmd = $env{'form.cmd'};
5531: my $position = $env{'form.position'};
1.563 raeburn 5532: if ($position > 0) {
5533: $env{'form.cmd'} = 'remove_'.$position;
1.480 raeburn 5534: my ($title,$url,@rrest) =
5535: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);
5536: if (&handle_edit_cmd($docuname,$docudom)) {
1.492 raeburn 5537: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
1.480 raeburn 5538: if ($fatal) {
5539: if ($container eq 'page') {
5540: $delwarning = &mt('An error occurred updating the contents of the current page.');
5541: } else {
5542: $delwarning = &mt('An error occurred updating the contents of the current folder.');
5543: }
5544: } else {
1.481 raeburn 5545: $delresult = &mt('Archive file removed.');
1.480 raeburn 5546: }
5547: }
5548: }
5549: $env{'form.cmd'} = $currcmd;
5550: }
5551: if ($delwarning) {
5552: $output = '<p class="LC_warning">'.
5553: $delwarning.
5554: '</p>';
5555: }
5556: if ($delresult) {
5557: $output .= '<p class="LC_info">'.
5558: $delresult.
5559: '</p>';
5560: }
1.481 raeburn 5561: return $output;
1.480 raeburn 5562: }
5563:
1.484 raeburn 5564: sub generate_admin_menu {
5565: my ($crstype) = @_;
5566: my $lc_crstype = lc($crstype);
5567: my ($home,$other,%outhash)=&authorhosts();
1.562 bisitz 5568: my %lt= ( # do not translate here
1.484 raeburn 5569: 'vc' => 'Verify Content',
5570: 'cv' => 'Check/Set Resource Versions',
5571: 'ls' => 'List Resource Identifiers',
5572: 'imse' => 'Export contents to IMS Archive',
1.568 raeburn 5573: 'dcd' => "Copy $crstype Content to Authoring Space",
1.562 bisitz 5574: );
1.484 raeburn 5575: my ($candump,$dumpurl);
5576: if ($home + $other > 0) {
5577: $candump = 'F';
5578: if ($home) {
5579: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
5580: } else {
5581: my @hosts;
5582: foreach my $aurole (keys(%outhash)) {
5583: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
5584: push(@hosts,$outhash{$aurole});
1.538 raeburn 5585: }
1.484 raeburn 5586: }
5587: if (@hosts == 1) {
5588: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
5589: '&role='.
5590: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
5591: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
5592: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
5593: } else {
5594: $dumpurl = "javascript:choose_switchserver_window()";
5595: }
5596: }
5597: }
5598: my @menu=
5599: ({ categorytitle=>'Administration',
5600: items =>[
5601: { linktext => $lt{'vc'},
5602: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
5603: permission => 'F',
1.571 raeburn 5604: help => 'Docs_Verify_Content',
1.484 raeburn 5605: icon => 'verify.png',
5606: linktitle => 'Verify contents can be retrieved/rendered',
5607: },
5608: { linktext => $lt{'cv'},
5609: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
5610: permission => 'F',
1.571 raeburn 5611: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 5612: icon => 'resversion.png',
5613: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
5614: },
5615: { linktext => $lt{'ls'},
5616: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
5617: permission => 'F',
5618: #help => '',
5619: icon => 'symbs.png',
5620: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
5621: },
5622: ]
5623: },
5624: { categorytitle=>'Export',
5625: items =>[
5626: { linktext => $lt{'imse'},
5627: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
5628: permission => 'F',
5629: help => 'Docs_Export_Course_Docs',
5630: icon => 'imsexport.png',
5631: linktitle => $lt{'imse'},
5632: },
5633: { linktext => $lt{'dcd'},
5634: url => $dumpurl,
5635: permission => $candump,
1.571 raeburn 5636: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 5637: icon => 'dump.png',
5638: linktitle => $lt{'dcd'},
5639: },
5640: ]
5641: });
5642: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
5643: '<input type="hidden" id="dummy" />'."\n".
5644: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
5645: '</form>';
1.329 droeschl 5646: }
5647:
5648: sub generate_edit_table {
1.538 raeburn 5649: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
5650: $need_save,$copyfolder) = @_;
1.406 raeburn 5651: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 5652: my %orderhash = %{$orderhash_ref};
1.344 bisitz 5653: my $form;
1.371 tempelho 5654: my $activetab;
5655: my $active;
1.570 raeburn 5656: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 5657: $activetab = $env{'form.active'};
5658: }
1.472 raeburn 5659: my $backicon = $iconpath.'clickhere.gif';
1.525 raeburn 5660: my $backtext = &mt('Exit Editor');
1.458 raeburn 5661: $form = '<div class="LC_Box" style="margin:0;">'.
1.488 raeburn 5662: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
5663: '<li class="goback">'.
1.546 raeburn 5664: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.488 raeburn 5665: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
5666: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
5667: '<li>'.
5668: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
5669: &mt('Undo Delete').'</a></li>'."\n";
5670: if ($env{'form.docslog'}) {
5671: $form .= '<li class="active">';
5672: } else {
5673: $form .= '<li>';
5674: }
5675: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
5676: &mt('History').'</a></li>'."\n";
5677: if ($env{'form.docslog'}) {
5678: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
5679: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 5680: }
1.458 raeburn 5681: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 5682: if($name ne '00'){
1.371 tempelho 5683: if($activetab eq '' || $activetab ne $name){
5684: $active = '';
5685: }elsif($activetab eq $name){
5686: $active = 'class="active"';
5687: }
1.458 raeburn 5688: $form .= '<li style="float:right" '.$active
1.484 raeburn 5689: .' 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 5690: } else {
1.570 raeburn 5691: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 5692:
5693: }
1.329 droeschl 5694: }
1.484 raeburn 5695: $form .= '</ul>'."\n";
5696: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 5697:
5698: if ($to_show ne '') {
1.538 raeburn 5699: my $saveform;
5700: if ($need_save) {
5701: my $button = &mt('Make changes');
5702: my $path;
5703: if ($env{'form.folderpath'}) {
5704: $path =
5705: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
5706: }
5707: $saveform = <<"END";
5708: <div id="multisave" style="display:none; clear:both;" >
5709: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
5710: <input type="hidden" name="folderpath" value="$path" />
5711: <input type="hidden" name="symb" value="$env{'form.symb'}" />
5712: <input type="hidden" name="allhiddenresource" value="" />
5713: <input type="hidden" name="allencrypturl" value="" />
5714: <input type="hidden" name="allrandompick" value="" />
5715: <input type="hidden" name="allrandomorder" value="" />
5716: <input type="hidden" name="changeparms" value="" />
5717: <input type="hidden" name="multiremove" value="" />
5718: <input type="hidden" name="multicut" value="" />
5719: <input type="hidden" name="multicopy" value="" />
5720: <input type="hidden" name="multichange" value="" />
5721: <input type="hidden" name="copyfolder" value="$copyfolder" />
5722: <input type="submit" name="savemultiples" value="$button" />
5723: </form>
5724: </div>
5725: END
5726: }
5727: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 5728: }
1.363 ehlerst 5729: foreach my $field (keys(%orderhash)){
1.390 tempelho 5730: if($field ne '00'){
1.422 onken 5731: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 5732: $active = 'style="display: none;float:left"';
1.422 onken 5733: }elsif($activetab eq $field){
1.458 raeburn 5734: $active = 'style="display:block;float:left"';
1.422 onken 5735: }
5736: $form .= '<div id="'.$field.$tid.'"'
5737: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 5738: .'</div>'."\n";
1.363 ehlerst 5739: }
5740: }
1.484 raeburn 5741: unless ($env{'form.docslog'}) {
5742: $form .= '</div></div>'."\n";
5743: }
1.329 droeschl 5744: return $form;
5745: }
5746:
5747: sub editing_js {
1.472 raeburn 5748: my ($udom,$uname,$supplementalflag) = @_;
1.329 droeschl 5749: my %lt = &Apache::lonlocal::texthash(
5750: p_mnf => 'Name of New Folder',
5751: t_mnf => 'New Folder',
5752: p_mnp => 'Name of New Page',
5753: t_mnp => 'New Page',
1.451 www 5754: p_mxu => 'Title for the External Score',
1.349 biermanm 5755: p_msp => 'Name of Simple Course Page',
1.329 droeschl 5756: p_msb => 'Title for the Problem',
5757: p_mdb => 'Title for the Drop Box',
1.336 schafran 5758: p_mbb => 'Title for the Discussion Board',
1.534 raeburn 5759: p_mwp => 'Title for Web Page',
1.348 weissno 5760: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 5761: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 5762: p_mab_alrt1 => 'Not a valid user:domain',
5763: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
5764: p_chn => 'New Title',
5765: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
5766: p_rmr2a => 'Remove[_99]',
5767: p_rmr2b => '?[_99]',
1.542 raeburn 5768: p_rmr3a => 'Remove those [_2]',
5769: p_rmr3b => 'items?[_2]',
1.329 droeschl 5770: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
5771: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
5772: p_ctr2a => 'Cut[_98]',
1.478 raeburn 5773: p_ctr2b => '?[_98]',
1.542 raeburn 5774: p_ctr3a => 'Cut those[_2]',
5775: p_ctr3b => 'items?[_2]',
1.478 raeburn 5776: rpck => 'Enter number to pick (e.g., 3)',
1.501 raeburn 5777: imsfile => 'You must choose an IMS package for import',
5778: imscms => 'You must select which Course Management System was the source of the IMS package',
5779: invurl => 'Invalid URL',
5780: titbl => 'Title is blank',
1.538 raeburn 5781: more => '(More ...)',
5782: less => '(Less ...)',
1.543 raeburn 5783: noor => 'No actions selected or changes to settings specified.',
5784: noch => 'No changes to settings specified.',
5785: noac => 'No actions selected.',
1.329 droeschl 5786: );
5787:
1.433 raeburn 5788: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 5789: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
5790: my $main_container_page;
1.519 raeburn 5791: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
5792: $main_container_page = 1;
1.434 raeburn 5793: }
1.538 raeburn 5794: my $toplevelmain =
1.548 raeburn 5795: &escape(&mt('Main Content').':::::');
1.446 www 5796: my $toplevelsupp = &supplemental_base();
1.433 raeburn 5797:
1.525 raeburn 5798: my $backtourl;
1.530 raeburn 5799: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
5800: my $caller = $1;
1.525 raeburn 5801: if ($caller =~ /^supplemental/) {
5802: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
5803: } else {
5804: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
5805: $res = &Apache::lonnet::clutter($res);
5806: if (&Apache::lonnet::is_on_map($res)) {
5807: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='.
5808: &HTML::Entities::encode($caller,'<>&"');
1.544 raeburn 5809: } else {
5810: $backtourl = '/adm/navmaps';
1.525 raeburn 5811: }
5812: }
5813: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
5814: $backtourl = '/adm/menu';
5815: } elsif ($supplementalflag) {
1.472 raeburn 5816: $backtourl = '/adm/supplemental';
1.525 raeburn 5817: } else {
5818: $backtourl = '/adm/navmaps';
1.472 raeburn 5819: }
5820:
1.519 raeburn 5821: my $fieldsets = "'ext','doc'";
5822: unless ($main_container_page) {
5823: $fieldsets .=",'ims'";
5824: }
1.501 raeburn 5825: if ($supplementalflag) {
5826: $fieldsets = "'suppext','suppdoc'";
5827: }
5828:
1.329 droeschl 5829: return <<ENDNEWSCRIPT;
5830: function makenewfolder(targetform,folderseq) {
5831: var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
5832: if (foldername) {
5833: targetform.importdetail.value=escape(foldername)+"="+folderseq;
5834: targetform.submit();
5835: }
5836: }
5837:
5838: function makenewpage(targetform,folderseq) {
5839: var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
5840: if (pagename) {
5841: targetform.importdetail.value=escape(pagename)+"="+folderseq;
5842: targetform.submit();
5843: }
5844: }
5845:
5846: function makeexamupload() {
5847: var title=prompt('$lt{"p_mxu"}');
1.344 bisitz 5848: if (title) {
1.329 droeschl 5849: this.document.forms.newexamupload.importdetail.value=
5850: escape(title)+'=/res/lib/templates/examupload.problem';
5851: this.document.forms.newexamupload.submit();
5852: }
5853: }
5854:
5855: function makesmppage() {
5856: var title=prompt('$lt{"p_msp"}');
1.344 bisitz 5857: if (title) {
1.329 droeschl 5858: this.document.forms.newsmppg.importdetail.value=
1.533 raeburn 5859: escape(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 5860: this.document.forms.newsmppg.submit();
5861: }
5862: }
5863:
1.534 raeburn 5864: function makewebpage(type) {
5865: var title=prompt('$lt{"p_mwp"}');
5866: var formname;
5867: if (type == 'supp') {
5868: formname = this.document.forms.supwebpage;
5869: } else {
5870: formname = this.document.forms.newwebpage;
5871: }
5872: if (title) {
5873: var webpage = formname.importdetail.value;
5874: formname.importdetail.value = escape(title)+'='+webpage;
5875: formname.submit();
5876: }
5877: }
5878:
1.329 droeschl 5879: function makesmpproblem() {
5880: var title=prompt('$lt{"p_msb"}');
1.344 bisitz 5881: if (title) {
1.329 droeschl 5882: this.document.forms.newsmpproblem.importdetail.value=
5883: escape(title)+'=/res/lib/templates/simpleproblem.problem';
5884: this.document.forms.newsmpproblem.submit();
5885: }
5886: }
5887:
5888: function makedropbox() {
5889: var title=prompt('$lt{"p_mdb"}');
1.344 bisitz 5890: if (title) {
1.329 droeschl 5891: this.document.forms.newdropbox.importdetail.value=
5892: escape(title)+'=/res/lib/templates/DropBox.problem';
5893: this.document.forms.newdropbox.submit();
5894: }
5895: }
5896:
5897: function makebulboard() {
5898: var title=prompt('$lt{"p_mbb"}');
5899: if (title) {
5900: this.document.forms.newbul.importdetail.value=
1.533 raeburn 5901: escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 5902: this.document.forms.newbul.submit();
5903: }
5904: }
5905:
5906: function makeabout() {
5907: var user=prompt("$lt{'p_mab'}");
5908: if (user) {
5909: var comp=new Array();
5910: comp=user.split(':');
5911: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
5912: if ((comp[0]) && (comp[1])) {
5913: this.document.forms.newaboutsomeone.importdetail.value=
5914: '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.335 ehlerst 5915: this.document.forms.newaboutsomeone.submit();
5916: } else {
5917: alert("$lt{'p_mab_alrt1'}");
1.329 droeschl 5918: }
1.335 ehlerst 5919: } else {
5920: alert("$lt{'p_mab_alrt2'}");
5921: }
5922: }
1.329 droeschl 5923: }
5924:
1.501 raeburn 5925: function toggleUpload(caller) {
5926: var blocks = Array($fieldsets);
5927: for (var i=0; i<blocks.length; i++) {
5928: var disp = 'none';
5929: if (caller == blocks[i]) {
5930: var curr = document.getElementById('upload'+caller+'form').style.display;
5931: if (curr == 'none') {
5932: disp='block';
5933: }
5934: }
5935: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
5936: }
1.502 raeburn 5937: resize_scrollbox('contentscroll','1','1');
5938: return;
5939: }
5940:
1.514 raeburn 5941: function toggleMap(caller) {
1.502 raeburn 5942: var disp = 'none';
1.510 raeburn 5943: if (document.getElementById('importmapform')) {
1.514 raeburn 5944: if (caller == 'map') {
5945: var curr = document.getElementById('importmapform').style.display;
5946: if (curr == 'none') {
5947: disp='block';
5948: }
1.510 raeburn 5949: }
5950: document.getElementById('importmapform').style.display=disp;
5951: resize_scrollbox('contentscroll','1','1');
1.502 raeburn 5952: }
1.501 raeburn 5953: return;
1.329 droeschl 5954: }
5955:
1.501 raeburn 5956: function makeims(imsform) {
5957: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
5958: alert("$lt{'imsfile'}");
5959: return;
5960: }
5961: if (imsform.source.selectedIndex == 0) {
5962: alert("$lt{'imscms'}");
5963: return;
5964: }
5965: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
5966: imsform.submit();
5967: }
5968:
1.519 raeburn 5969: function changename(folderpath,index,oldtitle) {
1.335 ehlerst 5970: var title=prompt('$lt{"p_chn"}',oldtitle);
5971: if (title) {
1.538 raeburn 5972: this.document.forms.renameform.markcopy.value='';
1.335 ehlerst 5973: this.document.forms.renameform.title.value=title;
5974: this.document.forms.renameform.cmd.value='rename_'+index;
1.519 raeburn 5975: this.document.forms.renameform.folderpath.value=folderpath;
1.335 ehlerst 5976: this.document.forms.renameform.submit();
5977: }
1.329 droeschl 5978: }
5979:
1.478 raeburn 5980: function updatePick(targetform,index,caller) {
1.537 raeburn 5981: var pickitem;
5982: var picknumitem;
5983: var picknumtext;
5984: if (index == 'all') {
5985: pickitem = document.getElementById('randompickall');
5986: picknumitem = document.getElementById('rpicknumall');
5987: picknumtext = document.getElementById('rpicktextall');
5988: } else {
5989: pickitem = document.getElementById('randompick_'+index);
5990: picknumitem = document.getElementById('rpicknum_'+index);
5991: picknumtext = document.getElementById('randompicknum_'+index);
5992: }
1.478 raeburn 5993: if (pickitem.checked) {
5994: var picknum=prompt('$lt{"rpck"}',picknumitem.value);
5995: if (picknum == '' || picknum == null) {
5996: if (caller == 'check') {
5997: pickitem.checked=false;
1.537 raeburn 5998: if (index == 'all') {
5999: picknumtext.innerHTML = '';
6000: if (caller == 'link') {
6001: propagateState(targetform,'rpicknum');
6002: }
6003: } else {
1.538 raeburn 6004: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6005: }
1.478 raeburn 6006: }
6007: } else {
6008: picknum.toString();
6009: var regexdigit=/^\\d+\$/;
6010: if (regexdigit.test(picknum)) {
6011: picknumitem.value = picknum;
1.537 raeburn 6012: if (index == 'all') {
1.538 raeburn 6013: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.537 raeburn 6014: if (caller == 'link') {
6015: propagateState(targetform,'rpicknum');
6016: }
6017: } else {
6018: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.538 raeburn 6019: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6020: }
1.478 raeburn 6021: } else {
6022: if (caller == 'check') {
1.537 raeburn 6023: if (index == 'all') {
6024: picknumtext.innerHTML = '';
6025: if (caller == 'link') {
6026: propagateState(targetform,'rpicknum');
6027: }
6028: } else {
6029: pickitem.checked=false;
1.538 raeburn 6030: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6031: }
1.478 raeburn 6032: }
6033: return;
6034: }
6035: }
6036: } else {
1.537 raeburn 6037: picknumitem.value = '';
6038: picknumtext.innerHTML = '';
6039: if (index == 'all') {
6040: if (caller == 'link') {
6041: propagateState(targetform,'rpicknum');
6042: }
6043: } else {
1.538 raeburn 6044: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6045: }
6046: }
6047: }
6048:
6049: function propagateState(form,param) {
6050: if (document.getElementById(param+'all')) {
6051: var setcheck = 0;
6052: var rpick = 0;
6053: if (param == 'rpicknum') {
6054: if (document.getElementById('randompickall')) {
6055: if (document.getElementById('randompickall').checked) {
6056: if (document.getElementById('rpicknumall')) {
6057: rpick = document.getElementById('rpicknumall').value;
6058: }
6059: }
6060: }
6061: } else {
6062: if (document.getElementById(param+'all').checked) {
6063: setcheck = 1;
6064: }
6065: }
1.538 raeburn 6066: var allidxlist;
6067: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6068: if (document.getElementById('all'+param+'idx')) {
6069: allidxlist = document.getElementById('all'+param+'idx').value;
6070: }
6071: var actions = new Array ('remove','cut','copy');
6072: for (var i=0; i<actions.length; i++) {
6073: if (actions[i] != param) {
6074: if (document.getElementById(actions[i]+'all')) {
6075: document.getElementById(actions[i]+'all').checked = false;
6076: }
6077: }
6078: }
6079: }
1.537 raeburn 6080: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.538 raeburn 6081: allidxlist = form.allidx.value;
6082: }
6083: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
6084: allidxlist = form.allmapidx.value;
6085: }
6086: if ((allidxlist != '') && (allidxlist != null)) {
6087: var allidxs = allidxlist.split(',');
6088: if (allidxs.length > 1) {
6089: for (var i=0; i<allidxs.length; i++) {
6090: if (document.getElementById(param+'_'+allidxs[i])) {
6091: if (param == 'rpicknum') {
6092: if (document.getElementById('randompick_'+allidxs[i])) {
6093: if (document.getElementById('randompick_'+allidxs[i]).checked) {
6094: document.getElementById(param+'_'+allidxs[i]).value = rpick;
6095: if (rpick > 0) {
6096: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
6097: } else {
6098: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6099: }
6100: }
6101: }
6102: } else {
1.537 raeburn 6103: if (setcheck == 1) {
6104: document.getElementById(param+'_'+allidxs[i]).checked = true;
6105: } else {
6106: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.538 raeburn 6107: if (param == 'randompick') {
6108: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6109: }
1.537 raeburn 6110: }
6111: }
6112: }
6113: }
1.538 raeburn 6114: if (setcheck == 1) {
6115: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6116: var actions = new Array('copy','cut','remove');
6117: for (var i=0; i<actions.length; i++) {
6118: var otheractions;
6119: var otheridxs;
6120: if (actions[i] === param) {
6121: continue;
6122: } else {
6123: if (document.getElementById('all'+actions[i]+'idx')) {
6124: otheractions = document.getElementById('all'+actions[i]+'idx').value;
6125: otheridxs = otheractions.split(',');
6126: if (otheridxs.length > 1) {
6127: for (var j=0; j<otheridxs.length; j++) {
6128: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
6129: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
6130: }
1.537 raeburn 6131: }
6132: }
6133: }
1.538 raeburn 6134: }
6135: }
6136: }
6137: }
6138: }
6139: }
6140: }
6141: return;
6142: }
6143:
6144: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder) {
1.539 raeburn 6145: var dosettings;
6146: var doaction;
1.538 raeburn 6147: var control = document.togglemultsettings;
6148: if (context == 'actions') {
6149: control = document.togglemultactions;
1.539 raeburn 6150: doaction = 1;
6151: } else {
6152: dosettings = 1;
1.538 raeburn 6153: }
1.539 raeburn 6154: if (control) {
6155: if (control.showmultpick.length) {
6156: for (var i=0; i<control.showmultpick.length; i++) {
6157: if (control.showmultpick[i].checked) {
6158: if (control.showmultpick[i].value == 1) {
6159: if (context == 'settings') {
6160: dosettings = 0;
6161: } else {
6162: doaction = 0;
1.538 raeburn 6163: }
6164: }
6165: }
1.537 raeburn 6166: }
6167: }
1.539 raeburn 6168: }
6169: if (context == 'settings') {
6170: if (dosettings == 1) {
1.538 raeburn 6171: targetform.changeparms.value=param;
6172: targetform.submit();
6173: }
1.537 raeburn 6174: }
1.539 raeburn 6175: if (context == 'actions') {
6176: if (doaction == 1) {
6177: targetform.cmd.value=param+'_'+index;
6178: targetform.folderpath.value=folderpath;
6179: targetform.markcopy.value=idx+':'+param;
6180: targetform.copyfolder.value=folder+'.'+container;
6181: if (param == 'remove') {
6182: if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
6183: targetform.markcopy.value='';
6184: targetform.copyfolder.value='';
6185: targetform.submit();
6186: }
6187: }
6188: if (param == 'cut') {
6189: if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
6190: targetform.submit();
6191: return;
6192: }
6193: }
6194: if (param == 'copy') {
6195: targetform.submit();
6196: return;
6197: }
6198: targetform.markcopy.value='';
6199: targetform.copyfolder.value='';
6200: targetform.cmd.value='';
6201: targetform.folderpath.value='';
6202: return;
6203: } else {
6204: if (document.getElementById(param+'_'+idx)) {
6205: item = document.getElementById(param+'_'+idx);
6206: if (item.type == 'checkbox') {
6207: if (item.checked) {
6208: item.checked = false;
6209: } else {
6210: item.checked = true;
6211: singleCheck(item,idx,param);
6212: }
6213: }
6214: }
6215: }
6216: }
1.537 raeburn 6217: return;
6218: }
6219:
1.538 raeburn 6220: function singleCheck(caller,idx,action) {
6221: actions = new Array('cut','copy','remove');
6222: if (caller.checked) {
6223: for (var i=0; i<actions.length; i++) {
6224: if (actions[i] != action) {
6225: if (document.getElementById(actions[i]+'_'+idx)) {
6226: if (document.getElementById(actions[i]+'_'+idx).checked) {
6227: document.getElementById(actions[i]+'_'+idx).checked = false;
6228: }
1.537 raeburn 6229: }
6230: }
6231: }
1.478 raeburn 6232: }
1.537 raeburn 6233: return;
1.478 raeburn 6234: }
6235:
1.334 muellerd 6236: function unselectInactive(nav) {
1.335 ehlerst 6237: currentNav = document.getElementById(nav);
6238: currentLis = currentNav.getElementsByTagName('LI');
6239: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 6240: if (currentLis[i].className == 'goback') {
6241: currentLis[i].className = 'goback';
6242: } else {
6243: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 6244: currentLis[i].className = 'right';
1.472 raeburn 6245: } else {
1.374 tempelho 6246: currentLis[i].className = 'i';
1.472 raeburn 6247: }
6248: }
1.335 ehlerst 6249: }
1.332 tempelho 6250: }
6251:
1.334 muellerd 6252: function hideAll(current, nav, data) {
1.335 ehlerst 6253: unselectInactive(nav);
1.570 raeburn 6254: if (current) {
6255: if (current.className == 'right'){
6256: current.className = 'right active'
6257: } else {
6258: current.className = 'active';
6259: }
1.374 tempelho 6260: }
1.335 ehlerst 6261: currentData = document.getElementById(data);
6262: currentDivs = currentData.getElementsByTagName('DIV');
6263: for (i = 0; i < currentDivs.length; i++) {
6264: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 6265: currentDivs[i].style.display = 'none';
1.330 tempelho 6266: }
6267: }
1.335 ehlerst 6268: }
1.330 tempelho 6269:
1.374 tempelho 6270: function openTabs(pageId) {
6271: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 6272: if(tabnav.length > 2 ){
1.389 tempelho 6273: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 6274: currentLis = currentNav.getElementsByTagName('LI');
6275: for(i = 0; i< currentLis.length; i++){
6276: if(currentLis[i].className == 'active') {
1.375 tempelho 6277: funcString = currentLis[i].onclick.toString();
6278: tab = funcString.split('"');
1.420 onken 6279: if(tab.length < 2) {
6280: tab = funcString.split("'");
6281: }
1.375 tempelho 6282: currentData = document.getElementById(tab[1]);
6283: currentData.style.display = 'block';
1.374 tempelho 6284: }
6285: }
6286: }
6287: }
6288:
1.334 muellerd 6289: function showPage(current, pageId, nav, data) {
1.570 raeburn 6290: currstate = current.className;
1.334 muellerd 6291: hideAll(current, nav, data);
1.375 tempelho 6292: openTabs(pageId);
1.334 muellerd 6293: unselectInactive(nav);
1.570 raeburn 6294: if ((currstate == 'active') || (currstate == 'right active')) {
6295: if (currstate == 'active') {
6296: current.className = '';
6297: } else {
6298: current.className = 'right';
6299: }
6300: activeTab = '';
6301: toggleUpload();
6302: toggleMap();
6303: resize_scrollbox('contentscroll','1','0');
6304: return;
6305: } else {
6306: current.className = 'active';
6307: }
1.330 tempelho 6308: currentData = document.getElementById(pageId);
6309: currentData.style.display = 'block';
1.458 raeburn 6310: activeTab = pageId;
1.501 raeburn 6311: toggleUpload();
1.503 raeburn 6312: toggleMap();
1.433 raeburn 6313: if (nav == 'mainnav') {
6314: var storedpath = "$docs_folderpath";
1.434 raeburn 6315: var storedpage = "$main_container_page";
1.433 raeburn 6316: var reg = new RegExp("^supplemental");
6317: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 6318: if (storedpage == 1) {
6319: document.simpleedit.folderpath.value = '';
6320: document.uploaddocument.folderpath.value = '';
6321: } else {
6322: if (reg.test(storedpath)) {
6323: document.simpleedit.folderpath.value = '$toplevelmain';
6324: document.uploaddocument.folderpath.value = '$toplevelmain';
6325: document.newext.folderpath.value = '$toplevelmain';
6326: } else {
6327: document.simpleedit.folderpath.value = storedpath;
6328: document.uploaddocument.folderpath.value = storedpath;
6329: document.newext.folderpath.value = storedpath;
6330: }
1.433 raeburn 6331: }
6332: } else {
1.434 raeburn 6333: if (reg.test(storedpath)) {
6334: document.simpleedit.folderpath.value = storedpath;
6335: document.supuploaddocument.folderpath.value = storedpath;
6336: document.supnewext.folderpath.value = storedpath;
6337: } else {
1.433 raeburn 6338: document.simpleedit.folderpath.value = '$toplevelsupp';
6339: document.supuploaddocument.folderpath.value = '$toplevelsupp';
6340: document.supnewext.folderpath.value = '$toplevelsupp';
6341: }
6342: }
6343: }
1.485 raeburn 6344: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 6345: return false;
6346: }
1.329 droeschl 6347:
1.472 raeburn 6348: function toContents(jumpto) {
6349: var newurl = '$backtourl';
1.525 raeburn 6350: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 6351: newurl = newurl+'?postdata='+jumpto;
6352: }
6353: location.href=newurl;
6354: }
6355:
1.538 raeburn 6356: function togglePick(caller,value) {
6357: var disp = 'none';
6358: if (document.getElementById('multi'+caller)) {
6359: var curr = document.getElementById('multi'+caller).style.display;
6360: if (value == 1) {
6361: disp='block';
6362: }
6363: if (curr == disp) {
6364: return;
6365: }
6366: document.getElementById('multi'+caller).style.display=disp;
6367: if (value == 1) {
6368: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$lt{'more'}</a>';
6369: } else {
6370: document.getElementById('more'+caller).innerHTML = '';
6371: }
6372: if (caller == 'actions') {
6373: setClass(value);
6374: setBoxes(value);
6375: }
6376: }
6377: var showButton = multiSettings();
6378: if (showButton != 1) {
6379: showButton = multiActions();
6380: }
6381: if (document.getElementById('multisave')) {
6382: if (showButton == 1) {
6383: document.getElementById('multisave').style.display='block';
6384: } else {
6385: document.getElementById('multisave').style.display='none';
6386: }
6387: }
6388: resize_scrollbox('contentscroll','1','1');
6389: return;
6390: }
6391:
6392: function toggleCheckUncheck(caller,more) {
6393: if (more == 1) {
6394: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$lt{'less'}</a>';
6395: document.getElementById('allfields'+caller).style.display='block';
6396: } else {
6397: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$lt{'more'}</a>';
6398: document.getElementById('allfields'+caller).style.display='none';
6399: }
6400: resize_scrollbox('contentscroll','1','1');
6401: }
6402:
6403: function multiSettings() {
6404: var inuse = 0;
6405: var settingsform = document.togglemultsettings;
6406: if (settingsform.showmultpick.length > 1) {
6407: for (var i=0; i<settingsform.showmultpick.length; i++) {
6408: if (settingsform.showmultpick[i].checked) {
6409: if (settingsform.showmultpick[i].value == 1) {
6410: inuse = 1;
6411: }
6412: }
6413: }
6414: }
6415: return inuse;
6416: }
6417:
6418: function multiActions() {
6419: var inuse = 0;
6420: var actionsform = document.togglemultactions;
6421: if (actionsform.showmultpick.length > 1) {
6422: for (var i=0; i<actionsform.showmultpick.length; i++) {
6423: if (actionsform.showmultpick[i].checked) {
6424: if (actionsform.showmultpick[i].value == 1) {
6425: inuse = 1;
6426: }
6427: }
6428: }
6429: }
6430: return inuse;
6431: }
6432:
6433: function checkSubmits() {
6434: var numchanges = 0;
6435: var form = document.saveactions;
6436: var doactions = multiActions();
1.542 raeburn 6437: var cutwarnings = 0;
6438: var remwarnings = 0;
1.538 raeburn 6439: if (doactions == 1) {
6440: var remidxlist = document.cumulativeactions.allremoveidx.value;
6441: if ((remidxlist != '') && (remidxlist != null)) {
6442: var remidxs = remidxlist.split(',');
6443: for (var i=0; i<remidxs.length; i++) {
6444: if (document.getElementById('remove_'+remidxs[i])) {
6445: if (document.getElementById('remove_'+remidxs[i]).checked) {
6446: form.multiremove.value += remidxs[i]+',';
6447: numchanges ++;
1.542 raeburn 6448: if (document.getElementById('skip_remove_'+remidxs[i])) {
6449: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
6450: remwarnings ++;
6451: }
6452: }
1.537 raeburn 6453: }
6454: }
1.538 raeburn 6455: }
6456: }
6457: var cutidxlist = document.cumulativeactions.allcutidx.value;
6458: if ((cutidxlist != '') && (cutidxlist != null)) {
6459: var cutidxs = cutidxlist.split(',');
6460: for (var i=0; i<cutidxs.length; i++) {
6461: if (document.getElementById('cut_'+cutidxs[i])) {
6462: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
6463: form.multicut.value += cutidxs[i]+',';
6464: numchanges ++;
1.542 raeburn 6465: if (document.getElementById('skip_cut_'+cutidxs[i])) {
6466: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
6467: cutwarnings ++;
6468: }
6469: }
1.537 raeburn 6470: }
6471: }
6472: }
6473: }
1.538 raeburn 6474: var copyidxlist = document.cumulativeactions.allcopyidx.value;
6475: if ((copyidxlist != '') && (copyidxlist != null)) {
6476: var copyidxs = copyidxlist.split(',');
6477: for (var i=0; i<copyidxs.length; i++) {
6478: if (document.getElementById('copy_'+copyidxs[i])) {
6479: if (document.getElementById('copy_'+copyidxs[i]).checked) {
6480: form.multicopy.value += copyidxs[i]+',';
6481: numchanges ++;
6482: }
6483: }
6484: }
6485: }
6486: if (numchanges > 0) {
6487: form.multichange.value = numchanges;
6488: }
1.537 raeburn 6489: }
1.538 raeburn 6490: var dosettings = multiSettings();
1.543 raeburn 6491: var haschanges = 0;
1.538 raeburn 6492: if (dosettings == 1) {
6493: form.allencrypturl.value = '';
6494: form.allhiddenresource.value = '';
1.543 raeburn 6495: form.changeparms.value = 'all';
6496: var patt=new RegExp(",\$");
1.538 raeburn 6497: var allidxlist = document.cumulativesettings.allidx.value;
6498: if ((allidxlist != '') && (allidxlist != null)) {
6499: var allidxs = allidxlist.split(',');
6500: if (allidxs.length > 1) {
6501: for (var i=0; i<allidxs.length; i++) {
6502: if (document.getElementById('hiddenresource_'+allidxs[i])) {
6503: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
6504: form.allhiddenresource.value += allidxs[i]+',';
6505: }
6506: }
6507: if (document.getElementById('encrypturl_'+allidxs[i])) {
6508: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
6509: form.allencrypturl.value += allidxs[i]+',';
6510: }
6511: }
6512: }
1.543 raeburn 6513: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
6514: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
1.537 raeburn 6515: }
1.538 raeburn 6516: }
6517: form.allrandompick.value = '';
6518: form.allrandomorder.value = '';
6519: var allmapidxlist = document.cumulativesettings.allmapidx.value;
6520: if ((allmapidxlist != '') && (allmapidxlist != null)) {
6521: var allmapidxs = allmapidxlist.split(',');
6522: for (var i=0; i<allmapidxs.length; i++) {
6523: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
6524: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
6525: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
6526: if ((randompick.checked) && (rpicknum.value != '')) {
6527: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
6528: }
6529: if (randorder.checked) {
6530: form.allrandomorder.value += allmapidxs[i]+',';
6531: }
1.537 raeburn 6532: }
1.543 raeburn 6533: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
6534: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
6535: }
6536: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
6537: haschanges = 1;
6538: }
6539: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
6540: haschanges = 1;
6541: }
6542: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
6543: haschanges = 1;
6544: }
6545: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
6546: haschanges = 1;
1.537 raeburn 6547: }
6548: }
1.543 raeburn 6549: if (doactions == 1) {
1.542 raeburn 6550: if (numchanges > 0) {
6551: if ((cutwarnings > 0) || (remwarnings > 0)) {
6552: if (remwarnings > 0) {
6553: if (!confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr3a"} '+remwarnings+' $lt{"p_rmr3b"}')) {
6554: return false;
6555: }
6556: }
6557: if (cutwarnings > 0) {
6558: if (!confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr3a"} '+cutwarnings+' $lt{"p_ctr3b"}')) {
6559: return false;
6560: }
6561: }
6562: }
6563: form.submit();
6564: return true;
1.543 raeburn 6565: }
6566: }
6567: if (dosettings == 1) {
6568: if (haschanges == 1) {
1.542 raeburn 6569: form.submit();
6570: return true;
6571: }
1.543 raeburn 6572: }
6573: if ((dosettings == 1) && (doactions == 1)) {
6574: alert("$lt{'noor'}");
6575: } else {
6576: if (dosettings == 1) {
6577: alert("$lt{'noch'}");
6578: } else {
6579: alert("$lt{'noac'}");
6580: }
6581: }
1.538 raeburn 6582: return false;
6583: }
6584:
6585: function setClass(value) {
6586: var cutclass = 'LC_docs_cut';
6587: var copyclass = 'LC_docs_copy';
6588: var removeclass = 'LC_docs_remove';
6589: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
6590: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
6591: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
6592: var links = document.getElementsByTagName('a');
6593: for (var i=0; i<links.length; i++) {
6594: var classes = links[i].className;
6595: if (cutreg.test(classes)) {
6596: links[i].className = cutclass;
6597: if (value == 1) {
6598: links[i].className += " LC_menubuttons_link";
6599: }
6600: } else {
6601: if (copyreg.test(classes)) {
6602: links[i].className = copyclass;
6603: if (value == 1) {
6604: links[i].className += " LC_menubuttons_link";
6605: }
6606: } else {
6607: if (removereg.test(classes)) {
6608: links[i].className = removeclass;
6609: if (value == 1) {
6610: links[i].className += " LC_menubuttons_link";
6611: }
6612: }
6613: }
6614: }
6615: }
6616: return;
1.537 raeburn 6617: }
6618:
1.538 raeburn 6619: function setBoxes(value) {
6620: var remidxlist = document.cumulativeactions.allremoveidx.value;
6621: if ((remidxlist != '') && (remidxlist != null)) {
6622: var remidxs = remidxlist.split(',');
6623: for (var i=0; i<remidxs.length; i++) {
6624: if (document.getElementById('remove_'+remidxs[i])) {
6625: var item = document.getElementById('remove_'+remidxs[i]);
6626: if (value == 1) {
6627: item.className = 'LC_docs_remove';
6628: } else {
6629: item.className = 'LC_hidden';
6630: }
6631: }
6632: }
6633: }
6634: var cutidxlist = document.cumulativeactions.allcutidx.value;
6635: if ((cutidxlist != '') && (cutidxlist != null)) {
6636: var cutidxs = cutidxlist.split(',');
6637: for (var i=0; i<cutidxs.length; i++) {
6638: if (document.getElementById('cut_'+cutidxs[i])) {
6639: var item = document.getElementById('cut_'+cutidxs[i]);
6640: if (value == 1) {
6641: item.className = 'LC_docs_cut';
6642: } else {
6643: item.className = 'LC_hidden';
6644: }
6645: }
1.537 raeburn 6646: }
6647: }
1.538 raeburn 6648: var copyidxlist = document.cumulativeactions.allcopyidx.value;
6649: if ((copyidxlist != '') && (copyidxlist != null)) {
6650: var copyidxs = copyidxlist.split(',');
6651: for (var i=0; i<copyidxs.length; i++) {
6652: if (document.getElementById('copy_'+copyidxs[i])) {
6653: var item = document.getElementById('copy_'+copyidxs[i]);
6654: if (value == 1) {
6655: item.className = 'LC_docs_copy';
6656: } else {
6657: item.className = 'LC_hidden';
6658: }
6659: }
1.537 raeburn 6660: }
6661: }
6662: return;
6663: }
6664:
1.329 droeschl 6665: ENDNEWSCRIPT
6666: }
1.457 raeburn 6667:
1.483 raeburn 6668: sub history_tab_js {
6669: return <<"ENDHIST";
6670: function toggleHistoryDisp(choice) {
6671: document.docslogform.docslog.value = choice;
6672: document.docslogform.submit();
6673: return;
6674: }
6675:
6676: ENDHIST
6677: }
6678:
1.484 raeburn 6679: sub inject_data_js {
6680: return <<ENDINJECT;
6681:
6682: function injectData(current, hiddenField, name, value) {
6683: currentElement = document.getElementById(hiddenField);
6684: currentElement.name = name;
6685: currentElement.value = value;
6686: current.submit();
6687: }
6688:
6689: ENDINJECT
6690: }
6691:
6692: sub dump_switchserver_js {
6693: my @hosts = @_;
6694: my %lt = &Apache::lonlocal::texthash(
1.574 raeburn 6695: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 6696: swit => 'Switch server?',
1.568 raeburn 6697: duco => 'Copying Content to Authoring Space',
1.484 raeburn 6698: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
6699: chos => 'Choose server',
6700: );
6701: my $role = $env{'request.role'};
6702: my $js = <<"ENDSWJS";
6703: <script type="text/javascript">
6704: function write_switchserver() {
6705: var server;
6706: if (document.setserver.posshosts.length > 0) {
6707: for (var i=0; i<document.setserver.posshosts.length; i++) {
6708: if (document.setserver.posshosts[i].checked) {
6709: server = document.setserver.posshosts[i].value;
6710: }
6711: }
6712: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
6713: }
6714: window.close();
6715: }
6716: </script>
6717:
6718: ENDSWJS
6719:
6720: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
6721: {'only_body' => 1,
6722: 'js_ready' => 1,});
6723: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
6724:
6725: my $hostpicker;
6726: my $count = 0;
6727: foreach my $host (sort(@hosts)) {
6728: my $checked;
6729: if ($count == 0) {
6730: $checked = ' checked="checked"';
6731: }
6732: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
6733: $host.'"'.$checked.' />'.$host.'</label> ';
6734: $count++;
6735: }
6736:
6737: return <<"ENDSWITCHJS";
6738:
6739: function dump_needs_switchserver(url) {
6740: if (url!='' && url!= null) {
6741: if (confirm("$lt{'dump'}\\n$lt{'swit'}")) {
6742: go(url);
6743: }
6744: }
6745: return;
6746: }
6747:
6748: function choose_switchserver_window() {
6749: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
6750: newWindow.document.open();
6751: newWindow.document.writeln('$startpage');
6752: newWindow.document.write('<h3>$lt{'duco'}<\\/h3>\\n'+
6753: '<p>$lt{'yone'}<\\/p>\\n'+
6754: '<div class="LC_left_float"><fieldset><legend>$lt{'chos'}<\\/legend>\\n'+
6755: '<form name="setserver" method="post" action="" \\/>\\n'+
6756: '$hostpicker\\n'+
6757: '<br \\/><br \\/>\\n'+
6758: '<input type="button" name="makeswitch" value="$lt{'swit'}" '+
6759: 'onclick="write_switchserver();" \\/>\\n'+
6760: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
6761: newWindow.document.writeln('$endpage');
6762: newWindow.document.close();
6763: newWindow.focus();
6764: }
6765:
6766: ENDSWITCHJS
6767: }
6768:
6769: sub makedocslogform {
6770: my ($formelems,$docslog) = @_;
6771: return <<"LOGSFORM";
6772: <form action="/adm/coursedocs" method="post" name="docslogform">
6773: <input type="hidden" name="docslog" value="$docslog" />
6774: $formelems
6775: </form>
6776: LOGSFORM
6777: }
6778:
6779: sub makesimpleeditform {
6780: my ($formelems) = @_;
6781: return <<"SIMPFORM";
6782: <form name="simpleedit" method="post" action="/adm/coursedocs">
6783: <input type="hidden" name="importdetail" value="" />
6784: $formelems
6785: </form>
6786: SIMPFORM
6787: }
6788:
1.329 droeschl 6789: 1;
6790: __END__
6791:
6792:
6793: =head1 NAME
6794:
6795: Apache::londocs.pm
6796:
6797: =head1 SYNOPSIS
6798:
6799: This is part of the LearningOnline Network with CAPA project
6800: described at http://www.lon-capa.org.
6801:
6802: =head1 SUBROUTINES
6803:
6804: =over
6805:
6806: =item %help=()
6807:
6808: Available help topics
6809:
6810: =item mapread()
6811:
1.344 bisitz 6812: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 6813: @order and @resources, determines status
6814: sets @order - pointer to resources in right order
6815: sets @resources - array with the resources with correct idx
6816:
6817: =item authorhosts()
6818:
6819: Return hash with valid author names
6820:
6821: =item clean()
6822:
6823: =item dumpcourse()
6824:
6825: Actually dump course
6826:
6827: =item group_import()
6828:
6829: Imports the given (name, url) resources into the course
6830: coursenum, coursedom, and folder must precede the list
6831:
6832: =item breadcrumbs()
6833:
6834: =item log_docs()
6835:
6836: =item docs_change_log()
6837:
6838: =item update_paste_buffer()
6839:
6840: =item print_paste_buffer()
6841:
6842: =item do_paste_from_buffer()
6843:
1.538 raeburn 6844: =item do_buffer_empty()
6845:
6846: =item clear_from_buffer()
6847:
1.492 raeburn 6848: =item get_newmap_url()
6849:
6850: =item dbcopy()
6851:
6852: =item uniqueness_check()
6853:
6854: =item contained_map_check()
6855:
6856: =item url_paste_fixups()
6857:
6858: =item apply_fixups()
6859:
6860: =item copy_dependencies()
6861:
1.329 droeschl 6862: =item update_parameter()
6863:
6864: =item handle_edit_cmd()
6865:
6866: =item editor()
6867:
6868: =item process_file_upload()
6869:
6870: =item process_secondary_uploads()
6871:
6872: =item is_supplemental_title()
6873:
6874: =item entryline()
6875:
6876: =item tiehash()
6877:
6878: =item untiehash()
6879:
6880: =item checkonthis()
6881:
6882: check on this
6883:
6884: =item verifycontent()
6885:
6886: Verify Content
6887:
6888: =item devalidateversioncache() & checkversions()
6889:
6890: Check Versions
6891:
6892: =item mark_hash_old()
6893:
6894: =item is_hash_old()
6895:
6896: =item changewarning()
6897:
6898: =item init_breadcrumbs()
6899:
6900: Breadcrumbs for special functions
6901:
1.484 raeburn 6902: =item create_list_elements()
6903:
6904: =item create_form_ul()
6905:
6906: =item startContentScreen()
6907:
6908: =item endContentScreen()
6909:
6910: =item supplemental_base()
6911:
6912: =item embedded_form_elems()
6913:
6914: =item embedded_destination()
6915:
6916: =item return_to_editor()
6917:
6918: =item decompression_info()
6919:
6920: =item decompression_phase_one()
6921:
6922: =item decompression_phase_two()
6923:
6924: =item remove_archive()
6925:
6926: =item generate_admin_menu()
6927:
6928: =item generate_edit_table()
6929:
6930: =item editing_js()
6931:
6932: =item history_tab_js()
6933:
6934: =item inject_data_js()
6935:
6936: =item dump_switchserver_js()
6937:
1.485 raeburn 6938: =item resize_scrollbox_js()
1.484 raeburn 6939:
6940: =item makedocslogform()
6941:
1.485 raeburn 6942: =item makesimpleeditform()
6943:
1.329 droeschl 6944: =back
6945:
6946: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>