Annotation of loncom/interface/londocs.pm, revision 1.228
1.1 www 1: # The LearningOnline Network
1.2 www 2: # Documents
1.1 www 3: #
1.228 ! www 4: # $Id: londocs.pm,v 1.227 2006/05/12 16:47:35 albertel Exp $
1.1 www 5: #
1.3 www 6: # Copyright Michigan State University Board of Trustees
1.1 www 7: #
1.3 www 8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
1.1 www 9: #
1.3 www 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.
1.1 www 14: #
1.3 www 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:
1.2 www 29: package Apache::londocs;
1.1 www 30:
31: use strict;
1.28 www 32: use Apache::Constants qw(:common :http);
1.158 raeburn 33: use Apache::imsexport;
1.4 www 34: use Apache::lonnet;
35: use Apache::loncommon;
1.7 www 36: use Apache::lonratedt;
37: use Apache::lonratsrv;
1.15 www 38: use Apache::lonxml;
1.74 www 39: use Apache::loncreatecourse;
1.138 raeburn 40: use Apache::lonnavmaps;
1.38 www 41: use HTML::Entities;
1.27 www 42: use GDBM_File;
1.81 www 43: use Apache::lonlocal;
1.143 raeburn 44: use Cwd;
1.228 ! www 45: use lib '/home/httpd/lib/perl/';
! 46: use LONCAPA;
1.7 www 47:
1.8 www 48: my $iconpath;
1.7 www 49:
1.27 www 50: my %hash;
51:
52: my $hashtied;
1.29 www 53: my %alreadyseen=();
1.27 www 54:
1.40 www 55: my $hadchanges;
56:
1.47 www 57: # Available help topics
58:
59: my %help=();
60:
1.7 www 61: # Mapread read maps into lonratedt::global arrays
1.10 www 62: # @order and @resources, determines status
1.7 www 63: # sets @order - pointer to resources in right order
64: # sets @resources - array with the resources with correct idx
65: #
66:
67: sub mapread {
68: my ($coursenum,$coursedom,$map)=@_;
69: return
70: &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
71: $map);
72: }
73:
74: sub storemap {
75: my ($coursenum,$coursedom,$map)=@_;
1.104 albertel 76: my ($outtext,$errtext)=
1.7 www 77: &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.15 www 78: $map,1);
1.104 albertel 79: if ($errtext) { return ($errtext,2); }
80:
81: $hadchanges=1;
82: return ($errtext,0);
1.7 www 83: }
84:
1.74 www 85: # ----------------------------------------- Return hash with valid author names
86:
87: sub authorhosts {
88: my %outhash=();
89: my $home=0;
90: my $other=0;
1.174 albertel 91: foreach (keys %env) {
1.74 www 92: if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
93: my $role=$1;
94: my $realm=$2;
1.174 albertel 95: my ($start,$end)=split(/\./,$env{$_});
1.74 www 96: if (($start) && ($start>time)) { next; }
97: if (($end) && (time>$end)) { next; }
98: my $ca; my $cd;
99: if ($1 eq 'au') {
1.174 albertel 100: $ca=$env{'user.name'};
101: $cd=$env{'user.domain'};
1.74 www 102: } else {
103: ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/);
104: }
1.107 albertel 105: my $allowed=0;
106: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
107: my @ids=&Apache::lonnet::current_machine_ids();
108: foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } }
109: if ($allowed) {
1.74 www 110: $home++;
111: $outhash{'home_'.$ca.'@'.$cd}=1;
112: } else {
1.107 albertel 113: $outhash{'otherhome_'.$ca.'@'.$cd}=$myhome;
1.74 www 114: $other++;
115: }
116: }
117: }
118: return ($home,$other,%outhash);
119: }
120: # ------------------------------------------------------ Generate "dump" button
121:
122: sub dumpbutton {
123: my ($home,$other,%outhash)=&authorhosts();
124: if ($home+$other==0) { return ''; }
125: my $output='</td><td bgcolor="#DDDDCC">';
126: if ($home) {
127: return '</td><td bgcolor="#DDDDCC">'.
1.81 www 128: '<input type="submit" name="dumpcourse" value="'.
1.130 www 129: &mt('Dump Course DOCS to Construction Space').'" />'.
130: &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs');
1.74 www 131: } else {
132: return'</td><td bgcolor="#DDDDCC">'.
1.81 www 133: &mt('Dump Course DOCS to Construction Space: available on other servers');
1.74 www 134: }
135: }
136:
1.164 albertel 137: sub clean {
138: my ($title)=@_;
139: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
140: return $title;
141: }
1.74 www 142: # -------------------------------------------------------- Actually dump course
143:
144: sub dumpcourse {
1.224 albertel 145: my ($r) = @_;
146:
147: $r->print(&Apache::loncommon::start_page('Dump Course DOCS to Construction Space').
1.76 www 148: '<form name="dumpdoc" method="post">');
1.74 www 149: my ($home,$other,%outhash)=&authorhosts();
1.75 www 150: unless ($home) { return ''; }
1.174 albertel 151: my $origcrsid=$env{'request.course.id'};
1.76 www 152: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
1.174 albertel 153: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
1.76 www 154: # Do the dumping
1.174 albertel 155: unless ($outhash{'home_'.$env{'form.authorspace'}}) { return ''; }
156: my ($ca,$cd)=split(/\@/,$env{'form.authorspace'});
1.87 www 157: $r->print('<h3>'.&mt('Copying Files').'</h3>');
1.174 albertel 158: my $title=$env{'form.authorfolder'};
1.164 albertel 159: $title=&clean($title);
1.79 www 160: my %replacehash=();
1.174 albertel 161: foreach (keys %env) {
1.79 www 162: if ($_=~/^form\.namefor\_(.+)/) {
1.174 albertel 163: $replacehash{$1}=$env{$_};
1.79 www 164: }
165: }
1.174 albertel 166: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
1.79 www 167: $crs=~s/\_/\//g;
168: foreach (keys %replacehash) {
169: my $newfilename=$title.'/'.$replacehash{$_};
1.205 albertel 170: $newfilename=~s/\.(\w+)$//;
171: my $ext=$1;
1.164 albertel 172: $newfilename=&clean($newfilename);
1.205 albertel 173: $newfilename.='.'.$ext;
1.79 www 174: my @dirs=split(/\//,$newfilename);
175: my $path='/home/'.$ca.'/public_html';
176: my $makepath=$path;
177: my $fail=0;
178: for (my $i=0;$i<$#dirs;$i++) {
179: $makepath.='/'.$dirs[$i];
180: unless (-e $makepath) {
181: unless(mkdir($makepath,0777)) { $fail=1; }
182: }
183: }
184: $r->print('<br /><tt>'.$_.'</tt> => <tt>'.$newfilename.'</tt>: ');
185: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
186: if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
187: print $fh &Apache::loncreatecourse::rewritefile(
1.174 albertel 188: &Apache::loncreatecourse::readfile($env{'request.course.id'},$_),
1.79 www 189: (%replacehash,$crs => '')
190: );
191: } else {
192: print $fh
1.174 albertel 193: &Apache::loncreatecourse::readfile($env{'request.course.id'},$_);
1.79 www 194: }
195: $fh->close();
196: } else {
197: $fail=1;
198: }
199: if ($fail) {
200: $r->print('<font color="red">fail</font>');
201: } else {
202: $r->print('<font color="green">ok</font>');
203: }
204: }
1.76 www 205: } else {
206: # Input form
207: unless ($home==1) {
208: $r->print(
1.81 www 209: '<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
1.76 www 210: }
211: foreach (sort keys %outhash) {
212: if ($_=~/^home_(.+)$/) {
213: if ($home==1) {
214: $r->print(
215: '<input type="hidden" name="authorspace" value="'.$1.'" />');
216: } else {
1.133 www 217: $r->print('<option value="'.$1.'">'.$1.' - '.
218: &Apache::loncommon::plainname(split(/\@/,$1)).'</option>');
1.76 www 219: }
220: }
221: }
222: unless ($home==1) {
223: $r->print('</select>');
224: }
225: my $title=$origcrsdata{'description'};
1.227 albertel 226: $title=~s/[\/\s]+/\_/gs;
1.164 albertel 227: $title=&clean($title);
1.81 www 228: $r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
1.76 www 229: &tiehash();
1.81 www 230: $r->print('<h3>'.&mt('Filenames in Construction Space').'</h3><table border="2"><tr><th>'.&mt('Internal Filename').'</th><th>'.&mt('Title').'</th><th>'.&mt('Save as ...').'</th></tr>');
1.76 www 231: foreach (&Apache::loncreatecourse::crsdirlist($origcrsid,'userfiles')) {
1.78 www 232: $r->print('<tr><td>'.$_.'</td>');
233: my ($ext)=($_=~/\.(\w+)$/);
234: my $title=$hash{'title_'.$hash{
235: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
1.163 albertel 236: $title=~s/:/:/g;
1.78 www 237: $r->print('<td>'.($title?$title:' ').'</td>');
238: unless ($title) {
239: $title=$_;
240: }
241: $title=~s/\.(\w+)$//;
1.164 albertel 242: $title=&clean($title);
1.78 www 243: $title.='.'.$ext;
1.79 www 244: $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
1.76 www 245: }
1.78 www 246: $r->print("</table>\n");
1.76 www 247: &untiehash();
248: $r->print(
1.81 www 249: '<p><input type="submit" name="dumpcourse" value="'.&mt('Dump Course DOCS').'" /></p></form>');
1.75 www 250: }
1.74 www 251: }
1.76 www 252:
1.138 raeburn 253: # ------------------------------------------------------ Generate "export" button
254:
255: sub exportbutton {
256: return '</td><td bgcolor="#DDDDCC">'.
257: '<input type="submit" name="exportcourse" value="'.
1.204 raeburn 258: &mt('Export Course to IMS').'" />'.
1.203 raeburn 259: &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');
1.138 raeburn 260: }
261:
262: sub exportcourse {
263: my $r=shift;
264: my %discussiontime = &Apache::lonnet::dump('discussiontimes',
1.174 albertel 265: $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
1.138 raeburn 266: my $numdisc = keys %discussiontime;
267: my $navmap = Apache::lonnavmaps::navmap->new();
268: my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
269: my $curRes;
1.143 raeburn 270: my $outcome;
1.138 raeburn 271:
272: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
273: ['finishexport']);
1.174 albertel 274: if ($env{'form.finishexport'}) {
1.138 raeburn 275: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
276: ['archive','discussion']);
277:
1.175 albertel 278: my @exportitems = &Apache::loncommon::get_env_multiple('form.archive');
279: my @discussions = &Apache::loncommon::get_env_multiple('form.discussion');
1.143 raeburn 280: if (@exportitems == 0 && @discussions == 0) {
281: $outcome = '<br />As you did not select any content items or discussions for export, an IMS package has not been created. Please <a href="javascript:history.go(-1)">go back</a> to select either content items or discussions for export';
282: } else {
283: my $now = time;
284: my %symbs;
285: my $manifestok = 0;
286: my $imsresources;
287: my $tempexport;
288: my $copyresult;
289: my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport);
290: if ($manifestok) {
1.157 raeburn 291: &build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,$tempexport,\$copyresult,$ims_manifest);
1.143 raeburn 292: close($ims_manifest);
293:
294: #Create zip file in prtspool
295: my $imszipfile = '/prtspool/'.
1.174 albertel 296: $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
1.143 raeburn 297: time.'_'.rand(1000000000).'.zip';
298: my $cwd = &Cwd::getcwd();
299: my $imszip = '/home/httpd/'.$imszipfile;
300: chdir $tempexport;
301: open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
302: close(OUTPUT);
303: chdir $cwd;
304: $outcome .= 'Download the zip file from <a href="'.$imszipfile.'">IMS course archive</a><br />';
305: if ($copyresult) {
306: $outcome .= 'The following errors occurred during export - '.$copyresult;
1.138 raeburn 307: }
1.143 raeburn 308: } else {
309: $outcome = '<br />Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.<br />';
1.138 raeburn 310: }
311: }
1.224 albertel 312: $r->print(&Apache::loncommon::start_page('Export course to IMS content package'));
1.143 raeburn 313: $r->print($outcome);
1.224 albertel 314: $r->print(&Apache::loncommon::end_page());
1.138 raeburn 315: } else {
316: my $display;
317: $display = '<form name="exportdoc" method="post">'."\n";
318: $display .= 'Choose which items you wish to export from your course.<br /><br />';
319: $display .= '<table border="0" cellspacing="0" cellpadding="3">'.
320: '<tr><td><fieldset><legend> <b>Content items</b></legend>'.
321: '<input type="button" value="check all" '.
322: 'onclick="javascript:checkAll(document.exportdoc.archive)" />'.
323: ' <input type="button" value="uncheck all"'.
324: ' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset></td>'.
325: '<td> </td><td> </td>'.
326: '<td align="right"><fieldset><legend> <b>Discussion posts'.
327: '</b></legend><input type="button" value="check all"'.
328: ' onclick="javascript:checkAll(document.exportdoc.discussion)" />'.
329: ' <input type="button" value="uncheck all"'.
330: ' onclick="javascript:uncheckAll(document.exportdoc.discussion)" /></fieldset></td>'.
331: '</tr></table>';
332: my $curRes;
333: my $depth = 0;
334: my $count = 0;
335: my $boards = 0;
336: my $startcount = 5;
337: my %parent = ();
338: my %children = ();
339: my $lastcontainer = $startcount;
340: my @bgcolors = ('#F6F6F6','#FFFFFF');
341: $display .= '<table cellspacing="0"><tr>'.
342: '<td><b>Export content item?<br /></b></td><td> </td><td align="right">'."\n";
343: if ($numdisc > 0) {
344: $display.='<b>Export discussion posts?</b>'."\n";
345: }
346: $display.=' </td></tr>';
347: while ($curRes = $it->next()) {
348: if (ref($curRes)) {
349: $count ++;
350: }
351: if ($curRes == $it->BEGIN_MAP()) {
352: $depth++;
353: $parent{$depth} = $lastcontainer;
354: }
355: if ($curRes == $it->END_MAP()) {
356: $depth--;
357: $lastcontainer = $parent{$depth};
358: }
359: if (ref($curRes)) {
360: my $symb = $curRes->symb();
1.158 raeburn 361: my $ressymb = $symb;
362: if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) {
363: unless ($ressymb =~ m|adm/wrapper/adm|) {
364: $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
365: }
366: }
1.138 raeburn 367: my $color = $count%2;
368: $display .='<tr bgcolor='.$bgcolors[$color].'><td>'."\n".
369: '<input type="checkbox" name="archive" value="'.$count.'" ';
370: if (($curRes->is_sequence()) || ($curRes->is_page())) {
371: my $checkitem = $count + $boards + $startcount;
372: $display .= 'onClick="javascript:propagateCheck('."'$checkitem'".')"';
373: }
374: $display .= ' />'."\n";
375: for (my $i=0; $i<$depth; $i++) {
376: $display .= '<img src="/adm/lonIcons/whitespace1.gif" width="25" height="1" alt="" border="0" /><img src="/adm/lonIcons/whitespace1.gif" width="25" height="1" alt="" border="0" />'."\n";
377: }
378: if ($curRes->is_sequence()) {
379: $display .= '<img src="/adm/lonIcons/navmap.folder.open.gif"> '."\n";
380: $lastcontainer = $count + $startcount + $boards;
381: } elsif ($curRes->is_page()) {
382: $display .= '<img src="/adm/lonIcons/navmap.page.open.gif"> '."\n";
383: $lastcontainer = $count + $startcount + $boards;
384: }
385: my $currelem = $count+$boards+$startcount;
386: $children{$parent{$depth}} .= $currelem.':';
387: $display .= ' '.$curRes->title().'</td>';
1.158 raeburn 388: if ($discussiontime{$ressymb} > 0) {
1.138 raeburn 389: $boards ++;
390: $currelem = $count+$boards+$startcount;
391: $display .= '<td> </td><td align="right"><input type="checkbox" name="discussion" value="'.$count.'" /> </td>'."\n";
392: } else {
393: $display .= '<td colspan="2"> </td>'."\n";
394: }
395: }
396: }
397: my $scripttag = qq|
398: <script>
399:
400: function checkAll(field) {
1.158 raeburn 401: if (field.length > 0) {
402: for (i = 0; i < field.length; i++) {
403: field[i].checked = true ;
404: }
405: } else {
406: field.checked = true
407: }
1.138 raeburn 408: }
1.158 raeburn 409:
1.138 raeburn 410: function uncheckAll(field) {
1.158 raeburn 411: if (field.length > 0) {
412: for (i = 0; i < field.length; i++) {
413: field[i].checked = false ;
414: }
415: } else {
416: field.checked = false ;
417: }
1.138 raeburn 418: }
419:
420: function propagateCheck(item) {
421: if (document.exportdoc.elements[item].checked == true) {
422: containerCheck(item)
423: }
424: }
425:
426: function containerCheck(item) {
427: document.exportdoc.elements[item].checked = true
428: var numitems = $count + $boards + $startcount
429: var parents = new Array(numitems)
430: for (var i=$startcount; i<numitems; i++) {
431: parents[i] = new Array
432: }
433: |;
434:
435: foreach my $container (sort { $a <=> $b } keys %children) {
436: my @contents = split/:/,$children{$container};
437: for (my $i=0; $i<@contents; $i ++) {
438: $scripttag .= ' parents['.$container.']['.$i.'] = '.$contents[$i]."\n";
439: }
440: }
441:
442: $scripttag .= qq|
443: if (parents[item].length > 0) {
444: for (var j=0; j<parents[item].length; j++) {
445: containerCheck(parents[item][j])
446: }
447: }
448: }
449:
450: </script>
451: |;
1.224 albertel 452: $r->print(&Apache::loncommon::start_page('Export course to IMS content package',
453: $scripttag));
454: $r->print($display.'</table>'.
1.138 raeburn 455: '<p><input type="hidden" name="finishexport" value="1">'.
456: '<input type="submit" name="exportcourse" value="'.
1.224 albertel 457: &mt('Export Course DOCS').'" /></p></form>'.
458: &Apache::loncommon::end_page());
1.138 raeburn 459: }
460: }
461:
1.143 raeburn 462: sub create_ims_store {
463: my ($now,$manifestok,$outcome,$tempexport) = @_;
464: $$tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports';
465: my $ims_manifest;
466: if (!-e $$tempexport) {
467: mkdir($$tempexport,0700);
468: }
469: $$tempexport .= '/'.$now;
470: if (!-e $$tempexport) {
471: mkdir($$tempexport,0700);
472: }
1.174 albertel 473: $$tempexport .= '/'.$env{'user.domain'}.'_'.$env{'user.name'};
1.143 raeburn 474: if (!-e $$tempexport) {
475: mkdir($$tempexport,0700);
476: }
1.159 raeburn 477: if (!-e "$$tempexport/resources") {
478: mkdir("$$tempexport/resources",0700);
479: }
1.143 raeburn 480: # open manifest file
481: my $manifest = '/imsmanifest.xml';
482: my $manifestfilename = $$tempexport.$manifest;
483: if ($ims_manifest = Apache::File->new('>'.$manifestfilename)) {
484: $$manifestok=1;
485: print $ims_manifest
486: '<?xml version="1.0" encoding="UTF-8"?>'."\n".
487: '<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"'.
488: ' xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"'.
489: ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'.
1.174 albertel 490: ' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'.
1.143 raeburn 491: ' xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'.
492: ' http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n".
1.199 raeburn 493: ' <metadata>
494: <schema></schema>
495: <imsmd:lom>
496: <imsmd:general>
497: <imsmd:identifier>'.$env{'request.course.id'}.'</imsmd:identifier>
498: <imsmd:title>
499: <imsmd:langstring xml:lang="en">'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</imsmd:langstring>
500: </imsmd:title>
501: </imsmd:general>
502: </imsmd:lom>
503: </metadata>'."\n".
1.174 albertel 504: ' <organizations default="ORG-'.$env{'request.course.id'}.'-'.$now.'">'."\n".
505: ' <organization identifier="ORG-'.$env{'request.course.id'}.'-'.$now.'"'.
1.143 raeburn 506: ' structure="hierarchical">'."\n".
1.199 raeburn 507: ' <title>'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</title>'
1.143 raeburn 508: } else {
509: $$outcome .= 'An error occurred opening the IMS manifest file.<br />'
510: ;
511: }
512: return $ims_manifest;
513: }
514:
515: sub build_package {
516: my ($now,$navmap,$exportitems,$discussions,$outcome,$tempexport,$copyresult,$ims_manifest) = @_;
517: # first iterator to look for dependencies
518: my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
519: my $curRes;
520: my $count = 0;
521: my $depth = 0;
522: my $lastcontainer = 0;
523: my %parent = ();
524: my @dependencies = ();
1.174 albertel 525: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
526: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.143 raeburn 527: while ($curRes = $it->next()) {
528: if (ref($curRes)) {
529: $count ++;
530: }
531: if ($curRes == $it->BEGIN_MAP()) {
532: $depth++;
533: $parent{$depth} = $lastcontainer;
534: }
535: if ($curRes == $it->END_MAP()) {
536: $depth--;
537: $lastcontainer = $parent{$depth};
538: }
539: if (ref($curRes)) {
540: if ($curRes->is_sequence() || $curRes->is_page()) {
541: $lastcontainer = $count;
542: }
543: if (grep/^$count$/,@$exportitems) {
544: &get_dependencies($exportitems,\%parent,$depth,\@dependencies);
545: }
546: }
547: }
548: # second iterator to build manifest and store resources
549: $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
550: $depth = 0;
551: my $prevdepth;
552: $count = 0;
553: my $imsresources;
554: my $pkgdepth;
1.157 raeburn 555: while ($curRes = $it->next()) {
556: if ($curRes == $it->BEGIN_MAP()) {
557: $prevdepth = $depth;
558: $depth++;
559: }
560: if ($curRes == $it->END_MAP()) {
1.143 raeburn 561: $prevdepth = $depth;
1.157 raeburn 562: $depth--;
563: }
564:
565: if (ref($curRes)) {
566: $count ++;
567: if ((grep/^$count$/,@$exportitems) || (grep/^$count$/,@dependencies)) {
568: my $symb = $curRes->symb();
569: my $isvisible = 'true';
570: my $resourceref;
571: if ($curRes->randomout()) {
572: $isvisible = 'false';
573: }
574: unless ($curRes->is_sequence()) {
1.174 albertel 575: $resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"';
1.157 raeburn 576: }
1.199 raeburn 577: my $step = $prevdepth - $depth;
578: if (($step >= 0) && ($count > 1)) {
579: while ($step >= 0) {
580: print $ims_manifest "\n".' </item>'."\n";
581: $step --;
582: }
1.157 raeburn 583: }
584: $prevdepth = $depth;
1.143 raeburn 585:
1.157 raeburn 586: my $itementry =
1.174 albertel 587: '<item identifier="ITEM-'.$env{'request.course.id'}.'-'.$count.
1.143 raeburn 588: '" isvisible="'.$isvisible.'" '.$resourceref.'>'.
589: '<title>'.$curRes->title().'</title>';
1.157 raeburn 590: print $ims_manifest "\n".$itementry;
1.143 raeburn 591:
1.157 raeburn 592: unless ($curRes->is_sequence()) {
593: my $content_file;
594: my @hrefs = ();
595: &process_content($count,$curRes,$cdom,$cnum,$symb,\$content_file,\@hrefs,$copyresult,$tempexport);
596: if ($content_file) {
597: $imsresources .= "\n".
1.174 albertel 598: ' <resource identifier="RES-'.$env{'request.course.id'}.'-'.$count.
1.143 raeburn 599: '" type="webcontent" href="'.$content_file.'">'."\n".
600: ' <file href="'.$content_file.'" />'."\n";
1.157 raeburn 601: foreach (@hrefs) {
602: $imsresources .=
1.143 raeburn 603: ' <file href="'.$_.'" />'."\n";
1.157 raeburn 604: }
1.158 raeburn 605: if (grep/^$count$/,@$discussions) {
606: my $ressymb = $symb;
607: my $mode;
608: if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) {
609: unless ($ressymb =~ m|adm/wrapper/adm|) {
610: $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
611: }
612: $mode = 'board';
613: }
614: my %extras = (
615: caller => 'imsexport',
1.159 raeburn 616: tempexport => $tempexport.'/resources',
1.158 raeburn 617: count => $count
618: );
619: my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras);
620: }
1.157 raeburn 621: $imsresources .= ' </resource>'."\n";
1.143 raeburn 622: }
623: }
1.157 raeburn 624: $pkgdepth = $depth;
1.143 raeburn 625: }
626: }
627: }
1.157 raeburn 628: while ($pkgdepth > 0) {
1.143 raeburn 629: print $ims_manifest " </item>\n";
630: $pkgdepth --;
631: }
632: my $resource_text = qq|
633: </organization>
634: </organizations>
635: <resources>
636: $imsresources
637: </resources>
638: </manifest>
639: |;
640: print $ims_manifest $resource_text;
641: }
642:
643: sub get_dependencies {
644: my ($exportitems,$parent,$depth,$dependencies) = @_;
645: if ($depth > 1) {
1.157 raeburn 646: if ((!grep/^$$parent{$depth}$/,@$exportitems) && (!grep/^$$parent{$depth}$/,@$dependencies)) {
1.143 raeburn 647: push @$dependencies, $$parent{$depth};
648: if ($depth > 2) {
649: &get_dependencies($exportitems,$parent,$depth-1,$dependencies);
650: }
651: }
652: }
653: }
654:
655: sub process_content {
656: my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_;
657: my $content_type;
658: my $message;
1.158 raeburn 659: my @uploads = ();
1.157 raeburn 660: if ($curRes->is_sequence()) {
661: $content_type = 'sequence';
662: } elsif ($curRes->is_page()) {
663: $content_type = 'page'; # need to handle individual items in pages.
1.143 raeburn 664: } elsif ($symb =~ m-public/$cdom/$cnum/syllabus$-) {
665: $content_type = 'syllabus';
1.158 raeburn 666: my $contents = &Apache::imsexport::templatedpage($content_type);
667: if ($contents) {
668: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
669: }
1.157 raeburn 670: } elsif ($symb =~ m-\.sequence___\d+___ext-) {
1.143 raeburn 671: $content_type = 'external';
1.158 raeburn 672: my $title = $curRes->title;
673: my $contents = &Apache::imsexport::external($symb,$title);
674: if ($contents) {
675: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
676: }
1.143 raeburn 677: } elsif ($symb =~ m-adm/navmaps$-) {
678: $content_type = 'navmap';
1.158 raeburn 679: } elsif ($symb =~ m-adm/[^/]+/[^/]+/(\d+)/smppg$-) {
1.143 raeburn 680: $content_type = 'simplepage';
1.158 raeburn 681: my $contents = &Apache::imsexport::templatedpage($content_type,$1,$count,\@uploads);
682: if ($contents) {
683: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
684: }
685: } elsif ($symb =~ m-lib/templates/simpleproblem\.problem$-) {
1.143 raeburn 686: $content_type = 'simpleproblem';
1.158 raeburn 687: my $contents = &Apache::imsexport::simpleproblem($symb);
688: if ($contents) {
689: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
690: }
1.188 raeburn 691: } elsif ($symb =~ m-lib/templates/examupload\.problem$-) {
1.158 raeburn 692: $content_type = 'examupload';
693: } elsif ($symb =~ m-adm/(\w+)/(\w+)/(\d+)/bulletinboard$-) {
1.143 raeburn 694: $content_type = 'bulletinboard';
1.158 raeburn 695: my $contents = &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2);
696: if ($contents) {
697: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
698: }
699: } elsif ($symb =~ m-adm/([^/]+)/([^/]+)/aboutme$-) {
1.143 raeburn 700: $content_type = 'aboutme';
1.158 raeburn 701: my $contents = &Apache::imsexport::templatedpage($content_type,undef,$count,\@uploads,$1,$2);
702: if ($contents) {
703: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
704: }
1.157 raeburn 705: } elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) {
706: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
1.162 raeburn 707: } elsif ($symb =~ m-\.(sequence|page)___\d+___([^/]+)/([^/]+)-) {
1.143 raeburn 708: my $canedit = 0;
1.174 albertel 709: if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'}) {
1.143 raeburn 710: $canedit= 1;
711: }
1.200 raeburn 712: # only include problem code where current user is author
1.143 raeburn 713: if ($canedit) {
1.157 raeburn 714: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource');
1.143 raeburn 715: } else {
1.157 raeburn 716: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit');
1.143 raeburn 717: }
1.162 raeburn 718: } elsif ($symb =~ m-uploaded/$cdom/$cnum-) {
719: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
1.143 raeburn 720: }
1.158 raeburn 721: if (@uploads > 0) {
722: foreach my $item (@uploads) {
723: my $uploadmsg = '';
1.159 raeburn 724: &replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'templateupload');
1.158 raeburn 725: if ($uploadmsg) {
726: $$copyresult .= $uploadmsg."\n";
727: }
728: }
729: }
1.157 raeburn 730: if ($message) {
731: $$copyresult .= $message."\n";
732: }
1.143 raeburn 733: }
734:
735: sub replicate_content {
1.157 raeburn 736: my ($cdom,$cnum,$tempexport,$symb,$count,$message,$href,$caller) = @_;
1.159 raeburn 737: my ($map,$ind,$url);
738: if ($caller eq 'templateupload') {
739: $url = $symb;
740: $url =~ s#//#/#g;
741: } else {
742: ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
743: }
1.143 raeburn 744: my $content;
745: my $filename;
746: my $repstatus;
1.157 raeburn 747: my $content_name;
748: if ($url =~ m-/([^/]+)$-) {
1.143 raeburn 749: $filename = $1;
750: if (!-e $tempexport.'/resources') {
751: mkdir($tempexport.'/resources',0700);
752: }
1.157 raeburn 753: if (!-e $tempexport.'/resources/'.$count) {
1.143 raeburn 754: mkdir($tempexport.'/resources/'.$count,0700);
755: }
1.157 raeburn 756: my $destination = $tempexport.'/resources/'.$count.'/'.$filename;
1.143 raeburn 757: my $copiedfile;
758: if ($copiedfile = Apache::File->new('>'.$destination)) {
759: my $content;
1.157 raeburn 760: if ($caller eq 'resource') {
1.197 raeburn 761: my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';
762: my $filepath = &Apache::lonnet::filelocation($respath,$url);
763: $content = &Apache::lonnet::getfile($filepath);
1.143 raeburn 764: if ($content eq -1) {
765: $$message = 'Could not copy file '.$filename;
766: } else {
1.197 raeburn 767: &extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'resource');
1.143 raeburn 768: $repstatus = 'ok';
769: }
1.162 raeburn 770: } elsif ($caller eq 'uploaded' || $caller eq 'templateupload') {
1.143 raeburn 771: my $rtncode;
1.157 raeburn 772: $repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode);
773: if ($repstatus eq 'ok') {
774: if ($url =~ /\.html?$/i) {
1.197 raeburn 775: &extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'uploaded');
1.157 raeburn 776: }
777: } else {
1.197 raeburn 778: $$message = 'Could not render '.$url.' server message - '.$rtncode."<br />\n";
1.143 raeburn 779: }
1.162 raeburn 780: } elsif ($caller eq 'noedit') {
781: # Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this.
782: $repstatus = 'ok';
783: $content = 'Not the owner of this resource';
1.143 raeburn 784: }
785: if ($repstatus eq 'ok') {
786: print $copiedfile $content;
787: }
788: close($copiedfile);
789: } else {
1.197 raeburn 790: $$message = 'Could not open destination file for '.$filename."<br />\n";
1.143 raeburn 791: }
792: } else {
1.197 raeburn 793: $$message = 'Could not determine name of file for '.$symb."<br />\n";
1.143 raeburn 794: }
1.157 raeburn 795: if ($repstatus eq 'ok') {
1.198 raeburn 796: $content_name = 'resources/'.$count.'/'.$filename;
1.157 raeburn 797: }
798: return $content_name;
799: }
800:
801: sub extract_media {
1.197 raeburn 802: my ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_;
1.198 raeburn 803: my ($dirpath,$container);
1.197 raeburn 804: my %allfiles = ();
805: my %codebase = ();
1.198 raeburn 806: if ($url =~ m-(.*/)([^/]+)$-) {
807: $dirpath = $1;
808: $container = $2;
809: } else {
810: $dirpath = $url;
811: $container = '';
812: }
1.197 raeburn 813: &Apache::lonnet::extract_embedded_items(undef,undef,\%allfiles,\%codebase,$content);
814: foreach my $embed_file (keys(%allfiles)) {
815: my $filename;
816: if ($embed_file =~ m#([^/]+)$#) {
817: $filename = $1;
818: } else {
819: $filename = $embed_file;
820: }
821: my $newname = 'res/'.$filename;
822: my ($rtncode,$embed_content,$repstatus);
823: my $embed_url;
824: if ($embed_file =~ m-^/-) {
825: $embed_url = $embed_file; # points to absolute path
826: } else {
827: if ($embed_file =~ m-https?://-) {
828: next; # points to url
829: } else {
1.198 raeburn 830: $embed_url = $dirpath.$embed_file; # points to relative path
1.197 raeburn 831: }
832: }
833: if ($caller eq 'resource') {
834: my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';
835: my $embed_path = &Apache::lonnet::filelocation($respath,$embed_url);
836: $embed_content = &Apache::lonnet::getfile($embed_path);
837: unless ($embed_content eq -1) {
838: $repstatus = 'ok';
839: }
840: } elsif ($caller eq 'uploaded') {
841:
842: $repstatus = &Apache::lonnet::getuploaded('GET',$embed_url,$cdom,$cnum,\$embed_content,$rtncode);
843: }
844: if ($repstatus eq 'ok') {
845: my $destination = $tempexport.'/resources/'.$count.'/res';
846: if (!-e "$destination") {
847: mkdir($destination,0755);
848: }
849: $destination .= '/'.$filename;
850: my $copiedfile;
851: if ($copiedfile = Apache::File->new('>'.$destination)) {
852: print $copiedfile $embed_content;
1.198 raeburn 853: push @{$href}, 'resources/'.$count.'/res/'.$filename;
1.197 raeburn 854: my $attrib_regexp = '';
855: if (@{$allfiles{$embed_file}} > 1) {
856: $attrib_regexp = join('|',@{$allfiles{$embed_file}});
857: } else {
858: $attrib_regexp = $allfiles{$embed_file}[0];
859: }
860: $$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$embed_file\E(['"]?)#$1$newname$2#gi;
1.198 raeburn 861: if ($caller eq 'resource' && $container =~ /\.(problem|library)$/) {
1.197 raeburn 862: $$content =~ s#\Q$embed_file\E#$newname#gi;
863: }
864: }
865: } else {
866: $$message .= 'replication of embedded file - '.$embed_file.' in '.$url.' failed, reason -'.$rtncode."<br />\n";
867: }
868: }
1.157 raeburn 869: return;
1.143 raeburn 870: }
1.74 www 871:
1.158 raeburn 872: sub store_template {
873: my ($contents,$tempexport,$count,$content_type) = @_;
874: if ($contents) {
1.159 raeburn 875: if ($tempexport) {
876: if (!-e $tempexport.'/resources') {
877: mkdir($tempexport.'/resources',0700);
878: }
879: if (!-e $tempexport.'/resources/'.$count) {
880: mkdir($tempexport.'/resources/'.$count,0700);
881: }
882: my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml';
883: my $storetemplate;
884: if ($storetemplate = Apache::File->new('>'.$destination)) {
885: print $storetemplate $contents;
886: close($storetemplate);
887: }
888: if ($content_type eq 'external') {
1.198 raeburn 889: return 'resources/'.$count.'/'.$content_type.'.html';
1.159 raeburn 890: } else {
1.198 raeburn 891: return 'resources/'.$count.'/'.$content_type.'.xml';
1.159 raeburn 892: }
1.158 raeburn 893: }
894: }
895: }
896:
1.73 bowersj2 897: # Imports the given (name, url) resources into the course
898: # coursenum, coursedom, and folder must precede the list
899: sub group_import {
900: my $coursenum = shift;
901: my $coursedom = shift;
902: my $folder = shift;
1.142 raeburn 903: my $container = shift;
904: my $caller = shift;
1.73 bowersj2 905: while (@_) {
906: my $name = shift;
907: my $url = shift;
1.142 raeburn 908: if (($url =~ m#^/uploaded/$coursedom/$coursenum/(default_\d+\.)(page|sequence)$#) && ($caller eq 'londocs')) {
909: my $errtext = '';
910: my $fatal = 0;
911: my $newmapstr = '<map>'."\n".
912: '<resource id="1" src="" type="start"></resource>'."\n".
913: '<link from="1" to="2" index="1"></link>'."\n".
914: '<resource id="2" src="" type="finish"></resource>'."\n".
915: '</map>';
1.174 albertel 916: $env{'form.output'}=$newmapstr;
1.189 albertel 917: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
1.142 raeburn 918: 'output',$1.$2);
919: if ($result != m|^/uploaded/|) {
920: $errtext.='Map not saved: A network error occured when trying to save the new map. ';
921: $fatal = 2;
922: }
923: if ($fatal) {
924: return ($errtext,$fatal);
925: }
926: }
1.73 bowersj2 927: if ($url) {
1.178 www 928: my $idx = &Apache::lonratedt::getresidx($url);
1.73 bowersj2 929: $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx;
930: my $ext = 'false';
931: if ($url=~/^http:\/\//) { $ext = 'true'; }
932: $url =~ s/:/\:/g;
933: $name =~ s/:/\:/g;
934: $Apache::lonratedt::resources[$idx] =
935: join ':', ($name, $url, $ext, 'normal', 'res');
936: }
937: }
1.142 raeburn 938: return &storemap($coursenum, $coursedom, $folder.'.'.$container);
1.73 bowersj2 939: }
940:
1.114 albertel 941: sub breadcrumbs {
942: my ($where)=@_;
943: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.142 raeburn 944: my (@folders);
1.174 albertel 945: if ($env{'form.pagepath'}) {
946: @folders = split('&',$env{'form.pagepath'});
1.142 raeburn 947: } else {
1.174 albertel 948: @folders=split('&',$env{'form.folderpath'});
1.142 raeburn 949: }
1.116 albertel 950: my $folderpath;
1.168 www 951: my $cpinfo='';
1.174 albertel 952: if ($env{'form.markedcopy_url'}) {
953: &Apache::lonnet::logthis('Found '.$env{'form.markedcopy_url'});
1.168 www 954: $cpinfo='&markedcopy_url='.
1.228 ! www 955: &escape($env{'form.markedcopy_url'}).
1.168 www 956: '&markedcopy_title='.
1.228 ! www 957: &escape($env{'form.markedcopy_title'});
1.168 www 958: }
1.116 albertel 959: while (@folders) {
960: my $folder=shift(@folders);
961: my $foldername=shift(@folders);
962: if ($folderpath) {$folderpath.='&';}
963: $folderpath.=$folder.'&'.$foldername;
964: my $url='/adm/coursedocs?folderpath='.
1.228 ! www 965: &escape($folderpath);
1.114 albertel 966: &Apache::lonhtmlcommon::add_breadcrumb(
1.168 www 967: {'href'=>$url.$cpinfo,
1.228 ! www 968: 'title'=>&unescape($foldername),
1.117 albertel 969: 'text'=>'<font size="+1">'.
1.228 ! www 970: &unescape($foldername).'</font>'
1.117 albertel 971: });
1.114 albertel 972:
973:
974: }
1.226 albertel 975: return &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp');
1.114 albertel 976: }
977:
1.7 www 978: sub editor {
1.188 raeburn 979: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output)=@_;
1.10 www 980: my $errtext='';
981: my $fatal=0;
1.142 raeburn 982: my $container='sequence';
1.174 albertel 983: if ($env{'form.pagepath'}) {
1.142 raeburn 984: $container='page';
985: }
1.10 www 986: ($errtext,$fatal)=
1.142 raeburn 987: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.17 www 988: if ($#Apache::lonratedt::order<1) {
1.178 www 989: my $idx=&Apache::lonratedt::getresidx();
990: if ($idx<=0) { $idx=1; }
991: $Apache::lonratedt::order[0]=$idx;
992: $Apache::lonratedt::resources[$idx]='';
1.17 www 993: }
1.174 albertel 994: if (defined($env{'form.markcopy'})) {
1.168 www 995: # Mark for copying
1.174 albertel 996: my ($title,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$env{'form.markcopy'}]]);
997: $env{'form.markedcopy_title'}=$title;
998: $env{'form.markedcopy_url'}=$url;
1.168 www 999: }
1000: $r->print(&breadcrumbs($folder));
1.7 www 1001: if ($fatal) {
1002: $r->print('<p><font color="red">'.$errtext.'</font></p>');
1003: } else {
1004: # ------------------------------------------------------------ Process commands
1.121 www 1005:
1.16 www 1006: # ---------------- if they are for this folder and user allowed to make changes
1.174 albertel 1007: if (($allowed) && ($env{'form.folder'} eq $folder)) {
1.123 www 1008: # set parameters and change order
1.174 albertel 1009: if (defined($env{'form.setparms'})) {
1010: my $idx=$env{'form.setparms'};
1.123 www 1011: # set parameters
1.174 albertel 1012: if ($env{'form.randpick_'.$idx}) {
1013: &Apache::lonratedt::storeparameter($idx,'parameter_randompick',$env{'form.randpick_'.$idx},'int_pos');
1.121 www 1014: } else {
1.122 www 1015: &Apache::lonratedt::delparameter($idx,'parameter_randompick');
1.121 www 1016: }
1.174 albertel 1017: if ($env{'form.hidprs_'.$idx}) {
1.122 www 1018: &Apache::lonratedt::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno');
1.121 www 1019: } else {
1.122 www 1020: &Apache::lonratedt::delparameter($idx,'parameter_hiddenresource');
1.121 www 1021: }
1.174 albertel 1022: if ($env{'form.encprs_'.$idx}) {
1.122 www 1023: &Apache::lonratedt::storeparameter($idx,'parameter_encrypturl','yes','string_yesno');
1.121 www 1024: } else {
1.122 www 1025: &Apache::lonratedt::delparameter($idx,'parameter_encrypturl');
1.121 www 1026: }
1027:
1.174 albertel 1028: if ($env{'form.newpos'}) {
1.123 www 1029: # change order
1030:
1.174 albertel 1031: my $newpos=$env{'form.newpos'}-1;
1032: my $currentpos=$env{'form.currentpos'}-1;
1.125 www 1033: my $i;
1034: my @neworder=();
1035: if ($newpos>$currentpos) {
1036: # moving stuff up
1037: for ($i=0;$i<$currentpos;$i++) {
1038: $neworder[$i]=$Apache::lonratedt::order[$i];
1039: }
1040: for ($i=$currentpos;$i<$newpos;$i++) {
1041: $neworder[$i]=$Apache::lonratedt::order[$i+1];
1042: }
1043: $neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
1044: for ($i=$newpos+1;$i<=$#Apache::lonratedt::order;$i++) {
1045: $neworder[$i]=$Apache::lonratedt::order[$i];
1046: }
1047: } else {
1048: # moving stuff down
1049: for ($i=0;$i<$newpos;$i++) {
1050: $neworder[$i]=$Apache::lonratedt::order[$i];
1051: }
1052: $neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
1053: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
1054: $neworder[$i]=$Apache::lonratedt::order[$i-1];
1055: }
1056: for ($i=$currentpos+1;$i<=$#Apache::lonratedt::order;$i++) {
1057: $neworder[$i]=$Apache::lonratedt::order[$i];
1058: }
1059: }
1060: @Apache::lonratedt::order=@neworder;
1.124 www 1061: }
1062: # store the changed version
1.123 www 1063:
1.142 raeburn 1064: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
1.124 www 1065: if ($fatal) {
1066: $r->print('<p><font color="red">'.$errtext.'</font></p>');
1067: return;
1.123 www 1068: }
1.124 www 1069:
1070: }
1.174 albertel 1071: if ($env{'form.pastemarked'}) {
1.168 www 1072: # paste resource to end of list
1.174 albertel 1073: my $url=$env{'form.markedcopy_url'};
1074: my $title=$env{'form.markedcopy_title'};
1.168 www 1075: # Maps need to be copied first
1076: if (($url=~/\.(page|sequence)$/) || ($url=~/^\/uploaded\//)) {
1077: $title=&mt('Copy of').' '.$title;
1078: my $newid=$$.time;
1079: $url=~/^(.+)\.(\w+)$/;
1080: my $newurl=$1.$newid.'.'.$2;
1081: my $storefn=$newurl;
1082: $storefn=~s/^\/\w+\/\w+\/\w+\///;
1083: &Apache::loncreatecourse::writefile
1.174 albertel 1084: ($env{'request.course.id'},$storefn,
1.168 www 1085: &Apache::lonnet::getfile($url));
1086: $url=$newurl;
1087: }
1088: $title=~s/\</\<\;/g;
1089: $title=~s/\>/\>\;/g;
1090: $title=~s/\:/\:/g;
1091: my $ext='false';
1092: if ($url=~/^http\:\/\//) { $ext='true'; }
1093: $url=~s/\:/\:/g;
1094: # Now insert the URL at the bottom
1.179 www 1095: my $newidx=&Apache::lonratedt::getresidx($url);
1.168 www 1096: $Apache::lonratedt::resources[$newidx]=
1097: $title.':'.$url.':'.$ext.':normal:res';
1098: $Apache::lonratedt::order[1+$#Apache::lonratedt::order]=$newidx;
1099: # Store the result
1100: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
1101: if ($fatal) {
1102: $r->print('<p><font color="red">'.$errtext.'</font></p>');
1103: return;
1104: }
1.123 www 1105:
1.168 www 1106: }
1.188 raeburn 1107: $r->print($upload_output);
1.174 albertel 1108: if ($env{'form.cmd'}) {
1109: my ($cmd,$idx)=split(/\_/,$env{'form.cmd'});
1.10 www 1110: if ($cmd eq 'del') {
1.128 albertel 1111: my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]);
1.187 www 1112: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.206 albertel 1113: ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) {
1.187 www 1114: &Apache::lonnet::removeuploadedurl($url);
1115: } else {
1116: &Apache::lonratedt::makezombie($Apache::lonratedt::order[$idx]);
1.128 albertel 1117: }
1.10 www 1118: for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
1119: $Apache::lonratedt::order[$i]=
1120: $Apache::lonratedt::order[$i+1];
1121: }
1122: $#Apache::lonratedt::order--;
1.171 www 1123: } elsif ($cmd eq 'cut') {
1124: my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]);
1.179 www 1125: &Apache::lonratedt::makezombie($Apache::lonratedt::order[$idx]);
1.171 www 1126: for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
1127: $Apache::lonratedt::order[$i]=
1128: $Apache::lonratedt::order[$i+1];
1129: }
1130: $#Apache::lonratedt::order--;
1.10 www 1131: } elsif ($cmd eq 'up') {
1.38 www 1132: if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) {
1.10 www 1133: my $i=$Apache::lonratedt::order[$idx-1];
1134: $Apache::lonratedt::order[$idx-1]=
1135: $Apache::lonratedt::order[$idx];
1136: $Apache::lonratedt::order[$idx]=$i;
1.38 www 1137: }
1.10 www 1138: } elsif ($cmd eq 'down') {
1.38 www 1139: if (defined($Apache::lonratedt::order[$idx+1])) {
1.10 www 1140: my $i=$Apache::lonratedt::order[$idx+1];
1141: $Apache::lonratedt::order[$idx+1]=
1142: $Apache::lonratedt::order[$idx];
1143: $Apache::lonratedt::order[$idx]=$i;
1.38 www 1144: }
1.36 www 1145: } elsif ($cmd eq 'rename') {
1.142 raeburn 1146: my $ratstr = $Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]];
1.36 www 1147: my ($rtitle,@rrest)=split(/\:/,
1148: $Apache::lonratedt::resources[
1149: $Apache::lonratedt::order[$idx]]);
1.38 www 1150: my $comment=
1.174 albertel 1151: &HTML::Entities::decode($env{'form.title'});
1.36 www 1152: $comment=~s/\</\<\;/g;
1153: $comment=~s/\>/\>\;/g;
1154: $comment=~s/\:/\:/g;
1.144 albertel 1155: if ($comment=~/\S/) {
1156: $Apache::lonratedt::resources[
1.36 www 1157: $Apache::lonratedt::order[$idx]]=
1.144 albertel 1158: $comment.':'.join(':',@rrest);
1159: }
1.10 www 1160: }
1161: # Store the changed version
1.104 albertel 1162: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.142 raeburn 1163: $folder.'.'.$container);
1.104 albertel 1164: if ($fatal) {
1165: $r->print('<p><font color="red">'.$errtext.'</font></p>');
1166: return;
1167: }
1.8 www 1168: }
1.11 www 1169: # Group import/search
1.174 albertel 1170: if ($env{'form.importdetail'}) {
1.73 bowersj2 1171: my @imports;
1.174 albertel 1172: foreach (split(/\&/,$env{'form.importdetail'})) {
1.73 bowersj2 1173: if (defined($_)) {
1174: my ($name,$url)=split(/\=/,$_);
1.228 ! www 1175: $name=&unescape($name);
! 1176: $url=&unescape($url);
1.73 bowersj2 1177: push @imports, $name, $url;
1178: }
1179: }
1.11 www 1180: # Store the changed version
1.104 albertel 1181: ($errtext,$fatal)=group_import($coursenum, $coursedom, $folder,
1.142 raeburn 1182: $container,'londocs',@imports);
1.104 albertel 1183: if ($fatal) {
1184: $r->print('<p><font color="red">'.$errtext.'</font></p>');
1185: return;
1186: }
1.11 www 1187: }
1.53 www 1188: # Loading a complete map
1.223 www 1189: if ($env{'form.loadmap'}) {
1190: if ($env{'form.importmap'}=~/\w/) {
1191: foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
1192: my ($title,$url,$ext,$type)=split(/\:/,$_);
1193: my $idx=&Apache::lonratedt::getresidx($url);
1194: $Apache::lonratedt::resources[$idx]=$_;
1195: $Apache::lonratedt::order
1196: [$#Apache::lonratedt::order+1]=$idx;
1197: }
1.53 www 1198: # Store the changed version
1.223 www 1199: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.142 raeburn 1200: $folder.'.'.$container);
1.223 www 1201: if ($fatal) {
1202: $r->print('<p><font color="red">'.$errtext.'</font></p>');
1203: return;
1204: }
1205: } else {
1206: $r->print('<p><font color="red">'.&mt('No map selected.').'</font></p>');
1207: }
1.53 www 1208: }
1.16 www 1209: }
1210: # ---------------------------------------------------------------- End commands
1.7 www 1211: # ---------------------------------------------------------------- Print screen
1.10 www 1212: my $idx=0;
1.148 www 1213: my $shown=0;
1.10 www 1214: $r->print('<table>');
1215: foreach (@Apache::lonratedt::order) {
1216: my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
1.207 albertel 1217: $name=&Apache::lonratsrv::qtescape($name);
1218: $url=&Apache::lonratsrv::qtescape($url);
1.10 www 1219: unless ($name) { $name=(split(/\//,$url))[-1]; }
1.148 www 1220: unless ($name) { $idx++; next; }
1.112 raeburn 1221: $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));
1.10 www 1222: $idx++;
1.148 www 1223: $shown++;
1.10 www 1224: }
1.148 www 1225: unless ($shown) {
1.131 www 1226: $r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
1227: }
1.168 www 1228: $r->print("\n</table>\n");
1.174 albertel 1229: if ($env{'form.markedcopy_url'}) {
1.168 www 1230: $r->print(<<ENDPASTE);
1231: <p><form name="pasteform" action="/adm/coursedocs" method="post">
1.174 albertel 1232: <input type="hidden" name="markedcopy_url" value="$env{'form.markedcopy_url'}" />
1233: <input type="hidden" name="markedcopy_title" value="$env{'form.markedcopy_title'}" />
1.168 www 1234: ENDPASTE
1235: $r->print(
1236: '<input type="submit" name="pastemarked" value="'.&mt('Paste').
1237: '" /> '.&Apache::loncommon::filedescription(
1.174 albertel 1238: (split(/\./,$env{'form.markedcopy_url'}))[-1]).': '.
1239: $env{'form.markedcopy_title'});
1.168 www 1240: if ($container eq 'page') {
1241: $r->print(<<PAGEINFO);
1.174 albertel 1242: <input type="hidden" name="pagepath" value="$env{'form.pagepath'}" />
1243: <input type="hidden" name="pagesymb" value="$env{'form.pagesymb'}" />
1.168 www 1244: PAGEINFO
1245: } else {
1246: $r->print(<<FOLDERINFO);
1.174 albertel 1247: <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
1.168 www 1248: FOLDERINFO
1249: }
1250: $r->print('</form></p>');
1251: }
1.7 www 1252: }
1253: }
1.1 www 1254:
1.188 raeburn 1255: sub process_file_upload {
1.194 raeburn 1256: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
1.188 raeburn 1257: # upload a file, if present
1258: my $parseaction;
1.190 albertel 1259: if ($env{'form.parserflag'}) {
1.188 raeburn 1260: $parseaction = 'parse';
1261: }
1262: my $phase_status;
1263: my $folder=$env{'form.folder'};
1.194 raeburn 1264: if ($folder eq '') {
1.188 raeburn 1265: $folder='default';
1266: }
1.194 raeburn 1267: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
1.188 raeburn 1268: my $errtext='';
1269: my $fatal=0;
1270: my $container='sequence';
1271: if ($env{'form.pagepath'}) {
1272: $container='page';
1273: }
1274: ($errtext,$fatal)=
1275: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1276: if ($#Apache::lonratedt::order<1) {
1277: $Apache::lonratedt::order[0]=1;
1278: $Apache::lonratedt::resources[1]='';
1279: }
1280: if ($fatal) {
1281: return 'failed';
1282: }
1283: my $destination = 'docs/';
1.194 raeburn 1284: if ($folder =~ /^supplemental/) {
1285: $destination = 'supplemental/';
1286: }
1287: if (($folder eq 'default') || ($folder eq 'supplemental')) {
1.188 raeburn 1288: $destination .= 'default/';
1.194 raeburn 1289: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
1290: $destination .= $2.'/';
1.188 raeburn 1291: }
1292: # this is for a course, not a user, so set coursedoc flag
1293: # probably the only place in the system where this should be "1"
1294: my $newidx=&Apache::lonratedt::getresidx();
1295: $destination .= $newidx;
1.190 albertel 1296: my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination,
1297: $parseaction,$allfiles,
1298: $codebase);
1.188 raeburn 1299: my $ext='false';
1300: if ($url=~/^http\:\/\//) { $ext='true'; }
1301: $url=~s/\:/\:/g;
1302: my $comment=$env{'form.comment'};
1303: $comment=~s/\</\<\;/g;
1304: $comment=~s/\>/\>\;/g;
1305: $comment=~s/\:/\:/g;
1306: if ($folder=~/^supplemental/) {
1307: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1308: $env{'user.domain'}.'___&&&___'.$comment;
1309: }
1310:
1311: $Apache::lonratedt::resources[$newidx]=
1312: $comment.':'.$url.':'.$ext.':normal:res';
1.190 albertel 1313: $Apache::lonratedt::order[$#Apache::lonratedt::order+1]= $newidx;
1314: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1315: $folder.'.'.$container);
1.188 raeburn 1316: if ($fatal) {
1317: $$upload_output .= '<p><font color="red">'.$errtext.'</font></p>';
1318: return 'failed';
1319: } else {
1320: if ($parseaction eq 'parse') {
1.190 albertel 1321: my $total_embedded = keys(%{$allfiles});
1.188 raeburn 1322: if ($total_embedded > 0) {
1323: my $num = 0;
1324: $$upload_output .= 'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />
1325: <form name="upload_embedded" action="/adm/coursedocs"
1326: method="post" enctype="multipart/form-data">
1327: <input type="hidden" name="folderpath" value="'.$env{'form.folderpath'}.'" /> <input type="hidden" name="cmd" value="upload_embedded" />
1328: <input type="hidden" name="newidx" value="'.$newidx.'" />
1.228 ! www 1329: <input type="hidden" name="primaryurl" value="'.&escape($url).'" />
1.188 raeburn 1330: <input type="hidden" name="phasetwo" value="'.$total_embedded.'" />';
1331: $$upload_output .= '<b>Upload embedded files</b>:<br />
1332: <table>';
1.190 albertel 1333: foreach my $embed_file (keys(%{$allfiles})) {
1.188 raeburn 1334: $$upload_output .= '<tr><td>'.$embed_file.
1.190 albertel 1335: '<input name="embedded_item_'.$num.'" type="file" />
1.228 ! www 1336: <input name="embedded_orig_'.$num.'" type="hidden" value="'.&escape($embed_file).'" />';
1.188 raeburn 1337: my $attrib;
1338: if (@{$$allfiles{$embed_file}} > 1) {
1339: $attrib = join(':',@{$$allfiles{$embed_file}});
1340: } else {
1341: $attrib = $$allfiles{$embed_file}[0];
1342: }
1343: $$upload_output .=
1344: '<input name="embedded_attrib_'.$num.'" type="hidden" value="'.$attrib.'" />';
1345: if (exists($$codebase{$embed_file})) {
1346: $$upload_output .=
1.228 ! www 1347: '<input name="codebase_'.$num.'" type="hidden" value="'.&escape($$codebase{$embed_file}).'" />';
1.188 raeburn 1348: }
1349: $$upload_output .= '</td></tr>';
1350: $num ++;
1351: }
1352: $phase_status = 'phasetwo';
1353: $$upload_output .= '</table><br />
1354: <input type ="submit" value="Complete upload" />
1355: </form>';
1356: } else {
1357: $$upload_output .= 'No embedded items identified<br />';
1358: }
1359: }
1360: }
1361: }
1362: return $phase_status;
1363: }
1364:
1365: sub process_secondary_uploads {
1366: my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
1367: my $folder=$env{'form.folder'};
1368: my $destination = 'docs/';
1.195 raeburn 1369: if ($folder =~ /^supplemental/) {
1370: $destination = 'supplemental/';
1371: }
1372: if (($folder eq 'default') || ($folder eq 'supplemental')) {
1.188 raeburn 1373: $destination .= 'default/';
1.195 raeburn 1374: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
1.217 raeburn 1375: $destination .= $2.'/';
1.188 raeburn 1376: }
1377: $destination .= $newidx;
1378: my ($url,$filename);
1379: $url=&Apache::lonnet::userfileupload($formname.$num,1,$destination);
1380: ($filename) = ($url =~ m-^/uploaded/$coursedom/$coursenum/$destination/(.+)$-);
1381: return $filename;
1382: }
1383:
1.8 www 1384: # --------------------------------------------------------------- An entry line
1385:
1386: sub entryline {
1.112 raeburn 1387: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
1.38 www 1388: $title=~s/\&colon\;/\:/g;
1389: $title=&HTML::Entities::encode(&HTML::Entities::decode(
1.228 ! www 1390: &unescape($title)),'"<>&\'');
1.38 www 1391: my $renametitle=$title;
1392: my $foldertitle=$title;
1.142 raeburn 1393: my $pagetitle=$title;
1.122 www 1394: my $orderidx=$Apache::lonratedt::order[$index];
1.109 albertel 1395: if ($title=~ /^(\d+)___&&&___(\w+)___&&&___(\w+)___&&&___(.*)$/ ) {
1396: $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
1397: $renametitle=$4;
1398: $title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '.
1399: &Apache::loncommon::plainname($2,$3).': <br />'.
1400: $foldertitle;
1401: }
1.222 albertel 1402: $renametitle=~s/\\/\\\\/g;
1.38 www 1403: $renametitle=~s/\"\;/\\\"/g;
1.8 www 1404: my $line='<tr>';
1405: # Edit commands
1.142 raeburn 1406: my $container;
1.120 www 1407: my $folderpath;
1.174 albertel 1408: if ($env{'form.folderpath'}) {
1.142 raeburn 1409: $container = 'sequence';
1.228 ! www 1410: $folderpath=&escape($env{'form.folderpath'});
1.174 albertel 1411: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
1.120 www 1412: }
1.156 albertel 1413: my ($pagepath,$pagesymb);
1.174 albertel 1414: if ($env{'form.pagepath'}) {
1.142 raeburn 1415: $container = 'page';
1.228 ! www 1416: $pagepath=&escape($env{'form.pagepath'});
! 1417: $pagesymb=&escape($env{'form.pagesymb'});
1.142 raeburn 1418: }
1.168 www 1419: my $cpinfo='';
1.174 albertel 1420: if ($env{'form.markedcopy_url'}) {
1.168 www 1421: $cpinfo='&markedcopy_url='.
1.228 ! www 1422: &escape($env{'form.markedcopy_url'}).
1.168 www 1423: '&markedcopy_title='.
1.228 ! www 1424: &escape($env{'form.markedcopy_title'});
1.168 www 1425: }
1.109 albertel 1426: if ($allowed) {
1.123 www 1427: my $incindex=$index+1;
1428: my $selectbox='';
1.168 www 1429: if (($folder!~/^supplemental/) &&
1430: ($#Apache::lonratedt::order>0) &&
1431: ((split(/\:/,
1432: $Apache::lonratedt::resources[$Apache::lonratedt::order[0]]))[1]
1433: ne '') &&
1434: ((split(/\:/,
1435: $Apache::lonratedt::resources[$Apache::lonratedt::order[1]]))[1]
1436: ne '')) {
1.123 www 1437: $selectbox=
1.124 www 1438: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.123 www 1439: '<select name="newpos" onChange="this.form.submit()">';
1440: for (my $i=1;$i<=$#Apache::lonratedt::order+1;$i++) {
1441: if ($i==$incindex) {
1442: $selectbox.='<option value="" selected="1">('.$i.')</option>';
1443: } else {
1444: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
1445: }
1446: }
1447: $selectbox.='</select>';
1448: }
1.119 www 1449: my %lt=&Apache::lonlocal::texthash(
1450: 'up' => 'Move Up',
1.109 albertel 1451: 'dw' => 'Move Down',
1452: 'rm' => 'Remove',
1.171 www 1453: 'ct' => 'Cut',
1.168 www 1454: 'rn' => 'Rename',
1455: 'cp' => 'Copy');
1.211 www 1456: my $nocopy=0;
1457: if ($url=~/\.(page|sequence)$/) {
1458: foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url))) {
1459: my ($title,$url,$ext,$type)=split(/\:/,$_);
1460: if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
1461: $nocopy=1;
1462: last;
1463: }
1464: }
1465: }
1466: my $copylink=' ';
1.174 albertel 1467: if ($env{'form.pagepath'}) {
1.211 www 1468: unless ($nocopy) {
1469: $copylink=(<<ENDCOPY);
1470: <a href='javascript:markcopy("$pagepath","$index","$renametitle","page","$pagesymb");'>
1471: <font size="-2" color="#000099">$lt{'cp'}</font></a></td>
1472: ENDCOPY
1473: }
1.142 raeburn 1474: $line.=(<<END);
1475: <form name="entry_$index" action="/adm/coursedocs" method="post">
1.174 albertel 1476: <input type="hidden" name="pagepath" value="$env{'form.pagepath'}" />
1477: <input type="hidden" name="pagesymb" value="$env{'form.pagesymb'}" />
1478: <input type="hidden" name="markedcopy_url" value="$env{'form.markedcopy_url'}" />
1479: <input type="hidden" name="markedcopy_title" value="$env{'form.markedcopy_title'}" />
1.142 raeburn 1480: <input type="hidden" name="setparms" value="$orderidx" />
1481: <td><table border='0' cellspacing='2' cellpadding='0'>
1482: <tr><td bgcolor="#DDDDDD">
1.168 www 1483: <a href='/adm/coursedocs?cmd=up_$index&pagepath=$pagepath&pagesymb=$pagesymb$cpinfo'>
1.142 raeburn 1484: <img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
1485: <tr><td bgcolor="#DDDDDD">
1.168 www 1486: <a href='/adm/coursedocs?cmd=down_$index&pagepath=$pagepath&pagesymb=$pagesymb$cpinfo'>
1.142 raeburn 1487: <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
1488: </table></td>
1489: <td>$selectbox
1490: </td><td bgcolor="#DDDDDD">
1.156 albertel 1491: <a href='javascript:removeres("$pagepath","$index","$renametitle","page","$pagesymb");'>
1.142 raeburn 1492: <font size="-2" color="#990000">$lt{'rm'}</font></a>
1.171 www 1493: <a href='javascript:cutres("$pagepath","$index","$renametitle","page","$pagesymb");'>
1494: <font size="-2" color="#550044">$lt{'ct'}</font></a>
1.213 albertel 1495: <a href='javascript:changename("$pagepath","$index","$renametitle","page","$pagesymb");'>
1.168 www 1496: <font size="-2" color="#009900">$lt{'rn'}</font></a>
1.211 www 1497: $copylink
1.142 raeburn 1498: END
1499: } else {
1.211 www 1500: unless ($nocopy) {
1501: $copylink=(<<ENDCOPY);
1502: <a href='javascript:markcopy("$folderpath","$index","$renametitle","sequence");'>
1503: <font size="-2" color="#000099">$lt{'cp'}</font></a></td>
1504: ENDCOPY
1505: }
1.142 raeburn 1506: $line.=(<<END);
1.121 www 1507: <form name="entry_$index" action="/adm/coursedocs" method="post">
1.174 albertel 1508: <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
1509: <input type="hidden" name="markedcopy_url" value="$env{'form.markedcopy_url'}" />
1510: <input type="hidden" name="markedcopy_title" value="$env{'form.markedcopy_title'}" />
1.122 www 1511: <input type="hidden" name="setparms" value="$orderidx" />
1.54 www 1512: <td><table border='0' cellspacing='2' cellpadding='0'>
1513: <tr><td bgcolor="#DDDDDD">
1.168 www 1514: <a href='/adm/coursedocs?cmd=up_$index&folderpath=$folderpath$cpinfo'>
1.90 www 1515: <img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
1.54 www 1516: <tr><td bgcolor="#DDDDDD">
1.168 www 1517: <a href='/adm/coursedocs?cmd=down_$index&folderpath=$folderpath$cpinfo'>
1.90 www 1518: <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
1.123 www 1519: </table></td>
1520: <td>$selectbox
1521: </td><td bgcolor="#DDDDDD">
1.142 raeburn 1522: <a href='javascript:removeres("$folderpath","$index","$renametitle","sequence");'>
1.90 www 1523: <font size="-2" color="#990000">$lt{'rm'}</font></a>
1.171 www 1524: <a href='javascript:cutres("$folderpath","$index","$renametitle","sequence");'>
1525: <font size="-2" color="#550044">$lt{'ct'}</font></a>
1.142 raeburn 1526: <a href='javascript:changename("$folderpath","$index","$renametitle","sequence");'>
1.168 www 1527: <font size="-2" color="#009900">$lt{'rn'}</font></a>
1.211 www 1528: $copylink
1.8 www 1529: END
1.142 raeburn 1530: }
1.8 www 1531: }
1.16 www 1532: # Figure out what kind of a resource this is
1533: my ($extension)=($url=~/\.(\w+)$/);
1534: my $uploaded=($url=~/^\/*uploaded\//);
1.97 albertel 1535: my $icon=&Apache::loncommon::icon($url);
1.17 www 1536: my $isfolder=0;
1.142 raeburn 1537: my $ispage=0;
1.114 albertel 1538: my $folderarg;
1.142 raeburn 1539: my $pagearg;
1540: my $pagefile;
1.16 www 1541: if ($uploaded) {
1.135 albertel 1542: if ($extension eq 'sequence') {
1543: $icon=$iconpath.'/folder_closed.gif';
1544: $url=~/$coursenum\/([\/\w]+)\.sequence$/;
1545: $url='/adm/coursedocs?';
1546: $folderarg=$1;
1547: $isfolder=1;
1.142 raeburn 1548: } elsif ($extension eq 'page') {
1549: $icon=$iconpath.'/page.gif';
1550: $url=~/$coursenum\/([\/\w]+)\.page$/;
1551: $pagearg=$1;
1552: $url='/adm/coursedocs?';
1553: $ispage=1;
1.135 albertel 1554: } else {
1555: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
1556: }
1.16 www 1557: }
1.215 albertel 1558: $url=~s-^http(\&colon\;|:)//-/adm/wrapper/ext/-;
1.142 raeburn 1559: if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
1.113 albertel 1560: my $symb=&Apache::lonnet::symbclean(
1.50 www 1561: &Apache::lonnet::declutter('uploaded/'.
1.174 albertel 1562: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
1563: $env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
1.50 www 1564: '.sequence').
1565: '___'.$residx.'___'.
1.113 albertel 1566: &Apache::lonnet::declutter($url));
1567: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
1568: $url=&Apache::lonnet::clutter($url);
1.127 albertel 1569: if ($url=~/^\/*uploaded\//) {
1570: $url=~/\.(\w+)$/;
1571: my $embstyle=&Apache::loncommon::fileembstyle($1);
1572: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
1573: $url='/adm/wrapper'.$url;
1574: } elsif ($embstyle eq 'ssi') {
1575: #do nothing with these
1576: } elsif ($url!~/\.(sequence|page)$/) {
1577: $url='/adm/coursedocs/showdoc'.$url;
1578: }
1.145 albertel 1579: } elsif ($url=~m|^/ext/|) {
1580: $url='/adm/wrapper'.$url;
1.127 albertel 1581: }
1.228 ! www 1582: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
1.152 albertel 1583: if ($container eq 'page') {
1.174 albertel 1584: my $symb=$env{'form.pagesymb'};
1.152 albertel 1585:
1586: $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
1.228 ! www 1587: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
1.152 albertel 1588: }
1.50 www 1589: }
1.120 www 1590: my $parameterset=' ';
1.216 albertel 1591: if ($isfolder || $extension eq 'sequence') {
1.228 ! www 1592: my $foldername=&escape($foldertitle);
1.174 albertel 1593: my $folderpath=$env{'form.folderpath'};
1.114 albertel 1594: if ($folderpath) { $folderpath.='&' };
1595: $folderpath.=$folderarg.'&'.$foldername;
1.228 ! www 1596: $url.='folderpath='.&escape($folderpath).$cpinfo;
1.147 matthew 1597: $parameterset='<label>'.&mt('Randomly Pick: ').
1.165 www 1598: '<input type="text" size="4" onChange="this.form.submit()" name="randpick_'.$orderidx.'" value="'.
1.147 matthew 1599: (&Apache::lonratedt::getparameter($orderidx,
1600: 'parameter_randompick'))[0].
1.165 www 1601: '" />'.
1602: '<font size="-2"><a href="javascript:void(0)">'.&mt('Store').'</a></font></label>';
1.147 matthew 1603:
1.114 albertel 1604: }
1.142 raeburn 1605: if ($ispage) {
1.228 ! www 1606: my $pagename=&escape($pagetitle);
1.142 raeburn 1607: my $pagepath;
1.174 albertel 1608: my $folderpath=$env{'form.folderpath'};
1.142 raeburn 1609: if ($folderpath) { $pagepath = $folderpath.'&' };
1610: $pagepath.=$pagearg.'&'.$pagename;
1.174 albertel 1611: my $symb=$env{'form.pagesymb'};
1.152 albertel 1612: if (!$symb) {
1613: my $path='uploaded/'.
1.174 albertel 1614: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
1615: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
1.152 albertel 1616: $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
1617: $residx,
1618: $path.$pagearg.'.page');
1619: }
1.228 ! www 1620: $url.='pagepath='.&escape($pagepath).
! 1621: '&pagesymb='.&escape($symb).$cpinfo;
1.142 raeburn 1622: }
1.113 albertel 1623: $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon.
1624: '" border="0"></a></td>'.
1.212 foxr 1625: "<td bgcolor='#FFFFBB'><a href=\"$url\">$title</a></td>";
1.120 www 1626: if (($allowed) && ($folder!~/^supplemental/)) {
1627: my %lt=&Apache::lonlocal::texthash(
1628: 'hd' => 'Hidden',
1.165 www 1629: 'ec' => 'URL hidden');
1.122 www 1630: my $enctext=
1631: ((&Apache::lonratedt::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':'');
1632: my $hidtext=
1633: ((&Apache::lonratedt::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':'');
1.120 www 1634: $line.=(<<ENDPARMS);
1635: <td bgcolor="#BBBBFF"><font size='-2'>
1.165 www 1636: <nobr><label><input type="checkbox" name="hidprs_$orderidx" onClick="this.form.submit()" $hidtext /> $lt{'hd'}</label></nobr></td>
1.149 albertel 1637: <td bgcolor="#BBBBFF"><font size='-2'>
1.165 www 1638: <nobr><label><input type="checkbox" name="encprs_$orderidx" onClick="this.form.submit()" $enctext /> $lt{'ec'}</label></nobr></td>
1.120 www 1639: <td bgcolor="#BBBBFF"><font size="-2">$parameterset</font></td>
1640: ENDPARMS
1.119 www 1641: }
1.120 www 1642: $line.="</form></tr>";
1.8 www 1643: return $line;
1644: }
1645:
1.27 www 1646: # ---------------------------------------------------------------- tie the hash
1647:
1648: sub tiehash {
1.136 albertel 1649: my ($mode)=@_;
1.27 www 1650: $hashtied=0;
1.174 albertel 1651: if ($env{'request.course.fn'}) {
1.136 albertel 1652: if ($mode eq 'write') {
1.174 albertel 1653: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
1.136 albertel 1654: &GDBM_WRCREAT(),0640)) {
1655: $hashtied=2;
1656: }
1657: } else {
1.174 albertel 1658: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
1.136 albertel 1659: &GDBM_READER(),0640)) {
1.27 www 1660: $hashtied=1;
1.136 albertel 1661: }
1662: }
1.27 www 1663: }
1664: }
1665:
1666: sub untiehash {
1667: if ($hashtied) { untie %hash; }
1668: $hashtied=0;
1.221 albertel 1669: return OK;
1.27 www 1670: }
1671:
1.29 www 1672: # --------------------------------------------------------------- check on this
1673:
1674: sub checkonthis {
1675: my ($r,$url,$level,$title)=@_;
1.228 ! www 1676: $url=&unescape($url);
1.29 www 1677: $alreadyseen{$url}=1;
1678: $r->rflush();
1.41 www 1679: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
1.108 albertel 1680: $r->print("\n<br />");
1.29 www 1681: for (my $i=0;$i<=$level*5;$i++) {
1682: $r->print(' ');
1683: }
1684: $r->print('<a href="'.$url.'" target="cat">'.
1685: ($title?$title:$url).'</a> ');
1686: if ($url=~/^\/res\//) {
1687: my $result=&Apache::lonnet::repcopy(
1688: &Apache::lonnet::filelocation('',$url));
1.172 raeburn 1689: if ($result eq 'ok') {
1.87 www 1690: $r->print('<font color="green">'.&mt('ok').'</font>');
1.29 www 1691: $r->rflush();
1.34 www 1692: &Apache::lonnet::countacc($url);
1693: $url=~/\.(\w+)$/;
1694: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
1695: $r->print('<br />');
1696: $r->rflush();
1697: for (my $i=0;$i<=$level*5;$i++) {
1698: $r->print(' ');
1699: }
1.84 www 1700: $r->print('- '.&mt('Rendering').': ');
1.170 www 1701: my ($errorcount,$warningcount)=split(/:/,
1702: &Apache::lonnet::ssi_body($url,
1.173 albertel 1703: ('grade_target'=>'web',
1704: 'return_only_error_and_warning_counts' => 1)));
1.170 www 1705: if (($errorcount) ||
1706: ($warningcount)) {
1707: if ($errorcount) {
1.98 www 1708: $r->print('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'.
1.170 www 1709: $errorcount.' '.
1.87 www 1710: &mt('error(s)').'</b></font> ');
1.34 www 1711: }
1.170 www 1712: if ($warningcount) {
1.34 www 1713: $r->print('<font color="blue">'.
1.170 www 1714: $warningcount.' '.
1.84 www 1715: &mt('warning(s)').'</font>');
1.34 www 1716: }
1717: } else {
1.87 www 1718: $r->print('<font color="green">'.&mt('ok').'</font>');
1.34 www 1719: }
1720: $r->rflush();
1721: }
1.29 www 1722: my $dependencies=
1723: &Apache::lonnet::metadata($url,'dependencies');
1724: foreach (split(/\,/,$dependencies)) {
1725: if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
1726: &checkonthis($r,$_,$level+1);
1727: }
1728: }
1.172 raeburn 1729: } elsif ($result eq 'unavailable') {
1.84 www 1730: $r->print('<font color="red"><b>'.&mt('connection down').'</b></font>');
1.172 raeburn 1731: } elsif ($result eq 'not_found') {
1.100 www 1732: unless ($url=~/\$/) {
1733: $r->print('<font color="red"><b>'.&mt('not found').'</b></font>');
1734: } else {
1735: $r->print('<font color="yellow"><b>'.&mt('unable to verify variable URL').'</b></font>');
1736: }
1.29 www 1737: } else {
1.84 www 1738: $r->print('<font color="red"><b>'.&mt('access denied').'</b></font>');
1.29 www 1739: }
1740: }
1741: }
1742: }
1743:
1.1 www 1744:
1.75 www 1745: #
1.208 albertel 1746: # ----------------------------------------------------------------- List Symbs
1747: #
1748: sub list_symbs {
1.224 albertel 1749: my ($r) = @_;
1750:
1751: $r->print(&Apache::loncommon::start_page('Symb List'));
1752: my $navmap = Apache::lonnavmaps::navmap->new();
1753: $r->print("<pre>\n");
1754: foreach my $res ($navmap->retrieveResources()) {
1755: $r->print($res->compTitle()."\t".$res->symb()."\n");
1756: }
1757: $r->print("\n</pre>\n");
1758: $r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>');
1.208 albertel 1759: }
1760:
1761:
1762: #
1.75 www 1763: # -------------------------------------------------------------- Verify Content
1764: #
1765: sub verifycontent {
1.224 albertel 1766: my ($r) = @_;
1.26 www 1767: my $loaderror=&Apache::lonnet::overloaderror($r);
1768: if ($loaderror) { return $loaderror; }
1.224 albertel 1769: $r->print(&Apache::loncommon::start_page('Verify Course Documents'));
1.27 www 1770: $hashtied=0;
1.30 www 1771: undef %alreadyseen;
1772: %alreadyseen=();
1.27 www 1773: &tiehash();
1774: foreach (keys %hash) {
1.140 www 1775: if ($hash{$_}=~/\.(page|sequence)$/) {
1.228 ! www 1776: if (($_=~/^src_/) && ($alreadyseen{&unescape($hash{$_})})) {
1.140 www 1777: $r->print('<hr /><font color="red">'.
1778: &mt('The following sequence or page is included more than once in your course: ').
1.228 ! www 1779: &unescape($hash{$_}).'</font><br />'.
1.140 www 1780: &mt('Note that grading records for problems included in this sequence or folder will overlap.<hr />'));
1781: }
1782: }
1.228 ! www 1783: if (($_=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$_})})) {
1.29 www 1784: &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
1.27 www 1785: }
1786: }
1787: &untiehash();
1.108 albertel 1788: $r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'.
1789: &mt('Return to DOCS').'</a>');
1.75 www 1790: }
1791:
1.192 www 1792:
1.75 www 1793: # -------------------------------------------------------------- Check Versions
1794:
1.192 www 1795: sub devalidateversioncache {
1796: my $src=shift;
1797: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
1798: &Apache::lonnet::clutter($src));
1799: }
1800:
1.75 www 1801: sub checkversions {
1.224 albertel 1802: my ($r) = @_;
1803: $r->print(&Apache::loncommon::start_page('Check Course Document Versions'));
1.89 www 1804: my $header='';
1805: my $startsel='';
1806: my $monthsel='';
1807: my $weeksel='';
1808: my $daysel='';
1809: my $allsel='';
1810: my %changes=();
1811: my $starttime=0;
1.91 www 1812: my $haschanged=0;
1.92 www 1813: my %setversions=&Apache::lonnet::dump('resourceversions',
1.174 albertel 1814: $env{'course.'.$env{'request.course.id'}.'.domain'},
1815: $env{'course.'.$env{'request.course.id'}.'.num'});
1.92 www 1816:
1817: $hashtied=0;
1818: &tiehash();
1819: my %newsetversions=();
1.174 albertel 1820: if ($env{'form.setmostrecent'}) {
1.91 www 1821: $haschanged=1;
1.92 www 1822: foreach (keys %hash) {
1823: if ($_=~/^ids\_(\/res\/.+)$/) {
1.93 www 1824: $newsetversions{$1}='mostrecent';
1.192 www 1825: &devalidateversioncache($1);
1.92 www 1826: }
1827: }
1.174 albertel 1828: } elsif ($env{'form.setcurrent'}) {
1.91 www 1829: $haschanged=1;
1.92 www 1830: foreach (keys %hash) {
1831: if ($_=~/^ids\_(\/res\/.+)$/) {
1.93 www 1832: my $getvers=&Apache::lonnet::getversion($1);
1833: if ($getvers>0) {
1834: $newsetversions{$1}=$getvers;
1.192 www 1835: &devalidateversioncache($1);
1.93 www 1836: }
1.92 www 1837: }
1838: }
1.174 albertel 1839: } elsif ($env{'form.setversions'}) {
1.91 www 1840: $haschanged=1;
1.174 albertel 1841: foreach (keys %env) {
1.92 www 1842: if ($_=~/^form\.set_version_(.+)$/) {
1843: my $src=$1;
1.174 albertel 1844: if (($env{$_}) && ($env{$_} ne $setversions{$src})) {
1845: $newsetversions{$src}=$env{$_};
1.192 www 1846: &devalidateversioncache($src);
1.92 www 1847: }
1848: }
1849: }
1.91 www 1850: }
1851: if ($haschanged) {
1.92 www 1852: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
1.174 albertel 1853: $env{'course.'.$env{'request.course.id'}.'.domain'},
1854: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
1.92 www 1855: $r->print('<h1>'.&mt('Your Version Settings have been Stored').'</h1>');
1856: } else {
1857: $r->print('<h1><font color="red">'.&mt('An Error Occured while Attempting to Store your Version Settings').'</font></h1>');
1858: }
1.136 albertel 1859: &mark_hash_old();
1.91 www 1860: }
1.136 albertel 1861: &changewarning($r,'');
1.174 albertel 1862: if ($env{'form.timerange'} eq 'all') {
1.89 www 1863: # show all documents
1864: $header=&mt('All Documents in Course');
1.91 www 1865: $allsel=1;
1.90 www 1866: foreach (keys %hash) {
1867: if ($_=~/^ids\_(\/res\/.+)$/) {
1868: my $src=$1;
1869: $changes{$src}=1;
1870: }
1871: }
1.89 www 1872: } else {
1873: # show documents which changed
1874: %changes=&Apache::lonnet::dump
1.174 albertel 1875: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
1876: $env{'course.'.$env{'request.course.id'}.'.num'});
1.89 www 1877: my $firstkey=(keys %changes)[0];
1878: unless ($firstkey=~/^error\:/) {
1.174 albertel 1879: unless ($env{'form.timerange'}) {
1880: $env{'form.timerange'}=604800;
1.89 www 1881: }
1.174 albertel 1882: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
1.89 www 1883: .&mt('seconds');
1.174 albertel 1884: if ($env{'form.timerange'}==-1) {
1.89 www 1885: $seltext='since start of course';
1886: $startsel='selected';
1.174 albertel 1887: $env{'form.timerange'}=time;
1.89 www 1888: }
1.174 albertel 1889: $starttime=time-$env{'form.timerange'};
1890: if ($env{'form.timerange'}==2592000) {
1.89 www 1891: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1892: $monthsel='selected';
1.174 albertel 1893: } elsif ($env{'form.timerange'}==604800) {
1.89 www 1894: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1895: $weeksel='selected';
1.174 albertel 1896: } elsif ($env{'form.timerange'}==86400) {
1.89 www 1897: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1898: $daysel='selected';
1899: }
1900: $header=&mt('Content changed').' '.$seltext;
1901: } else {
1902: $header=&mt('No content modifications yet.');
1903: }
1904: }
1.92 www 1905: %setversions=&Apache::lonnet::dump('resourceversions',
1.174 albertel 1906: $env{'course.'.$env{'request.course.id'}.'.domain'},
1907: $env{'course.'.$env{'request.course.id'}.'.num'});
1.89 www 1908: my %lt=&Apache::lonlocal::texthash
1.88 www 1909: ('st' => 'Version changes since start of Course',
1910: 'lm' => 'Version changes since last Month',
1911: 'lw' => 'Version changes since last Week',
1912: 'sy' => 'Version changes since Yesterday',
1.91 www 1913: 'al' => 'All Resources (possibly large output)',
1.88 www 1914: 'sd' => 'Display',
1.84 www 1915: 'fi' => 'File',
1916: 'md' => 'Modification Date',
1.87 www 1917: 'mr' => 'Most recently published Version',
1918: 've' => 'Version used in Course',
1.91 www 1919: 'vu' => 'Set Version to be used in Course',
1920: 'sv' => 'Set Versions to be used in Course according to Selections below',
1921: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
1922: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.84 www 1923: 'di' => 'Differences');
1.89 www 1924: $r->print(<<ENDHEADERS);
1.31 www 1925: <form action="/adm/coursedocs" method="post">
1.91 www 1926: <input type="hidden" name="versions" value="1" />
1927: <input type="submit" name="setmostrecent" value="$lt{'sm'}" />
1928: <input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
1.31 www 1929: <select name="timerange">
1.88 www 1930: <option value='all' $allsel>$lt{'al'}</option>
1.84 www 1931: <option value="-1" $startsel>$lt{'st'}</option>
1932: <option value="2592000" $monthsel>$lt{'lm'}</option>
1933: <option value="604800" $weeksel>$lt{'lw'}</option>
1934: <option value="86400" $daysel>$lt{'sy'}</option>
1.31 www 1935: </select>
1.91 www 1936: <input type="submit" name="display" value="$lt{'sd'}" />
1.89 www 1937: <h3>$header</h3>
1.91 www 1938: <input type="submit" name="setversions" value="$lt{'sv'}" />
1.103 matthew 1939: <table border="0">
1.31 www 1940: ENDHEADERS
1.91 www 1941: foreach (sort keys %changes) {
1.89 www 1942: if ($changes{$_}>$starttime) {
1943: my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
1944: my $currentversion=&Apache::lonnet::getversion($_);
1.93 www 1945: if ($currentversion<0) {
1946: $currentversion=&mt('Could not be determined.');
1947: }
1.89 www 1948: my $linkurl=&Apache::lonnet::clutter($_);
1949: $r->print(
1.103 matthew 1950: '<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
1.91 www 1951: &Apache::lonnet::gettitle($linkurl).
1.103 matthew 1952: '</b></font></td></tr>'.
1953: '<tr><td> </td>'.
1954: '<td colspan="4">'.
1955: '<a href="'.$linkurl.'" target="cat">'.$linkurl.
1956: '</a></td></tr>'.
1957: '<tr><td></td>'.
1958: '<td title="'.$lt{'md'}.'">'.
1.102 matthew 1959: &Apache::lonlocal::locallocaltime(
1960: &Apache::lonnet::metadata($root.'.'.$extension,
1961: 'lastrevisiondate')
1962: ).
1.103 matthew 1963: '</td>'.
1964: '<td title="'.$lt{'mr'}.'"><nobr>Most Recent: '.
1965: '<font size="+1">'.$currentversion.'</font>'.
1966: '</nobr></td>'.
1967: '<td title="'.$lt{'ve'}.'"><nobr>In Course: '.
1968: '<font size="+1">');
1.87 www 1969: # Used in course
1.89 www 1970: my $usedversion=$hash{'version_'.$linkurl};
1.93 www 1971: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.89 www 1972: $r->print($usedversion);
1973: } else {
1974: $r->print($currentversion);
1975: }
1.103 matthew 1976: $r->print('</font></nobr></td><td title="'.$lt{'vu'}.'">'.
1977: '<nobr>Use: ');
1.87 www 1978: # Set version
1.92 www 1979: $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
1.89 www 1980: 'set_version_'.$linkurl,
1.136 albertel 1981: ('select_form_order' =>
1982: ['',1..$currentversion,'mostrecent'],
1983: '' => '',
1.93 www 1984: 'mostrecent' => 'most recent',
1.89 www 1985: map {$_,$_} (1..$currentversion))));
1.103 matthew 1986: $r->print('</nobr></td></tr><tr><td></td>');
1.89 www 1987: my $lastold=1;
1988: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
1989: my $url=$root.'.'.$prevvers.'.'.$extension;
1990: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
1991: $starttime) {
1992: $lastold=$prevvers;
1993: }
1994: }
1.103 matthew 1995: #
1996: # Code to figure out how many version entries should go in
1997: # each of the four columns
1998: my $entries_per_col = 0;
1999: my $num_entries = ($currentversion-$lastold);
2000: if ($num_entries % 4 == 0) {
2001: $entries_per_col = $num_entries/4;
2002: } else {
2003: $entries_per_col = $num_entries/4 + 1;
2004: }
2005: my $entries_count = 0;
2006: $r->print('<td valign="top"><font size="-2">');
2007: my $cols_output = 1;
1.32 www 2008: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
1.89 www 2009: my $url=$root.'.'.$prevvers.'.'.$extension;
1.103 matthew 2010: $r->print('<nobr><a href="'.&Apache::lonnet::clutter($url).
1.91 www 2011: '">'.&mt('Version').' '.$prevvers.'</a> ('.
1.103 matthew 2012: &Apache::lonlocal::locallocaltime(
2013: &Apache::lonnet::metadata($url,
2014: 'lastrevisiondate')
2015: ).
1.91 www 2016: ')');
1.89 www 2017: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
1.33 www 2018: $r->print(' <a href="/adm/diff?filename='.
1.89 www 2019: &Apache::lonnet::clutter($root.'.'.$extension).
2020: '&versionone='.$prevvers.
2021: '">'.&mt('Diffs').'</a>');
2022: }
1.103 matthew 2023: $r->print('</nobr><br />');
2024: if (++$entries_count % $entries_per_col == 0) {
2025: $r->print('</font></td>');
2026: if ($cols_output != 4) {
2027: $r->print('<td valign="top"><font size="-2">');
2028: $cols_output++;
2029: }
2030: }
1.89 www 2031: }
1.103 matthew 2032: while($cols_output++ < 4) {
2033: $r->print('</font></td><td><font>')
2034: }
2035: $r->print('</font></td></tr>'."\n");
1.89 www 2036: }
2037: }
1.92 www 2038: $r->print('</table></form>');
1.89 www 2039: $r->print('<h1>'.&mt('Done').'.</h1>');
2040:
2041: &untiehash();
1.75 www 2042: }
2043:
1.136 albertel 2044: sub mark_hash_old {
2045: my $retie_hash=0;
2046: if ($hashtied) {
2047: $retie_hash=1;
2048: &untiehash();
2049: }
2050: &tiehash('write');
2051: $hash{'old'}=1;
2052: &untiehash();
2053: if ($retie_hash) { &tiehash(); }
2054: }
2055:
2056: sub is_hash_old {
2057: my $untie_hash=0;
2058: if (!$hashtied) {
2059: $untie_hash=1;
2060: &tiehash();
2061: }
2062: my $return=$hash{'old'};
2063: if ($untie_hash) { &untiehash(); }
2064: return $return;
2065: }
2066:
1.91 www 2067: sub changewarning {
1.177 albertel 2068: my ($r,$postexec,$message,$url)=@_;
1.136 albertel 2069: if (!&is_hash_old()) { return; }
1.150 albertel 2070: my $pathvar='folderpath';
1.228 ! www 2071: my $path=&escape($env{'form.folderpath'});
1.177 albertel 2072: if (!defined($url)) {
2073: if (defined($env{'form.pagepath'})) {
2074: $pathvar='pagepath';
1.228 ! www 2075: $path=&escape($env{'form.pagepath'});
! 2076: $path.='&pagesymb='.&escape($env{'form.pagesymb'});
1.177 albertel 2077: }
2078: $url='/adm/coursedocs?'.$pathvar.'='.$path;
2079: }
2080: if (!defined($message)) {
2081: $message='Changes will become active for your current session after [_1], or the next time you log in.';
1.150 albertel 2082: }
1.185 www 2083: $r->print("\n\n".
2084: '<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'."\n".
2085: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.177 albertel 2086: '<input type="hidden" name="orgurl" value="'.$url.
1.117 albertel 2087: '" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'.
1.177 albertel 2088: &mt($message,' <input type="hidden" name="'.
2089: $env{'request.role'}.'" value="1" /><input type="button" value="'.
2090: &mt('re-initializing course').'" onClick="reinit(this.form)" />').
1.185 www 2091: $help{'Caching'}.'</font></h3></form>'."\n\n");
1.91 www 2092: }
2093:
1.75 www 2094: # ================================================================ Main Handler
2095: sub handler {
2096: my $r = shift;
1.82 www 2097: &Apache::loncommon::content_type($r,'text/html');
1.75 www 2098: $r->send_http_header;
2099: return OK if $r->header_only;
2100:
2101: # --------------------------------------------- Initialize help topics for this
1.209 albertel 2102: foreach ('Adding_Course_Doc','Main_Course_Documents',
2103: 'Adding_External_Resource','Navigate_Content',
2104: 'Adding_Folders','Docs_Overview', 'Load_Map',
2105: 'Supplemental','Score_Upload_Form','Adding_Pages',
2106: 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
2107: 'Check_Resource_Versions','Verify_Content') {
2108: $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
2109: }
1.75 www 2110: # Composite help files
2111: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
2112: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
2113: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
2114: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
1.86 albertel 2115: $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
2116: 'Option_Response_Simple');
1.75 www 2117: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
2118: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
2119: $help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
2120: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
2121: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.142 raeburn 2122:
1.209 albertel 2123: # does this user have privileges to modify docs
2124: my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
2125:
2126: if ($allowed && $env{'form.verify'}) {
1.75 www 2127: &verifycontent($r);
1.209 albertel 2128: } elsif ($allowed && $env{'form.listsymbs'}) {
1.208 albertel 2129: &list_symbs($r);
1.209 albertel 2130: } elsif ($allowed && $env{'form.versions'}) {
1.75 www 2131: &checkversions($r);
1.209 albertel 2132: } elsif ($allowed && $env{'form.dumpcourse'}) {
1.75 www 2133: &dumpcourse($r);
1.209 albertel 2134: } elsif ($allowed && $env{'form.exportcourse'}) {
1.138 raeburn 2135: &exportcourse($r);
1.26 www 2136: } else {
1.7 www 2137: # is this a standard course?
2138:
1.174 albertel 2139: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.155 raeburn 2140: my $forcestandard = 0;
1.15 www 2141: my $forcesupplement;
2142: my $script='';
1.19 www 2143: my $showdoc=0;
1.142 raeburn 2144: my $containertag;
2145: my $uploadtag;
1.15 www 2146: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.224 albertel 2147: ['folderpath','pagepath',
2148: 'pagesymb','markedcopy_url',
2149: 'markedcopy_title']);
1.174 albertel 2150: if ($env{'form.folderpath'}) {
2151: my (@folderpath)=split('&',$env{'form.folderpath'});
1.228 ! www 2152: $env{'form.foldername'}=&unescape(pop(@folderpath));
1.174 albertel 2153: $env{'form.folder'}=pop(@folderpath);
2154: }
2155: if ($env{'form.pagepath'}) {
2156: my (@pagepath)=split('&',$env{'form.pagepath'});
1.228 ! www 2157: $env{'form.pagename'}=&unescape(pop(@pagepath));
1.174 albertel 2158: $env{'form.folder'}=pop(@pagepath);
1.156 albertel 2159: $containertag = '<input type="hidden" name="pagepath" value="" />'.
2160: '<input type="hidden" name="pagesymb" value="" />';
1.174 albertel 2161: $uploadtag = '<input type="hidden" name="pagepath" value="'.$env{'form.pagepath'}.'" />'.
2162: '<input type="hidden" name="pagesymb" value="'.$env{'form.pagesymb'}.'" />';
1.142 raeburn 2163: }
1.21 www 2164: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
1.127 albertel 2165: $showdoc='/'.$1;
1.21 www 2166: }
2167: unless ($showdoc) { # got called from remote
1.174 albertel 2168: if (($env{'form.folder'}=~/^default_/) ||
1.209 albertel 2169: ($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) {
1.155 raeburn 2170: $forcestandard = 1;
2171: }
1.174 albertel 2172: $forcesupplement=($env{'form.folder'}=~/^supplemental_/);
1.7 www 2173:
1.15 www 2174: if ($allowed) {
2175: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
2176: $script=&Apache::lonratedt::editscript('simple');
2177: }
2178: } else { # got called in sequence from course
2179: $allowed=0;
1.3 www 2180: }
1.4 www 2181:
2182: # get course data
1.174 albertel 2183: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
2184: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
1.4 www 2185:
1.225 albertel 2186: # get personal data
1.174 albertel 2187: my $uname=$env{'user.name'};
2188: my $udom=$env{'user.domain'};
1.228 ! www 2189: my $plainname=&escape(
1.14 www 2190: &Apache::loncommon::plainname($uname,$udom));
2191:
1.8 www 2192: # graphics settings
1.4 www 2193:
1.176 albertel 2194: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
1.8 www 2195:
1.224 albertel 2196: if ($allowed) {
2197: $script .= &editing_js($udom,$uname);
1.171 www 2198: }
1.42 www 2199: # -------------------------------------------------------------------- Body tag
1.224 albertel 2200: $script = '<script type="text/javascript">'."\n".$script."\n".'</script>';
2201: $r->print(&Apache::loncommon::start_page('Course Documents', $script,
1.225 albertel 2202: {'force_register' => $showdoc,}).
1.224 albertel 2203: &Apache::loncommon::help_open_menu('','','','',273,'RAT'));
2204:
1.188 raeburn 2205: my %allfiles = ();
2206: my %codebase = ();
2207: my ($upload_result,$upload_output);
2208: if ($allowed) {
2209: if (($env{'form.uploaddoc.filename'}) && ($env{'form.cmd'}=~/^upload_(\w+)/)) {
2210: # Process file upload - phase one - upload and parse primary file.
1.190 albertel 2211: $upload_result = &process_file_upload(\$upload_output,$coursenum,
2212: $coursedom,\%allfiles,
1.194 raeburn 2213: \%codebase,$1);
1.188 raeburn 2214: if ($upload_result eq 'phasetwo') {
2215: $r->print($upload_output);
2216: }
2217: } elsif ($env{'form.phasetwo'}) {
2218: my %newname = ();
2219: my %origname = ();
2220: my %attribs = ();
2221: my $updateflag = 0;
2222: my $residx = $env{'form.newidx'};
1.228 ! www 2223: my $primary_url = &unescape($env{'form.primaryurl'});
1.188 raeburn 2224: # Process file upload - phase two - gather secondary files.
2225: for (my $i=0; $i<$env{'form.phasetwo'}; $i++) {
2226: if ($env{'form.embedded_item_'.$i.'.filename'}) {
2227: my $javacodebase;
2228: $newname{$i} = &process_secondary_uploads(\$upload_output,$coursedom,$coursenum,'embedded_item_',$i,$residx);
1.228 ! www 2229: $origname{$i} = &unescape($env{'form.embedded_orig_'.$i});
1.188 raeburn 2230: if (exists($env{'form.embedded_codebase_'.$i})) {
1.228 ! www 2231: $javacodebase = &unescape($env{'form.embedded_codebase_'.$i});
1.188 raeburn 2232: $origname{$i} =~ s#^\Q$javacodebase\E/##;
2233: }
2234: my @attributes = ();
2235: if ($env{'form.embedded_attrib_'.$i} =~ /:/) {
2236: @attributes = split/:/,$env{'form.embedded_attrib_'.$i};
2237: } else {
2238: @attributes = ($env{'form.embedded_attrib_'.$i});
2239: }
2240: foreach (@attributes) {
1.228 ! www 2241: push(@{$attribs{$i}},&unescape($_));
1.188 raeburn 2242: }
2243: if ($javacodebase) {
2244: $codebase{$i} = $javacodebase;
2245: $codebase{$i} =~ s#/$##;
2246: $updateflag = 1;
2247: }
2248: }
2249: unless ($newname{$i} eq $origname{$i}) {
2250: $updateflag = 1;
2251: }
2252: }
2253: # Process file upload - phase three - modify primary file
2254: if ($updateflag) {
2255: my ($content,$rtncode);
2256: my $updateflag = 0;
2257: my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode);
2258: if ($getstatus eq 'ok') {
2259: foreach my $item (keys %newname) {
2260: if ($newname{$item} ne $origname{$item}) {
2261: my $attrib_regexp = '';
2262: if (@{$attribs{$item}} > 1) {
2263: $attrib_regexp = join('|',@{$attribs{$item}});
2264: } else {
2265: $attrib_regexp = $attribs{$item}[0];
2266: }
2267: if ($content =~ m#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#) {
2268: }
2269: $content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi;
2270: }
2271: if (exists($codebase{$item})) {
1.224 albertel 2272: $content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; #' stupid emacs
1.188 raeburn 2273: }
2274: }
2275: # Save edited file.
2276: my $saveresult;
2277: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
2278: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
1.191 raeburn 2279: my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult);
1.188 raeburn 2280: } else {
2281: &Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus);
2282: }
2283: }
2284: }
2285: }
2286:
2287: unless ($showdoc || $upload_result eq 'phasetwo') {
1.81 www 2288: # -----------------------------------------------------------------------------
2289: my %lt=&Apache::lonlocal::texthash(
2290: 'uplm' => 'Upload a new main course document',
2291: 'upls' => 'Upload a new supplemental course document',
1.168 www 2292: 'impp' => 'Import a document',
2293: 'pubd' => 'Published documents',
1.181 www 2294: 'copm' => 'All documents out of a published map into this folder',
1.81 www 2295: 'spec' => 'Special documents',
2296: 'upld' => 'Upload Document',
2297: 'srch' => 'Search',
2298: 'impo' => 'Import',
2299: 'selm' => 'Select Map',
2300: 'load' => 'Load Map',
1.186 www 2301: 'reco' => 'Recover Deleted Resources',
1.81 www 2302: 'newf' => 'New Folder',
1.142 raeburn 2303: 'newp' => 'New Composite Page',
1.81 www 2304: 'extr' => 'External Resource',
2305: 'syll' => 'Syllabus',
2306: 'navc' => 'Navigate Contents',
2307: 'sipa' => 'Simple Page',
2308: 'sipr' => 'Simple Problem',
1.219 www 2309: 'drbx' => 'Drop Box',
1.81 www 2310: 'scuf' => 'Score Upload Form',
2311: 'bull' => 'Bulletin Board',
1.96 sakharuk 2312: 'mypi' => 'My Personal Info',
1.101 www 2313: 'abou' => 'About User',
1.110 raeburn 2314: 'imsf' => 'Import IMS package',
1.96 sakharuk 2315: 'file' => 'File',
2316: 'title' => 'Title',
1.188 raeburn 2317: 'comment' => 'Comment',
2318: 'parse' => 'If HTML file, upload embedded images/multimedia files'
1.81 www 2319: );
2320: # -----------------------------------------------------------------------------
1.42 www 2321: if ($allowed) {
1.74 www 2322: my $dumpbut=&dumpbutton();
1.138 raeburn 2323: my $exportbut=&exportbutton();
1.88 www 2324: my %lt=&Apache::lonlocal::texthash(
2325: 'vc' => 'Verify Content',
2326: 'cv' => 'Check/Set Resource Versions',
1.208 albertel 2327: 'ls' => 'List Symbs',
1.88 www 2328: );
1.118 albertel 2329:
1.174 albertel 2330: my $folderpath=$env{'form.folderpath'};
1.118 albertel 2331: if (!$folderpath) {
1.174 albertel 2332: if ($env{'form.folder'} eq '' ||
2333: $env{'form.folder'} eq 'supplemental') {
1.118 albertel 2334: $folderpath='default&'.
1.228 ! www 2335: &escape(&mt('Main Course Documents'));
1.118 albertel 2336: }
2337: }
1.174 albertel 2338: unless ($env{'form.pagepath'}) {
1.142 raeburn 2339: $containertag = '<input type="hidden" name="folderpath" value="" />';
2340: $uploadtag = '<input type="hidden" name="folderpath" value="'.$folderpath.'" />';
2341: }
2342:
1.42 www 2343: $r->print(<<ENDCOURSEVERIFY);
1.36 www 2344: <form name="renameform" method="post" action="/adm/coursedocs">
2345: <input type="hidden" name="title" />
2346: <input type="hidden" name="cmd" />
1.168 www 2347: <input type="hidden" name="markcopy" />
1.142 raeburn 2348: $containertag
1.36 www 2349: </form>
1.39 www 2350: <form name="simpleedit" method="post" action="/adm/coursedocs">
2351: <input type=hidden name="importdetail" value="">
1.142 raeburn 2352: $uploadtag
1.39 www 2353: </form>
1.26 www 2354: <form action="/adm/coursedocs" method="post" name="courseverify">
1.74 www 2355: <table bgcolor="#AAAAAA" width="100%" cellspacing="4" cellpadding="4">
2356: <tr><td bgcolor="#DDDDCC">
1.130 www 2357: <input type="submit" name="verify" value="$lt{'vc'}" />$help{'Verify_Content'}
1.74 www 2358: </td><td bgcolor="#DDDDCC">
1.130 www 2359: <input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'}
1.74 www 2360: $dumpbut
1.138 raeburn 2361: $exportbut
1.218 albertel 2362: </td><td bgcolor="#DDDDCC">
1.208 albertel 2363: <input type="submit" name="listsymbs" value="$lt{'ls'}" />
1.218 albertel 2364: </td></tr></table>
1.25 www 2365: </form>
2366: ENDCOURSEVERIFY
1.74 www 2367: $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
1.96 sakharuk 2368: &mt('Editing the Table of Contents for your Course')));
1.25 www 2369: }
1.17 www 2370: # --------------------------------------------------------- Standard documents
1.43 www 2371: $r->print('<table border=2 cellspacing=4 cellpadding=4>');
1.7 www 2372: if (($standard) && ($allowed) && (!$forcesupplement)) {
1.116 albertel 2373: $r->print('<tr><td bgcolor="#BBBBBB">');
2374: # '<h2>'.&mt('Main Course Documents').
2375: # ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
1.174 albertel 2376: my $folder=$env{'form.folder'};
1.117 albertel 2377: if ($folder eq '' || $folder eq 'supplemental') {
1.112 raeburn 2378: $folder='default';
1.228 ! www 2379: $env{'form.folderpath'}='default&'.&escape(&mt('Main Course Documents'));
1.112 raeburn 2380: }
1.51 www 2381: my $postexec='';
2382: if ($folder eq 'default') {
2383: $r->print('<script>this.window.name="loncapaclient";</script>');
2384: } else {
1.117 albertel 2385: #$postexec='self.close();';
1.51 www 2386: }
1.40 www 2387: $hadchanges=0;
1.188 raeburn 2388: &editor($r,$coursenum,$coursedom,$folder,$allowed,$upload_output);
1.40 www 2389: if ($hadchanges) {
1.136 albertel 2390: &mark_hash_old()
1.40 www 2391: }
1.136 albertel 2392: &changewarning($r,$postexec);
1.16 www 2393: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
2394: '.sequence';
1.142 raeburn 2395: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
2396: '.page';
1.186 www 2397: my $container='sequence';
2398: if ($env{'form.pagepath'}) {
2399: $container='page';
2400: }
2401: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
1.8 www 2402: $r->print(<<ENDFORM);
1.43 www 2403: <table cellspacing=4 cellpadding=4><tr>
1.81 www 2404: <th bgcolor="#DDDDDD">$lt{'uplm'}</th>
2405: <th bgcolor="#DDDDDD">$lt{'impp'}</th>
2406: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
1.11 www 2407: </tr>
1.16 www 2408: <tr><td bgcolor="#DDDDDD">
1.96 sakharuk 2409: $lt{'file'}:<br />
1.182 albertel 2410: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59 www 2411: <input type="file" name="uploaddoc" size="40">
1.8 www 2412: <br />
1.96 sakharuk 2413: $lt{'title'}:<br />
1.11 www 2414: <input type="text" size="50" name="comment">
1.142 raeburn 2415: $uploadtag
1.10 www 2416: <input type="hidden" name="cmd" value="upload_default">
1.188 raeburn 2417: <br />
2418: <nobr>
1.190 albertel 2419: <label>$lt{'parse'}?
1.188 raeburn 2420: <input type="checkbox" name="parserflag" />
1.190 albertel 2421: </label>
1.188 raeburn 2422: </nobr>
2423: <br />
2424: <br />
1.129 albertel 2425: <nobr>
1.81 www 2426: <input type="submit" value="$lt{'upld'}">
1.60 albertel 2427: $help{'Uploading_From_Harddrive'}
1.58 albertel 2428: </nobr>
1.60 albertel 2429: </form>
1.11 www 2430: </td>
1.16 www 2431: <td bgcolor="#DDDDDD">
1.39 www 2432: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
1.168 www 2433: $lt{'pubd'}<br />
1.142 raeburn 2434: $uploadtag
1.115 albertel 2435: <input type=button onClick="javascript:groupsearch()" value="$lt{'srch'}">
1.58 albertel 2436: <nobr>
1.115 albertel 2437: <input type=button onClick="javascript:groupimport();" value="$lt{'impo'}">
1.58 albertel 2438: $help{'Importing_LON-CAPA_Resource'}
2439: </nobr>
1.59 www 2440: <p>
2441: <hr />
1.181 www 2442: $lt{'copm'}<br />
2443: <input type="text" size="40" name="importmap"><br />
1.68 bowersj2 2444: <nobr><input type=button
1.52 www 2445: onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
1.81 www 2446: value="$lt{'selm'}"> <input type="submit" name="loadmap" value="$lt{'load'}">
1.68 bowersj2 2447: $help{'Load_Map'}</nobr>
1.59 www 2448: </p>
1.52 www 2449: </form>
1.186 www 2450: <hr />
2451: <form action="/adm/groupsort" method="post" name="recover">
2452: <input type="button" name="recovermap" onClick="javascript:groupopen('$readfile',1)" value="$lt{'reco'}" />
2453: </form>
1.142 raeburn 2454: ENDFORM
1.174 albertel 2455: unless ($env{'form.pagepath'}) {
1.168 www 2456: $r->print(<<ENDFORM);
2457: <hr />
2458: <form action="/adm/coursedocs" method="post" name="newext">
2459: $uploadtag
2460: <input type=hidden name="importdetail" value="">
2461: <nobr>
2462: <input name="newext" type="button" onClick="javascript:makenewext('newext');"
2463: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
2464: </nobr>
2465: </form>
1.214 www 2466: <br /><form action="/adm/imsimportdocs" method="post" name="ims">
1.168 www 2467: <input type="hidden" name="folder" value="$folder" />
2468: <input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
2469: </nobr>
2470: </form>
2471: ENDFORM
2472: }
2473: $r->print('</td><td bgcolor="#DDDDDD">');
1.174 albertel 2474: unless ($env{'form.pagepath'}) {
1.142 raeburn 2475: $r->print(<<ENDFORM);
1.214 www 2476: <br /><form action="/adm/coursedocs" method="post" name="newfolder">
1.174 albertel 2477: <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
1.13 www 2478: <input type=hidden name="importdetail" value="">
1.58 albertel 2479: <nobr>
1.16 www 2480: <input name="newfolder" type="button"
2481: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.81 www 2482: value="$lt{'newf'}" />$help{'Adding_Folders'}
1.58 albertel 2483: </nobr>
1.11 www 2484: </form>
1.214 www 2485: <br /><form action="/adm/coursedocs" method="post" name="newpage">
1.174 albertel 2486: <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
1.142 raeburn 2487: <input type=hidden name="importdetail" value="">
2488: <nobr>
2489: <input name="newpage" type="button"
2490: onClick="javascript:makenewpage(this.form,'$pageseq');"
2491: value="$lt{'newp'}" />$help{'Adding_Pages'}
2492: </nobr>
2493: </form>
1.214 www 2494: <br /><form action="/adm/coursedocs" method="post" name="newsyl">
1.142 raeburn 2495: $uploadtag
1.14 www 2496: <input type=hidden name="importdetail"
2497: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58 albertel 2498: <nobr>
1.81 www 2499: <input name="newsyl" type="submit" value="$lt{'syll'}" />
1.65 bowersj2 2500: $help{'Syllabus'}
1.58 albertel 2501: </nobr>
2502: </form>
1.214 www 2503: <br /><form action="/adm/coursedocs" method="post" name="newnav">
1.142 raeburn 2504: $uploadtag
1.15 www 2505: <input type=hidden name="importdetail"
2506: value="Navigate Content=/adm/navmaps">
1.58 albertel 2507: <nobr>
1.81 www 2508: <input name="newnav" type="submit" value="$lt{'navc'}" />
1.47 www 2509: $help{'Navigate_Content'}
1.58 albertel 2510: </nobr>
1.22 www 2511: </form>
1.214 www 2512: <br /><form action="/adm/coursedocs" method="post" name="newsmppg">
1.142 raeburn 2513: $uploadtag
1.22 www 2514: <input type=hidden name="importdetail" value="">
1.58 albertel 2515: <nobr>
1.81 www 2516: <input name="newsmppg" type="button" value="$lt{'sipa'}"
1.65 bowersj2 2517: onClick="javascript:makesmppage();" /> $help{'Simple Page'}
1.58 albertel 2518: </nobr>
1.55 www 2519: </form>
1.214 www 2520: <br /><form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.142 raeburn 2521: $uploadtag
1.55 www 2522: <input type=hidden name="importdetail" value="">
1.58 albertel 2523: <nobr>
1.81 www 2524: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
1.65 bowersj2 2525: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
1.62 www 2526: </nobr>
2527: </form>
1.219 www 2528: <br /><form action="/adm/coursedocs" method="post" name="newdropbox">
2529: $uploadtag
2530: <input type=hidden name="importdetail" value="">
2531: <nobr>
2532: <input name="newdropbox" type="button" value="$lt{'drbx'}"
2533: onClick="javascript:makedropbox();" />
2534: </nobr>
2535: </form>
1.214 www 2536: <br /><form action="/adm/coursedocs" method="post" name="newexamupload">
1.142 raeburn 2537: $uploadtag
1.62 www 2538: <input type=hidden name="importdetail" value="">
2539: <nobr>
1.81 www 2540: <input name="newexamupload" type="button" value="$lt{'scuf'}"
1.62 www 2541: onClick="javascript:makeexamupload();" />
1.66 bowersj2 2542: $help{'Score_Upload_Form'}
1.58 albertel 2543: </nobr>
1.22 www 2544: </form>
1.214 www 2545: <br /><form action="/adm/coursedocs" method="post" name="newbul">
1.142 raeburn 2546: $uploadtag
1.22 www 2547: <input type=hidden name="importdetail" value="">
1.58 albertel 2548: <nobr>
1.81 www 2549: <input name="newbulletin" type="button" value="$lt{'bull'}"
1.22 www 2550: onClick="javascript:makebulboard();" />
1.65 bowersj2 2551: $help{'Bulletin Board'}
1.58 albertel 2552: </nobr>
2553: </form>
1.214 www 2554: <br /><form action="/adm/coursedocs" method="post" name="newaboutme">
1.142 raeburn 2555: $uploadtag
1.14 www 2556: <input type=hidden name="importdetail"
2557: value="$plainname=/adm/$udom/$uname/aboutme">
1.58 albertel 2558: <nobr>
1.81 www 2559: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.65 bowersj2 2560: $help{'My Personal Info'}
1.101 www 2561: </nobr>
2562: </form>
1.214 www 2563: <br /><form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.142 raeburn 2564: $uploadtag
1.101 www 2565: <input type=hidden name="importdetail" value="">
2566: <nobr>
2567: <input name="newaboutsomeone" type="button" value="$lt{'abou'}"
2568: onClick="javascript:makeabout();" />
1.110 raeburn 2569: </nobr>
1.182 albertel 2570: </form>
1.142 raeburn 2571: ENDFORM
2572: }
1.174 albertel 2573: if ($env{'form.pagepath'}) {
1.142 raeburn 2574: $r->print(<<ENDBLOCK);
2575: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
2576: $uploadtag
2577: <input type=hidden name="importdetail" value="">
2578: <nobr>
2579: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
2580: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
2581: </nobr>
2582: </form>
1.214 www 2583: <br /><form action="/adm/coursedocs" method="post" name="newexamupload">
1.142 raeburn 2584: $uploadtag
2585: <input type=hidden name="importdetail" value="">
2586: <nobr>
2587: <input name="newexamupload" type="button" value="$lt{'scuf'}"
2588: onClick="javascript:makeexamupload();" />
2589: $help{'Score_Upload_Form'}
2590: </nobr>
1.182 albertel 2591: </form>
1.142 raeburn 2592: ENDBLOCK
2593: }
2594: $r->print('</td></tr>'."\n".
2595: '</table>');
1.24 www 2596: $r->print('</td></tr>');
1.7 www 2597: }
2598: # ----------------------------------------------------- Supplemental documents
2599: if (!$forcestandard) {
1.116 albertel 2600: $r->print('<tr><td bgcolor="#BBBBBB">');
2601: # '<h2>'.&mt('Supplemental Course Documents').
2602: # ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
1.174 albertel 2603: my $folder=$env{'form.folder'};
1.117 albertel 2604: unless ($folder=~/^supplemental/) {
1.116 albertel 2605: $folder='supplemental';
1.117 albertel 2606: }
2607: if ($folder =~ /^supplemental$/ &&
1.174 albertel 2608: $env{'form.folderpath'} =~ /^default\&/) {
2609: $env{'form.folderpath'}='supplemental&'.
1.228 ! www 2610: &escape(&mt('Supplemental Course Documents'));
1.116 albertel 2611: }
1.7 www 2612: &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.8 www 2613: if ($allowed) {
1.17 www 2614: my $folderseq=
2615: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
2616: '.sequence';
2617:
1.8 www 2618: $r->print(<<ENDSUPFORM);
1.43 www 2619: <table cellspacing=4 cellpadding=4><tr>
1.81 www 2620: <th bgcolor="#DDDDDD">$lt{'upls'}</th>
2621: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
1.17 www 2622: </tr>
2623: <tr><td bgcolor="#DDDDDD">
1.10 www 2624: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59 www 2625: <input type="file" name="uploaddoc" size="40">
1.196 raeburn 2626: <br />
2627: <br />
2628: <nobr>
2629: <label>$lt{'parse'}?
2630: <input type="checkbox" name="parserflag" />
2631: </label>
2632: </nobr>
2633: <br /><br />
2634: $lt{'comment'}:<br />
1.4 www 2635: <textarea cols=50 rows=4 name='comment'>
2636: </textarea>
1.115 albertel 2637: <br />
1.174 albertel 2638: <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
1.10 www 2639: <input type="hidden" name="cmd" value="upload_supplemental">
1.58 albertel 2640: <nobr>
1.81 www 2641: <input type="submit" value="$lt{'upld'}">
1.58 albertel 2642: $help{'Uploading_From_Harddrive'}
2643: </nobr>
2644: </form>
1.17 www 2645: </td>
2646: <td bgcolor="#DDDDDD">
1.18 www 2647: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.174 albertel 2648: <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
1.17 www 2649: <input type=hidden name="importdetail" value="">
1.58 albertel 2650: <nobr>
1.17 www 2651: <input name="newfolder" type="button"
2652: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.81 www 2653: value="$lt{'newf'}" /> $help{'Adding_Folders'}
1.58 albertel 2654: </nobr>
1.17 www 2655: </form>
1.214 www 2656: <br /><form action="/adm/coursedocs" method="post" name="supnewext">
1.174 albertel 2657: <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
1.17 www 2658: <input type=hidden name="importdetail" value="">
1.58 albertel 2659: <nobr>
1.18 www 2660: <input name="newext" type="button"
2661: onClick="javascript:makenewext('supnewext');"
1.81 www 2662: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
1.58 albertel 2663: </nobr>
1.17 www 2664: </form>
1.214 www 2665: <br /><form action="/adm/coursedocs" method="post" name="supnewsyl">
1.174 albertel 2666: <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
1.17 www 2667: <input type=hidden name="importdetail"
2668: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58 albertel 2669: <nobr>
1.81 www 2670: <input name="newsyl" type="submit" value="$lt{'syll'}" />
1.65 bowersj2 2671: $help{'Syllabus'}
1.58 albertel 2672: </nobr>
2673: </form>
1.214 www 2674: <br /><form action="/adm/coursedocs" method="post" name="subnewaboutme">
1.174 albertel 2675: <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
1.17 www 2676: <input type=hidden name="importdetail"
2677: value="$plainname=/adm/$udom/$uname/aboutme">
1.58 albertel 2678: <nobr>
1.81 www 2679: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.65 bowersj2 2680: $help{'My Personal Info'}
1.58 albertel 2681: </nobr>
2682: </form>
1.17 www 2683: </td></tr>
1.24 www 2684: </table></td></tr>
1.8 www 2685: ENDSUPFORM
2686: }
1.7 www 2687: }
1.18 www 2688: if ($allowed) {
1.182 albertel 2689: $r->print('<form method="POST" name="extimport" action="/adm/coursedocs"><input type="hidden" name="title" /><input type="hidden" name="url" /><input type="hidden" name="useform" /></form>');
1.18 www 2690: }
1.24 www 2691: $r->print('</table>');
1.19 www 2692: } else {
1.188 raeburn 2693: unless ($upload_result eq 'phasetwo') {
1.19 www 2694: # -------------------------------------------------------- This is showdoc mode
1.188 raeburn 2695: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.141 albertel 2696: &Apache::lonnet::gettitle($r->uri).'</h1><p>'.
1.81 www 2697: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><p><table>".
1.188 raeburn 2698: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table></p>');
2699: }
1.19 www 2700: }
1.26 www 2701: }
1.224 albertel 2702: $r->print(&Apache::loncommon::end_page());
1.26 www 2703: return OK;
1.1 www 2704: }
2705:
1.224 albertel 2706:
2707: sub editing_js {
2708: my ($udom,$uname) = @_;
2709: my $now = time();
2710:
2711: return <<ENDNEWSCRIPT;
2712: function makenewfolder(targetform,folderseq) {
2713: var foldername=prompt('Name of New Folder','New Folder');
2714: if (foldername) {
2715: targetform.importdetail.value=foldername+"="+folderseq;
2716: targetform.submit();
2717: }
2718: }
2719:
2720: function makenewpage(targetform,folderseq) {
2721: var pagename=prompt('Name of New Page','New Page');
2722: if (pagename) {
2723: targetform.importdetail.value=pagename+"="+folderseq;
2724: targetform.submit();
2725: }
2726: }
2727:
2728: function makenewext(targetname) {
2729: this.document.forms.extimport.useform.value=targetname;
2730: window.open('/adm/rat/extpickframe.html');
2731: }
2732:
2733: function makeexamupload() {
2734: var title=prompt('Listed Title for the Uploaded Score');
2735: if (title) {
2736: this.document.forms.newexamupload.importdetail.value=
2737: title+'=/res/lib/templates/examupload.problem';
2738: this.document.forms.newexamupload.submit();
2739: }
2740: }
2741:
2742: function makesmppage() {
2743: var title=prompt('Listed Title for the Page');
2744: if (title) {
2745: this.document.forms.newsmppg.importdetail.value=
2746: title+'=/adm/$udom/$uname/$now/smppg';
2747: this.document.forms.newsmppg.submit();
2748: }
2749: }
2750:
2751: function makesmpproblem() {
2752: var title=prompt('Listed Title for the Problem');
2753: if (title) {
2754: this.document.forms.newsmpproblem.importdetail.value=
2755: title+'=/res/lib/templates/simpleproblem.problem';
2756: this.document.forms.newsmpproblem.submit();
2757: }
2758: }
2759:
2760: function makedropbox() {
2761: var title=prompt('Listed Title for the Drop Box');
2762: if (title) {
2763: this.document.forms.newdropbox.importdetail.value=
2764: title+'=/res/lib/templates/DropBox.problem';
2765: this.document.forms.newdropbox.submit();
2766: }
2767: }
2768:
2769: function makebulboard() {
2770: var title=prompt('Listed Title for the Bulletin Board');
2771: if (title) {
2772: this.document.forms.newbul.importdetail.value=
2773: title+'=/adm/$udom/$uname/$now/bulletinboard';
2774: this.document.forms.newbul.submit();
2775: }
2776: }
2777:
2778: function makeabout() {
2779: var user=prompt("Enter user\@domain for User's 'About Me' Page");
2780: if (user) {
2781: var comp=new Array();
2782: comp=user.split('\@');
2783: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
2784: if ((comp[0]) && (comp[1])) {
2785: this.document.forms.newaboutsomeone.importdetail.value=
2786: 'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
2787: this.document.forms.newaboutsomeone.submit();
2788: } else {
2789: alert("Not a valid user\@domain");
2790: }
2791: } else {
2792: alert("Please enter both user and domain in the format user\@domain");
2793: }
2794: }
2795: }
2796:
2797: function makeims() {
2798: var caller = document.forms.ims.folder.value;
2799: var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
2800: newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
2801: newWindow.location.href = newlocation;
2802: }
2803:
2804:
2805: function finishpick() {
2806: var title=this.document.forms.extimport.title.value;
2807: var url=this.document.forms.extimport.url.value;
2808: var form=this.document.forms.extimport.useform.value;
2809: eval
2810: ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
2811: '";this.document.forms.'+form+'.submit();');
2812: }
2813:
2814: function changename(folderpath,index,oldtitle,container,pagesymb) {
2815: var title=prompt('New Title',oldtitle);
2816: if (title) {
2817: this.document.forms.renameform.title.value=title;
2818: this.document.forms.renameform.cmd.value='rename_'+index;
2819: if (container == 'sequence') {
2820: this.document.forms.renameform.folderpath.value=folderpath;
2821: }
2822: if (container == 'page') {
2823: this.document.forms.renameform.pagepath.value=folderpath;
2824: this.document.forms.renameform.pagesymb.value=pagesymb;
2825: }
2826: this.document.forms.renameform.submit();
2827: }
2828: }
2829:
2830: function removeres(folderpath,index,oldtitle,container,pagesymb) {
2831: if (confirm('WARNING: Removing a resource makes associated grades and scores inaccessible!\\nRemove "'+oldtitle+'"?')) {
2832: this.document.forms.renameform.cmd.value='del_'+index;
2833: if (container == 'sequence') {
2834: this.document.forms.renameform.folderpath.value=folderpath;
2835: }
2836: if (container == 'page') {
2837: this.document.forms.renameform.pagepath.value=folderpath;
2838: this.document.forms.renameform.pagesymb.value=pagesymb;
2839: }
2840: this.document.forms.renameform.submit();
2841: }
2842: }
2843:
2844: function cutres(folderpath,index,oldtitle,container,pagesymb) {
2845: if (confirm('WARNING: Cutting a resource makes associated grades and scores inaccessible!\\nGrades remain inaccessible if resource is pasted into another folder.\\nCut "'+oldtitle+'"?')) {
2846: this.document.forms.renameform.cmd.value='cut_'+index;
2847: this.document.forms.renameform.markcopy.value=index;
2848: if (container == 'sequence') {
2849: this.document.forms.renameform.folderpath.value=folderpath;
2850: }
2851: if (container == 'page') {
2852: this.document.forms.renameform.pagepath.value=folderpath;
2853: this.document.forms.renameform.pagesymb.value=pagesymb;
2854: }
2855: this.document.forms.renameform.submit();
2856: }
2857: }
2858:
2859: function markcopy(folderpath,index,oldtitle,container,pagesymb) {
2860: this.document.forms.renameform.markcopy.value=index;
2861: if (container == 'sequence') {
2862: this.document.forms.renameform.folderpath.value=folderpath;
2863: }
2864: if (container == 'page') {
2865: this.document.forms.renameform.pagepath.value=folderpath;
2866: this.document.forms.renameform.pagesymb.value=pagesymb;
2867: }
2868: this.document.forms.renameform.submit();
2869: }
2870:
2871: ENDNEWSCRIPT
2872: }
1.1 www 2873: 1;
2874: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>