Annotation of loncom/interface/londocs.pm, revision 1.499
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.499 ! raeburn 4: # $Id: londocs.pm,v 1.498 2012/10/02 18:08:12 bisitz Exp $
1.329 droeschl 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::londocs;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use Apache::imsexport;
34: use Apache::lonnet;
35: use Apache::loncommon;
1.383 tempelho 36: use Apache::lonhtmlcommon;
1.329 droeschl 37: use LONCAPA::map();
38: use Apache::lonratedt();
39: use Apache::lonxml;
40: use Apache::lonclonecourse;
41: use Apache::lonnavmaps;
1.472 raeburn 42: use Apache::lonnavdisplay();
1.488 raeburn 43: use Apache::lonuserstate();
1.329 droeschl 44: use HTML::Entities;
1.488 raeburn 45: use HTML::TokeParser;
1.329 droeschl 46: use GDBM_File;
47: use Apache::lonlocal;
48: use Cwd;
49: use LONCAPA qw(:DEFAULT :match);
50:
51: my $iconpath;
52:
53: my %hash;
54:
55: my $hashtied;
56: my %alreadyseen=();
57:
58: my $hadchanges;
59:
60:
61: my %help=();
62:
63:
64: sub mapread {
65: my ($coursenum,$coursedom,$map)=@_;
66: return
67: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
68: $map);
69: }
70:
71: sub storemap {
1.492 raeburn 72: my ($coursenum,$coursedom,$map,$contentchg)=@_;
73: my $report;
74: if (($contentchg) && ($map =~ /^default/)) {
75: $report = 1;
76: }
1.329 droeschl 77: my ($outtext,$errtext)=
78: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.492 raeburn 79: $map,1,$report);
1.329 droeschl 80: if ($errtext) { return ($errtext,2); }
1.364 bisitz 81:
1.329 droeschl 82: $hadchanges=1;
83: return ($errtext,0);
84: }
85:
86:
87:
88: sub authorhosts {
89: my %outhash=();
90: my $home=0;
91: my $other=0;
92: foreach my $key (keys(%env)) {
93: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
94: my $role=$1;
95: my $realm=$2;
96: my ($start,$end)=split(/\./,$env{$key});
97: if (($start) && ($start>time)) { next; }
98: if (($end) && (time>$end)) { next; }
99: my ($ca,$cd);
100: if ($1 eq 'au') {
101: $ca=$env{'user.name'};
102: $cd=$env{'user.domain'};
103: } else {
104: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
105: }
106: my $allowed=0;
107: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
108: my @ids=&Apache::lonnet::current_machine_ids();
1.484 raeburn 109: foreach my $id (@ids) {
110: if ($id eq $myhome) {
111: $allowed=1;
112: last;
113: }
114: }
1.329 droeschl 115: if ($allowed) {
116: $home++;
1.484 raeburn 117: $outhash{'home_'.$ca.':'.$cd}=1;
1.329 droeschl 118: } else {
1.484 raeburn 119: $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329 droeschl 120: $other++;
121: }
122: }
123: }
124: return ($home,$other,%outhash);
125: }
126:
127:
128: sub clean {
129: my ($title)=@_;
130: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 131: return $title;
1.329 droeschl 132: }
133:
134:
135:
136: sub dumpcourse {
137: my ($r) = @_;
1.408 raeburn 138: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 139: $r->print(&Apache::loncommon::start_page('Dump '.$crstype.' Content to Authoring Space')."\n".
140: &Apache::lonhtmlcommon::breadcrumbs('Dump '.$crstype.' Content to Authoring Space')."\n");
141: $r->print(&startContentScreen('tools'));
1.329 droeschl 142: my ($home,$other,%outhash)=&authorhosts();
1.484 raeburn 143: unless ($home) {
144: $r->print(&endContentScreen());
145: return '';
146: }
1.329 droeschl 147: my $origcrsid=$env{'request.course.id'};
148: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
149: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
150: # Do the dumping
1.484 raeburn 151: unless ($outhash{'home_'.$env{'form.authorspace'}}) {
152: $r->print(&endContentScreen());
153: return '';
154: }
1.329 droeschl 155: my ($ca,$cd)=split(/\@/,$env{'form.authorspace'});
156: $r->print('<h3>'.&mt('Copying Files').'</h3>');
157: my $title=$env{'form.authorfolder'};
158: $title=&clean($title);
159: my %replacehash=();
160: foreach my $key (keys(%env)) {
161: if ($key=~/^form\.namefor\_(.+)/) {
162: $replacehash{$1}=$env{$key};
163: }
164: }
165: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
166: $crs=~s/\_/\//g;
167: foreach my $item (keys(%replacehash)) {
168: my $newfilename=$title.'/'.$replacehash{$item};
169: $newfilename=~s/\.(\w+)$//;
170: my $ext=$1;
171: $newfilename=&clean($newfilename);
172: $newfilename.='.'.$ext;
173: my @dirs=split(/\//,$newfilename);
1.462 raeburn 174: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
1.329 droeschl 175: my $makepath=$path;
176: my $fail=0;
177: for (my $i=0;$i<$#dirs;$i++) {
178: $makepath.='/'.$dirs[$i];
1.344 bisitz 179: unless (-e $makepath) {
180: unless(mkdir($makepath,0777)) { $fail=1; }
1.329 droeschl 181: }
182: }
183: $r->print('<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ');
184: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
185: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
186: print $fh &Apache::lonclonecourse::rewritefile(
187: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
188: (%replacehash,$crs => '')
189: );
190: } else {
191: print $fh
192: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
193: }
194: $fh->close();
195: } else {
196: $fail=1;
197: }
198: if ($fail) {
199: $r->print('<span class="LC_error">'.&mt('fail').'</span>');
200: } else {
201: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
202: }
203: }
204: } else {
1.484 raeburn 205: $r->print(&mt('Searching ...').'<br />');
206: $r->rflush();
1.329 droeschl 207: # Input form
1.484 raeburn 208: $r->print('<form name="dumpdoc" action="" method="post">'."\n");
1.329 droeschl 209: unless ($home==1) {
1.484 raeburn 210: $r->print('<div class="LC_left_float">'.
211: '<fieldset><legend>'.
212: &mt('Select the Authoring Space').
213: '</legend><select name="authorspace">');
1.329 droeschl 214: }
215: foreach my $key (sort(keys(%outhash))) {
216: if ($key=~/^home_(.+)$/) {
217: if ($home==1) {
218: $r->print(
219: '<input type="hidden" name="authorspace" value="'.$1.'" />');
220: } else {
221: $r->print('<option value="'.$1.'">'.$1.' - '.
1.484 raeburn 222: &Apache::loncommon::plainname(split(/\:/,$1)).'</option>');
1.329 droeschl 223: }
224: }
225: }
226: unless ($home==1) {
1.484 raeburn 227: $r->print('</select></fieldset></div>'."\n");
1.329 droeschl 228: }
229: my $title=$origcrsdata{'description'};
230: $title=~s/[\/\s]+/\_/gs;
231: $title=&clean($title);
1.484 raeburn 232: $r->print('<div class="LC_left_float">'.
233: '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
234: '<input type="text" size="50" name="authorfolder" value="'.
235: $title.'" />'.
236: '</fieldset></div><br clear="all" />'."\n");
1.329 droeschl 237: &tiehash();
1.484 raeburn 238: $r->print('<h4>'.&mt('Filenames in Authoring Space').'</h4>'
1.329 droeschl 239: .&Apache::loncommon::start_data_table()
240: .&Apache::loncommon::start_data_table_header_row()
241: .'<th>'.&mt('Internal Filename').'</th>'
242: .'<th>'.&mt('Title').'</th>'
243: .'<th>'.&mt('Save as ...').'</th>'
244: .&Apache::loncommon::end_data_table_header_row());
245: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
246: $r->print(&Apache::loncommon::start_data_table_row()
247: .'<td>'.$file.'</td>');
248: my ($ext)=($file=~/\.(\w+)$/);
249: my $title=$hash{'title_'.$hash{
250: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
251: $r->print('<td>'.($title?$title:' ').'</td>');
252: if (!$title) {
253: $title=$file;
254: } else {
255: $title=~s|/|_|g;
256: }
257: $title=~s/\.(\w+)$//;
258: $title=&clean($title);
259: $title.='.'.$ext;
260: $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
261: .&Apache::loncommon::end_data_table_row());
262: }
263: $r->print(&Apache::loncommon::end_data_table());
264: &untiehash();
265: $r->print(
1.484 raeburn 266: '<p><input type="submit" name="dumpcourse" value="'.&mt("Dump $crstype Content").'" /></p></form>');
1.329 droeschl 267: }
1.484 raeburn 268: $r->print(&endContentScreen());
1.329 droeschl 269: }
270:
271: sub group_import {
272: my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
273:
274: while (@files) {
275: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 276: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 277: && ($caller eq 'londocs')
278: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 279:
1.329 droeschl 280: my $errtext = '';
281: my $fatal = 0;
282: my $newmapstr = '<map>'."\n".
283: '<resource id="1" src="" type="start"></resource>'."\n".
284: '<link from="1" to="2" index="1"></link>'."\n".
285: '<resource id="2" src="" type="finish"></resource>'."\n".
286: '</map>';
287: $env{'form.output'}=$newmapstr;
288: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
289: 'output',$1.$2);
290: if ($result != m|^/uploaded/|) {
291: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
292: $fatal = 2;
293: }
294: if ($fatal) {
295: return ($errtext,$fatal);
296: }
297: }
298: if ($url) {
1.344 bisitz 299: if (!$residx
1.329 droeschl 300: || defined($LONCAPA::map::zombies[$residx])) {
301: $residx = &LONCAPA::map::getresidx($url,$residx);
302: push(@LONCAPA::map::order, $residx);
303: }
304: my $ext = 'false';
305: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
306: $url = &LONCAPA::map::qtunescape($url);
307: $name = &LONCAPA::map::qtunescape($name);
1.344 bisitz 308: $LONCAPA::map::resources[$residx] =
1.329 droeschl 309: join(':', ($name, $url, $ext, 'normal', 'res'));
310: }
311: }
1.492 raeburn 312: return &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
1.329 droeschl 313: }
314:
315: sub breadcrumbs {
1.408 raeburn 316: my ($allowed,$crstype)=@_;
1.329 droeschl 317: &Apache::lonhtmlcommon::clear_breadcrumbs();
318: my (@folders);
319: if ($env{'form.pagepath'}) {
320: @folders = split('&',$env{'form.pagepath'});
321: } else {
322: @folders=split('&',$env{'form.folderpath'});
323: }
324: my $folderpath;
325: my $plain='';
326: my $randompick=-1;
327: my $isencrypted=0;
328: my $ishidden=0;
329: my $is_random_order=0;
330: while (@folders) {
331: my $folder=shift(@folders);
332: my $foldername=shift(@folders);
333: if ($folderpath) {$folderpath.='&';}
334: $folderpath.=$folder.'&'.$foldername;
1.472 raeburn 335: my $url;
336: if ($allowed) {
337: $url = '/adm/coursedocs?folderpath=';
338: } else {
339: $url = '/adm/supplemental?folderpath=';
340: }
341: $url .= &escape($folderpath);
342: my $name=&unescape($foldername);
1.344 bisitz 343: # randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername
1.472 raeburn 344: $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;
345: if ($1 ne '') {
346: $randompick=$1;
347: } else {
348: $randompick=-1;
349: }
350: if ($2) { $ishidden=1; }
351: if ($3) { $isencrypted=1; }
352: if ($4 ne '') { $is_random_order = 1; }
353: if ($folder eq 'supplemental') {
354: $name = &mt('Supplemental '.$crstype.' Content');
355: }
356: &Apache::lonhtmlcommon::add_breadcrumb(
1.499 ! raeburn 357: {'href'=>$url,
1.329 droeschl 358: 'title'=>$name,
1.367 droeschl 359: 'text'=>$name,
1.329 droeschl 360: 'no_mt'=>1,
361: });
362: $plain.=$name.' > ';
363: }
364: $plain=~s/\>\;\s*$//;
365: return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
1.472 raeburn 366: undef, undef, 1 ),$randompick,$ishidden,
367: $isencrypted,$plain,$is_random_order);
1.329 droeschl 368: }
369:
370: sub log_docs {
1.494 raeburn 371: return &Apache::lonnet::write_log('course','docslog',@_);
1.329 droeschl 372: }
373:
374: {
375: my @oldresources=();
376: my @oldorder=();
377: my $parmidx;
378: my %parmaction=();
379: my %parmvalue=();
380: my $changedflag;
381:
382: sub snapshotbefore {
383: @oldresources=@LONCAPA::map::resources;
384: @oldorder=@LONCAPA::map::order;
385: $parmidx=undef;
386: %parmaction=();
387: %parmvalue=();
388: $changedflag=0;
389: }
390:
391: sub remember_parms {
392: my ($idx,$parameter,$action,$value)=@_;
393: $parmidx=$idx;
394: $parmaction{$parameter}=$action;
395: $parmvalue{$parameter}=$value;
396: $changedflag=1;
397: }
398:
399: sub log_differences {
400: my ($plain)=@_;
401: my %storehash=('folder' => $plain,
402: 'currentfolder' => $env{'form.folder'});
403: if ($parmidx) {
404: $storehash{'parameter_res'}=$oldresources[$parmidx];
405: foreach my $parm (keys(%parmaction)) {
406: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
407: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
408: }
409: }
410: my $maxidx=$#oldresources;
411: if ($#LONCAPA::map::resources>$#oldresources) {
412: $maxidx=$#LONCAPA::map::resources;
413: }
414: for (my $idx=0; $idx<=$maxidx; $idx++) {
415: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
416: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
417: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
418: $changedflag=1;
419: }
420: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
421: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
422: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
423: $changedflag=1;
424: }
425: }
426: $storehash{'maxidx'}=$maxidx;
427: if ($changedflag) { &log_docs(\%storehash); }
428: }
429: }
430:
431: sub docs_change_log {
1.484 raeburn 432: my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath)=@_;
1.486 raeburn 433: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.483 raeburn 434: my $js = '<script type="text/javascript">'."\n".
435: '// <![CDATA['."\n".
436: &Apache::loncommon::display_filter_js('docslog')."\n".
1.486 raeburn 437: &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag)."\n".
1.483 raeburn 438: &history_tab_js()."\n".
1.484 raeburn 439: &Apache::lonratedt::editscript('simple')."\n".
1.483 raeburn 440: '// ]]>'."\n".
441: '</script>'."\n";
1.484 raeburn 442: $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
443: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
1.489 raeburn 444: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 445: my %orderhash;
446: my $container='sequence';
447: my $pathitem;
448: if ($env{'form.pagepath'}) {
449: $container='page';
450: $pathitem = '<input type="hidden" name="pagepath" value="'.
451: &HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />';
452: } else {
453: my $folderpath=$env{'form.folderpath'};
454: if ($folderpath eq '') {
455: $folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Documents'));
456: }
457: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
458: }
459: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
460: my $jumpto = $readfile;
461: $jumpto =~ s{^/}{};
462: my $tid = 1;
1.489 raeburn 463: if ($supplementalflag) {
464: $tid = 2;
465: }
1.484 raeburn 466: my ($breadcrumbtrail) = &breadcrumbs($allowed,$crstype);
467: $r->print($breadcrumbtrail.
468: &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
469: $readfile));
1.329 droeschl 470: my %docslog=&Apache::lonnet::dump('nohist_docslog',
471: $env{'course.'.$env{'request.course.id'}.'.domain'},
472: $env{'course.'.$env{'request.course.id'}.'.num'});
473:
474: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
475:
476: my %saveable_parameters = ('show' => 'scalar',);
477: &Apache::loncommon::store_course_settings('docs_log',
478: \%saveable_parameters);
479: &Apache::loncommon::restore_course_settings('docs_log',
480: \%saveable_parameters);
481: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452 www 482: # FIXME: internationalization seems wrong here
1.329 droeschl 483: my %lt=('hiddenresource' => 'Resources hidden',
484: 'encrypturl' => 'URL hidden',
485: 'randompick' => 'Randomly pick',
486: 'randomorder' => 'Randomly ordered',
487: 'set' => 'set to',
488: 'del' => 'deleted');
1.484 raeburn 489: my $filter = &Apache::loncommon::display_filter('docslog')."\n".
490: $pathitem."\n".
491: '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
492: (' 'x2).'<input type="submit" value="'.&mt('Display').'" />';
493: $r->print('<div class="LC_left_float">'.
494: '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
495: &makedocslogform($filter,1).
496: '</fieldset></div><br clear="all" />');
1.329 droeschl 497: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
498: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
499: &mt('After').'</th>'.
500: &Apache::loncommon::end_data_table_header_row());
501: my $shown=0;
502: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
503: if ($env{'form.displayfilter'} eq 'currentfolder') {
504: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
505: }
506: my @changes=keys(%{$docslog{$id}{'logentry'}});
507: if ($env{'form.displayfilter'} eq 'containing') {
508: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
509: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
510: foreach my $key (@changes) {
511: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
512: }
1.344 bisitz 513: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 514: }
515: my $count = 0;
516: my $time =
517: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
518: my $plainname =
519: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
520: $docslog{$id}{'exe_udom'});
521: my $about_me_link =
522: &Apache::loncommon::aboutmewrapper($plainname,
523: $docslog{$id}{'exe_uname'},
524: $docslog{$id}{'exe_udom'});
525: my $send_msg_link='';
526: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
527: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
528: $send_msg_link ='<br />'.
529: &Apache::loncommon::messagewrapper(&mt('Send message'),
530: $docslog{$id}{'exe_uname'},
531: $docslog{$id}{'exe_udom'});
532: }
533: $r->print(&Apache::loncommon::start_data_table_row());
534: $r->print('<td>'.$time.'</td>
535: <td>'.$about_me_link.
536: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
537: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
538: $send_msg_link.'</td><td>'.
539: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1.488 raeburn 540: my $is_supp = 0;
541: if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) {
542: $is_supp = 1;
543: }
1.329 droeschl 544: # Before
545: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
546: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
547: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
548: if ($oldname ne $newname) {
1.488 raeburn 549: my $shown = &LONCAPA::map::qtescape($oldname);
550: if ($is_supp) {
551: $shown = &Apache::loncommon::parse_supplemental_title($shown);
552: }
553: $r->print($shown);
1.329 droeschl 554: }
555: }
556: $r->print('<ul>');
557: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
558: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1.488 raeburn 559: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]);
560: if ($is_supp) {
561: $shown = &Apache::loncommon::parse_supplemental_title($shown);
562: }
563: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 564: }
565: }
566: $r->print('</ul>');
567: # After
568: $r->print('</td><td>');
569:
570: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
571: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
572: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
573: if ($oldname ne '' && $oldname ne $newname) {
1.488 raeburn 574: my $shown = &LONCAPA::map::qtescape($newname);
575: if ($is_supp) {
576: $shown = &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($newname));
577: }
578: $r->print($shown);
1.329 droeschl 579: }
1.364 bisitz 580: }
1.329 droeschl 581: $r->print('<ul>');
582: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
583: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1.488 raeburn 584: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]);
585: if ($is_supp) {
586: $shown = &Apache::loncommon::parse_supplemental_title($shown);
587: }
588: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 589: }
590: }
591: $r->print('</ul>');
592: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
593: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
594: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
595: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452 www 596: # FIXME: internationalization seems wrong here
1.329 droeschl 597: $r->print('<li>'.
598: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
599: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
600: .'</li>');
601: }
602: }
603: $r->print('</ul>');
604: }
605: # End
606: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
607: $shown++;
608: if (!($env{'form.show'} eq &mt('all')
609: || $shown<=$env{'form.show'})) { last; }
610: }
1.484 raeburn 611: $r->print(&Apache::loncommon::end_data_table()."\n".
612: &makesimpleeditform($pathitem)."\n".
613: '</div></div>');
614: $r->print(&endContentScreen());
1.329 droeschl 615: }
616:
617: sub update_paste_buffer {
1.492 raeburn 618: my ($coursenum,$coursedom,$folder) = @_;
1.329 droeschl 619:
620: return if (!defined($env{'form.markcopy'}));
621: return if (!defined($env{'form.copyfolder'}));
622: return if ($env{'form.markcopy'} < 0);
623:
624: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
625: $env{'form.copyfolder'});
1.364 bisitz 626:
1.329 droeschl 627: return if ($fatal);
628:
629: # Mark for copying
630: my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
631: if (&is_supplemental_title($title)) {
632: &Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
1.488 raeburn 633: ($title) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 634: } elsif ($env{'docs.markedcopy_supplemental'}) {
1.346 raeburn 635: &Apache::lonnet::delenv('docs.markedcopy_supplemental');
1.329 droeschl 636: }
637: $url=~s{http(:|:)//https(:|:)//}{https$2//};
638:
1.492 raeburn 639: (my $cmd,undef)=split('_',$env{'form.cmd'});
640:
641: my %addtoenv = (
642: 'docs.markedcopy_title' => $title,
643: 'docs.markedcopy_url' => $url,
644: 'docs.markedcopy_cmd' => $cmd,
645: );
646: &Apache::lonnet::delenv('docs.markedcopy_nested');
647: &Apache::lonnet::delenv('docs.markedcopy_nestednames');
648: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) {
649: my $prefix = $1;
650: my $subdir =$2;
651: if ($subdir eq '') {
652: $subdir = $prefix;
653: }
654: my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
655: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,\%addedmaps,
656: \%hierarchy,\%titles,\%allmaps);
657: if (ref($hierarchy{$url}) eq 'HASH') {
658: my ($nested,$nestednames);
659: &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
660: $nested =~ s/\&$//;
661: $nestednames =~ s/\Q___&&&___\E$//;
662: if ($nested ne '') {
663: $addtoenv{'docs.markedcopy_nested'} = $nested;
664: }
665: if ($nestednames ne '') {
666: $addtoenv{'docs.markedcopy_nestednames'} = $nestednames;
667: }
668: }
669: }
670: &Apache::lonnet::appenv(\%addtoenv);
1.329 droeschl 671: delete($env{'form.markcopy'});
672: }
673:
1.492 raeburn 674: sub recurse_uploaded_maps {
675: my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_;
676: if (ref($hierarchy->{$url}) eq 'HASH') {
677: my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}}));
678: my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}}));
679: my (@uploaded,@names,%shorter);
680: for (my $i=0; $i<@maps; $i++) {
681: my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$});
682: if ($inner ne '') {
683: push(@uploaded,$inner);
684: push(@names,&escape($titles[$i]));
685: $shorter{$maps[$i]} = $inner;
686: }
687: }
688: $$nestref .= "$dir:".join(',',@uploaded).'&';
689: $$namesref .= "$dir:".(join(',',@names)).'___&&&___';
690: foreach my $map (@maps) {
691: if ($shorter{$map} ne '') {
692: &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref);
693: }
694: }
695: }
696: return;
697: }
698:
1.329 droeschl 699: sub print_paste_buffer {
1.492 raeburn 700: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.329 droeschl 701: return if (!defined($env{'docs.markedcopy_url'}));
702:
1.492 raeburn 703: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent);
1.488 raeburn 704: my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
705: if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
706: $is_external = 1;
707: }
708:
1.492 raeburn 709: my ($canpaste,$nopaste,$othercrs,$areachange,$is_uploaded_map);
1.488 raeburn 710: if ($folder =~ /^supplemental/) {
1.492 raeburn 711: $canpaste = &supp_pasteable($env{'docs.markedcopy_url'});
712: unless ($canpaste) {
713: $nopaste = &mt('Paste into Supplemental Content unavailable for this type of content.');
714: }
1.488 raeburn 715: } else {
716: $canpaste = 1;
717: }
718:
719: if ($canpaste) {
1.492 raeburn 720: if ($env{'docs.markedcopy_url'} =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
721: my $srcdom = $1;
722: my $srcnum = $2;
723: my $rem = $3;
724: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
725: $othercourse = 1;
726: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
727: if ($canpaste) {
728: $othercrs = '<br />'.&mt('(from another course).');
729: }
730: } else {
731: $canpaste = 0;
732: $nopaste = &mt('Paste from another course unavailable.')
733: }
734: }
735: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
736: my $prefix = $1;
737: $parent = $2;
738: if ($folder !~ /^\Q$prefix\E/) {
739: $areachange = 1;
740: }
741: $is_uploaded_map = 1;
742: }
743: }
1.488 raeburn 744: }
745:
1.381 bisitz 746: $r->print('<fieldset>'
1.492 raeburn 747: .'<legend>'.&mt('Clipboard').'</legend>');
748: my ($type,$buffer);
1.488 raeburn 749: if ($is_external) {
1.492 raeburn 750: $type = &mt('External Resource');
751: $buffer = $type.': '.
752: &LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('.
753: &LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')';
1.329 droeschl 754: } else {
1.492 raeburn 755: my $icon = &Apache::loncommon::icon($extension);
756: if ($extension eq 'sequence' &&
757: $env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) {
758: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
759: $icon .= '/navmap.folder.closed.gif';
760: }
761: $icon = '<img src="'.$icon.'" alt="" class="LC_icon" />';
762: $buffer = $icon.$type.': '. &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}));
1.329 droeschl 763: }
1.488 raeburn 764: if ($canpaste) {
1.492 raeburn 765: $r->print('<form name="pasteform" action="/adm/coursedocs" method="post">'.$buffer);
766: if (($is_uploaded_map) && (!$areachange)) {
767: if ((!$othercourse) && ($env{'docs.markedcopy_cmd'} eq 'cut')) {
768: $r->print((' 'x 4).'<span id="pasteoptionstext">'.
769: '<a href="javascript:showPasteOptions();" class="LC_menubuttons_link">'.
770: &mt('Show Paste Options').'</a></span><br />'.
771: '<div id="pasteoptions" class="LC_dccid">'.(' 'x 4).
772: '<label>'.
773: '<input type="radio" name="docs.markedcopy_options" value="new" checked="checked" />'.
774: &mt('Copy to new folder').'</label>'.(' ' x2).
775: '<label>'.
776: '<input type="radio" name="docs.markedcopy_options" value="move" />'.
777: &mt('Move old folder').'</label><br />');
778: if ($env{'docs.markedcopy_nested'}) {
779: $r->print('<br />'.&mt('Folder to paste contains sub-folders').
780: '<br /><table border="0">');
781: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested'});
782: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames'});
783: my $lastdir = $parent;
784: my %depths = (
785: $lastdir => 0,
786: );
787: my (%display,%deps);
788: for (my $i=0; $i<@pastemaps; $i++) {
789: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
790: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
791: my @subfolders = split(/,/,$subfolderstr);
792: $deps{$lastdir} = \@subfolders;
793: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
794: my $depth = $depths{$lastdir} + 1;
795: my $offset = int($depth * 4);
796: my $indent = (' ' x $offset);
797: for (my $j=0; $j<@subfolders; $j++) {
798: $depths{$subfolders[$j]} = $depth;
799: $display{$subfolders[$j]} =
800: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
801: '<td><label>'.
802: '<input type="radio" name="docs.markedcopy_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
803: '<label>'.
804: '<input type="radio" name="docs.markedcopy_'.$subfolders[$j].'" value="move" />'.
805: &mt('Move old').'</label>'.
806: '</td></tr>';
807: }
808: }
809: &recurse_print($r,$parent,\%deps,\%display);
810: $r->print('</table>');
811: }
812: $r->print('</div>');
813: }
814: }
815: $r->print('<br /><input type="submit" name="pastemarked" value="'.&mt('Paste').'" />'.$othercrs);
1.488 raeburn 816: if ($container eq 'page') {
1.492 raeburn 817: $r->print('
818: <input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />
819: <input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />
1.329 droeschl 820: ');
1.488 raeburn 821: } else {
1.492 raeburn 822: $r->print('
1.329 droeschl 823: <input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
824: ');
1.488 raeburn 825: }
826: $r->print('</form>');
827: } else {
1.492 raeburn 828: $r->print(&mt('Paste buffer contains:').' '.$buffer.
829: '<br /><p class="LC_info">'.$nopaste.'</p>');
1.329 droeschl 830: }
1.488 raeburn 831: $r->print('</fieldset>');
832: }
833:
1.492 raeburn 834: sub recurse_print {
835: my ($r,$dir,$deps,$display) = @_;
836: $r->print($display->{$dir}."\n");
837: if (ref($deps->{$dir}) eq 'ARRAY') {
838: foreach my $subdir (@{$deps->{$dir}}) {
839: &recurse_print($r,$subdir,$deps,$display);
840: }
841: }
842: }
843:
1.488 raeburn 844: sub supp_pasteable {
845: my ($url) = @_;
846: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
847: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
848: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
849: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
850: ($url =~ m{^/public/$match_domain/$match_courseid/syllabus})) {
851: return 1;
852: }
853: return;
1.329 droeschl 854: }
855:
1.492 raeburn 856: sub paste_popup_js {
857: my %lt = &Apache::lonlocal::texthash(
858: show => 'Show Paste Options',
859: hide => 'Hide Paste Options',
860: );
861: return <<"END";
862:
863: function showPasteOptions() {
864: document.getElementById('pasteoptions').style.display='block';
865: document.getElementById('pasteoptions').style.textAlign='left';
866: document.getElementById('pasteoptions').style.textFace='normal';
867: document.getElementById('pasteoptionstext').innerHTML ='<a href="javascript:hidePasteOptions();" class="LC_menubuttons_link">$lt{'hide'}</a><br />';
868: return;
869: }
870:
871: function hidePasteOptions() {
872: document.getElementById('pasteoptions').style.display='none';
873: document.getElementById('pasteoptionstext').innerHTML ='<a href="javascript:showPasteOptions()" class="LC_menubuttons_link">$lt{'show'}</a>';
874: return;
875: }
876:
877: END
878:
879: }
880:
881:
1.329 droeschl 882: sub do_paste_from_buffer {
1.492 raeburn 883: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 884:
1.492 raeburn 885: # Early out if paste buffer is empty
1.329 droeschl 886: if (!$env{'form.pastemarked'}) {
1.492 raeburn 887: return ();
1.329 droeschl 888: }
889:
1.492 raeburn 890: # Supplemental content may only include certain types of content
891: # Early out if pasted content is not supported in Supplemental area
892: if ($folder =~ /^supplemental/) {
893: unless (&supp_pasteable($env{'docs.markedcopy_url'})) {
894: return (&mt('Paste failed: content type is not supported within Supplemental Content'));
895: }
896: }
897:
898: # Prepare to paste resource at end of list
1.491 raeburn 899: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
900: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});
901:
1.492 raeburn 902: my ($is_map,$srcdom,$srcnum,$prefixchg,%before,%after,%mapchanges,%tomove);
1.491 raeburn 903: if ($url=~/\.(page|sequence)$/) {
904: $is_map = 1;
905: }
906: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/([^/]+)}) {
907: $srcdom = $1;
908: $srcnum = $2;
909: my $oldprefix = $3;
1.492 raeburn 910: # When paste buffer was populated using an active role in a different course
911: # check for mdc privilege in the course from which the resource was pasted
1.491 raeburn 912: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
913: unless ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.492 raeburn 914: return (&mt('Paste failed: Item is from a different course which you do not have rights to edit.'));
1.491 raeburn 915: }
916: }
1.492 raeburn 917: # When pasting content from Main Content to Supplemental Content and vice versa
918: # URLs will contain different paths (which depend on whether pasted item is
919: # a folder/page or a document.
1.491 raeburn 920: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
921: $prefixchg = 1;
922: %before = ( map => 'default',
923: doc => 'docs');
924: %after = ( map => 'supplemental',
925: doc => 'supplemental' );
926: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
927: $prefixchg = 1;
928: %before = ( map => 'supplemental',
929: doc => 'supplemental');
930: %after = ( map => 'default',
931: doc => 'docs');
932: }
933:
1.492 raeburn 934: # If pasting an uploaded map, get list of contained uploaded maps.
935: my @nested;
936: if ($env{'docs.markedcopy_nested'}) {
937: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
938: my @items = split(/\&/,$env{'docs.markedcopy_nested'});
939: my @deps = map { /\d+:([\d,]+$)/ } @items;
940: foreach my $dep (@deps) {
941: if ($dep =~ /,/) {
942: push(@nested,split(/,/,$dep));
943: } else {
944: push(@nested,$dep);
945: }
946: }
947: foreach my $item (@nested) {
948: if ($env{'form.docs.markedcopy_'.$item} eq 'move') {
949: $tomove{$type.'_'.$item} = 1;
950: }
951: }
1.488 raeburn 952: }
953: }
954:
1.329 droeschl 955: # Maps need to be copied first
1.492 raeburn 956: my ($oldurl,%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
957: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%newsubdir,%newurls);
1.489 raeburn 958: $oldurl = $url;
1.491 raeburn 959: if ($is_map) {
1.492 raeburn 960: if ($folder =~ /^default/) {
961: my $lastchange = &Apache::lonnet::get_coursechange($coursedom,$coursenum);
962: if ($lastchange > $env{'request.course.tied'}) {
963: &reinit_role($coursedom,$coursenum,$env{"course.$env{'request.course.id'}.home"});
964: }
965: }
1.491 raeburn 966: # If pasting a map, check if map contains other maps
1.492 raeburn 967: my (%allmaps,%hierarchy,%titles);
1.491 raeburn 968: if ($folder =~ /^default/) {
969: my $navmap = Apache::lonnavmaps::navmap->new();
970: if (defined($navmap)) {
971: foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_map() },1,0,1)) {
972: $allmaps{$res->src()} = 1;
973: }
1.488 raeburn 974: }
975: }
1.492 raeburn 976: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,
977: \%addedmaps,\%hierarchy,\%titles,\%allmaps);
1.488 raeburn 978: if ($url=~ m{^/uploaded/}) {
1.492 raeburn 979: my $newurl;
980: unless ($env{'form.docs.markedcopy_options'} eq 'move') {
981: ($newurl,my $error) =
982: &get_newmap_url($url,$folder,$prefixchg,$coursedom,$coursenum,
983: $srcdom,$srcnum,\$title,\%allmaps,\%newurls);
984: if ($error) {
985: return ($error);
986: }
987: if ($newurl ne '') {
988: if ($newurl ne $url) {
989: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
990: $newsubdir{$url} = $1;
991: }
992: $mapchanges{$url} = 1;
993: }
1.491 raeburn 994: }
995: }
1.492 raeburn 996: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum) || ($prefixchg) ||
997: (($newurl ne '') && ($newurl ne $url))) {
998: unless (&url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum,
999: \%allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
1000: \%zombies,\%params,\%mapmoves,\%mapchanges,\%tomove,
1001: \%newsubdir,\%newurls)) {
1002: $mapmoves{$url} = 1;
1003: }
1004: $url = $newurl;
1005: } elsif ($env{'docs.markedcopy_nested'}) {
1006: &url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum,\%allmaps,\%rewrites,
1007: \%retitles,\%copies,\%dbcopies,\%zombies,\%params,\%mapmoves,
1008: \%mapchanges,\%tomove,\%newsubdir,\%newurls);
1.329 droeschl 1009: }
1.488 raeburn 1010: } elsif ($url=~m {^/res/}) {
1011: # published maps can only exists once, so remove it from paste buffer when done
1012: &Apache::lonnet::delenv('docs.markedcopy');
1.492 raeburn 1013: # if pasting published map (main content are only) check map is not already in course
1014: if ($folder =~ /^default/) {
1.491 raeburn 1015: if ($allmaps{$url}) {
1.492 raeburn 1016: return (&mt('Paste failed: only one instance of a particular published sequence or page is allowed within each course.'));
1.491 raeburn 1017: }
1.489 raeburn 1018: }
1019: }
1.329 droeschl 1020: }
1021: if ($url=~ m{/smppg$}) {
1022: my $db_name = &Apache::lonsimplepage::get_db_name($url);
1023: if ($db_name =~ /^smppage_/) {
1024: #simple pages, need to copy the db contents to a new one.
1025: my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum);
1026: my $now = time();
1027: $db_name =~ s{_\d*$ }{_$now}x;
1.491 raeburn 1028: my $dbresult=&Apache::lonnet::put($db_name,\%contents,
1.329 droeschl 1029: $coursedom,$coursenum);
1.491 raeburn 1030: if ($dbresult eq 'ok') {
1031: $url =~ s{/(\d*)/smppg$ }{/$now/smppg}x;
1032: $title=&mt('Copy of').' '.$title;
1033: } else {
1.492 raeburn 1034: return (&mt('Paste failed: An error occurred when copying the simple page.'));
1.491 raeburn 1035: }
1.329 droeschl 1036: }
1037: }
1038: $title = &LONCAPA::map::qtunescape($title);
1039: my $ext='false';
1040: if ($url=~m{^http(|s)://}) { $ext='true'; }
1041: $url = &LONCAPA::map::qtunescape($url);
1.491 raeburn 1042:
1043: # For uploaded files (excluding pages/sequences) path in copied file is changed
1044: # if paste is from Main to Supplemental (or vice versa), or if pasting between
1045: # courses.
1046:
1.492 raeburn 1047: my $newidx;
1.491 raeburn 1048: unless ($is_map) {
1.492 raeburn 1049: # Now insert the URL at the bottom
1050: $newidx = &LONCAPA::map::getresidx($url);
1.491 raeburn 1051: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
1052: my $relpath = $1;
1053: if ($relpath ne '') {
1054: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
1.492 raeburn 1055: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
1.491 raeburn 1056: my $newprefix = $newloc;
1057: if ($newloc eq 'default') {
1058: $newprefix = 'docs';
1059: }
1.492 raeburn 1060: if ($newdocsdir eq '') {
1061: $newdocsdir = 'default';
1.491 raeburn 1062: }
1063: if (($prefixchg) || ($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
1.492 raeburn 1064: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
1.491 raeburn 1065: $url =
1066: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
1067: &Apache::lonnet::getfile($oldurl));
1068: if ($url eq '/adm/notfound.html') {
1.492 raeburn 1069: return (&mt('Paste failed: an error occurred saving the file.'));
1.491 raeburn 1070: } else {
1071: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
1072: $newsubpath =~ s{/+$}{/};
1073: $docmoves{$oldurl} = $newsubpath;
1074: }
1075: }
1076: }
1.488 raeburn 1077: }
1.491 raeburn 1078: }
1.492 raeburn 1079: # Apply any changes to maps, or copy dependencies for uploaded HTML pages
1080: my ($result,$save_err);
1081: $result =
1082: &apply_fixups($folder,$is_map,$prefixchg,$coursedom,$coursenum,$oldurl,
1083: $url,\%removefrommap,\%removeparam,\%rewrites,\%retitles,
1084: \%copies,\%dbcopies,\%zombies,\%params,\%docmoves,
1085: \%mapmoves,\%newsubdir,$errors,\%before,\%after);
1.491 raeburn 1086: if ($result eq 'ok') {
1.492 raeburn 1087: if ($is_map) {
1088: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1089: $folder.'.'.$container);
1090: return $errtext if ($fatal);
1091:
1092: if ($#LONCAPA::map::order<1) {
1093: my $idx=&LONCAPA::map::getresidx();
1094: if ($idx<=0) { $idx=1; }
1095: $LONCAPA::map::order[0]=$idx;
1096: $LONCAPA::map::resources[$idx]='';
1097: }
1098: $newidx = &LONCAPA::map::getresidx($url);
1099: }
1.491 raeburn 1100: if ($env{'docs.markedcopy_supplemental'}) {
1.492 raeburn 1101: if ($folder !~ /^supplemental/) {
1.491 raeburn 1102: (undef,undef,$title) =
1103: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental'});
1.489 raeburn 1104: }
1.329 droeschl 1105: } else {
1.491 raeburn 1106: if ($folder=~/^supplemental/) {
1107: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1108: $env{'user.domain'}.'___&&&___'.$title;
1109: }
1.329 droeschl 1110: }
1.491 raeburn 1111: $LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
1112: push(@LONCAPA::map::order, $newidx);
1.492 raeburn 1113:
1114: # Store the result
1115: my ($errtext,$fatal) =
1116: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1117: if ($fatal) {
1118: $save_err = $errtext;
1119: }
1120: }
1121:
1122: if ($env{'form.docs.markedcopy_options'} eq 'move') {
1123: &Apache::lonnet::delenv('docs.markedcopy');
1124: &Apache::lonnet::delenv('docs.markedcopy_nested');
1125: &Apache::lonnet::delenv('docs.markedcopy_nestednames');
1126: }
1127: return ($result,$save_err);
1128: }
1129:
1130: sub get_newmap_url {
1131: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
1132: $titleref,$allmaps,$newurls) = @_;
1133: my $newurl;
1134: if ($url=~ m{^/uploaded/}) {
1135: $$titleref=&mt('Copy of').' '.$$titleref;
1136: }
1137: my $now = time;
1138: my $suffix=$$.int(rand(100)).$now;
1139: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
1140: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
1141: my $path = $1;
1142: my $prefix = $2;
1143: my $ancestor = $3;
1144: if (length($ancestor) > 10) {
1145: $ancestor = substr($ancestor,-10,10);
1146: }
1147: my $newid;
1148: if ($prefixchg) {
1149: if ($folder =~ /^supplemental/) {
1150: $prefix =~ s/^default/supplemental/;
1151: } else {
1152: $prefix =~ s/^supplemental/default/;
1153: }
1154: }
1155: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
1156: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
1157: } else {
1158: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
1159: }
1160: my $counter = 0;
1161: my $is_unique = &uniqueness_check($newurl);
1162: if ($folder =~ /^default/) {
1163: if ($allmaps->{$newurl}) {
1164: $is_unique = 0;
1165: }
1166: }
1167: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
1168: $counter ++;
1169: $suffix ++;
1170: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
1171: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
1172: } else {
1173: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
1174: }
1175: $is_unique = &uniqueness_check($newurl);
1176: }
1177: if ($is_unique) {
1178: $newurls->{$newurl} = 1;
1179: } else {
1180: if ($url=~/\.page$/) {
1181: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
1182: } else {
1183: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
1184: }
1185: }
1.329 droeschl 1186: }
1.492 raeburn 1187: return ($newurl);
1.329 droeschl 1188: }
1189:
1.488 raeburn 1190: sub dbcopy {
1191: my ($url,$coursedom,$coursenum) = @_;
1192: if ($url=~ m{/smppg$}) {
1193: my $db_name = &Apache::lonsimplepage::get_db_name($url);
1194: if ($db_name =~ /^smppage_/) {
1195: #simple pages, need to copy the db contents to a new one.
1196: my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum);
1197: my $now = time();
1198: $db_name =~ s{_\d*$ }{_$now}x;
1199: my $result=&Apache::lonnet::put($db_name,\%contents,
1200: $coursedom,$coursenum);
1201: $url =~ s{/(\d*)/smppg$ }{/$now/smppg}x;
1202: }
1203: }
1204: return $url;
1205: }
1206:
1.329 droeschl 1207: sub uniqueness_check {
1208: my ($newurl) = @_;
1209: my $unique = 1;
1210: foreach my $res (@LONCAPA::map::order) {
1211: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
1212: $url=&LONCAPA::map::qtescape($url);
1213: if ($newurl eq $url) {
1214: $unique = 0;
1.344 bisitz 1215: last;
1.329 droeschl 1216: }
1217: }
1218: return $unique;
1219: }
1220:
1.488 raeburn 1221: sub contained_map_check {
1.492 raeburn 1222: my ($url,$folder,$removefrommap,$removeparam,$addedmaps,$hierarchy,$titles,
1223: $allmaps) = @_;
1.488 raeburn 1224: my $content = &Apache::lonnet::getfile($url);
1225: unless ($content eq '-1') {
1226: my $parser = HTML::TokeParser->new(\$content);
1227: $parser->attr_encoded(1);
1228: while (my $token = $parser->get_token) {
1229: next if ($token->[0] ne 'S');
1230: if ($token->[1] eq 'resource') {
1231: next if ($token->[2]->{'type'} eq 'zombie');
1232: my $ressrc = $token->[2]->{'src'};
1233: if ($folder =~ /^supplemental/) {
1234: unless (&supp_pasteable($ressrc)) {
1.492 raeburn 1235: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.488 raeburn 1236: next;
1237: }
1238: }
1.492 raeburn 1239: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
1240: if ($1 eq 'uploaded') {
1241: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
1242: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
1.488 raeburn 1243: } else {
1.492 raeburn 1244: if ($allmaps->{$ressrc}) {
1245: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1246: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
1247: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1248: } else {
1249: $addedmaps->{$ressrc} = [$url];
1250: }
1.488 raeburn 1251: }
1.492 raeburn 1252: &contained_map_check($ressrc,$folder,$removefrommap,$removeparam,
1253: $addedmaps,$hierarchy,$titles,$allmaps);
1.488 raeburn 1254: }
1.492 raeburn 1255: } elsif ($token->[1] eq 'param') {
1.488 raeburn 1256: if ($folder =~ /^supplemental/) {
1.492 raeburn 1257: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
1258: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
1259: } else {
1260: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
1261: }
1.488 raeburn 1262: }
1263: }
1264: }
1265: }
1266: return;
1267: }
1268:
1269: sub reinit_role {
1270: my ($cdom,$cnum,$chome) = @_;
1271: my ($furl,$ferr) = &Apache::lonuserstate::readmap("$cdom/$cnum");
1272: unless ($ferr) {
1273: &Apache::loncommon::update_content_constraints($cdom,$cnum,$chome,$cdom.'_'.$cnum);
1274: }
1275: return;
1276: }
1277:
1278: sub url_paste_fixups {
1.492 raeburn 1279: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$allmaps,$rewrites,$retitles,$copies,
1280: $dbcopies,$zombies,$params,$mapmoves,$mapchanges,$tomove,$newsubdir,$newurls) = @_;
1.491 raeburn 1281: my $checktitle;
1282: if (($prefixchg) &&
1.492 raeburn 1283: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
1.491 raeburn 1284: $checktitle = 1;
1285: }
1.492 raeburn 1286: my $skip;
1287: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
1288: my $mapid = $1.$2;
1289: if ($tomove->{$mapid}) {
1290: $skip = 1;
1291: }
1292: }
1.491 raeburn 1293: my $file = &Apache::lonnet::getfile($oldurl);
1.488 raeburn 1294: return if ($file eq '-1');
1295: my $parser = HTML::TokeParser->new(\$file);
1296: $parser->attr_encoded(1);
1.491 raeburn 1297: my $changed = 0;
1.488 raeburn 1298: while (my $token = $parser->get_token) {
1299: next if ($token->[0] ne 'S');
1300: if ($token->[1] eq 'resource') {
1301: my $ressrc = $token->[2]->{'src'};
1302: next if ($ressrc eq '');
1.491 raeburn 1303: my $id = $token->[2]->{'id'};
1.492 raeburn 1304: my $title = $token->[2]->{'title'};
1.491 raeburn 1305: if ($checktitle) {
1306: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1307: $retitles->{$oldurl}{$ressrc} = $id;
1308: }
1309: }
1.488 raeburn 1310: next if ($token->[2]->{'type'} eq 'external');
1311: if ($token->[2]->{'type'} eq 'zombie') {
1.492 raeburn 1312: next if ($skip);
1.488 raeburn 1313: $zombies->{$oldurl}{$ressrc} = $id;
1.491 raeburn 1314: $changed = 1;
1315: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 1316: my $srcdom = $1;
1317: my $srcnum = $2;
1.488 raeburn 1318: my $rem = $3;
1.492 raeburn 1319: my $newurl;
1320: my $mapname;
1321: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1322: my $prefix = $1;
1323: $mapname = $prefix.$2;
1324: if ($tomove->{$mapname}) {
1325: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,$allmaps,
1326: $rewrites,$retitles,$copies,$dbcopies,$zombies,
1327: $params,$mapmoves,$mapchanges,$tomove,$newsubdir,
1328: $newurls);
1329: next;
1330: } else {
1331: ($newurl,my $error) =
1332: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
1333: $srcdom,$srcnum,\$title,$allmaps,$newurls);
1334: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
1335: $newsubdir->{$ressrc} = $1;
1336: }
1337: if ($error) {
1338: next;
1339: }
1340: }
1341: }
1342: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
1343: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
1344:
1.488 raeburn 1345: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1346: $rewrites->{$oldurl}{$ressrc} = $id;
1.491 raeburn 1347: $mapchanges->{$ressrc} = 1;
1.492 raeburn 1348: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,$allmaps,
1.491 raeburn 1349: $rewrites,$retitles,$copies,$dbcopies,$zombies,
1.492 raeburn 1350: $params,$mapmoves,$mapchanges,$tomove,$newsubdir,
1351: $newurls)) {
1.491 raeburn 1352: $mapmoves->{$ressrc} = 1;
1353: }
1354: $changed = 1;
1.488 raeburn 1355: } else {
1.489 raeburn 1356: $rewrites->{$oldurl}{$ressrc} = $id;
1.488 raeburn 1357: $copies->{$oldurl}{$ressrc} = $id;
1.491 raeburn 1358: $changed = 1;
1.488 raeburn 1359: }
1360: }
1361: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 1362: next if ($skip);
1363: my $srcdom = $1;
1364: my $srcnum = $2;
1365: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.488 raeburn 1366: $rewrites->{$oldurl}{$ressrc} = $id;
1367: $dbcopies->{$oldurl}{$ressrc} = $id;
1.491 raeburn 1368: $changed = 1;
1.488 raeburn 1369: }
1370: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 1371: next if ($skip);
1372: my $srcdom = $1;
1373: my $srcnum = $2;
1374: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.488 raeburn 1375: $rewrites->{$oldurl}{$ressrc} = $id;
1376: $dbcopies->{$oldurl}{$ressrc} = $id;
1.491 raeburn 1377: $changed = 1;
1.488 raeburn 1378: }
1379: }
1380: } elsif ($token->[1] eq 'param') {
1.492 raeburn 1381: next if ($skip);
1.488 raeburn 1382: my $to = $token->[2]->{'to'};
1383: if ($to ne '') {
1384: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
1.492 raeburn 1385: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
1.488 raeburn 1386: } else {
1387: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
1388: }
1389: }
1390: }
1391: }
1.491 raeburn 1392: return $changed;
1.488 raeburn 1393: }
1394:
1395: sub apply_fixups {
1.492 raeburn 1396: my ($folder,$is_map,$prefixchg,$cdom,$cnum,$oldurl,$url,$removefrommap,
1397: $removeparam,$rewrites,$retitles,$copies,$dbcopies,$zombies,$params,
1398: $docmoves,$mapmoves,$newsubdir,$errors,$before,$after) = @_;
1.491 raeburn 1399: foreach my $key (keys(%{$copies}),keys(%{$docmoves})) {
1400: my @allcopies;
1401: if (ref($copies->{$key}) eq 'HASH') {
1402: my %added;
1403: foreach my $innerkey (keys(%{$copies->{$key}})) {
1404: if (($innerkey ne '') && (!$added{$innerkey})) {
1405: push(@allcopies,$innerkey);
1406: $added{$innerkey} = 1;
1407: }
1408: }
1409: undef(%added);
1410: }
1411: if ($key eq $oldurl) {
1412: if ((exists($docmoves->{$key}))) {
1413: unless (grep(/^\Q$oldurl\E/,@allcopies)) {
1414: push(@allcopies,$oldurl);
1415: }
1416: }
1417: }
1418: if (@allcopies > 0) {
1419: foreach my $item (@allcopies) {
1.492 raeburn 1420: my ($relpath,$oldsubdir,$fname) =
1421: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
1.491 raeburn 1422: if ($fname ne '') {
1423: my $content = &Apache::lonnet::getfile($item);
1424: unless ($content eq '-1') {
1425: my $storefn;
1426: if (($key eq $oldurl) && (ref($docmoves) eq 'HASH') && (exists($docmoves->{$key}))) {
1427: $storefn = $docmoves->{$key};
1428: } else {
1429: $storefn = $relpath;
1430: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1431: if ($prefixchg) {
1432: $storefn =~ s/^\Q$before->{'doc'}\E/$after->{'doc'}/;
1433: }
1.492 raeburn 1434: if ($newsubdir->{$key}) {
1435: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir->{$key}#;
1.491 raeburn 1436: }
1437: }
1438: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
1439: my $copyurl =
1440: &Apache::lonclonecourse::writefile($env{'request.course.id'},
1441: $storefn.$fname,$content);
1442: if ($copyurl eq '/adm/notfound.html') {
1443: if ((ref($docmoves) eq 'HASH') && (exists($docmoves->{$oldurl}))) {
1444: return &mt('Paste failed: an error occurred copying the file.');
1445: } elsif (ref($errors) eq 'HASH') {
1446: $errors->{$item} = 1;
1.489 raeburn 1447: }
1448: }
1.488 raeburn 1449: }
1450: }
1.491 raeburn 1451: }
1452: }
1453: }
1454: foreach my $key (keys(%{$mapmoves})) {
1455: my $storefn=$key;
1456: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1457: if ($prefixchg) {
1458: $storefn =~ s/^\Q$before->{'map'}\E/$after->{'map'}/;
1459: }
1.492 raeburn 1460: if ($newsubdir->{$key}) {
1461: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir->{$key}/;
1462: }
1.491 raeburn 1463: my $mapcontent = &Apache::lonnet::getfile($key);
1464: if ($mapcontent eq '-1') {
1465: if (ref($errors) eq 'HASH') {
1466: $errors->{$key} = 1;
1467: }
1468: } else {
1469: my $newmap =
1470: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
1471: $mapcontent);
1472: if ($newmap eq '/adm/notfound.html') {
1473: if (ref($errors) eq 'HASH') {
1474: $errors->{$key} = 1;
1.489 raeburn 1475: }
1.488 raeburn 1476: }
1477: }
1478: }
1.491 raeburn 1479: my %updates;
1480: if ($is_map) {
1481: foreach my $key (keys(%{$rewrites})) {
1.492 raeburn 1482: $updates{$key} = 1;
1.491 raeburn 1483: }
1484: foreach my $key (keys(%{$zombies})) {
1.492 raeburn 1485: $updates{$key} = 1;
1.491 raeburn 1486: }
1487: foreach my $key (keys(%{$removefrommap})) {
1.492 raeburn 1488: $updates{$key} = 1;
1489: }
1490: foreach my $key (keys(%{$removeparam})) {
1491: $updates{$key} = 1;
1492: }
1.491 raeburn 1493: foreach my $key (keys(%{$dbcopies})) {
1.492 raeburn 1494: $updates{$key} = 1;
1.491 raeburn 1495: }
1496: foreach my $key (keys(%{$retitles})) {
1.492 raeburn 1497: $updates{$key} = 1;
1.491 raeburn 1498: }
1499: foreach my $key (keys(%updates)) {
1.492 raeburn 1500: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.491 raeburn 1501: if (ref($rewrites->{$key}) eq 'HASH') {
1502: %torewrite = %{$rewrites->{$key}};
1503: }
1504: if (ref($retitles->{$key}) eq 'HASH') {
1505: %toretitle = %{$retitles->{$key}};
1506: }
1507: if (ref($removefrommap->{$key}) eq 'HASH') {
1508: %toremove = %{$removefrommap->{$key}};
1509: }
1.492 raeburn 1510: if (ref($removeparam->{$key}) eq 'HASH') {
1511: %remparam = %{$removeparam->{$key}};
1512: }
1.491 raeburn 1513: if (ref($zombies->{$key}) eq 'HASH') {
1514: %zombie = %{$zombies->{$key}};
1515: }
1516: if (ref($dbcopies->{$key}) eq 'HASH') {
1517: foreach my $item (keys(%{$dbcopies->{$key}})) {
1518: $newdb{$item} = &dbcopy($item);
1519: }
1520: }
1.492 raeburn 1521: if (ref($params->{$key}) eq 'HASH') {
1522: %currparam = %{$params->{$key}};
1523: }
1524: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
1525: if ($fatal) {
1526: return $errtext;
1527: }
1528: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
1529: if (defined($LONCAPA::map::zombies[$i])) {
1530: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1531: if ($zombie{$src} eq $i) {
1532: undef($LONCAPA::map::zombies[$i]);
1533: }
1534: }
1535: }
1536: for (my $i=0; $i<@LONCAPA::map::resources; $i++) {
1537: if (defined($LONCAPA::map::resources[$i])) {
1538: my $changed;
1539: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$i]);
1540: if ($toremove{$src} eq $i) {
1541: splice(@LONCAPA::map::order,$i,1);
1542: if (ref($currparam{$i}) eq 'ARRAY') {
1543: foreach my $name (@{$currparam{$i}}) {
1544: &LONCAPA::map::delparameter($i,'parameter_'.$name);
1545: }
1546: }
1547: next;
1548: }
1549: my $origsrc = $src;
1550: if ((exists($toretitle{$src})) && ($toretitle{$src} eq $i)) {
1551: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1552: $changed = 1;
1.491 raeburn 1553: }
1.492 raeburn 1554: }
1555: if ((exists($torewrite{$src})) && ($torewrite{$src} eq $i)) {
1556: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
1557: if ($origsrc =~ m{^/uploaded/}) {
1558: if ($prefixchg) {
1559: if ($src =~ /\.(page|sequence)$/) {
1560: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before->{'map'}\E#$1$after->{'map'}#;
1561: } else {
1562: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before->{'doc'}\E#$1$after->{'doc'}#;
1.488 raeburn 1563: }
1.491 raeburn 1564: }
1.492 raeburn 1565: if ($newsubdir->{$origsrc}) {
1566: if ($src =~ /\.(page|sequence)$/) {
1567: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir->{$origsrc}#;
1568: } else {
1569: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir->{$origsrc}#;
1.491 raeburn 1570: }
1.488 raeburn 1571: }
1572: }
1.492 raeburn 1573: $changed = 1;
1574: } elsif ($newdb{$src} ne '') {
1575: $src = $newdb{$src};
1576: $changed = 1;
1577: }
1578: if ($changed) {
1579: $LONCAPA::map::resources[$i] = join(':',($title,$src,$ext,$type));
1580: }
1581: }
1582: }
1583: foreach my $idx (keys(%remparam)) {
1584: if (ref($remparam{$idx}) eq 'ARRAY') {
1585: foreach my $name (@{$remparam{$idx}}) {
1586: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.491 raeburn 1587: }
1588: }
1589: }
1590: my $storefn;
1591: if ($key eq $oldurl) {
1592: $storefn = $url;
1593: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1594: } else {
1595: $storefn = $key;
1596: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1597: if ($prefixchg) {
1598: $storefn =~ s/^\Q$before->{'map'}\E/$after->{'map'}/;
1599: }
1.492 raeburn 1600: if ($newsubdir->{$key}) {
1601: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir->{$key}/;
1602: }
1.491 raeburn 1603: }
1.492 raeburn 1604: my $report;
1605: if ($folder !~ /^supplemental/) {
1606: $report = 1;
1607: }
1608: my ($outtext,$errtext) =
1609: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
1610: if ($errtext) {
1.491 raeburn 1611: return &mt('Paste failed: an error occurred saving the folder or page.');
1612: }
1613: }
1614: }
1615: return 'ok';
1616: }
1617:
1618: sub copy_dependencies {
1619: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
1620: my $content;
1621: if (ref($contentref)) {
1622: $content = $$contentref;
1623: } else {
1624: $content = &Apache::lonnet::getfile($item);
1625: }
1626: unless ($content eq '-1') {
1627: my $mm = new File::MMagic;
1628: my $mimetype = $mm->checktype_contents($content);
1629: if ($mimetype eq 'text/html') {
1630: my (%allfiles,%codebase,$state);
1631: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
1632: if ($res eq 'ok') {
1633: my ($numexisting,$numpathchanges,$existing);
1634: (undef,$numexisting,$numpathchanges,$existing) =
1635: &Apache::loncommon::ask_for_embedded_content(
1636: '/adm/coursedocs',$state,\%allfiles,\%codebase,
1637: {'error_on_invalid_names' => 1,
1638: 'ignore_remote_references' => 1,
1639: 'docs_url' => $item,
1640: 'context' => 'paste'});
1641: if ($numexisting > 0) {
1642: if (ref($existing) eq 'HASH') {
1643: foreach my $dep (keys(%{$existing})) {
1644: my $depfile = $dep;
1645: unless ($depfile =~ m{^\Q$relpath\E}) {
1646: $depfile = $relpath.$dep;
1647: }
1648: my $depcontent = &Apache::lonnet::getfile($depfile);
1649: unless ($depcontent eq '-1') {
1650: my $storedep = $dep;
1651: $storedep =~ s{^\Q$relpath\E}{};
1652: my $dep_url =
1653: &Apache::lonclonecourse::writefile(
1654: $env{'request.course.id'},
1655: $storefn.$storedep,$depcontent);
1656: if ($dep_url eq '/adm/notfound.html') {
1657: if (ref($errors) eq 'HASH') {
1658: $errors->{$depfile} = 1;
1659: }
1660: } else {
1661: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
1662: }
1663: }
1664: }
1.488 raeburn 1665: }
1666: }
1667: }
1668: }
1669: }
1670: return;
1671: }
1672:
1.329 droeschl 1673: my %parameter_type = ( 'randompick' => 'int_pos',
1674: 'hiddenresource' => 'string_yesno',
1675: 'encrypturl' => 'string_yesno',
1676: 'randomorder' => 'string_yesno',);
1677: my $valid_parameters_re = join('|',keys(%parameter_type));
1678: # set parameters
1679: sub update_parameter {
1680:
1681: return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1682:
1683: my $which = $env{'form.changeparms'};
1684: my $idx = $env{'form.setparms'};
1685: if ($env{'form.'.$which.'_'.$idx}) {
1686: my $value = ($which eq 'randompick') ? $env{'form.'.$which.'_'.$idx}
1687: : 'yes';
1688: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
1689: $parameter_type{$which});
1690: &remember_parms($idx,$which,'set',$value);
1691: } else {
1692: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
1.364 bisitz 1693:
1.329 droeschl 1694: &remember_parms($idx,$which,'del');
1695: }
1696: return 1;
1697: }
1698:
1699:
1700: sub handle_edit_cmd {
1701: my ($coursenum,$coursedom) =@_;
1702: my ($cmd,$idx)=split('_',$env{'form.cmd'});
1703:
1704: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
1705: my ($title, $url, @rrest) = split(':', $ratstr);
1706:
1707: if ($cmd eq 'del') {
1708: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 1709: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 1710: &Apache::lonnet::removeuploadedurl($url);
1711: } else {
1712: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
1713: }
1714: splice(@LONCAPA::map::order, $idx, 1);
1715:
1716: } elsif ($cmd eq 'cut') {
1717: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
1718: splice(@LONCAPA::map::order, $idx, 1);
1719:
1.344 bisitz 1720: } elsif ($cmd eq 'up'
1.329 droeschl 1721: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
1722: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
1723:
1724: } elsif ($cmd eq 'down'
1725: && defined($LONCAPA::map::order[$idx+1])) {
1726: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
1727:
1728: } elsif ($cmd eq 'rename') {
1729:
1730: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
1731: if ($comment=~/\S/) {
1732: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
1733: $comment.':'.join(':', $url, @rrest);
1734: }
1735: # Devalidate title cache
1736: my $renamed_url=&LONCAPA::map::qtescape($url);
1737: &Apache::lonnet::devalidate_title_cache($renamed_url);
1738: } else {
1739: return 0;
1740: }
1741: return 1;
1742: }
1743:
1744: sub editor {
1.458 raeburn 1745: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.472 raeburn 1746: $supplementalflag,$orderhash,$iconpath)=@_;
1.329 droeschl 1747: my $container= ($env{'form.pagepath'}) ? 'page'
1748: : 'sequence';
1749:
1.484 raeburn 1750: my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) =
1751: &breadcrumbs($allowed,$crstype);
1752: $r->print($breadcrumbtrail);
1753:
1754: my $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1755:
1756: unless ($allowed) {
1757: $randompick = -1;
1758: }
1759:
1.329 droeschl 1760: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1761: $folder.'.'.$container);
1762: return $errtext if ($fatal);
1763:
1764: if ($#LONCAPA::map::order<1) {
1765: my $idx=&LONCAPA::map::getresidx();
1766: if ($idx<=0) { $idx=1; }
1767: $LONCAPA::map::order[0]=$idx;
1768: $LONCAPA::map::resources[$idx]='';
1769: }
1.364 bisitz 1770:
1.329 droeschl 1771: # ------------------------------------------------------------ Process commands
1772:
1773: # ---------------- if they are for this folder and user allowed to make changes
1774: if (($allowed) && ($env{'form.folder'} eq $folder)) {
1775: # set parameters and change order
1776: &snapshotbefore();
1777:
1778: if (&update_parameter()) {
1779: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
1780: return $errtext if ($fatal);
1781: }
1782:
1783: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
1784: # change order
1785: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
1786: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
1787:
1788: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
1789: return $errtext if ($fatal);
1790: }
1.364 bisitz 1791:
1.329 droeschl 1792: if ($env{'form.pastemarked'}) {
1.491 raeburn 1793: my %paste_errors;
1.492 raeburn 1794: my ($paste_res,$save_error) =
1795: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
1796: \%paste_errors);
1797: if ($save_error ne '') {
1798: return $save_error;
1799: }
1800: if ($paste_res ne 'ok') {
1.329 droeschl 1801: $r->print('<p><span class="LC_error">'.$paste_res.'</span></p>');
1802: }
1.491 raeburn 1803: if (keys(%paste_errors) > 0) {
1804: $r->print('<p span class="LC_warning">'."\n".
1805: &mt('The following files are either dependencies of a web page or references within a folder and/or composite page which could not be copied during the paste operation:')."\n".
1806: '<ul>'."\n");
1807: foreach my $key (sort(keys(%paste_errors))) {
1808: $r->print('<li>'.$key.'</li>'."\n");
1809: }
1810: $r->print('</ul></p>'."\n");
1811: }
1.329 droeschl 1812: }
1813:
1814: $r->print($upload_output);
1815:
1816: if (&handle_edit_cmd()) {
1.492 raeburn 1817: my $contentchg;
1818: if ($env{'form.cmd'} =~ /^(del|cut)_/) {
1819: $contentchg = 1;
1820: }
1821: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 1822: return $errtext if ($fatal);
1823: }
1824: # Group import/search
1825: if ($env{'form.importdetail'}) {
1826: my @imports;
1827: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
1828: if (defined($item)) {
1829: my ($name,$url,$residx)=
1830: map {&unescape($_)} split(/\=/,$item);
1831: push(@imports, [$name, $url, $residx]);
1832: }
1833: }
1834: ($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder,
1835: $container,'londocs',@imports);
1836: return $errtext if ($fatal);
1837: }
1838: # Loading a complete map
1839: if ($env{'form.loadmap'}) {
1840: if ($env{'form.importmap'}=~/\w/) {
1841: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
1842: my ($title,$url,$ext,$type)=split(/\:/,$res);
1843: my $idx=&LONCAPA::map::getresidx($url);
1844: $LONCAPA::map::resources[$idx]=$res;
1845: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
1846: }
1847: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 1848: $folder.'.'.$container,1);
1.329 droeschl 1849: return $errtext if ($fatal);
1850: } else {
1851: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 1852:
1.329 droeschl 1853: }
1854: }
1855: &log_differences($plain);
1856: }
1857: # ---------------------------------------------------------------- End commands
1858: # ---------------------------------------------------------------- Print screen
1859: my $idx=0;
1860: my $shown=0;
1861: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 1862: $r->print('<div class="LC_Box">'.
1.432 raeburn 1863: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
1864: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
1865: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
1866: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
1867: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 1868: '</ol>');
1.381 bisitz 1869: if ($randompick>=0) {
1870: $r->print('<p class="LC_warning">'
1871: .&mt('Caution: this folder is set to randomly pick a subset'
1872: .' of resources. Adding or removing resources from this'
1873: .' folder will change the set of resources that the'
1874: .' students see, resulting in spurious or missing credit'
1875: .' for completed problems, not limited to ones you'
1876: .' modify. Do not modify the contents of this folder if'
1877: .' it is in active student use.')
1878: .'</p>'
1879: );
1880: }
1881: if ($is_random_order) {
1882: $r->print('<p class="LC_warning">'
1883: .&mt('Caution: this folder is set to randomly order its'
1884: .' contents. Adding or removing resources from this folder'
1885: .' will change the order of resources shown.')
1886: .'</p>'
1887: );
1888: }
1889: $r->print('</div>');
1.364 bisitz 1890: }
1.381 bisitz 1891:
1.458 raeburn 1892: my ($to_show,$output);
1.424 onken 1893:
1894: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 1895: foreach my $res (@LONCAPA::map::order) {
1896: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
1897: $name=&LONCAPA::map::qtescape($name);
1898: $url=&LONCAPA::map::qtescape($url);
1899: unless ($name) { $name=(split(/\//,$url))[-1]; }
1900: unless ($name) { $idx++; next; }
1901: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.408 raeburn 1902: $coursenum,$crstype);
1.381 bisitz 1903: $idx++;
1904: $shown++;
1.329 droeschl 1905: }
1.424 onken 1906: &Apache::loncommon::end_data_table_count();
1907:
1.381 bisitz 1908: if ($shown) {
1.458 raeburn 1909: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
1910: .&Apache::loncommon::start_data_table(undef,'contentlist');
1.393 raeburn 1911: if ($allowed) {
1.458 raeburn 1912: $to_show .= &Apache::loncommon::start_data_table_header_row()
1.393 raeburn 1913: .'<th colspan="2">'.&mt('Move').'</th>'
1914: .'<th>'.&mt('Actions').'</th>'
1.458 raeburn 1915: .'<th colspan="2">'.&mt('Document').'</th>';
1.393 raeburn 1916: if ($folder !~ /^supplemental/) {
1.458 raeburn 1917: $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
1.393 raeburn 1918: }
1.458 raeburn 1919: $to_show .= &Apache::loncommon::end_data_table_header_row();
1.393 raeburn 1920: }
1.458 raeburn 1921: $to_show .= $output.' '
1.393 raeburn 1922: .&Apache::loncommon::end_data_table()
1.458 raeburn 1923: .'<br style="line-height:2px;" />'
1924: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 1925: } else {
1.458 raeburn 1926: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
1927: .'<div class="LC_info" id="contentlist">'
1.381 bisitz 1928: .&mt('Currently no documents.')
1.458 raeburn 1929: .'</div>'
1930: .&Apache::loncommon::end_scrollbox();
1931: }
1932: my $tid = 1;
1933: if ($supplementalflag) {
1934: $tid = 2;
1.329 droeschl 1935: }
1936: if ($allowed) {
1.484 raeburn 1937: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1938: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,$jumpto,
1939: $readfile));
1.492 raeburn 1940: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
1.460 raeburn 1941: } else {
1.472 raeburn 1942: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
1943: #Function Box for Supplemental Content for users with mdc priv.
1944: my $funcname = &mt('Folder Editor');
1945: $r->print(
1946: &Apache::loncommon::head_subbox(
1947: &Apache::lonhtmlcommon::start_funclist().
1948: &Apache::lonhtmlcommon::add_item_funclist(
1949: '<a href="/adm/coursedocs?command=direct&forcesupplement=1&'.
1950: 'supppath='.&HTML::Entities::encode($env{'form.folderpath'}).'">'.
1951: '<img src="/res/adm/pages/docs.png" alt="'.$funcname.'" class="LC_icon" />'.
1952: '<span class="LC_menubuttons_inline_text">'.$funcname.'</span></a>').
1953: &Apache::lonhtmlcommon::end_funclist()));
1954: }
1.460 raeburn 1955: $r->print($to_show);
1.329 droeschl 1956: }
1957: return;
1958: }
1959:
1960: sub process_file_upload {
1961: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
1962: # upload a file, if present
1.440 raeburn 1963: my ($parseaction,$showupload,$nextphase,$mimetype);
1964: if ($env{'form.parserflag'}) {
1.329 droeschl 1965: $parseaction = 'parse';
1966: }
1967: my $folder=$env{'form.folder'};
1968: if ($folder eq '') {
1969: $folder='default';
1970: }
1971: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
1972: my $errtext='';
1973: my $fatal=0;
1974: my $container='sequence';
1975: if ($env{'form.pagepath'}) {
1976: $container='page';
1977: }
1978: ($errtext,$fatal)=
1979: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1980: if ($#LONCAPA::map::order<1) {
1981: $LONCAPA::map::order[0]=1;
1982: $LONCAPA::map::resources[1]='';
1983: }
1984: if ($fatal) {
1.457 raeburn 1985: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</div>';
1.440 raeburn 1986: return;
1.329 droeschl 1987: }
1988: my $destination = 'docs/';
1989: if ($folder =~ /^supplemental/) {
1990: $destination = 'supplemental/';
1991: }
1992: if (($folder eq 'default') || ($folder eq 'supplemental')) {
1993: $destination .= 'default/';
1994: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
1995: $destination .= $2.'/';
1996: }
1.440 raeburn 1997: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 1998: my $newidx=&LONCAPA::map::getresidx();
1999: $destination .= $newidx;
1.439 raeburn 2000: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 2001: $parseaction,$allfiles,
1.440 raeburn 2002: $codebase,undef,undef,undef,undef,
2003: undef,undef,\$mimetype);
2004: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
2005: my $stored = $1;
2006: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
2007: $stored.'</span>').'</p>';
2008: } else {
2009: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
2010:
1.457 raeburn 2011: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 2012: return;
2013: }
1.329 droeschl 2014: my $ext='false';
2015: if ($url=~m{^http://}) { $ext='true'; }
2016: $url = &LONCAPA::map::qtunescape($url);
2017: my $comment=$env{'form.comment'};
2018: $comment = &LONCAPA::map::qtunescape($comment);
2019: if ($folder=~/^supplemental/) {
2020: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
2021: $env{'user.domain'}.'___&&&___'.$comment;
2022: }
2023:
2024: $LONCAPA::map::resources[$newidx]=
2025: $comment.':'.$url.':'.$ext.':normal:res';
2026: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
2027: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 2028: $folder.'.'.$container,1);
1.329 droeschl 2029: if ($fatal) {
1.457 raeburn 2030: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 2031: return;
1.329 droeschl 2032: } else {
1.440 raeburn 2033: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
2034: $$upload_output = $showupload;
1.384 raeburn 2035: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 2036: if ($total_embedded > 0) {
1.440 raeburn 2037: my $uploadphase = 'upload_embedded';
2038: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
2039: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
2040: my ($embedded,$num) =
2041: &Apache::loncommon::ask_for_embedded_content(
2042: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
2043: if ($embedded) {
2044: if ($num) {
2045: $$upload_output .=
2046: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
2047: $nextphase = $uploadphase;
2048: } else {
2049: $$upload_output .= $embedded;
2050: }
2051: } else {
2052: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
2053: }
1.329 droeschl 2054: } else {
1.440 raeburn 2055: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 2056: }
1.457 raeburn 2057: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.476 raeburn 2058: } elsif (&Apache::loncommon::is_archive_file($mimetype)) {
2059: $nextphase = 'decompress_uploaded';
2060: my $position = scalar(@LONCAPA::map::order)-1;
2061: my $noextract = &return_to_editor();
2062: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
2063: my %archiveitems = (
2064: folderpath => $env{'form.folderpath'},
2065: pagepath => $env{'form.pagepath'},
2066: cmd => $nextphase,
2067: newidx => $newidx,
2068: position => $position,
2069: phase => $nextphase,
1.477 raeburn 2070: comment => $comment,
1.480 raeburn 2071: );
2072: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
2073: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 2074: $$upload_output = $showupload.
2075: &Apache::loncommon::decompress_form($mimetype,
2076: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 2077: \%archiveitems,\@current);
1.329 droeschl 2078: }
2079: }
2080: }
1.440 raeburn 2081: return $nextphase;
1.329 droeschl 2082: }
2083:
1.480 raeburn 2084: sub get_dir_list {
2085: my ($url,$coursenum,$coursedom,$newidx) = @_;
2086: my ($destination,$dir_root) = &embedded_destination();
2087: my ($dirlistref,$listerror) =
2088: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
2089: my @dir_lines;
2090: my $dirptr=16384;
2091: if (ref($dirlistref) eq 'ARRAY') {
2092: foreach my $dir_line (sort
2093: {
2094: my ($afile)=split('&',$a,2);
2095: my ($bfile)=split('&',$b,2);
2096: return (lc($afile) cmp lc($bfile));
2097: } (@{$dirlistref})) {
2098: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
2099: $filename =~ s/\s+$//;
2100: next if ($filename =~ /^\.\.?$/);
2101: my $isdir = 0;
2102: if ($dirptr&$testdir) {
2103: $isdir = 1;
2104: }
2105: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
2106: }
2107: }
2108: return @dir_lines;
2109: }
2110:
1.329 droeschl 2111: sub is_supplemental_title {
2112: my ($title) = @_;
2113: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
2114: }
2115:
2116: # --------------------------------------------------------------- An entry line
2117:
2118: sub entryline {
1.408 raeburn 2119: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_;
1.329 droeschl 2120: my ($foldertitle,$pagetitle,$renametitle);
2121: if (&is_supplemental_title($title)) {
1.488 raeburn 2122: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 2123: $pagetitle = $foldertitle;
2124: } else {
2125: $title=&HTML::Entities::encode($title,'"<>&\'');
2126: $renametitle=$title;
2127: $foldertitle=$title;
2128: $pagetitle=$title;
2129: }
2130:
2131: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 2132:
1.329 droeschl 2133:
2134: $renametitle=~s/\\/\\\\/g;
2135: $renametitle=~s/\"\;/\\\"/g;
2136: $renametitle=~s/ /%20/g;
1.379 bisitz 2137: my $line=&Apache::loncommon::start_data_table_row();
1.478 raeburn 2138: my ($form_start,$form_end,$form_common);
1.329 droeschl 2139: # Edit commands
2140: my ($container, $type, $esc_path, $path, $symb);
2141: if ($env{'form.folderpath'}) {
2142: $type = 'folder';
2143: $container = 'sequence';
2144: $esc_path=&escape($env{'form.folderpath'});
2145: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
2146: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
2147: }
2148: if ($env{'form.pagepath'}) {
2149: $type = $container = 'page';
1.440 raeburn 2150: $esc_path=&escape($env{'form.pagepath'});
1.329 droeschl 2151: $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
2152: $symb=&escape($env{'form.pagesymb'});
2153: }
2154: if ($allowed) {
2155: my $incindex=$index+1;
2156: my $selectbox='';
1.471 raeburn 2157: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 2158: ((split(/\:/,
1.344 bisitz 2159: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
2160: ne '') &&
1.329 droeschl 2161: ((split(/\:/,
1.344 bisitz 2162: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 2163: ne '')) {
2164: $selectbox=
2165: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.373 bisitz 2166: '<select name="newpos" onchange="this.form.submit()">';
1.329 droeschl 2167: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
2168: if ($i==$incindex) {
1.358 bisitz 2169: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 2170: } else {
2171: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
2172: }
2173: }
2174: $selectbox.='</select>';
2175: }
2176: my %lt=&Apache::lonlocal::texthash(
2177: 'up' => 'Move Up',
2178: 'dw' => 'Move Down',
2179: 'rm' => 'Remove',
2180: 'ct' => 'Cut',
2181: 'rn' => 'Rename',
2182: 'cp' => 'Copy');
2183: my $nocopy=0;
2184: my $nocut=0;
1.497 raeburn 2185: my $noremove=0;
1.492 raeburn 2186: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
2187: # no copy for published maps
2188: $nocopy=1;
1.329 droeschl 2189: }
1.344 bisitz 2190: if ($url=~/^\/res\/lib\/templates\//) {
2191: $nocopy=1;
1.329 droeschl 2192: $nocut=1;
2193: }
1.497 raeburn 2194: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2195: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2196: if ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
2197: if ($env{'form.folderpath'} =~ /^default&[^\&]+$/) {
2198: my %curr_groups = &Apache::longroup::coursegroups();
2199: if (keys(%curr_groups) > 0) {
2200: $noremove=1;
2201: }
2202: $nocut=1;
2203: $nocopy=1;
2204: }
2205: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
2206: my $group = $1;
2207: if ($env{'form.folderpath'} =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
2208: my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group);
2209: if (keys(%curr_group) > 0) {
2210: $noremove=1;
2211: }
2212: }
2213: $nocut=1;
2214: $nocopy=1;
2215: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
2216: my $group = $1;
2217: if ($env{'form.folderpath'} =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
2218: my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group);
2219: my %groupsettings = &Apache::longroup::get_group_settings($curr_group{$group});
2220: if (keys(%groupsettings) > 0) {
2221: $noremove=1;
2222: }
2223: $nocut=1;
2224: $nocopy=1;
2225: }
2226: } elsif ($env{'form.folderpath'} =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
2227: my $group = $1;
2228: my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group);
2229: if ($url =~ /group_boards_\Q$group\E/) {
2230: my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group);
2231: my %groupsettings = &Apache::longroup::get_group_settings($curr_group{$group});
2232: if (keys(%groupsettings) > 0) {
2233: if (ref($groupsettings{'functions'}) eq 'HASH') {
2234: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
2235: $noremove=1;
2236: }
2237: }
2238: }
2239: $nocut=1;
2240: $nocopy=1;
2241: }
2242: }
1.329 droeschl 2243: my $copylink=' ';
2244: my $cutlink=' ';
1.497 raeburn 2245: my $removelink=' ';
1.364 bisitz 2246:
1.329 droeschl 2247: my $skip_confirm = 0;
2248: if ( $folder =~ /^supplemental/
2249: || ($url =~ m{( /smppg$
2250: |/syllabus$
2251: |/aboutme$
2252: |/navmaps$
2253: |/bulletinboard$
2254: |\.html$
2255: |^/adm/wrapper/ext)}x)) {
2256: $skip_confirm = 1;
2257: }
2258:
2259: if (!$nocopy) {
2260: $copylink=(<<ENDCOPY);
1.484 raeburn 2261: <a href="javascript:markcopy('$esc_path','$index','$renametitle','$container','$symb','$folder');" class="LC_docs_copy">$lt{'cp'}</a>
1.329 droeschl 2262: ENDCOPY
2263: }
2264: if (!$nocut) {
2265: $cutlink=(<<ENDCUT);
1.484 raeburn 2266: <a href="javascript:cutres('$esc_path','$index','$renametitle','$container','$symb','$folder',$skip_confirm);" class="LC_docs_cut">$lt{'ct'}</a>
1.329 droeschl 2267: ENDCUT
2268: }
1.497 raeburn 2269: if (!$noremove) {
2270: $removelink=(<<ENDREM);
2271: <a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
2272: ENDREM
2273: }
1.478 raeburn 2274: $form_start = '
2275: <form action="/adm/coursedocs" method="post">
2276: ';
2277: $form_common=(<<END);
1.329 droeschl 2278: <input type="hidden" name="${type}path" value="$path" />
2279: <input type="hidden" name="${type}symb" value="$symb" />
2280: <input type="hidden" name="setparms" value="$orderidx" />
2281: <input type="hidden" name="changeparms" value="0" />
2282: END
2283: $form_end = '</form>';
2284: $line.=(<<END);
2285: <td>
1.379 bisitz 2286: <div class="LC_docs_entry_move">
1.499 ! raeburn 2287: <a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb'>
1.379 bisitz 2288: <img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" />
2289: </a>
2290: </div>
2291: <div class="LC_docs_entry_move">
1.499 ! raeburn 2292: <a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb'>
1.379 bisitz 2293: <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" />
2294: </a>
2295: </div>
1.329 droeschl 2296: </td>
2297: <td>
2298: $form_start
1.478 raeburn 2299: $form_common
1.329 droeschl 2300: $selectbox
2301: $form_end
2302: </td>
2303: <td class="LC_docs_entry_commands">
1.497 raeburn 2304: $removelink
1.329 droeschl 2305: $cutlink
2306: <a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>
2307: $copylink
2308: </td>
2309: END
2310:
2311: }
2312: # Figure out what kind of a resource this is
2313: my ($extension)=($url=~/\.(\w+)$/);
2314: my $uploaded=($url=~/^\/*uploaded\//);
2315: my $icon=&Apache::loncommon::icon($url);
2316: my $isfolder=0;
2317: my $ispage=0;
2318: my $folderarg;
2319: my $pagearg;
2320: my $pagefile;
2321: if ($uploaded) {
1.472 raeburn 2322: if (($extension eq 'sequence') || ($extension eq 'page')) {
2323: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
2324: my $containerarg = $1;
2325: if ($extension eq 'sequence') {
2326: $icon=$iconpath.'navmap.folder.closed.gif';
2327: $folderarg=$containerarg;
2328: $isfolder=1;
2329: } else {
2330: $icon=$iconpath.'page.gif';
2331: $pagearg=$containerarg;
2332: $ispage=1;
2333: }
2334: if ($allowed) {
2335: $url='/adm/coursedocs?';
2336: } else {
2337: $url='/adm/supplemental?';
2338: }
1.329 droeschl 2339: } else {
2340: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
2341: }
2342: }
1.364 bisitz 2343:
1.329 droeschl 2344: my $orig_url = $url;
1.340 raeburn 2345: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.329 droeschl 2346: my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
2347: if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
2348: my $symb=&Apache::lonnet::symbclean(
2349: &Apache::lonnet::declutter('uploaded/'.
2350: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
2351: $env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
2352: '.sequence').
2353: '___'.$residx.'___'.
2354: &Apache::lonnet::declutter($url));
2355: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
2356: $url=&Apache::lonnet::clutter($url);
2357: if ($url=~/^\/*uploaded\//) {
2358: $url=~/\.(\w+)$/;
2359: my $embstyle=&Apache::loncommon::fileembstyle($1);
2360: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
2361: $url='/adm/wrapper'.$url;
2362: } elsif ($embstyle eq 'ssi') {
2363: #do nothing with these
2364: } elsif ($url!~/\.(sequence|page)$/) {
2365: $url='/adm/coursedocs/showdoc'.$url;
2366: }
1.344 bisitz 2367: } elsif ($url=~m|^/ext/|) {
1.329 droeschl 2368: $url='/adm/wrapper'.$url;
2369: $external = 1;
2370: }
2371: if (&Apache::lonnet::symbverify($symb,$url)) {
2372: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
2373: } else {
2374: $url='';
2375: }
2376: if ($container eq 'page') {
2377: my $symb=$env{'form.pagesymb'};
1.364 bisitz 2378:
1.329 droeschl 2379: $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
2380: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
2381: }
2382: }
1.478 raeburn 2383: my ($rand_pick_text,$rand_order_text);
1.329 droeschl 2384: if ($isfolder || $extension eq 'sequence') {
2385: my $foldername=&escape($foldertitle);
2386: my $folderpath=$env{'form.folderpath'};
2387: if ($folderpath) { $folderpath.='&' };
1.344 bisitz 2388: # Append randompick number, hidden, and encrypted with ":" to foldername,
1.329 droeschl 2389: # so it gets transferred between levels
2390: $folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx,
2391: 'parameter_randompick'))[0]
2392: .':'.((&LONCAPA::map::getparameter($orderidx,
2393: 'parameter_hiddenresource'))[0]=~/^yes$/i)
2394: .':'.((&LONCAPA::map::getparameter($orderidx,
2395: 'parameter_encrypturl'))[0]=~/^yes$/i)
2396: .':'.((&LONCAPA::map::getparameter($orderidx,
2397: 'parameter_randomorder'))[0]=~/^yes$/i);
1.499 ! raeburn 2398: $url.='folderpath='.&escape($folderpath);
1.478 raeburn 2399: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
2400: 'parameter_randompick'))[0];
2401: my $rpckchk;
2402: if ($rpicknum) {
2403: $rpckchk = ' checked="checked"';
2404: }
2405: my $formname = 'edit_rpick_'.$orderidx;
2406: $rand_pick_text =
2407: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
2408: $form_common."\n".
2409: '<span class="LC_nobreak"><label><input type="checkbox" name="randpickon_'.$orderidx.'" id="rpick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="randompick_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" />';
2410: if ($rpicknum ne '') {
2411: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
2412: }
2413: $rand_pick_text .= '</span></form>';
1.329 droeschl 2414: my $ro_set=
2415: ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
1.478 raeburn 2416: $rand_order_text =
2417: $form_start.
2418: $form_common.'
2419: <span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onclick="'."this.form.changeparms.value='randomorder';this.form.submit()".'" '.$ro_set.' /> '.&mt('Random Order').' </label></span></form>';
1.329 droeschl 2420: }
2421: if ($ispage) {
2422: my $pagename=&escape($pagetitle);
2423: my $pagepath;
2424: my $folderpath=$env{'form.folderpath'};
2425: if ($folderpath) { $pagepath = $folderpath.'&' };
2426: $pagepath.=$pagearg.'&'.$pagename;
2427: my $symb=$env{'form.pagesymb'};
2428: if (!$symb) {
2429: my $path='uploaded/'.
2430: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
2431: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
2432: $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
2433: $residx,
2434: $path.$pagearg.'.page');
2435: }
2436: $url.='pagepath='.&escape($pagepath).
1.499 ! raeburn 2437: '&pagesymb='.&escape($symb);
1.329 droeschl 2438: }
1.396 raeburn 2439: if (($external) && ($allowed)) {
1.329 droeschl 2440: my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
2441: $external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>';
2442: } else {
2443: undef($external);
2444: }
1.408 raeburn 2445: my $reinit;
2446: if ($crstype eq 'Community') {
2447: $reinit = &mt('(re-initialize community to access)');
2448: } else {
2449: $reinit = &mt('(re-initialize course to access)');
2450: }
1.469 www 2451: $line.='<td>';
1.472 raeburn 2452: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 2453: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
2454: } elsif ($url) {
1.484 raeburn 2455: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1.470 raeburn 2456: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
1.469 www 2457: } else {
2458: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
2459: }
2460: $line.='</td><td>';
1.472 raeburn 2461: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 2462: $line.='<a href="'.$url.'">'.$title.'</a>';
2463: } elsif ($url) {
1.484 raeburn 2464: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1.470 raeburn 2465: $title,600,500);
1.469 www 2466: } else {
2467: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
2468: }
2469: $line.=$external."</td>";
1.478 raeburn 2470: $rand_pick_text = ' ' if ($rand_pick_text eq '');
2471: $rand_order_text = ' ' if ($rand_order_text eq '');
1.329 droeschl 2472: if (($allowed) && ($folder!~/^supplemental/)) {
2473: my %lt=&Apache::lonlocal::texthash(
2474: 'hd' => 'Hidden',
2475: 'ec' => 'URL hidden');
2476: my $enctext=
1.358 bisitz 2477: ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':'');
1.329 droeschl 2478: my $hidtext=
1.358 bisitz 2479: ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':'');
1.329 droeschl 2480: $line.=(<<ENDPARMS);
2481: <td class="LC_docs_entry_parameter">
2482: $form_start
1.478 raeburn 2483: $form_common
1.369 bisitz 2484: <label><input type="checkbox" name="hiddenresource_$orderidx" onclick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
1.329 droeschl 2485: $form_end
1.458 raeburn 2486: <br />
1.329 droeschl 2487: $form_start
1.478 raeburn 2488: $form_common
1.369 bisitz 2489: <label><input type="checkbox" name="encrypturl_$orderidx" onclick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
1.329 droeschl 2490: $form_end
2491: </td>
1.478 raeburn 2492: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
2493: $rand_order_text</td>
1.329 droeschl 2494: ENDPARMS
2495: }
1.379 bisitz 2496: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 2497: return $line;
2498: }
2499:
2500: =pod
2501:
2502: =item tiehash()
2503:
2504: tie the hash
2505:
2506: =cut
2507:
2508: sub tiehash {
2509: my ($mode)=@_;
2510: $hashtied=0;
2511: if ($env{'request.course.fn'}) {
2512: if ($mode eq 'write') {
2513: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
2514: &GDBM_WRCREAT(),0640)) {
2515: $hashtied=2;
2516: }
2517: } else {
2518: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
2519: &GDBM_READER(),0640)) {
2520: $hashtied=1;
2521: }
2522: }
1.364 bisitz 2523: }
1.329 droeschl 2524: }
2525:
2526: sub untiehash {
2527: if ($hashtied) { untie %hash; }
2528: $hashtied=0;
2529: return OK;
2530: }
2531:
2532:
2533:
2534:
2535: sub checkonthis {
2536: my ($r,$url,$level,$title)=@_;
2537: $url=&unescape($url);
2538: $alreadyseen{$url}=1;
2539: $r->rflush();
2540: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
2541: $r->print("\n<br />");
2542: if ($level==0) {
2543: $r->print("<br />");
2544: }
2545: for (my $i=0;$i<=$level*5;$i++) {
2546: $r->print(' ');
2547: }
2548: $r->print('<a href="'.$url.'" target="cat">'.
2549: ($title?$title:$url).'</a> ');
2550: if ($url=~/^\/res\//) {
2551: my $result=&Apache::lonnet::repcopy(
2552: &Apache::lonnet::filelocation('',$url));
2553: if ($result eq 'ok') {
2554: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
2555: $r->rflush();
2556: &Apache::lonnet::countacc($url);
2557: $url=~/\.(\w+)$/;
2558: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
2559: $r->print('<br />');
2560: $r->rflush();
2561: for (my $i=0;$i<=$level*5;$i++) {
2562: $r->print(' ');
2563: }
2564: $r->print('- '.&mt('Rendering:').' ');
2565: my ($errorcount,$warningcount)=split(/:/,
2566: &Apache::lonnet::ssi_body($url,
2567: ('grade_target'=>'web',
2568: 'return_only_error_and_warning_counts' => 1)));
2569: if (($errorcount) ||
2570: ($warningcount)) {
2571: if ($errorcount) {
1.369 bisitz 2572: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 2573: &mt('[quant,_1,error]',$errorcount).'</span>');
2574: }
2575: if ($warningcount) {
2576: $r->print('<span class="LC_warning">'.
2577: &mt('[quant,_1,warning]',$warningcount).'</span>');
2578: }
2579: } else {
2580: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
2581: }
2582: $r->rflush();
2583: }
2584: my $dependencies=
2585: &Apache::lonnet::metadata($url,'dependencies');
2586: foreach my $dep (split(/\,/,$dependencies)) {
2587: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
2588: &checkonthis($r,$dep,$level+1);
2589: }
2590: }
2591: } elsif ($result eq 'unavailable') {
2592: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
2593: } elsif ($result eq 'not_found') {
2594: unless ($url=~/\$/) {
2595: $r->print('<span class="LC_error">'.&mt('not found').'</b></span>');
2596: } else {
1.366 bisitz 2597: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 2598: }
2599: } else {
2600: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
2601: }
2602: }
2603: }
2604: }
2605:
2606:
2607:
2608: =pod
2609:
2610: =item list_symbs()
2611:
1.485 raeburn 2612: List Content Identifiers
1.329 droeschl 2613:
2614: =cut
2615:
2616: sub list_symbs {
2617: my ($r) = @_;
2618:
1.408 raeburn 2619: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 2620: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
2621: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
2622: $r->print(&startContentScreen('tools'));
1.329 droeschl 2623: my $navmap = Apache::lonnavmaps::navmap->new();
2624: if (!defined($navmap)) {
2625: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
2626: '<div class="LC_error">'.
2627: &mt('Unable to retrieve information about course contents').
2628: '</div>');
1.408 raeburn 2629: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 2630: } else {
1.484 raeburn 2631: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
2632: &Apache::loncommon::start_data_table().
2633: &Apache::loncommon::start_data_table_header_row().
2634: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
2635: &Apache::loncommon::end_data_table_header_row()."\n");
2636: my $count;
1.329 droeschl 2637: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 2638: $r->print(&Apache::loncommon::start_data_table_row().
2639: '<td>'.$res->compTitle().'</td>'.
2640: '<td>'.$res->symb().'</td>'.
2641: &Apache::loncommon::start_data_table_row());
2642: $count ++;
2643: }
2644: if (!$count) {
2645: $r->print(&Apache::loncommon::start_data_table_row().
2646: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
2647: &Apache::loncommon::end_data_table_row());
1.329 droeschl 2648: }
1.484 raeburn 2649: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 2650: }
2651: }
2652:
2653:
2654: sub verifycontent {
2655: my ($r) = @_;
1.408 raeburn 2656: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 2657: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents'));
2658: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents'));
2659: $r->print(&startContentScreen('tools'));
2660: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 2661: $hashtied=0;
2662: undef %alreadyseen;
2663: %alreadyseen=();
2664: &tiehash();
1.484 raeburn 2665:
1.329 droeschl 2666: foreach my $key (keys(%hash)) {
2667: if ($hash{$key}=~/\.(page|sequence)$/) {
2668: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
2669: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 2670: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 2671: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 2672: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 2673: }
2674: }
2675: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
2676: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
2677: }
2678: }
2679: &untiehash();
1.442 www 2680: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.329 droeschl 2681: }
2682:
2683:
2684: sub devalidateversioncache {
2685: my $src=shift;
2686: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
2687: &Apache::lonnet::clutter($src));
2688: }
2689:
2690: sub checkversions {
2691: my ($r) = @_;
1.408 raeburn 2692: my $crstype = &Apache::loncommon::course_type();
2693: $r->print(&Apache::loncommon::start_page("Check $crstype Document Versions"));
2694: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions"));
1.484 raeburn 2695: $r->print(&startContentScreen('tools'));
1.442 www 2696:
1.329 droeschl 2697: my $header='';
2698: my $startsel='';
2699: my $monthsel='';
2700: my $weeksel='';
2701: my $daysel='';
2702: my $allsel='';
2703: my %changes=();
2704: my $starttime=0;
2705: my $haschanged=0;
2706: my %setversions=&Apache::lonnet::dump('resourceversions',
2707: $env{'course.'.$env{'request.course.id'}.'.domain'},
2708: $env{'course.'.$env{'request.course.id'}.'.num'});
2709:
2710: $hashtied=0;
2711: &tiehash();
2712: my %newsetversions=();
2713: if ($env{'form.setmostrecent'}) {
2714: $haschanged=1;
2715: foreach my $key (keys(%hash)) {
2716: if ($key=~/^ids\_(\/res\/.+)$/) {
2717: $newsetversions{$1}='mostrecent';
2718: &devalidateversioncache($1);
2719: }
2720: }
2721: } elsif ($env{'form.setcurrent'}) {
2722: $haschanged=1;
2723: foreach my $key (keys(%hash)) {
2724: if ($key=~/^ids\_(\/res\/.+)$/) {
2725: my $getvers=&Apache::lonnet::getversion($1);
2726: if ($getvers>0) {
2727: $newsetversions{$1}=$getvers;
2728: &devalidateversioncache($1);
2729: }
2730: }
2731: }
2732: } elsif ($env{'form.setversions'}) {
2733: $haschanged=1;
2734: foreach my $key (keys(%env)) {
2735: if ($key=~/^form\.set_version_(.+)$/) {
2736: my $src=$1;
2737: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
2738: $newsetversions{$src}=$env{$key};
2739: &devalidateversioncache($src);
2740: }
2741: }
2742: }
2743: }
2744: if ($haschanged) {
2745: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
2746: $env{'course.'.$env{'request.course.id'}.'.domain'},
1.344 bisitz 2747: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
1.479 golterma 2748: $r->print(&Apache::loncommon::confirmwrapper(
2749: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
1.329 droeschl 2750: } else {
1.479 golterma 2751: $r->print(&Apache::loncommon::confirmwrapper(
2752: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
1.329 droeschl 2753: }
2754: &mark_hash_old();
2755: }
2756: &changewarning($r,'');
2757: if ($env{'form.timerange'} eq 'all') {
2758: # show all documents
1.408 raeburn 2759: $header=&mt('All Documents in '.$crstype);
1.329 droeschl 2760: $allsel=1;
2761: foreach my $key (keys(%hash)) {
2762: if ($key=~/^ids\_(\/res\/.+)$/) {
2763: my $src=$1;
2764: $changes{$src}=1;
2765: }
2766: }
2767: } else {
2768: # show documents which changed
2769: %changes=&Apache::lonnet::dump
2770: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
2771: $env{'course.'.$env{'request.course.id'}.'.num'});
2772: my $firstkey=(keys(%changes))[0];
2773: unless ($firstkey=~/^error\:/) {
2774: unless ($env{'form.timerange'}) {
2775: $env{'form.timerange'}=604800;
2776: }
2777: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
2778: .&mt('seconds');
2779: if ($env{'form.timerange'}==-1) {
2780: $seltext='since start of course';
2781: $startsel='selected';
2782: $env{'form.timerange'}=time;
2783: }
2784: $starttime=time-$env{'form.timerange'};
2785: if ($env{'form.timerange'}==2592000) {
2786: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
2787: $monthsel='selected';
2788: } elsif ($env{'form.timerange'}==604800) {
2789: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
2790: $weeksel='selected';
2791: } elsif ($env{'form.timerange'}==86400) {
2792: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
2793: $daysel='selected';
2794: }
2795: $header=&mt('Content changed').' '.$seltext;
2796: } else {
2797: $header=&mt('No content modifications yet.');
2798: }
2799: }
2800: %setversions=&Apache::lonnet::dump('resourceversions',
2801: $env{'course.'.$env{'request.course.id'}.'.domain'},
2802: $env{'course.'.$env{'request.course.id'}.'.num'});
2803: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 2804: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 2805: 'lm' => 'Version changes since last Month',
2806: 'lw' => 'Version changes since last Week',
2807: 'sy' => 'Version changes since Yesterday',
2808: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 2809: 'cd' => 'Change display',
1.329 droeschl 2810: 'sd' => 'Display',
2811: 'fi' => 'File',
2812: 'md' => 'Modification Date',
2813: 'mr' => 'Most recently published Version',
1.408 raeburn 2814: 've' => 'Version used in '.$crstype,
2815: 'vu' => 'Set Version to be used in '.$crstype,
2816: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 2817: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
2818: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 2819: 'di' => 'Differences',
1.484 raeburn 2820: 'save' => 'Save changes',
2821: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 2822: 'act' => 'Actions');
1.329 droeschl 2823: $r->print(<<ENDHEADERS);
1.484 raeburn 2824: <h4 class="LC_info">$header</h4>
1.329 droeschl 2825: <form action="/adm/coursedocs" method="post">
2826: <input type="hidden" name="versions" value="1" />
1.484 raeburn 2827: <div class="LC_left_float">
1.479 golterma 2828: <fieldset>
1.484 raeburn 2829: <legend>$lt{'cd'}</legend>
1.329 droeschl 2830: <select name="timerange">
2831: <option value='all' $allsel>$lt{'al'}</option>
2832: <option value="-1" $startsel>$lt{'st'}</option>
2833: <option value="2592000" $monthsel>$lt{'lm'}</option>
2834: <option value="604800" $weeksel>$lt{'lw'}</option>
2835: <option value="86400" $daysel>$lt{'sy'}</option>
2836: </select>
2837: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 2838: </fieldset>
2839: </div>
2840: <div class="LC_left_float">
2841: <fieldset>
2842: <legend>$lt{'act'}</legend>
2843: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" /><br />
2844: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" />
2845: </fieldset>
2846: </div>
2847: <br clear="all" />
2848: <hr />
2849: <h4>$lt{'vers'}</h4>
1.479 golterma 2850: <input type="submit" name="setversions" value="$lt{'save'}" />
1.329 droeschl 2851: <table border="0">
2852: ENDHEADERS
1.479 golterma 2853: #number of columns for version history
2854: my $num_ver_col = 1;
2855: $r->print(
2856: &Apache::loncommon::start_data_table().
2857: &Apache::loncommon::start_data_table_header_row().
2858: '<th>'.&mt('Resources').'</th>'.
2859: "<th>$lt{'mr'}</th>".
2860: "<th>$lt{'ve'}</th>".
2861: "<th>$lt{'vu'}</th>".
2862: '<th colspan="'.$num_ver_col.'">'.&mt('History').'</th>'.
2863: '</b>');
1.329 droeschl 2864: foreach my $key (sort(keys(%changes))) {
1.496 golterma 2865: #excludes not versionable problems from resource version history:
2866: if ($changes{$key}>$starttime && $key !~ /^\/res\/lib\/templates/) {
1.329 droeschl 2867: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
2868: my $currentversion=&Apache::lonnet::getversion($key);
2869: if ($currentversion<0) {
1.479 golterma 2870: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
1.329 droeschl 2871: }
2872: my $linkurl=&Apache::lonnet::clutter($key);
1.479 golterma 2873: $r->print(
2874: &Apache::loncommon::end_data_table_header_row().
2875: &Apache::loncommon::start_data_table_row().
2876: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br>'.
2877: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
2878: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br>('.
2879: &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate')).')</span></td>'.
2880: '<td align="right">');
1.329 droeschl 2881: # Used in course
2882: my $usedversion=$hash{'version_'.$linkurl};
2883: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.479 golterma 2884: if($usedversion != $currentversion){
2885: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
2886: }else{
2887: $r->print($usedversion);
2888: }
1.329 droeschl 2889: } else {
2890: $r->print($currentversion);
2891: }
1.479 golterma 2892: $r->print('</td><td title="'.$lt{'vu'}.'">');
1.329 droeschl 2893: # Set version
2894: $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
2895: 'set_version_'.$linkurl,
1.428 raeburn 2896: {'select_form_order' =>
1.329 droeschl 2897: ['',1..$currentversion,'mostrecent'],
2898: '' => '',
1.411 bisitz 2899: 'mostrecent' => &mt('most recent'),
1.428 raeburn 2900: map {$_,$_} (1..$currentversion)}));
1.329 droeschl 2901: my $lastold=1;
2902: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
2903: my $url=$root.'.'.$prevvers.'.'.$extension;
2904: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
2905: $starttime) {
2906: $lastold=$prevvers;
2907: }
2908: }
1.364 bisitz 2909: #
1.329 droeschl 2910: # Code to figure out how many version entries should go in
2911: # each of the four columns
2912: my $entries_per_col = 0;
2913: my $num_entries = ($currentversion-$lastold);
1.479 golterma 2914: if ($num_entries % $num_ver_col == 0) {
2915: $entries_per_col = $num_entries/$num_ver_col;
1.329 droeschl 2916: } else {
1.479 golterma 2917: $entries_per_col = $num_entries/$num_ver_col + 1;
1.329 droeschl 2918: }
2919: my $entries_count = 0;
1.479 golterma 2920: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
1.329 droeschl 2921: my $cols_output = 1;
2922: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
2923: my $url=$root.'.'.$prevvers.'.'.$extension;
2924: $r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url).
2925: '">'.&mt('Version').' '.$prevvers.'</a> ('.
2926: &Apache::lonlocal::locallocaltime(
2927: &Apache::lonnet::metadata($url,
2928: 'lastrevisiondate')
2929: ).
2930: ')');
2931: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
2932: $r->print(' <a href="/adm/diff?filename='.
2933: &Apache::lonnet::clutter($root.'.'.$extension).
2934: '&versionone='.$prevvers.
1.462 raeburn 2935: '" target="diffs">'.&mt('Diffs').'</a>');
1.329 droeschl 2936: }
2937: $r->print('</span><br />');
2938: if (++$entries_count % $entries_per_col == 0) {
1.479 golterma 2939: $r->print('</span></td>');
2940: if ($cols_output != $num_ver_col) {
2941: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
1.329 droeschl 2942: $cols_output++;
2943: }
2944: }
2945: }
1.479 golterma 2946: while($cols_output++ < $num_ver_col) {
2947: $r->print('</span></td><td>');
1.329 droeschl 2948: }
2949: }
2950: }
1.479 golterma 2951: $r->print('</td>'.&Apache::loncommon::end_data_table_row().
2952: &Apache::loncommon::end_data_table().
2953: '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />');
1.329 droeschl 2954:
2955: &untiehash();
2956: }
2957:
2958: sub mark_hash_old {
2959: my $retie_hash=0;
2960: if ($hashtied) {
2961: $retie_hash=1;
2962: &untiehash();
2963: }
2964: &tiehash('write');
2965: $hash{'old'}=1;
2966: &untiehash();
2967: if ($retie_hash) { &tiehash(); }
2968: }
2969:
2970: sub is_hash_old {
2971: my $untie_hash=0;
2972: if (!$hashtied) {
2973: $untie_hash=1;
2974: &tiehash();
2975: }
2976: my $return=$hash{'old'};
2977: if ($untie_hash) { &untiehash(); }
2978: return $return;
2979: }
2980:
2981: sub changewarning {
2982: my ($r,$postexec,$message,$url)=@_;
2983: if (!&is_hash_old()) { return; }
2984: my $pathvar='folderpath';
2985: my $path=&escape($env{'form.folderpath'});
2986: if (!defined($url)) {
2987: if (defined($env{'form.pagepath'})) {
2988: $pathvar='pagepath';
2989: $path=&escape($env{'form.pagepath'});
2990: $path.='&pagesymb='.&escape($env{'form.pagesymb'});
2991: }
2992: $url='/adm/coursedocs?'.$pathvar.'='.$path;
2993: }
2994: my $course_type = &Apache::loncommon::course_type();
2995: if (!defined($message)) {
2996: $message='Changes will become active for your current session after [_1], or the next time you log in.';
2997: }
2998: $r->print("\n\n".
1.372 bisitz 2999: '<script type="text/javascript">'."\n".
3000: '// <![CDATA['."\n".
3001: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
3002: '// ]]>'."\n".
1.369 bisitz 3003: '</script>'."\n".
1.375 tempelho 3004: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.329 droeschl 3005: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 3006: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 3007: &mt($message,' <input type="hidden" name="'.
3008: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 3009: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 3010: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 3011: }
3012:
3013:
3014: sub init_breadcrumbs {
3015: my ($form,$text)=@_;
3016: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 3017: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 3018: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 3019: faq=>273,
3020: bug=>'Instructor Interface',
3021: help => 'Docs_Adding_Course_Doc'});
3022: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
3023: text=>$text,
3024: faq=>273,
3025: bug=>'Instructor Interface'});
3026: }
3027:
1.441 www 3028: # subroutine to list form elements
3029: sub create_list_elements {
3030: my @formarr = @_;
3031: my $list = '';
3032: for my $button (@formarr){
3033: for my $picture(keys %$button) {
3034: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'});
3035: }
3036: }
3037: return $list;
3038: }
1.329 droeschl 3039:
1.441 www 3040: # subroutine to create ul from list elements
3041: sub create_form_ul {
3042: my $list = shift;
3043: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
3044: return $ul;
3045: }
1.329 droeschl 3046:
1.442 www 3047: #
3048: # Start tabs
3049: #
3050:
3051: sub startContentScreen {
1.484 raeburn 3052: my ($mode) = @_;
3053: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 3054: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 3055: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
3056: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
3057: $output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'."\n";
3058: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
3059: } else {
3060: $output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Content Editor').' </b></a></li>'."\n";
3061: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
3062: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
3063: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
3064: }
3065: $output .= "\n".'</ul>'."\n";
3066: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
3067: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
3068: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
3069: return $output;
1.442 www 3070: }
3071:
3072: #
3073: # End tabs
3074: #
3075:
3076: sub endContentScreen {
1.484 raeburn 3077: return '</div></div></div>';
1.442 www 3078: }
1.329 droeschl 3079:
1.446 www 3080: sub supplemental_base {
1.472 raeburn 3081: return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Content'));
1.446 www 3082: }
3083:
1.329 droeschl 3084: sub handler {
3085: my $r = shift;
3086: &Apache::loncommon::content_type($r,'text/html');
3087: $r->send_http_header;
3088: return OK if $r->header_only;
1.484 raeburn 3089:
3090: # get course data
1.408 raeburn 3091: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 3092: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
3093: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3094:
3095: # graphics settings
3096: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 3097:
1.443 www 3098: #
1.329 droeschl 3099: # --------------------------------------------- Initialize help topics for this
3100: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
3101: 'Adding_External_Resource','Navigate_Content',
3102: 'Adding_Folders','Docs_Overview', 'Load_Map',
3103: 'Supplemental','Score_Upload_Form','Adding_Pages',
3104: 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
3105: 'Check_Resource_Versions','Verify_Content') {
3106: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
3107: }
3108: # Composite help files
3109: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
3110: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
3111: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
3112: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
3113: $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
3114: 'Option_Response_Simple');
3115: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
3116: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 3117: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 3118: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 3119: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 3120: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
3121:
1.472 raeburn 3122:
3123: my $allowed;
3124: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
3125: unless ($r->uri eq '/adm/supplemental') {
3126: # does this user have privileges to modify content.
3127: $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
3128: }
3129:
1.484 raeburn 3130: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chooseserver',
3131: 'inhibitmenu']);
3132: if ($allowed && $env{'form.chooseserver'}) {
3133: &choose_dump_server($r);
3134: return OK;
3135: } elsif ($allowed && $env{'form.verify'}) {
1.329 droeschl 3136: &init_breadcrumbs('verify','Verify Content');
3137: &verifycontent($r);
3138: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 3139: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 3140: &list_symbs($r);
3141: } elsif ($allowed && $env{'form.docslog'}) {
3142: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 3143: my $folder = $env{'form.folder'};
3144: if ($folder eq '') {
3145: $folder='default';
3146: }
3147: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath);
1.329 droeschl 3148: } elsif ($allowed && $env{'form.versions'}) {
3149: &init_breadcrumbs('versions','Check/Set Resource Versions');
3150: &checkversions($r);
3151: } elsif ($allowed && $env{'form.dumpcourse'}) {
1.484 raeburn 3152: &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 3153: &dumpcourse($r);
3154: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 3155: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 3156: &Apache::imsexport::exportcourse($r);
1.329 droeschl 3157: } else {
1.445 www 3158: #
3159: # Done catching special calls
1.484 raeburn 3160: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 3161: # Get the parameters that may be needed
3162: #
3163: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
3164: ['folderpath','pagepath',
1.466 www 3165: 'pagesymb','forcesupplement','forcestandard',
1.484 raeburn 3166: 'tools','symb','command']);
1.445 www 3167:
3168: # standard=1: this is a "new-style" course with an uploaded map as top level
3169: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 3170:
3171: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 3172:
1.484 raeburn 3173: # Decide whether this should display supplemental or main content or utilities
1.445 www 3174: # supplementalflag=1: show supplemental documents
3175: # supplementalflag=0: show standard documents
1.484 raeburn 3176: # toolsflag=1: show utilities
1.445 www 3177:
3178:
3179: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
3180: if (($env{'form.folderpath'}=~/^default/) || $env{'form.folderpath'} eq "" || ($env{'form.pagepath'})) {
3181: $supplementalflag=0;
3182: }
3183: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
3184: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
3185: unless ($allowed) { $supplementalflag=1; }
3186: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 3187: my $toolsflag=0;
3188: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 3189:
1.329 droeschl 3190: my $script='';
3191: my $showdoc=0;
1.457 raeburn 3192: my $addentries = {};
1.475 raeburn 3193: my $container;
1.329 droeschl 3194: my $containertag;
3195: my $uploadtag;
3196:
1.464 www 3197: # Do we directly jump somewhere?
1.466 www 3198:
1.464 www 3199: if ($env{'form.command'} eq 'direct') {
1.468 raeburn 3200: my ($mapurl,$id,$resurl);
1.472 raeburn 3201: if ($env{'form.symb'} ne '') {
1.468 raeburn 3202: ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
3203: if ($resurl=~/\.(sequence|page)$/) {
3204: $mapurl=$resurl;
3205: } elsif ($resurl eq 'adm/navmaps') {
3206: $mapurl=$env{'course.'.$env{'request.course.id'}.'.url'};
3207: }
1.472 raeburn 3208: my $mapresobj;
3209: my $navmap = Apache::lonnavmaps::navmap->new();
3210: if (ref($navmap)) {
3211: $mapresobj = $navmap->getResourceByUrl($mapurl);
3212: }
3213: $mapurl=~s{^.*/([^/]+)\.(\w+)$}{$1};
3214: my $type=$2;
3215: my $path;
3216: if (ref($mapresobj)) {
3217: my $pcslist = $mapresobj->map_hierarchy();
3218: if ($pcslist ne '') {
3219: foreach my $pc (split(/,/,$pcslist)) {
3220: next if ($pc <= 1);
3221: my $res = $navmap->getByMapPc($pc);
3222: if (ref($res)) {
3223: my $thisurl = $res->src();
3224: $thisurl=~s{^.*/([^/]+)\.\w+$}{$1};
3225: my $thistitle = $res->title();
3226: $path .= '&'.
3227: &Apache::lonhtmlcommon::entity_encode($thisurl).'&'.
3228: &Apache::lonhtmlcommon::entity_encode($thistitle).
3229: ':'.$res->randompick().
3230: ':'.$res->randomout().
3231: ':'.$res->encrypted().
3232: ':'.$res->randomorder();
3233: }
1.467 raeburn 3234: }
3235: }
1.472 raeburn 3236: $path .= '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
1.467 raeburn 3237: &Apache::lonhtmlcommon::entity_encode($mapresobj->title()).
3238: ':'.$mapresobj->randompick().
3239: ':'.$mapresobj->randomout().
3240: ':'.$mapresobj->encrypted().
3241: ':'.$mapresobj->randomorder();
1.472 raeburn 3242: } else {
3243: my $maptitle = &Apache::lonnet::gettitle($mapurl);
3244: $path = '&default&...::::'.
3245: '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
3246: &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
3247: }
3248: $path = 'default&'.
3249: &Apache::lonhtmlcommon::entity_encode('Main Course Documents').
3250: $path;
3251: if ($type eq 'sequence') {
3252: $env{'form.folderpath'}=$path;
3253: $env{'form.pagepath'}='';
3254: } else {
3255: $env{'form.pagepath'}=$path;
3256: $env{'form.folderpath'}='';
3257: }
3258: } elsif ($env{'form.supppath'} ne '') {
3259: $env{'form.folderpath'}=$env{'form.supppath'};
1.466 www 3260: }
1.472 raeburn 3261: } elsif ($env{'form.command'} eq 'editdocs') {
3262: $env{'form.folderpath'} = 'default&'.
3263: &Apache::lonhtmlcommon::entity_encode('Main Course Content');
3264: $env{'form.pagepath'}='';
3265: } elsif ($env{'form.command'} eq 'editsupp') {
3266: $env{'form.folderpath'} = 'default&'.
3267: &Apache::lonhtmlcommon::entity_encode('Supplemental Content');
3268: $env{'form.pagepath'}='';
1.464 www 3269: }
3270:
1.445 www 3271: # Where do we store these for when we come back?
3272: my $stored_folderpath='docs_folderpath';
3273: if ($supplementalflag) {
3274: $stored_folderpath='docs_sup_folderpath';
3275: }
1.464 www 3276:
1.329 droeschl 3277: # No folderpath, no pagepath, see if we have something stored
3278: if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
1.445 www 3279: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.329 droeschl 3280: {'folderpath' => 'scalar'});
3281: }
1.446 www 3282:
3283: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 3284: if (!$allowed) {
1.446 www 3285: $env{'form.pagepath'}='';
3286: unless ($env{'form.folderpath'} =~ /^supplemental/) {
3287: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 3288: }
3289: }
1.446 www 3290: # If we still not have a folderpath, see if we can resurrect at pagepath
1.409 raeburn 3291: if (!$env{'form.folderpath'} && $allowed) {
1.445 www 3292: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.329 droeschl 3293: {'pagepath' => 'scalar'});
3294: }
1.446 www 3295: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 3296: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 3297: $env{'form.folderpath'} = &supplemental_base()
3298: .'&'.
1.329 droeschl 3299: $env{'form.folderpath'};
3300: }
1.446 www 3301: # If after all of this, we still don't have any paths, make them
3302: unless (($env{'form.pagepath'}) || ($env{'form.folderpath'})) {
3303: if ($supplementalflag) {
3304: $env{'form.folderpath'}=&supplemental_base();
3305: } else {
3306: $env{'form.folderpath'}='default';
3307: }
1.472 raeburn 3308: }
1.446 www 3309:
1.445 www 3310: # Store this
1.484 raeburn 3311: unless ($toolsflag) {
3312: &Apache::loncommon::store_course_settings($stored_folderpath,
3313: {'pagepath' => 'scalar',
3314: 'folderpath' => 'scalar'});
3315: if ($env{'form.folderpath'}) {
3316: my (@folderpath)=split('&',$env{'form.folderpath'});
3317: $env{'form.foldername'}=&unescape(pop(@folderpath));
3318: $env{'form.folder'}=pop(@folderpath);
3319: $container='sequence';
3320: }
3321: if ($env{'form.pagepath'}) {
3322: my (@pagepath)=split('&',$env{'form.pagepath'});
3323: $env{'form.pagename'}=&unescape(pop(@pagepath));
3324: $env{'form.folder'}=pop(@pagepath);
3325: $container='page';
3326: $containertag = '<input type="hidden" name="pagepath" value="" />'.
3327: '<input type="hidden" name="pagesymb" value="" />';
3328: $uploadtag =
3329: '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
3330: '<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />'.
3331: '<input type="hidden" name="folderpath" value="" />';
3332: } else {
3333: my $folderpath=$env{'form.folderpath'};
3334: if (!$folderpath) {
3335: if ($env{'form.folder'} eq '' ||
3336: $env{'form.folder'} eq 'supplemental') {
3337: $folderpath='default&'.
3338: &escape(&mt('Main '.$crstype.' Documents'));
3339: }
3340: }
3341: $containertag = '<input type="hidden" name="folderpath" value="" />';
3342: $uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
3343: }
3344: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
3345: $showdoc='/'.$1;
3346: }
3347: if ($showdoc) { # got called in sequence from course
3348: $allowed=0;
3349: } else {
3350: if ($allowed) {
3351: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
3352: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 3353: }
3354: }
1.329 droeschl 3355: }
3356:
1.344 bisitz 3357: # get personal data
1.329 droeschl 3358: my $uname=$env{'user.name'};
3359: my $udom=$env{'user.domain'};
3360: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
3361:
3362: if ($allowed) {
1.484 raeburn 3363: if ($toolsflag) {
3364: $script .= &inject_data_js();
3365: my ($home,$other,%outhash)=&authorhosts();
3366: if (!$home && $other) {
3367: my @hosts;
3368: foreach my $aurole (keys(%outhash)) {
3369: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
3370: push(@hosts,$outhash{$aurole});
3371: }
3372: }
3373: $script .= &dump_switchserver_js(@hosts);
3374: }
1.458 raeburn 3375: } else {
1.484 raeburn 3376: my @tabids;
3377: if ($supplementalflag) {
3378: @tabids = ('002','ee2','ff2');
3379: } else {
3380: @tabids = ('aa1','bb1','cc1','ff1');
3381: unless ($env{'form.pagepath'}) {
3382: unshift(@tabids,'001');
3383: push(@tabids,('dd1','ee1'));
3384: }
1.458 raeburn 3385: }
1.484 raeburn 3386: my $tabidstr = join("','",@tabids);
3387: $script .= &editing_js($udom,$uname,$supplementalflag).
3388: &history_tab_js().
3389: &inject_data_js().
1.485 raeburn 3390: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr);
1.484 raeburn 3391: $addentries = {
1.485 raeburn 3392: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 3393: };
1.458 raeburn 3394: }
1.492 raeburn 3395: if ($env{'docs.markedcopy_url'}) {
3396: $script .= &paste_popup_js();
3397: }
1.329 droeschl 3398: }
3399: # -------------------------------------------------------------------- Body tag
1.369 bisitz 3400: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 3401: .'// <![CDATA['."\n"
3402: .$script."\n"
3403: .'// ]]>'."\n"
3404: .'</script>'."\n";
1.385 bisitz 3405:
3406: # Breadcrumbs
3407: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.446 www 3408: unless ($showdoc) {
1.392 raeburn 3409: &Apache::lonhtmlcommon::add_breadcrumb({
1.446 www 3410: href=>"/adm/coursedocs",text=>"$crstype Contents"});
1.392 raeburn 3411:
1.446 www 3412: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.457 raeburn 3413: {'force_register' => $showdoc,
3414: 'add_entries' => $addentries,
3415: })
1.392 raeburn 3416: .&Apache::loncommon::help_open_menu('','',273,'RAT')
3417: .&Apache::lonhtmlcommon::breadcrumbs(
1.484 raeburn 3418: 'Editing '.$crstype.' Contents',
1.392 raeburn 3419: 'Docs_Adding_Course_Doc')
3420: );
1.446 www 3421: } else {
1.408 raeburn 3422: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
1.402 raeburn 3423: {'force_register' => $showdoc,}));
1.392 raeburn 3424: }
1.364 bisitz 3425:
1.329 droeschl 3426: my %allfiles = ();
3427: my %codebase = ();
1.440 raeburn 3428: my ($upload_result,$upload_output,$uploadphase);
1.329 droeschl 3429: if ($allowed) {
3430: if (($env{'form.uploaddoc.filename'}) &&
3431: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 3432: my $context = $1;
3433: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 3434: undef($hadchanges);
1.440 raeburn 3435: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
3436: \%allfiles,\%codebase,$context);
1.329 droeschl 3437: if ($hadchanges) {
3438: &mark_hash_old();
3439: }
1.440 raeburn 3440: $r->print($upload_output);
3441: } elsif ($env{'form.phase'} eq 'upload_embedded') {
3442: # Process file upload - phase two - upload embedded objects
3443: $uploadphase = 'check_embedded';
3444: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
3445: my $state = &embedded_form_elems($uploadphase,$primaryurl,
3446: $env{'form.newidx'});
3447: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
3448: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3449: my ($destination,$dir_root) = &embedded_destination();
3450: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
3451: my $actionurl = '/adm/coursedocs';
3452: my ($result,$flag) =
3453: &Apache::loncommon::upload_embedded('coursedoc',$destination,
3454: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
3455: $actionurl);
3456: $r->print($result.&return_to_editor());
3457: } elsif ($env{'form.phase'} eq 'check_embedded') {
3458: # Process file upload - phase three - modify references in HTML file
3459: $uploadphase = 'modified_orightml';
3460: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
3461: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3462: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 3463: my $result =
3464: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
3465: $docuname,$docudom,undef,
3466: $dir_root);
3467: $r->print($result.&return_to_editor());
1.476 raeburn 3468: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
3469: $uploadphase = 'decompress_phase_one';
3470: $r->print(&decompression_phase_one().
3471: &return_to_editor());
3472: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
3473: $uploadphase = 'decompress_phase_two';
3474: $r->print(&decompression_phase_two().
3475: &return_to_editor());
1.329 droeschl 3476: }
3477: }
3478:
1.484 raeburn 3479: if ($allowed && $toolsflag) {
3480: $r->print(&startContentScreen('tools'));
3481: $r->print(&generate_admin_menu($crstype));
3482: $r->print(&endContentScreen());
3483: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 3484: # -----------------------------------------------------------------------------
3485: my %lt=&Apache::lonlocal::texthash(
1.408 raeburn 3486: 'uplm' => 'Upload a new main '.lc($crstype).' document',
3487: 'upls' => 'Upload a new supplemental '.lc($crstype).' document',
1.329 droeschl 3488: 'impp' => 'Import a document',
3489: 'copm' => 'All documents out of a published map into this folder',
1.417 droeschl 3490: 'upld' => 'Import Document',
1.329 droeschl 3491: 'srch' => 'Search',
3492: 'impo' => 'Import',
1.487 raeburn 3493: 'lnks' => 'Import from Stored Links',
1.329 droeschl 3494: 'selm' => 'Select Map',
3495: 'load' => 'Load Map',
1.419 bisitz 3496: 'reco' => 'Recover Deleted Documents',
1.329 droeschl 3497: 'newf' => 'New Folder',
3498: 'newp' => 'New Composite Page',
3499: 'extr' => 'External Resource',
3500: 'syll' => 'Syllabus',
1.425 raeburn 3501: 'navc' => 'Table of Contents',
1.343 biermanm 3502: 'sipa' => 'Simple Course Page',
1.329 droeschl 3503: 'sipr' => 'Simple Problem',
3504: 'drbx' => 'Drop Box',
1.451 www 3505: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 3506: 'bull' => 'Discussion Board',
1.347 weissno 3507: 'mypi' => 'My Personal Information Page',
1.353 weissno 3508: 'grpo' => 'Group Portfolio',
1.329 droeschl 3509: 'rost' => 'Course Roster',
1.348 weissno 3510: 'abou' => 'Personal Information Page for a User',
1.377 bisitz 3511: 'imsf' => 'IMS Import',
3512: 'imsl' => 'Import IMS package',
1.329 droeschl 3513: 'file' => 'File',
3514: 'title' => 'Title',
3515: 'comment' => 'Comment',
1.403 raeburn 3516: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.368 truskell 3517: 'nd' => 'Upload Document',
1.329 droeschl 3518: 'pm' => 'Published Map',
3519: 'sd' => 'Special Document',
3520: 'mo' => 'More Options',
3521: );
3522: # -----------------------------------------------------------------------------
3523: my $fileupload=(<<FIUP);
3524: $lt{'file'}:<br />
3525: <input type="file" name="uploaddoc" size="40" />
3526: FIUP
3527:
3528: my $checkbox=(<<CHBO);
3529: <!-- <label>$lt{'parse'}?
3530: <input type="checkbox" name="parserflag" />
3531: </label> -->
3532: <label>
3533: <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
3534: </label>
3535: CHBO
3536:
1.458 raeburn 3537: my $fileuploada = "<br clear='all' /><input type='submit' value='".$lt{'upld'}."' /> $help{'Uploading_From_Harddrive'}";
1.329 droeschl 3538: my $fileuploadform=(<<FUFORM);
3539: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.371 tempelho 3540: <input type="hidden" name="active" value="aa" />
1.329 droeschl 3541: $fileupload
3542: <br />
3543: $lt{'title'}:<br />
1.458 raeburn 3544: <input type="text" size="60" name="comment" />
1.329 droeschl 3545: $uploadtag
3546: <input type="hidden" name="cmd" value="upload_default" />
3547: <br />
1.458 raeburn 3548: <span class="LC_nobreak" style="float:left">
1.329 droeschl 3549: $checkbox
3550: </span>
1.383 tempelho 3551: FUFORM
1.459 raeburn 3552: $fileuploadform .= $fileuploada.'</form>';
1.329 droeschl 3553:
3554: my $simpleeditdefaultform=(<<SEDFFORM);
3555: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
1.371 tempelho 3556: <input type="hidden" name="active" value="bb" />
1.383 tempelho 3557: SEDFFORM
3558: my @simpleeditdefaultforma = (
1.423 onken 3559: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => "$uploadtag<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" },
3560: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" },
1.487 raeburn 3561: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:open_StoredLinks_Import();" />' => "<a class='LC_menubuttons_link' href='javascript:open_StoredLinks_Import();'>$lt{'lnks'}</a>" },
1.383 tempelho 3562: );
1.443 www 3563: $simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma));
1.383 tempelho 3564: $simpleeditdefaultform .=(<<SEDFFORM);
1.459 raeburn 3565: <hr id="bb_hrule" style="width:0px;text-align:left;margin-left:0" />
1.329 droeschl 3566: $lt{'copm'}<br />
3567: <input type="text" size="40" name="importmap" /><br />
1.458 raeburn 3568: <span class="LC_nobreak" style="float:left"><input type="button"
1.369 bisitz 3569: onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
1.329 droeschl 3570: value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
3571: $help{'Load_Map'}</span>
3572: </form>
3573: SEDFFORM
3574:
1.442 www 3575: my $extresourcesform=(<<ERFORM);
3576: <form action="/adm/coursedocs" method="post" name="newext">
3577: $uploadtag
3578: <input type="hidden" name="importdetail" value="" />
3579: <a class="LC_menubuttons_link" href="javascript:makenewext('newext');">$lt{'extr'}</a>$help{'Adding_External_Resource'}
3580: </form>
1.329 droeschl 3581: ERFORM
3582:
1.442 www 3583:
1.329 droeschl 3584: if ($allowed) {
1.492 raeburn 3585: my $folder = $env{'form.folder'};
3586: if ($folder eq '') {
3587: $folder='default';
3588: }
3589: &update_paste_buffer($coursenum,$coursedom,$folder);
1.337 ehlerst 3590: $r->print(<<HIDDENFORM);
3591: <form name="renameform" method="post" action="/adm/coursedocs">
3592: <input type="hidden" name="title" />
3593: <input type="hidden" name="cmd" />
3594: <input type="hidden" name="markcopy" />
3595: <input type="hidden" name="copyfolder" />
3596: $containertag
3597: </form>
1.484 raeburn 3598:
1.337 ehlerst 3599: HIDDENFORM
1.484 raeburn 3600: $r->print(&makesimpleeditform($uploadtag)."\n".
3601: &makedocslogform($uploadtag."\n".
3602: '<input type="hidden" name="folder" value="'.
3603: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 3604: }
1.442 www 3605:
3606: # Generate the tabs
1.472 raeburn 3607: my $mode;
3608: if (($supplementalflag) && (!$allowed)) {
3609: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
3610: } else {
1.484 raeburn 3611: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.472 raeburn 3612: }
1.443 www 3613:
1.442 www 3614: #
3615:
3616: my $savefolderpath;
3617:
1.395 raeburn 3618: if ($allowed) {
1.329 droeschl 3619: my $folder=$env{'form.folder'};
1.443 www 3620: if ($folder eq '' || $supplementalflag) {
1.329 droeschl 3621: $folder='default';
1.356 tempelho 3622: $savefolderpath = $env{'form.folderpath'};
1.442 www 3623: $env{'form.folderpath'}='default&'.&escape(&mt('Content'));
1.329 droeschl 3624: $uploadtag = '<input type="hidden" name="folderpath" value="'.
3625: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
3626: }
3627: my $postexec='';
3628: if ($folder eq 'default') {
1.372 bisitz 3629: $r->print('<script type="text/javascript">'."\n"
3630: .'// <![CDATA['."\n"
3631: .'this.window.name="loncapaclient";'."\n"
3632: .'// ]]>'."\n"
3633: .'</script>'."\n"
1.369 bisitz 3634: );
1.329 droeschl 3635: } else {
3636: #$postexec='self.close();';
3637: }
3638: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
3639: '.sequence';
3640: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
3641: '.page';
3642: my $container='sequence';
3643: if ($env{'form.pagepath'}) {
3644: $container='page';
3645: }
3646: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
3647:
3648: my $imspform=(<<IMSPFORM);
3649: <form action="/adm/imsimportdocs" method="post" name="ims">
3650: <input type="hidden" name="folder" value="$folder" />
1.423 onken 3651: <a class="LC_menubuttons_link" href="javascript:makeims();">$lt{'imsf'}</a>
1.329 droeschl 3652: </form>
3653: IMSPFORM
3654:
3655: my $newnavform=(<<NNFORM);
3656: <form action="/adm/coursedocs" method="post" name="newnav">
1.371 tempelho 3657: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3658: $uploadtag
3659: <input type="hidden" name="importdetail"
3660: value="$lt{'navc'}=/adm/navmaps" />
1.423 onken 3661: <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
1.329 droeschl 3662: $help{'Navigate_Content'}
3663: </form>
3664: NNFORM
3665: my $newsmppageform=(<<NSPFORM);
3666: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.371 tempelho 3667: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3668: $uploadtag
3669: <input type="hidden" name="importdetail" value="" />
1.423 onken 3670: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 3671: $help{'Simple Page'}
1.329 droeschl 3672: </form>
3673: NSPFORM
3674:
3675: my $newsmpproblemform=(<<NSPROBFORM);
3676: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 3677: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3678: $uploadtag
3679: <input type="hidden" name="importdetail" value="" />
1.423 onken 3680: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.383 tempelho 3681: $help{'Simple Problem'}
1.329 droeschl 3682: </form>
3683:
3684: NSPROBFORM
3685:
3686: my $newdropboxform=(<<NDBFORM);
3687: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 3688: <input type="hidden" name="active" value="cc" />
1.344 bisitz 3689: $uploadtag
1.329 droeschl 3690: <input type="hidden" name="importdetail" value="" />
1.423 onken 3691: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.344 bisitz 3692: </form>
1.329 droeschl 3693: NDBFORM
3694:
3695: my $newexuploadform=(<<NEXUFORM);
3696: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 3697: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3698: $uploadtag
3699: <input type="hidden" name="importdetail" value="" />
1.423 onken 3700: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 3701: $help{'Score_Upload_Form'}
3702: </form>
3703: NEXUFORM
3704:
3705: my $newbulform=(<<NBFORM);
3706: <form action="/adm/coursedocs" method="post" name="newbul">
1.371 tempelho 3707: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3708: $uploadtag
3709: <input type="hidden" name="importdetail" value="" />
1.423 onken 3710: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 3711: $help{'Bulletin Board'}
3712: </form>
3713: NBFORM
3714:
3715: my $newaboutmeform=(<<NAMFORM);
3716: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.371 tempelho 3717: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3718: $uploadtag
3719: <input type="hidden" name="importdetail"
3720: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 3721: <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 3722: $help{'My Personal Information Page'}
1.329 droeschl 3723: </form>
3724: NAMFORM
3725:
3726: my $newaboutsomeoneform=(<<NASOFORM);
3727: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.371 tempelho 3728: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3729: $uploadtag
3730: <input type="hidden" name="importdetail" value="" />
1.423 onken 3731: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 3732: </form>
3733: NASOFORM
3734:
3735:
3736: my $newrosterform=(<<NROSTFORM);
3737: <form action="/adm/coursedocs" method="post" name="newroster">
1.371 tempelho 3738: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3739: $uploadtag
3740: <input type="hidden" name="importdetail"
3741: value="$lt{'rost'}=/adm/viewclasslist" />
1.423 onken 3742: <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
1.329 droeschl 3743: $help{'Course Roster'}
3744: </form>
3745: NROSTFORM
3746:
1.342 ehlerst 3747: my $specialdocumentsform;
1.383 tempelho 3748: my @specialdocumentsforma;
1.451 www 3749: my $gradingform;
3750: my @gradingforma;
3751: my $communityform;
3752: my @communityforma;
1.351 ehlerst 3753: my $newfolderform;
1.390 tempelho 3754: my $newfolderb;
1.342 ehlerst 3755:
1.451 www 3756: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 3757:
1.329 droeschl 3758: my $newpageform=(<<NPFORM);
3759: <form action="/adm/coursedocs" method="post" name="newpage">
3760: <input type="hidden" name="folderpath" value="$path" />
3761: <input type="hidden" name="importdetail" value="" />
1.371 tempelho 3762: <input type="hidden" name="active" value="cc" />
1.423 onken 3763: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 3764: $help{'Adding_Pages'}
1.329 droeschl 3765: </form>
3766: NPFORM
1.390 tempelho 3767:
3768:
1.351 ehlerst 3769: $newfolderform=(<<NFFORM);
1.329 droeschl 3770: <form action="/adm/coursedocs" method="post" name="newfolder">
3771: <input type="hidden" name="folderpath" value="$path" />
3772: <input type="hidden" name="importdetail" value="" />
1.371 tempelho 3773: <input type="hidden" name="active" value="aa" />
1.422 onken 3774: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 3775: </form>
3776: NFFORM
3777:
3778: my $newsylform=(<<NSYLFORM);
3779: <form action="/adm/coursedocs" method="post" name="newsyl">
1.371 tempelho 3780: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3781: $uploadtag
3782: <input type="hidden" name="importdetail"
3783: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 3784: <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 3785: $help{'Syllabus'}
1.383 tempelho 3786:
1.329 droeschl 3787: </form>
3788: NSYLFORM
1.364 bisitz 3789:
1.329 droeschl 3790: my $newgroupfileform=(<<NGFFORM);
3791: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.371 tempelho 3792: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3793: $uploadtag
3794: <input type="hidden" name="importdetail"
3795: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.423 onken 3796: <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
1.353 weissno 3797: $help{'Group Portfolio'}
1.329 droeschl 3798: </form>
3799: NGFFORM
1.383 tempelho 3800: @specialdocumentsforma=(
1.421 onken 3801: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'" onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform},
1.417 droeschl 3802: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
1.451 www 3803: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
3804: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
3805: );
3806: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
3807:
1.434 raeburn 3808:
3809: my @importdoc = (
3810: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'newext\');" />'=>$extresourcesform},
3811: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:makeims();" />'=>$imspform},);
1.459 raeburn 3812: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc)) . '<hr id="cc_hrule" style="width:0px;text-align:left;margin-left:0" />' . $fileuploadform;
1.434 raeburn 3813:
1.451 www 3814: @gradingforma=(
3815: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
3816: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
3817: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
3818:
3819: );
3820: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
3821:
3822: @communityforma=(
3823: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
3824: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
3825: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
3826: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},
3827: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
3828: );
3829: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 3830:
1.330 tempelho 3831: my %orderhash = (
1.488 raeburn 3832: 'aa' => ['Import Content',$fileuploadform],
3833: 'bb' => ['Published Content',$simpleeditdefaultform],
1.451 www 3834: 'cc' => ['Grading Resources',$gradingform],
1.330 tempelho 3835: );
1.451 www 3836: unless ($env{'form.pagepath'}) {
1.434 raeburn 3837: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 3838: $orderhash{'dd'} = ['Collaboration',$communityform];
1.451 www 3839: $orderhash{'ee'} = ['Special Documents',$specialdocumentsform];
1.434 raeburn 3840: }
3841:
1.341 ehlerst 3842: $hadchanges=0;
1.484 raeburn 3843: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 3844: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.472 raeburn 3845: $supplementalflag,\%orderhash,$iconpath);
1.443 www 3846: if ($error) {
3847: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
3848: }
3849: if ($hadchanges) {
3850: &mark_hash_old();
3851: }
1.341 ehlerst 3852:
1.443 www 3853: &changewarning($r,'');
3854: }
1.458 raeburn 3855: }
1.442 www 3856:
1.443 www 3857: # Supplemental documents start here
3858:
1.329 droeschl 3859: my $folder=$env{'form.folder'};
1.443 www 3860: unless ($supplementalflag) {
1.329 droeschl 3861: $folder='supplemental';
3862: }
3863: if ($folder =~ /^supplemental$/ &&
3864: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 3865: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 3866: } elsif ($allowed) {
1.356 tempelho 3867: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 3868: }
1.362 ehlerst 3869: $env{'form.pagepath'} = '';
1.329 droeschl 3870: if ($allowed) {
3871: my $folderseq=
3872: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
3873: '.sequence';
3874:
3875: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3876:
1.400 droeschl 3877: my $supupdocformbtn = "<input type='submit' value='".$lt{'upld'}."' />$help{'Uploading_From_Harddrive'}";
1.329 droeschl 3878: my $supupdocform=(<<SUPDOCFORM);
1.383 tempelho 3879: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.371 tempelho 3880: <input type="hidden" name="active" value="ee" />
1.329 droeschl 3881: $fileupload
3882: <br />
3883: <br />
3884: <span class="LC_nobreak">
3885: $checkbox
3886: </span>
3887: <br /><br />
3888: $lt{'comment'}:<br />
1.383 tempelho 3889: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 3890: <br />
3891: <input type="hidden" name="folderpath" value="$path" />
3892: <input type="hidden" name="cmd" value="upload_supplemental" />
3893: SUPDOCFORM
1.443 www 3894: $supupdocform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'}))."</form>";
1.329 droeschl 3895:
3896: my $supnewfolderform=(<<SNFFORM);
3897: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.371 tempelho 3898: <input type="hidden" name="active" value="ee" />
1.329 droeschl 3899: <input type="hidden" name="folderpath" value="$path" />
3900: <input type="hidden" name="importdetail" value="" />
1.423 onken 3901: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 3902: $help{'Adding_Folders'}
1.329 droeschl 3903: </form>
3904: SNFFORM
1.383 tempelho 3905:
1.329 droeschl 3906:
3907: my $supnewextform=(<<SNEFORM);
3908: <form action="/adm/coursedocs" method="post" name="supnewext">
1.371 tempelho 3909: <input type="hidden" name="active" value="ff" />
1.329 droeschl 3910: <input type="hidden" name="folderpath" value="$path" />
3911: <input type="hidden" name="importdetail" value="" />
1.423 onken 3912: <a class="LC_menubuttons_link" href="javascript:makenewext('supnewext');">$lt{'extr'}</a> $help{'Adding_External_Resource'}
1.329 droeschl 3913: </form>
3914: SNEFORM
3915:
3916: my $supnewsylform=(<<SNSFORM);
3917: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 3918: <input type="hidden" name="active" value="ff" />
1.329 droeschl 3919: <input type="hidden" name="folderpath" value="$path" />
3920: <input type="hidden" name="importdetail"
3921: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 3922: <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 3923: $help{'Syllabus'}
3924: </form>
3925: SNSFORM
3926:
3927: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 3928: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 3929: <input type="hidden" name="active" value="ff" />
1.329 droeschl 3930: <input type="hidden" name="folderpath" value="$path" />
3931: <input type="hidden" name="importdetail"
3932: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 3933: <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 3934: $help{'My Personal Information Page'}
1.329 droeschl 3935: </form>
3936: SNAMFORM
3937:
1.333 muellerd 3938:
1.383 tempelho 3939: my @specialdocs = (
1.417 droeschl 3940: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
3941: =>$supnewsylform},
3942: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
3943: =>$supnewaboutmeform},
1.383 tempelho 3944: );
1.417 droeschl 3945: my @supimportdoc = (
3946: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supnewext\');" />'
3947: =>$supnewextform},
3948: );
1.459 raeburn 3949: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)) . '<hr id="ee_hrule" style="width:0px;text-align:left;margin-left:0" />' . $supupdocform;
1.333 muellerd 3950: my %suporderhash = (
1.390 tempelho 3951: '00' => ['Supnewfolder', $supnewfolderform],
1.488 raeburn 3952: 'ee' => ['Import Content',$supupdocform],
1.443 www 3953: 'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 3954: );
1.443 www 3955: if ($supplementalflag) {
1.458 raeburn 3956: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.472 raeburn 3957: $supplementalflag,\%suporderhash,$iconpath);
1.443 www 3958: if ($error) {
3959: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
3960: }
1.393 raeburn 3961: }
1.443 www 3962: } elsif ($supplementalflag) {
1.458 raeburn 3963: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.472 raeburn 3964: $supplementalflag,'',$iconpath);
1.393 raeburn 3965: if ($error) {
3966: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 3967: }
1.393 raeburn 3968: }
1.389 tempelho 3969:
1.484 raeburn 3970: $r->print(&endContentScreen());
1.383 tempelho 3971:
1.329 droeschl 3972: if ($allowed) {
3973: $r->print('
3974: <form method="post" name="extimport" action="/adm/coursedocs">
3975: <input type="hidden" name="title" />
3976: <input type="hidden" name="url" />
3977: <input type="hidden" name="useform" />
3978: <input type="hidden" name="residx" />
3979: </form>');
3980: }
1.484 raeburn 3981: } elsif ($showdoc) {
1.329 droeschl 3982: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 3983: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.498 bisitz 3984: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 3985: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 3986: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 3987: }
3988: }
3989: $r->print(&Apache::loncommon::end_page());
3990: return OK;
1.364 bisitz 3991: }
1.329 droeschl 3992:
1.440 raeburn 3993: sub embedded_form_elems {
3994: my ($phase,$primaryurl,$newidx) = @_;
3995: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3996: return <<STATE;
3997: <input type="hidden" name="folderpath" value="$folderpath" />
3998: <input type="hidden" name="cmd" value="upload_embedded" />
3999: <input type="hidden" name="newidx" value="$newidx" />
4000: <input type="hidden" name="phase" value="$phase" />
4001: <input type="hidden" name="primaryurl" value="$primaryurl" />
4002: STATE
4003: }
4004:
4005: sub embedded_destination {
4006: my $folder=$env{'form.folder'};
4007: my $destination = 'docs/';
4008: if ($folder =~ /^supplemental/) {
4009: $destination = 'supplemental/';
4010: }
4011: if (($folder eq 'default') || ($folder eq 'supplemental')) {
4012: $destination .= 'default/';
4013: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
4014: $destination .= $2.'/';
4015: }
4016: $destination .= $env{'form.newidx'};
4017: my $dir_root = '/userfiles';
4018: return ($destination,$dir_root);
4019: }
4020:
4021: sub return_to_editor {
4022: my $actionurl = '/adm/coursedocs';
4023: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
4024: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
4025: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
4026: '</a></p>';
4027: }
4028:
1.476 raeburn 4029: sub decompression_info {
4030: my ($destination,$dir_root) = &embedded_destination();
4031: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
4032: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4033: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
4034: my $container='sequence';
1.480 raeburn 4035: my ($pathitem,$hiddenelem);
4036: my @hiddens = ('newidx','comment','position');
1.476 raeburn 4037: if ($env{'form.pagepath'}) {
4038: $container='page';
1.480 raeburn 4039: $pathitem = 'pagepath';
1.476 raeburn 4040: } else {
1.480 raeburn 4041: $pathitem = 'folderpath';
1.476 raeburn 4042: }
1.480 raeburn 4043: unshift(@hiddens,$pathitem);
4044: foreach my $item (@hiddens) {
4045: if ($env{'form.'.$item}) {
4046: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
4047: $env{'form.'.$item}.'" />'."\n";
4048: }
1.477 raeburn 4049: }
1.476 raeburn 4050: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
4051: $hiddenelem);
4052: }
4053:
4054: sub decompression_phase_one {
4055: my ($dir,$file,$warning,$error,$output);
4056: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
4057: &decompression_info();
1.490 raeburn 4058: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 4059: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
4060: } else {
4061: my $file = $1;
1.481 raeburn 4062: $output =
4063: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
4064: $destination,$dir_root,
4065: $hiddenelem);
4066: if ($env{'form.autoextract_camtasia'}) {
4067: $output .= &remove_archive($docudom,$docuname,$container);
4068: }
1.476 raeburn 4069: }
4070: if ($error) {
4071: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
4072: $error.'</p>'."\n";
4073: }
4074: if ($warning) {
4075: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
4076: }
4077: return $output;
4078: }
4079:
4080: sub decompression_phase_two {
4081: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
4082: &decompression_info();
1.481 raeburn 4083: my $output;
1.480 raeburn 4084: if ($env{'form.archivedelete'}) {
1.481 raeburn 4085: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 4086: }
4087: $output .=
1.481 raeburn 4088: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 4089: $destination,$dir_root,$hiddenelem);
4090: return $output;
4091: }
4092:
1.480 raeburn 4093: sub remove_archive {
4094: my ($docudom,$docuname,$container) = @_;
4095: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 4096: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 4097: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
4098: if ($fatal) {
4099: if ($container eq 'page') {
4100: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
4101: } else {
4102: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
4103: }
4104: $delwarning .= &mt('As a result the archive file has not been removed.');
4105: } else {
4106: my $currcmd = $env{'form.cmd'};
4107: my $position = $env{'form.position'};
4108: if ($position > 0) {
4109: $env{'form.cmd'} = 'del_'.$position;
4110: my ($title,$url,@rrest) =
4111: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);
4112: if (&handle_edit_cmd($docuname,$docudom)) {
1.492 raeburn 4113: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
1.480 raeburn 4114: if ($fatal) {
4115: if ($container eq 'page') {
4116: $delwarning = &mt('An error occurred updating the contents of the current page.');
4117: } else {
4118: $delwarning = &mt('An error occurred updating the contents of the current folder.');
4119: }
4120: } else {
1.481 raeburn 4121: $delresult = &mt('Archive file removed.');
1.480 raeburn 4122: }
4123: }
4124: }
4125: $env{'form.cmd'} = $currcmd;
4126: }
4127: if ($delwarning) {
4128: $output = '<p class="LC_warning">'.
4129: $delwarning.
4130: '</p>';
4131: }
4132: if ($delresult) {
4133: $output .= '<p class="LC_info">'.
4134: $delresult.
4135: '</p>';
4136: }
1.481 raeburn 4137: return $output;
1.480 raeburn 4138: }
4139:
1.484 raeburn 4140: sub generate_admin_menu {
4141: my ($crstype) = @_;
4142: my $lc_crstype = lc($crstype);
4143: my ($home,$other,%outhash)=&authorhosts();
4144: my %lt=&Apache::lonlocal::texthash (
4145: 'vc' => 'Verify Content',
4146: 'cv' => 'Check/Set Resource Versions',
4147: 'ls' => 'List Resource Identifiers',
4148: 'imse' => 'Export contents to IMS Archive',
4149: 'dcd' => "Dump $crstype Content to Authoring Space",
4150: );
4151: my ($candump,$dumpurl);
4152: if ($home + $other > 0) {
4153: $candump = 'F';
4154: if ($home) {
4155: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
4156: } else {
4157: my @hosts;
4158: foreach my $aurole (keys(%outhash)) {
4159: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
4160: push(@hosts,$outhash{$aurole});
4161: }
4162: }
4163: if (@hosts == 1) {
4164: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
4165: '&role='.
4166: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
4167: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
4168: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
4169: } else {
4170: $dumpurl = "javascript:choose_switchserver_window()";
4171: }
4172: }
4173: }
4174: my @menu=
4175: ({ categorytitle=>'Administration',
4176: items =>[
4177: { linktext => $lt{'vc'},
4178: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
4179: permission => 'F',
4180: help => 'Verify_Content',
4181: icon => 'verify.png',
4182: linktitle => 'Verify contents can be retrieved/rendered',
4183: },
4184: { linktext => $lt{'cv'},
4185: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
4186: permission => 'F',
4187: help => 'Check_Resource_Versions',
4188: icon => 'resversion.png',
4189: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
4190: },
4191: { linktext => $lt{'ls'},
4192: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
4193: permission => 'F',
4194: #help => '',
4195: icon => 'symbs.png',
4196: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
4197: },
4198: ]
4199: },
4200: { categorytitle=>'Export',
4201: items =>[
4202: { linktext => $lt{'imse'},
4203: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
4204: permission => 'F',
4205: help => 'Docs_Export_Course_Docs',
4206: icon => 'imsexport.png',
4207: linktitle => $lt{'imse'},
4208: },
4209: { linktext => $lt{'dcd'},
4210: url => $dumpurl,
4211: permission => $candump,
4212: #help => '',
4213: icon => 'dump.png',
4214: linktitle => $lt{'dcd'},
4215: },
4216: ]
4217: });
4218: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
4219: '<input type="hidden" id="dummy" />'."\n".
4220: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
4221: '</form>';
1.329 droeschl 4222: }
4223:
4224: sub generate_edit_table {
1.484 raeburn 4225: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile) = @_;
1.406 raeburn 4226: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 4227: my %orderhash = %{$orderhash_ref};
1.344 bisitz 4228: my $form;
1.371 tempelho 4229: my $activetab;
4230: my $active;
4231: if($env{'form.active'} ne ''){
4232: $activetab = $env{'form.active'};
4233: }
1.472 raeburn 4234: my $backicon = $iconpath.'clickhere.gif';
1.481 raeburn 4235: my $backtext = &mt('To Overview');
1.458 raeburn 4236: $form = '<div class="LC_Box" style="margin:0;">'.
1.488 raeburn 4237: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
4238: '<li class="goback">'.
4239: '<a href="javascript:toContents('."'$jumpto'".');">'.
4240: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
4241: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
4242: '<li>'.
4243: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
4244: &mt('Undo Delete').'</a></li>'."\n";
4245: if ($env{'form.docslog'}) {
4246: $form .= '<li class="active">';
4247: } else {
4248: $form .= '<li>';
4249: }
4250: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
4251: &mt('History').'</a></li>'."\n";
4252: if ($env{'form.docslog'}) {
4253: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
4254: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 4255: }
1.458 raeburn 4256: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 4257: if($name ne '00'){
1.371 tempelho 4258: if($activetab eq '' || $activetab ne $name){
4259: $active = '';
4260: }elsif($activetab eq $name){
4261: $active = 'class="active"';
4262: }
1.458 raeburn 4263: $form .= '<li style="float:right" '.$active
1.429 droeschl 4264: .' onmouseover="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"'
1.484 raeburn 4265: .' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>'."\n";
1.390 tempelho 4266: } else {
1.484 raeburn 4267: $form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 4268:
4269: }
1.329 droeschl 4270: }
1.484 raeburn 4271: $form .= '</ul>'."\n";
4272: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 4273:
4274: if ($to_show ne '') {
1.484 raeburn 4275: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'."\n";
1.458 raeburn 4276: }
1.363 ehlerst 4277: foreach my $field (keys(%orderhash)){
1.390 tempelho 4278: if($field ne '00'){
1.422 onken 4279: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 4280: $active = 'style="display: none;float:left"';
1.422 onken 4281: }elsif($activetab eq $field){
1.458 raeburn 4282: $active = 'style="display:block;float:left"';
1.422 onken 4283: }
4284: $form .= '<div id="'.$field.$tid.'"'
4285: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 4286: .'</div>'."\n";
1.363 ehlerst 4287: }
4288: }
1.484 raeburn 4289: unless ($env{'form.docslog'}) {
4290: $form .= '</div></div>'."\n";
4291: }
1.329 droeschl 4292: return $form;
4293: }
4294:
4295: sub editing_js {
1.472 raeburn 4296: my ($udom,$uname,$supplementalflag) = @_;
1.329 droeschl 4297: my $now = time();
4298: my %lt = &Apache::lonlocal::texthash(
4299: p_mnf => 'Name of New Folder',
4300: t_mnf => 'New Folder',
4301: p_mnp => 'Name of New Page',
4302: t_mnp => 'New Page',
1.451 www 4303: p_mxu => 'Title for the External Score',
1.349 biermanm 4304: p_msp => 'Name of Simple Course Page',
1.329 droeschl 4305: p_msb => 'Title for the Problem',
4306: p_mdb => 'Title for the Drop Box',
1.336 schafran 4307: p_mbb => 'Title for the Discussion Board',
1.348 weissno 4308: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 4309: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 4310: p_mab_alrt1 => 'Not a valid user:domain',
4311: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
4312: p_chn => 'New Title',
4313: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
4314: p_rmr2a => 'Remove[_99]',
4315: p_rmr2b => '?[_99]',
4316: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
4317: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
4318: p_ctr2a => 'Cut[_98]',
1.478 raeburn 4319: p_ctr2b => '?[_98]',
4320: rpck => 'Enter number to pick (e.g., 3)',
1.329 droeschl 4321: );
4322:
1.433 raeburn 4323: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 4324: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
4325: my $docs_pagepath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.pagepath'},'<>&"');
4326: my $main_container_page;
4327: if ($docs_folderpath eq '') {
4328: if ($docs_pagepath ne '') {
4329: $main_container_page = 1;
4330: }
4331: }
1.433 raeburn 4332: my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents';
1.446 www 4333: my $toplevelsupp = &supplemental_base();
1.433 raeburn 4334:
1.472 raeburn 4335: my $backtourl = '/adm/navmaps';
4336: if ($supplementalflag) {
4337: $backtourl = '/adm/supplemental';
4338: }
4339:
1.329 droeschl 4340: return <<ENDNEWSCRIPT;
4341: function makenewfolder(targetform,folderseq) {
4342: var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
4343: if (foldername) {
4344: targetform.importdetail.value=escape(foldername)+"="+folderseq;
4345: targetform.submit();
4346: }
4347: }
4348:
4349: function makenewpage(targetform,folderseq) {
4350: var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
4351: if (pagename) {
4352: targetform.importdetail.value=escape(pagename)+"="+folderseq;
4353: targetform.submit();
4354: }
4355: }
4356:
4357: function makenewext(targetname) {
4358: this.document.forms.extimport.useform.value=targetname;
4359: this.document.forms.extimport.title.value='';
4360: this.document.forms.extimport.url.value='';
4361: this.document.forms.extimport.residx.value='';
4362: window.open('/adm/rat/extpickframe.html');
4363: }
4364:
4365: function edittext(targetname,residx,title,url) {
4366: this.document.forms.extimport.useform.value=targetname;
4367: this.document.forms.extimport.residx.value=residx;
4368: this.document.forms.extimport.url.value=url;
4369: this.document.forms.extimport.title.value=title;
4370: window.open('/adm/rat/extpickframe.html');
4371: }
4372:
4373: function makeexamupload() {
4374: var title=prompt('$lt{"p_mxu"}');
1.344 bisitz 4375: if (title) {
1.329 droeschl 4376: this.document.forms.newexamupload.importdetail.value=
4377: escape(title)+'=/res/lib/templates/examupload.problem';
4378: this.document.forms.newexamupload.submit();
4379: }
4380: }
4381:
4382: function makesmppage() {
4383: var title=prompt('$lt{"p_msp"}');
1.344 bisitz 4384: if (title) {
1.329 droeschl 4385: this.document.forms.newsmppg.importdetail.value=
4386: escape(title)+'=/adm/$udom/$uname/$now/smppg';
4387: this.document.forms.newsmppg.submit();
4388: }
4389: }
4390:
4391: function makesmpproblem() {
4392: var title=prompt('$lt{"p_msb"}');
1.344 bisitz 4393: if (title) {
1.329 droeschl 4394: this.document.forms.newsmpproblem.importdetail.value=
4395: escape(title)+'=/res/lib/templates/simpleproblem.problem';
4396: this.document.forms.newsmpproblem.submit();
4397: }
4398: }
4399:
4400: function makedropbox() {
4401: var title=prompt('$lt{"p_mdb"}');
1.344 bisitz 4402: if (title) {
1.329 droeschl 4403: this.document.forms.newdropbox.importdetail.value=
4404: escape(title)+'=/res/lib/templates/DropBox.problem';
4405: this.document.forms.newdropbox.submit();
4406: }
4407: }
4408:
4409: function makebulboard() {
4410: var title=prompt('$lt{"p_mbb"}');
4411: if (title) {
4412: this.document.forms.newbul.importdetail.value=
4413: escape(title)+'=/adm/$udom/$uname/$now/bulletinboard';
4414: this.document.forms.newbul.submit();
4415: }
4416: }
4417:
4418: function makeabout() {
4419: var user=prompt("$lt{'p_mab'}");
4420: if (user) {
4421: var comp=new Array();
4422: comp=user.split(':');
4423: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
4424: if ((comp[0]) && (comp[1])) {
4425: this.document.forms.newaboutsomeone.importdetail.value=
4426: '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.335 ehlerst 4427: this.document.forms.newaboutsomeone.submit();
4428: } else {
4429: alert("$lt{'p_mab_alrt1'}");
1.329 droeschl 4430: }
1.335 ehlerst 4431: } else {
4432: alert("$lt{'p_mab_alrt2'}");
4433: }
4434: }
1.329 droeschl 4435: }
4436:
4437: function makeims() {
1.335 ehlerst 4438: var caller = document.forms.ims.folder.value;
4439: var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
4440: newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
4441: newWindow.location.href = newlocation;
1.329 droeschl 4442: }
4443:
4444: function finishpick() {
1.335 ehlerst 4445: var title=this.document.forms.extimport.title.value;
4446: var url=this.document.forms.extimport.url.value;
4447: var form=this.document.forms.extimport.useform.value;
4448: var residx=this.document.forms.extimport.residx.value;
4449: eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();');
1.329 droeschl 4450: }
4451:
4452: function changename(folderpath,index,oldtitle,container,pagesymb) {
1.335 ehlerst 4453: var title=prompt('$lt{"p_chn"}',oldtitle);
4454: if (title) {
4455: this.document.forms.renameform.markcopy.value=-1;
4456: this.document.forms.renameform.title.value=title;
4457: this.document.forms.renameform.cmd.value='rename_'+index;
4458: if (container == 'sequence') {
4459: this.document.forms.renameform.folderpath.value=folderpath;
4460: }
4461: if (container == 'page') {
4462: this.document.forms.renameform.pagepath.value=folderpath;
4463: this.document.forms.renameform.pagesymb.value=pagesymb;
4464: }
4465: this.document.forms.renameform.submit();
4466: }
1.329 droeschl 4467: }
4468:
4469: function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) {
1.335 ehlerst 4470: if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
4471: this.document.forms.renameform.markcopy.value=-1;
4472: this.document.forms.renameform.cmd.value='del_'+index;
4473: if (container == 'sequence') {
4474: this.document.forms.renameform.folderpath.value=folderpath;
4475: }
4476: if (container == 'page') {
4477: this.document.forms.renameform.pagepath.value=folderpath;
4478: this.document.forms.renameform.pagesymb.value=pagesymb;
4479: }
4480: this.document.forms.renameform.submit();
4481: }
1.329 droeschl 4482: }
4483:
4484: function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) {
1.335 ehlerst 4485: if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
4486: this.document.forms.renameform.cmd.value='cut_'+index;
4487: this.document.forms.renameform.markcopy.value=index;
4488: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
4489: if (container == 'sequence') {
4490: this.document.forms.renameform.folderpath.value=folderpath;
4491: }
4492: if (container == 'page') {
4493: this.document.forms.renameform.pagepath.value=folderpath;
4494: this.document.forms.renameform.pagesymb.value=pagesymb;
4495: }
4496: this.document.forms.renameform.submit();
4497: }
1.329 droeschl 4498: }
4499:
4500: function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) {
1.335 ehlerst 4501: this.document.forms.renameform.markcopy.value=index;
4502: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
4503: if (container == 'sequence') {
4504: this.document.forms.renameform.folderpath.value=folderpath;
4505: }
4506: if (container == 'page') {
4507: this.document.forms.renameform.pagepath.value=folderpath;
4508: this.document.forms.renameform.pagesymb.value=pagesymb;
4509: }
4510: this.document.forms.renameform.submit();
1.329 droeschl 4511: }
4512:
1.478 raeburn 4513: function updatePick(targetform,index,caller) {
4514: var pickitem = document.getElementById('rpick_'+index);
4515: var picknumitem = document.getElementById('rpicknum_'+index);
4516: if (pickitem.checked) {
4517: var picknum=prompt('$lt{"rpck"}',picknumitem.value);
4518: if (picknum == '' || picknum == null) {
4519: if (caller == 'check') {
4520: pickitem.checked=false;
4521: return;
4522: }
4523: } else {
4524: picknum.toString();
4525: var regexdigit=/^\\d+\$/;
4526: if (regexdigit.test(picknum)) {
4527: picknumitem.value = picknum;
4528: targetform.changeparms.value='randompick';
4529: targetform.submit();
4530: } else {
4531: if (caller == 'check') {
4532: pickitem.checked=false;
4533: }
4534: return;
4535: }
4536: }
4537: } else {
4538: picknumitem.value = 0;
4539: targetform.changeparms.value='randompick';
4540: targetform.submit();
4541: }
4542: }
4543:
1.334 muellerd 4544: function unselectInactive(nav) {
1.335 ehlerst 4545: currentNav = document.getElementById(nav);
4546: currentLis = currentNav.getElementsByTagName('LI');
4547: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 4548: if (currentLis[i].className == 'goback') {
4549: currentLis[i].className = 'goback';
4550: } else {
4551: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 4552: currentLis[i].className = 'right';
1.472 raeburn 4553: } else {
1.374 tempelho 4554: currentLis[i].className = 'i';
1.472 raeburn 4555: }
4556: }
1.335 ehlerst 4557: }
1.332 tempelho 4558: }
4559:
1.334 muellerd 4560: function hideAll(current, nav, data) {
1.335 ehlerst 4561: unselectInactive(nav);
1.374 tempelho 4562: if(current.className == 'right'){
4563: current.className = 'right active'
4564: }else{
4565: current.className = 'active';
4566: }
1.335 ehlerst 4567: currentData = document.getElementById(data);
4568: currentDivs = currentData.getElementsByTagName('DIV');
4569: for (i = 0; i < currentDivs.length; i++) {
4570: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 4571: currentDivs[i].style.display = 'none';
1.330 tempelho 4572: }
4573: }
1.335 ehlerst 4574: }
1.330 tempelho 4575:
1.374 tempelho 4576: function openTabs(pageId) {
4577: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 4578: if(tabnav.length > 2 ){
1.389 tempelho 4579: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 4580: currentLis = currentNav.getElementsByTagName('LI');
4581: for(i = 0; i< currentLis.length; i++){
4582: if(currentLis[i].className == 'active') {
1.375 tempelho 4583: funcString = currentLis[i].onclick.toString();
4584: tab = funcString.split('"');
1.420 onken 4585: if(tab.length < 2) {
4586: tab = funcString.split("'");
4587: }
1.375 tempelho 4588: currentData = document.getElementById(tab[1]);
4589: currentData.style.display = 'block';
1.374 tempelho 4590: }
4591: }
4592: }
4593: }
4594:
1.334 muellerd 4595: function showPage(current, pageId, nav, data) {
4596: hideAll(current, nav, data);
1.375 tempelho 4597: openTabs(pageId);
1.334 muellerd 4598: unselectInactive(nav);
1.330 tempelho 4599: current.className = 'active';
4600: currentData = document.getElementById(pageId);
4601: currentData.style.display = 'block';
1.458 raeburn 4602: activeTab = pageId;
1.433 raeburn 4603: if (nav == 'mainnav') {
4604: var storedpath = "$docs_folderpath";
4605: if (storedpath == '') {
4606: storedpath = "$docs_pagepath";
4607: }
1.434 raeburn 4608: var storedpage = "$main_container_page";
1.433 raeburn 4609: var reg = new RegExp("^supplemental");
4610: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 4611: if (storedpage == 1) {
4612: document.simpleedit.folderpath.value = '';
4613: document.uploaddocument.folderpath.value = '';
4614: } else {
4615: if (reg.test(storedpath)) {
4616: document.simpleedit.folderpath.value = '$toplevelmain';
4617: document.uploaddocument.folderpath.value = '$toplevelmain';
4618: document.newext.folderpath.value = '$toplevelmain';
4619: } else {
4620: document.simpleedit.folderpath.value = storedpath;
4621: document.uploaddocument.folderpath.value = storedpath;
4622: document.newext.folderpath.value = storedpath;
4623: }
1.433 raeburn 4624: }
4625: } else {
1.434 raeburn 4626: if (reg.test(storedpath)) {
4627: document.simpleedit.folderpath.value = storedpath;
4628: document.supuploaddocument.folderpath.value = storedpath;
4629: document.supnewext.folderpath.value = storedpath;
4630: } else {
1.433 raeburn 4631: document.simpleedit.folderpath.value = '$toplevelsupp';
4632: document.supuploaddocument.folderpath.value = '$toplevelsupp';
4633: document.supnewext.folderpath.value = '$toplevelsupp';
4634: }
4635: }
4636: }
1.485 raeburn 4637: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 4638: return false;
4639: }
1.329 droeschl 4640:
1.472 raeburn 4641: function toContents(jumpto) {
4642: var newurl = '$backtourl';
4643: if (jumpto != '') {
4644: newurl = newurl+'?postdata='+jumpto;
4645: ;
4646: }
4647: location.href=newurl;
4648: }
4649:
1.329 droeschl 4650: ENDNEWSCRIPT
4651: }
1.457 raeburn 4652:
1.483 raeburn 4653: sub history_tab_js {
4654: return <<"ENDHIST";
4655: function toggleHistoryDisp(choice) {
4656: document.docslogform.docslog.value = choice;
4657: document.docslogform.submit();
4658: return;
4659: }
4660:
4661: ENDHIST
4662: }
4663:
1.484 raeburn 4664: sub inject_data_js {
4665: return <<ENDINJECT;
4666:
4667: function injectData(current, hiddenField, name, value) {
4668: currentElement = document.getElementById(hiddenField);
4669: currentElement.name = name;
4670: currentElement.value = value;
4671: current.submit();
4672: }
4673:
4674: ENDINJECT
4675: }
4676:
4677: sub dump_switchserver_js {
4678: my @hosts = @_;
4679: my %lt = &Apache::lonlocal::texthash(
4680: dump => 'Dumping to Authoring Space requires switching server.',
4681: swit => 'Switch server?',
4682: duco => 'Dump content to Authoring Space',
4683: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
4684: chos => 'Choose server',
4685: );
4686: my $role = $env{'request.role'};
4687: my $js = <<"ENDSWJS";
4688: <script type="text/javascript">
4689: function write_switchserver() {
4690: var server;
4691: if (document.setserver.posshosts.length > 0) {
4692: for (var i=0; i<document.setserver.posshosts.length; i++) {
4693: if (document.setserver.posshosts[i].checked) {
4694: server = document.setserver.posshosts[i].value;
4695: }
4696: }
4697: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
4698: }
4699: window.close();
4700: }
4701: </script>
4702:
4703: ENDSWJS
4704:
4705: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
4706: {'only_body' => 1,
4707: 'js_ready' => 1,});
4708: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
4709:
4710: my $hostpicker;
4711: my $count = 0;
4712: foreach my $host (sort(@hosts)) {
4713: my $checked;
4714: if ($count == 0) {
4715: $checked = ' checked="checked"';
4716: }
4717: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
4718: $host.'"'.$checked.' />'.$host.'</label> ';
4719: $count++;
4720: }
4721:
4722: return <<"ENDSWITCHJS";
4723:
4724: function dump_needs_switchserver(url) {
4725: if (url!='' && url!= null) {
4726: if (confirm("$lt{'dump'}\\n$lt{'swit'}")) {
4727: go(url);
4728: }
4729: }
4730: return;
4731: }
4732:
4733: function choose_switchserver_window() {
4734: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
4735: newWindow.document.open();
4736: newWindow.document.writeln('$startpage');
4737: newWindow.document.write('<h3>$lt{'duco'}<\\/h3>\\n'+
4738: '<p>$lt{'yone'}<\\/p>\\n'+
4739: '<div class="LC_left_float"><fieldset><legend>$lt{'chos'}<\\/legend>\\n'+
4740: '<form name="setserver" method="post" action="" \\/>\\n'+
4741: '$hostpicker\\n'+
4742: '<br \\/><br \\/>\\n'+
4743: '<input type="button" name="makeswitch" value="$lt{'swit'}" '+
4744: 'onclick="write_switchserver();" \\/>\\n'+
4745: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
4746: newWindow.document.writeln('$endpage');
4747: newWindow.document.close();
4748: newWindow.focus();
4749: }
4750:
4751: ENDSWITCHJS
4752: }
4753:
4754: sub makedocslogform {
4755: my ($formelems,$docslog) = @_;
4756: return <<"LOGSFORM";
4757: <form action="/adm/coursedocs" method="post" name="docslogform">
4758: <input type="hidden" name="docslog" value="$docslog" />
4759: $formelems
4760: </form>
4761: LOGSFORM
4762: }
4763:
4764: sub makesimpleeditform {
4765: my ($formelems) = @_;
4766: return <<"SIMPFORM";
4767: <form name="simpleedit" method="post" action="/adm/coursedocs">
4768: <input type="hidden" name="importdetail" value="" />
4769: $formelems
4770: </form>
4771: SIMPFORM
4772: }
4773:
1.329 droeschl 4774: 1;
4775: __END__
4776:
4777:
4778: =head1 NAME
4779:
4780: Apache::londocs.pm
4781:
4782: =head1 SYNOPSIS
4783:
4784: This is part of the LearningOnline Network with CAPA project
4785: described at http://www.lon-capa.org.
4786:
4787: =head1 SUBROUTINES
4788:
4789: =over
4790:
4791: =item %help=()
4792:
4793: Available help topics
4794:
4795: =item mapread()
4796:
1.344 bisitz 4797: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 4798: @order and @resources, determines status
4799: sets @order - pointer to resources in right order
4800: sets @resources - array with the resources with correct idx
4801:
4802: =item authorhosts()
4803:
4804: Return hash with valid author names
4805:
4806: =item clean()
4807:
4808: =item dumpcourse()
4809:
4810: Actually dump course
4811:
4812: =item group_import()
4813:
4814: Imports the given (name, url) resources into the course
4815: coursenum, coursedom, and folder must precede the list
4816:
4817: =item breadcrumbs()
4818:
4819: =item log_docs()
4820:
4821: =item docs_change_log()
4822:
4823: =item update_paste_buffer()
4824:
4825: =item print_paste_buffer()
4826:
4827: =item do_paste_from_buffer()
4828:
1.492 raeburn 4829: =item get_newmap_url()
4830:
4831: =item dbcopy()
4832:
4833: =item uniqueness_check()
4834:
4835: =item contained_map_check()
4836:
4837: =item reinit_role()
4838:
4839: =item url_paste_fixups()
4840:
4841: =item apply_fixups()
4842:
4843: =item copy_dependencies()
4844:
1.329 droeschl 4845: =item update_parameter()
4846:
4847: =item handle_edit_cmd()
4848:
4849: =item editor()
4850:
4851: =item process_file_upload()
4852:
4853: =item process_secondary_uploads()
4854:
4855: =item is_supplemental_title()
4856:
4857: =item entryline()
4858:
4859: =item tiehash()
4860:
4861: =item untiehash()
4862:
4863: =item checkonthis()
4864:
4865: check on this
4866:
4867: =item verifycontent()
4868:
4869: Verify Content
4870:
4871: =item devalidateversioncache() & checkversions()
4872:
4873: Check Versions
4874:
4875: =item mark_hash_old()
4876:
4877: =item is_hash_old()
4878:
4879: =item changewarning()
4880:
4881: =item init_breadcrumbs()
4882:
4883: Breadcrumbs for special functions
4884:
1.484 raeburn 4885: =item create_list_elements()
4886:
4887: =item create_form_ul()
4888:
4889: =item startContentScreen()
4890:
4891: =item endContentScreen()
4892:
4893: =item supplemental_base()
4894:
4895: =item embedded_form_elems()
4896:
4897: =item embedded_destination()
4898:
4899: =item return_to_editor()
4900:
4901: =item decompression_info()
4902:
4903: =item decompression_phase_one()
4904:
4905: =item decompression_phase_two()
4906:
4907: =item remove_archive()
4908:
4909: =item generate_admin_menu()
4910:
4911: =item generate_edit_table()
4912:
4913: =item editing_js()
4914:
4915: =item history_tab_js()
4916:
4917: =item inject_data_js()
4918:
4919: =item dump_switchserver_js()
4920:
1.485 raeburn 4921: =item resize_scrollbox_js()
1.484 raeburn 4922:
4923: =item makedocslogform()
4924:
1.485 raeburn 4925: =item makesimpleeditform()
4926:
1.329 droeschl 4927: =back
4928:
4929: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>