Annotation of loncom/interface/londocs.pm, revision 1.484.2.27
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.484.2.27! raeburn 4: # $Id: londocs.pm,v 1.484.2.26 2013/03/17 17:21:34 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.484.2.19 raeburn 43: use Apache::lonextresedit();
1.329 droeschl 44: use HTML::Entities;
1.484.2.7 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.484.2.7 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.484.2.7 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.484.2.24 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.484.2.23 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.484.2.27! 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.484.2.23 raeburn 301: if (($caller eq 'londocs') &&
302: ($folder =~ /^default/)) {
1.484.2.27! raeburn 303: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.484.2.23 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.484.2.27! 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.484.2.23 raeburn 374: if ($importuploaded) {
375: my %import_errors;
376: my %updated = (
377: removefrommap => \%removefrommap,
378: removeparam => \%removeparam,
379: );
1.484.2.26 raeburn 380: my ($result,$msgsarray,$lockerror) =
381: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.484.2.23 raeburn 382: if (keys(%import_errors) > 0) {
383: $fixuperrors =
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.484.2.26 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.484.2.23 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.484.2.8 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.484.2.6 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.484.2.6 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.484.2.7 raeburn 484: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 485: my %orderhash;
486: my $container='sequence';
487: my $pathitem;
1.484.2.19 raeburn 488: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 489: $container='page';
490: }
1.484.2.19 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.484.2.7 raeburn 501: if ($supplementalflag) {
502: $tid = 2;
503: }
1.484.2.19 raeburn 504: my ($breadcrumbtrail) =
1.484.2.18 raeburn 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.484.2.19 raeburn 579: my $is_supp = 0;
1.484.2.7 raeburn 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.484.2.7 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.484.2.7 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: }
1.484.2.19 raeburn 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.484.2.7 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.484.2.7 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.484.2.7 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.484.2.7 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.484.2.7 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.484.2.7 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.484.2.7 raeburn 739: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.329 droeschl 740: return if (!defined($env{'docs.markedcopy_url'}));
741:
1.484.2.7 raeburn 742: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent);
743: my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
1.329 droeschl 744: if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1.484.2.7 raeburn 745: $is_external = 1;
746: }
747:
1.484.2.20 raeburn 748: my ($canpaste,$nopaste,$othercrs,$areachange);
1.484.2.7 raeburn 749: if ($folder =~ /^supplemental/) {
750: $canpaste = &supp_pasteable($env{'docs.markedcopy_url'});
751: unless ($canpaste) {
752: $nopaste = &mt('Paste into Supplemental Content unavailable for this type of content.');
1.484.2.19 raeburn 753: }
1.484.2.7 raeburn 754: } else {
755: $canpaste = 1;
756: }
757:
758: if ($canpaste) {
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) {
1.484.2.19 raeburn 767: $othercrs = '<br />'.&mt('(from another course).');
1.484.2.7 raeburn 768: }
769: } else {
770: $canpaste = 0;
1.484.2.19 raeburn 771: $nopaste = &mt('Paste from another course unavailable.')
1.484.2.7 raeburn 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: }
783: }
784:
785: $r->print('<fieldset>'
786: .'<legend>'.&mt('Clipboard').'</legend>');
787: my ($type,$buffer);
788: if ($is_external) {
1.484.2.19 raeburn 789: $type = &mt('External Resource');
790: $buffer = $type.': '.
791: &LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('.
1.484.2.7 raeburn 792: &LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')';
1.484.2.26 raeburn 793: } else {
1.484.2.19 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" />';
1.484.2.7 raeburn 801: $buffer = $icon.$type.': '. &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}));
1.329 droeschl 802: }
1.484.2.7 raeburn 803: if ($canpaste) {
804: $r->print('<form name="pasteform" action="/adm/coursedocs" method="post">'.$buffer);
1.484.2.26 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.484.2.7 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.484.2.26 raeburn 830: $copytext.'</label>'.(' ' x2).
1.484.2.19 raeburn 831: '<label>'.
1.484.2.7 raeburn 832: '<input type="radio" name="docs.markedcopy_options" value="move" />'.
1.484.2.26 raeburn 833: $movetext.'</label><br />');
834: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested'})) {
1.484.2.7 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: );
1.484.2.19 raeburn 843: my (%display,%deps);
1.484.2.7 raeburn 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;
1.484.2.19 raeburn 855: $display{$subfolders[$j]} =
1.484.2.7 raeburn 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.484.2.19 raeburn 872: $r->print('
1.329 droeschl 873: <input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
874: ');
1.484.2.7 raeburn 875: $r->print('</form>');
876: } else {
877: $r->print(&mt('Paste buffer contains:').' '.$buffer.
878: '<br /><p class="LC_info">'.$nopaste.'</p>');
1.329 droeschl 879: }
1.484.2.7 raeburn 880: $r->print('</fieldset>');
1.329 droeschl 881: }
882:
1.484.2.7 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:
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;
903: }
904:
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.484.2.7 raeburn 932: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 933:
1.484.2.7 raeburn 934: # Early out if paste buffer is empty
1.329 droeschl 935: if (!$env{'form.pastemarked'}) {
1.484.2.7 raeburn 936: return ();
937: }
938:
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: }
1.329 droeschl 945: }
946:
1.484.2.7 raeburn 947: # Prepare to paste resource at end of list
1.329 droeschl 948: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
949: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});
1.484.2.7 raeburn 950:
951: my ($is_map,$srcdom,$srcnum,$prefixchg,%before,%after,%mapchanges,%tomove);
952: if ($url=~/\.(page|sequence)$/) {
1.484.2.19 raeburn 953: $is_map = 1;
1.484.2.7 raeburn 954: }
955: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/([^/]+)}) {
956: $srcdom = $1;
957: $srcnum = $2;
958: my $oldprefix = $3;
959: # When paste buffer was populated using an active role in a different course
1.484.2.19 raeburn 960: # check for mdc privilege in the course from which the resource was pasted
1.484.2.7 raeburn 961: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
962: unless ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
963: return (&mt('Paste failed: Item is from a different course which you do not have rights to edit.'));
1.329 droeschl 964: }
965: }
1.484.2.19 raeburn 966: # When pasting content from Main Content to Supplemental Content and vice versa
1.484.2.7 raeburn 967: # URLs will contain different paths (which depend on whether pasted item is
1.484.2.19 raeburn 968: # a folder/page or a document.
1.484.2.7 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:
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.329 droeschl 1001: }
1.484.2.7 raeburn 1002: }
1003:
1004: # Maps need to be copied first
1005: my ($oldurl,%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1006: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%newsubdir,%newurls);
1007: $oldurl = $url;
1008: if ($is_map) {
1009: # If pasting a map, check if map contains other maps
1.484.2.23 raeburn 1010: my ($allmaps,%hierarchy,%titles);
1011: $allmaps = {};
1.484.2.7 raeburn 1012: if ($folder =~ /^default/) {
1.484.2.23 raeburn 1013: $allmaps =
1014: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1015: $env{"course.$env{'request.course.id'}.home"},
1016: $env{'request.course.id'});
1.329 droeschl 1017: }
1.484.2.7 raeburn 1018: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,
1.484.2.23 raeburn 1019: \%addedmaps,\%hierarchy,\%titles,$allmaps);
1.484.2.7 raeburn 1020: if ($url=~ m{^/uploaded/}) {
1021: my $newurl;
1022: unless ($env{'form.docs.markedcopy_options'} eq 'move') {
1.484.2.19 raeburn 1023: ($newurl,my $error) =
1.484.2.7 raeburn 1024: &get_newmap_url($url,$folder,$prefixchg,$coursedom,$coursenum,
1.484.2.23 raeburn 1025: $srcdom,$srcnum,\$title,$allmaps,\%newurls);
1.484.2.7 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: }
1036: }
1037: }
1038: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum) || ($prefixchg) ||
1039: (($newurl ne '') && ($newurl ne $url))) {
1.484.2.26 raeburn 1040: unless (&url_paste_fixups($url,$folder,$prefixchg,$coursedom,
1041: $coursenum,$srcdom,$srcnum,$allmaps,
1042: \%rewrites,\%retitles,\%copies,\%dbcopies,
1.484.2.7 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.484.2.26 raeburn 1049: &url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum,
1050: $srcdom,$srcnum,$allmaps,\%rewrites,
1.484.2.7 raeburn 1051: \%retitles,\%copies,\%dbcopies,\%zombies,\%params,\%mapmoves,
1.484.2.26 raeburn 1052: \%mapchanges,\%tomove,\%newsubdir,\%newurls);
1.484.2.7 raeburn 1053: }
1054: } elsif ($url=~m {^/res/}) {
1.329 droeschl 1055: # published maps can only exists once, so remove it from paste buffer when done
1.484.2.7 raeburn 1056: &Apache::lonnet::delenv('docs.markedcopy');
1057: # if pasting published map (main content are only) check map is not already in course
1058: if ($folder =~ /^default/) {
1.484.2.23 raeburn 1059: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1.484.2.7 raeburn 1060: return (&mt('Paste failed: only one instance of a particular published sequence or page is allowed within each course.'));
1061: }
1062: }
1063: }
1.329 droeschl 1064: }
1.484.2.26 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.484.2.7 raeburn 1080: $title=&mt('Copy of').' '.$title;
1081: } else {
1.484.2.26 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});
1.484.2.7 raeburn 1088: }
1.484.2.26 raeburn 1089: if ($lockerr{$prefix}) {
1090: $lockerrors = $lockerr{$prefix};
1091: }
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.484.2.7 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:
1103: my $newidx;
1104: unless ($is_map) {
1.329 droeschl 1105: # Now insert the URL at the bottom
1.484.2.7 raeburn 1106: $newidx = &LONCAPA::map::getresidx($url);
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+)/(.+)$});
1111: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
1112: my $newprefix = $newloc;
1113: if ($newloc eq 'default') {
1114: $newprefix = 'docs';
1115: }
1116: if ($newdocsdir eq '') {
1117: $newdocsdir = 'default';
1118: }
1.484.2.26 raeburn 1119: if (($prefixchg) ||
1120: ($srcdom ne $coursedom) || ($srcnum ne $coursenum) ||
1121: ($env{'form.docs.markedcopy_options'} ne 'move')) {
1.484.2.7 raeburn 1122: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
1123: $url =
1124: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
1125: &Apache::lonnet::getfile($oldurl));
1126: if ($url eq '/adm/notfound.html') {
1127: return (&mt('Paste failed: an error occurred saving the file.'));
1128: } else {
1129: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
1130: $newsubpath =~ s{/+$}{/};
1131: $docmoves{$oldurl} = $newsubpath;
1132: }
1133: }
1134: }
1135: }
1136: }
1.484.2.19 raeburn 1137: # Apply any changes to maps, or copy dependencies for uploaded HTML pages
1.484.2.7 raeburn 1138: my ($result,$save_err);
1.484.2.23 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,
1157: );
1.484.2.26 raeburn 1158: ($result,my $msgsarray,my $lockerror) =
1.484.2.23 raeburn 1159: &apply_fixups($folder,$is_map,$coursedom,$coursenum,$errors,
1160: \%updated,\%info,\%moves,$prefixchg,$oldurl,$url,'paste');
1.484.2.26 raeburn 1161: $lockerrors .= $lockerror;
1.484.2.7 raeburn 1162: if ($result eq 'ok') {
1.484.2.19 raeburn 1163: if ($is_map) {
1.484.2.7 raeburn 1164: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1165: $folder.'.'.$container);
1.484.2.26 raeburn 1166: return ($errtext,$save_err,$msgsarray,$lockerrors) if ($fatal);
1.484.2.7 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: }
1176: if ($env{'docs.markedcopy_supplemental'}) {
1177: if ($folder !~ /^supplemental/) {
1178: (undef,undef,$title) =
1179: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental'});
1180: }
1.329 droeschl 1181: } else {
1.484.2.7 raeburn 1182: if ($folder=~/^supplemental/) {
1183: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1184: $env{'user.domain'}.'___&&&___'.$title;
1185: }
1.329 droeschl 1186: }
1.484.2.19 raeburn 1187: $LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
1.484.2.7 raeburn 1188: push(@LONCAPA::map::order, $newidx);
1189:
1190: # Store the result
1.484.2.19 raeburn 1191: my ($errtext,$fatal) =
1.484.2.7 raeburn 1192: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1193: if ($fatal) {
1194: $save_err = $errtext;
1.329 droeschl 1195: }
1196: }
1.484.2.19 raeburn 1197:
1.484.2.7 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.484.2.26 raeburn 1203: return ($result,$save_err,$msgsarray,$lockerrors);
1.484.2.7 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: }
1262: }
1263: return ($newurl);
1264: }
1265:
1266: sub dbcopy {
1.484.2.26 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.484.2.7 raeburn 1354: }
1355: }
1.484.2.26 raeburn 1356: return ($url,$result,$errtext);
1.329 droeschl 1357: }
1358:
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.484.2.7 raeburn 1373: sub contained_map_check {
1374: my ($url,$folder,$removefrommap,$removeparam,$addedmaps,$hierarchy,$titles,
1375: $allmaps) = @_;
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)) {
1387: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1388: next;
1389: }
1390: }
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'};
1395: } else {
1396: if ($allmaps->{$ressrc}) {
1.484.2.23 raeburn 1397: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.484.2.7 raeburn 1398: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
1399: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1400: } else {
1401: $addedmaps->{$ressrc} = [$url];
1402: }
1403: }
1404: &contained_map_check($ressrc,$folder,$removefrommap,$removeparam,
1405: $addedmaps,$hierarchy,$titles,$allmaps);
1406: }
1407: } elsif ($token->[1] eq 'param') {
1408: if ($folder =~ /^supplemental/) {
1409: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
1410: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
1411: } else {
1.484.2.19 raeburn 1412: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
1.484.2.7 raeburn 1413: }
1414: }
1415: }
1416: }
1417: }
1418: return;
1419: }
1420:
1421: sub url_paste_fixups {
1.484.2.26 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.484.2.7 raeburn 1425: my $checktitle;
1426: if (($prefixchg) &&
1427: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
1428: $checktitle = 1;
1429: }
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: }
1437: my $file = &Apache::lonnet::getfile($oldurl);
1438: return if ($file eq '-1');
1439: my $parser = HTML::TokeParser->new(\$file);
1440: $parser->attr_encoded(1);
1441: my $changed = 0;
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 '');
1447: my $id = $token->[2]->{'id'};
1448: my $title = $token->[2]->{'title'};
1449: if ($checktitle) {
1450: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.484.2.25 raeburn 1451: $retitles->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 1452: }
1453: }
1454: next if ($token->[2]->{'type'} eq 'external');
1455: if ($token->[2]->{'type'} eq 'zombie') {
1.484.2.19 raeburn 1456: next if ($skip);
1.484.2.25 raeburn 1457: $zombies->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 1458: $changed = 1;
1459: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1460: my $srcdom = $1;
1461: my $srcnum = $2;
1462: my $rem = $3;
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.484.2.26 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.484.2.7 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))) {
1.484.2.19 raeburn 1489:
1.484.2.7 raeburn 1490: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.484.2.25 raeburn 1491: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 1492: $mapchanges->{$ressrc} = 1;
1.484.2.26 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.484.2.7 raeburn 1498: $mapmoves->{$ressrc} = 1;
1499: }
1500: $changed = 1;
1501: } else {
1.484.2.25 raeburn 1502: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 1503: $copies->{$oldurl}{$ressrc} = $id;
1504: $changed = 1;
1505: }
1506: }
1.484.2.26 raeburn 1507: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
1.484.2.19 raeburn 1508: next if ($skip);
1.484.2.7 raeburn 1509: my $srcdom = $1;
1510: my $srcnum = $2;
1511: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.25 raeburn 1512: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.26 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.484.2.7 raeburn 1524: $changed = 1;
1525: }
1526: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
1527: next if ($skip);
1528: my $srcdom = $1;
1529: my $srcnum = $2;
1530: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.26 raeburn 1531: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
1532: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
1533: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.484.2.7 raeburn 1534: $changed = 1;
1535: }
1536: }
1537: } elsif ($token->[1] eq 'param') {
1538: next if ($skip);
1.484.2.19 raeburn 1539: my $to = $token->[2]->{'to'};
1.484.2.7 raeburn 1540: if ($to ne '') {
1541: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
1542: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
1543: } else {
1544: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
1545: }
1546: }
1547: }
1548: }
1549: return $changed;
1550: }
1551:
1552: sub apply_fixups {
1.484.2.23 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.484.2.26 raeburn 1556: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
1557: %lockerrors,$lockmsg);
1.484.2.23 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.484.2.7 raeburn 1604: my @allcopies;
1.484.2.23 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.484.2.7 raeburn 1613: }
1.484.2.23 raeburn 1614: undef(%added);
1.484.2.7 raeburn 1615: }
1616: }
1617: if ($key eq $oldurl) {
1.484.2.23 raeburn 1618: if ((exists($docmoves{$key}))) {
1.484.2.25 raeburn 1619: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.484.2.7 raeburn 1620: push(@allcopies,$oldurl);
1621: }
1622: }
1623: }
1624: if (@allcopies > 0) {
1625: foreach my $item (@allcopies) {
1.484.2.19 raeburn 1626: my ($relpath,$oldsubdir,$fname) =
1.484.2.7 raeburn 1627: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
1628: if ($fname ne '') {
1629: my $content = &Apache::lonnet::getfile($item);
1630: unless ($content eq '-1') {
1631: my $storefn;
1.484.2.23 raeburn 1632: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
1633: $storefn = $docmoves{$key};
1.484.2.7 raeburn 1634: } else {
1635: $storefn = $relpath;
1636: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 1637: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
1638: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.484.2.7 raeburn 1639: }
1.484.2.23 raeburn 1640: if ($newsubdir{$key}) {
1.484.2.25 raeburn 1641: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.484.2.7 raeburn 1642: }
1643: }
1644: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
1.484.2.19 raeburn 1645: my $copyurl =
1.484.2.7 raeburn 1646: &Apache::lonclonecourse::writefile($env{'request.course.id'},
1647: $storefn.$fname,$content);
1648: if ($copyurl eq '/adm/notfound.html') {
1.484.2.23 raeburn 1649: if (exists($docmoves{$oldurl})) {
1.484.2.7 raeburn 1650: return &mt('Paste failed: an error occurred copying the file.');
1651: } elsif (ref($errors) eq 'HASH') {
1652: $errors->{$item} = 1;
1653: }
1654: }
1655: }
1656: }
1657: }
1658: }
1659: }
1.484.2.23 raeburn 1660: foreach my $key (keys(%mapmoves)) {
1.484.2.7 raeburn 1661: my $storefn=$key;
1662: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 1663: if ($prefixchg && $before{'map'} && $after{'map'}) {
1664: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 1665: }
1.484.2.23 raeburn 1666: if ($newsubdir{$key}) {
1667: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 1668: }
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;
1681: }
1682: }
1683: }
1684: }
1685: my %updates;
1686: if ($is_map) {
1.484.2.23 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.484.2.7 raeburn 1695: }
1696: foreach my $key (keys(%updates)) {
1697: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.484.2.23 raeburn 1698: if (ref($rewrites{$key}) eq 'HASH') {
1699: %torewrite = %{$rewrites{$key}};
1.484.2.7 raeburn 1700: }
1.484.2.23 raeburn 1701: if (ref($retitles{$key}) eq 'HASH') {
1702: %toretitle = %{$retitles{$key}};
1.484.2.7 raeburn 1703: }
1.484.2.23 raeburn 1704: if (ref($removefrommap{$key}) eq 'HASH') {
1705: %toremove = %{$removefrommap{$key}};
1.484.2.7 raeburn 1706: }
1.484.2.23 raeburn 1707: if (ref($removeparam{$key}) eq 'HASH') {
1708: %remparam = %{$removeparam{$key}};
1.484.2.7 raeburn 1709: }
1.484.2.23 raeburn 1710: if (ref($zombies{$key}) eq 'HASH') {
1711: %zombie = %{$zombies{$key}};
1.484.2.7 raeburn 1712: }
1.484.2.23 raeburn 1713: if (ref($dbcopies{$key}) eq 'HASH') {
1.484.2.26 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.484.2.7 raeburn 1725: }
1726: }
1.484.2.23 raeburn 1727: if (ref($params{$key}) eq 'HASH') {
1728: %currparam = %{$params{$key}};
1.484.2.7 raeburn 1729: }
1730: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
1731: if ($fatal) {
1.484.2.26 raeburn 1732: return ($errtext);
1.484.2.7 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.484.2.25 raeburn 1737: if ($zombie{$i} eq $src) {
1.484.2.7 raeburn 1738: undef($LONCAPA::map::zombies[$i]);
1739: }
1740: }
1741: }
1.484.2.23 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.484.2.7 raeburn 1745: my $changed;
1.484.2.23 raeburn 1746: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1747: if ((exists($toremove{$idx})) && ($toremove{$idx} eq $src)) {
1.484.2.7 raeburn 1748: splice(@LONCAPA::map::order,$i,1);
1.484.2.23 raeburn 1749: if (ref($currparam{$idx}) eq 'ARRAY') {
1750: foreach my $name (@{$currparam{$idx}}) {
1751: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.484.2.7 raeburn 1752: }
1753: }
1754: next;
1755: }
1756: my $origsrc = $src;
1.484.2.25 raeburn 1757: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.484.2.7 raeburn 1758: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1759: $changed = 1;
1760: }
1761: }
1.484.2.25 raeburn 1762: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.484.2.7 raeburn 1763: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
1764: if ($origsrc =~ m{^/uploaded/}) {
1.484.2.23 raeburn 1765: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.484.2.7 raeburn 1766: if ($src =~ /\.(page|sequence)$/) {
1.484.2.23 raeburn 1767: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.484.2.7 raeburn 1768: } else {
1.484.2.23 raeburn 1769: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.484.2.7 raeburn 1770: }
1771: }
1.484.2.25 raeburn 1772: if ($origsrc =~ /\.(page|sequence)$/) {
1773: if ($newsubdir{$origsrc}) {
1.484.2.23 raeburn 1774: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.484.2.7 raeburn 1775: }
1.484.2.25 raeburn 1776: } elsif ($newsubdir{$key}) {
1777: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.484.2.7 raeburn 1778: }
1779: }
1780: $changed = 1;
1.484.2.26 raeburn 1781: } elsif ($newdb{$idx} ne '') {
1782: $src = $newdb{$idx};
1.484.2.7 raeburn 1783: $changed = 1;
1784: }
1785: if ($changed) {
1.484.2.23 raeburn 1786: $LONCAPA::map::resources[$idx] = join(':',($title,$src,$ext,$type));
1.484.2.7 raeburn 1787: }
1788: }
1789: }
1790: foreach my $idx (keys(%remparam)) {
1791: if (ref($remparam{$idx}) eq 'ARRAY') {
1.484.2.19 raeburn 1792: foreach my $name (@{$remparam{$idx}}) {
1.484.2.7 raeburn 1793: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1794: }
1795: }
1796: }
1.484.2.26 raeburn 1797: if (values(%lockerrors) > 0) {
1798: $lockmsg = join('<br />',values(%lockerrors));
1799: }
1.484.2.7 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.484.2.23 raeburn 1807: if ($prefixchg && $before{'map'} && $after{'map'}) {
1808: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 1809: }
1.484.2.23 raeburn 1810: if ($newsubdir{$key}) {
1811: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 1812: }
1813: }
1814: my $report;
1815: if ($folder !~ /^supplemental/) {
1816: $report = 1;
1817: }
1.484.2.20 raeburn 1818: (my $outtext,$errtext) =
1.484.2.7 raeburn 1819: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
1820: if ($errtext) {
1.484.2.23 raeburn 1821: if ($caller eq 'paste') {
1.484.2.26 raeburn 1822: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.484.2.23 raeburn 1823: }
1.484.2.7 raeburn 1824: }
1825: }
1826: }
1.484.2.26 raeburn 1827: return ('ok',\@msgs,$lockmsg);
1.484.2.7 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: }
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.484.2.17 raeburn 1958: $supplementalflag,$orderhash,$iconpath,$pathitem)=@_;
1.484.2.19 raeburn 1959: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
1960: if ($allowed) {
1961: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
1962: $is_random_order,$container) =
1963: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1964: $r->print($breadcrumbtrail);
1965: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
1966: $container = 'page';
1967: } else {
1968: $container = 'sequence';
1969: }
1.484 raeburn 1970:
1.484.2.21 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.484.2.7 raeburn 2014: my %paste_errors;
1.484.2.26 raeburn 2015: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.484.2.7 raeburn 2016: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
2017: \%paste_errors);
1.484.2.26 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.484.2.7 raeburn 2031: if ($save_error ne '') {
1.484.2.19 raeburn 2032: return $save_error;
1.484.2.7 raeburn 2033: }
2034: if ($paste_res ne 'ok') {
1.329 droeschl 2035: $r->print('<p><span class="LC_error">'.$paste_res.'</span></p>');
2036: }
1.484.2.7 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.484.2.7 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.484.2.26 raeburn 2064: map { &unescape($_); } split(/\=/,$item);
2065: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
1.484.2.19 raeburn 2066: my ($suffix,$errortxt,$locknotfreed) =
1.484.2.26 raeburn 2067: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.484.2.15 raeburn 2068: if ($locknotfreed) {
2069: $r->print($locknotfreed);
2070: }
2071: if ($suffix) {
1.484.2.19 raeburn 2072: $url =~ s/_new\./_$suffix./;
1.484.2.15 raeburn 2073: } else {
2074: return $errortxt;
2075: }
1.484.2.26 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.484.2.27! 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.484.2.15 raeburn 2104: }
1.329 droeschl 2105: push(@imports, [$name, $url, $residx]);
2106: }
2107: }
1.484.2.23 raeburn 2108: ($errtext,$fatal,my $fixuperrors) =
2109: &group_import($coursenum, $coursedom, $folder,$container,
2110: 'londocs',@imports);
1.329 droeschl 2111: return $errtext if ($fatal);
1.484.2.23 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.484.2.7 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.484.2.12 raeburn 2180: $coursenum,$coursedom,$crstype,
1.484.2.19 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.484.2.19 raeburn 2186:
2187: if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) {
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.484.2.21 raeburn 2193: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.484.2.19 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 />';
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 {
2215: $to_show .= $toolslink
2216: .&Apache::loncommon::start_data_table('LC_tableOfContent')
2217: .$output.' '
2218: .&Apache::loncommon::end_data_table();
2219: }
2220: } else {
2221: if (!$allowed) {
2222: $to_show .= $toolslink;
1.393 raeburn 2223: }
1.484.2.19 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.484.2.19 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.484.2.7 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.484.2.19 raeburn 2273: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 2274: $container='page';
2275: }
2276: ($errtext,$fatal)=
1.484.2.27! 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.484.2.27! 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.484.2.7 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.484.2.12 raeburn 2416: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.484.2.19 raeburn 2417: $crstype,$pathitem,$supplementalflag,$container)=@_;
2418: my ($foldertitle,$renametitle);
1.329 droeschl 2419: if (&is_supplemental_title($title)) {
1.484.2.7 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.484.2.19 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.484.2.16 raeburn 2446: my $isexternal;
1.484.2.19 raeburn 2447: if ($residx) {
1.484.2.12 raeburn 2448: my $currurl = $url;
2449: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.16 raeburn 2450: if ($currurl =~ m{^/adm/wrapper/ext/}) {
2451: $isexternal = 1;
2452: }
1.484.2.19 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.484.2.12 raeburn 2461: }
1.484.2.19 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.484.2.12 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.484.2.12 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.484.2.9 raeburn 2501: my $noremove=0;
1.484.2.7 raeburn 2502: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
1.484.2.19 raeburn 2503: # no copy for published maps
2504: $nocopy=1;
2505: }
1.344 bisitz 2506: if ($url=~/^\/res\/lib\/templates\//) {
2507: $nocopy=1;
1.329 droeschl 2508: $nocut=1;
2509: }
1.484.2.9 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.484.2.19 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.484.2.16 raeburn 2567: |\.html$)}x)
1.484.2.19 raeburn 2568: || $isexternal) {
1.329 droeschl 2569: $skip_confirm = 1;
2570: }
1.484.2.19 raeburn 2571:
2572: if ($nocopy) {
1.484.2.16 raeburn 2573: $copylink=(<<ENDCOPY);
2574: <span style="visibility: hidden;">$lt{'cp'}</span>
2575: ENDCOPY
2576: } else {
1.484.2.19 raeburn 2577: $copylink=(<<ENDCOPY);
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.484.2.19 raeburn 2581: if ($nocut) {
1.484.2.16 raeburn 2582: $cutlink=(<<ENDCUT);
2583: <span style="visibility: hidden;">$lt{'ct'}</span>
2584: ENDCUT
2585: } else {
1.484.2.19 raeburn 2586: $cutlink=(<<ENDCUT);
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.484.2.16 raeburn 2590: if ($noremove) {
2591: $removelink=(<<ENDREM);
2592: <span style="visibility: hidden;">$lt{'rm'}</a>
2593: ENDREM
2594: } else {
1.484.2.9 raeburn 2595: $removelink=(<<ENDREM);
1.484.2.19 raeburn 2596: <a href='javascript:removeres("$esc_path","$index","$renametitle",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
1.484.2.9 raeburn 2597: ENDREM
2598: }
1.484.2.19 raeburn 2599: unless ($isexternal) {
2600: $renamelink=(<<ENDREN);
2601: <a href='javascript:changename("$esc_path","$index","$renametitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.484.2.16 raeburn 2602: ENDREN
1.484.2.19 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.484.2.10 raeburn 2617: <a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb'>
1.484.2.12 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.484.2.10 raeburn 2622: <a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb'>
1.484.2.12 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.484.2.16 raeburn 2633: <td class="LC_docs_entry_commands"><span class="LC_nobreak">
1.484.2.9 raeburn 2634: $removelink
1.329 droeschl 2635: $cutlink
2636: $copylink
1.484.2.16 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.484.2.19 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.484.2.19 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.484.2.19 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.484.2.19 raeburn 2673: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.12 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.484.2.19 raeburn 2690: }
1.484.2.12 raeburn 2691: if (&Apache::lonnet::symbverify($symb,$url)) {
1.484.2.19 raeburn 2692: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
1.484.2.12 raeburn 2693: } else {
2694: $url='';
2695: }
1.484.2.19 raeburn 2696: }
1.329 droeschl 2697: }
1.478 raeburn 2698: my ($rand_pick_text,$rand_order_text);
1.484.2.19 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.484.2.19 raeburn 2703: if (!$allowed && $supplementalflag) {
2704: $folderpath.=$containerarg.'&'.$foldername;
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.484.2.19 raeburn 2709: $folderpath.=$containerarg.'&'.$foldername.
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.484.2.19 raeburn 2717: 'parameter_randomorder'))[0]=~/^yes$/i)
2718: .':'.$ispage;
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.484.2.19 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.484.2.19 raeburn 2741: }
1.484.2.18 raeburn 2742: } elsif ($supplementalflag && !$allowed) {
1.484.2.19 raeburn 2743: $url .= ($url =~ /\?/) ? '&':'?';
1.484.2.18 raeburn 2744: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.484.2.19 raeburn 2745: if ($title) {
2746: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
2747: }
2748: if ($isexternal && $orderidx) {
2749: $url .= '&idx='.$orderidx;
2750: }
1.329 droeschl 2751: }
1.484.2.19 raeburn 2752: my ($tdalign,$tdwidth);
1.484.2.12 raeburn 2753: if ($allowed) {
1.484.2.19 raeburn 2754: my $fileloc =
1.484.2.12 raeburn 2755: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.484.2.19 raeburn 2756: if ($isexternal) {
2757: ($editlink,$extresform) =
2758: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem);
2759: } elsif (!$isfolder && !$ispage) {
2760: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
1.484.2.14 raeburn 2761: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.484.2.19 raeburn 2762: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
2763: my $jscall =
1.484.2.12 raeburn 2764: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
2765: $switchserver,
1.484.2.14 raeburn 2766: $forceedit,
1.484.2.19 raeburn 2767: undef,$symb,
2768: &escape($env{'form.folderpath'}),
2769: $renametitle,'','',1);
1.484.2.12 raeburn 2770: if ($jscall) {
1.484.2.19 raeburn 2771: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
2772: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.484.2.12 raeburn 2773: }
2774: }
2775: }
1.484.2.19 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.484.2.19 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.484.2.19 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.484.2.19 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.484.2.26 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.484.2.15 raeburn 2847: }
2848: $idtype = 'concat';
2849: my ($suffix,$freedlock,$error) =
1.484.2.26 raeburn 2850: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,
1.484.2.15 raeburn 2851: $coursedom,$coursenum);
2852: if (!$suffix) {
1.484.2.26 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.484.2.15 raeburn 2860: if ($error) {
2861: $errtext .= '<br />'.$error;
2862: }
2863: }
2864: if ($freedlock ne 'ok') {
1.484.2.26 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.484.2.15 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.484.2.19 raeburn 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.484.2.3 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.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.19 raeburn 3176: $weeksel=' selected="selected"';
1.329 droeschl 3177: } elsif ($env{'form.timerange'}==86400) {
3178: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.10 raeburn 3250: #excludes not versionable problems from resource version history:
3251: next unless ($changes{$key}>$starttime && $key !~ /^\/res\/lib\/templates/);
1.484.2.19 raeburn 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.484.2.19 raeburn 3260: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
1.479 golterma 3261: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
1.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.19 raeburn 3271: } else {
1.479 golterma 3272: $r->print($usedversion);
3273: }
1.329 droeschl 3274: } else {
1.484.2.19 raeburn 3275: $r->print($currentversion);
1.329 droeschl 3276: }
1.484.2.19 raeburn 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.484.2.19 raeburn 3312: $r->print('</span><br />');
3313: }
3314: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.329 droeschl 3315: }
1.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.12 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 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
3421: } else {
3422: $output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Content Editor').' </b></a></li>'."\n";
3423: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
3424: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
3425: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
3426: }
3427: $output .= "\n".'</ul>'."\n";
3428: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
3429: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
3430: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
3431: return $output;
1.442 www 3432: }
3433:
3434: #
3435: # End tabs
3436: #
3437:
3438: sub endContentScreen {
1.484 raeburn 3439: return '</div></div></div>';
1.442 www 3440: }
1.329 droeschl 3441:
1.446 www 3442: sub supplemental_base {
1.472 raeburn 3443: return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Content'));
1.446 www 3444: }
3445:
1.329 droeschl 3446: sub handler {
3447: my $r = shift;
3448: &Apache::loncommon::content_type($r,'text/html');
3449: $r->send_http_header;
3450: return OK if $r->header_only;
1.484 raeburn 3451:
3452: # get course data
1.408 raeburn 3453: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 3454: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
3455: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3456:
3457: # graphics settings
3458: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 3459:
1.443 www 3460: #
1.329 droeschl 3461: # --------------------------------------------- Initialize help topics for this
3462: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
3463: 'Adding_External_Resource','Navigate_Content',
3464: 'Adding_Folders','Docs_Overview', 'Load_Map',
3465: 'Supplemental','Score_Upload_Form','Adding_Pages',
1.484.2.19 raeburn 3466: 'Importing_LON-CAPA_Resource','Importing_IMS_Course',
1.484.2.12 raeburn 3467: 'Uploading_From_Harddrive',
1.329 droeschl 3468: 'Check_Resource_Versions','Verify_Content') {
3469: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
3470: }
3471: # Composite help files
3472: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
3473: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
3474: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
3475: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
3476: $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
3477: 'Option_Response_Simple');
3478: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
3479: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 3480: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 3481: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 3482: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 3483: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.484.2.27! raeburn 3484: $help{'Course Roster'} = &Apache::loncommon::help_open_topic('Docs_Course_Roster');
! 3485: $help{'Web Page'} = &Apache::loncommon::help_open_topic('Docs_Web_Page');
1.472 raeburn 3486:
3487: my $allowed;
3488: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
3489: unless ($r->uri eq '/adm/supplemental') {
3490: # does this user have privileges to modify content.
3491: $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
3492: }
3493:
1.484 raeburn 3494: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chooseserver',
3495: 'inhibitmenu']);
3496: if ($allowed && $env{'form.chooseserver'}) {
3497: &choose_dump_server($r);
3498: return OK;
3499: } elsif ($allowed && $env{'form.verify'}) {
1.329 droeschl 3500: &init_breadcrumbs('verify','Verify Content');
3501: &verifycontent($r);
3502: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 3503: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 3504: &list_symbs($r);
3505: } elsif ($allowed && $env{'form.docslog'}) {
3506: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 3507: my $folder = $env{'form.folder'};
3508: if ($folder eq '') {
3509: $folder='default';
3510: }
3511: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath);
1.329 droeschl 3512: } elsif ($allowed && $env{'form.versions'}) {
3513: &init_breadcrumbs('versions','Check/Set Resource Versions');
3514: &checkversions($r);
3515: } elsif ($allowed && $env{'form.dumpcourse'}) {
1.484 raeburn 3516: &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 3517: &dumpcourse($r);
3518: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 3519: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 3520: &Apache::imsexport::exportcourse($r);
1.329 droeschl 3521: } else {
1.445 www 3522: #
3523: # Done catching special calls
1.484 raeburn 3524: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 3525: # Get the parameters that may be needed
3526: #
3527: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.484.2.19 raeburn 3528: ['folderpath',
3529: 'forcesupplement','forcestandard',
3530: 'tools','symb','command','supppath']);
1.445 www 3531:
3532: # standard=1: this is a "new-style" course with an uploaded map as top level
3533: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 3534:
3535: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 3536:
1.484 raeburn 3537: # Decide whether this should display supplemental or main content or utilities
1.445 www 3538: # supplementalflag=1: show supplemental documents
3539: # supplementalflag=0: show standard documents
1.484 raeburn 3540: # toolsflag=1: show utilities
1.445 www 3541:
3542:
3543: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.484.2.19 raeburn 3544: if (($env{'form.folderpath'}=~/^default/) || ($env{'form.folderpath'} eq "")) {
1.445 www 3545: $supplementalflag=0;
3546: }
3547: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
3548: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
3549: unless ($allowed) { $supplementalflag=1; }
3550: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 3551: my $toolsflag=0;
3552: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 3553:
1.329 droeschl 3554: my $script='';
3555: my $showdoc=0;
1.457 raeburn 3556: my $addentries = {};
1.475 raeburn 3557: my $container;
1.329 droeschl 3558: my $containertag;
1.484.2.17 raeburn 3559: my $pathitem;
1.329 droeschl 3560:
1.464 www 3561: # Do we directly jump somewhere?
1.466 www 3562:
1.484.2.21 raeburn 3563: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 3564: if ($env{'form.symb'} ne '') {
1.484.2.19 raeburn 3565: $env{'form.folderpath'}=
3566: &Apache::loncommon::symb_to_docspath($env{'form.symb'});
1.484.2.21 raeburn 3567: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
3568: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 3569: } elsif ($env{'form.supppath'} ne '') {
3570: $env{'form.folderpath'}=$env{'form.supppath'};
1.484.2.21 raeburn 3571: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
3572: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 3573: }
1.472 raeburn 3574: } elsif ($env{'form.command'} eq 'editdocs') {
1.484.2.21 raeburn 3575: $env{'form.folderpath'} = 'default&'.
3576: &Apache::lonhtmlcommon::entity_encode('Main Course Content').
3577: ':::::';
3578: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 3579: } elsif ($env{'form.command'} eq 'editsupp') {
1.484.2.21 raeburn 3580: $env{'form.folderpath'} = 'supplemental&'.
1.472 raeburn 3581: &Apache::lonhtmlcommon::entity_encode('Supplemental Content');
1.484.2.21 raeburn 3582: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
3583: } elsif ($env{'form.command'} eq 'contents') {
3584: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
3585: } elsif ($env{'form.command'} eq 'home') {
3586: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 3587: }
3588:
1.484.2.23 raeburn 3589:
1.445 www 3590: # Where do we store these for when we come back?
3591: my $stored_folderpath='docs_folderpath';
3592: if ($supplementalflag) {
3593: $stored_folderpath='docs_sup_folderpath';
3594: }
1.464 www 3595:
1.484.2.19 raeburn 3596: # No folderpath, and in edit mode, see if we have something stored
3597: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 3598: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.484.2.19 raeburn 3599: {'folderpath' => 'scalar'});
3600: unless (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
3601: undef($env{'form.folderpath'});
3602: }
1.329 droeschl 3603: }
1.446 www 3604:
3605: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 3606: if (!$allowed) {
1.446 www 3607: unless ($env{'form.folderpath'} =~ /^supplemental/) {
3608: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 3609: }
3610: }
1.446 www 3611: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 3612: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 3613: $env{'form.folderpath'} = &supplemental_base()
3614: .'&'.
1.329 droeschl 3615: $env{'form.folderpath'};
3616: }
1.446 www 3617: # If after all of this, we still don't have any paths, make them
1.484.2.19 raeburn 3618: unless ($env{'form.folderpath'}) {
1.446 www 3619: if ($supplementalflag) {
3620: $env{'form.folderpath'}=&supplemental_base();
3621: } else {
1.484.2.19 raeburn 3622: $env{'form.folderpath'}='default'.&escape(&mt('Main '.$crstype.' Documents')).
3623: ':::::';
1.446 www 3624: }
1.472 raeburn 3625: }
1.446 www 3626:
1.445 www 3627: # Store this
1.484 raeburn 3628: unless ($toolsflag) {
1.484.2.19 raeburn 3629: if ($allowed) {
3630: &Apache::loncommon::store_course_settings($stored_folderpath,
3631: {'folderpath' => 'scalar'});
3632: }
3633: my $folderpath;
1.484 raeburn 3634: if ($env{'form.folderpath'}) {
1.484.2.19 raeburn 3635: $folderpath = $env{'form.folderpath'};
3636: my (@folders)=split('&',$env{'form.folderpath'});
3637: $env{'form.foldername'}=&unescape(pop(@folders));
3638: if ($env{'form.foldername'} =~ /\:1$/) {
3639: $container = 'page';
3640: } else {
3641: $container = 'sequence';
3642: }
3643: $env{'form.folder'}=pop(@folders);
1.484 raeburn 3644: } else {
1.484.2.19 raeburn 3645: if ($env{'form.folder'} eq '' ||
3646: $env{'form.folder'} eq 'supplemental') {
3647: $folderpath='default&'.
3648: &escape(&mt('Main '.$crstype.' Documents')).
3649: ':::::';
1.484 raeburn 3650: }
3651: }
1.484.2.19 raeburn 3652: $containertag = '<input type="hidden" name="folderpath" value="" />';
3653: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 3654: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
3655: $showdoc='/'.$1;
3656: }
3657: if ($showdoc) { # got called in sequence from course
3658: $allowed=0;
3659: } else {
3660: if ($allowed) {
3661: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
3662: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 3663: }
3664: }
1.329 droeschl 3665: }
3666:
1.344 bisitz 3667: # get personal data
1.329 droeschl 3668: my $uname=$env{'user.name'};
3669: my $udom=$env{'user.domain'};
3670: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
3671:
3672: if ($allowed) {
1.484 raeburn 3673: if ($toolsflag) {
3674: $script .= &inject_data_js();
3675: my ($home,$other,%outhash)=&authorhosts();
3676: if (!$home && $other) {
3677: my @hosts;
3678: foreach my $aurole (keys(%outhash)) {
3679: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
3680: push(@hosts,$outhash{$aurole});
3681: }
3682: }
3683: $script .= &dump_switchserver_js(@hosts);
3684: }
1.458 raeburn 3685: } else {
1.484 raeburn 3686: my @tabids;
3687: if ($supplementalflag) {
3688: @tabids = ('002','ee2','ff2');
3689: } else {
3690: @tabids = ('aa1','bb1','cc1','ff1');
1.484.2.19 raeburn 3691: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 3692: unshift(@tabids,'001');
3693: push(@tabids,('dd1','ee1'));
3694: }
1.458 raeburn 3695: }
1.484 raeburn 3696: my $tabidstr = join("','",@tabids);
3697: $script .= &editing_js($udom,$uname,$supplementalflag).
3698: &history_tab_js().
3699: &inject_data_js().
1.484.2.19 raeburn 3700: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr).
3701: &Apache::lonextresedit::extedit_javascript();
1.484 raeburn 3702: $addentries = {
1.484.2.3 raeburn 3703: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 3704: };
1.458 raeburn 3705: }
1.484.2.7 raeburn 3706: if ($env{'docs.markedcopy_url'}) {
1.484.2.19 raeburn 3707: $script .= &paste_popup_js();
1.484.2.7 raeburn 3708: }
1.484.2.12 raeburn 3709: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
3710: &mt('Switch server?');
1.484.2.19 raeburn 3711:
3712:
1.329 droeschl 3713: }
3714: # -------------------------------------------------------------------- Body tag
1.369 bisitz 3715: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 3716: .'// <![CDATA['."\n"
3717: .$script."\n"
3718: .'// ]]>'."\n"
3719: .'</script>'."\n";
1.385 bisitz 3720:
3721: # Breadcrumbs
3722: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484.2.19 raeburn 3723:
3724: if ($showdoc) {
3725: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
3726: {'force_register' => $showdoc,}));
3727: } elsif ($r->uri eq '/adm/supplemental') {
3728: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
3729: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
3730: {'bread_crumbs' => $brcrum,}));
3731: } else {
1.392 raeburn 3732: &Apache::lonhtmlcommon::add_breadcrumb({
1.446 www 3733: href=>"/adm/coursedocs",text=>"$crstype Contents"});
1.392 raeburn 3734:
1.446 www 3735: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.484.2.19 raeburn 3736: {'add_entries' => $addentries}
3737: )
1.392 raeburn 3738: .&Apache::loncommon::help_open_menu('','',273,'RAT')
3739: .&Apache::lonhtmlcommon::breadcrumbs(
1.484 raeburn 3740: 'Editing '.$crstype.' Contents',
1.392 raeburn 3741: 'Docs_Adding_Course_Doc')
3742: );
3743: }
1.364 bisitz 3744:
1.329 droeschl 3745: my %allfiles = ();
3746: my %codebase = ();
1.440 raeburn 3747: my ($upload_result,$upload_output,$uploadphase);
1.329 droeschl 3748: if ($allowed) {
3749: if (($env{'form.uploaddoc.filename'}) &&
3750: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 3751: my $context = $1;
3752: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 3753: undef($hadchanges);
1.440 raeburn 3754: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
3755: \%allfiles,\%codebase,$context);
1.329 droeschl 3756: if ($hadchanges) {
3757: &mark_hash_old();
3758: }
1.440 raeburn 3759: $r->print($upload_output);
3760: } elsif ($env{'form.phase'} eq 'upload_embedded') {
3761: # Process file upload - phase two - upload embedded objects
3762: $uploadphase = 'check_embedded';
3763: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
3764: my $state = &embedded_form_elems($uploadphase,$primaryurl,
3765: $env{'form.newidx'});
3766: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
3767: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3768: my ($destination,$dir_root) = &embedded_destination();
3769: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
3770: my $actionurl = '/adm/coursedocs';
3771: my ($result,$flag) =
3772: &Apache::loncommon::upload_embedded('coursedoc',$destination,
3773: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
3774: $actionurl);
3775: $r->print($result.&return_to_editor());
3776: } elsif ($env{'form.phase'} eq 'check_embedded') {
3777: # Process file upload - phase three - modify references in HTML file
3778: $uploadphase = 'modified_orightml';
3779: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
3780: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3781: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 3782: my $result =
3783: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
3784: $docuname,$docudom,undef,
3785: $dir_root);
3786: $r->print($result.&return_to_editor());
1.476 raeburn 3787: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
3788: $uploadphase = 'decompress_phase_one';
3789: $r->print(&decompression_phase_one().
3790: &return_to_editor());
3791: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
3792: $uploadphase = 'decompress_phase_two';
3793: $r->print(&decompression_phase_two().
3794: &return_to_editor());
1.329 droeschl 3795: }
3796: }
3797:
1.484 raeburn 3798: if ($allowed && $toolsflag) {
3799: $r->print(&startContentScreen('tools'));
3800: $r->print(&generate_admin_menu($crstype));
3801: $r->print(&endContentScreen());
3802: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 3803: # -----------------------------------------------------------------------------
3804: my %lt=&Apache::lonlocal::texthash(
3805: 'copm' => 'All documents out of a published map into this folder',
1.484.2.12 raeburn 3806: 'upfi' => 'Upload File',
3807: 'upld' => 'Import Content',
1.329 droeschl 3808: 'srch' => 'Search',
3809: 'impo' => 'Import',
1.484.2.19 raeburn 3810: 'lnks' => 'Import from Stored Links',
1.484.2.13 raeburn 3811: 'impm' => 'Import from Assembled Map',
1.329 droeschl 3812: 'selm' => 'Select Map',
3813: 'load' => 'Load Map',
3814: 'newf' => 'New Folder',
3815: 'newp' => 'New Composite Page',
3816: 'syll' => 'Syllabus',
1.425 raeburn 3817: 'navc' => 'Table of Contents',
1.343 biermanm 3818: 'sipa' => 'Simple Course Page',
1.329 droeschl 3819: 'sipr' => 'Simple Problem',
1.484.2.27! raeburn 3820: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 3821: 'drbx' => 'Drop Box',
1.451 www 3822: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 3823: 'bull' => 'Discussion Board',
1.347 weissno 3824: 'mypi' => 'My Personal Information Page',
1.353 weissno 3825: 'grpo' => 'Group Portfolio',
1.329 droeschl 3826: 'rost' => 'Course Roster',
1.484.2.22 raeburn 3827: 'abou' => 'Personal Information Page for a User',
1.377 bisitz 3828: 'imsf' => 'IMS Import',
3829: 'imsl' => 'Import IMS package',
1.484.2.12 raeburn 3830: 'cms' => 'Origin of IMS package',
3831: 'se' => 'Select',
1.484.2.19 raeburn 3832: 'file' => 'File',
1.329 droeschl 3833: 'title' => 'Title',
3834: 'comment' => 'Comment',
1.403 raeburn 3835: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.329 droeschl 3836: );
3837: # -----------------------------------------------------------------------------
3838: my $fileupload=(<<FIUP);
3839: $lt{'file'}:<br />
3840: <input type="file" name="uploaddoc" size="40" />
3841: FIUP
3842:
3843: my $checkbox=(<<CHBO);
3844: <!-- <label>$lt{'parse'}?
3845: <input type="checkbox" name="parserflag" />
3846: </label> -->
3847: <label>
3848: <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
3849: </label>
3850: CHBO
1.484.2.12 raeburn 3851: my $imsfolder = $env{'form.folder'};
3852: if ($imsfolder eq '') {
1.484.2.19 raeburn 3853: $imsfolder = 'default';
1.484.2.12 raeburn 3854: }
3855: my $imspform=(<<IMSFORM);
3856: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
3857: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
3858: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.484.2.19 raeburn 3859: <fieldset id="uploadimsform" style="display: none;">
1.484.2.12 raeburn 3860: <legend>$lt{'imsf'}</legend>
3861: $fileupload
3862: <br />
3863: <p>
1.484.2.19 raeburn 3864: $lt{'cms'}:
1.484.2.12 raeburn 3865: <select name="source">
3866: <option value="-1" selected="selected">$lt{'se'}</option>
3867: <option value="bb5">Blackboard 5</option>
3868: <option value="bb6">Blackboard 6</option>
3869: <option value="angel5">ANGEL 5.5</option>
3870: <option value="webctce4">WebCT 4 Campus Edition</option>
3871: </select>
3872: <input type="hidden" name="folder" value="$imsfolder" />
3873: </p>
3874: <input type="hidden" name="phase" value="one" />
3875: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" />
3876: </fieldset>
3877: </form>
3878: IMSFORM
3879:
1.484.2.19 raeburn 3880: my $fileuploadform=(<<FUFORM);
1.484.2.12 raeburn 3881: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
3882: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
3883: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.484.2.19 raeburn 3884: <fieldset id="uploaddocform" style="display: none;">
1.484.2.12 raeburn 3885: <legend>$lt{'upfi'}</legend>
1.371 tempelho 3886: <input type="hidden" name="active" value="aa" />
1.329 droeschl 3887: $fileupload
3888: <br />
3889: $lt{'title'}:<br />
1.458 raeburn 3890: <input type="text" size="60" name="comment" />
1.484.2.17 raeburn 3891: $pathitem
1.329 droeschl 3892: <input type="hidden" name="cmd" value="upload_default" />
3893: <br />
1.458 raeburn 3894: <span class="LC_nobreak" style="float:left">
1.329 droeschl 3895: $checkbox
3896: </span>
1.484.2.12 raeburn 3897: <br clear="all" />
3898: <input type="submit" value="$lt{'upld'}" />
3899: </fieldset>
3900: </form>
1.383 tempelho 3901: FUFORM
1.329 droeschl 3902:
1.484.2.19 raeburn 3903: my $importpubform=(<<SEDFFORM);
3904: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.484.2.13 raeburn 3905: $lt{'impm'}</a>$help{'Load_Map'}
1.484.2.19 raeburn 3906: <form action="/adm/coursedocs" method="post" name="mapimportform">
3907: <fieldset id="importmapform" style="display: none;">
1.484.2.13 raeburn 3908: <legend>$lt{'impm'}</legend>
1.484.2.19 raeburn 3909: <input type="hidden" name="active" value="bb" />
1.484.2.13 raeburn 3910: $lt{'copm'}<br />
3911: <span class="LC_nobreak">
1.484.2.19 raeburn 3912: <input type="text" name="importmap" size="40" value=""
1.484.2.13 raeburn 3913: onfocus="this.blur();openbrowser('mapimportform','importmap','sequence,page','');" />
1.484.2.19 raeburn 3914: <a href="javascript:openbrowser('mapimportform','importmap','sequence,page','');">$lt{'selm'}</a></span><br />
1.484.2.13 raeburn 3915: <input type="submit" name="loadmap" value="$lt{'load'}" />
3916: </fieldset>
3917: </form>
3918:
1.383 tempelho 3919: SEDFFORM
1.484.2.19 raeburn 3920: my @importpubforma = (
3921: { '<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 3922: { '<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.484.2.19 raeburn 3923: { '<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>" },
3924: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
3925: );
3926: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
3927: my $extresourcesform =
3928: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
3929: $help{'Adding_External_Resource'});
1.329 droeschl 3930: if ($allowed) {
1.484.2.7 raeburn 3931: my $folder = $env{'form.folder'};
3932: if ($folder eq '') {
3933: $folder='default';
3934: }
3935: &update_paste_buffer($coursenum,$coursedom,$folder);
1.337 ehlerst 3936: $r->print(<<HIDDENFORM);
3937: <form name="renameform" method="post" action="/adm/coursedocs">
3938: <input type="hidden" name="title" />
3939: <input type="hidden" name="cmd" />
3940: <input type="hidden" name="markcopy" />
3941: <input type="hidden" name="copyfolder" />
3942: $containertag
3943: </form>
1.484 raeburn 3944:
1.337 ehlerst 3945: HIDDENFORM
1.484.2.17 raeburn 3946: $r->print(&makesimpleeditform($pathitem)."\n".
3947: &makedocslogform($pathitem."\n".
1.484 raeburn 3948: '<input type="hidden" name="folder" value="'.
3949: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 3950: }
1.442 www 3951:
3952: # Generate the tabs
1.484.2.19 raeburn 3953: my ($mode,$needs_end);
1.472 raeburn 3954: if (($supplementalflag) && (!$allowed)) {
1.484.2.19 raeburn 3955: my @folders = split('&',$env{'form.folderpath'});
3956: unless (@folders > 2) {
3957: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
3958: $needs_end = 1;
3959: }
1.472 raeburn 3960: } else {
1.484 raeburn 3961: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484.2.19 raeburn 3962: $needs_end = 1;
1.472 raeburn 3963: }
1.443 www 3964:
1.442 www 3965: #
3966:
3967: my $savefolderpath;
3968:
1.395 raeburn 3969: if ($allowed) {
1.329 droeschl 3970: my $folder=$env{'form.folder'};
1.443 www 3971: if ($folder eq '' || $supplementalflag) {
1.329 droeschl 3972: $folder='default';
1.356 tempelho 3973: $savefolderpath = $env{'form.folderpath'};
1.442 www 3974: $env{'form.folderpath'}='default&'.&escape(&mt('Content'));
1.484.2.17 raeburn 3975: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 3976: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
3977: }
3978: my $postexec='';
3979: if ($folder eq 'default') {
1.372 bisitz 3980: $r->print('<script type="text/javascript">'."\n"
3981: .'// <![CDATA['."\n"
3982: .'this.window.name="loncapaclient";'."\n"
3983: .'// ]]>'."\n"
3984: .'</script>'."\n"
1.369 bisitz 3985: );
1.329 droeschl 3986: } else {
3987: #$postexec='self.close();';
3988: }
1.484.2.15 raeburn 3989: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
3990: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 3991: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
3992:
3993: my $newnavform=(<<NNFORM);
3994: <form action="/adm/coursedocs" method="post" name="newnav">
1.371 tempelho 3995: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 3996: $pathitem
1.329 droeschl 3997: <input type="hidden" name="importdetail"
3998: value="$lt{'navc'}=/adm/navmaps" />
1.423 onken 3999: <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
1.329 droeschl 4000: $help{'Navigate_Content'}
4001: </form>
4002: NNFORM
4003: my $newsmppageform=(<<NSPFORM);
4004: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.371 tempelho 4005: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4006: $pathitem
1.329 droeschl 4007: <input type="hidden" name="importdetail" value="" />
1.423 onken 4008: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 4009: $help{'Simple Page'}
1.329 droeschl 4010: </form>
4011: NSPFORM
4012:
4013: my $newsmpproblemform=(<<NSPROBFORM);
4014: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 4015: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4016: $pathitem
1.329 droeschl 4017: <input type="hidden" name="importdetail" value="" />
1.423 onken 4018: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.383 tempelho 4019: $help{'Simple Problem'}
1.329 droeschl 4020: </form>
4021:
4022: NSPROBFORM
4023:
4024: my $newdropboxform=(<<NDBFORM);
4025: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 4026: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4027: $pathitem
1.329 droeschl 4028: <input type="hidden" name="importdetail" value="" />
1.423 onken 4029: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.344 bisitz 4030: </form>
1.329 droeschl 4031: NDBFORM
4032:
4033: my $newexuploadform=(<<NEXUFORM);
4034: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 4035: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4036: $pathitem
1.329 droeschl 4037: <input type="hidden" name="importdetail" value="" />
1.423 onken 4038: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 4039: $help{'Score_Upload_Form'}
4040: </form>
4041: NEXUFORM
4042:
4043: my $newbulform=(<<NBFORM);
4044: <form action="/adm/coursedocs" method="post" name="newbul">
1.371 tempelho 4045: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4046: $pathitem
1.329 droeschl 4047: <input type="hidden" name="importdetail" value="" />
1.423 onken 4048: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 4049: $help{'Bulletin Board'}
4050: </form>
4051: NBFORM
4052:
4053: my $newaboutmeform=(<<NAMFORM);
4054: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.371 tempelho 4055: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4056: $pathitem
1.329 droeschl 4057: <input type="hidden" name="importdetail"
4058: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 4059: <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 4060: $help{'My Personal Information Page'}
1.329 droeschl 4061: </form>
4062: NAMFORM
4063:
4064: my $newaboutsomeoneform=(<<NASOFORM);
4065: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.371 tempelho 4066: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4067: $pathitem
1.329 droeschl 4068: <input type="hidden" name="importdetail" value="" />
1.423 onken 4069: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 4070: </form>
4071: NASOFORM
4072:
4073: my $newrosterform=(<<NROSTFORM);
4074: <form action="/adm/coursedocs" method="post" name="newroster">
1.371 tempelho 4075: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4076: $pathitem
1.329 droeschl 4077: <input type="hidden" name="importdetail"
4078: value="$lt{'rost'}=/adm/viewclasslist" />
1.423 onken 4079: <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
1.329 droeschl 4080: $help{'Course Roster'}
4081: </form>
4082: NROSTFORM
4083:
1.484.2.27! raeburn 4084: my $newwebpage;
! 4085: if ($folder =~ /^default_?(\d*)$/) {
! 4086: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
! 4087: if ($1) {
! 4088: $newwebpage .= $1;
! 4089: } else {
! 4090: $newwebpage .= 'default';
! 4091: }
! 4092: $newwebpage .= '/new.html';
! 4093: }
! 4094: my $newwebpageform =(<<NWEBFORM);
! 4095: <form action="/adm/coursedocs" method="post" name="newwebpage">
! 4096: <input type="hidden" name="active" value="cc" />
! 4097: $pathitem
! 4098: <input type="hidden" name="importdetail" value="$newwebpage" />
! 4099: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
! 4100: $help{'Web Page'}
! 4101: </form>
! 4102: NWEBFORM
! 4103:
! 4104:
1.342 ehlerst 4105: my $specialdocumentsform;
1.383 tempelho 4106: my @specialdocumentsforma;
1.451 www 4107: my $gradingform;
4108: my @gradingforma;
4109: my $communityform;
4110: my @communityforma;
1.351 ehlerst 4111: my $newfolderform;
1.390 tempelho 4112: my $newfolderb;
1.342 ehlerst 4113:
1.451 www 4114: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 4115:
1.329 droeschl 4116: my $newpageform=(<<NPFORM);
4117: <form action="/adm/coursedocs" method="post" name="newpage">
4118: <input type="hidden" name="folderpath" value="$path" />
4119: <input type="hidden" name="importdetail" value="" />
1.371 tempelho 4120: <input type="hidden" name="active" value="cc" />
1.423 onken 4121: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 4122: $help{'Adding_Pages'}
1.329 droeschl 4123: </form>
4124: NPFORM
1.390 tempelho 4125:
4126:
1.351 ehlerst 4127: $newfolderform=(<<NFFORM);
1.329 droeschl 4128: <form action="/adm/coursedocs" method="post" name="newfolder">
1.484.2.19 raeburn 4129: $pathitem
1.329 droeschl 4130: <input type="hidden" name="importdetail" value="" />
1.371 tempelho 4131: <input type="hidden" name="active" value="aa" />
1.422 onken 4132: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 4133: </form>
4134: NFFORM
4135:
4136: my $newsylform=(<<NSYLFORM);
4137: <form action="/adm/coursedocs" method="post" name="newsyl">
1.371 tempelho 4138: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4139: $pathitem
1.329 droeschl 4140: <input type="hidden" name="importdetail"
4141: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 4142: <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 4143: $help{'Syllabus'}
1.383 tempelho 4144:
1.329 droeschl 4145: </form>
4146: NSYLFORM
1.364 bisitz 4147:
1.329 droeschl 4148: my $newgroupfileform=(<<NGFFORM);
4149: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.371 tempelho 4150: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4151: $pathitem
1.329 droeschl 4152: <input type="hidden" name="importdetail"
4153: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.423 onken 4154: <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
1.353 weissno 4155: $help{'Group Portfolio'}
1.329 droeschl 4156: </form>
4157: NGFFORM
1.383 tempelho 4158: @specialdocumentsforma=(
1.421 onken 4159: {'<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 4160: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
1.451 www 4161: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
4162: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.484.2.27! raeburn 4163: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.451 www 4164: );
4165: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
4166:
1.434 raeburn 4167:
4168: my @importdoc = (
1.484.2.19 raeburn 4169: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
4170: );
4171: unless ($container eq 'page') {
4172: push(@importdoc,
4173: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
4174: );
4175: }
4176: push(@importdoc,
4177: {'<img class="LC_noBorder_LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform}
4178: );
1.484.2.12 raeburn 4179: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 4180:
1.451 www 4181: @gradingforma=(
4182: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
4183: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
4184: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
4185:
4186: );
4187: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
4188:
4189: @communityforma=(
4190: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
4191: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
4192: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
4193: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},
4194: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
4195: );
4196: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 4197:
1.330 tempelho 4198: my %orderhash = (
1.484.2.7 raeburn 4199: 'aa' => ['Import Content',$fileuploadform],
1.484.2.13 raeburn 4200: 'bb' => ['Published Content',$importpubform],
1.451 www 4201: 'cc' => ['Grading Resources',$gradingform],
1.330 tempelho 4202: );
1.484.2.19 raeburn 4203: unless ($container eq 'page') {
1.434 raeburn 4204: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 4205: $orderhash{'dd'} = ['Collaboration',$communityform];
1.484.2.19 raeburn 4206: $orderhash{'ee'} = ['Special Pages',$specialdocumentsform];
1.434 raeburn 4207: }
4208:
1.341 ehlerst 4209: $hadchanges=0;
1.484 raeburn 4210: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 4211: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.17 raeburn 4212: $supplementalflag,\%orderhash,$iconpath,$pathitem);
1.443 www 4213: if ($error) {
4214: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
4215: }
4216: if ($hadchanges) {
4217: &mark_hash_old();
4218: }
1.341 ehlerst 4219:
1.443 www 4220: &changewarning($r,'');
4221: }
1.458 raeburn 4222: }
1.442 www 4223:
1.443 www 4224: # Supplemental documents start here
4225:
1.329 droeschl 4226: my $folder=$env{'form.folder'};
1.443 www 4227: unless ($supplementalflag) {
1.329 droeschl 4228: $folder='supplemental';
4229: }
4230: if ($folder =~ /^supplemental$/ &&
4231: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 4232: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 4233: } elsif ($allowed) {
1.356 tempelho 4234: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 4235: }
1.484.2.17 raeburn 4236: $pathitem = '<input type="hidden" name="folderpath" value="'.
4237: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 4238: if ($allowed) {
4239: my $folderseq=
1.484.2.15 raeburn 4240: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 4241:
4242: my $supupdocform=(<<SUPDOCFORM);
1.484.2.12 raeburn 4243: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
4244: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 4245: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.484.2.19 raeburn 4246: <fieldset id="uploadsuppdocform" style="display: none;">
1.484.2.12 raeburn 4247: <legend>$lt{'upfi'}</legend>
1.371 tempelho 4248: <input type="hidden" name="active" value="ee" />
1.329 droeschl 4249: $fileupload
4250: <br />
4251: <br />
4252: <span class="LC_nobreak">
4253: $checkbox
4254: </span>
4255: <br /><br />
4256: $lt{'comment'}:<br />
1.383 tempelho 4257: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 4258: <br />
1.484.2.19 raeburn 4259: $pathitem
1.329 droeschl 4260: <input type="hidden" name="cmd" value="upload_supplemental" />
1.484.2.12 raeburn 4261: <input type='submit' value="$lt{'upld'}" />
4262: </form>
1.484.2.19 raeburn 4263: SUPDOCFORM
1.329 droeschl 4264:
4265: my $supnewfolderform=(<<SNFFORM);
4266: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.371 tempelho 4267: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 4268: $pathitem
1.329 droeschl 4269: <input type="hidden" name="importdetail" value="" />
1.423 onken 4270: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 4271: $help{'Adding_Folders'}
1.329 droeschl 4272: </form>
4273: SNFFORM
1.383 tempelho 4274:
1.484.2.19 raeburn 4275: my $supextform =
4276: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
4277: $help{'Adding_External_Resource'});
1.329 droeschl 4278:
4279: my $supnewsylform=(<<SNSFORM);
4280: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 4281: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 4282: $pathitem
1.329 droeschl 4283: <input type="hidden" name="importdetail"
4284: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 4285: <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 4286: $help{'Syllabus'}
4287: </form>
4288: SNSFORM
4289:
4290: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 4291: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 4292: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 4293: $pathitem
1.329 droeschl 4294: <input type="hidden" name="importdetail"
4295: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 4296: <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 4297: $help{'My Personal Information Page'}
1.329 droeschl 4298: </form>
4299: SNAMFORM
4300:
1.484.2.27! raeburn 4301: my $supwebpage;
! 4302: if ($folder =~ /^supplemental_?(\d*)$/) {
! 4303: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
! 4304: if ($1) {
! 4305: $supwebpage .= $1;
! 4306: } else {
! 4307: $supwebpage .= 'default';
! 4308: }
! 4309: $supwebpage .= '/new.html';
! 4310: }
! 4311: my $supwebpageform =(<<SWEBFORM);
! 4312: <form action="/adm/coursedocs" method="post" name="supwebpage">
! 4313: <input type="hidden" name="active" value="cc" />
! 4314: $pathitem
! 4315: <input type="hidden" name="importdetail" value="$supwebpage" />
! 4316: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
! 4317: $help{'Web Page'}
! 4318: </form>
! 4319: SWEBFORM
! 4320:
1.333 muellerd 4321:
1.383 tempelho 4322: my @specialdocs = (
1.417 droeschl 4323: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
4324: =>$supnewsylform},
4325: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
4326: =>$supnewaboutmeform},
1.484.2.27! raeburn 4327: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
! 4328:
1.383 tempelho 4329: );
1.417 droeschl 4330: my @supimportdoc = (
1.484.2.19 raeburn 4331: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />'
1.484.2.12 raeburn 4332: =>$supextform},
4333: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
4334: =>$supupdocform},
1.484.2.19 raeburn 4335: );
4336:
1.484.2.12 raeburn 4337: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 4338: my %suporderhash = (
1.390 tempelho 4339: '00' => ['Supnewfolder', $supnewfolderform],
1.484.2.7 raeburn 4340: 'ee' => ['Import Content',$supupdocform],
1.484.2.19 raeburn 4341: 'ff' => ['Special Pages',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 4342: );
1.443 www 4343: if ($supplementalflag) {
1.458 raeburn 4344: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.17 raeburn 4345: $supplementalflag,\%suporderhash,$iconpath,$pathitem);
1.443 www 4346: if ($error) {
4347: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
4348: }
1.393 raeburn 4349: }
1.443 www 4350: } elsif ($supplementalflag) {
1.458 raeburn 4351: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.17 raeburn 4352: $supplementalflag,'',$iconpath,$pathitem);
1.393 raeburn 4353: if ($error) {
4354: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 4355: }
1.393 raeburn 4356: }
1.389 tempelho 4357:
1.484.2.19 raeburn 4358: if ($needs_end) {
4359: $r->print(&endContentScreen());
4360: }
1.383 tempelho 4361:
1.329 droeschl 4362: if ($allowed) {
4363: $r->print('
4364: <form method="post" name="extimport" action="/adm/coursedocs">
4365: <input type="hidden" name="title" />
4366: <input type="hidden" name="url" />
4367: <input type="hidden" name="useform" />
4368: <input type="hidden" name="residx" />
4369: </form>');
4370: }
1.484 raeburn 4371: } elsif ($showdoc) {
1.329 droeschl 4372: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 4373: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.484.2.10 raeburn 4374: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 4375: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 4376: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 4377: }
4378: }
4379: $r->print(&Apache::loncommon::end_page());
4380: return OK;
1.364 bisitz 4381: }
1.329 droeschl 4382:
1.440 raeburn 4383: sub embedded_form_elems {
4384: my ($phase,$primaryurl,$newidx) = @_;
4385: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
4386: return <<STATE;
4387: <input type="hidden" name="folderpath" value="$folderpath" />
4388: <input type="hidden" name="cmd" value="upload_embedded" />
4389: <input type="hidden" name="newidx" value="$newidx" />
4390: <input type="hidden" name="phase" value="$phase" />
4391: <input type="hidden" name="primaryurl" value="$primaryurl" />
4392: STATE
4393: }
4394:
4395: sub embedded_destination {
4396: my $folder=$env{'form.folder'};
4397: my $destination = 'docs/';
4398: if ($folder =~ /^supplemental/) {
4399: $destination = 'supplemental/';
4400: }
4401: if (($folder eq 'default') || ($folder eq 'supplemental')) {
4402: $destination .= 'default/';
4403: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
4404: $destination .= $2.'/';
4405: }
4406: $destination .= $env{'form.newidx'};
4407: my $dir_root = '/userfiles';
4408: return ($destination,$dir_root);
4409: }
4410:
4411: sub return_to_editor {
4412: my $actionurl = '/adm/coursedocs';
4413: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
4414: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
4415: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
4416: '</a></p>';
4417: }
4418:
1.476 raeburn 4419: sub decompression_info {
4420: my ($destination,$dir_root) = &embedded_destination();
4421: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
4422: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4423: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
4424: my $container='sequence';
1.480 raeburn 4425: my ($pathitem,$hiddenelem);
1.484.2.19 raeburn 4426: my @hiddens = ('newidx','comment','position','folderpath');
4427: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 4428: $container='page';
4429: }
1.480 raeburn 4430: unshift(@hiddens,$pathitem);
4431: foreach my $item (@hiddens) {
4432: if ($env{'form.'.$item}) {
4433: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
4434: $env{'form.'.$item}.'" />'."\n";
4435: }
1.477 raeburn 4436: }
1.476 raeburn 4437: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
4438: $hiddenelem);
4439: }
4440:
4441: sub decompression_phase_one {
4442: my ($dir,$file,$warning,$error,$output);
4443: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
4444: &decompression_info();
1.484.2.7 raeburn 4445: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 4446: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
4447: } else {
4448: my $file = $1;
1.481 raeburn 4449: $output =
4450: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
4451: $destination,$dir_root,
4452: $hiddenelem);
4453: if ($env{'form.autoextract_camtasia'}) {
4454: $output .= &remove_archive($docudom,$docuname,$container);
4455: }
1.476 raeburn 4456: }
4457: if ($error) {
4458: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
4459: $error.'</p>'."\n";
4460: }
4461: if ($warning) {
4462: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
4463: }
4464: return $output;
4465: }
4466:
4467: sub decompression_phase_two {
4468: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
4469: &decompression_info();
1.481 raeburn 4470: my $output;
1.480 raeburn 4471: if ($env{'form.archivedelete'}) {
1.481 raeburn 4472: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 4473: }
4474: $output .=
1.481 raeburn 4475: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 4476: $destination,$dir_root,$hiddenelem);
4477: return $output;
4478: }
4479:
1.480 raeburn 4480: sub remove_archive {
4481: my ($docudom,$docuname,$container) = @_;
4482: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 4483: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 4484: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
4485: if ($fatal) {
4486: if ($container eq 'page') {
4487: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
4488: } else {
4489: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
4490: }
4491: $delwarning .= &mt('As a result the archive file has not been removed.');
4492: } else {
4493: my $currcmd = $env{'form.cmd'};
4494: my $position = $env{'form.position'};
4495: if ($position > 0) {
4496: $env{'form.cmd'} = 'del_'.$position;
4497: my ($title,$url,@rrest) =
4498: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);
4499: if (&handle_edit_cmd($docuname,$docudom)) {
1.484.2.7 raeburn 4500: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
1.480 raeburn 4501: if ($fatal) {
4502: if ($container eq 'page') {
4503: $delwarning = &mt('An error occurred updating the contents of the current page.');
4504: } else {
4505: $delwarning = &mt('An error occurred updating the contents of the current folder.');
4506: }
4507: } else {
1.481 raeburn 4508: $delresult = &mt('Archive file removed.');
1.480 raeburn 4509: }
4510: }
4511: }
4512: $env{'form.cmd'} = $currcmd;
4513: }
4514: if ($delwarning) {
4515: $output = '<p class="LC_warning">'.
4516: $delwarning.
4517: '</p>';
4518: }
4519: if ($delresult) {
4520: $output .= '<p class="LC_info">'.
4521: $delresult.
4522: '</p>';
4523: }
1.481 raeburn 4524: return $output;
1.480 raeburn 4525: }
4526:
1.484 raeburn 4527: sub generate_admin_menu {
4528: my ($crstype) = @_;
4529: my $lc_crstype = lc($crstype);
4530: my ($home,$other,%outhash)=&authorhosts();
4531: my %lt=&Apache::lonlocal::texthash (
4532: 'vc' => 'Verify Content',
4533: 'cv' => 'Check/Set Resource Versions',
4534: 'ls' => 'List Resource Identifiers',
4535: 'imse' => 'Export contents to IMS Archive',
4536: 'dcd' => "Dump $crstype Content to Authoring Space",
4537: );
4538: my ($candump,$dumpurl);
4539: if ($home + $other > 0) {
4540: $candump = 'F';
4541: if ($home) {
4542: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
4543: } else {
4544: my @hosts;
4545: foreach my $aurole (keys(%outhash)) {
4546: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
4547: push(@hosts,$outhash{$aurole});
4548: }
4549: }
4550: if (@hosts == 1) {
4551: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
4552: '&role='.
4553: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
4554: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
4555: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
4556: } else {
4557: $dumpurl = "javascript:choose_switchserver_window()";
4558: }
4559: }
4560: }
4561: my @menu=
4562: ({ categorytitle=>'Administration',
4563: items =>[
4564: { linktext => $lt{'vc'},
4565: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
4566: permission => 'F',
4567: help => 'Verify_Content',
4568: icon => 'verify.png',
4569: linktitle => 'Verify contents can be retrieved/rendered',
4570: },
4571: { linktext => $lt{'cv'},
4572: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
4573: permission => 'F',
4574: help => 'Check_Resource_Versions',
4575: icon => 'resversion.png',
4576: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
4577: },
4578: { linktext => $lt{'ls'},
4579: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
4580: permission => 'F',
4581: #help => '',
4582: icon => 'symbs.png',
4583: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
4584: },
4585: ]
4586: },
4587: { categorytitle=>'Export',
4588: items =>[
4589: { linktext => $lt{'imse'},
4590: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
4591: permission => 'F',
4592: help => 'Docs_Export_Course_Docs',
4593: icon => 'imsexport.png',
4594: linktitle => $lt{'imse'},
4595: },
4596: { linktext => $lt{'dcd'},
4597: url => $dumpurl,
4598: permission => $candump,
4599: #help => '',
4600: icon => 'dump.png',
4601: linktitle => $lt{'dcd'},
4602: },
4603: ]
4604: });
4605: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
4606: '<input type="hidden" id="dummy" />'."\n".
4607: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
4608: '</form>';
1.329 droeschl 4609: }
4610:
4611: sub generate_edit_table {
1.484 raeburn 4612: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile) = @_;
1.406 raeburn 4613: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 4614: my %orderhash = %{$orderhash_ref};
1.344 bisitz 4615: my $form;
1.371 tempelho 4616: my $activetab;
4617: my $active;
1.484.2.20 raeburn 4618: if (($env{'form.active'} ne '') && ($env{'form.active'} ne 'aa')) {
1.371 tempelho 4619: $activetab = $env{'form.active'};
4620: }
1.472 raeburn 4621: my $backicon = $iconpath.'clickhere.gif';
1.484.2.21 raeburn 4622: my $backtext = &mt('Exit Editor');
1.458 raeburn 4623: $form = '<div class="LC_Box" style="margin:0;">'.
1.484.2.19 raeburn 4624: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
4625: '<li class="goback">'.
1.484.2.21 raeburn 4626: '<a href="javascript:toContents('.$jumpto.');">'.
1.484.2.19 raeburn 4627: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
4628: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
4629: '<li>'.
4630: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
4631: &mt('Undo Delete').'</a></li>'."\n";
1.484.2.7 raeburn 4632: if ($env{'form.docslog'}) {
4633: $form .= '<li class="active">';
4634: } else {
4635: $form .= '<li>';
4636: }
4637: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
4638: &mt('History').'</a></li>'."\n";
4639: if ($env{'form.docslog'}) {
4640: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
4641: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 4642: }
1.458 raeburn 4643: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 4644: if($name ne '00'){
1.371 tempelho 4645: if($activetab eq '' || $activetab ne $name){
4646: $active = '';
4647: }elsif($activetab eq $name){
4648: $active = 'class="active"';
4649: }
1.458 raeburn 4650: $form .= '<li style="float:right" '.$active
1.484 raeburn 4651: .' 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 4652: } else {
1.484 raeburn 4653: $form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 4654:
4655: }
1.329 droeschl 4656: }
1.484 raeburn 4657: $form .= '</ul>'."\n";
4658: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 4659:
4660: if ($to_show ne '') {
1.484 raeburn 4661: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'."\n";
1.458 raeburn 4662: }
1.363 ehlerst 4663: foreach my $field (keys(%orderhash)){
1.390 tempelho 4664: if($field ne '00'){
1.422 onken 4665: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 4666: $active = 'style="display: none;float:left"';
1.422 onken 4667: }elsif($activetab eq $field){
1.458 raeburn 4668: $active = 'style="display:block;float:left"';
1.422 onken 4669: }
4670: $form .= '<div id="'.$field.$tid.'"'
4671: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 4672: .'</div>'."\n";
1.363 ehlerst 4673: }
4674: }
1.484 raeburn 4675: unless ($env{'form.docslog'}) {
4676: $form .= '</div></div>'."\n";
4677: }
1.329 droeschl 4678: return $form;
4679: }
4680:
4681: sub editing_js {
1.472 raeburn 4682: my ($udom,$uname,$supplementalflag) = @_;
1.329 droeschl 4683: my %lt = &Apache::lonlocal::texthash(
4684: p_mnf => 'Name of New Folder',
4685: t_mnf => 'New Folder',
4686: p_mnp => 'Name of New Page',
4687: t_mnp => 'New Page',
1.451 www 4688: p_mxu => 'Title for the External Score',
1.349 biermanm 4689: p_msp => 'Name of Simple Course Page',
1.329 droeschl 4690: p_msb => 'Title for the Problem',
4691: p_mdb => 'Title for the Drop Box',
1.336 schafran 4692: p_mbb => 'Title for the Discussion Board',
1.484.2.27! raeburn 4693: p_mwp => 'Title for Web Page',
1.348 weissno 4694: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 4695: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 4696: p_mab_alrt1 => 'Not a valid user:domain',
4697: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
4698: p_chn => 'New Title',
4699: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
4700: p_rmr2a => 'Remove[_99]',
4701: p_rmr2b => '?[_99]',
4702: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
4703: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
4704: p_ctr2a => 'Cut[_98]',
1.478 raeburn 4705: p_ctr2b => '?[_98]',
4706: rpck => 'Enter number to pick (e.g., 3)',
1.484.2.12 raeburn 4707: imsfile => 'You must choose an IMS package for import',
4708: imscms => 'You must select which Course Management System was the source of the IMS package',
4709: invurl => 'Invalid URL',
4710: titbl => 'Title is blank',
1.329 droeschl 4711: );
4712:
1.433 raeburn 4713: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 4714: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
4715: my $main_container_page;
1.484.2.19 raeburn 4716: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
4717: $main_container_page = 1;
1.434 raeburn 4718: }
1.484.2.19 raeburn 4719: my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents%3A%3A%3A%3A%3A';
1.446 www 4720: my $toplevelsupp = &supplemental_base();
1.433 raeburn 4721:
1.484.2.21 raeburn 4722: my $backtourl;
4723: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
4724: my $caller = $1;
4725: if ($caller =~ /^supplemental/) {
4726: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
4727: } else {
4728: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
4729: $res = &Apache::lonnet::clutter($res);
4730: if (&Apache::lonnet::is_on_map($res)) {
4731: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='.
4732: &HTML::Entities::encode($caller,'<>&"');
4733: }
4734: }
4735: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
4736: $backtourl = '/adm/menu';
4737: } elsif ($supplementalflag) {
1.472 raeburn 4738: $backtourl = '/adm/supplemental';
1.484.2.21 raeburn 4739: } else {
4740: $backtourl = '/adm/navmaps';
1.472 raeburn 4741: }
4742:
1.484.2.19 raeburn 4743: my $fieldsets = "'ext','doc'";
4744: unless ($main_container_page) {
4745: $fieldsets .=",'ims'";
4746: }
1.484.2.12 raeburn 4747: if ($supplementalflag) {
4748: $fieldsets = "'suppext','suppdoc'";
4749: }
4750:
1.329 droeschl 4751: return <<ENDNEWSCRIPT;
4752: function makenewfolder(targetform,folderseq) {
4753: var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
4754: if (foldername) {
4755: targetform.importdetail.value=escape(foldername)+"="+folderseq;
4756: targetform.submit();
4757: }
4758: }
4759:
4760: function makenewpage(targetform,folderseq) {
4761: var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
4762: if (pagename) {
4763: targetform.importdetail.value=escape(pagename)+"="+folderseq;
4764: targetform.submit();
4765: }
4766: }
4767:
4768: function makeexamupload() {
4769: var title=prompt('$lt{"p_mxu"}');
1.344 bisitz 4770: if (title) {
1.329 droeschl 4771: this.document.forms.newexamupload.importdetail.value=
4772: escape(title)+'=/res/lib/templates/examupload.problem';
4773: this.document.forms.newexamupload.submit();
4774: }
4775: }
4776:
4777: function makesmppage() {
4778: var title=prompt('$lt{"p_msp"}');
1.344 bisitz 4779: if (title) {
1.329 droeschl 4780: this.document.forms.newsmppg.importdetail.value=
1.484.2.26 raeburn 4781: escape(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 4782: this.document.forms.newsmppg.submit();
4783: }
4784: }
4785:
1.484.2.27! raeburn 4786: function makewebpage(type) {
! 4787: var title=prompt('$lt{"p_mwp"}');
! 4788: var formname;
! 4789: if (type == 'supp') {
! 4790: formname = this.document.forms.supwebpage;
! 4791: } else {
! 4792: formname = this.document.forms.newwebpage;
! 4793: }
! 4794: if (title) {
! 4795: var webpage = formname.importdetail.value;
! 4796: formname.importdetail.value = escape(title)+'='+webpage;
! 4797: formname.submit();
! 4798: }
! 4799: }
! 4800:
1.329 droeschl 4801: function makesmpproblem() {
4802: var title=prompt('$lt{"p_msb"}');
1.344 bisitz 4803: if (title) {
1.329 droeschl 4804: this.document.forms.newsmpproblem.importdetail.value=
4805: escape(title)+'=/res/lib/templates/simpleproblem.problem';
4806: this.document.forms.newsmpproblem.submit();
4807: }
4808: }
4809:
4810: function makedropbox() {
4811: var title=prompt('$lt{"p_mdb"}');
1.344 bisitz 4812: if (title) {
1.329 droeschl 4813: this.document.forms.newdropbox.importdetail.value=
4814: escape(title)+'=/res/lib/templates/DropBox.problem';
4815: this.document.forms.newdropbox.submit();
4816: }
4817: }
4818:
4819: function makebulboard() {
4820: var title=prompt('$lt{"p_mbb"}');
4821: if (title) {
4822: this.document.forms.newbul.importdetail.value=
1.484.2.26 raeburn 4823: escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 4824: this.document.forms.newbul.submit();
4825: }
4826: }
4827:
4828: function makeabout() {
4829: var user=prompt("$lt{'p_mab'}");
4830: if (user) {
4831: var comp=new Array();
4832: comp=user.split(':');
4833: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
4834: if ((comp[0]) && (comp[1])) {
4835: this.document.forms.newaboutsomeone.importdetail.value=
4836: '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.335 ehlerst 4837: this.document.forms.newaboutsomeone.submit();
4838: } else {
4839: alert("$lt{'p_mab_alrt1'}");
1.329 droeschl 4840: }
1.335 ehlerst 4841: } else {
4842: alert("$lt{'p_mab_alrt2'}");
4843: }
4844: }
1.329 droeschl 4845: }
4846:
1.484.2.13 raeburn 4847: function toggleUpload(caller) {
4848: var blocks = Array($fieldsets);
4849: for (var i=0; i<blocks.length; i++) {
4850: var disp = 'none';
4851: if (caller == blocks[i]) {
4852: var curr = document.getElementById('upload'+caller+'form').style.display;
4853: if (curr == 'none') {
4854: disp='block';
4855: }
4856: }
4857: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
4858: }
4859: resize_scrollbox('contentscroll','1','1');
4860: return;
4861: }
4862:
1.484.2.19 raeburn 4863: function toggleMap(caller) {
1.484.2.13 raeburn 4864: var disp = 'none';
1.484.2.19 raeburn 4865: if (document.getElementById('importmapform')) {
4866: if (caller == 'map') {
4867: var curr = document.getElementById('importmapform').style.display;
4868: if (curr == 'none') {
4869: disp='block';
4870: }
1.484.2.12 raeburn 4871: }
1.484.2.19 raeburn 4872: document.getElementById('importmapform').style.display=disp;
4873: resize_scrollbox('contentscroll','1','1');
1.484.2.12 raeburn 4874: }
1.484.2.19 raeburn 4875: return;
1.329 droeschl 4876: }
4877:
1.484.2.12 raeburn 4878: function makeims(imsform) {
4879: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
4880: alert("$lt{'imsfile'}");
4881: return;
4882: }
4883: if (imsform.source.selectedIndex == 0) {
4884: alert("$lt{'imscms'}");
4885: return;
4886: }
4887: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
4888: imsform.submit();
4889: }
4890:
1.484.2.19 raeburn 4891: function changename(folderpath,index,oldtitle) {
1.335 ehlerst 4892: var title=prompt('$lt{"p_chn"}',oldtitle);
4893: if (title) {
4894: this.document.forms.renameform.markcopy.value=-1;
4895: this.document.forms.renameform.title.value=title;
4896: this.document.forms.renameform.cmd.value='rename_'+index;
1.484.2.19 raeburn 4897: this.document.forms.renameform.folderpath.value=folderpath;
1.335 ehlerst 4898: this.document.forms.renameform.submit();
4899: }
1.329 droeschl 4900: }
4901:
1.484.2.19 raeburn 4902: function removeres(folderpath,index,oldtitle,skip_confirm) {
1.335 ehlerst 4903: if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
4904: this.document.forms.renameform.markcopy.value=-1;
4905: this.document.forms.renameform.cmd.value='del_'+index;
1.484.2.19 raeburn 4906: this.document.forms.renameform.folderpath.value=folderpath;
1.335 ehlerst 4907: this.document.forms.renameform.submit();
4908: }
1.329 droeschl 4909: }
4910:
1.484.2.19 raeburn 4911: function cutres(folderpath,index,oldtitle,container,folder,skip_confirm) {
1.335 ehlerst 4912: if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
4913: this.document.forms.renameform.cmd.value='cut_'+index;
4914: this.document.forms.renameform.markcopy.value=index;
4915: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
1.484.2.19 raeburn 4916: this.document.forms.renameform.folderpath.value=folderpath;
1.335 ehlerst 4917: this.document.forms.renameform.submit();
4918: }
1.329 droeschl 4919: }
4920:
1.484.2.19 raeburn 4921: function markcopy(folderpath,index,oldtitle,container,folder) {
1.335 ehlerst 4922: this.document.forms.renameform.markcopy.value=index;
4923: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
4924: this.document.forms.renameform.folderpath.value=folderpath;
4925: this.document.forms.renameform.submit();
1.329 droeschl 4926: }
4927:
1.478 raeburn 4928: function updatePick(targetform,index,caller) {
4929: var pickitem = document.getElementById('rpick_'+index);
4930: var picknumitem = document.getElementById('rpicknum_'+index);
4931: if (pickitem.checked) {
4932: var picknum=prompt('$lt{"rpck"}',picknumitem.value);
4933: if (picknum == '' || picknum == null) {
4934: if (caller == 'check') {
4935: pickitem.checked=false;
4936: return;
4937: }
4938: } else {
4939: picknum.toString();
4940: var regexdigit=/^\\d+\$/;
4941: if (regexdigit.test(picknum)) {
4942: picknumitem.value = picknum;
4943: targetform.changeparms.value='randompick';
4944: targetform.submit();
4945: } else {
4946: if (caller == 'check') {
4947: pickitem.checked=false;
4948: }
4949: return;
4950: }
4951: }
4952: } else {
4953: picknumitem.value = 0;
4954: targetform.changeparms.value='randompick';
4955: targetform.submit();
4956: }
4957: }
4958:
1.334 muellerd 4959: function unselectInactive(nav) {
1.335 ehlerst 4960: currentNav = document.getElementById(nav);
4961: currentLis = currentNav.getElementsByTagName('LI');
4962: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 4963: if (currentLis[i].className == 'goback') {
4964: currentLis[i].className = 'goback';
4965: } else {
4966: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 4967: currentLis[i].className = 'right';
1.472 raeburn 4968: } else {
1.374 tempelho 4969: currentLis[i].className = 'i';
1.472 raeburn 4970: }
4971: }
1.335 ehlerst 4972: }
1.332 tempelho 4973: }
4974:
1.334 muellerd 4975: function hideAll(current, nav, data) {
1.335 ehlerst 4976: unselectInactive(nav);
1.374 tempelho 4977: if(current.className == 'right'){
4978: current.className = 'right active'
4979: }else{
4980: current.className = 'active';
4981: }
1.335 ehlerst 4982: currentData = document.getElementById(data);
4983: currentDivs = currentData.getElementsByTagName('DIV');
4984: for (i = 0; i < currentDivs.length; i++) {
4985: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 4986: currentDivs[i].style.display = 'none';
1.330 tempelho 4987: }
4988: }
1.335 ehlerst 4989: }
1.330 tempelho 4990:
1.374 tempelho 4991: function openTabs(pageId) {
4992: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 4993: if(tabnav.length > 2 ){
1.389 tempelho 4994: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 4995: currentLis = currentNav.getElementsByTagName('LI');
4996: for(i = 0; i< currentLis.length; i++){
4997: if(currentLis[i].className == 'active') {
1.375 tempelho 4998: funcString = currentLis[i].onclick.toString();
4999: tab = funcString.split('"');
1.420 onken 5000: if(tab.length < 2) {
5001: tab = funcString.split("'");
5002: }
1.375 tempelho 5003: currentData = document.getElementById(tab[1]);
5004: currentData.style.display = 'block';
1.374 tempelho 5005: }
5006: }
5007: }
5008: }
5009:
1.334 muellerd 5010: function showPage(current, pageId, nav, data) {
5011: hideAll(current, nav, data);
1.375 tempelho 5012: openTabs(pageId);
1.334 muellerd 5013: unselectInactive(nav);
1.330 tempelho 5014: current.className = 'active';
5015: currentData = document.getElementById(pageId);
5016: currentData.style.display = 'block';
1.458 raeburn 5017: activeTab = pageId;
1.484.2.12 raeburn 5018: toggleUpload();
1.484.2.14 raeburn 5019: toggleMap();
1.433 raeburn 5020: if (nav == 'mainnav') {
5021: var storedpath = "$docs_folderpath";
1.434 raeburn 5022: var storedpage = "$main_container_page";
1.433 raeburn 5023: var reg = new RegExp("^supplemental");
5024: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 5025: if (storedpage == 1) {
5026: document.simpleedit.folderpath.value = '';
5027: document.uploaddocument.folderpath.value = '';
5028: } else {
5029: if (reg.test(storedpath)) {
5030: document.simpleedit.folderpath.value = '$toplevelmain';
5031: document.uploaddocument.folderpath.value = '$toplevelmain';
5032: document.newext.folderpath.value = '$toplevelmain';
5033: } else {
5034: document.simpleedit.folderpath.value = storedpath;
5035: document.uploaddocument.folderpath.value = storedpath;
5036: document.newext.folderpath.value = storedpath;
5037: }
1.433 raeburn 5038: }
5039: } else {
1.434 raeburn 5040: if (reg.test(storedpath)) {
5041: document.simpleedit.folderpath.value = storedpath;
5042: document.supuploaddocument.folderpath.value = storedpath;
5043: document.supnewext.folderpath.value = storedpath;
5044: } else {
1.433 raeburn 5045: document.simpleedit.folderpath.value = '$toplevelsupp';
5046: document.supuploaddocument.folderpath.value = '$toplevelsupp';
5047: document.supnewext.folderpath.value = '$toplevelsupp';
5048: }
5049: }
5050: }
1.484.2.3 raeburn 5051: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 5052: return false;
5053: }
1.329 droeschl 5054:
1.472 raeburn 5055: function toContents(jumpto) {
5056: var newurl = '$backtourl';
1.484.2.21 raeburn 5057: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 5058: newurl = newurl+'?postdata='+jumpto;
5059: }
5060: location.href=newurl;
5061: }
5062:
1.329 droeschl 5063: ENDNEWSCRIPT
5064: }
1.457 raeburn 5065:
1.483 raeburn 5066: sub history_tab_js {
5067: return <<"ENDHIST";
5068: function toggleHistoryDisp(choice) {
5069: document.docslogform.docslog.value = choice;
5070: document.docslogform.submit();
5071: return;
5072: }
5073:
5074: ENDHIST
5075: }
5076:
1.484 raeburn 5077: sub inject_data_js {
5078: return <<ENDINJECT;
5079:
5080: function injectData(current, hiddenField, name, value) {
5081: currentElement = document.getElementById(hiddenField);
5082: currentElement.name = name;
5083: currentElement.value = value;
5084: current.submit();
5085: }
5086:
5087: ENDINJECT
5088: }
5089:
5090: sub dump_switchserver_js {
5091: my @hosts = @_;
5092: my %lt = &Apache::lonlocal::texthash(
5093: dump => 'Dumping to Authoring Space requires switching server.',
5094: swit => 'Switch server?',
5095: duco => 'Dump content to Authoring Space',
5096: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
5097: chos => 'Choose server',
5098: );
5099: my $role = $env{'request.role'};
5100: my $js = <<"ENDSWJS";
5101: <script type="text/javascript">
5102: function write_switchserver() {
5103: var server;
5104: if (document.setserver.posshosts.length > 0) {
5105: for (var i=0; i<document.setserver.posshosts.length; i++) {
5106: if (document.setserver.posshosts[i].checked) {
5107: server = document.setserver.posshosts[i].value;
5108: }
5109: }
5110: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
5111: }
5112: window.close();
5113: }
5114: </script>
5115:
5116: ENDSWJS
5117:
5118: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
5119: {'only_body' => 1,
5120: 'js_ready' => 1,});
5121: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
5122:
5123: my $hostpicker;
5124: my $count = 0;
5125: foreach my $host (sort(@hosts)) {
5126: my $checked;
5127: if ($count == 0) {
5128: $checked = ' checked="checked"';
5129: }
5130: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
5131: $host.'"'.$checked.' />'.$host.'</label> ';
5132: $count++;
5133: }
5134:
5135: return <<"ENDSWITCHJS";
5136:
5137: function dump_needs_switchserver(url) {
5138: if (url!='' && url!= null) {
5139: if (confirm("$lt{'dump'}\\n$lt{'swit'}")) {
5140: go(url);
5141: }
5142: }
5143: return;
5144: }
5145:
5146: function choose_switchserver_window() {
5147: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
5148: newWindow.document.open();
5149: newWindow.document.writeln('$startpage');
5150: newWindow.document.write('<h3>$lt{'duco'}<\\/h3>\\n'+
5151: '<p>$lt{'yone'}<\\/p>\\n'+
5152: '<div class="LC_left_float"><fieldset><legend>$lt{'chos'}<\\/legend>\\n'+
5153: '<form name="setserver" method="post" action="" \\/>\\n'+
5154: '$hostpicker\\n'+
5155: '<br \\/><br \\/>\\n'+
5156: '<input type="button" name="makeswitch" value="$lt{'swit'}" '+
5157: 'onclick="write_switchserver();" \\/>\\n'+
5158: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
5159: newWindow.document.writeln('$endpage');
5160: newWindow.document.close();
5161: newWindow.focus();
5162: }
5163:
5164: ENDSWITCHJS
5165: }
5166:
5167: sub makedocslogform {
5168: my ($formelems,$docslog) = @_;
5169: return <<"LOGSFORM";
5170: <form action="/adm/coursedocs" method="post" name="docslogform">
5171: <input type="hidden" name="docslog" value="$docslog" />
5172: $formelems
5173: </form>
5174: LOGSFORM
5175: }
5176:
5177: sub makesimpleeditform {
5178: my ($formelems) = @_;
5179: return <<"SIMPFORM";
5180: <form name="simpleedit" method="post" action="/adm/coursedocs">
5181: <input type="hidden" name="importdetail" value="" />
5182: $formelems
5183: </form>
5184: SIMPFORM
5185: }
5186:
1.329 droeschl 5187: 1;
5188: __END__
5189:
5190:
5191: =head1 NAME
5192:
5193: Apache::londocs.pm
5194:
5195: =head1 SYNOPSIS
5196:
5197: This is part of the LearningOnline Network with CAPA project
5198: described at http://www.lon-capa.org.
5199:
5200: =head1 SUBROUTINES
5201:
5202: =over
5203:
5204: =item %help=()
5205:
5206: Available help topics
5207:
5208: =item mapread()
5209:
1.344 bisitz 5210: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 5211: @order and @resources, determines status
5212: sets @order - pointer to resources in right order
5213: sets @resources - array with the resources with correct idx
5214:
5215: =item authorhosts()
5216:
5217: Return hash with valid author names
5218:
5219: =item clean()
5220:
5221: =item dumpcourse()
5222:
5223: Actually dump course
5224:
5225: =item group_import()
5226:
5227: Imports the given (name, url) resources into the course
5228: coursenum, coursedom, and folder must precede the list
5229:
5230: =item breadcrumbs()
5231:
5232: =item log_docs()
5233:
5234: =item docs_change_log()
5235:
5236: =item update_paste_buffer()
5237:
5238: =item print_paste_buffer()
5239:
5240: =item do_paste_from_buffer()
5241:
1.484.2.7 raeburn 5242: =item get_newmap_url()
5243:
5244: =item dbcopy()
5245:
5246: =item uniqueness_check()
5247:
5248: =item contained_map_check()
5249:
5250: =item url_paste_fixups()
5251:
5252: =item apply_fixups()
5253:
5254: =item copy_dependencies()
5255:
1.329 droeschl 5256: =item update_parameter()
5257:
5258: =item handle_edit_cmd()
5259:
5260: =item editor()
5261:
5262: =item process_file_upload()
5263:
5264: =item process_secondary_uploads()
5265:
5266: =item is_supplemental_title()
5267:
5268: =item entryline()
5269:
5270: =item tiehash()
5271:
5272: =item untiehash()
5273:
5274: =item checkonthis()
5275:
5276: check on this
5277:
5278: =item verifycontent()
5279:
5280: Verify Content
5281:
5282: =item devalidateversioncache() & checkversions()
5283:
5284: Check Versions
5285:
5286: =item mark_hash_old()
5287:
5288: =item is_hash_old()
5289:
5290: =item changewarning()
5291:
5292: =item init_breadcrumbs()
5293:
5294: Breadcrumbs for special functions
5295:
1.484 raeburn 5296: =item create_list_elements()
5297:
5298: =item create_form_ul()
5299:
5300: =item startContentScreen()
5301:
5302: =item endContentScreen()
5303:
5304: =item supplemental_base()
5305:
5306: =item embedded_form_elems()
5307:
5308: =item embedded_destination()
5309:
5310: =item return_to_editor()
5311:
5312: =item decompression_info()
5313:
5314: =item decompression_phase_one()
5315:
5316: =item decompression_phase_two()
5317:
5318: =item remove_archive()
5319:
5320: =item generate_admin_menu()
5321:
5322: =item generate_edit_table()
5323:
5324: =item editing_js()
5325:
5326: =item history_tab_js()
5327:
5328: =item inject_data_js()
5329:
5330: =item dump_switchserver_js()
5331:
1.484.2.3 raeburn 5332: =item resize_scrollbox_js()
1.484 raeburn 5333:
5334: =item makedocslogform()
5335:
1.484.2.3 raeburn 5336: =item makesimpleeditform()
5337:
1.329 droeschl 5338: =back
5339:
5340: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>