File:
[LON-CAPA] /
loncom /
interface /
londocs.pm
Revision
1.479:
download - view:
text,
annotated -
select for diffs
Wed Mar 28 12:58:42 2012 UTC (12 years, 4 months ago) by
goltermann
Branches:
MAIN
CVS tags:
HEAD
ui redesign:
- confirm_success() to display save message
- reduced text on buttons to make them easier to recognize as buttons, put them in a fieldset
- rework of resource table, now using data table for easier reading and unified design
- if the used version of a resource is not equal to the current version in the course, it will now be red to be identified easier
- added a second save button at the end of the table
1: # The LearningOnline Network
2: # Documents
3: #
4: # $Id: londocs.pm,v 1.479 2012/03/28 12:58:42 goltermann Exp $
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;
36: use Apache::lonhtmlcommon;
37: use LONCAPA::map();
38: use Apache::lonratedt();
39: use Apache::lonxml;
40: use Apache::lonclonecourse;
41: use Apache::lonnavmaps;
42: use Apache::lonnavdisplay();
43: use HTML::Entities;
44: use GDBM_File;
45: use Apache::lonlocal;
46: use Cwd;
47: use LONCAPA qw(:DEFAULT :match);
48:
49: my $iconpath;
50:
51: my %hash;
52:
53: my $hashtied;
54: my %alreadyseen=();
55:
56: my $hadchanges;
57:
58:
59: my %help=();
60:
61:
62: sub mapread {
63: my ($coursenum,$coursedom,$map)=@_;
64: return
65: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
66: $map);
67: }
68:
69: sub storemap {
70: my ($coursenum,$coursedom,$map)=@_;
71: my ($outtext,$errtext)=
72: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
73: $map,1);
74: if ($errtext) { return ($errtext,2); }
75:
76: $hadchanges=1;
77: return ($errtext,0);
78: }
79:
80:
81:
82: sub authorhosts {
83: my %outhash=();
84: my $home=0;
85: my $other=0;
86: foreach my $key (keys(%env)) {
87: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
88: my $role=$1;
89: my $realm=$2;
90: my ($start,$end)=split(/\./,$env{$key});
91: if (($start) && ($start>time)) { next; }
92: if (($end) && (time>$end)) { next; }
93: my ($ca,$cd);
94: if ($1 eq 'au') {
95: $ca=$env{'user.name'};
96: $cd=$env{'user.domain'};
97: } else {
98: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
99: }
100: my $allowed=0;
101: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
102: my @ids=&Apache::lonnet::current_machine_ids();
103: foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } }
104: if ($allowed) {
105: $home++;
106: $outhash{'home_'.$ca.'@'.$cd}=1;
107: } else {
108: $outhash{'otherhome_'.$ca.'@'.$cd}=$myhome;
109: $other++;
110: }
111: }
112: }
113: return ($home,$other,%outhash);
114: }
115:
116:
117: sub dumpbutton {
118: my ($home,$other,%outhash)=&authorhosts();
119: my $crstype = &Apache::loncommon::course_type();
120: if ($home+$other==0) { return ''; }
121: if ($home) {
122: my $link =
123: "<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"dumpcourse\", \""
124: .&mt('Dump '.$crstype.' Documents to Construction Space')
125: ."\")'>"
126: .&mt('Dump '.$crstype.' Documents to Construction Space')
127: .'</a>';
128: return
129: $link.' '
130: .&Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs')
131: .'<br />';
132: } else {
133: return
134: &mt('Dump '.$crstype.' Documents to Construction Space: available on other servers');
135: }
136: }
137:
138: sub clean {
139: my ($title)=@_;
140: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
141: return $title;
142: }
143:
144:
145:
146: sub dumpcourse {
147: my ($r) = @_;
148: my $crstype = &Apache::loncommon::course_type();
149: $r->print(&Apache::loncommon::start_page('Dump '.$crstype.' Documents to Construction Space').
150: '<form name="dumpdoc" action="" method="post">');
151: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$crstype.' Documents to Construction Space'));
152: my ($home,$other,%outhash)=&authorhosts();
153: unless ($home) { return ''; }
154: my $origcrsid=$env{'request.course.id'};
155: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
156: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
157: # Do the dumping
158: unless ($outhash{'home_'.$env{'form.authorspace'}}) { return ''; }
159: my ($ca,$cd)=split(/\@/,$env{'form.authorspace'});
160: $r->print('<h3>'.&mt('Copying Files').'</h3>');
161: my $title=$env{'form.authorfolder'};
162: $title=&clean($title);
163: my %replacehash=();
164: foreach my $key (keys(%env)) {
165: if ($key=~/^form\.namefor\_(.+)/) {
166: $replacehash{$1}=$env{$key};
167: }
168: }
169: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
170: $crs=~s/\_/\//g;
171: foreach my $item (keys(%replacehash)) {
172: my $newfilename=$title.'/'.$replacehash{$item};
173: $newfilename=~s/\.(\w+)$//;
174: my $ext=$1;
175: $newfilename=&clean($newfilename);
176: $newfilename.='.'.$ext;
177: my @dirs=split(/\//,$newfilename);
178: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
179: my $makepath=$path;
180: my $fail=0;
181: for (my $i=0;$i<$#dirs;$i++) {
182: $makepath.='/'.$dirs[$i];
183: unless (-e $makepath) {
184: unless(mkdir($makepath,0777)) { $fail=1; }
185: }
186: }
187: $r->print('<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ');
188: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
189: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
190: print $fh &Apache::lonclonecourse::rewritefile(
191: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
192: (%replacehash,$crs => '')
193: );
194: } else {
195: print $fh
196: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
197: }
198: $fh->close();
199: } else {
200: $fail=1;
201: }
202: if ($fail) {
203: $r->print('<span class="LC_error">'.&mt('fail').'</span>');
204: } else {
205: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
206: }
207: }
208: } else {
209: # Input form
210: unless ($home==1) {
211: $r->print(
212: '<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
213: }
214: foreach my $key (sort(keys(%outhash))) {
215: if ($key=~/^home_(.+)$/) {
216: if ($home==1) {
217: $r->print(
218: '<input type="hidden" name="authorspace" value="'.$1.'" />');
219: } else {
220: $r->print('<option value="'.$1.'">'.$1.' - '.
221: &Apache::loncommon::plainname(split(/\@/,$1)).'</option>');
222: }
223: }
224: }
225: unless ($home==1) {
226: $r->print('</select>');
227: }
228: my $title=$origcrsdata{'description'};
229: $title=~s/[\/\s]+/\_/gs;
230: $title=&clean($title);
231: $r->print('<h3>'.&mt('Folder in Construction Space').'</h3>'
232: .'<input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
233: &tiehash();
234: $r->print('<h3>'.&mt('Filenames in Construction Space').'</h3>'
235: .&Apache::loncommon::start_data_table()
236: .&Apache::loncommon::start_data_table_header_row()
237: .'<th>'.&mt('Internal Filename').'</th>'
238: .'<th>'.&mt('Title').'</th>'
239: .'<th>'.&mt('Save as ...').'</th>'
240: .&Apache::loncommon::end_data_table_header_row());
241: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
242: $r->print(&Apache::loncommon::start_data_table_row()
243: .'<td>'.$file.'</td>');
244: my ($ext)=($file=~/\.(\w+)$/);
245: my $title=$hash{'title_'.$hash{
246: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
247: $r->print('<td>'.($title?$title:' ').'</td>');
248: if (!$title) {
249: $title=$file;
250: } else {
251: $title=~s|/|_|g;
252: }
253: $title=~s/\.(\w+)$//;
254: $title=&clean($title);
255: $title.='.'.$ext;
256: $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
257: .&Apache::loncommon::end_data_table_row());
258: }
259: $r->print(&Apache::loncommon::end_data_table());
260: &untiehash();
261: $r->print(
262: '<p><input type="submit" name="dumpcourse" value="'.&mt("Dump $crstype Documents").'" /></p></form>');
263: }
264: }
265:
266: sub exportbutton {
267: my $crstype = &Apache::loncommon::course_type();
268: return "<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"exportcourse\", \"".&mt('IMS Export')."\")'>".&mt('IMS Export')."</a>".
269: &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'<br />';
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) };
277: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
278: && ($caller eq 'londocs')
279: && (!&Apache::lonnet::stat_file($url))) {
280:
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) {
300: if (!$residx
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);
309: $LONCAPA::map::resources[$residx] =
310: join(':', ($name, $url, $ext, 'normal', 'res'));
311: }
312: }
313: return &storemap($coursenum, $coursedom, $folder.'.'.$container);
314: }
315:
316: sub breadcrumbs {
317: my ($allowed,$crstype)=@_;
318: &Apache::lonhtmlcommon::clear_breadcrumbs();
319: my (@folders);
320: if ($env{'form.pagepath'}) {
321: @folders = split('&',$env{'form.pagepath'});
322: } else {
323: @folders=split('&',$env{'form.folderpath'});
324: }
325: my $folderpath;
326: my $cpinfo='';
327: my $plain='';
328: my $randompick=-1;
329: my $isencrypted=0;
330: my $ishidden=0;
331: my $is_random_order=0;
332: while (@folders) {
333: my $folder=shift(@folders);
334: my $foldername=shift(@folders);
335: if ($folderpath) {$folderpath.='&';}
336: $folderpath.=$folder.'&'.$foldername;
337: my $url;
338: if ($allowed) {
339: $url = '/adm/coursedocs?folderpath=';
340: } else {
341: $url = '/adm/supplemental?folderpath=';
342: }
343: $url .= &escape($folderpath);
344: my $name=&unescape($foldername);
345: # randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername
346: $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;
347: if ($1 ne '') {
348: $randompick=$1;
349: } else {
350: $randompick=-1;
351: }
352: if ($2) { $ishidden=1; }
353: if ($3) { $isencrypted=1; }
354: if ($4 ne '') { $is_random_order = 1; }
355: if ($folder eq 'supplemental') {
356: $name = &mt('Supplemental '.$crstype.' Content');
357: }
358: &Apache::lonhtmlcommon::add_breadcrumb(
359: {'href'=>$url.$cpinfo,
360: 'title'=>$name,
361: 'text'=>$name,
362: 'no_mt'=>1,
363: });
364: $plain.=$name.' > ';
365: }
366: $plain=~s/\>\;\s*$//;
367: return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
368: undef, undef, 1 ),$randompick,$ishidden,
369: $isencrypted,$plain,$is_random_order);
370: }
371:
372: sub log_docs {
373: return &Apache::lonnet::instructor_log('docslog',@_);
374: }
375:
376: {
377: my @oldresources=();
378: my @oldorder=();
379: my $parmidx;
380: my %parmaction=();
381: my %parmvalue=();
382: my $changedflag;
383:
384: sub snapshotbefore {
385: @oldresources=@LONCAPA::map::resources;
386: @oldorder=@LONCAPA::map::order;
387: $parmidx=undef;
388: %parmaction=();
389: %parmvalue=();
390: $changedflag=0;
391: }
392:
393: sub remember_parms {
394: my ($idx,$parameter,$action,$value)=@_;
395: $parmidx=$idx;
396: $parmaction{$parameter}=$action;
397: $parmvalue{$parameter}=$value;
398: $changedflag=1;
399: }
400:
401: sub log_differences {
402: my ($plain)=@_;
403: my %storehash=('folder' => $plain,
404: 'currentfolder' => $env{'form.folder'});
405: if ($parmidx) {
406: $storehash{'parameter_res'}=$oldresources[$parmidx];
407: foreach my $parm (keys(%parmaction)) {
408: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
409: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
410: }
411: }
412: my $maxidx=$#oldresources;
413: if ($#LONCAPA::map::resources>$#oldresources) {
414: $maxidx=$#LONCAPA::map::resources;
415: }
416: for (my $idx=0; $idx<=$maxidx; $idx++) {
417: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
418: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
419: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
420: $changedflag=1;
421: }
422: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
423: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
424: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
425: $changedflag=1;
426: }
427: }
428: $storehash{'maxidx'}=$maxidx;
429: if ($changedflag) { &log_docs(\%storehash); }
430: }
431: }
432:
433:
434:
435:
436:
437: sub docs_change_log {
438: my ($r)=@_;
439: my $folder=$env{'form.folder'};
440: $r->print(&Apache::loncommon::start_page('Course Document Change Log'));
441: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log'));
442: my %docslog=&Apache::lonnet::dump('nohist_docslog',
443: $env{'course.'.$env{'request.course.id'}.'.domain'},
444: $env{'course.'.$env{'request.course.id'}.'.num'});
445:
446: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
447:
448: $r->print('<form action="/adm/coursedocs" method="post" name="docslog">'.
449: '<input type="hidden" name="docslog" value="1" />');
450:
451: my %saveable_parameters = ('show' => 'scalar',);
452: &Apache::loncommon::store_course_settings('docs_log',
453: \%saveable_parameters);
454: &Apache::loncommon::restore_course_settings('docs_log',
455: \%saveable_parameters);
456: if (!$env{'form.show'}) { $env{'form.show'}=10; }
457: # FIXME: internationalization seems wrong here
458: my %lt=('hiddenresource' => 'Resources hidden',
459: 'encrypturl' => 'URL hidden',
460: 'randompick' => 'Randomly pick',
461: 'randomorder' => 'Randomly ordered',
462: 'set' => 'set to',
463: 'del' => 'deleted');
464: $r->print(&Apache::loncommon::display_filter().
465: '<input type="hidden" name="folder" value="'.$folder.'" />'.
466: '<input type="submit" value="'.&mt('Display').'" /></form>');
467: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
468: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
469: &mt('After').'</th>'.
470: &Apache::loncommon::end_data_table_header_row());
471: my $shown=0;
472: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
473: if ($env{'form.displayfilter'} eq 'currentfolder') {
474: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
475: }
476: my @changes=keys(%{$docslog{$id}{'logentry'}});
477: if ($env{'form.displayfilter'} eq 'containing') {
478: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
479: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
480: foreach my $key (@changes) {
481: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
482: }
483: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
484: }
485: my $count = 0;
486: my $time =
487: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
488: my $plainname =
489: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
490: $docslog{$id}{'exe_udom'});
491: my $about_me_link =
492: &Apache::loncommon::aboutmewrapper($plainname,
493: $docslog{$id}{'exe_uname'},
494: $docslog{$id}{'exe_udom'});
495: my $send_msg_link='';
496: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
497: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
498: $send_msg_link ='<br />'.
499: &Apache::loncommon::messagewrapper(&mt('Send message'),
500: $docslog{$id}{'exe_uname'},
501: $docslog{$id}{'exe_udom'});
502: }
503: $r->print(&Apache::loncommon::start_data_table_row());
504: $r->print('<td>'.$time.'</td>
505: <td>'.$about_me_link.
506: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
507: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
508: $send_msg_link.'</td><td>'.
509: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
510: # Before
511: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
512: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
513: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
514: if ($oldname ne $newname) {
515: $r->print(&LONCAPA::map::qtescape($oldname));
516: }
517: }
518: $r->print('<ul>');
519: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
520: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
521: $r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]).'</li>');
522: }
523: }
524: $r->print('</ul>');
525: # After
526: $r->print('</td><td>');
527:
528: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
529: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
530: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
531: if ($oldname ne '' && $oldname ne $newname) {
532: $r->print(&LONCAPA::map::qtescape($newname));
533: }
534: }
535: $r->print('<ul>');
536: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
537: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
538: $r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]).'</li>');
539: }
540: }
541: $r->print('</ul>');
542: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
543: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
544: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
545: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
546: # FIXME: internationalization seems wrong here
547: $r->print('<li>'.
548: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
549: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
550: .'</li>');
551: }
552: }
553: $r->print('</ul>');
554: }
555: # End
556: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
557: $shown++;
558: if (!($env{'form.show'} eq &mt('all')
559: || $shown<=$env{'form.show'})) { last; }
560: }
561: $r->print(&Apache::loncommon::end_data_table());
562: }
563:
564: sub update_paste_buffer {
565: my ($coursenum,$coursedom) = @_;
566:
567: return if (!defined($env{'form.markcopy'}));
568: return if (!defined($env{'form.copyfolder'}));
569: return if ($env{'form.markcopy'} < 0);
570:
571: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
572: $env{'form.copyfolder'});
573:
574: return if ($fatal);
575:
576: # Mark for copying
577: my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
578: if (&is_supplemental_title($title)) {
579: &Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
580: ($title) = &parse_supplemental_title($title);
581: } elsif ($env{'docs.markedcopy_supplemental'}) {
582: &Apache::lonnet::delenv('docs.markedcopy_supplemental');
583: }
584: $url=~s{http(:|:)//https(:|:)//}{https$2//};
585:
586: &Apache::lonnet::appenv({'docs.markedcopy_title' => $title,
587: 'docs.markedcopy_url' => $url});
588: delete($env{'form.markcopy'});
589: }
590:
591: sub print_paste_buffer {
592: my ($r,$container) = @_;
593: return if (!defined($env{'docs.markedcopy_url'}));
594:
595: $r->print('<fieldset>'
596: .'<legend>'.&mt('Clipboard').'</legend>'
597: .'<form name="pasteform" action="/adm/coursedocs" method="post">'
598: .'<input type="submit" name="pastemarked" value="'.&mt('Paste').'" /> '
599: );
600:
601: my $type;
602: if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
603: $type = &mt('External Resource');
604: $r->print($type.': '.
605: &LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('.
606: &LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')');
607: } else {
608: my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
609: my $icon = &Apache::loncommon::icon($extension);
610: if ($extension eq 'sequence' &&
611: $env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) {
612: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
613: $icon .= '/navmap.folder.closed.gif';
614: }
615: $icon = '<img src="'.$icon.'" alt="" class="LC_icon" />';
616: $r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'})));
617: }
618: if ($container eq 'page') {
619: $r->print('
620: <input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />
621: <input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />
622: ');
623: } else {
624: $r->print('
625: <input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
626: ');
627: }
628: $r->print('</form></fieldset>');
629: }
630:
631: sub do_paste_from_buffer {
632: my ($coursenum,$coursedom,$folder) = @_;
633:
634: if (!$env{'form.pastemarked'}) {
635: return;
636: }
637:
638: # paste resource to end of list
639: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
640: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});
641: # Maps need to be copied first
642: if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {
643: $title=&mt('Copy of').' '.$title;
644: my $newid=$$.int(rand(100)).time;
645: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
646: if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) {
647: my $path = $1;
648: my $prefix = $2;
649: my $ancestor = $3;
650: if (length($ancestor) > 10) {
651: $ancestor = substr($ancestor,-10,10);
652: }
653: $oldid = $path.$prefix.$ancestor;
654: }
655: my $counter = 0;
656: my $newurl=$oldid.$newid.'.'.$ext;
657: my $is_unique = &uniqueness_check($newurl);
658: while (!$is_unique && $counter < 100) {
659: $counter ++;
660: $newid ++;
661: $newurl = $oldid.$newid;
662: $is_unique = &uniqueness_check($newurl);
663: }
664: if (!$is_unique) {
665: if ($url=~/\.page$/) {
666: return &mt('Paste failed: an error occurred creating a unique URL for the composite page');
667: } else {
668: return &mt('Paste failed: an error occurred creating a unique URL for the folder');
669: }
670: }
671: my $storefn=$newurl;
672: $storefn=~s{^/\w+/$match_domain/$match_username/}{};
673: my $paste_map_result =
674: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
675: &Apache::lonnet::getfile($url));
676: if ($paste_map_result eq '/adm/notfound.html') {
677: if ($url=~/\.page$/) {
678: return &mt('Paste failed: an error occurred saving the composite page');
679: } else {
680: return &mt('Paste failed: an error occurred saving the folder');
681: }
682: }
683: $url = $newurl;
684: }
685: # published maps can only exists once, so remove it from paste buffer when done
686: if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) {
687: &Apache::lonnet::delenv('docs.markedcopy');
688: }
689: if ($url=~ m{/smppg$}) {
690: my $db_name = &Apache::lonsimplepage::get_db_name($url);
691: if ($db_name =~ /^smppage_/) {
692: #simple pages, need to copy the db contents to a new one.
693: my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum);
694: my $now = time();
695: $db_name =~ s{_\d*$ }{_$now}x;
696: my $result=&Apache::lonnet::put($db_name,\%contents,
697: $coursedom,$coursenum);
698: $url =~ s{/(\d*)/smppg$ }{/$now/smppg}x;
699: $title=&mt('Copy of').' '.$title;
700: }
701: }
702: $title = &LONCAPA::map::qtunescape($title);
703: my $ext='false';
704: if ($url=~m{^http(|s)://}) { $ext='true'; }
705: $url = &LONCAPA::map::qtunescape($url);
706: # Now insert the URL at the bottom
707: my $newidx = &LONCAPA::map::getresidx($url);
708: if ($env{'docs.markedcopy_supplemental'}) {
709: if ($folder =~ /^supplemental/) {
710: $title = $env{'docs.markedcopy_supplemental'};
711: } else {
712: (undef,undef,$title) =
713: &parse_supplemental_title($env{'docs.markedcopy_supplemental'});
714: }
715: } else {
716: if ($folder=~/^supplemental/) {
717: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
718: $env{'user.domain'}.'___&&&___'.$title;
719: }
720: }
721:
722: $LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
723: push(@LONCAPA::map::order, $newidx);
724: return 'ok';
725: # Store the result
726: }
727:
728: sub uniqueness_check {
729: my ($newurl) = @_;
730: my $unique = 1;
731: foreach my $res (@LONCAPA::map::order) {
732: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
733: $url=&LONCAPA::map::qtescape($url);
734: if ($newurl eq $url) {
735: $unique = 0;
736: last;
737: }
738: }
739: return $unique;
740: }
741:
742: my %parameter_type = ( 'randompick' => 'int_pos',
743: 'hiddenresource' => 'string_yesno',
744: 'encrypturl' => 'string_yesno',
745: 'randomorder' => 'string_yesno',);
746: my $valid_parameters_re = join('|',keys(%parameter_type));
747: # set parameters
748: sub update_parameter {
749:
750: return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
751:
752: my $which = $env{'form.changeparms'};
753: my $idx = $env{'form.setparms'};
754: if ($env{'form.'.$which.'_'.$idx}) {
755: my $value = ($which eq 'randompick') ? $env{'form.'.$which.'_'.$idx}
756: : 'yes';
757: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
758: $parameter_type{$which});
759: &remember_parms($idx,$which,'set',$value);
760: } else {
761: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
762:
763: &remember_parms($idx,$which,'del');
764: }
765: return 1;
766: }
767:
768:
769: sub handle_edit_cmd {
770: my ($coursenum,$coursedom) =@_;
771: my ($cmd,$idx)=split('_',$env{'form.cmd'});
772:
773: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
774: my ($title, $url, @rrest) = split(':', $ratstr);
775:
776: if ($cmd eq 'del') {
777: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
778: ($url!~/$LONCAPA::assess_page_seq_re/)) {
779: &Apache::lonnet::removeuploadedurl($url);
780: } else {
781: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
782: }
783: splice(@LONCAPA::map::order, $idx, 1);
784:
785: } elsif ($cmd eq 'cut') {
786: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
787: splice(@LONCAPA::map::order, $idx, 1);
788:
789: } elsif ($cmd eq 'up'
790: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
791: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
792:
793: } elsif ($cmd eq 'down'
794: && defined($LONCAPA::map::order[$idx+1])) {
795: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
796:
797: } elsif ($cmd eq 'rename') {
798:
799: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
800: if ($comment=~/\S/) {
801: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
802: $comment.':'.join(':', $url, @rrest);
803: }
804: # Devalidate title cache
805: my $renamed_url=&LONCAPA::map::qtescape($url);
806: &Apache::lonnet::devalidate_title_cache($renamed_url);
807: } else {
808: return 0;
809: }
810: return 1;
811: }
812:
813: sub editor {
814: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
815: $supplementalflag,$orderhash,$iconpath)=@_;
816: my $container= ($env{'form.pagepath'}) ? 'page'
817: : 'sequence';
818:
819: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
820: $folder.'.'.$container);
821: return $errtext if ($fatal);
822:
823: if ($#LONCAPA::map::order<1) {
824: my $idx=&LONCAPA::map::getresidx();
825: if ($idx<=0) { $idx=1; }
826: $LONCAPA::map::order[0]=$idx;
827: $LONCAPA::map::resources[$idx]='';
828: }
829:
830: my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) =
831: &breadcrumbs($allowed,$crstype);
832: $r->print($breadcrumbtrail);
833:
834: my $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
835:
836: unless ($allowed) {
837: $randompick = -1;
838: }
839:
840: # ------------------------------------------------------------ Process commands
841:
842: # ---------------- if they are for this folder and user allowed to make changes
843: if (($allowed) && ($env{'form.folder'} eq $folder)) {
844: # set parameters and change order
845: &snapshotbefore();
846:
847: if (&update_parameter()) {
848: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
849: return $errtext if ($fatal);
850: }
851:
852: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
853: # change order
854: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
855: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
856:
857: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
858: return $errtext if ($fatal);
859: }
860:
861: if ($env{'form.pastemarked'}) {
862: my $paste_res =
863: &do_paste_from_buffer($coursenum,$coursedom,$folder);
864: if ($paste_res eq 'ok') {
865: ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
866: return $errtext if ($fatal);
867: } elsif ($paste_res ne '') {
868: $r->print('<p><span class="LC_error">'.$paste_res.'</span></p>');
869: }
870: }
871:
872: $r->print($upload_output);
873:
874: if (&handle_edit_cmd()) {
875: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
876: return $errtext if ($fatal);
877: }
878: # Group import/search
879: if ($env{'form.importdetail'}) {
880: my @imports;
881: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
882: if (defined($item)) {
883: my ($name,$url,$residx)=
884: map {&unescape($_)} split(/\=/,$item);
885: push(@imports, [$name, $url, $residx]);
886: }
887: }
888: ($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder,
889: $container,'londocs',@imports);
890: return $errtext if ($fatal);
891: }
892: # Loading a complete map
893: if ($env{'form.loadmap'}) {
894: if ($env{'form.importmap'}=~/\w/) {
895: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
896: my ($title,$url,$ext,$type)=split(/\:/,$res);
897: my $idx=&LONCAPA::map::getresidx($url);
898: $LONCAPA::map::resources[$idx]=$res;
899: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
900: }
901: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
902: $folder.'.'.$container);
903: return $errtext if ($fatal);
904: } else {
905: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
906:
907: }
908: }
909: &log_differences($plain);
910: }
911: # ---------------------------------------------------------------- End commands
912: # ---------------------------------------------------------------- Print screen
913: my $idx=0;
914: my $shown=0;
915: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
916: $r->print('<div class="LC_Box">'.
917: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
918: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
919: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
920: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
921: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
922: '</ol>');
923: if ($randompick>=0) {
924: $r->print('<p class="LC_warning">'
925: .&mt('Caution: this folder is set to randomly pick a subset'
926: .' of resources. Adding or removing resources from this'
927: .' folder will change the set of resources that the'
928: .' students see, resulting in spurious or missing credit'
929: .' for completed problems, not limited to ones you'
930: .' modify. Do not modify the contents of this folder if'
931: .' it is in active student use.')
932: .'</p>'
933: );
934: }
935: if ($is_random_order) {
936: $r->print('<p class="LC_warning">'
937: .&mt('Caution: this folder is set to randomly order its'
938: .' contents. Adding or removing resources from this folder'
939: .' will change the order of resources shown.')
940: .'</p>'
941: );
942: }
943: $r->print('</div>');
944: }
945:
946: my ($to_show,$output);
947:
948: &Apache::loncommon::start_data_table_count(); #setup a row counter
949: foreach my $res (@LONCAPA::map::order) {
950: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
951: $name=&LONCAPA::map::qtescape($name);
952: $url=&LONCAPA::map::qtescape($url);
953: unless ($name) { $name=(split(/\//,$url))[-1]; }
954: unless ($name) { $idx++; next; }
955: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
956: $coursenum,$crstype);
957: $idx++;
958: $shown++;
959: }
960: &Apache::loncommon::end_data_table_count();
961:
962: if ($shown) {
963: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
964: .&Apache::loncommon::start_data_table(undef,'contentlist');
965: if ($allowed) {
966: $to_show .= &Apache::loncommon::start_data_table_header_row()
967: .'<th colspan="2">'.&mt('Move').'</th>'
968: .'<th>'.&mt('Actions').'</th>'
969: .'<th colspan="2">'.&mt('Document').'</th>';
970: if ($folder !~ /^supplemental/) {
971: $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
972: }
973: $to_show .= &Apache::loncommon::end_data_table_header_row();
974: }
975: $to_show .= $output.' '
976: .&Apache::loncommon::end_data_table()
977: .'<br style="line-height:2px;" />'
978: .&Apache::loncommon::end_scrollbox();
979: } else {
980: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
981: .'<div class="LC_info" id="contentlist">'
982: .&mt('Currently no documents.')
983: .'</div>'
984: .&Apache::loncommon::end_scrollbox();
985: }
986: my $tid = 1;
987: if ($supplementalflag) {
988: $tid = 2;
989: }
990: if ($allowed) {
991: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,$jumpto));
992: &print_paste_buffer($r,$container);
993: } else {
994: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
995: #Function Box for Supplemental Content for users with mdc priv.
996: my $funcname = &mt('Folder Editor');
997: $r->print(
998: &Apache::loncommon::head_subbox(
999: &Apache::lonhtmlcommon::start_funclist().
1000: &Apache::lonhtmlcommon::add_item_funclist(
1001: '<a href="/adm/coursedocs?command=direct&forcesupplement=1&'.
1002: 'supppath='.&HTML::Entities::encode($env{'form.folderpath'}).'">'.
1003: '<img src="/res/adm/pages/docs.png" alt="'.$funcname.'" class="LC_icon" />'.
1004: '<span class="LC_menubuttons_inline_text">'.$funcname.'</span></a>').
1005: &Apache::lonhtmlcommon::end_funclist()));
1006: }
1007: $r->print($to_show);
1008: }
1009: return;
1010: }
1011:
1012: sub process_file_upload {
1013: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
1014: # upload a file, if present
1015: my ($parseaction,$showupload,$nextphase,$mimetype);
1016: if ($env{'form.parserflag'}) {
1017: $parseaction = 'parse';
1018: }
1019: my $folder=$env{'form.folder'};
1020: if ($folder eq '') {
1021: $folder='default';
1022: }
1023: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
1024: my $errtext='';
1025: my $fatal=0;
1026: my $container='sequence';
1027: if ($env{'form.pagepath'}) {
1028: $container='page';
1029: }
1030: ($errtext,$fatal)=
1031: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1032: if ($#LONCAPA::map::order<1) {
1033: $LONCAPA::map::order[0]=1;
1034: $LONCAPA::map::resources[1]='';
1035: }
1036: if ($fatal) {
1037: $$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>';
1038: return;
1039: }
1040: my $destination = 'docs/';
1041: if ($folder =~ /^supplemental/) {
1042: $destination = 'supplemental/';
1043: }
1044: if (($folder eq 'default') || ($folder eq 'supplemental')) {
1045: $destination .= 'default/';
1046: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
1047: $destination .= $2.'/';
1048: }
1049: # this is for a course, not a user, so set context to coursedoc.
1050: my $newidx=&LONCAPA::map::getresidx();
1051: $destination .= $newidx;
1052: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1053: $parseaction,$allfiles,
1054: $codebase,undef,undef,undef,undef,
1055: undef,undef,\$mimetype);
1056: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
1057: my $stored = $1;
1058: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
1059: $stored.'</span>').'</p>';
1060: } else {
1061: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
1062:
1063: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1064: return;
1065: }
1066: my $ext='false';
1067: if ($url=~m{^http://}) { $ext='true'; }
1068: $url = &LONCAPA::map::qtunescape($url);
1069: my $comment=$env{'form.comment'};
1070: $comment = &LONCAPA::map::qtunescape($comment);
1071: if ($folder=~/^supplemental/) {
1072: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1073: $env{'user.domain'}.'___&&&___'.$comment;
1074: }
1075:
1076: $LONCAPA::map::resources[$newidx]=
1077: $comment.':'.$url.':'.$ext.':normal:res';
1078: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
1079: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1080: $folder.'.'.$container);
1081: if ($fatal) {
1082: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1083: return;
1084: } else {
1085: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
1086: $$upload_output = $showupload;
1087: my $total_embedded = scalar(keys(%{$allfiles}));
1088: if ($total_embedded > 0) {
1089: my $uploadphase = 'upload_embedded';
1090: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
1091: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
1092: my ($embedded,$num) =
1093: &Apache::loncommon::ask_for_embedded_content(
1094: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
1095: if ($embedded) {
1096: if ($num) {
1097: $$upload_output .=
1098: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
1099: $nextphase = $uploadphase;
1100: } else {
1101: $$upload_output .= $embedded;
1102: }
1103: } else {
1104: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
1105: }
1106: } else {
1107: $$upload_output .= &mt('No embedded items identified').'<br />';
1108: }
1109: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1110: } elsif (&Apache::loncommon::is_archive_file($mimetype)) {
1111: $nextphase = 'decompress_uploaded';
1112: my $position = scalar(@LONCAPA::map::order)-1;
1113: my $noextract = &return_to_editor();
1114: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
1115: my %archiveitems = (
1116: folderpath => $env{'form.folderpath'},
1117: pagepath => $env{'form.pagepath'},
1118: cmd => $nextphase,
1119: newidx => $newidx,
1120: position => $position,
1121: phase => $nextphase,
1122: comment => $comment,
1123: );
1124: $$upload_output = $showupload.
1125: &Apache::loncommon::decompress_form($mimetype,
1126: $archiveurl,'/adm/coursedocs',$noextract,
1127: \%archiveitems);
1128: }
1129: }
1130: }
1131: return $nextphase;
1132: }
1133:
1134: sub is_supplemental_title {
1135: my ($title) = @_;
1136: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
1137: }
1138:
1139: sub parse_supplemental_title {
1140: my ($title) = @_;
1141:
1142: my ($foldertitle,$renametitle);
1143: if ($title =~ /&&&/) {
1144: $title = &HTML::Entites::decode($title);
1145: }
1146: if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) {
1147: $renametitle=$4;
1148: my ($time,$uname,$udom) = ($1,$2,$3);
1149: $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
1150: my $name = &Apache::loncommon::plainname($uname,$udom);
1151: $name = &HTML::Entities::encode($name,'"<>&\'');
1152: $renametitle = &HTML::Entities::encode($renametitle,'"<>&\'');
1153: $title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '.
1154: $name.': <br />'.$foldertitle;
1155: }
1156: if (wantarray) {
1157: return ($title,$foldertitle,$renametitle);
1158: }
1159: return $title;
1160: }
1161:
1162: # --------------------------------------------------------------- An entry line
1163:
1164: sub entryline {
1165: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_;
1166: my ($foldertitle,$pagetitle,$renametitle);
1167: if (&is_supplemental_title($title)) {
1168: ($title,$foldertitle,$renametitle) = &parse_supplemental_title($title);
1169: $pagetitle = $foldertitle;
1170: } else {
1171: $title=&HTML::Entities::encode($title,'"<>&\'');
1172: $renametitle=$title;
1173: $foldertitle=$title;
1174: $pagetitle=$title;
1175: }
1176:
1177: my $orderidx=$LONCAPA::map::order[$index];
1178:
1179:
1180: $renametitle=~s/\\/\\\\/g;
1181: $renametitle=~s/\"\;/\\\"/g;
1182: $renametitle=~s/ /%20/g;
1183: my $line=&Apache::loncommon::start_data_table_row();
1184: my ($form_start,$form_end,$form_common);
1185: # Edit commands
1186: my ($container, $type, $esc_path, $path, $symb);
1187: if ($env{'form.folderpath'}) {
1188: $type = 'folder';
1189: $container = 'sequence';
1190: $esc_path=&escape($env{'form.folderpath'});
1191: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1192: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
1193: }
1194: if ($env{'form.pagepath'}) {
1195: $type = $container = 'page';
1196: $esc_path=&escape($env{'form.pagepath'});
1197: $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
1198: $symb=&escape($env{'form.pagesymb'});
1199: }
1200: my $cpinfo='';
1201: if ($allowed) {
1202: my $incindex=$index+1;
1203: my $selectbox='';
1204: if (($#LONCAPA::map::order>0) &&
1205: ((split(/\:/,
1206: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
1207: ne '') &&
1208: ((split(/\:/,
1209: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1210: ne '')) {
1211: $selectbox=
1212: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1213: '<select name="newpos" onchange="this.form.submit()">';
1214: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
1215: if ($i==$incindex) {
1216: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1217: } else {
1218: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
1219: }
1220: }
1221: $selectbox.='</select>';
1222: }
1223: my %lt=&Apache::lonlocal::texthash(
1224: 'up' => 'Move Up',
1225: 'dw' => 'Move Down',
1226: 'rm' => 'Remove',
1227: 'ct' => 'Cut',
1228: 'rn' => 'Rename',
1229: 'cp' => 'Copy');
1230: my $nocopy=0;
1231: my $nocut=0;
1232: if ($url=~/\.(page|sequence)$/) {
1233: if ($url =~ m{/res/}) {
1234: # no copy for published maps
1235: $nocopy = 1;
1236: } else {
1237: foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
1238: my ($title,$url,$ext,$type)=split(/\:/,$item);
1239: if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
1240: $nocopy=1;
1241: last;
1242: }
1243: }
1244: }
1245: }
1246: if ($url=~/^\/res\/lib\/templates\//) {
1247: $nocopy=1;
1248: $nocut=1;
1249: }
1250: my $copylink=' ';
1251: my $cutlink=' ';
1252:
1253: my $skip_confirm = 0;
1254: if ( $folder =~ /^supplemental/
1255: || ($url =~ m{( /smppg$
1256: |/syllabus$
1257: |/aboutme$
1258: |/navmaps$
1259: |/bulletinboard$
1260: |\.html$
1261: |^/adm/wrapper/ext)}x)) {
1262: $skip_confirm = 1;
1263: }
1264:
1265: if (!$nocopy) {
1266: $copylink=(<<ENDCOPY);
1267: <a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_copy">$lt{'cp'}</a>
1268: ENDCOPY
1269: }
1270: if (!$nocut) {
1271: $cutlink=(<<ENDCUT);
1272: <a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder",$skip_confirm);' class="LC_docs_cut">$lt{'ct'}</a>
1273: ENDCUT
1274: }
1275: $form_start = '
1276: <form action="/adm/coursedocs" method="post">
1277: ';
1278: $form_common=(<<END);
1279: <input type="hidden" name="${type}path" value="$path" />
1280: <input type="hidden" name="${type}symb" value="$symb" />
1281: <input type="hidden" name="setparms" value="$orderidx" />
1282: <input type="hidden" name="changeparms" value="0" />
1283: END
1284: $form_end = '</form>';
1285: $line.=(<<END);
1286: <td>
1287: <div class="LC_docs_entry_move">
1288: <a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'>
1289: <img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" />
1290: </a>
1291: </div>
1292: <div class="LC_docs_entry_move">
1293: <a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'>
1294: <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" />
1295: </a>
1296: </div>
1297: </td>
1298: <td>
1299: $form_start
1300: $form_common
1301: $selectbox
1302: $form_end
1303: </td>
1304: <td class="LC_docs_entry_commands">
1305: <a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
1306: $cutlink
1307: <a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>
1308: $copylink
1309: </td>
1310: END
1311:
1312: }
1313: # Figure out what kind of a resource this is
1314: my ($extension)=($url=~/\.(\w+)$/);
1315: my $uploaded=($url=~/^\/*uploaded\//);
1316: my $icon=&Apache::loncommon::icon($url);
1317: my $isfolder=0;
1318: my $ispage=0;
1319: my $folderarg;
1320: my $pagearg;
1321: my $pagefile;
1322: if ($uploaded) {
1323: if (($extension eq 'sequence') || ($extension eq 'page')) {
1324: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1325: my $containerarg = $1;
1326: if ($extension eq 'sequence') {
1327: $icon=$iconpath.'navmap.folder.closed.gif';
1328: $folderarg=$containerarg;
1329: $isfolder=1;
1330: } else {
1331: $icon=$iconpath.'page.gif';
1332: $pagearg=$containerarg;
1333: $ispage=1;
1334: }
1335: if ($allowed) {
1336: $url='/adm/coursedocs?';
1337: } else {
1338: $url='/adm/supplemental?';
1339: }
1340: } else {
1341: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
1342: }
1343: }
1344:
1345: my $orig_url = $url;
1346: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1347: my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
1348: if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
1349: my $symb=&Apache::lonnet::symbclean(
1350: &Apache::lonnet::declutter('uploaded/'.
1351: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
1352: $env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
1353: '.sequence').
1354: '___'.$residx.'___'.
1355: &Apache::lonnet::declutter($url));
1356: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
1357: $url=&Apache::lonnet::clutter($url);
1358: if ($url=~/^\/*uploaded\//) {
1359: $url=~/\.(\w+)$/;
1360: my $embstyle=&Apache::loncommon::fileembstyle($1);
1361: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
1362: $url='/adm/wrapper'.$url;
1363: } elsif ($embstyle eq 'ssi') {
1364: #do nothing with these
1365: } elsif ($url!~/\.(sequence|page)$/) {
1366: $url='/adm/coursedocs/showdoc'.$url;
1367: }
1368: } elsif ($url=~m|^/ext/|) {
1369: $url='/adm/wrapper'.$url;
1370: $external = 1;
1371: }
1372: if (&Apache::lonnet::symbverify($symb,$url)) {
1373: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
1374: } else {
1375: $url='';
1376: }
1377: if ($container eq 'page') {
1378: my $symb=$env{'form.pagesymb'};
1379:
1380: $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
1381: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
1382: }
1383: }
1384: my ($rand_pick_text,$rand_order_text);
1385: if ($isfolder || $extension eq 'sequence') {
1386: my $foldername=&escape($foldertitle);
1387: my $folderpath=$env{'form.folderpath'};
1388: if ($folderpath) { $folderpath.='&' };
1389: # Append randompick number, hidden, and encrypted with ":" to foldername,
1390: # so it gets transferred between levels
1391: $folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx,
1392: 'parameter_randompick'))[0]
1393: .':'.((&LONCAPA::map::getparameter($orderidx,
1394: 'parameter_hiddenresource'))[0]=~/^yes$/i)
1395: .':'.((&LONCAPA::map::getparameter($orderidx,
1396: 'parameter_encrypturl'))[0]=~/^yes$/i)
1397: .':'.((&LONCAPA::map::getparameter($orderidx,
1398: 'parameter_randomorder'))[0]=~/^yes$/i);
1399: $url.='folderpath='.&escape($folderpath).$cpinfo;
1400: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
1401: 'parameter_randompick'))[0];
1402: my $rpckchk;
1403: if ($rpicknum) {
1404: $rpckchk = ' checked="checked"';
1405: }
1406: my $formname = 'edit_rpick_'.$orderidx;
1407: $rand_pick_text =
1408: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1409: $form_common."\n".
1410: '<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.'" />';
1411: if ($rpicknum ne '') {
1412: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
1413: }
1414: $rand_pick_text .= '</span></form>';
1415: my $ro_set=
1416: ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
1417: $rand_order_text =
1418: $form_start.
1419: $form_common.'
1420: <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>';
1421: }
1422: if ($ispage) {
1423: my $pagename=&escape($pagetitle);
1424: my $pagepath;
1425: my $folderpath=$env{'form.folderpath'};
1426: if ($folderpath) { $pagepath = $folderpath.'&' };
1427: $pagepath.=$pagearg.'&'.$pagename;
1428: my $symb=$env{'form.pagesymb'};
1429: if (!$symb) {
1430: my $path='uploaded/'.
1431: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
1432: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
1433: $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
1434: $residx,
1435: $path.$pagearg.'.page');
1436: }
1437: $url.='pagepath='.&escape($pagepath).
1438: '&pagesymb='.&escape($symb).$cpinfo;
1439: }
1440: if (($external) && ($allowed)) {
1441: my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
1442: $external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>';
1443: } else {
1444: undef($external);
1445: }
1446: my $reinit;
1447: if ($crstype eq 'Community') {
1448: $reinit = &mt('(re-initialize community to access)');
1449: } else {
1450: $reinit = &mt('(re-initialize course to access)');
1451: }
1452: $line.='<td>';
1453: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1454: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
1455: } elsif ($url) {
1456: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1457: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
1458: } else {
1459: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
1460: }
1461: $line.='</td><td>';
1462: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1463: $line.='<a href="'.$url.'">'.$title.'</a>';
1464: } elsif ($url) {
1465: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1466: $title,600,500);
1467: } else {
1468: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
1469: }
1470: $line.=$external."</td>";
1471: $rand_pick_text = ' ' if ($rand_pick_text eq '');
1472: $rand_order_text = ' ' if ($rand_order_text eq '');
1473: if (($allowed) && ($folder!~/^supplemental/)) {
1474: my %lt=&Apache::lonlocal::texthash(
1475: 'hd' => 'Hidden',
1476: 'ec' => 'URL hidden');
1477: my $enctext=
1478: ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':'');
1479: my $hidtext=
1480: ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':'');
1481: $line.=(<<ENDPARMS);
1482: <td class="LC_docs_entry_parameter">
1483: $form_start
1484: $form_common
1485: <label><input type="checkbox" name="hiddenresource_$orderidx" onclick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
1486: $form_end
1487: <br />
1488: $form_start
1489: $form_common
1490: <label><input type="checkbox" name="encrypturl_$orderidx" onclick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
1491: $form_end
1492: </td>
1493: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
1494: $rand_order_text</td>
1495: ENDPARMS
1496: }
1497: $line.=&Apache::loncommon::end_data_table_row();
1498: return $line;
1499: }
1500:
1501: =pod
1502:
1503: =item tiehash()
1504:
1505: tie the hash
1506:
1507: =cut
1508:
1509: sub tiehash {
1510: my ($mode)=@_;
1511: $hashtied=0;
1512: if ($env{'request.course.fn'}) {
1513: if ($mode eq 'write') {
1514: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
1515: &GDBM_WRCREAT(),0640)) {
1516: $hashtied=2;
1517: }
1518: } else {
1519: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
1520: &GDBM_READER(),0640)) {
1521: $hashtied=1;
1522: }
1523: }
1524: }
1525: }
1526:
1527: sub untiehash {
1528: if ($hashtied) { untie %hash; }
1529: $hashtied=0;
1530: return OK;
1531: }
1532:
1533:
1534:
1535:
1536: sub checkonthis {
1537: my ($r,$url,$level,$title)=@_;
1538: $url=&unescape($url);
1539: $alreadyseen{$url}=1;
1540: $r->rflush();
1541: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
1542: $r->print("\n<br />");
1543: if ($level==0) {
1544: $r->print("<br />");
1545: }
1546: for (my $i=0;$i<=$level*5;$i++) {
1547: $r->print(' ');
1548: }
1549: $r->print('<a href="'.$url.'" target="cat">'.
1550: ($title?$title:$url).'</a> ');
1551: if ($url=~/^\/res\//) {
1552: my $result=&Apache::lonnet::repcopy(
1553: &Apache::lonnet::filelocation('',$url));
1554: if ($result eq 'ok') {
1555: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
1556: $r->rflush();
1557: &Apache::lonnet::countacc($url);
1558: $url=~/\.(\w+)$/;
1559: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
1560: $r->print('<br />');
1561: $r->rflush();
1562: for (my $i=0;$i<=$level*5;$i++) {
1563: $r->print(' ');
1564: }
1565: $r->print('- '.&mt('Rendering:').' ');
1566: my ($errorcount,$warningcount)=split(/:/,
1567: &Apache::lonnet::ssi_body($url,
1568: ('grade_target'=>'web',
1569: 'return_only_error_and_warning_counts' => 1)));
1570: if (($errorcount) ||
1571: ($warningcount)) {
1572: if ($errorcount) {
1573: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1574: &mt('[quant,_1,error]',$errorcount).'</span>');
1575: }
1576: if ($warningcount) {
1577: $r->print('<span class="LC_warning">'.
1578: &mt('[quant,_1,warning]',$warningcount).'</span>');
1579: }
1580: } else {
1581: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
1582: }
1583: $r->rflush();
1584: }
1585: my $dependencies=
1586: &Apache::lonnet::metadata($url,'dependencies');
1587: foreach my $dep (split(/\,/,$dependencies)) {
1588: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
1589: &checkonthis($r,$dep,$level+1);
1590: }
1591: }
1592: } elsif ($result eq 'unavailable') {
1593: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
1594: } elsif ($result eq 'not_found') {
1595: unless ($url=~/\$/) {
1596: $r->print('<span class="LC_error">'.&mt('not found').'</b></span>');
1597: } else {
1598: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1599: }
1600: } else {
1601: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
1602: }
1603: }
1604: }
1605: }
1606:
1607:
1608:
1609: =pod
1610:
1611: =item list_symbs()
1612:
1613: List Symbs
1614:
1615: =cut
1616:
1617: sub list_symbs {
1618: my ($r) = @_;
1619:
1620: my $crstype = &Apache::loncommon::course_type();
1621: $r->print(&Apache::loncommon::start_page('Symb List'));
1622: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List'));
1623: &startContentScreen($r,'tools');
1624: my $navmap = Apache::lonnavmaps::navmap->new();
1625: if (!defined($navmap)) {
1626: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
1627: '<div class="LC_error">'.
1628: &mt('Unable to retrieve information about course contents').
1629: '</div>');
1630: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1631: } else {
1632: $r->print("<pre>\n");
1633: foreach my $res ($navmap->retrieveResources()) {
1634: $r->print($res->compTitle()."\t".$res->symb()."\n");
1635: }
1636: $r->print("\n</pre>\n");
1637: }
1638: }
1639:
1640:
1641: sub verifycontent {
1642: my ($r) = @_;
1643: my $crstype = &Apache::loncommon::course_type();
1644: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents'));
1645: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents'));
1646: &startContentScreen($r,'tools');
1647: $hashtied=0;
1648: undef %alreadyseen;
1649: %alreadyseen=();
1650: &tiehash();
1651: foreach my $key (keys(%hash)) {
1652: if ($hash{$key}=~/\.(page|sequence)$/) {
1653: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
1654: $r->print('<hr /><span class="LC_error">'.
1655: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1656: &unescape($hash{$key}).'</span><br />'.
1657: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1658: }
1659: }
1660: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
1661: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
1662: }
1663: }
1664: &untiehash();
1665: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1666: }
1667:
1668:
1669: sub devalidateversioncache {
1670: my $src=shift;
1671: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
1672: &Apache::lonnet::clutter($src));
1673: }
1674:
1675: sub checkversions {
1676: my ($r) = @_;
1677: my $crstype = &Apache::loncommon::course_type();
1678: $r->print(&Apache::loncommon::start_page("Check $crstype Document Versions"));
1679: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions"));
1680: &startContentScreen($r,'tools');
1681:
1682: my $header='';
1683: my $startsel='';
1684: my $monthsel='';
1685: my $weeksel='';
1686: my $daysel='';
1687: my $allsel='';
1688: my %changes=();
1689: my $starttime=0;
1690: my $haschanged=0;
1691: my %setversions=&Apache::lonnet::dump('resourceversions',
1692: $env{'course.'.$env{'request.course.id'}.'.domain'},
1693: $env{'course.'.$env{'request.course.id'}.'.num'});
1694:
1695: $hashtied=0;
1696: &tiehash();
1697: my %newsetversions=();
1698: if ($env{'form.setmostrecent'}) {
1699: $haschanged=1;
1700: foreach my $key (keys(%hash)) {
1701: if ($key=~/^ids\_(\/res\/.+)$/) {
1702: $newsetversions{$1}='mostrecent';
1703: &devalidateversioncache($1);
1704: }
1705: }
1706: } elsif ($env{'form.setcurrent'}) {
1707: $haschanged=1;
1708: foreach my $key (keys(%hash)) {
1709: if ($key=~/^ids\_(\/res\/.+)$/) {
1710: my $getvers=&Apache::lonnet::getversion($1);
1711: if ($getvers>0) {
1712: $newsetversions{$1}=$getvers;
1713: &devalidateversioncache($1);
1714: }
1715: }
1716: }
1717: } elsif ($env{'form.setversions'}) {
1718: $haschanged=1;
1719: foreach my $key (keys(%env)) {
1720: if ($key=~/^form\.set_version_(.+)$/) {
1721: my $src=$1;
1722: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
1723: $newsetversions{$src}=$env{$key};
1724: &devalidateversioncache($src);
1725: }
1726: }
1727: }
1728: }
1729: if ($haschanged) {
1730: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
1731: $env{'course.'.$env{'request.course.id'}.'.domain'},
1732: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
1733: $r->print(&Apache::loncommon::confirmwrapper(
1734: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
1735: } else {
1736: $r->print(&Apache::loncommon::confirmwrapper(
1737: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
1738: }
1739: &mark_hash_old();
1740: }
1741: &changewarning($r,'');
1742: if ($env{'form.timerange'} eq 'all') {
1743: # show all documents
1744: $header=&mt('All Documents in '.$crstype);
1745: $allsel=1;
1746: foreach my $key (keys(%hash)) {
1747: if ($key=~/^ids\_(\/res\/.+)$/) {
1748: my $src=$1;
1749: $changes{$src}=1;
1750: }
1751: }
1752: } else {
1753: # show documents which changed
1754: %changes=&Apache::lonnet::dump
1755: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
1756: $env{'course.'.$env{'request.course.id'}.'.num'});
1757: my $firstkey=(keys(%changes))[0];
1758: unless ($firstkey=~/^error\:/) {
1759: unless ($env{'form.timerange'}) {
1760: $env{'form.timerange'}=604800;
1761: }
1762: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
1763: .&mt('seconds');
1764: if ($env{'form.timerange'}==-1) {
1765: $seltext='since start of course';
1766: $startsel='selected';
1767: $env{'form.timerange'}=time;
1768: }
1769: $starttime=time-$env{'form.timerange'};
1770: if ($env{'form.timerange'}==2592000) {
1771: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1772: $monthsel='selected';
1773: } elsif ($env{'form.timerange'}==604800) {
1774: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1775: $weeksel='selected';
1776: } elsif ($env{'form.timerange'}==86400) {
1777: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1778: $daysel='selected';
1779: }
1780: $header=&mt('Content changed').' '.$seltext;
1781: } else {
1782: $header=&mt('No content modifications yet.');
1783: }
1784: }
1785: %setversions=&Apache::lonnet::dump('resourceversions',
1786: $env{'course.'.$env{'request.course.id'}.'.domain'},
1787: $env{'course.'.$env{'request.course.id'}.'.num'});
1788: my %lt=&Apache::lonlocal::texthash
1789: ('st' => 'Version changes since start of '.$crstype,
1790: 'lm' => 'Version changes since last Month',
1791: 'lw' => 'Version changes since last Week',
1792: 'sy' => 'Version changes since Yesterday',
1793: 'al' => 'All Resources (possibly large output)',
1794: 'sd' => 'Display',
1795: 'fi' => 'File',
1796: 'md' => 'Modification Date',
1797: 'mr' => 'Most recently published Version',
1798: 've' => 'Version used in '.$crstype,
1799: 'vu' => 'Set Version to be used in '.$crstype,
1800: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1801: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
1802: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1803: 'di' => 'Differences',
1804: 'save' => 'Save',
1805: 'act' => 'Actions');
1806: $r->print(<<ENDHEADERS);
1807: <form action="/adm/coursedocs" method="post">
1808: <input type="hidden" name="versions" value="1" />
1809: <div class="LC_columnSection">
1810: <fieldset>
1811: <legend>$lt{'act'}</legend>
1812: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" /><br />
1813: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" />
1814: </fieldset>
1815: </div>
1816: <select name="timerange">
1817: <option value='all' $allsel>$lt{'al'}</option>
1818: <option value="-1" $startsel>$lt{'st'}</option>
1819: <option value="2592000" $monthsel>$lt{'lm'}</option>
1820: <option value="604800" $weeksel>$lt{'lw'}</option>
1821: <option value="86400" $daysel>$lt{'sy'}</option>
1822: </select>
1823: <input type="submit" name="display" value="$lt{'sd'}" />
1824: <h2>$header</h2>
1825: <input type="submit" name="setversions" value="$lt{'save'}" />
1826: <table border="0">
1827: ENDHEADERS
1828: #number of columns for version history
1829: my $num_ver_col = 1;
1830: $r->print(
1831: &Apache::loncommon::start_data_table().
1832: &Apache::loncommon::start_data_table_header_row().
1833: '<th>'.&mt('Resources').'</th>'.
1834: "<th>$lt{'mr'}</th>".
1835: "<th>$lt{'ve'}</th>".
1836: "<th>$lt{'vu'}</th>".
1837: '<th colspan="'.$num_ver_col.'">'.&mt('History').'</th>'.
1838: '</b>');
1839: foreach my $key (sort(keys(%changes))) {
1840: if ($changes{$key}>$starttime) {
1841: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
1842: my $currentversion=&Apache::lonnet::getversion($key);
1843: if ($currentversion<0) {
1844: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
1845: }
1846: my $linkurl=&Apache::lonnet::clutter($key);
1847: $r->print(
1848: &Apache::loncommon::end_data_table_header_row().
1849: &Apache::loncommon::start_data_table_row().
1850: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br>'.
1851: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
1852: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br>('.
1853: &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate')).')</span></td>'.
1854: '<td align="right">');
1855: # Used in course
1856: my $usedversion=$hash{'version_'.$linkurl};
1857: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1858: if($usedversion != $currentversion){
1859: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1860: }else{
1861: $r->print($usedversion);
1862: }
1863: } else {
1864: $r->print($currentversion);
1865: }
1866: $r->print('</td><td title="'.$lt{'vu'}.'">');
1867: # Set version
1868: $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
1869: 'set_version_'.$linkurl,
1870: {'select_form_order' =>
1871: ['',1..$currentversion,'mostrecent'],
1872: '' => '',
1873: 'mostrecent' => &mt('most recent'),
1874: map {$_,$_} (1..$currentversion)}));
1875: my $lastold=1;
1876: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
1877: my $url=$root.'.'.$prevvers.'.'.$extension;
1878: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
1879: $starttime) {
1880: $lastold=$prevvers;
1881: }
1882: }
1883: #
1884: # Code to figure out how many version entries should go in
1885: # each of the four columns
1886: my $entries_per_col = 0;
1887: my $num_entries = ($currentversion-$lastold);
1888: if ($num_entries % $num_ver_col == 0) {
1889: $entries_per_col = $num_entries/$num_ver_col;
1890: } else {
1891: $entries_per_col = $num_entries/$num_ver_col + 1;
1892: }
1893: my $entries_count = 0;
1894: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
1895: my $cols_output = 1;
1896: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
1897: my $url=$root.'.'.$prevvers.'.'.$extension;
1898: $r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url).
1899: '">'.&mt('Version').' '.$prevvers.'</a> ('.
1900: &Apache::lonlocal::locallocaltime(
1901: &Apache::lonnet::metadata($url,
1902: 'lastrevisiondate')
1903: ).
1904: ')');
1905: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
1906: $r->print(' <a href="/adm/diff?filename='.
1907: &Apache::lonnet::clutter($root.'.'.$extension).
1908: '&versionone='.$prevvers.
1909: '" target="diffs">'.&mt('Diffs').'</a>');
1910: }
1911: $r->print('</span><br />');
1912: if (++$entries_count % $entries_per_col == 0) {
1913: $r->print('</span></td>');
1914: if ($cols_output != $num_ver_col) {
1915: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
1916: $cols_output++;
1917: }
1918: }
1919: }
1920: while($cols_output++ < $num_ver_col) {
1921: $r->print('</span></td><td>');
1922: }
1923: }
1924: }
1925: $r->print('</td>'.&Apache::loncommon::end_data_table_row().
1926: &Apache::loncommon::end_data_table().
1927: '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />');
1928:
1929: &untiehash();
1930: }
1931:
1932: sub mark_hash_old {
1933: my $retie_hash=0;
1934: if ($hashtied) {
1935: $retie_hash=1;
1936: &untiehash();
1937: }
1938: &tiehash('write');
1939: $hash{'old'}=1;
1940: &untiehash();
1941: if ($retie_hash) { &tiehash(); }
1942: }
1943:
1944: sub is_hash_old {
1945: my $untie_hash=0;
1946: if (!$hashtied) {
1947: $untie_hash=1;
1948: &tiehash();
1949: }
1950: my $return=$hash{'old'};
1951: if ($untie_hash) { &untiehash(); }
1952: return $return;
1953: }
1954:
1955: sub changewarning {
1956: my ($r,$postexec,$message,$url)=@_;
1957: if (!&is_hash_old()) { return; }
1958: my $pathvar='folderpath';
1959: my $path=&escape($env{'form.folderpath'});
1960: if (!defined($url)) {
1961: if (defined($env{'form.pagepath'})) {
1962: $pathvar='pagepath';
1963: $path=&escape($env{'form.pagepath'});
1964: $path.='&pagesymb='.&escape($env{'form.pagesymb'});
1965: }
1966: $url='/adm/coursedocs?'.$pathvar.'='.$path;
1967: }
1968: my $course_type = &Apache::loncommon::course_type();
1969: if (!defined($message)) {
1970: $message='Changes will become active for your current session after [_1], or the next time you log in.';
1971: }
1972: $r->print("\n\n".
1973: '<script type="text/javascript">'."\n".
1974: '// <![CDATA['."\n".
1975: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
1976: '// ]]>'."\n".
1977: '</script>'."\n".
1978: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1979: '<input type="hidden" name="orgurl" value="'.$url.
1980: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1981: &mt($message,' <input type="hidden" name="'.
1982: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1983: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1984: $help{'Caching'}.'</p></form>'."\n\n");
1985: }
1986:
1987:
1988: sub init_breadcrumbs {
1989: my ($form,$text)=@_;
1990: &Apache::lonhtmlcommon::clear_breadcrumbs();
1991: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs",
1992: text=>&Apache::loncommon::course_type().' Editor',
1993: faq=>273,
1994: bug=>'Instructor Interface',
1995: help => 'Docs_Adding_Course_Doc'});
1996: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
1997: text=>$text,
1998: faq=>273,
1999: bug=>'Instructor Interface'});
2000: }
2001:
2002: # subroutine to list form elements
2003: sub create_list_elements {
2004: my @formarr = @_;
2005: my $list = '';
2006: for my $button (@formarr){
2007: for my $picture(keys %$button) {
2008: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'});
2009: }
2010: }
2011: return $list;
2012: }
2013:
2014: # subroutine to create ul from list elements
2015: sub create_form_ul {
2016: my $list = shift;
2017: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
2018: return $ul;
2019: }
2020:
2021: #
2022: # Start tabs
2023: #
2024:
2025: sub startContentScreen {
2026: my ($r,$mode)=@_;
2027: $r->print('<ul class="LC_TabContentBigger" id="mainnav">');
2028: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
2029: $r->print('<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n");
2030: $r->print('<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n");
2031: $r->print('<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'."\n");
2032: $r->print('<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>');
2033: } else {
2034: $r->print('<li '.(($mode eq 'docs')?' class="active"':'').
2035: ' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Content Editor').' </b></a></li>');
2036: $r->print('<li '.(($mode eq 'suppdocs')?' class="active"':'').
2037: '><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>');
2038: }
2039: $r->print("\n".'</ul>'."\n");
2040: $r->print('<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
2041: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
2042: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">');
2043: }
2044:
2045: #
2046: # End tabs
2047: #
2048:
2049: sub endContentScreen {
2050: my ($r)=@_;
2051: $r->print('</div></div></div>');
2052: }
2053:
2054: sub supplemental_base {
2055: return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Content'));
2056: }
2057:
2058: sub handler {
2059: my $r = shift;
2060: &Apache::loncommon::content_type($r,'text/html');
2061: $r->send_http_header;
2062: return OK if $r->header_only;
2063: my $crstype = &Apache::loncommon::course_type();
2064:
2065: #
2066: # --------------------------------------------- Initialize help topics for this
2067: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
2068: 'Adding_External_Resource','Navigate_Content',
2069: 'Adding_Folders','Docs_Overview', 'Load_Map',
2070: 'Supplemental','Score_Upload_Form','Adding_Pages',
2071: 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
2072: 'Check_Resource_Versions','Verify_Content') {
2073: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
2074: }
2075: # Composite help files
2076: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
2077: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
2078: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
2079: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
2080: $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
2081: 'Option_Response_Simple');
2082: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
2083: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
2084: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
2085: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
2086: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
2087: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
2088:
2089:
2090: my $allowed;
2091: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
2092: unless ($r->uri eq '/adm/supplemental') {
2093: # does this user have privileges to modify content.
2094: $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
2095: }
2096:
2097: if ($allowed && $env{'form.verify'}) {
2098: &init_breadcrumbs('verify','Verify Content');
2099: &verifycontent($r);
2100: } elsif ($allowed && $env{'form.listsymbs'}) {
2101: &init_breadcrumbs('listsymbs','List Symbs');
2102: &list_symbs($r);
2103: } elsif ($allowed && $env{'form.docslog'}) {
2104: &init_breadcrumbs('docslog','Show Log');
2105: &docs_change_log($r);
2106: } elsif ($allowed && $env{'form.versions'}) {
2107: &init_breadcrumbs('versions','Check/Set Resource Versions');
2108: &checkversions($r);
2109: } elsif ($allowed && $env{'form.dumpcourse'}) {
2110: &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' Documents to Construction Space');
2111: &dumpcourse($r);
2112: } elsif ($allowed && $env{'form.exportcourse'}) {
2113: &init_breadcrumbs('exportcourse','IMS Export');
2114: &Apache::imsexport::exportcourse($r);
2115: } else {
2116: #
2117: # Done catching special calls
2118: # The whole rest is for course and supplemental documents
2119: # Get the parameters that may be needed
2120: #
2121: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
2122: ['folderpath','pagepath',
2123: 'pagesymb','forcesupplement','forcestandard',
2124: 'symb','command']);
2125:
2126: # standard=1: this is a "new-style" course with an uploaded map as top level
2127: # standard=2: this is a "old-style" course, and there is nothing we can do
2128:
2129: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
2130:
2131: # Decide whether this should display supplemental or main content
2132: # supplementalflag=1: show supplemental documents
2133: # supplementalflag=0: show standard documents
2134:
2135:
2136: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
2137: if (($env{'form.folderpath'}=~/^default/) || $env{'form.folderpath'} eq "" || ($env{'form.pagepath'})) {
2138: $supplementalflag=0;
2139: }
2140: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
2141: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
2142: unless ($allowed) { $supplementalflag=1; }
2143: unless ($standard) { $supplementalflag=1; }
2144:
2145: my $script='';
2146: my $showdoc=0;
2147: my $addentries = {};
2148: my $container;
2149: my $containertag;
2150: my $uploadtag;
2151:
2152: # Do we directly jump somewhere?
2153:
2154: if ($env{'form.command'} eq 'direct') {
2155: my ($mapurl,$id,$resurl);
2156: if ($env{'form.symb'} ne '') {
2157: ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
2158: if ($resurl=~/\.(sequence|page)$/) {
2159: $mapurl=$resurl;
2160: } elsif ($resurl eq 'adm/navmaps') {
2161: $mapurl=$env{'course.'.$env{'request.course.id'}.'.url'};
2162: }
2163: my $mapresobj;
2164: my $navmap = Apache::lonnavmaps::navmap->new();
2165: if (ref($navmap)) {
2166: $mapresobj = $navmap->getResourceByUrl($mapurl);
2167: }
2168: $mapurl=~s{^.*/([^/]+)\.(\w+)$}{$1};
2169: my $type=$2;
2170: my $path;
2171: if (ref($mapresobj)) {
2172: my $pcslist = $mapresobj->map_hierarchy();
2173: if ($pcslist ne '') {
2174: foreach my $pc (split(/,/,$pcslist)) {
2175: next if ($pc <= 1);
2176: my $res = $navmap->getByMapPc($pc);
2177: if (ref($res)) {
2178: my $thisurl = $res->src();
2179: $thisurl=~s{^.*/([^/]+)\.\w+$}{$1};
2180: my $thistitle = $res->title();
2181: $path .= '&'.
2182: &Apache::lonhtmlcommon::entity_encode($thisurl).'&'.
2183: &Apache::lonhtmlcommon::entity_encode($thistitle).
2184: ':'.$res->randompick().
2185: ':'.$res->randomout().
2186: ':'.$res->encrypted().
2187: ':'.$res->randomorder();
2188: }
2189: }
2190: }
2191: $path .= '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
2192: &Apache::lonhtmlcommon::entity_encode($mapresobj->title()).
2193: ':'.$mapresobj->randompick().
2194: ':'.$mapresobj->randomout().
2195: ':'.$mapresobj->encrypted().
2196: ':'.$mapresobj->randomorder();
2197: } else {
2198: my $maptitle = &Apache::lonnet::gettitle($mapurl);
2199: $path = '&default&...::::'.
2200: '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
2201: &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
2202: }
2203: $path = 'default&'.
2204: &Apache::lonhtmlcommon::entity_encode('Main Course Documents').
2205: $path;
2206: if ($type eq 'sequence') {
2207: $env{'form.folderpath'}=$path;
2208: $env{'form.pagepath'}='';
2209: } else {
2210: $env{'form.pagepath'}=$path;
2211: $env{'form.folderpath'}='';
2212: }
2213: } elsif ($env{'form.supppath'} ne '') {
2214: $env{'form.folderpath'}=$env{'form.supppath'};
2215: }
2216: } elsif ($env{'form.command'} eq 'editdocs') {
2217: $env{'form.folderpath'} = 'default&'.
2218: &Apache::lonhtmlcommon::entity_encode('Main Course Content');
2219: $env{'form.pagepath'}='';
2220: } elsif ($env{'form.command'} eq 'editsupp') {
2221: $env{'form.folderpath'} = 'default&'.
2222: &Apache::lonhtmlcommon::entity_encode('Supplemental Content');
2223: $env{'form.pagepath'}='';
2224: }
2225:
2226: # Where do we store these for when we come back?
2227: my $stored_folderpath='docs_folderpath';
2228: if ($supplementalflag) {
2229: $stored_folderpath='docs_sup_folderpath';
2230: }
2231:
2232: # No folderpath, no pagepath, see if we have something stored
2233: if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
2234: &Apache::loncommon::restore_course_settings($stored_folderpath,
2235: {'folderpath' => 'scalar'});
2236: }
2237:
2238: # If we are not allowed to make changes, all we can see are supplemental docs
2239: if (!$allowed) {
2240: $env{'form.pagepath'}='';
2241: unless ($env{'form.folderpath'} =~ /^supplemental/) {
2242: $env{'form.folderpath'} = &supplemental_base();
2243: }
2244: }
2245: # If we still not have a folderpath, see if we can resurrect at pagepath
2246: if (!$env{'form.folderpath'} && $allowed) {
2247: &Apache::loncommon::restore_course_settings($stored_folderpath,
2248: {'pagepath' => 'scalar'});
2249: }
2250: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
2251: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
2252: $env{'form.folderpath'} = &supplemental_base()
2253: .'&'.
2254: $env{'form.folderpath'};
2255: }
2256: # If after all of this, we still don't have any paths, make them
2257: unless (($env{'form.pagepath'}) || ($env{'form.folderpath'})) {
2258: if ($supplementalflag) {
2259: $env{'form.folderpath'}=&supplemental_base();
2260: } else {
2261: $env{'form.folderpath'}='default';
2262: }
2263: }
2264:
2265: # Store this
2266: &Apache::loncommon::store_course_settings($stored_folderpath,
2267: {'pagepath' => 'scalar',
2268: 'folderpath' => 'scalar'});
2269:
2270: if ($env{'form.folderpath'}) {
2271: my (@folderpath)=split('&',$env{'form.folderpath'});
2272: $env{'form.foldername'}=&unescape(pop(@folderpath));
2273: $env{'form.folder'}=pop(@folderpath);
2274: $container='sequence';
2275: }
2276: if ($env{'form.pagepath'}) {
2277: my (@pagepath)=split('&',$env{'form.pagepath'});
2278: $env{'form.pagename'}=&unescape(pop(@pagepath));
2279: $env{'form.folder'}=pop(@pagepath);
2280: $container='page';
2281: $containertag = '<input type="hidden" name="pagepath" value="" />'.
2282: '<input type="hidden" name="pagesymb" value="" />';
2283: $uploadtag =
2284: '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
2285: '<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />'.
2286: '<input type="hidden" name="folderpath" value="" />';
2287: } else {
2288: my $folderpath=$env{'form.folderpath'};
2289: if (!$folderpath) {
2290: if ($env{'form.folder'} eq '' ||
2291: $env{'form.folder'} eq 'supplemental') {
2292: $folderpath='default&'.
2293: &escape(&mt('Main '.$crstype.' Documents'));
2294: }
2295: }
2296: $containertag = '<input type="hidden" name="folderpath" value="" />';
2297: $uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
2298: }
2299: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
2300: $showdoc='/'.$1;
2301: }
2302: if ($showdoc) { # got called in sequence from course
2303: $allowed=0;
2304: } else {
2305: if ($allowed) {
2306: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
2307: $script=&Apache::lonratedt::editscript('simple');
2308: }
2309: }
2310:
2311: # get course data
2312: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
2313: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
2314:
2315: # get personal data
2316: my $uname=$env{'user.name'};
2317: my $udom=$env{'user.domain'};
2318: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
2319:
2320: # graphics settings
2321:
2322: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
2323:
2324: if ($allowed) {
2325: my @tabids;
2326: if ($supplementalflag) {
2327: @tabids = ('002','ee2','ff2');
2328: } else {
2329: @tabids = ('aa1','bb1','cc1','ff1');
2330: unless ($env{'form.pagepath'}) {
2331: unshift(@tabids,'001');
2332: push(@tabids,('dd1','ee1'));
2333: }
2334: }
2335: my $tabidstr = join("','",@tabids);
2336: $script .= &editing_js($udom,$uname,$supplementalflag).
2337: &resize_contentdiv_js($tabidstr);
2338: $addentries = {
2339: onload => "javascript:resize_contentdiv('contentscroll','1','1');",
2340: };
2341: }
2342: # -------------------------------------------------------------------- Body tag
2343: $script = '<script type="text/javascript">'."\n"
2344: .'// <![CDATA['."\n"
2345: .$script."\n"
2346: .'// ]]>'."\n"
2347: .'</script>'."\n";
2348:
2349: # Breadcrumbs
2350: &Apache::lonhtmlcommon::clear_breadcrumbs();
2351: unless ($showdoc) {
2352: &Apache::lonhtmlcommon::add_breadcrumb({
2353: href=>"/adm/coursedocs",text=>"$crstype Contents"});
2354:
2355: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
2356: {'force_register' => $showdoc,
2357: 'add_entries' => $addentries,
2358: })
2359: .&Apache::loncommon::help_open_menu('','',273,'RAT')
2360: .&Apache::lonhtmlcommon::breadcrumbs(
2361: 'Editing the Table of Contents for your '.$crstype,
2362: 'Docs_Adding_Course_Doc')
2363: );
2364: } else {
2365: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
2366: {'force_register' => $showdoc,}));
2367: }
2368:
2369: my %allfiles = ();
2370: my %codebase = ();
2371: my ($upload_result,$upload_output,$uploadphase);
2372: if ($allowed) {
2373: if (($env{'form.uploaddoc.filename'}) &&
2374: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
2375: my $context = $1;
2376: # Process file upload - phase one - upload and parse primary file.
2377: undef($hadchanges);
2378: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
2379: \%allfiles,\%codebase,$context);
2380: if ($hadchanges) {
2381: &mark_hash_old();
2382: }
2383: $r->print($upload_output);
2384: } elsif ($env{'form.phase'} eq 'upload_embedded') {
2385: # Process file upload - phase two - upload embedded objects
2386: $uploadphase = 'check_embedded';
2387: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
2388: my $state = &embedded_form_elems($uploadphase,$primaryurl,
2389: $env{'form.newidx'});
2390: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
2391: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
2392: my ($destination,$dir_root) = &embedded_destination();
2393: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
2394: my $actionurl = '/adm/coursedocs';
2395: my ($result,$flag) =
2396: &Apache::loncommon::upload_embedded('coursedoc',$destination,
2397: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
2398: $actionurl);
2399: $r->print($result.&return_to_editor());
2400: } elsif ($env{'form.phase'} eq 'check_embedded') {
2401: # Process file upload - phase three - modify references in HTML file
2402: $uploadphase = 'modified_orightml';
2403: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
2404: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
2405: my ($destination,$dir_root) = &embedded_destination();
2406: $r->print(&Apache::loncommon::modify_html_refs('coursedoc',$destination,
2407: $docuname,$docudom,undef,
2408: $dir_root).
2409: &return_to_editor());
2410: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
2411: $uploadphase = 'decompress_phase_one';
2412: $r->print(&decompression_phase_one().
2413: &return_to_editor());
2414: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
2415: $uploadphase = 'decompress_phase_two';
2416: $r->print(&decompression_phase_two().
2417: &return_to_editor());
2418: }
2419: }
2420:
2421: unless ($showdoc || $uploadphase) {
2422: # -----------------------------------------------------------------------------
2423: my %lt=&Apache::lonlocal::texthash(
2424: 'uplm' => 'Upload a new main '.lc($crstype).' document',
2425: 'upls' => 'Upload a new supplemental '.lc($crstype).' document',
2426: 'impp' => 'Import a document',
2427: 'copm' => 'All documents out of a published map into this folder',
2428: 'upld' => 'Import Document',
2429: 'srch' => 'Search',
2430: 'impo' => 'Import',
2431: 'wish' => 'Import from Wishlist',
2432: 'selm' => 'Select Map',
2433: 'load' => 'Load Map',
2434: 'reco' => 'Recover Deleted Documents',
2435: 'newf' => 'New Folder',
2436: 'newp' => 'New Composite Page',
2437: 'extr' => 'External Resource',
2438: 'syll' => 'Syllabus',
2439: 'navc' => 'Table of Contents',
2440: 'sipa' => 'Simple Course Page',
2441: 'sipr' => 'Simple Problem',
2442: 'drbx' => 'Drop Box',
2443: 'scuf' => 'External Scores (handgrade, upload, clicker)',
2444: 'bull' => 'Discussion Board',
2445: 'mypi' => 'My Personal Information Page',
2446: 'grpo' => 'Group Portfolio',
2447: 'rost' => 'Course Roster',
2448: 'abou' => 'Personal Information Page for a User',
2449: 'imsf' => 'IMS Import',
2450: 'imsl' => 'Import IMS package',
2451: 'file' => 'File',
2452: 'title' => 'Title',
2453: 'comment' => 'Comment',
2454: 'parse' => 'Upload embedded images/multimedia files if HTML file',
2455: 'nd' => 'Upload Document',
2456: 'pm' => 'Published Map',
2457: 'sd' => 'Special Document',
2458: 'mo' => 'More Options',
2459: );
2460: # -----------------------------------------------------------------------------
2461: my $fileupload=(<<FIUP);
2462: $lt{'file'}:<br />
2463: <input type="file" name="uploaddoc" size="40" />
2464: FIUP
2465:
2466: my $checkbox=(<<CHBO);
2467: <!-- <label>$lt{'parse'}?
2468: <input type="checkbox" name="parserflag" />
2469: </label> -->
2470: <label>
2471: <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
2472: </label>
2473: CHBO
2474:
2475: my $fileuploada = "<br clear='all' /><input type='submit' value='".$lt{'upld'}."' /> $help{'Uploading_From_Harddrive'}";
2476: my $fileuploadform=(<<FUFORM);
2477: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
2478: <input type="hidden" name="active" value="aa" />
2479: $fileupload
2480: <br />
2481: $lt{'title'}:<br />
2482: <input type="text" size="60" name="comment" />
2483: $uploadtag
2484: <input type="hidden" name="cmd" value="upload_default" />
2485: <br />
2486: <span class="LC_nobreak" style="float:left">
2487: $checkbox
2488: </span>
2489: FUFORM
2490: $fileuploadform .= $fileuploada.'</form>';
2491:
2492: my $simpleeditdefaultform=(<<SEDFFORM);
2493: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
2494: <input type="hidden" name="active" value="bb" />
2495: SEDFFORM
2496: my @simpleeditdefaultforma = (
2497: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => "$uploadtag<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" },
2498: { '<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'}" },
2499: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{wish}.'" onclick="javascript:open_Wishlist_Import();" />' => "<a class='LC_menubuttons_link' href='javascript:open_Wishlist_Import();'>$lt{'wish'}</a>" },
2500: );
2501: $simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma));
2502: $simpleeditdefaultform .=(<<SEDFFORM);
2503: <hr id="bb_hrule" style="width:0px;text-align:left;margin-left:0" />
2504: $lt{'copm'}<br />
2505: <input type="text" size="40" name="importmap" /><br />
2506: <span class="LC_nobreak" style="float:left"><input type="button"
2507: onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
2508: value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
2509: $help{'Load_Map'}</span>
2510: </form>
2511: SEDFFORM
2512:
2513: my $extresourcesform=(<<ERFORM);
2514: <form action="/adm/coursedocs" method="post" name="newext">
2515: $uploadtag
2516: <input type="hidden" name="importdetail" value="" />
2517: <a class="LC_menubuttons_link" href="javascript:makenewext('newext');">$lt{'extr'}</a>$help{'Adding_External_Resource'}
2518: </form>
2519: ERFORM
2520:
2521:
2522: if ($allowed) {
2523: &update_paste_buffer($coursenum,$coursedom);
2524: my %lt=&Apache::lonlocal::texthash(
2525: 'vc' => 'Verify Content',
2526: 'cv' => 'Check/Set Resource Versions',
2527: 'ls' => 'List Symbs',
2528: 'sl' => 'Show Log'
2529: );
2530:
2531: $r->print(<<HIDDENFORM);
2532: <form name="renameform" method="post" action="/adm/coursedocs">
2533: <input type="hidden" name="title" />
2534: <input type="hidden" name="cmd" />
2535: <input type="hidden" name="markcopy" />
2536: <input type="hidden" name="copyfolder" />
2537: $containertag
2538: </form>
2539: <form name="simpleedit" method="post" action="/adm/coursedocs">
2540: <input type="hidden" name="importdetail" value="" />
2541: $uploadtag
2542: </form>
2543: HIDDENFORM
2544: }
2545:
2546: # Generate the tabs
2547: my $mode;
2548: if (($supplementalflag) && (!$allowed)) {
2549: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
2550: } else {
2551: &startContentScreen($r,($supplementalflag?'suppdocs':'docs'));
2552: }
2553:
2554: #
2555:
2556: my $savefolderpath;
2557:
2558: if ($allowed) {
2559: my $folder=$env{'form.folder'};
2560: if ($folder eq '' || $supplementalflag) {
2561: $folder='default';
2562: $savefolderpath = $env{'form.folderpath'};
2563: $env{'form.folderpath'}='default&'.&escape(&mt('Content'));
2564: $uploadtag = '<input type="hidden" name="folderpath" value="'.
2565: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
2566: }
2567: my $postexec='';
2568: if ($folder eq 'default') {
2569: $r->print('<script type="text/javascript">'."\n"
2570: .'// <![CDATA['."\n"
2571: .'this.window.name="loncapaclient";'."\n"
2572: .'// ]]>'."\n"
2573: .'</script>'."\n"
2574: );
2575: } else {
2576: #$postexec='self.close();';
2577: }
2578: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
2579: '.sequence';
2580: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
2581: '.page';
2582: my $container='sequence';
2583: if ($env{'form.pagepath'}) {
2584: $container='page';
2585: }
2586: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
2587:
2588:
2589:
2590: my $recoverform=(<<RFORM);
2591: <form action="/adm/groupsort" method="post" name="recover">
2592: <a class="LC_menubuttons_link" href="javascript:groupopen('$readfile',1)">$lt{'reco'}</a>
2593: </form>
2594: RFORM
2595:
2596: my $imspform=(<<IMSPFORM);
2597: <form action="/adm/imsimportdocs" method="post" name="ims">
2598: <input type="hidden" name="folder" value="$folder" />
2599: <a class="LC_menubuttons_link" href="javascript:makeims();">$lt{'imsf'}</a>
2600: </form>
2601: IMSPFORM
2602:
2603: my $newnavform=(<<NNFORM);
2604: <form action="/adm/coursedocs" method="post" name="newnav">
2605: <input type="hidden" name="active" value="cc" />
2606: $uploadtag
2607: <input type="hidden" name="importdetail"
2608: value="$lt{'navc'}=/adm/navmaps" />
2609: <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
2610: $help{'Navigate_Content'}
2611: </form>
2612: NNFORM
2613: my $newsmppageform=(<<NSPFORM);
2614: <form action="/adm/coursedocs" method="post" name="newsmppg">
2615: <input type="hidden" name="active" value="cc" />
2616: $uploadtag
2617: <input type="hidden" name="importdetail" value="" />
2618: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
2619: $help{'Simple Page'}
2620: </form>
2621: NSPFORM
2622:
2623: my $newsmpproblemform=(<<NSPROBFORM);
2624: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
2625: <input type="hidden" name="active" value="cc" />
2626: $uploadtag
2627: <input type="hidden" name="importdetail" value="" />
2628: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
2629: $help{'Simple Problem'}
2630: </form>
2631:
2632: NSPROBFORM
2633:
2634: my $newdropboxform=(<<NDBFORM);
2635: <form action="/adm/coursedocs" method="post" name="newdropbox">
2636: <input type="hidden" name="active" value="cc" />
2637: $uploadtag
2638: <input type="hidden" name="importdetail" value="" />
2639: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
2640: </form>
2641: NDBFORM
2642:
2643: my $newexuploadform=(<<NEXUFORM);
2644: <form action="/adm/coursedocs" method="post" name="newexamupload">
2645: <input type="hidden" name="active" value="cc" />
2646: $uploadtag
2647: <input type="hidden" name="importdetail" value="" />
2648: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
2649: $help{'Score_Upload_Form'}
2650: </form>
2651: NEXUFORM
2652:
2653: my $newbulform=(<<NBFORM);
2654: <form action="/adm/coursedocs" method="post" name="newbul">
2655: <input type="hidden" name="active" value="cc" />
2656: $uploadtag
2657: <input type="hidden" name="importdetail" value="" />
2658: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
2659: $help{'Bulletin Board'}
2660: </form>
2661: NBFORM
2662:
2663: my $newaboutmeform=(<<NAMFORM);
2664: <form action="/adm/coursedocs" method="post" name="newaboutme">
2665: <input type="hidden" name="active" value="cc" />
2666: $uploadtag
2667: <input type="hidden" name="importdetail"
2668: value="$plainname=/adm/$udom/$uname/aboutme" />
2669: <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
2670: $help{'My Personal Information Page'}
2671: </form>
2672: NAMFORM
2673:
2674: my $newaboutsomeoneform=(<<NASOFORM);
2675: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
2676: <input type="hidden" name="active" value="cc" />
2677: $uploadtag
2678: <input type="hidden" name="importdetail" value="" />
2679: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
2680: </form>
2681: NASOFORM
2682:
2683:
2684: my $newrosterform=(<<NROSTFORM);
2685: <form action="/adm/coursedocs" method="post" name="newroster">
2686: <input type="hidden" name="active" value="cc" />
2687: $uploadtag
2688: <input type="hidden" name="importdetail"
2689: value="$lt{'rost'}=/adm/viewclasslist" />
2690: <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
2691: $help{'Course Roster'}
2692: </form>
2693: NROSTFORM
2694:
2695: my $specialdocumentsform;
2696: my @specialdocumentsforma;
2697: my $gradingform;
2698: my @gradingforma;
2699: my $communityform;
2700: my @communityforma;
2701: my $newfolderform;
2702: my $newfolderb;
2703:
2704: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
2705:
2706: my $newpageform=(<<NPFORM);
2707: <form action="/adm/coursedocs" method="post" name="newpage">
2708: <input type="hidden" name="folderpath" value="$path" />
2709: <input type="hidden" name="importdetail" value="" />
2710: <input type="hidden" name="active" value="cc" />
2711: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
2712: $help{'Adding_Pages'}
2713: </form>
2714: NPFORM
2715:
2716:
2717: $newfolderform=(<<NFFORM);
2718: <form action="/adm/coursedocs" method="post" name="newfolder">
2719: <input type="hidden" name="folderpath" value="$path" />
2720: <input type="hidden" name="importdetail" value="" />
2721: <input type="hidden" name="active" value="aa" />
2722: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
2723: </form>
2724: NFFORM
2725:
2726: my $newsylform=(<<NSYLFORM);
2727: <form action="/adm/coursedocs" method="post" name="newsyl">
2728: <input type="hidden" name="active" value="cc" />
2729: $uploadtag
2730: <input type="hidden" name="importdetail"
2731: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
2732: <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
2733: $help{'Syllabus'}
2734:
2735: </form>
2736: NSYLFORM
2737:
2738: my $newgroupfileform=(<<NGFFORM);
2739: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
2740: <input type="hidden" name="active" value="cc" />
2741: $uploadtag
2742: <input type="hidden" name="importdetail"
2743: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
2744: <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
2745: $help{'Group Portfolio'}
2746: </form>
2747: NGFFORM
2748: @specialdocumentsforma=(
2749: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'" onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform},
2750: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
2751: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
2752: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
2753: );
2754: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
2755:
2756:
2757: my @importdoc = (
2758: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'newext\');" />'=>$extresourcesform},
2759: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:makeims();" />'=>$imspform},);
2760: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc)) . '<hr id="cc_hrule" style="width:0px;text-align:left;margin-left:0" />' . $fileuploadform;
2761:
2762: @gradingforma=(
2763: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
2764: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
2765: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
2766:
2767: );
2768: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
2769:
2770: @communityforma=(
2771: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
2772: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
2773: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
2774: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},
2775: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
2776: );
2777: $communityform = &create_form_ul(&create_list_elements(@communityforma));
2778:
2779:
2780:
2781: my @tools = (
2782: # {'<img class="LC_noBorder LC_middle" align="left" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" />'=>$extresourcesform},
2783: # {'<img class="LC_noBorder LC_middle" align="left" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" />'=>$imspform},
2784: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/recover.png" alt="'.$lt{reco}.'" onclick="javascript:groupopen(\''.$readfile.'\',1)" />'=>$recoverform},
2785: );
2786:
2787: my %orderhash = (
2788: 'aa' => ['Import Documents',$fileuploadform],
2789: 'bb' => ['Published Resources',$simpleeditdefaultform],
2790: 'cc' => ['Grading Resources',$gradingform],
2791: 'ff' => ['Tools', &create_form_ul(&create_list_elements(@tools)).&generate_admin_options(\%help,\%env)],
2792: );
2793: unless ($env{'form.pagepath'}) {
2794: $orderhash{'00'} = ['Newfolder',$newfolderform];
2795: $orderhash{'dd'} = ['Community Resources',$communityform];
2796: $orderhash{'ee'} = ['Special Documents',$specialdocumentsform];
2797: }
2798:
2799: $hadchanges=0;
2800: unless ($supplementalflag) {
2801: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
2802: $supplementalflag,\%orderhash,$iconpath);
2803: if ($error) {
2804: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
2805: }
2806: if ($hadchanges) {
2807: &mark_hash_old();
2808: }
2809:
2810: &changewarning($r,'');
2811: }
2812: }
2813:
2814: # Supplemental documents start here
2815:
2816: my $folder=$env{'form.folder'};
2817: unless ($supplementalflag) {
2818: $folder='supplemental';
2819: }
2820: if ($folder =~ /^supplemental$/ &&
2821: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
2822: $env{'form.folderpath'} = &supplemental_base();
2823: } elsif ($allowed) {
2824: $env{'form.folderpath'} = $savefolderpath;
2825: }
2826: $env{'form.pagepath'} = '';
2827: if ($allowed) {
2828: my $folderseq=
2829: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
2830: '.sequence';
2831:
2832: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
2833:
2834: my $supupdocformbtn = "<input type='submit' value='".$lt{'upld'}."' />$help{'Uploading_From_Harddrive'}";
2835: my $supupdocform=(<<SUPDOCFORM);
2836: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
2837: <input type="hidden" name="active" value="ee" />
2838: $fileupload
2839: <br />
2840: <br />
2841: <span class="LC_nobreak">
2842: $checkbox
2843: </span>
2844: <br /><br />
2845: $lt{'comment'}:<br />
2846: <textarea cols="50" rows="4" name="comment"></textarea>
2847: <br />
2848: <input type="hidden" name="folderpath" value="$path" />
2849: <input type="hidden" name="cmd" value="upload_supplemental" />
2850: SUPDOCFORM
2851: $supupdocform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'}))."</form>";
2852:
2853: my $supnewfolderform=(<<SNFFORM);
2854: <form action="/adm/coursedocs" method="post" name="supnewfolder">
2855: <input type="hidden" name="active" value="ee" />
2856: <input type="hidden" name="folderpath" value="$path" />
2857: <input type="hidden" name="importdetail" value="" />
2858: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
2859: $help{'Adding_Folders'}
2860: </form>
2861: SNFFORM
2862:
2863:
2864: my $supnewextform=(<<SNEFORM);
2865: <form action="/adm/coursedocs" method="post" name="supnewext">
2866: <input type="hidden" name="active" value="ff" />
2867: <input type="hidden" name="folderpath" value="$path" />
2868: <input type="hidden" name="importdetail" value="" />
2869: <a class="LC_menubuttons_link" href="javascript:makenewext('supnewext');">$lt{'extr'}</a> $help{'Adding_External_Resource'}
2870: </form>
2871: SNEFORM
2872:
2873: my $supnewsylform=(<<SNSFORM);
2874: <form action="/adm/coursedocs" method="post" name="supnewsyl">
2875: <input type="hidden" name="active" value="ff" />
2876: <input type="hidden" name="folderpath" value="$path" />
2877: <input type="hidden" name="importdetail"
2878: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
2879: <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
2880: $help{'Syllabus'}
2881: </form>
2882: SNSFORM
2883:
2884: my $supnewaboutmeform=(<<SNAMFORM);
2885: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
2886: <input type="hidden" name="active" value="ff" />
2887: <input type="hidden" name="folderpath" value="$path" />
2888: <input type="hidden" name="importdetail"
2889: value="$plainname=/adm/$udom/$uname/aboutme" />
2890: <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
2891: $help{'My Personal Information Page'}
2892: </form>
2893: SNAMFORM
2894:
2895:
2896: my @specialdocs = (
2897: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
2898: =>$supnewsylform},
2899: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
2900: =>$supnewaboutmeform},
2901: );
2902: my @supimportdoc = (
2903: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supnewext\');" />'
2904: =>$supnewextform},
2905: );
2906: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)) . '<hr id="ee_hrule" style="width:0px;text-align:left;margin-left:0" />' . $supupdocform;
2907: my %suporderhash = (
2908: '00' => ['Supnewfolder', $supnewfolderform],
2909: 'ee' => ['Import Documents',$supupdocform],
2910: 'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))]
2911: );
2912: if ($supplementalflag) {
2913: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
2914: $supplementalflag,\%suporderhash,$iconpath);
2915: if ($error) {
2916: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
2917: }
2918: }
2919: } elsif ($supplementalflag) {
2920: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
2921: $supplementalflag,'',$iconpath);
2922: if ($error) {
2923: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
2924: }
2925: }
2926:
2927: &endContentScreen($r);
2928:
2929: if ($allowed) {
2930: $r->print('
2931: <form method="post" name="extimport" action="/adm/coursedocs">
2932: <input type="hidden" name="title" />
2933: <input type="hidden" name="url" />
2934: <input type="hidden" name="useform" />
2935: <input type="hidden" name="residx" />
2936: </form>');
2937: }
2938: } else {
2939: unless ($uploadphase) {
2940: # -------------------------------------------------------- This is showdoc mode
2941: $r->print("<h1>".&mt('Uploaded Document').' - '.
2942: &Apache::lonnet::gettitle($r->uri).'</h1><p>'.
2943: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
2944: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
2945: }
2946: }
2947: }
2948: $r->print(&Apache::loncommon::end_page());
2949: return OK;
2950: }
2951:
2952: sub embedded_form_elems {
2953: my ($phase,$primaryurl,$newidx) = @_;
2954: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
2955: return <<STATE;
2956: <input type="hidden" name="folderpath" value="$folderpath" />
2957: <input type="hidden" name="cmd" value="upload_embedded" />
2958: <input type="hidden" name="newidx" value="$newidx" />
2959: <input type="hidden" name="phase" value="$phase" />
2960: <input type="hidden" name="primaryurl" value="$primaryurl" />
2961: STATE
2962: }
2963:
2964: sub embedded_destination {
2965: my $folder=$env{'form.folder'};
2966: my $destination = 'docs/';
2967: if ($folder =~ /^supplemental/) {
2968: $destination = 'supplemental/';
2969: }
2970: if (($folder eq 'default') || ($folder eq 'supplemental')) {
2971: $destination .= 'default/';
2972: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
2973: $destination .= $2.'/';
2974: }
2975: $destination .= $env{'form.newidx'};
2976: my $dir_root = '/userfiles';
2977: return ($destination,$dir_root);
2978: }
2979:
2980: sub return_to_editor {
2981: my $actionurl = '/adm/coursedocs';
2982: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
2983: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
2984: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
2985: '</a></p>';
2986: }
2987:
2988: sub decompression_info {
2989: my ($destination,$dir_root) = &embedded_destination();
2990: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
2991: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
2992: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
2993: my $container='sequence';
2994: my $hiddenelem;
2995: if ($env{'form.pagepath'}) {
2996: $container='page';
2997: $hiddenelem = '<input type="hidden" name="pagepath" value="'.$env{'form.pagepath'}.'" />'."\n";
2998: } else {
2999: $hiddenelem = '<input type="hidden" name="folderpath" value="'.$env{'form.folderpath'}.'" />'."\n";
3000: }
3001: if ($env{'form.newidx'}) {
3002: $hiddenelem .= '<input type="hidden" name="newidx" value="'.$env{'form.newidx'}.'" />'."\n";
3003: }
3004: if ($env{'form.comment'}) {
3005: $hiddenelem .= '<input type="hidden" name="comment" value="'.$env{'form.comment'}.'" />'."\n";
3006: }
3007: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
3008: $hiddenelem);
3009: }
3010:
3011: sub decompression_phase_one {
3012: my ($dir,$file,$warning,$error,$output);
3013: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
3014: &decompression_info();
3015: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/docs/\E(?:default|supplemental|\d+).*/([^/]+)$}) {
3016: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
3017: } else {
3018: my $file = $1;
3019: $output = &Apache::loncommon::process_decompression($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem);
3020: if ($env{'form.archivedelete'}) {
3021: my $map = $env{'form.folder'}.'.'.$container;
3022: my ($delwarning,$delresult);
3023: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
3024: if ($fatal) {
3025: if ($container eq 'page') {
3026: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
3027: } else {
3028: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
3029: }
3030: $delwarning .= &mt('As a result the archive file has not been removed.');
3031: } else {
3032: my $currcmd = $env{'form.cmd'};
3033: $env{'form.cmd'} = 'del_'.$env{'form.position'};
3034: if (&handle_edit_cmd($docuname,$docudom)) {
3035: ($errtext,$fatal) = &storemap($docuname,$docudom,$map);
3036: if ($fatal) {
3037: if ($container eq 'page') {
3038: $delwarning = &mt('An error occurred updating the contents of the current page.');
3039: } else {
3040: $delwarning = &mt('An error occurred updating the contents of the current folder.');
3041: }
3042: }
3043: }
3044: $env{'form.cmd'} = $currcmd;
3045: $delresult = &mt('Archive file removed after extracting files.');
3046: }
3047: if ($delwarning) {
3048: $output .= '<p class="LC_warning">'.
3049: $delwarning.
3050: '</p>';
3051: }
3052: if ($delresult) {
3053: $output .= '<p class="LC_info">'.
3054: $delresult.
3055: '</p>';
3056: }
3057: }
3058: }
3059: if ($error) {
3060: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
3061: $error.'</p>'."\n";
3062: }
3063: if ($warning) {
3064: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
3065: }
3066: return $output;
3067: }
3068:
3069: sub decompression_phase_two {
3070: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
3071: &decompression_info();
3072: my $output =
3073: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
3074: $destination,$dir_root,$hiddenelem);
3075: return $output;
3076: }
3077:
3078: sub generate_admin_options {
3079: my ($help_ref,$env_ref) = @_;
3080: my %lt=&Apache::lonlocal::texthash(
3081: 'vc' => 'Verify Content',
3082: 'cv' => 'Check/Set Resource Versions',
3083: 'ls' => 'List Symbs',
3084: 'sl' => 'Show Log',
3085: 'imse' => 'IMS Export',
3086: 'dcd' => 'Dump Course Documents to Construction Space: available on other servers'
3087: );
3088: my %help = %{$help_ref};
3089: my %env = %{$env_ref};
3090: my $dumpbut=&dumpbutton();
3091: my $exportbut=&exportbutton();
3092: my @list = (
3093: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/verify.png" alt="'.$lt{vc}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "verify", "'.$lt{'vc'}.'")\' />'
3094: => "<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"verify\", \"$lt{'vc'}\")'>$lt{'vc'}</a>$help{'Verify_Content'}"},
3095: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/resversion.png" alt="'.$lt{cv}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "versions", "'.$lt{'cv'}.'")\' />'
3096: =>"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"versions\", \"$lt{'cv'}\")'>$lt{'cv'}</a>$help{'Check_Resource_Versions'}"},
3097: );
3098: if($dumpbut ne ''){
3099: push @list, {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dump.png" alt="'.$lt{dcd}.'" />'=>$dumpbut};
3100: }
3101: push @list, ({'<img class="LC_noBorder LC_middle" src="/res/adm/pages/imsexport.png" alt="'.$lt{imse}.'" onclick="javascript:injectData(document.courseverify, \'dummy\', \'exportcourse\', \''.&mt('IMS Export').'\');" />'
3102: =>$exportbut},
3103: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/symbs.png" alt="'.$lt{ls}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "listsymbs", "'.$lt{'ls'}.'")\' />'
3104: =>"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"listsymbs\", \"$lt{'ls'}\")'>$lt{'ls'}</a><input type='hidden' name='folder' value='$env{'form.folder'}' />"},
3105: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/document-properties.png" alt="'.$lt{sl}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "docslog", "'.$lt{'sl'}.'")\' />'
3106: =>"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"docslog\", \"$lt{'sl'}\")'>$lt{'sl'}</a>"},
3107: );
3108: return '<form action="/adm/coursedocs" method="post" name="courseverify"><input type="hidden" id="dummy" />'.&create_form_ul(&create_list_elements(@list)).'</form>';
3109:
3110: }
3111:
3112:
3113: sub generate_edit_table {
3114: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto) = @_;
3115: return unless(ref($orderhash_ref) eq 'HASH');
3116: my %orderhash = %{$orderhash_ref};
3117: my $form;
3118: my $activetab;
3119: my $active;
3120: if($env{'form.active'} ne ''){
3121: $activetab = $env{'form.active'};
3122: }
3123: my $backicon = $iconpath.'clickhere.gif';
3124: my $backtext = &mt('Back to Overview');
3125: $form = '<div class="LC_Box" style="margin:0;">'.
3126: '<ul id="navigation'.$tid.'" class="LC_TabContent">'.
3127: '<li class="goback">'.
3128: '<a href="javascript:toContents('."'$jumpto'".');">'.
3129: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
3130: ' alt="'.$backtext.'" />'.$backtext.'</a></li>';
3131: foreach my $name (reverse(sort(keys(%orderhash)))) {
3132: if($name ne '00'){
3133: if($activetab eq '' || $activetab ne $name){
3134: $active = '';
3135: }elsif($activetab eq $name){
3136: $active = 'class="active"';
3137: }
3138: $form .= '<li style="float:right" '.$active
3139: .' onmouseover="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"'
3140: .' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>';
3141: } else {
3142: $form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>';
3143:
3144: }
3145: }
3146: $form .= '</ul>';
3147: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">';
3148:
3149: if ($to_show ne '') {
3150: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>';
3151: }
3152: foreach my $field (keys(%orderhash)){
3153: if($field ne '00'){
3154: if($activetab eq '' || $activetab ne $field){
3155: $active = 'style="display: none;float:left"';
3156: }elsif($activetab eq $field){
3157: $active = 'style="display:block;float:left"';
3158: }
3159: $form .= '<div id="'.$field.$tid.'"'
3160: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
3161: .'</div>';
3162: }
3163: }
3164: $form .= '</div></div>';
3165:
3166: return $form;
3167: }
3168:
3169: sub editing_js {
3170: my ($udom,$uname,$supplementalflag) = @_;
3171: my $now = time();
3172: my %lt = &Apache::lonlocal::texthash(
3173: p_mnf => 'Name of New Folder',
3174: t_mnf => 'New Folder',
3175: p_mnp => 'Name of New Page',
3176: t_mnp => 'New Page',
3177: p_mxu => 'Title for the External Score',
3178: p_msp => 'Name of Simple Course Page',
3179: p_msb => 'Title for the Problem',
3180: p_mdb => 'Title for the Drop Box',
3181: p_mbb => 'Title for the Discussion Board',
3182: p_mab => "Enter user:domain for User's Personal Information Page",
3183: p_mab2 => 'Personal Information Page of ',
3184: p_mab_alrt1 => 'Not a valid user:domain',
3185: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
3186: p_chn => 'New Title',
3187: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
3188: p_rmr2a => 'Remove[_99]',
3189: p_rmr2b => '?[_99]',
3190: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
3191: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
3192: p_ctr2a => 'Cut[_98]',
3193: p_ctr2b => '?[_98]',
3194: rpck => 'Enter number to pick (e.g., 3)',
3195: );
3196:
3197: my $crstype = &Apache::loncommon::course_type();
3198: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
3199: my $docs_pagepath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.pagepath'},'<>&"');
3200: my $main_container_page;
3201: if ($docs_folderpath eq '') {
3202: if ($docs_pagepath ne '') {
3203: $main_container_page = 1;
3204: }
3205: }
3206: my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents';
3207: my $toplevelsupp = &supplemental_base();
3208:
3209: my $backtourl = '/adm/navmaps';
3210: if ($supplementalflag) {
3211: $backtourl = '/adm/supplemental';
3212: }
3213:
3214: return <<ENDNEWSCRIPT;
3215: function makenewfolder(targetform,folderseq) {
3216: var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
3217: if (foldername) {
3218: targetform.importdetail.value=escape(foldername)+"="+folderseq;
3219: targetform.submit();
3220: }
3221: }
3222:
3223: function makenewpage(targetform,folderseq) {
3224: var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
3225: if (pagename) {
3226: targetform.importdetail.value=escape(pagename)+"="+folderseq;
3227: targetform.submit();
3228: }
3229: }
3230:
3231: function makenewext(targetname) {
3232: this.document.forms.extimport.useform.value=targetname;
3233: this.document.forms.extimport.title.value='';
3234: this.document.forms.extimport.url.value='';
3235: this.document.forms.extimport.residx.value='';
3236: window.open('/adm/rat/extpickframe.html');
3237: }
3238:
3239: function edittext(targetname,residx,title,url) {
3240: this.document.forms.extimport.useform.value=targetname;
3241: this.document.forms.extimport.residx.value=residx;
3242: this.document.forms.extimport.url.value=url;
3243: this.document.forms.extimport.title.value=title;
3244: window.open('/adm/rat/extpickframe.html');
3245: }
3246:
3247: function makeexamupload() {
3248: var title=prompt('$lt{"p_mxu"}');
3249: if (title) {
3250: this.document.forms.newexamupload.importdetail.value=
3251: escape(title)+'=/res/lib/templates/examupload.problem';
3252: this.document.forms.newexamupload.submit();
3253: }
3254: }
3255:
3256: function makesmppage() {
3257: var title=prompt('$lt{"p_msp"}');
3258: if (title) {
3259: this.document.forms.newsmppg.importdetail.value=
3260: escape(title)+'=/adm/$udom/$uname/$now/smppg';
3261: this.document.forms.newsmppg.submit();
3262: }
3263: }
3264:
3265: function makesmpproblem() {
3266: var title=prompt('$lt{"p_msb"}');
3267: if (title) {
3268: this.document.forms.newsmpproblem.importdetail.value=
3269: escape(title)+'=/res/lib/templates/simpleproblem.problem';
3270: this.document.forms.newsmpproblem.submit();
3271: }
3272: }
3273:
3274: function makedropbox() {
3275: var title=prompt('$lt{"p_mdb"}');
3276: if (title) {
3277: this.document.forms.newdropbox.importdetail.value=
3278: escape(title)+'=/res/lib/templates/DropBox.problem';
3279: this.document.forms.newdropbox.submit();
3280: }
3281: }
3282:
3283: function makebulboard() {
3284: var title=prompt('$lt{"p_mbb"}');
3285: if (title) {
3286: this.document.forms.newbul.importdetail.value=
3287: escape(title)+'=/adm/$udom/$uname/$now/bulletinboard';
3288: this.document.forms.newbul.submit();
3289: }
3290: }
3291:
3292: function makeabout() {
3293: var user=prompt("$lt{'p_mab'}");
3294: if (user) {
3295: var comp=new Array();
3296: comp=user.split(':');
3297: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
3298: if ((comp[0]) && (comp[1])) {
3299: this.document.forms.newaboutsomeone.importdetail.value=
3300: '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
3301: this.document.forms.newaboutsomeone.submit();
3302: } else {
3303: alert("$lt{'p_mab_alrt1'}");
3304: }
3305: } else {
3306: alert("$lt{'p_mab_alrt2'}");
3307: }
3308: }
3309: }
3310:
3311: function makeims() {
3312: var caller = document.forms.ims.folder.value;
3313: var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
3314: newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
3315: newWindow.location.href = newlocation;
3316: }
3317:
3318:
3319: function finishpick() {
3320: var title=this.document.forms.extimport.title.value;
3321: var url=this.document.forms.extimport.url.value;
3322: var form=this.document.forms.extimport.useform.value;
3323: var residx=this.document.forms.extimport.residx.value;
3324: eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();');
3325: }
3326:
3327: function changename(folderpath,index,oldtitle,container,pagesymb) {
3328: var title=prompt('$lt{"p_chn"}',oldtitle);
3329: if (title) {
3330: this.document.forms.renameform.markcopy.value=-1;
3331: this.document.forms.renameform.title.value=title;
3332: this.document.forms.renameform.cmd.value='rename_'+index;
3333: if (container == 'sequence') {
3334: this.document.forms.renameform.folderpath.value=folderpath;
3335: }
3336: if (container == 'page') {
3337: this.document.forms.renameform.pagepath.value=folderpath;
3338: this.document.forms.renameform.pagesymb.value=pagesymb;
3339: }
3340: this.document.forms.renameform.submit();
3341: }
3342: }
3343:
3344: function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) {
3345: if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
3346: this.document.forms.renameform.markcopy.value=-1;
3347: this.document.forms.renameform.cmd.value='del_'+index;
3348: if (container == 'sequence') {
3349: this.document.forms.renameform.folderpath.value=folderpath;
3350: }
3351: if (container == 'page') {
3352: this.document.forms.renameform.pagepath.value=folderpath;
3353: this.document.forms.renameform.pagesymb.value=pagesymb;
3354: }
3355: this.document.forms.renameform.submit();
3356: }
3357: }
3358:
3359: function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) {
3360: if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
3361: this.document.forms.renameform.cmd.value='cut_'+index;
3362: this.document.forms.renameform.markcopy.value=index;
3363: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
3364: if (container == 'sequence') {
3365: this.document.forms.renameform.folderpath.value=folderpath;
3366: }
3367: if (container == 'page') {
3368: this.document.forms.renameform.pagepath.value=folderpath;
3369: this.document.forms.renameform.pagesymb.value=pagesymb;
3370: }
3371: this.document.forms.renameform.submit();
3372: }
3373: }
3374:
3375: function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) {
3376: this.document.forms.renameform.markcopy.value=index;
3377: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
3378: if (container == 'sequence') {
3379: this.document.forms.renameform.folderpath.value=folderpath;
3380: }
3381: if (container == 'page') {
3382: this.document.forms.renameform.pagepath.value=folderpath;
3383: this.document.forms.renameform.pagesymb.value=pagesymb;
3384: }
3385: this.document.forms.renameform.submit();
3386: }
3387:
3388: function updatePick(targetform,index,caller) {
3389: var pickitem = document.getElementById('rpick_'+index);
3390: var picknumitem = document.getElementById('rpicknum_'+index);
3391: if (pickitem.checked) {
3392: var picknum=prompt('$lt{"rpck"}',picknumitem.value);
3393: if (picknum == '' || picknum == null) {
3394: if (caller == 'check') {
3395: pickitem.checked=false;
3396: return;
3397: }
3398: } else {
3399: picknum.toString();
3400: var regexdigit=/^\\d+\$/;
3401: if (regexdigit.test(picknum)) {
3402: picknumitem.value = picknum;
3403: targetform.changeparms.value='randompick';
3404: targetform.submit();
3405: } else {
3406: if (caller == 'check') {
3407: pickitem.checked=false;
3408: }
3409: return;
3410: }
3411: }
3412: } else {
3413: picknumitem.value = 0;
3414: targetform.changeparms.value='randompick';
3415: targetform.submit();
3416: }
3417: }
3418:
3419: function unselectInactive(nav) {
3420: currentNav = document.getElementById(nav);
3421: currentLis = currentNav.getElementsByTagName('LI');
3422: for (i = 0; i < currentLis.length; i++) {
3423: if (currentLis[i].className == 'goback') {
3424: currentLis[i].className = 'goback';
3425: } else {
3426: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
3427: currentLis[i].className = 'right';
3428: } else {
3429: currentLis[i].className = 'i';
3430: }
3431: }
3432: }
3433: }
3434:
3435: function hideAll(current, nav, data) {
3436: unselectInactive(nav);
3437: if(current.className == 'right'){
3438: current.className = 'right active'
3439: }else{
3440: current.className = 'active';
3441: }
3442: currentData = document.getElementById(data);
3443: currentDivs = currentData.getElementsByTagName('DIV');
3444: for (i = 0; i < currentDivs.length; i++) {
3445: if(currentDivs[i].className == 'LC_ContentBox'){
3446: currentDivs[i].style.display = 'none';
3447: }
3448: }
3449: }
3450:
3451: function openTabs(pageId) {
3452: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
3453: if(tabnav.length > 2 ){
3454: currentNav = document.getElementById(tabnav[1].id);
3455: currentLis = currentNav.getElementsByTagName('LI');
3456: for(i = 0; i< currentLis.length; i++){
3457: if(currentLis[i].className == 'active') {
3458: funcString = currentLis[i].onclick.toString();
3459: tab = funcString.split('"');
3460: if(tab.length < 2) {
3461: tab = funcString.split("'");
3462: }
3463: currentData = document.getElementById(tab[1]);
3464: currentData.style.display = 'block';
3465: }
3466: }
3467: }
3468: }
3469:
3470: function showPage(current, pageId, nav, data) {
3471: hideAll(current, nav, data);
3472: openTabs(pageId);
3473: unselectInactive(nav);
3474: current.className = 'active';
3475: currentData = document.getElementById(pageId);
3476: currentData.style.display = 'block';
3477: activeTab = pageId;
3478: if (nav == 'mainnav') {
3479: var storedpath = "$docs_folderpath";
3480: if (storedpath == '') {
3481: storedpath = "$docs_pagepath";
3482: }
3483: var storedpage = "$main_container_page";
3484: var reg = new RegExp("^supplemental");
3485: if (pageId == 'mainCourseDocuments') {
3486: if (storedpage == 1) {
3487: document.simpleedit.folderpath.value = '';
3488: document.uploaddocument.folderpath.value = '';
3489: } else {
3490: if (reg.test(storedpath)) {
3491: document.simpleedit.folderpath.value = '$toplevelmain';
3492: document.uploaddocument.folderpath.value = '$toplevelmain';
3493: document.newext.folderpath.value = '$toplevelmain';
3494: } else {
3495: document.simpleedit.folderpath.value = storedpath;
3496: document.uploaddocument.folderpath.value = storedpath;
3497: document.newext.folderpath.value = storedpath;
3498: }
3499: }
3500: } else {
3501: if (reg.test(storedpath)) {
3502: document.simpleedit.folderpath.value = storedpath;
3503: document.supuploaddocument.folderpath.value = storedpath;
3504: document.supnewext.folderpath.value = storedpath;
3505: } else {
3506: document.simpleedit.folderpath.value = '$toplevelsupp';
3507: document.supuploaddocument.folderpath.value = '$toplevelsupp';
3508: document.supnewext.folderpath.value = '$toplevelsupp';
3509: }
3510: }
3511: }
3512: resize_contentdiv('contentscroll','1','0');
3513: return false;
3514: }
3515:
3516: function injectData(current, hiddenField, name, value) {
3517: currentElement = document.getElementById(hiddenField);
3518: currentElement.name = name;
3519: currentElement.value = value;
3520: current.submit();
3521: }
3522:
3523: function toContents(jumpto) {
3524: var newurl = '$backtourl';
3525: if (jumpto != '') {
3526: newurl = newurl+'?postdata='+jumpto;
3527: ;
3528: }
3529: location.href=newurl;
3530: }
3531:
3532: ENDNEWSCRIPT
3533: }
3534:
3535: sub resize_contentdiv_js {
3536: my ($tabidstr) = @_;
3537: my $viewport_js = &Apache::loncommon::viewport_geometry_js();
3538: return <<ENDRESIZESCRIPT;
3539:
3540: window.onresize=resizeContentEditor;
3541:
3542: var activeTab;
3543:
3544: $viewport_js
3545:
3546: function resize_contentdiv(scrollboxname,chkw,chkh) {
3547: var scrollboxid = 'div_'+scrollboxname;
3548: var scrolltableid = 'table_'+scrollboxname;
3549: var scrollbox;
3550: var scrolltable;
3551:
3552: if (document.getElementById("contenteditor") == null) {
3553: return;
3554: }
3555:
3556: if (document.getElementById(scrollboxid) == null) {
3557: return;
3558: } else {
3559: scrollbox = document.getElementById(scrollboxid);
3560: }
3561:
3562: if (document.getElementById(scrolltableid) == null) {
3563: return;
3564: } else {
3565: scrolltable = document.getElementById(scrolltableid);
3566: }
3567:
3568: init_geometry();
3569: var vph = Geometry.getViewportHeight();
3570: var vpw = Geometry.getViewportWidth();
3571:
3572: var alltabs = ['$tabidstr'];
3573: var listwchange;
3574: if (chkw == 1) {
3575: var contenteditorw = document.getElementById("contenteditor").offsetWidth;
3576: var contentlistw;
3577: var contentlistid = document.getElementById("contentlist");
3578: if (contentlistid != null) {
3579: contentlistw = document.getElementById("contentlist").offsetWidth;
3580: }
3581: var contentlistwstart = contentlistw;
3582:
3583: var scrollboxw = scrollbox.offsetWidth;
3584: var scrollboxscrollw = scrollbox.scrollWidth;
3585:
3586: var offsetw = parseInt(vpw * 0.015);
3587: var paddingw = parseInt(vpw * 0.09);
3588:
3589: var minscrollboxw = 250;
3590:
3591: var maxtabw = 0;
3592: var actabw = 0;
3593: for (var i=0; i<alltabs.length; i++) {
3594: if (activeTab == alltabs[i]) {
3595: actabw = document.getElementById(alltabs[i]).offsetWidth;
3596: if (actabw > maxtabw) {
3597: maxtabw = actabw;
3598: }
3599: } else {
3600: if (document.getElementById(alltabs[i]) != null) {
3601: var thistab = document.getElementById(alltabs[i]);
3602: thistab.style.visibility = 'hidden';
3603: thistab.style.display = 'block';
3604: var tabw = document.getElementById(alltabs[i]).offsetWidth;
3605: thistab.style.display = 'none';
3606: thistab.style.visibility = '';
3607: if (tabw > maxtabw) {
3608: maxtabw = tabw;
3609: }
3610: }
3611: }
3612: }
3613:
3614: if (maxtabw > 0) {
3615: var newscrollboxw;
3616: if (maxtabw+paddingw+scrollboxscrollw<contenteditorw) {
3617: newscrollboxw = contenteditorw-paddingw-maxtabw;
3618: if (newscrollboxw < minscrollboxw) {
3619: newscrollboxw = minscrollboxw;
3620: }
3621: scrollbox.style.width = newscrollboxw+"px";
3622: if (newscrollboxw != scrollboxw) {
3623: var newcontentlistw = newscrollboxw-offsetw;
3624: contentlistid.style.width = newcontentlistw+"px";
3625: }
3626: } else {
3627: newscrollboxw = contenteditorw-paddingw-maxtabw;
3628: if (newscrollboxw < minscrollboxw) {
3629: newscrollboxw = minscrollboxw;
3630: }
3631: scrollbox.style.width = newscrollboxw+"px";
3632: if (newscrollboxw != scrollboxw) {
3633: var newcontentlistw = newscrollboxw-offsetw;
3634: contentlistid.style.width = newcontentlistw+"px";
3635: }
3636: }
3637:
3638: if (newscrollboxw != scrollboxw) {
3639: var newscrolltablew = newscrollboxw+offsetw;
3640: scrolltable.style.width = newscrolltablew+"px";
3641: }
3642: }
3643:
3644: if (contentlistid.offsetWidth != contentlistwstart) {
3645: listwchange = 1;
3646: }
3647:
3648: if (activeTab == 'cc1') {
3649: if (document.getElementById('cc_hrule') != null) {
3650: document.getElementById('cc_hrule').style.width=actabw+"px";
3651: }
3652: } else {
3653: if (activeTab == 'bb1') {
3654: if (document.getElementById('bb_hrule') != null) {
3655: document.getElementById('bb_hrule').style.width=actabw+"px";
3656: }
3657: } else {
3658: if (activeTab == 'ee2') {
3659: if (document.getElementById('ee_hrule') != null) {
3660: document.getElementById('ee_hrule').style.width=actabw+"px";
3661: }
3662: }
3663: }
3664: }
3665: }
3666: if ((chkh == 1) || (listwchange)) {
3667: var primaryheight = document.getElementById("LC_nav_bar").offsetHeight;
3668: var secondaryheight = document.getElementById("LC_secondary_menu").offsetHeight;
3669: var crumbsheight = document.getElementById("LC_breadcrumbs").offsetHeight;
3670: var dccidheight = document.getElementById("dccid").offsetHeight;
3671:
3672: var uploadresultheight = 0;
3673: if (document.getElementById("uploadfileresult") != null) {
3674: uploadresultheight = document.getElementById("uploadfileresult").offsetHeight;
3675: }
3676: var tabbedheight = document.getElementById("tabbededitor").offsetHeight;
3677: var contenteditorheight = document.getElementById("contenteditor").offsetHeight;
3678: var scrollboxheight = scrollbox.offsetHeight;
3679: var scrollboxscrollheight = scrollbox.scrollHeight;
3680: var freevspace = vph-(primaryheight+secondaryheight+crumbsheight+dccidheight+uploadresultheight+tabbedheight+contenteditorheight);
3681:
3682: var minvscrollbox = 200;
3683: var offsetv = 20;
3684: var newscrollboxheight;
3685: if (freevspace < 0) {
3686: newscrollboxheight = scrollboxheight+freevspace-offsetv;
3687: if (newscrollboxheight < minvscrollbox) {
3688: newscrollboxheight = minvscrollbox;
3689: }
3690: scrollbox.style.height = newscrollboxheight + "px";
3691: } else {
3692: if (scrollboxscrollheight > scrollboxheight) {
3693: if (freevspace > offsetv) {
3694: newscrollboxheight = scrollboxheight+freevspace-offsetv;
3695: if (newscrollboxheight < minvscrollbox) {
3696: newscrollboxheight = minvscrollbox;
3697: }
3698: scrollbox.style.height = newscrollboxheight+"px";
3699: }
3700: }
3701: }
3702: scrollboxheight = scrollbox.offsetHeight;
3703: var contentlistheight = document.getElementById("contentlist").offsetHeight;
3704:
3705: if (scrollboxscrollheight <= scrollboxheight) {
3706: if ((contentlistheight+offsetv)<scrollboxheight) {
3707: newscrollheight = contentlistheight+offsetv;
3708: scrollbox.style.height = newscrollheight+"px";
3709: }
3710: }
3711: }
3712: return;
3713: }
3714:
3715: function resizeContentEditor() {
3716: var timer;
3717: clearTimeout(timer)
3718: timer=setTimeout('resize_contentdiv("contentscroll","1","1")',500);
3719: }
3720:
3721: ENDRESIZESCRIPT
3722: return;
3723: }
3724:
3725: 1;
3726: __END__
3727:
3728:
3729: =head1 NAME
3730:
3731: Apache::londocs.pm
3732:
3733: =head1 SYNOPSIS
3734:
3735: This is part of the LearningOnline Network with CAPA project
3736: described at http://www.lon-capa.org.
3737:
3738: =head1 SUBROUTINES
3739:
3740: =over
3741:
3742: =item %help=()
3743:
3744: Available help topics
3745:
3746: =item mapread()
3747:
3748: Mapread read maps into LONCAPA::map:: global arrays
3749: @order and @resources, determines status
3750: sets @order - pointer to resources in right order
3751: sets @resources - array with the resources with correct idx
3752:
3753: =item authorhosts()
3754:
3755: Return hash with valid author names
3756:
3757: =item dumpbutton()
3758:
3759: Generate "dump" button
3760:
3761: =item clean()
3762:
3763: =item dumpcourse()
3764:
3765: Actually dump course
3766:
3767:
3768: =item exportbutton()
3769:
3770: Generate "export" button
3771:
3772: =item group_import()
3773:
3774: Imports the given (name, url) resources into the course
3775: coursenum, coursedom, and folder must precede the list
3776:
3777: =item breadcrumbs()
3778:
3779: =item log_docs()
3780:
3781: =item docs_change_log()
3782:
3783: =item update_paste_buffer()
3784:
3785: =item print_paste_buffer()
3786:
3787: =item do_paste_from_buffer()
3788:
3789: =item update_parameter()
3790:
3791: =item handle_edit_cmd()
3792:
3793: =item editor()
3794:
3795: =item process_file_upload()
3796:
3797: =item process_secondary_uploads()
3798:
3799: =item is_supplemental_title()
3800:
3801: =item parse_supplemental_title()
3802:
3803: =item entryline()
3804:
3805: =item tiehash()
3806:
3807: =item untiehash()
3808:
3809: =item checkonthis()
3810:
3811: check on this
3812:
3813: =item verifycontent()
3814:
3815: Verify Content
3816:
3817: =item devalidateversioncache() & checkversions()
3818:
3819: Check Versions
3820:
3821: =item mark_hash_old()
3822:
3823: =item is_hash_old()
3824:
3825: =item changewarning()
3826:
3827: =item init_breadcrumbs()
3828:
3829: Breadcrumbs for special functions
3830:
3831: =back
3832:
3833: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>