File:
[LON-CAPA] /
loncom /
interface /
londocs.pm
Revision
1.481:
download - view:
text,
annotated -
select for diffs
Sun Apr 8 22:34:58 2012 UTC (12 years, 4 months ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
- Extraction of contents of archive files (zip, tar etc.) from a file
uploaded directly to a course.
- Where session is server is not course's home server, prompt home server
to fetch files extracted from archive.
- For Camtasia zip files, give option to process contents automatically.
1: # The LearningOnline Network
2: # Documents
3: #
4: # $Id: londocs.pm,v 1.481 2012/04/08 22:34:58 raeburn 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: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
1125: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1126: $$upload_output = $showupload.
1127: &Apache::loncommon::decompress_form($mimetype,
1128: $archiveurl,'/adm/coursedocs',$noextract,
1129: \%archiveitems,\@current);
1130: }
1131: }
1132: }
1133: return $nextphase;
1134: }
1135:
1136: sub get_dir_list {
1137: my ($url,$coursenum,$coursedom,$newidx) = @_;
1138: my ($destination,$dir_root) = &embedded_destination();
1139: my ($dirlistref,$listerror) =
1140: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
1141: my @dir_lines;
1142: my $dirptr=16384;
1143: if (ref($dirlistref) eq 'ARRAY') {
1144: foreach my $dir_line (sort
1145: {
1146: my ($afile)=split('&',$a,2);
1147: my ($bfile)=split('&',$b,2);
1148: return (lc($afile) cmp lc($bfile));
1149: } (@{$dirlistref})) {
1150: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
1151: $filename =~ s/\s+$//;
1152: next if ($filename =~ /^\.\.?$/);
1153: my $isdir = 0;
1154: if ($dirptr&$testdir) {
1155: $isdir = 1;
1156: }
1157: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
1158: }
1159: }
1160: return @dir_lines;
1161: }
1162:
1163: sub is_supplemental_title {
1164: my ($title) = @_;
1165: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
1166: }
1167:
1168: sub parse_supplemental_title {
1169: my ($title) = @_;
1170:
1171: my ($foldertitle,$renametitle);
1172: if ($title =~ /&&&/) {
1173: $title = &HTML::Entites::decode($title);
1174: }
1175: if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) {
1176: $renametitle=$4;
1177: my ($time,$uname,$udom) = ($1,$2,$3);
1178: $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
1179: my $name = &Apache::loncommon::plainname($uname,$udom);
1180: $name = &HTML::Entities::encode($name,'"<>&\'');
1181: $renametitle = &HTML::Entities::encode($renametitle,'"<>&\'');
1182: $title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '.
1183: $name.': <br />'.$foldertitle;
1184: }
1185: if (wantarray) {
1186: return ($title,$foldertitle,$renametitle);
1187: }
1188: return $title;
1189: }
1190:
1191: # --------------------------------------------------------------- An entry line
1192:
1193: sub entryline {
1194: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_;
1195: my ($foldertitle,$pagetitle,$renametitle);
1196: if (&is_supplemental_title($title)) {
1197: ($title,$foldertitle,$renametitle) = &parse_supplemental_title($title);
1198: $pagetitle = $foldertitle;
1199: } else {
1200: $title=&HTML::Entities::encode($title,'"<>&\'');
1201: $renametitle=$title;
1202: $foldertitle=$title;
1203: $pagetitle=$title;
1204: }
1205:
1206: my $orderidx=$LONCAPA::map::order[$index];
1207:
1208:
1209: $renametitle=~s/\\/\\\\/g;
1210: $renametitle=~s/\"\;/\\\"/g;
1211: $renametitle=~s/ /%20/g;
1212: my $line=&Apache::loncommon::start_data_table_row();
1213: my ($form_start,$form_end,$form_common);
1214: # Edit commands
1215: my ($container, $type, $esc_path, $path, $symb);
1216: if ($env{'form.folderpath'}) {
1217: $type = 'folder';
1218: $container = 'sequence';
1219: $esc_path=&escape($env{'form.folderpath'});
1220: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1221: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
1222: }
1223: if ($env{'form.pagepath'}) {
1224: $type = $container = 'page';
1225: $esc_path=&escape($env{'form.pagepath'});
1226: $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
1227: $symb=&escape($env{'form.pagesymb'});
1228: }
1229: my $cpinfo='';
1230: if ($allowed) {
1231: my $incindex=$index+1;
1232: my $selectbox='';
1233: if (($#LONCAPA::map::order>0) &&
1234: ((split(/\:/,
1235: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
1236: ne '') &&
1237: ((split(/\:/,
1238: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1239: ne '')) {
1240: $selectbox=
1241: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1242: '<select name="newpos" onchange="this.form.submit()">';
1243: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
1244: if ($i==$incindex) {
1245: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1246: } else {
1247: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
1248: }
1249: }
1250: $selectbox.='</select>';
1251: }
1252: my %lt=&Apache::lonlocal::texthash(
1253: 'up' => 'Move Up',
1254: 'dw' => 'Move Down',
1255: 'rm' => 'Remove',
1256: 'ct' => 'Cut',
1257: 'rn' => 'Rename',
1258: 'cp' => 'Copy');
1259: my $nocopy=0;
1260: my $nocut=0;
1261: if ($url=~/\.(page|sequence)$/) {
1262: if ($url =~ m{/res/}) {
1263: # no copy for published maps
1264: $nocopy = 1;
1265: } else {
1266: foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
1267: my ($title,$url,$ext,$type)=split(/\:/,$item);
1268: if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
1269: $nocopy=1;
1270: last;
1271: }
1272: }
1273: }
1274: }
1275: if ($url=~/^\/res\/lib\/templates\//) {
1276: $nocopy=1;
1277: $nocut=1;
1278: }
1279: my $copylink=' ';
1280: my $cutlink=' ';
1281:
1282: my $skip_confirm = 0;
1283: if ( $folder =~ /^supplemental/
1284: || ($url =~ m{( /smppg$
1285: |/syllabus$
1286: |/aboutme$
1287: |/navmaps$
1288: |/bulletinboard$
1289: |\.html$
1290: |^/adm/wrapper/ext)}x)) {
1291: $skip_confirm = 1;
1292: }
1293:
1294: if (!$nocopy) {
1295: $copylink=(<<ENDCOPY);
1296: <a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_copy">$lt{'cp'}</a>
1297: ENDCOPY
1298: }
1299: if (!$nocut) {
1300: $cutlink=(<<ENDCUT);
1301: <a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder",$skip_confirm);' class="LC_docs_cut">$lt{'ct'}</a>
1302: ENDCUT
1303: }
1304: $form_start = '
1305: <form action="/adm/coursedocs" method="post">
1306: ';
1307: $form_common=(<<END);
1308: <input type="hidden" name="${type}path" value="$path" />
1309: <input type="hidden" name="${type}symb" value="$symb" />
1310: <input type="hidden" name="setparms" value="$orderidx" />
1311: <input type="hidden" name="changeparms" value="0" />
1312: END
1313: $form_end = '</form>';
1314: $line.=(<<END);
1315: <td>
1316: <div class="LC_docs_entry_move">
1317: <a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'>
1318: <img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" />
1319: </a>
1320: </div>
1321: <div class="LC_docs_entry_move">
1322: <a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'>
1323: <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" />
1324: </a>
1325: </div>
1326: </td>
1327: <td>
1328: $form_start
1329: $form_common
1330: $selectbox
1331: $form_end
1332: </td>
1333: <td class="LC_docs_entry_commands">
1334: <a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
1335: $cutlink
1336: <a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>
1337: $copylink
1338: </td>
1339: END
1340:
1341: }
1342: # Figure out what kind of a resource this is
1343: my ($extension)=($url=~/\.(\w+)$/);
1344: my $uploaded=($url=~/^\/*uploaded\//);
1345: my $icon=&Apache::loncommon::icon($url);
1346: my $isfolder=0;
1347: my $ispage=0;
1348: my $folderarg;
1349: my $pagearg;
1350: my $pagefile;
1351: if ($uploaded) {
1352: if (($extension eq 'sequence') || ($extension eq 'page')) {
1353: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1354: my $containerarg = $1;
1355: if ($extension eq 'sequence') {
1356: $icon=$iconpath.'navmap.folder.closed.gif';
1357: $folderarg=$containerarg;
1358: $isfolder=1;
1359: } else {
1360: $icon=$iconpath.'page.gif';
1361: $pagearg=$containerarg;
1362: $ispage=1;
1363: }
1364: if ($allowed) {
1365: $url='/adm/coursedocs?';
1366: } else {
1367: $url='/adm/supplemental?';
1368: }
1369: } else {
1370: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
1371: }
1372: }
1373:
1374: my $orig_url = $url;
1375: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1376: my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
1377: if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
1378: my $symb=&Apache::lonnet::symbclean(
1379: &Apache::lonnet::declutter('uploaded/'.
1380: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
1381: $env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
1382: '.sequence').
1383: '___'.$residx.'___'.
1384: &Apache::lonnet::declutter($url));
1385: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
1386: $url=&Apache::lonnet::clutter($url);
1387: if ($url=~/^\/*uploaded\//) {
1388: $url=~/\.(\w+)$/;
1389: my $embstyle=&Apache::loncommon::fileembstyle($1);
1390: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
1391: $url='/adm/wrapper'.$url;
1392: } elsif ($embstyle eq 'ssi') {
1393: #do nothing with these
1394: } elsif ($url!~/\.(sequence|page)$/) {
1395: $url='/adm/coursedocs/showdoc'.$url;
1396: }
1397: } elsif ($url=~m|^/ext/|) {
1398: $url='/adm/wrapper'.$url;
1399: $external = 1;
1400: }
1401: if (&Apache::lonnet::symbverify($symb,$url)) {
1402: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
1403: } else {
1404: $url='';
1405: }
1406: if ($container eq 'page') {
1407: my $symb=$env{'form.pagesymb'};
1408:
1409: $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
1410: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
1411: }
1412: }
1413: my ($rand_pick_text,$rand_order_text);
1414: if ($isfolder || $extension eq 'sequence') {
1415: my $foldername=&escape($foldertitle);
1416: my $folderpath=$env{'form.folderpath'};
1417: if ($folderpath) { $folderpath.='&' };
1418: # Append randompick number, hidden, and encrypted with ":" to foldername,
1419: # so it gets transferred between levels
1420: $folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx,
1421: 'parameter_randompick'))[0]
1422: .':'.((&LONCAPA::map::getparameter($orderidx,
1423: 'parameter_hiddenresource'))[0]=~/^yes$/i)
1424: .':'.((&LONCAPA::map::getparameter($orderidx,
1425: 'parameter_encrypturl'))[0]=~/^yes$/i)
1426: .':'.((&LONCAPA::map::getparameter($orderidx,
1427: 'parameter_randomorder'))[0]=~/^yes$/i);
1428: $url.='folderpath='.&escape($folderpath).$cpinfo;
1429: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
1430: 'parameter_randompick'))[0];
1431: my $rpckchk;
1432: if ($rpicknum) {
1433: $rpckchk = ' checked="checked"';
1434: }
1435: my $formname = 'edit_rpick_'.$orderidx;
1436: $rand_pick_text =
1437: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1438: $form_common."\n".
1439: '<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.'" />';
1440: if ($rpicknum ne '') {
1441: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
1442: }
1443: $rand_pick_text .= '</span></form>';
1444: my $ro_set=
1445: ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
1446: $rand_order_text =
1447: $form_start.
1448: $form_common.'
1449: <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>';
1450: }
1451: if ($ispage) {
1452: my $pagename=&escape($pagetitle);
1453: my $pagepath;
1454: my $folderpath=$env{'form.folderpath'};
1455: if ($folderpath) { $pagepath = $folderpath.'&' };
1456: $pagepath.=$pagearg.'&'.$pagename;
1457: my $symb=$env{'form.pagesymb'};
1458: if (!$symb) {
1459: my $path='uploaded/'.
1460: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
1461: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
1462: $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
1463: $residx,
1464: $path.$pagearg.'.page');
1465: }
1466: $url.='pagepath='.&escape($pagepath).
1467: '&pagesymb='.&escape($symb).$cpinfo;
1468: }
1469: if (($external) && ($allowed)) {
1470: my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
1471: $external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>';
1472: } else {
1473: undef($external);
1474: }
1475: my $reinit;
1476: if ($crstype eq 'Community') {
1477: $reinit = &mt('(re-initialize community to access)');
1478: } else {
1479: $reinit = &mt('(re-initialize course to access)');
1480: }
1481: $line.='<td>';
1482: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1483: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
1484: } elsif ($url) {
1485: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1486: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
1487: } else {
1488: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
1489: }
1490: $line.='</td><td>';
1491: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1492: $line.='<a href="'.$url.'">'.$title.'</a>';
1493: } elsif ($url) {
1494: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1495: $title,600,500);
1496: } else {
1497: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
1498: }
1499: $line.=$external."</td>";
1500: $rand_pick_text = ' ' if ($rand_pick_text eq '');
1501: $rand_order_text = ' ' if ($rand_order_text eq '');
1502: if (($allowed) && ($folder!~/^supplemental/)) {
1503: my %lt=&Apache::lonlocal::texthash(
1504: 'hd' => 'Hidden',
1505: 'ec' => 'URL hidden');
1506: my $enctext=
1507: ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':'');
1508: my $hidtext=
1509: ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':'');
1510: $line.=(<<ENDPARMS);
1511: <td class="LC_docs_entry_parameter">
1512: $form_start
1513: $form_common
1514: <label><input type="checkbox" name="hiddenresource_$orderidx" onclick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
1515: $form_end
1516: <br />
1517: $form_start
1518: $form_common
1519: <label><input type="checkbox" name="encrypturl_$orderidx" onclick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
1520: $form_end
1521: </td>
1522: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
1523: $rand_order_text</td>
1524: ENDPARMS
1525: }
1526: $line.=&Apache::loncommon::end_data_table_row();
1527: return $line;
1528: }
1529:
1530: =pod
1531:
1532: =item tiehash()
1533:
1534: tie the hash
1535:
1536: =cut
1537:
1538: sub tiehash {
1539: my ($mode)=@_;
1540: $hashtied=0;
1541: if ($env{'request.course.fn'}) {
1542: if ($mode eq 'write') {
1543: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
1544: &GDBM_WRCREAT(),0640)) {
1545: $hashtied=2;
1546: }
1547: } else {
1548: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
1549: &GDBM_READER(),0640)) {
1550: $hashtied=1;
1551: }
1552: }
1553: }
1554: }
1555:
1556: sub untiehash {
1557: if ($hashtied) { untie %hash; }
1558: $hashtied=0;
1559: return OK;
1560: }
1561:
1562:
1563:
1564:
1565: sub checkonthis {
1566: my ($r,$url,$level,$title)=@_;
1567: $url=&unescape($url);
1568: $alreadyseen{$url}=1;
1569: $r->rflush();
1570: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
1571: $r->print("\n<br />");
1572: if ($level==0) {
1573: $r->print("<br />");
1574: }
1575: for (my $i=0;$i<=$level*5;$i++) {
1576: $r->print(' ');
1577: }
1578: $r->print('<a href="'.$url.'" target="cat">'.
1579: ($title?$title:$url).'</a> ');
1580: if ($url=~/^\/res\//) {
1581: my $result=&Apache::lonnet::repcopy(
1582: &Apache::lonnet::filelocation('',$url));
1583: if ($result eq 'ok') {
1584: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
1585: $r->rflush();
1586: &Apache::lonnet::countacc($url);
1587: $url=~/\.(\w+)$/;
1588: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
1589: $r->print('<br />');
1590: $r->rflush();
1591: for (my $i=0;$i<=$level*5;$i++) {
1592: $r->print(' ');
1593: }
1594: $r->print('- '.&mt('Rendering:').' ');
1595: my ($errorcount,$warningcount)=split(/:/,
1596: &Apache::lonnet::ssi_body($url,
1597: ('grade_target'=>'web',
1598: 'return_only_error_and_warning_counts' => 1)));
1599: if (($errorcount) ||
1600: ($warningcount)) {
1601: if ($errorcount) {
1602: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1603: &mt('[quant,_1,error]',$errorcount).'</span>');
1604: }
1605: if ($warningcount) {
1606: $r->print('<span class="LC_warning">'.
1607: &mt('[quant,_1,warning]',$warningcount).'</span>');
1608: }
1609: } else {
1610: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
1611: }
1612: $r->rflush();
1613: }
1614: my $dependencies=
1615: &Apache::lonnet::metadata($url,'dependencies');
1616: foreach my $dep (split(/\,/,$dependencies)) {
1617: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
1618: &checkonthis($r,$dep,$level+1);
1619: }
1620: }
1621: } elsif ($result eq 'unavailable') {
1622: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
1623: } elsif ($result eq 'not_found') {
1624: unless ($url=~/\$/) {
1625: $r->print('<span class="LC_error">'.&mt('not found').'</b></span>');
1626: } else {
1627: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1628: }
1629: } else {
1630: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
1631: }
1632: }
1633: }
1634: }
1635:
1636:
1637:
1638: =pod
1639:
1640: =item list_symbs()
1641:
1642: List Symbs
1643:
1644: =cut
1645:
1646: sub list_symbs {
1647: my ($r) = @_;
1648:
1649: my $crstype = &Apache::loncommon::course_type();
1650: $r->print(&Apache::loncommon::start_page('Symb List'));
1651: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List'));
1652: &startContentScreen($r,'tools');
1653: my $navmap = Apache::lonnavmaps::navmap->new();
1654: if (!defined($navmap)) {
1655: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
1656: '<div class="LC_error">'.
1657: &mt('Unable to retrieve information about course contents').
1658: '</div>');
1659: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1660: } else {
1661: $r->print("<pre>\n");
1662: foreach my $res ($navmap->retrieveResources()) {
1663: $r->print($res->compTitle()."\t".$res->symb()."\n");
1664: }
1665: $r->print("\n</pre>\n");
1666: }
1667: }
1668:
1669:
1670: sub verifycontent {
1671: my ($r) = @_;
1672: my $crstype = &Apache::loncommon::course_type();
1673: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents'));
1674: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents'));
1675: &startContentScreen($r,'tools');
1676: $hashtied=0;
1677: undef %alreadyseen;
1678: %alreadyseen=();
1679: &tiehash();
1680: foreach my $key (keys(%hash)) {
1681: if ($hash{$key}=~/\.(page|sequence)$/) {
1682: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
1683: $r->print('<hr /><span class="LC_error">'.
1684: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1685: &unescape($hash{$key}).'</span><br />'.
1686: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1687: }
1688: }
1689: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
1690: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
1691: }
1692: }
1693: &untiehash();
1694: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1695: }
1696:
1697:
1698: sub devalidateversioncache {
1699: my $src=shift;
1700: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
1701: &Apache::lonnet::clutter($src));
1702: }
1703:
1704: sub checkversions {
1705: my ($r) = @_;
1706: my $crstype = &Apache::loncommon::course_type();
1707: $r->print(&Apache::loncommon::start_page("Check $crstype Document Versions"));
1708: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions"));
1709: &startContentScreen($r,'tools');
1710:
1711: my $header='';
1712: my $startsel='';
1713: my $monthsel='';
1714: my $weeksel='';
1715: my $daysel='';
1716: my $allsel='';
1717: my %changes=();
1718: my $starttime=0;
1719: my $haschanged=0;
1720: my %setversions=&Apache::lonnet::dump('resourceversions',
1721: $env{'course.'.$env{'request.course.id'}.'.domain'},
1722: $env{'course.'.$env{'request.course.id'}.'.num'});
1723:
1724: $hashtied=0;
1725: &tiehash();
1726: my %newsetversions=();
1727: if ($env{'form.setmostrecent'}) {
1728: $haschanged=1;
1729: foreach my $key (keys(%hash)) {
1730: if ($key=~/^ids\_(\/res\/.+)$/) {
1731: $newsetversions{$1}='mostrecent';
1732: &devalidateversioncache($1);
1733: }
1734: }
1735: } elsif ($env{'form.setcurrent'}) {
1736: $haschanged=1;
1737: foreach my $key (keys(%hash)) {
1738: if ($key=~/^ids\_(\/res\/.+)$/) {
1739: my $getvers=&Apache::lonnet::getversion($1);
1740: if ($getvers>0) {
1741: $newsetversions{$1}=$getvers;
1742: &devalidateversioncache($1);
1743: }
1744: }
1745: }
1746: } elsif ($env{'form.setversions'}) {
1747: $haschanged=1;
1748: foreach my $key (keys(%env)) {
1749: if ($key=~/^form\.set_version_(.+)$/) {
1750: my $src=$1;
1751: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
1752: $newsetversions{$src}=$env{$key};
1753: &devalidateversioncache($src);
1754: }
1755: }
1756: }
1757: }
1758: if ($haschanged) {
1759: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
1760: $env{'course.'.$env{'request.course.id'}.'.domain'},
1761: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
1762: $r->print(&Apache::loncommon::confirmwrapper(
1763: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
1764: } else {
1765: $r->print(&Apache::loncommon::confirmwrapper(
1766: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
1767: }
1768: &mark_hash_old();
1769: }
1770: &changewarning($r,'');
1771: if ($env{'form.timerange'} eq 'all') {
1772: # show all documents
1773: $header=&mt('All Documents in '.$crstype);
1774: $allsel=1;
1775: foreach my $key (keys(%hash)) {
1776: if ($key=~/^ids\_(\/res\/.+)$/) {
1777: my $src=$1;
1778: $changes{$src}=1;
1779: }
1780: }
1781: } else {
1782: # show documents which changed
1783: %changes=&Apache::lonnet::dump
1784: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
1785: $env{'course.'.$env{'request.course.id'}.'.num'});
1786: my $firstkey=(keys(%changes))[0];
1787: unless ($firstkey=~/^error\:/) {
1788: unless ($env{'form.timerange'}) {
1789: $env{'form.timerange'}=604800;
1790: }
1791: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
1792: .&mt('seconds');
1793: if ($env{'form.timerange'}==-1) {
1794: $seltext='since start of course';
1795: $startsel='selected';
1796: $env{'form.timerange'}=time;
1797: }
1798: $starttime=time-$env{'form.timerange'};
1799: if ($env{'form.timerange'}==2592000) {
1800: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1801: $monthsel='selected';
1802: } elsif ($env{'form.timerange'}==604800) {
1803: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1804: $weeksel='selected';
1805: } elsif ($env{'form.timerange'}==86400) {
1806: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1807: $daysel='selected';
1808: }
1809: $header=&mt('Content changed').' '.$seltext;
1810: } else {
1811: $header=&mt('No content modifications yet.');
1812: }
1813: }
1814: %setversions=&Apache::lonnet::dump('resourceversions',
1815: $env{'course.'.$env{'request.course.id'}.'.domain'},
1816: $env{'course.'.$env{'request.course.id'}.'.num'});
1817: my %lt=&Apache::lonlocal::texthash
1818: ('st' => 'Version changes since start of '.$crstype,
1819: 'lm' => 'Version changes since last Month',
1820: 'lw' => 'Version changes since last Week',
1821: 'sy' => 'Version changes since Yesterday',
1822: 'al' => 'All Resources (possibly large output)',
1823: 'sd' => 'Display',
1824: 'fi' => 'File',
1825: 'md' => 'Modification Date',
1826: 'mr' => 'Most recently published Version',
1827: 've' => 'Version used in '.$crstype,
1828: 'vu' => 'Set Version to be used in '.$crstype,
1829: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1830: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
1831: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1832: 'di' => 'Differences',
1833: 'save' => 'Save',
1834: 'act' => 'Actions');
1835: $r->print(<<ENDHEADERS);
1836: <form action="/adm/coursedocs" method="post">
1837: <input type="hidden" name="versions" value="1" />
1838: <div class="LC_columnSection">
1839: <fieldset>
1840: <legend>$lt{'act'}</legend>
1841: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" /><br />
1842: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" />
1843: </fieldset>
1844: </div>
1845: <select name="timerange">
1846: <option value='all' $allsel>$lt{'al'}</option>
1847: <option value="-1" $startsel>$lt{'st'}</option>
1848: <option value="2592000" $monthsel>$lt{'lm'}</option>
1849: <option value="604800" $weeksel>$lt{'lw'}</option>
1850: <option value="86400" $daysel>$lt{'sy'}</option>
1851: </select>
1852: <input type="submit" name="display" value="$lt{'sd'}" />
1853: <h2>$header</h2>
1854: <input type="submit" name="setversions" value="$lt{'save'}" />
1855: <table border="0">
1856: ENDHEADERS
1857: #number of columns for version history
1858: my $num_ver_col = 1;
1859: $r->print(
1860: &Apache::loncommon::start_data_table().
1861: &Apache::loncommon::start_data_table_header_row().
1862: '<th>'.&mt('Resources').'</th>'.
1863: "<th>$lt{'mr'}</th>".
1864: "<th>$lt{'ve'}</th>".
1865: "<th>$lt{'vu'}</th>".
1866: '<th colspan="'.$num_ver_col.'">'.&mt('History').'</th>'.
1867: '</b>');
1868: foreach my $key (sort(keys(%changes))) {
1869: if ($changes{$key}>$starttime) {
1870: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
1871: my $currentversion=&Apache::lonnet::getversion($key);
1872: if ($currentversion<0) {
1873: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
1874: }
1875: my $linkurl=&Apache::lonnet::clutter($key);
1876: $r->print(
1877: &Apache::loncommon::end_data_table_header_row().
1878: &Apache::loncommon::start_data_table_row().
1879: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br>'.
1880: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
1881: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br>('.
1882: &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate')).')</span></td>'.
1883: '<td align="right">');
1884: # Used in course
1885: my $usedversion=$hash{'version_'.$linkurl};
1886: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1887: if($usedversion != $currentversion){
1888: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1889: }else{
1890: $r->print($usedversion);
1891: }
1892: } else {
1893: $r->print($currentversion);
1894: }
1895: $r->print('</td><td title="'.$lt{'vu'}.'">');
1896: # Set version
1897: $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
1898: 'set_version_'.$linkurl,
1899: {'select_form_order' =>
1900: ['',1..$currentversion,'mostrecent'],
1901: '' => '',
1902: 'mostrecent' => &mt('most recent'),
1903: map {$_,$_} (1..$currentversion)}));
1904: my $lastold=1;
1905: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
1906: my $url=$root.'.'.$prevvers.'.'.$extension;
1907: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
1908: $starttime) {
1909: $lastold=$prevvers;
1910: }
1911: }
1912: #
1913: # Code to figure out how many version entries should go in
1914: # each of the four columns
1915: my $entries_per_col = 0;
1916: my $num_entries = ($currentversion-$lastold);
1917: if ($num_entries % $num_ver_col == 0) {
1918: $entries_per_col = $num_entries/$num_ver_col;
1919: } else {
1920: $entries_per_col = $num_entries/$num_ver_col + 1;
1921: }
1922: my $entries_count = 0;
1923: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
1924: my $cols_output = 1;
1925: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
1926: my $url=$root.'.'.$prevvers.'.'.$extension;
1927: $r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url).
1928: '">'.&mt('Version').' '.$prevvers.'</a> ('.
1929: &Apache::lonlocal::locallocaltime(
1930: &Apache::lonnet::metadata($url,
1931: 'lastrevisiondate')
1932: ).
1933: ')');
1934: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
1935: $r->print(' <a href="/adm/diff?filename='.
1936: &Apache::lonnet::clutter($root.'.'.$extension).
1937: '&versionone='.$prevvers.
1938: '" target="diffs">'.&mt('Diffs').'</a>');
1939: }
1940: $r->print('</span><br />');
1941: if (++$entries_count % $entries_per_col == 0) {
1942: $r->print('</span></td>');
1943: if ($cols_output != $num_ver_col) {
1944: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
1945: $cols_output++;
1946: }
1947: }
1948: }
1949: while($cols_output++ < $num_ver_col) {
1950: $r->print('</span></td><td>');
1951: }
1952: }
1953: }
1954: $r->print('</td>'.&Apache::loncommon::end_data_table_row().
1955: &Apache::loncommon::end_data_table().
1956: '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />');
1957:
1958: &untiehash();
1959: }
1960:
1961: sub mark_hash_old {
1962: my $retie_hash=0;
1963: if ($hashtied) {
1964: $retie_hash=1;
1965: &untiehash();
1966: }
1967: &tiehash('write');
1968: $hash{'old'}=1;
1969: &untiehash();
1970: if ($retie_hash) { &tiehash(); }
1971: }
1972:
1973: sub is_hash_old {
1974: my $untie_hash=0;
1975: if (!$hashtied) {
1976: $untie_hash=1;
1977: &tiehash();
1978: }
1979: my $return=$hash{'old'};
1980: if ($untie_hash) { &untiehash(); }
1981: return $return;
1982: }
1983:
1984: sub changewarning {
1985: my ($r,$postexec,$message,$url)=@_;
1986: if (!&is_hash_old()) { return; }
1987: my $pathvar='folderpath';
1988: my $path=&escape($env{'form.folderpath'});
1989: if (!defined($url)) {
1990: if (defined($env{'form.pagepath'})) {
1991: $pathvar='pagepath';
1992: $path=&escape($env{'form.pagepath'});
1993: $path.='&pagesymb='.&escape($env{'form.pagesymb'});
1994: }
1995: $url='/adm/coursedocs?'.$pathvar.'='.$path;
1996: }
1997: my $course_type = &Apache::loncommon::course_type();
1998: if (!defined($message)) {
1999: $message='Changes will become active for your current session after [_1], or the next time you log in.';
2000: }
2001: $r->print("\n\n".
2002: '<script type="text/javascript">'."\n".
2003: '// <![CDATA['."\n".
2004: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
2005: '// ]]>'."\n".
2006: '</script>'."\n".
2007: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
2008: '<input type="hidden" name="orgurl" value="'.$url.
2009: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
2010: &mt($message,' <input type="hidden" name="'.
2011: $env{'request.role'}.'" value="1" /><input type="button" value="'.
2012: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
2013: $help{'Caching'}.'</p></form>'."\n\n");
2014: }
2015:
2016:
2017: sub init_breadcrumbs {
2018: my ($form,$text)=@_;
2019: &Apache::lonhtmlcommon::clear_breadcrumbs();
2020: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs",
2021: text=>&Apache::loncommon::course_type().' Editor',
2022: faq=>273,
2023: bug=>'Instructor Interface',
2024: help => 'Docs_Adding_Course_Doc'});
2025: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
2026: text=>$text,
2027: faq=>273,
2028: bug=>'Instructor Interface'});
2029: }
2030:
2031: # subroutine to list form elements
2032: sub create_list_elements {
2033: my @formarr = @_;
2034: my $list = '';
2035: for my $button (@formarr){
2036: for my $picture(keys %$button) {
2037: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'});
2038: }
2039: }
2040: return $list;
2041: }
2042:
2043: # subroutine to create ul from list elements
2044: sub create_form_ul {
2045: my $list = shift;
2046: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
2047: return $ul;
2048: }
2049:
2050: #
2051: # Start tabs
2052: #
2053:
2054: sub startContentScreen {
2055: my ($r,$mode)=@_;
2056: $r->print('<ul class="LC_TabContentBigger" id="mainnav">');
2057: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
2058: $r->print('<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n");
2059: $r->print('<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n");
2060: $r->print('<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'."\n");
2061: $r->print('<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>');
2062: } else {
2063: $r->print('<li '.(($mode eq 'docs')?' class="active"':'').
2064: ' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Content Editor').' </b></a></li>');
2065: $r->print('<li '.(($mode eq 'suppdocs')?' class="active"':'').
2066: '><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>');
2067: }
2068: $r->print("\n".'</ul>'."\n");
2069: $r->print('<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
2070: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
2071: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">');
2072: }
2073:
2074: #
2075: # End tabs
2076: #
2077:
2078: sub endContentScreen {
2079: my ($r)=@_;
2080: $r->print('</div></div></div>');
2081: }
2082:
2083: sub supplemental_base {
2084: return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Content'));
2085: }
2086:
2087: sub handler {
2088: my $r = shift;
2089: &Apache::loncommon::content_type($r,'text/html');
2090: $r->send_http_header;
2091: return OK if $r->header_only;
2092: my $crstype = &Apache::loncommon::course_type();
2093:
2094: #
2095: # --------------------------------------------- Initialize help topics for this
2096: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
2097: 'Adding_External_Resource','Navigate_Content',
2098: 'Adding_Folders','Docs_Overview', 'Load_Map',
2099: 'Supplemental','Score_Upload_Form','Adding_Pages',
2100: 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
2101: 'Check_Resource_Versions','Verify_Content') {
2102: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
2103: }
2104: # Composite help files
2105: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
2106: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
2107: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
2108: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
2109: $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
2110: 'Option_Response_Simple');
2111: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
2112: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
2113: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
2114: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
2115: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
2116: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
2117:
2118:
2119: my $allowed;
2120: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
2121: unless ($r->uri eq '/adm/supplemental') {
2122: # does this user have privileges to modify content.
2123: $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
2124: }
2125:
2126: if ($allowed && $env{'form.verify'}) {
2127: &init_breadcrumbs('verify','Verify Content');
2128: &verifycontent($r);
2129: } elsif ($allowed && $env{'form.listsymbs'}) {
2130: &init_breadcrumbs('listsymbs','List Symbs');
2131: &list_symbs($r);
2132: } elsif ($allowed && $env{'form.docslog'}) {
2133: &init_breadcrumbs('docslog','Show Log');
2134: &docs_change_log($r);
2135: } elsif ($allowed && $env{'form.versions'}) {
2136: &init_breadcrumbs('versions','Check/Set Resource Versions');
2137: &checkversions($r);
2138: } elsif ($allowed && $env{'form.dumpcourse'}) {
2139: &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' Documents to Construction Space');
2140: &dumpcourse($r);
2141: } elsif ($allowed && $env{'form.exportcourse'}) {
2142: &init_breadcrumbs('exportcourse','IMS Export');
2143: &Apache::imsexport::exportcourse($r);
2144: } else {
2145: #
2146: # Done catching special calls
2147: # The whole rest is for course and supplemental documents
2148: # Get the parameters that may be needed
2149: #
2150: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
2151: ['folderpath','pagepath',
2152: 'pagesymb','forcesupplement','forcestandard',
2153: 'symb','command']);
2154:
2155: # standard=1: this is a "new-style" course with an uploaded map as top level
2156: # standard=2: this is a "old-style" course, and there is nothing we can do
2157:
2158: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
2159:
2160: # Decide whether this should display supplemental or main content
2161: # supplementalflag=1: show supplemental documents
2162: # supplementalflag=0: show standard documents
2163:
2164:
2165: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
2166: if (($env{'form.folderpath'}=~/^default/) || $env{'form.folderpath'} eq "" || ($env{'form.pagepath'})) {
2167: $supplementalflag=0;
2168: }
2169: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
2170: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
2171: unless ($allowed) { $supplementalflag=1; }
2172: unless ($standard) { $supplementalflag=1; }
2173:
2174: my $script='';
2175: my $showdoc=0;
2176: my $addentries = {};
2177: my $container;
2178: my $containertag;
2179: my $uploadtag;
2180:
2181: # Do we directly jump somewhere?
2182:
2183: if ($env{'form.command'} eq 'direct') {
2184: my ($mapurl,$id,$resurl);
2185: if ($env{'form.symb'} ne '') {
2186: ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
2187: if ($resurl=~/\.(sequence|page)$/) {
2188: $mapurl=$resurl;
2189: } elsif ($resurl eq 'adm/navmaps') {
2190: $mapurl=$env{'course.'.$env{'request.course.id'}.'.url'};
2191: }
2192: my $mapresobj;
2193: my $navmap = Apache::lonnavmaps::navmap->new();
2194: if (ref($navmap)) {
2195: $mapresobj = $navmap->getResourceByUrl($mapurl);
2196: }
2197: $mapurl=~s{^.*/([^/]+)\.(\w+)$}{$1};
2198: my $type=$2;
2199: my $path;
2200: if (ref($mapresobj)) {
2201: my $pcslist = $mapresobj->map_hierarchy();
2202: if ($pcslist ne '') {
2203: foreach my $pc (split(/,/,$pcslist)) {
2204: next if ($pc <= 1);
2205: my $res = $navmap->getByMapPc($pc);
2206: if (ref($res)) {
2207: my $thisurl = $res->src();
2208: $thisurl=~s{^.*/([^/]+)\.\w+$}{$1};
2209: my $thistitle = $res->title();
2210: $path .= '&'.
2211: &Apache::lonhtmlcommon::entity_encode($thisurl).'&'.
2212: &Apache::lonhtmlcommon::entity_encode($thistitle).
2213: ':'.$res->randompick().
2214: ':'.$res->randomout().
2215: ':'.$res->encrypted().
2216: ':'.$res->randomorder();
2217: }
2218: }
2219: }
2220: $path .= '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
2221: &Apache::lonhtmlcommon::entity_encode($mapresobj->title()).
2222: ':'.$mapresobj->randompick().
2223: ':'.$mapresobj->randomout().
2224: ':'.$mapresobj->encrypted().
2225: ':'.$mapresobj->randomorder();
2226: } else {
2227: my $maptitle = &Apache::lonnet::gettitle($mapurl);
2228: $path = '&default&...::::'.
2229: '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
2230: &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
2231: }
2232: $path = 'default&'.
2233: &Apache::lonhtmlcommon::entity_encode('Main Course Documents').
2234: $path;
2235: if ($type eq 'sequence') {
2236: $env{'form.folderpath'}=$path;
2237: $env{'form.pagepath'}='';
2238: } else {
2239: $env{'form.pagepath'}=$path;
2240: $env{'form.folderpath'}='';
2241: }
2242: } elsif ($env{'form.supppath'} ne '') {
2243: $env{'form.folderpath'}=$env{'form.supppath'};
2244: }
2245: } elsif ($env{'form.command'} eq 'editdocs') {
2246: $env{'form.folderpath'} = 'default&'.
2247: &Apache::lonhtmlcommon::entity_encode('Main Course Content');
2248: $env{'form.pagepath'}='';
2249: } elsif ($env{'form.command'} eq 'editsupp') {
2250: $env{'form.folderpath'} = 'default&'.
2251: &Apache::lonhtmlcommon::entity_encode('Supplemental Content');
2252: $env{'form.pagepath'}='';
2253: }
2254:
2255: # Where do we store these for when we come back?
2256: my $stored_folderpath='docs_folderpath';
2257: if ($supplementalflag) {
2258: $stored_folderpath='docs_sup_folderpath';
2259: }
2260:
2261: # No folderpath, no pagepath, see if we have something stored
2262: if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
2263: &Apache::loncommon::restore_course_settings($stored_folderpath,
2264: {'folderpath' => 'scalar'});
2265: }
2266:
2267: # If we are not allowed to make changes, all we can see are supplemental docs
2268: if (!$allowed) {
2269: $env{'form.pagepath'}='';
2270: unless ($env{'form.folderpath'} =~ /^supplemental/) {
2271: $env{'form.folderpath'} = &supplemental_base();
2272: }
2273: }
2274: # If we still not have a folderpath, see if we can resurrect at pagepath
2275: if (!$env{'form.folderpath'} && $allowed) {
2276: &Apache::loncommon::restore_course_settings($stored_folderpath,
2277: {'pagepath' => 'scalar'});
2278: }
2279: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
2280: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
2281: $env{'form.folderpath'} = &supplemental_base()
2282: .'&'.
2283: $env{'form.folderpath'};
2284: }
2285: # If after all of this, we still don't have any paths, make them
2286: unless (($env{'form.pagepath'}) || ($env{'form.folderpath'})) {
2287: if ($supplementalflag) {
2288: $env{'form.folderpath'}=&supplemental_base();
2289: } else {
2290: $env{'form.folderpath'}='default';
2291: }
2292: }
2293:
2294: # Store this
2295: &Apache::loncommon::store_course_settings($stored_folderpath,
2296: {'pagepath' => 'scalar',
2297: 'folderpath' => 'scalar'});
2298:
2299: if ($env{'form.folderpath'}) {
2300: my (@folderpath)=split('&',$env{'form.folderpath'});
2301: $env{'form.foldername'}=&unescape(pop(@folderpath));
2302: $env{'form.folder'}=pop(@folderpath);
2303: $container='sequence';
2304: }
2305: if ($env{'form.pagepath'}) {
2306: my (@pagepath)=split('&',$env{'form.pagepath'});
2307: $env{'form.pagename'}=&unescape(pop(@pagepath));
2308: $env{'form.folder'}=pop(@pagepath);
2309: $container='page';
2310: $containertag = '<input type="hidden" name="pagepath" value="" />'.
2311: '<input type="hidden" name="pagesymb" value="" />';
2312: $uploadtag =
2313: '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
2314: '<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />'.
2315: '<input type="hidden" name="folderpath" value="" />';
2316: } else {
2317: my $folderpath=$env{'form.folderpath'};
2318: if (!$folderpath) {
2319: if ($env{'form.folder'} eq '' ||
2320: $env{'form.folder'} eq 'supplemental') {
2321: $folderpath='default&'.
2322: &escape(&mt('Main '.$crstype.' Documents'));
2323: }
2324: }
2325: $containertag = '<input type="hidden" name="folderpath" value="" />';
2326: $uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
2327: }
2328: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
2329: $showdoc='/'.$1;
2330: }
2331: if ($showdoc) { # got called in sequence from course
2332: $allowed=0;
2333: } else {
2334: if ($allowed) {
2335: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
2336: $script=&Apache::lonratedt::editscript('simple');
2337: }
2338: }
2339:
2340: # get course data
2341: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
2342: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
2343:
2344: # get personal data
2345: my $uname=$env{'user.name'};
2346: my $udom=$env{'user.domain'};
2347: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
2348:
2349: # graphics settings
2350:
2351: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
2352:
2353: if ($allowed) {
2354: my @tabids;
2355: if ($supplementalflag) {
2356: @tabids = ('002','ee2','ff2');
2357: } else {
2358: @tabids = ('aa1','bb1','cc1','ff1');
2359: unless ($env{'form.pagepath'}) {
2360: unshift(@tabids,'001');
2361: push(@tabids,('dd1','ee1'));
2362: }
2363: }
2364: my $tabidstr = join("','",@tabids);
2365: $script .= &editing_js($udom,$uname,$supplementalflag).
2366: &resize_contentdiv_js($tabidstr);
2367: $addentries = {
2368: onload => "javascript:resize_contentdiv('contentscroll','1','1');",
2369: };
2370: }
2371: # -------------------------------------------------------------------- Body tag
2372: $script = '<script type="text/javascript">'."\n"
2373: .'// <![CDATA['."\n"
2374: .$script."\n"
2375: .'// ]]>'."\n"
2376: .'</script>'."\n";
2377:
2378: # Breadcrumbs
2379: &Apache::lonhtmlcommon::clear_breadcrumbs();
2380: unless ($showdoc) {
2381: &Apache::lonhtmlcommon::add_breadcrumb({
2382: href=>"/adm/coursedocs",text=>"$crstype Contents"});
2383:
2384: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
2385: {'force_register' => $showdoc,
2386: 'add_entries' => $addentries,
2387: })
2388: .&Apache::loncommon::help_open_menu('','',273,'RAT')
2389: .&Apache::lonhtmlcommon::breadcrumbs(
2390: 'Editing the Table of Contents for your '.$crstype,
2391: 'Docs_Adding_Course_Doc')
2392: );
2393: } else {
2394: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
2395: {'force_register' => $showdoc,}));
2396: }
2397:
2398: my %allfiles = ();
2399: my %codebase = ();
2400: my ($upload_result,$upload_output,$uploadphase);
2401: if ($allowed) {
2402: if (($env{'form.uploaddoc.filename'}) &&
2403: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
2404: my $context = $1;
2405: # Process file upload - phase one - upload and parse primary file.
2406: undef($hadchanges);
2407: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
2408: \%allfiles,\%codebase,$context);
2409: if ($hadchanges) {
2410: &mark_hash_old();
2411: }
2412: $r->print($upload_output);
2413: } elsif ($env{'form.phase'} eq 'upload_embedded') {
2414: # Process file upload - phase two - upload embedded objects
2415: $uploadphase = 'check_embedded';
2416: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
2417: my $state = &embedded_form_elems($uploadphase,$primaryurl,
2418: $env{'form.newidx'});
2419: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
2420: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
2421: my ($destination,$dir_root) = &embedded_destination();
2422: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
2423: my $actionurl = '/adm/coursedocs';
2424: my ($result,$flag) =
2425: &Apache::loncommon::upload_embedded('coursedoc',$destination,
2426: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
2427: $actionurl);
2428: $r->print($result.&return_to_editor());
2429: } elsif ($env{'form.phase'} eq 'check_embedded') {
2430: # Process file upload - phase three - modify references in HTML file
2431: $uploadphase = 'modified_orightml';
2432: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
2433: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
2434: my ($destination,$dir_root) = &embedded_destination();
2435: $r->print(&Apache::loncommon::modify_html_refs('coursedoc',$destination,
2436: $docuname,$docudom,undef,
2437: $dir_root).
2438: &return_to_editor());
2439: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
2440: $uploadphase = 'decompress_phase_one';
2441: $r->print(&decompression_phase_one().
2442: &return_to_editor());
2443: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
2444: $uploadphase = 'decompress_phase_two';
2445: $r->print(&decompression_phase_two().
2446: &return_to_editor());
2447: }
2448: }
2449:
2450: unless ($showdoc || $uploadphase) {
2451: # -----------------------------------------------------------------------------
2452: my %lt=&Apache::lonlocal::texthash(
2453: 'uplm' => 'Upload a new main '.lc($crstype).' document',
2454: 'upls' => 'Upload a new supplemental '.lc($crstype).' document',
2455: 'impp' => 'Import a document',
2456: 'copm' => 'All documents out of a published map into this folder',
2457: 'upld' => 'Import Document',
2458: 'srch' => 'Search',
2459: 'impo' => 'Import',
2460: 'wish' => 'Import from Wishlist',
2461: 'selm' => 'Select Map',
2462: 'load' => 'Load Map',
2463: 'reco' => 'Recover Deleted Documents',
2464: 'newf' => 'New Folder',
2465: 'newp' => 'New Composite Page',
2466: 'extr' => 'External Resource',
2467: 'syll' => 'Syllabus',
2468: 'navc' => 'Table of Contents',
2469: 'sipa' => 'Simple Course Page',
2470: 'sipr' => 'Simple Problem',
2471: 'drbx' => 'Drop Box',
2472: 'scuf' => 'External Scores (handgrade, upload, clicker)',
2473: 'bull' => 'Discussion Board',
2474: 'mypi' => 'My Personal Information Page',
2475: 'grpo' => 'Group Portfolio',
2476: 'rost' => 'Course Roster',
2477: 'abou' => 'Personal Information Page for a User',
2478: 'imsf' => 'IMS Import',
2479: 'imsl' => 'Import IMS package',
2480: 'file' => 'File',
2481: 'title' => 'Title',
2482: 'comment' => 'Comment',
2483: 'parse' => 'Upload embedded images/multimedia files if HTML file',
2484: 'nd' => 'Upload Document',
2485: 'pm' => 'Published Map',
2486: 'sd' => 'Special Document',
2487: 'mo' => 'More Options',
2488: );
2489: # -----------------------------------------------------------------------------
2490: my $fileupload=(<<FIUP);
2491: $lt{'file'}:<br />
2492: <input type="file" name="uploaddoc" size="40" />
2493: FIUP
2494:
2495: my $checkbox=(<<CHBO);
2496: <!-- <label>$lt{'parse'}?
2497: <input type="checkbox" name="parserflag" />
2498: </label> -->
2499: <label>
2500: <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
2501: </label>
2502: CHBO
2503:
2504: my $fileuploada = "<br clear='all' /><input type='submit' value='".$lt{'upld'}."' /> $help{'Uploading_From_Harddrive'}";
2505: my $fileuploadform=(<<FUFORM);
2506: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
2507: <input type="hidden" name="active" value="aa" />
2508: $fileupload
2509: <br />
2510: $lt{'title'}:<br />
2511: <input type="text" size="60" name="comment" />
2512: $uploadtag
2513: <input type="hidden" name="cmd" value="upload_default" />
2514: <br />
2515: <span class="LC_nobreak" style="float:left">
2516: $checkbox
2517: </span>
2518: FUFORM
2519: $fileuploadform .= $fileuploada.'</form>';
2520:
2521: my $simpleeditdefaultform=(<<SEDFFORM);
2522: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
2523: <input type="hidden" name="active" value="bb" />
2524: SEDFFORM
2525: my @simpleeditdefaultforma = (
2526: { '<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>" },
2527: { '<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'}" },
2528: { '<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>" },
2529: );
2530: $simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma));
2531: $simpleeditdefaultform .=(<<SEDFFORM);
2532: <hr id="bb_hrule" style="width:0px;text-align:left;margin-left:0" />
2533: $lt{'copm'}<br />
2534: <input type="text" size="40" name="importmap" /><br />
2535: <span class="LC_nobreak" style="float:left"><input type="button"
2536: onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
2537: value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
2538: $help{'Load_Map'}</span>
2539: </form>
2540: SEDFFORM
2541:
2542: my $extresourcesform=(<<ERFORM);
2543: <form action="/adm/coursedocs" method="post" name="newext">
2544: $uploadtag
2545: <input type="hidden" name="importdetail" value="" />
2546: <a class="LC_menubuttons_link" href="javascript:makenewext('newext');">$lt{'extr'}</a>$help{'Adding_External_Resource'}
2547: </form>
2548: ERFORM
2549:
2550:
2551: if ($allowed) {
2552: &update_paste_buffer($coursenum,$coursedom);
2553: my %lt=&Apache::lonlocal::texthash(
2554: 'vc' => 'Verify Content',
2555: 'cv' => 'Check/Set Resource Versions',
2556: 'ls' => 'List Symbs',
2557: 'sl' => 'Show Log'
2558: );
2559:
2560: $r->print(<<HIDDENFORM);
2561: <form name="renameform" method="post" action="/adm/coursedocs">
2562: <input type="hidden" name="title" />
2563: <input type="hidden" name="cmd" />
2564: <input type="hidden" name="markcopy" />
2565: <input type="hidden" name="copyfolder" />
2566: $containertag
2567: </form>
2568: <form name="simpleedit" method="post" action="/adm/coursedocs">
2569: <input type="hidden" name="importdetail" value="" />
2570: $uploadtag
2571: </form>
2572: HIDDENFORM
2573: }
2574:
2575: # Generate the tabs
2576: my $mode;
2577: if (($supplementalflag) && (!$allowed)) {
2578: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
2579: } else {
2580: &startContentScreen($r,($supplementalflag?'suppdocs':'docs'));
2581: }
2582:
2583: #
2584:
2585: my $savefolderpath;
2586:
2587: if ($allowed) {
2588: my $folder=$env{'form.folder'};
2589: if ($folder eq '' || $supplementalflag) {
2590: $folder='default';
2591: $savefolderpath = $env{'form.folderpath'};
2592: $env{'form.folderpath'}='default&'.&escape(&mt('Content'));
2593: $uploadtag = '<input type="hidden" name="folderpath" value="'.
2594: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
2595: }
2596: my $postexec='';
2597: if ($folder eq 'default') {
2598: $r->print('<script type="text/javascript">'."\n"
2599: .'// <![CDATA['."\n"
2600: .'this.window.name="loncapaclient";'."\n"
2601: .'// ]]>'."\n"
2602: .'</script>'."\n"
2603: );
2604: } else {
2605: #$postexec='self.close();';
2606: }
2607: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
2608: '.sequence';
2609: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
2610: '.page';
2611: my $container='sequence';
2612: if ($env{'form.pagepath'}) {
2613: $container='page';
2614: }
2615: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
2616:
2617:
2618:
2619: my $recoverform=(<<RFORM);
2620: <form action="/adm/groupsort" method="post" name="recover">
2621: <a class="LC_menubuttons_link" href="javascript:groupopen('$readfile',1)">$lt{'reco'}</a>
2622: </form>
2623: RFORM
2624:
2625: my $imspform=(<<IMSPFORM);
2626: <form action="/adm/imsimportdocs" method="post" name="ims">
2627: <input type="hidden" name="folder" value="$folder" />
2628: <a class="LC_menubuttons_link" href="javascript:makeims();">$lt{'imsf'}</a>
2629: </form>
2630: IMSPFORM
2631:
2632: my $newnavform=(<<NNFORM);
2633: <form action="/adm/coursedocs" method="post" name="newnav">
2634: <input type="hidden" name="active" value="cc" />
2635: $uploadtag
2636: <input type="hidden" name="importdetail"
2637: value="$lt{'navc'}=/adm/navmaps" />
2638: <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
2639: $help{'Navigate_Content'}
2640: </form>
2641: NNFORM
2642: my $newsmppageform=(<<NSPFORM);
2643: <form action="/adm/coursedocs" method="post" name="newsmppg">
2644: <input type="hidden" name="active" value="cc" />
2645: $uploadtag
2646: <input type="hidden" name="importdetail" value="" />
2647: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
2648: $help{'Simple Page'}
2649: </form>
2650: NSPFORM
2651:
2652: my $newsmpproblemform=(<<NSPROBFORM);
2653: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
2654: <input type="hidden" name="active" value="cc" />
2655: $uploadtag
2656: <input type="hidden" name="importdetail" value="" />
2657: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
2658: $help{'Simple Problem'}
2659: </form>
2660:
2661: NSPROBFORM
2662:
2663: my $newdropboxform=(<<NDBFORM);
2664: <form action="/adm/coursedocs" method="post" name="newdropbox">
2665: <input type="hidden" name="active" value="cc" />
2666: $uploadtag
2667: <input type="hidden" name="importdetail" value="" />
2668: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
2669: </form>
2670: NDBFORM
2671:
2672: my $newexuploadform=(<<NEXUFORM);
2673: <form action="/adm/coursedocs" method="post" name="newexamupload">
2674: <input type="hidden" name="active" value="cc" />
2675: $uploadtag
2676: <input type="hidden" name="importdetail" value="" />
2677: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
2678: $help{'Score_Upload_Form'}
2679: </form>
2680: NEXUFORM
2681:
2682: my $newbulform=(<<NBFORM);
2683: <form action="/adm/coursedocs" method="post" name="newbul">
2684: <input type="hidden" name="active" value="cc" />
2685: $uploadtag
2686: <input type="hidden" name="importdetail" value="" />
2687: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
2688: $help{'Bulletin Board'}
2689: </form>
2690: NBFORM
2691:
2692: my $newaboutmeform=(<<NAMFORM);
2693: <form action="/adm/coursedocs" method="post" name="newaboutme">
2694: <input type="hidden" name="active" value="cc" />
2695: $uploadtag
2696: <input type="hidden" name="importdetail"
2697: value="$plainname=/adm/$udom/$uname/aboutme" />
2698: <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
2699: $help{'My Personal Information Page'}
2700: </form>
2701: NAMFORM
2702:
2703: my $newaboutsomeoneform=(<<NASOFORM);
2704: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
2705: <input type="hidden" name="active" value="cc" />
2706: $uploadtag
2707: <input type="hidden" name="importdetail" value="" />
2708: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
2709: </form>
2710: NASOFORM
2711:
2712:
2713: my $newrosterform=(<<NROSTFORM);
2714: <form action="/adm/coursedocs" method="post" name="newroster">
2715: <input type="hidden" name="active" value="cc" />
2716: $uploadtag
2717: <input type="hidden" name="importdetail"
2718: value="$lt{'rost'}=/adm/viewclasslist" />
2719: <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
2720: $help{'Course Roster'}
2721: </form>
2722: NROSTFORM
2723:
2724: my $specialdocumentsform;
2725: my @specialdocumentsforma;
2726: my $gradingform;
2727: my @gradingforma;
2728: my $communityform;
2729: my @communityforma;
2730: my $newfolderform;
2731: my $newfolderb;
2732:
2733: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
2734:
2735: my $newpageform=(<<NPFORM);
2736: <form action="/adm/coursedocs" method="post" name="newpage">
2737: <input type="hidden" name="folderpath" value="$path" />
2738: <input type="hidden" name="importdetail" value="" />
2739: <input type="hidden" name="active" value="cc" />
2740: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
2741: $help{'Adding_Pages'}
2742: </form>
2743: NPFORM
2744:
2745:
2746: $newfolderform=(<<NFFORM);
2747: <form action="/adm/coursedocs" method="post" name="newfolder">
2748: <input type="hidden" name="folderpath" value="$path" />
2749: <input type="hidden" name="importdetail" value="" />
2750: <input type="hidden" name="active" value="aa" />
2751: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
2752: </form>
2753: NFFORM
2754:
2755: my $newsylform=(<<NSYLFORM);
2756: <form action="/adm/coursedocs" method="post" name="newsyl">
2757: <input type="hidden" name="active" value="cc" />
2758: $uploadtag
2759: <input type="hidden" name="importdetail"
2760: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
2761: <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
2762: $help{'Syllabus'}
2763:
2764: </form>
2765: NSYLFORM
2766:
2767: my $newgroupfileform=(<<NGFFORM);
2768: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
2769: <input type="hidden" name="active" value="cc" />
2770: $uploadtag
2771: <input type="hidden" name="importdetail"
2772: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
2773: <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
2774: $help{'Group Portfolio'}
2775: </form>
2776: NGFFORM
2777: @specialdocumentsforma=(
2778: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'" onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform},
2779: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
2780: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
2781: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
2782: );
2783: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
2784:
2785:
2786: my @importdoc = (
2787: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'newext\');" />'=>$extresourcesform},
2788: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:makeims();" />'=>$imspform},);
2789: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc)) . '<hr id="cc_hrule" style="width:0px;text-align:left;margin-left:0" />' . $fileuploadform;
2790:
2791: @gradingforma=(
2792: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
2793: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
2794: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
2795:
2796: );
2797: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
2798:
2799: @communityforma=(
2800: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
2801: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
2802: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
2803: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},
2804: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
2805: );
2806: $communityform = &create_form_ul(&create_list_elements(@communityforma));
2807:
2808:
2809:
2810: my @tools = (
2811: # {'<img class="LC_noBorder LC_middle" align="left" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" />'=>$extresourcesform},
2812: # {'<img class="LC_noBorder LC_middle" align="left" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" />'=>$imspform},
2813: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/recover.png" alt="'.$lt{reco}.'" onclick="javascript:groupopen(\''.$readfile.'\',1)" />'=>$recoverform},
2814: );
2815:
2816: my %orderhash = (
2817: 'aa' => ['Import Documents',$fileuploadform],
2818: 'bb' => ['Published Resources',$simpleeditdefaultform],
2819: 'cc' => ['Grading Resources',$gradingform],
2820: 'ff' => ['Tools', &create_form_ul(&create_list_elements(@tools)).&generate_admin_options(\%help,\%env)],
2821: );
2822: unless ($env{'form.pagepath'}) {
2823: $orderhash{'00'} = ['Newfolder',$newfolderform];
2824: $orderhash{'dd'} = ['Community Resources',$communityform];
2825: $orderhash{'ee'} = ['Special Documents',$specialdocumentsform];
2826: }
2827:
2828: $hadchanges=0;
2829: unless ($supplementalflag) {
2830: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
2831: $supplementalflag,\%orderhash,$iconpath);
2832: if ($error) {
2833: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
2834: }
2835: if ($hadchanges) {
2836: &mark_hash_old();
2837: }
2838:
2839: &changewarning($r,'');
2840: }
2841: }
2842:
2843: # Supplemental documents start here
2844:
2845: my $folder=$env{'form.folder'};
2846: unless ($supplementalflag) {
2847: $folder='supplemental';
2848: }
2849: if ($folder =~ /^supplemental$/ &&
2850: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
2851: $env{'form.folderpath'} = &supplemental_base();
2852: } elsif ($allowed) {
2853: $env{'form.folderpath'} = $savefolderpath;
2854: }
2855: $env{'form.pagepath'} = '';
2856: if ($allowed) {
2857: my $folderseq=
2858: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
2859: '.sequence';
2860:
2861: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
2862:
2863: my $supupdocformbtn = "<input type='submit' value='".$lt{'upld'}."' />$help{'Uploading_From_Harddrive'}";
2864: my $supupdocform=(<<SUPDOCFORM);
2865: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
2866: <input type="hidden" name="active" value="ee" />
2867: $fileupload
2868: <br />
2869: <br />
2870: <span class="LC_nobreak">
2871: $checkbox
2872: </span>
2873: <br /><br />
2874: $lt{'comment'}:<br />
2875: <textarea cols="50" rows="4" name="comment"></textarea>
2876: <br />
2877: <input type="hidden" name="folderpath" value="$path" />
2878: <input type="hidden" name="cmd" value="upload_supplemental" />
2879: SUPDOCFORM
2880: $supupdocform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'}))."</form>";
2881:
2882: my $supnewfolderform=(<<SNFFORM);
2883: <form action="/adm/coursedocs" method="post" name="supnewfolder">
2884: <input type="hidden" name="active" value="ee" />
2885: <input type="hidden" name="folderpath" value="$path" />
2886: <input type="hidden" name="importdetail" value="" />
2887: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
2888: $help{'Adding_Folders'}
2889: </form>
2890: SNFFORM
2891:
2892:
2893: my $supnewextform=(<<SNEFORM);
2894: <form action="/adm/coursedocs" method="post" name="supnewext">
2895: <input type="hidden" name="active" value="ff" />
2896: <input type="hidden" name="folderpath" value="$path" />
2897: <input type="hidden" name="importdetail" value="" />
2898: <a class="LC_menubuttons_link" href="javascript:makenewext('supnewext');">$lt{'extr'}</a> $help{'Adding_External_Resource'}
2899: </form>
2900: SNEFORM
2901:
2902: my $supnewsylform=(<<SNSFORM);
2903: <form action="/adm/coursedocs" method="post" name="supnewsyl">
2904: <input type="hidden" name="active" value="ff" />
2905: <input type="hidden" name="folderpath" value="$path" />
2906: <input type="hidden" name="importdetail"
2907: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
2908: <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
2909: $help{'Syllabus'}
2910: </form>
2911: SNSFORM
2912:
2913: my $supnewaboutmeform=(<<SNAMFORM);
2914: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
2915: <input type="hidden" name="active" value="ff" />
2916: <input type="hidden" name="folderpath" value="$path" />
2917: <input type="hidden" name="importdetail"
2918: value="$plainname=/adm/$udom/$uname/aboutme" />
2919: <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
2920: $help{'My Personal Information Page'}
2921: </form>
2922: SNAMFORM
2923:
2924:
2925: my @specialdocs = (
2926: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
2927: =>$supnewsylform},
2928: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
2929: =>$supnewaboutmeform},
2930: );
2931: my @supimportdoc = (
2932: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supnewext\');" />'
2933: =>$supnewextform},
2934: );
2935: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)) . '<hr id="ee_hrule" style="width:0px;text-align:left;margin-left:0" />' . $supupdocform;
2936: my %suporderhash = (
2937: '00' => ['Supnewfolder', $supnewfolderform],
2938: 'ee' => ['Import Documents',$supupdocform],
2939: 'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))]
2940: );
2941: if ($supplementalflag) {
2942: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
2943: $supplementalflag,\%suporderhash,$iconpath);
2944: if ($error) {
2945: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
2946: }
2947: }
2948: } elsif ($supplementalflag) {
2949: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
2950: $supplementalflag,'',$iconpath);
2951: if ($error) {
2952: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
2953: }
2954: }
2955:
2956: &endContentScreen($r);
2957:
2958: if ($allowed) {
2959: $r->print('
2960: <form method="post" name="extimport" action="/adm/coursedocs">
2961: <input type="hidden" name="title" />
2962: <input type="hidden" name="url" />
2963: <input type="hidden" name="useform" />
2964: <input type="hidden" name="residx" />
2965: </form>');
2966: }
2967: } else {
2968: unless ($uploadphase) {
2969: # -------------------------------------------------------- This is showdoc mode
2970: $r->print("<h1>".&mt('Uploaded Document').' - '.
2971: &Apache::lonnet::gettitle($r->uri).'</h1><p>'.
2972: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
2973: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
2974: }
2975: }
2976: }
2977: $r->print(&Apache::loncommon::end_page());
2978: return OK;
2979: }
2980:
2981: sub embedded_form_elems {
2982: my ($phase,$primaryurl,$newidx) = @_;
2983: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
2984: return <<STATE;
2985: <input type="hidden" name="folderpath" value="$folderpath" />
2986: <input type="hidden" name="cmd" value="upload_embedded" />
2987: <input type="hidden" name="newidx" value="$newidx" />
2988: <input type="hidden" name="phase" value="$phase" />
2989: <input type="hidden" name="primaryurl" value="$primaryurl" />
2990: STATE
2991: }
2992:
2993: sub embedded_destination {
2994: my $folder=$env{'form.folder'};
2995: my $destination = 'docs/';
2996: if ($folder =~ /^supplemental/) {
2997: $destination = 'supplemental/';
2998: }
2999: if (($folder eq 'default') || ($folder eq 'supplemental')) {
3000: $destination .= 'default/';
3001: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
3002: $destination .= $2.'/';
3003: }
3004: $destination .= $env{'form.newidx'};
3005: my $dir_root = '/userfiles';
3006: return ($destination,$dir_root);
3007: }
3008:
3009: sub return_to_editor {
3010: my $actionurl = '/adm/coursedocs';
3011: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
3012: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
3013: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
3014: '</a></p>';
3015: }
3016:
3017: sub decompression_info {
3018: my ($destination,$dir_root) = &embedded_destination();
3019: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
3020: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3021: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
3022: my $container='sequence';
3023: my ($pathitem,$hiddenelem);
3024: my @hiddens = ('newidx','comment','position');
3025: if ($env{'form.pagepath'}) {
3026: $container='page';
3027: $pathitem = 'pagepath';
3028: } else {
3029: $pathitem = 'folderpath';
3030: }
3031: unshift(@hiddens,$pathitem);
3032: foreach my $item (@hiddens) {
3033: if ($env{'form.'.$item}) {
3034: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
3035: $env{'form.'.$item}.'" />'."\n";
3036: }
3037: }
3038: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
3039: $hiddenelem);
3040: }
3041:
3042: sub decompression_phase_one {
3043: my ($dir,$file,$warning,$error,$output);
3044: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
3045: &decompression_info();
3046: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/docs/\E(?:default|supplemental|\d+).*/([^/]+)$}) {
3047: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
3048: } else {
3049: my $file = $1;
3050: $output =
3051: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
3052: $destination,$dir_root,
3053: $hiddenelem);
3054: if ($env{'form.autoextract_camtasia'}) {
3055: $output .= &remove_archive($docudom,$docuname,$container);
3056: }
3057: }
3058: if ($error) {
3059: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
3060: $error.'</p>'."\n";
3061: }
3062: if ($warning) {
3063: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
3064: }
3065: return $output;
3066: }
3067:
3068: sub decompression_phase_two {
3069: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
3070: &decompression_info();
3071: my $output;
3072: if ($env{'form.archivedelete'}) {
3073: $output = &remove_archive($docudom,$docuname,$container);
3074: }
3075: $output .=
3076: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
3077: $destination,$dir_root,$hiddenelem);
3078: return $output;
3079: }
3080:
3081: sub remove_archive {
3082: my ($docudom,$docuname,$container) = @_;
3083: my $map = $env{'form.folder'}.'.'.$container;
3084: my ($output,$delwarning,$delresult,$url);
3085: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
3086: if ($fatal) {
3087: if ($container eq 'page') {
3088: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
3089: } else {
3090: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
3091: }
3092: $delwarning .= &mt('As a result the archive file has not been removed.');
3093: } else {
3094: my $currcmd = $env{'form.cmd'};
3095: my $position = $env{'form.position'};
3096: if ($position > 0) {
3097: $env{'form.cmd'} = 'del_'.$position;
3098: my ($title,$url,@rrest) =
3099: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);
3100: if (&handle_edit_cmd($docuname,$docudom)) {
3101: ($errtext,$fatal) = &storemap($docuname,$docudom,$map);
3102: if ($fatal) {
3103: if ($container eq 'page') {
3104: $delwarning = &mt('An error occurred updating the contents of the current page.');
3105: } else {
3106: $delwarning = &mt('An error occurred updating the contents of the current folder.');
3107: }
3108: } else {
3109: $delresult = &mt('Archive file removed.');
3110: }
3111: }
3112: }
3113: $env{'form.cmd'} = $currcmd;
3114: }
3115: if ($delwarning) {
3116: $output = '<p class="LC_warning">'.
3117: $delwarning.
3118: '</p>';
3119: }
3120: if ($delresult) {
3121: $output .= '<p class="LC_info">'.
3122: $delresult.
3123: '</p>';
3124: }
3125: return $output;
3126: }
3127:
3128: sub generate_admin_options {
3129: my ($help_ref,$env_ref) = @_;
3130: my %lt=&Apache::lonlocal::texthash(
3131: 'vc' => 'Verify Content',
3132: 'cv' => 'Check/Set Resource Versions',
3133: 'ls' => 'List Symbs',
3134: 'sl' => 'Show Log',
3135: 'imse' => 'IMS Export',
3136: 'dcd' => 'Dump Course Documents to Construction Space: available on other servers'
3137: );
3138: my %help = %{$help_ref};
3139: my %env = %{$env_ref};
3140: my $dumpbut=&dumpbutton();
3141: my $exportbut=&exportbutton();
3142: my @list = (
3143: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/verify.png" alt="'.$lt{vc}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "verify", "'.$lt{'vc'}.'")\' />'
3144: => "<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"verify\", \"$lt{'vc'}\")'>$lt{'vc'}</a>$help{'Verify_Content'}"},
3145: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/resversion.png" alt="'.$lt{cv}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "versions", "'.$lt{'cv'}.'")\' />'
3146: =>"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"versions\", \"$lt{'cv'}\")'>$lt{'cv'}</a>$help{'Check_Resource_Versions'}"},
3147: );
3148: if($dumpbut ne ''){
3149: push @list, {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dump.png" alt="'.$lt{dcd}.'" />'=>$dumpbut};
3150: }
3151: 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').'\');" />'
3152: =>$exportbut},
3153: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/symbs.png" alt="'.$lt{ls}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "listsymbs", "'.$lt{'ls'}.'")\' />'
3154: =>"<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'}' />"},
3155: {'<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'}.'")\' />'
3156: =>"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"docslog\", \"$lt{'sl'}\")'>$lt{'sl'}</a>"},
3157: );
3158: return '<form action="/adm/coursedocs" method="post" name="courseverify"><input type="hidden" id="dummy" />'.&create_form_ul(&create_list_elements(@list)).'</form>';
3159:
3160: }
3161:
3162:
3163: sub generate_edit_table {
3164: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto) = @_;
3165: return unless(ref($orderhash_ref) eq 'HASH');
3166: my %orderhash = %{$orderhash_ref};
3167: my $form;
3168: my $activetab;
3169: my $active;
3170: if($env{'form.active'} ne ''){
3171: $activetab = $env{'form.active'};
3172: }
3173: my $backicon = $iconpath.'clickhere.gif';
3174: my $backtext = &mt('To Overview');
3175: $form = '<div class="LC_Box" style="margin:0;">'.
3176: '<ul id="navigation'.$tid.'" class="LC_TabContent">'.
3177: '<li class="goback">'.
3178: '<a href="javascript:toContents('."'$jumpto'".');">'.
3179: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
3180: ' alt="'.$backtext.'" />'.$backtext.'</a></li>';
3181: foreach my $name (reverse(sort(keys(%orderhash)))) {
3182: if($name ne '00'){
3183: if($activetab eq '' || $activetab ne $name){
3184: $active = '';
3185: }elsif($activetab eq $name){
3186: $active = 'class="active"';
3187: }
3188: $form .= '<li style="float:right" '.$active
3189: .' onmouseover="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"'
3190: .' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>';
3191: } else {
3192: $form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>';
3193:
3194: }
3195: }
3196: $form .= '</ul>';
3197: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">';
3198:
3199: if ($to_show ne '') {
3200: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>';
3201: }
3202: foreach my $field (keys(%orderhash)){
3203: if($field ne '00'){
3204: if($activetab eq '' || $activetab ne $field){
3205: $active = 'style="display: none;float:left"';
3206: }elsif($activetab eq $field){
3207: $active = 'style="display:block;float:left"';
3208: }
3209: $form .= '<div id="'.$field.$tid.'"'
3210: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
3211: .'</div>';
3212: }
3213: }
3214: $form .= '</div></div>';
3215:
3216: return $form;
3217: }
3218:
3219: sub editing_js {
3220: my ($udom,$uname,$supplementalflag) = @_;
3221: my $now = time();
3222: my %lt = &Apache::lonlocal::texthash(
3223: p_mnf => 'Name of New Folder',
3224: t_mnf => 'New Folder',
3225: p_mnp => 'Name of New Page',
3226: t_mnp => 'New Page',
3227: p_mxu => 'Title for the External Score',
3228: p_msp => 'Name of Simple Course Page',
3229: p_msb => 'Title for the Problem',
3230: p_mdb => 'Title for the Drop Box',
3231: p_mbb => 'Title for the Discussion Board',
3232: p_mab => "Enter user:domain for User's Personal Information Page",
3233: p_mab2 => 'Personal Information Page of ',
3234: p_mab_alrt1 => 'Not a valid user:domain',
3235: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
3236: p_chn => 'New Title',
3237: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
3238: p_rmr2a => 'Remove[_99]',
3239: p_rmr2b => '?[_99]',
3240: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
3241: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
3242: p_ctr2a => 'Cut[_98]',
3243: p_ctr2b => '?[_98]',
3244: rpck => 'Enter number to pick (e.g., 3)',
3245: );
3246:
3247: my $crstype = &Apache::loncommon::course_type();
3248: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
3249: my $docs_pagepath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.pagepath'},'<>&"');
3250: my $main_container_page;
3251: if ($docs_folderpath eq '') {
3252: if ($docs_pagepath ne '') {
3253: $main_container_page = 1;
3254: }
3255: }
3256: my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents';
3257: my $toplevelsupp = &supplemental_base();
3258:
3259: my $backtourl = '/adm/navmaps';
3260: if ($supplementalflag) {
3261: $backtourl = '/adm/supplemental';
3262: }
3263:
3264: return <<ENDNEWSCRIPT;
3265: function makenewfolder(targetform,folderseq) {
3266: var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
3267: if (foldername) {
3268: targetform.importdetail.value=escape(foldername)+"="+folderseq;
3269: targetform.submit();
3270: }
3271: }
3272:
3273: function makenewpage(targetform,folderseq) {
3274: var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
3275: if (pagename) {
3276: targetform.importdetail.value=escape(pagename)+"="+folderseq;
3277: targetform.submit();
3278: }
3279: }
3280:
3281: function makenewext(targetname) {
3282: this.document.forms.extimport.useform.value=targetname;
3283: this.document.forms.extimport.title.value='';
3284: this.document.forms.extimport.url.value='';
3285: this.document.forms.extimport.residx.value='';
3286: window.open('/adm/rat/extpickframe.html');
3287: }
3288:
3289: function edittext(targetname,residx,title,url) {
3290: this.document.forms.extimport.useform.value=targetname;
3291: this.document.forms.extimport.residx.value=residx;
3292: this.document.forms.extimport.url.value=url;
3293: this.document.forms.extimport.title.value=title;
3294: window.open('/adm/rat/extpickframe.html');
3295: }
3296:
3297: function makeexamupload() {
3298: var title=prompt('$lt{"p_mxu"}');
3299: if (title) {
3300: this.document.forms.newexamupload.importdetail.value=
3301: escape(title)+'=/res/lib/templates/examupload.problem';
3302: this.document.forms.newexamupload.submit();
3303: }
3304: }
3305:
3306: function makesmppage() {
3307: var title=prompt('$lt{"p_msp"}');
3308: if (title) {
3309: this.document.forms.newsmppg.importdetail.value=
3310: escape(title)+'=/adm/$udom/$uname/$now/smppg';
3311: this.document.forms.newsmppg.submit();
3312: }
3313: }
3314:
3315: function makesmpproblem() {
3316: var title=prompt('$lt{"p_msb"}');
3317: if (title) {
3318: this.document.forms.newsmpproblem.importdetail.value=
3319: escape(title)+'=/res/lib/templates/simpleproblem.problem';
3320: this.document.forms.newsmpproblem.submit();
3321: }
3322: }
3323:
3324: function makedropbox() {
3325: var title=prompt('$lt{"p_mdb"}');
3326: if (title) {
3327: this.document.forms.newdropbox.importdetail.value=
3328: escape(title)+'=/res/lib/templates/DropBox.problem';
3329: this.document.forms.newdropbox.submit();
3330: }
3331: }
3332:
3333: function makebulboard() {
3334: var title=prompt('$lt{"p_mbb"}');
3335: if (title) {
3336: this.document.forms.newbul.importdetail.value=
3337: escape(title)+'=/adm/$udom/$uname/$now/bulletinboard';
3338: this.document.forms.newbul.submit();
3339: }
3340: }
3341:
3342: function makeabout() {
3343: var user=prompt("$lt{'p_mab'}");
3344: if (user) {
3345: var comp=new Array();
3346: comp=user.split(':');
3347: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
3348: if ((comp[0]) && (comp[1])) {
3349: this.document.forms.newaboutsomeone.importdetail.value=
3350: '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
3351: this.document.forms.newaboutsomeone.submit();
3352: } else {
3353: alert("$lt{'p_mab_alrt1'}");
3354: }
3355: } else {
3356: alert("$lt{'p_mab_alrt2'}");
3357: }
3358: }
3359: }
3360:
3361: function makeims() {
3362: var caller = document.forms.ims.folder.value;
3363: var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
3364: newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
3365: newWindow.location.href = newlocation;
3366: }
3367:
3368: function finishpick() {
3369: var title=this.document.forms.extimport.title.value;
3370: var url=this.document.forms.extimport.url.value;
3371: var form=this.document.forms.extimport.useform.value;
3372: var residx=this.document.forms.extimport.residx.value;
3373: eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();');
3374: }
3375:
3376: function changename(folderpath,index,oldtitle,container,pagesymb) {
3377: var title=prompt('$lt{"p_chn"}',oldtitle);
3378: if (title) {
3379: this.document.forms.renameform.markcopy.value=-1;
3380: this.document.forms.renameform.title.value=title;
3381: this.document.forms.renameform.cmd.value='rename_'+index;
3382: if (container == 'sequence') {
3383: this.document.forms.renameform.folderpath.value=folderpath;
3384: }
3385: if (container == 'page') {
3386: this.document.forms.renameform.pagepath.value=folderpath;
3387: this.document.forms.renameform.pagesymb.value=pagesymb;
3388: }
3389: this.document.forms.renameform.submit();
3390: }
3391: }
3392:
3393: function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) {
3394: if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
3395: this.document.forms.renameform.markcopy.value=-1;
3396: this.document.forms.renameform.cmd.value='del_'+index;
3397: if (container == 'sequence') {
3398: this.document.forms.renameform.folderpath.value=folderpath;
3399: }
3400: if (container == 'page') {
3401: this.document.forms.renameform.pagepath.value=folderpath;
3402: this.document.forms.renameform.pagesymb.value=pagesymb;
3403: }
3404: this.document.forms.renameform.submit();
3405: }
3406: }
3407:
3408: function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) {
3409: if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
3410: this.document.forms.renameform.cmd.value='cut_'+index;
3411: this.document.forms.renameform.markcopy.value=index;
3412: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
3413: if (container == 'sequence') {
3414: this.document.forms.renameform.folderpath.value=folderpath;
3415: }
3416: if (container == 'page') {
3417: this.document.forms.renameform.pagepath.value=folderpath;
3418: this.document.forms.renameform.pagesymb.value=pagesymb;
3419: }
3420: this.document.forms.renameform.submit();
3421: }
3422: }
3423:
3424: function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) {
3425: this.document.forms.renameform.markcopy.value=index;
3426: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
3427: if (container == 'sequence') {
3428: this.document.forms.renameform.folderpath.value=folderpath;
3429: }
3430: if (container == 'page') {
3431: this.document.forms.renameform.pagepath.value=folderpath;
3432: this.document.forms.renameform.pagesymb.value=pagesymb;
3433: }
3434: this.document.forms.renameform.submit();
3435: }
3436:
3437: function updatePick(targetform,index,caller) {
3438: var pickitem = document.getElementById('rpick_'+index);
3439: var picknumitem = document.getElementById('rpicknum_'+index);
3440: if (pickitem.checked) {
3441: var picknum=prompt('$lt{"rpck"}',picknumitem.value);
3442: if (picknum == '' || picknum == null) {
3443: if (caller == 'check') {
3444: pickitem.checked=false;
3445: return;
3446: }
3447: } else {
3448: picknum.toString();
3449: var regexdigit=/^\\d+\$/;
3450: if (regexdigit.test(picknum)) {
3451: picknumitem.value = picknum;
3452: targetform.changeparms.value='randompick';
3453: targetform.submit();
3454: } else {
3455: if (caller == 'check') {
3456: pickitem.checked=false;
3457: }
3458: return;
3459: }
3460: }
3461: } else {
3462: picknumitem.value = 0;
3463: targetform.changeparms.value='randompick';
3464: targetform.submit();
3465: }
3466: }
3467:
3468: function unselectInactive(nav) {
3469: currentNav = document.getElementById(nav);
3470: currentLis = currentNav.getElementsByTagName('LI');
3471: for (i = 0; i < currentLis.length; i++) {
3472: if (currentLis[i].className == 'goback') {
3473: currentLis[i].className = 'goback';
3474: } else {
3475: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
3476: currentLis[i].className = 'right';
3477: } else {
3478: currentLis[i].className = 'i';
3479: }
3480: }
3481: }
3482: }
3483:
3484: function hideAll(current, nav, data) {
3485: unselectInactive(nav);
3486: if(current.className == 'right'){
3487: current.className = 'right active'
3488: }else{
3489: current.className = 'active';
3490: }
3491: currentData = document.getElementById(data);
3492: currentDivs = currentData.getElementsByTagName('DIV');
3493: for (i = 0; i < currentDivs.length; i++) {
3494: if(currentDivs[i].className == 'LC_ContentBox'){
3495: currentDivs[i].style.display = 'none';
3496: }
3497: }
3498: }
3499:
3500: function openTabs(pageId) {
3501: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
3502: if(tabnav.length > 2 ){
3503: currentNav = document.getElementById(tabnav[1].id);
3504: currentLis = currentNav.getElementsByTagName('LI');
3505: for(i = 0; i< currentLis.length; i++){
3506: if(currentLis[i].className == 'active') {
3507: funcString = currentLis[i].onclick.toString();
3508: tab = funcString.split('"');
3509: if(tab.length < 2) {
3510: tab = funcString.split("'");
3511: }
3512: currentData = document.getElementById(tab[1]);
3513: currentData.style.display = 'block';
3514: }
3515: }
3516: }
3517: }
3518:
3519: function showPage(current, pageId, nav, data) {
3520: hideAll(current, nav, data);
3521: openTabs(pageId);
3522: unselectInactive(nav);
3523: current.className = 'active';
3524: currentData = document.getElementById(pageId);
3525: currentData.style.display = 'block';
3526: activeTab = pageId;
3527: if (nav == 'mainnav') {
3528: var storedpath = "$docs_folderpath";
3529: if (storedpath == '') {
3530: storedpath = "$docs_pagepath";
3531: }
3532: var storedpage = "$main_container_page";
3533: var reg = new RegExp("^supplemental");
3534: if (pageId == 'mainCourseDocuments') {
3535: if (storedpage == 1) {
3536: document.simpleedit.folderpath.value = '';
3537: document.uploaddocument.folderpath.value = '';
3538: } else {
3539: if (reg.test(storedpath)) {
3540: document.simpleedit.folderpath.value = '$toplevelmain';
3541: document.uploaddocument.folderpath.value = '$toplevelmain';
3542: document.newext.folderpath.value = '$toplevelmain';
3543: } else {
3544: document.simpleedit.folderpath.value = storedpath;
3545: document.uploaddocument.folderpath.value = storedpath;
3546: document.newext.folderpath.value = storedpath;
3547: }
3548: }
3549: } else {
3550: if (reg.test(storedpath)) {
3551: document.simpleedit.folderpath.value = storedpath;
3552: document.supuploaddocument.folderpath.value = storedpath;
3553: document.supnewext.folderpath.value = storedpath;
3554: } else {
3555: document.simpleedit.folderpath.value = '$toplevelsupp';
3556: document.supuploaddocument.folderpath.value = '$toplevelsupp';
3557: document.supnewext.folderpath.value = '$toplevelsupp';
3558: }
3559: }
3560: }
3561: resize_contentdiv('contentscroll','1','0');
3562: return false;
3563: }
3564:
3565: function injectData(current, hiddenField, name, value) {
3566: currentElement = document.getElementById(hiddenField);
3567: currentElement.name = name;
3568: currentElement.value = value;
3569: current.submit();
3570: }
3571:
3572: function toContents(jumpto) {
3573: var newurl = '$backtourl';
3574: if (jumpto != '') {
3575: newurl = newurl+'?postdata='+jumpto;
3576: ;
3577: }
3578: location.href=newurl;
3579: }
3580:
3581: ENDNEWSCRIPT
3582: }
3583:
3584: sub resize_contentdiv_js {
3585: my ($tabidstr) = @_;
3586: my $viewport_js = &Apache::loncommon::viewport_geometry_js();
3587: return <<ENDRESIZESCRIPT;
3588:
3589: window.onresize=resizeContentEditor;
3590:
3591: var activeTab;
3592:
3593: $viewport_js
3594:
3595: function resize_contentdiv(scrollboxname,chkw,chkh) {
3596: var scrollboxid = 'div_'+scrollboxname;
3597: var scrolltableid = 'table_'+scrollboxname;
3598: var scrollbox;
3599: var scrolltable;
3600:
3601: if (document.getElementById("contenteditor") == null) {
3602: return;
3603: }
3604:
3605: if (document.getElementById(scrollboxid) == null) {
3606: return;
3607: } else {
3608: scrollbox = document.getElementById(scrollboxid);
3609: }
3610:
3611: if (document.getElementById(scrolltableid) == null) {
3612: return;
3613: } else {
3614: scrolltable = document.getElementById(scrolltableid);
3615: }
3616:
3617: init_geometry();
3618: var vph = Geometry.getViewportHeight();
3619: var vpw = Geometry.getViewportWidth();
3620:
3621: var alltabs = ['$tabidstr'];
3622: var listwchange;
3623: if (chkw == 1) {
3624: var contenteditorw = document.getElementById("contenteditor").offsetWidth;
3625: var contentlistw;
3626: var contentlistid = document.getElementById("contentlist");
3627: if (contentlistid != null) {
3628: contentlistw = document.getElementById("contentlist").offsetWidth;
3629: }
3630: var contentlistwstart = contentlistw;
3631:
3632: var scrollboxw = scrollbox.offsetWidth;
3633: var scrollboxscrollw = scrollbox.scrollWidth;
3634:
3635: var offsetw = parseInt(vpw * 0.015);
3636: var paddingw = parseInt(vpw * 0.09);
3637:
3638: var minscrollboxw = 250;
3639:
3640: var maxtabw = 0;
3641: var actabw = 0;
3642: for (var i=0; i<alltabs.length; i++) {
3643: if (activeTab == alltabs[i]) {
3644: actabw = document.getElementById(alltabs[i]).offsetWidth;
3645: if (actabw > maxtabw) {
3646: maxtabw = actabw;
3647: }
3648: } else {
3649: if (document.getElementById(alltabs[i]) != null) {
3650: var thistab = document.getElementById(alltabs[i]);
3651: thistab.style.visibility = 'hidden';
3652: thistab.style.display = 'block';
3653: var tabw = document.getElementById(alltabs[i]).offsetWidth;
3654: thistab.style.display = 'none';
3655: thistab.style.visibility = '';
3656: if (tabw > maxtabw) {
3657: maxtabw = tabw;
3658: }
3659: }
3660: }
3661: }
3662:
3663: if (maxtabw > 0) {
3664: var newscrollboxw;
3665: if (maxtabw+paddingw+scrollboxscrollw<contenteditorw) {
3666: newscrollboxw = contenteditorw-paddingw-maxtabw;
3667: if (newscrollboxw < minscrollboxw) {
3668: newscrollboxw = minscrollboxw;
3669: }
3670: scrollbox.style.width = newscrollboxw+"px";
3671: if (newscrollboxw != scrollboxw) {
3672: var newcontentlistw = newscrollboxw-offsetw;
3673: contentlistid.style.width = newcontentlistw+"px";
3674: }
3675: } else {
3676: newscrollboxw = contenteditorw-paddingw-maxtabw;
3677: if (newscrollboxw < minscrollboxw) {
3678: newscrollboxw = minscrollboxw;
3679: }
3680: scrollbox.style.width = newscrollboxw+"px";
3681: if (newscrollboxw != scrollboxw) {
3682: var newcontentlistw = newscrollboxw-offsetw;
3683: contentlistid.style.width = newcontentlistw+"px";
3684: }
3685: }
3686:
3687: if (newscrollboxw != scrollboxw) {
3688: var newscrolltablew = newscrollboxw+offsetw;
3689: scrolltable.style.width = newscrolltablew+"px";
3690: }
3691: }
3692:
3693: if (contentlistid.offsetWidth != contentlistwstart) {
3694: listwchange = 1;
3695: }
3696:
3697: if (activeTab == 'cc1') {
3698: if (document.getElementById('cc_hrule') != null) {
3699: document.getElementById('cc_hrule').style.width=actabw+"px";
3700: }
3701: } else {
3702: if (activeTab == 'bb1') {
3703: if (document.getElementById('bb_hrule') != null) {
3704: document.getElementById('bb_hrule').style.width=actabw+"px";
3705: }
3706: } else {
3707: if (activeTab == 'ee2') {
3708: if (document.getElementById('ee_hrule') != null) {
3709: document.getElementById('ee_hrule').style.width=actabw+"px";
3710: }
3711: }
3712: }
3713: }
3714: }
3715: if ((chkh == 1) || (listwchange)) {
3716: var primaryheight = document.getElementById("LC_nav_bar").offsetHeight;
3717: var secondaryheight = document.getElementById("LC_secondary_menu").offsetHeight;
3718: var crumbsheight = document.getElementById("LC_breadcrumbs").offsetHeight;
3719: var dccidheight = document.getElementById("dccid").offsetHeight;
3720:
3721: var uploadresultheight = 0;
3722: if (document.getElementById("uploadfileresult") != null) {
3723: uploadresultheight = document.getElementById("uploadfileresult").offsetHeight;
3724: }
3725: var tabbedheight = document.getElementById("tabbededitor").offsetHeight;
3726: var contenteditorheight = document.getElementById("contenteditor").offsetHeight;
3727: var scrollboxheight = scrollbox.offsetHeight;
3728: var scrollboxscrollheight = scrollbox.scrollHeight;
3729: var freevspace = vph-(primaryheight+secondaryheight+crumbsheight+dccidheight+uploadresultheight+tabbedheight+contenteditorheight);
3730:
3731: var minvscrollbox = 200;
3732: var offsetv = 20;
3733: var newscrollboxheight;
3734: if (freevspace < 0) {
3735: newscrollboxheight = scrollboxheight+freevspace-offsetv;
3736: if (newscrollboxheight < minvscrollbox) {
3737: newscrollboxheight = minvscrollbox;
3738: }
3739: scrollbox.style.height = newscrollboxheight + "px";
3740: } else {
3741: if (scrollboxscrollheight > scrollboxheight) {
3742: if (freevspace > offsetv) {
3743: newscrollboxheight = scrollboxheight+freevspace-offsetv;
3744: if (newscrollboxheight < minvscrollbox) {
3745: newscrollboxheight = minvscrollbox;
3746: }
3747: scrollbox.style.height = newscrollboxheight+"px";
3748: }
3749: }
3750: }
3751: scrollboxheight = scrollbox.offsetHeight;
3752: var contentlistheight = document.getElementById("contentlist").offsetHeight;
3753:
3754: if (scrollboxscrollheight <= scrollboxheight) {
3755: if ((contentlistheight+offsetv)<scrollboxheight) {
3756: newscrollheight = contentlistheight+offsetv;
3757: scrollbox.style.height = newscrollheight+"px";
3758: }
3759: }
3760: }
3761: return;
3762: }
3763:
3764: function resizeContentEditor() {
3765: var timer;
3766: clearTimeout(timer)
3767: timer=setTimeout('resize_contentdiv("contentscroll","1","1")',500);
3768: }
3769:
3770: ENDRESIZESCRIPT
3771: return;
3772: }
3773:
3774: 1;
3775: __END__
3776:
3777:
3778: =head1 NAME
3779:
3780: Apache::londocs.pm
3781:
3782: =head1 SYNOPSIS
3783:
3784: This is part of the LearningOnline Network with CAPA project
3785: described at http://www.lon-capa.org.
3786:
3787: =head1 SUBROUTINES
3788:
3789: =over
3790:
3791: =item %help=()
3792:
3793: Available help topics
3794:
3795: =item mapread()
3796:
3797: Mapread read maps into LONCAPA::map:: global arrays
3798: @order and @resources, determines status
3799: sets @order - pointer to resources in right order
3800: sets @resources - array with the resources with correct idx
3801:
3802: =item authorhosts()
3803:
3804: Return hash with valid author names
3805:
3806: =item dumpbutton()
3807:
3808: Generate "dump" button
3809:
3810: =item clean()
3811:
3812: =item dumpcourse()
3813:
3814: Actually dump course
3815:
3816:
3817: =item exportbutton()
3818:
3819: Generate "export" button
3820:
3821: =item group_import()
3822:
3823: Imports the given (name, url) resources into the course
3824: coursenum, coursedom, and folder must precede the list
3825:
3826: =item breadcrumbs()
3827:
3828: =item log_docs()
3829:
3830: =item docs_change_log()
3831:
3832: =item update_paste_buffer()
3833:
3834: =item print_paste_buffer()
3835:
3836: =item do_paste_from_buffer()
3837:
3838: =item update_parameter()
3839:
3840: =item handle_edit_cmd()
3841:
3842: =item editor()
3843:
3844: =item process_file_upload()
3845:
3846: =item process_secondary_uploads()
3847:
3848: =item is_supplemental_title()
3849:
3850: =item parse_supplemental_title()
3851:
3852: =item entryline()
3853:
3854: =item tiehash()
3855:
3856: =item untiehash()
3857:
3858: =item checkonthis()
3859:
3860: check on this
3861:
3862: =item verifycontent()
3863:
3864: Verify Content
3865:
3866: =item devalidateversioncache() & checkversions()
3867:
3868: Check Versions
3869:
3870: =item mark_hash_old()
3871:
3872: =item is_hash_old()
3873:
3874: =item changewarning()
3875:
3876: =item init_breadcrumbs()
3877:
3878: Breadcrumbs for special functions
3879:
3880: =back
3881:
3882: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>