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