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