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