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