Annotation of loncom/publisher/lonpubdir.pm, revision 1.160.2.6
1.1 www 1: # The LearningOnline Network with CAPA
1.145 raeburn 2: # Authoring Space Directory Lister
1.16 albertel 3: #
1.160.2.6! raeburn 4: # $Id: lonpubdir.pm,v 1.160.2.5 2019/08/13 19:27:43 raeburn Exp $
1.16 albertel 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/
1.1 www 27: #
1.17 harris41 28: ###
1.1 www 29:
30: package Apache::lonpubdir;
31:
32: use strict;
33: use Apache::File;
34: use File::Copy;
35: use Apache::Constants qw(:common :http :methods);
1.17 harris41 36: use Apache::loncommon();
1.48 www 37: use Apache::lonhtmlcommon();
1.91 www 38: use Apache::londiff();
1.39 www 39: use Apache::lonlocal;
1.50 www 40: use Apache::lonmsg;
1.64 raeburn 41: use Apache::lonmenu;
42: use Apache::lonnet;
1.154 raeburn 43: use LONCAPA qw(:DEFAULT :match);
1.1 www 44:
45: sub handler {
46:
1.152 musolffc 47: my $r=shift;
1.1 www 48:
1.152 musolffc 49: # Validate access to the construction space and get username:domain.
1.6 www 50:
1.153 raeburn 51: my ($uname,$udom)=&Apache::lonnet::constructaccess($r->uri);
1.152 musolffc 52: unless (($uname) && ($udom)) {
53: return HTTP_NOT_ACCEPTABLE;
54: }
1.23 foxr 55:
1.127 www 56: # ----------------------------------------------------------- Start page output
1.23 foxr 57:
1.152 musolffc 58: my $fn=$r->filename;
59: $fn=~s/\/$//;
60: my $thisdisfn=$fn;
1.1 www 61:
1.152 musolffc 62: my $docroot=$r->dir_config('lonDocRoot'); # Apache londocument root.
1.155 raeburn 63: if ($thisdisfn eq "$docroot/priv/$udom") {
64: if ((-d "/home/$uname/public_html/") && (!-e "$docroot/priv/$udom/$uname")) {
65: my ($version) = ($r->dir_config('lonVersion') =~ /^\'?(\d+\.\d+)\./);
66: &Apache::loncommon::content_type($r,'text/html');
67: $r->send_http_header;
68:
69: &Apache::lonhtmlcommon::clear_breadcrumbs();
70: $r->print(&Apache::loncommon::start_page('Authoring Space').
71: '<div class="LC_error">'.
72: '<br /><p>'.
73: &mt('Your Authoring Space is currently in the location used by LON-CAPA version 2.10 and older, but your domain is using a newer LON-CAPA version ([_1]).',$version).'</p>'.
74: '<p>'.
75: &mt('Please ask your Domain Coordinator to move your Authoring Space to the new location.').
76: '</p>'.
77: '</div>'.
78: &Apache::loncommon::end_page());
79: return OK;
80: }
81: }
1.152 musolffc 82: $thisdisfn=~s/^\Q$docroot\E\/priv//;
1.160.2.4 raeburn 83:
1.152 musolffc 84: my $resdir=$docroot.'/res'.$thisdisfn; # Resource directory
85: my $targetdir='/res'.$thisdisfn; # Publication target directory.
86: my $linkdir='/priv'.$thisdisfn; # Full URL name of constr space.
87:
88: my %bombs=&Apache::lonmsg::all_url_author_res_msg($uname,$udom);
89:
1.160.2.4 raeburn 90: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
91: my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,
92: "$londocroot/priv/$udom/$uname"); # expressed in kB
93: my $disk_quota = &Apache::loncommon::get_user_quota($uname,$udom,
1.160.2.5 raeburn 94: 'author'); # expressed in MB
1.160.2.4 raeburn 95:
96: # Put out the start of page.
1.160.2.5 raeburn 97: &startpage($r, $uname, $udom, $thisdisfn, $current_disk_usage, $disk_quota);
1.157 raeburn 98:
99: if (!-d $fn) {
100: if (-e $fn) {
101: $r->print('<p class="LC_info">'.&mt('Requested item is a file not a directory.').'</p>');
102: } else {
103: $r->print('<p class="LC_info">'.&mt('The requested subdirectory does not exist.').'</p>');
104: }
105: $r->print(&Apache::loncommon::end_page());
106: return OK;
107: }
108: my @files;
109: if (opendir(DIR,$fn)) {
1.158 raeburn 110: @files = grep(!/^\.+$/,readdir(DIR));
1.157 raeburn 111: closedir(DIR);
112: } else {
113: $r->print('<p class="LC_error">'.&mt('Could not open directory.').'</p>');
114: $r->print(&Apache::loncommon::end_page());
115: return OK;
116: }
117:
1.160.2.4 raeburn 118: # Put out actions for directory, browse/upload + new file page.
119: &dircontrols($r,$uname,$udom,$thisdisfn, $current_disk_usage, $disk_quota);
1.152 musolffc 120: &resourceactions($r,$uname,$udom,$thisdisfn); # Put out form used for printing/deletion etc.
1.64 raeburn 121:
1.152 musolffc 122: my $numdir = 0;
123: my $numres = 0;
1.6 www 124:
1.160 musolffc 125: if ((@files == 0) && ($thisdisfn =~ m{^/$match_domain/$match_username})) {
126: if ($thisdisfn =~ m{^/$match_domain/$match_username$}) {
127: $r->print('<p class="LC_info">'.&mt('This Authoring Space is currently empty.').'</p>');
128: } else {
129: $r->print('<p class="LC_info">'.&mt('This subdirectory is currently empty.').'</p>');
130: }
131: $r->print(&Apache::loncommon::end_page());
132: return OK;
133: }
134:
1.152 musolffc 135: # Retrieving value for "sortby" and "sortorder" from QUERY_STRING
136: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
137: ['sortby','sortorder']);
138:
139: # Sort by name as default, not reversed
140: if (! exists($env{'form.sortby'})) { $env{'form.sortby'} = 'filename' }
141: if (! exists($env{'form.sortorder'})) { $env{'form.sortorder'} = '' }
142: my $sortby = $env{'form.sortby'};
143: my $sortorder = $env{'form.sortorder'};
144:
1.160 musolffc 145: # Order in which columns are displayed from left to right
146: my @order = ('filetype','actions','filename','title',
147: 'pubstatus','cmtime','size');
148:
149: # Up and down arrows to indicate sort order
150: my @arrows = (' ▲',' ▼','');
151:
152: # Default sort order and column title
153: my %columns = (
154: filetype => {
155: order => 'ascending',
156: text => &mt('Type'),
157: },
158: actions => {
159: # Not sortable
160: text => &mt('Actions'),
161: },
162: filename => {
163: order => 'ascending',
164: text => &mt('Name'),
165: },
166: title => {
167: order => 'ascending',
168: text => &mt('Title'),
169: },
170: pubstatus => {
171: order => 'ascending',
172: text => &mt('Status'),
173: colspan => '2',
174: },
175: cmtime => {
176: order => 'descending',
177: text => &mt('Last Modified'),
178: },
179: size => {
180: order => 'ascending',
181: text => &mt('Size').' (kB)',
182: },
183: );
184:
185: # Print column headers
186: my $output = '';
187: foreach my $key (@order) {
188: my $idx;
189: # Append an up or down arrow to sorted column
190: if ($sortby eq $key) {
191: $idx = ($columns{$key}{order} eq 'ascending') ? 0:1;
192: if ($sortorder eq 'rev') { $idx ++; }
193: $idx = $idx%2;
194: } else { $idx = 2; } # No arrow if column is not sorted
195: $output .= (($columns{$key}{order}) ?
196: '<th'.($columns{$key}{colspan} ? ' colspan="'.$columns{$key}{colspan}.'"' : '')
1.160.2.4 raeburn 197: .'><a href="'.$linkdir.'/?sortby='.$key.'&sortorder='
1.160 musolffc 198: .((($sortby eq $key) && ($sortorder ne 'rev')) ? 'rev' : '').'">'
199: .$columns{$key}{text}.$arrows[$idx].'</a></th>' :
200: '<th>'.$columns{$key}{text}.'</th>');
1.154 raeburn 201: }
1.152 musolffc 202: $r->print(&Apache::loncommon::start_data_table()
1.160 musolffc 203: .&Apache::loncommon::start_data_table_header_row() . $output
1.152 musolffc 204: .&Apache::loncommon::end_data_table_header_row()
205: );
206:
207: my $dirptr=16384; # Mask indicating a directory in stat.cmode.
208: my $filehash = {};
209: foreach my $filename (@files) {
1.159 musolffc 210: # Skip .DS_Store, .DAV and hidden files
1.152 musolffc 211: my ($extension) = ($filename=~/\.(\w+)$/);
1.156 raeburn 212: next if (($filename eq '.DS_Store')
1.159 musolffc 213: || ($filename eq '.DAV')
1.156 raeburn 214: || (&Apache::loncommon::fileembstyle($extension) eq 'hdn')
215: || ($filename =~ /^\._/));
1.152 musolffc 216:
217: my ($cmode,$csize,$cmtime)=(stat($fn.'/'.$filename))[2,7,9];
218: my $linkfilename = &HTML::Entities::encode('/priv'.$thisdisfn.'/'.$filename,'<>&"');
219: # Identify type of file according to icon used
220: my ($filetype) = (&Apache::loncommon::icon($filename) =~ m{/(\w+).gif$});
221: my $cstr_dir = $r->dir_config('lonDocRoot').'/priv'.$thisdisfn;
222: my $meta_same = &isMetaSame($cstr_dir, $resdir, $filename);
223:
224: # Store size, title, and status for files but not directories
225: my $size = (!($cmode&$dirptr)) ? $csize/1024. : 0;
226: my ($status, $pubstatus, $title, $fulltitle);
227: if (!($cmode&$dirptr)) {
228: ($status, $pubstatus) = &getStatus($resdir, $targetdir, $cstr_dir,
229: $filename, $linkfilename, $cmtime, $meta_same);
230: ($fulltitle, $title) = &getTitle($resdir, $targetdir, $filename,
231: $linkfilename, $meta_same, \%bombs);
232: } else {
233: ($status, $pubstatus) = ('','');
234: ($fulltitle, $title) = ('','');
235: }
1.150 musolffc 236:
1.152 musolffc 237: # This hash will allow sorting
238: $filehash->{ $filename } = {
239: "cmtime" => $cmtime,
240: "size" => $size,
241: "cmode" => $cmode,
242: "filetype" => $filetype,
243: "title" => $title,
244: "fulltitle" => $fulltitle,
245: "status" => $status,
246: "pubstatus" => $pubstatus,
247: "linkfilename" => $linkfilename,
248: }
249: }
250:
251: my @sorted_files;
252: # Sorting by something other than "Name". Name is the secondary key.
253: if ($sortby =~ m{cmtime|size}) { # Numeric fields
254: # First check if order should be reversed
255: if ($sortorder eq "rev") {
256: @sorted_files = sort {
257: $filehash->{$a}->{$sortby} <=> $filehash->{$b}->{$sortby}
258: or
259: uc($a) cmp uc($b)
260: } (keys(%{$filehash}));
261: } else {
262: @sorted_files = sort {
263: $filehash->{$b}->{$sortby} <=> $filehash->{$a}->{$sortby}
264: or
265: uc($a) cmp uc($b)
266: } (keys(%{$filehash}));
267: }
268: } elsif ($sortby =~ m{filetype|title|status}) { # String fields
269: if ($sortorder eq "rev") {
270: @sorted_files = sort {
271: $filehash->{$b}->{$sortby} cmp $filehash->{$a}->{$sortby}
272: or
273: uc($a) cmp uc($b)
274: } (keys(%{$filehash}));
275: } else {
276: @sorted_files = sort {
277: $filehash->{$a}->{$sortby} cmp $filehash->{$b}->{$sortby}
278: or
279: uc($a) cmp uc($b)
280: } (keys(%{$filehash}));
281: }
282:
283: # Sort by "Name" is the default
284: } else {
285: if ($sortorder eq "rev") {
286: @sorted_files = sort {uc($b) cmp uc($a)} (keys(%{$filehash}));
287: } else {
288: @sorted_files = sort {uc($a) cmp uc($b)} (keys(%{$filehash}));
289: }
290: }
291:
292: # Print the sorted resources
293: foreach my $filename (@sorted_files) {
294: if ($filehash->{$filename}->{"cmode"}&$dirptr) { # Directories
295: &putdirectory($r, $thisdisfn, $linkdir, $filename,
296: $filehash->{$filename}->{"cmtime"},
297: $targetdir, \%bombs, \$numdir);
298: } else { # Files
299: &putresource($r, $udom, $uname, $filename, $thisdisfn, $resdir,
300: $targetdir, $linkdir, $filehash->{$filename}->{"cmtime"},
301: $filehash->{$filename}->{"size"}, \$numres,
302: $filehash->{$filename}->{"linkfilename"},
303: $filehash->{$filename}->{"fulltitle"},
304: $filehash->{$filename}->{"status"},
305: $filehash->{$filename}->{"pubstatus"});
306: }
307: }
308:
309: $r->print( &Apache::loncommon::end_data_table()
310: .&Apache::loncommon::end_page() );
1.2 www 311:
1.154 raeburn 312: return OK;
1.1 www 313: }
1.127 www 314:
1.152 musolffc 315:
316:
1.23 foxr 317: # Output the header of the page. This includes:
318: # - The HTML header
319: # - The H1/H3 stuff which includes the directory.
320: #
1.160.2.4 raeburn 321: # startpage($r, $uame, $udom, $thisdisfn, $current_disk_usage, $disk_quota);
1.23 foxr 322: # $r - The apache request object.
323: # $uname - User name.
324: # $udom - Domain name the user is logged in under.
325: # $thisdisfn - Displayable version of the filename.
1.160.2.4 raeburn 326: # $current_disk_usage - User's current disk usage (in kB).
327: # $disk_quota - Disk quota for user's authoring space (in MB).
328: # $crstype - Course type, if this is for "course author"
1.26 www 329:
1.23 foxr 330: sub startpage {
1.160.2.4 raeburn 331: my ($r, $uname, $udom, $thisdisfn, $current_disk_usage, $disk_quota) = @_;
1.39 www 332: &Apache::loncommon::content_type($r,'text/html');
1.23 foxr 333: $r->send_http_header;
1.64 raeburn 334:
1.132 www 335: my $formaction='/priv'.$thisdisfn.'/';
1.89 albertel 336: $formaction=~s|/+|/|g;
1.66 raeburn 337: &Apache::lonhtmlcommon::store_recent('construct',$formaction,$formaction);
1.121 bisitz 338:
1.125 droeschl 339: &Apache::lonhtmlcommon::clear_breadcrumbs();
340: &Apache::lonhtmlcommon::add_breadcrumb({
1.145 raeburn 341: 'text' => 'Authoring Space',
1.137 raeburn 342: 'href' => &Apache::loncommon::authorspace($formaction),
1.125 droeschl 343: });
344: # breadcrumbs (and tools) will be created
345: # in start_page->bodytag->innerregister
346:
1.132 www 347: $env{'request.noversionuri'}=$formaction;
1.153 raeburn 348: $r->print(&Apache::loncommon::start_page('Authoring Space'));
1.90 albertel 349:
1.147 raeburn 350: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
351: my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,"$londocroot/priv/$udom/$uname");
1.153 raeburn 352: my $disk_quota = &Apache::loncommon::get_user_quota($uname,$udom,'author'); #expressed in MB
1.160.2.4 raeburn 353: $disk_quota = 1024 * $disk_quota; # convert from MB to kB
1.147 raeburn 354:
1.121 bisitz 355: $r->print(&Apache::loncommon::head_subbox(
1.147 raeburn 356: '<div style="float:right;padding-top:0;margin-top;0">'
1.160.2.1 raeburn 357: .&Apache::lonhtmlcommon::display_usage($current_disk_usage,
358: $disk_quota,'authoring')
1.147 raeburn 359: .'</div>'
360: .&Apache::loncommon::CSTR_pageheader()));
1.121 bisitz 361:
1.101 albertel 362: my $esc_thisdisfn = &Apache::loncommon::escape_single($thisdisfn);
1.145 raeburn 363: my $doctitle = 'LON-CAPA '.&mt('Authoring Space');
1.109 bisitz 364: my $newname = &mt('New Name');
1.29 www 365: my $pubdirscript=(<<ENDPUBDIRSCRIPT);
1.77 albertel 366: <script type="text/javascript">
1.107 bisitz 367: top.document.title = '$esc_thisdisfn/ - $doctitle';
1.37 www 368: // Store directory location for menu bar to find
369:
1.132 www 370: parent.lastknownpriv='/priv$esc_thisdisfn/';
1.37 www 371:
372: // Confirmation dialogues
373:
1.64 raeburn 374: function currdiract(theform) {
375: if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'publish') {
1.79 www 376: document.publishdir.filename.value = theform.filename.value;
377: document.publishdir.submit();
1.64 raeburn 378: }
1.113 schafran 379: if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'editmeta') {
1.66 raeburn 380: top.location=theform.filename.value+'default.meta'
1.64 raeburn 381: }
382: if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'printdir' ) {
383: document.printdir.postdata.value=theform.filename.value
384: document.printdir.submit();
385: }
1.88 raeburn 386: if (theform.dirtask.options[theform.dirtask.selectedIndex].value == "delete") {
387: var delform = document.delresource
388: delform.filename.value = theform.filename.value
389: delform.submit()
390: }
1.64 raeburn 391: }
392:
393: function checkUpload(theform) {
394: if (theform.file == '') {
395: alert("Please use 'Browse..' to choose a file first, before uploading")
396: return
397: }
398: theform.submit()
399: }
400:
401: function SetPubDir(theform,printForm) {
402: if (theform.diraction.options[theform.diraction.selectedIndex].value == "open") {
1.75 albertel 403: top.location = theform.openname.value
1.64 raeburn 404: return
405: }
406: if (theform.diraction.options[theform.diraction.selectedIndex].value == "publish") {
1.79 www 407: theform.submit();
1.64 raeburn 408: }
1.113 schafran 409: if (theform.diraction.options[theform.diraction.selectedIndex].value == "editmeta") {
1.66 raeburn 410: top.location=theform.filename.value+'default.meta'
1.64 raeburn 411: }
1.68 raeburn 412: if (theform.diraction.options[theform.diraction.selectedIndex].value == "printdir") {
1.64 raeburn 413: theform.action = '/adm/printout'
414: theform.postdata.value = theform.filename.value
415: theform.submit()
416: }
1.88 raeburn 417: if (theform.diraction.options[theform.diraction.selectedIndex].value == "delete") {
418: var delform = document.delresource
419: delform.filename.value = theform.filename.value
420: delform.submit()
421: }
1.64 raeburn 422: return
423: }
424: function SetResChoice(theform) {
425: var activity = theform.reschoice.options[theform.reschoice.selectedIndex].value
426: if ((activity == 'rename') || (activity == 'copy') || (activity == 'move')) {
427: changename(theform,activity)
428: }
429: if (activity == 'publish') {
430: var pubform = document.pubresource
431: pubform.filename.value = theform.filename.value
432: pubform.submit()
433: }
434: if (activity == 'delete') {
435: var delform = document.delresource
436: delform.filename.value = theform.filename.value
1.71 raeburn 437: delform.submit()
1.64 raeburn 438: }
439: if (activity == 'obsolete') {
1.68 raeburn 440: var pubform = document.pubresource
441: pubform.filename.value = theform.filename.value
1.80 www 442: pubform.makeobsolete.value=1;
1.68 raeburn 443: pubform.submit()
1.64 raeburn 444: }
445: if (activity == 'print') {
1.68 raeburn 446: document.printresource.postdata.value = theform.filename.value
1.64 raeburn 447: document.printresource.submit()
448: }
449: if (activity == 'retrieve') {
1.68 raeburn 450: document.retrieveres.filename.value = theform.filename.value
451: document.retrieveres.submit()
1.64 raeburn 452: }
1.82 www 453: if (activity == 'cleanup') {
454: document.cleanup.filename.value = theform.filename.value
455: document.cleanup.submit()
456: }
1.64 raeburn 457: return
458: }
459: function changename(theform,activity) {
1.96 banghart 460: var oldname=theform.dispfilename.value;
1.109 bisitz 461: var newname=prompt('$newname',oldname);
1.97 banghart 462: if (newname == "" || !newname || newname == oldname) {
1.64 raeburn 463: return
464: }
465: document.moveresource.newfilename.value = newname
466: document.moveresource.filename.value = theform.filename.value
467: document.moveresource.action.value = activity
468: document.moveresource.submit();
469: }
1.29 www 470: </script>
471: ENDPUBDIRSCRIPT
1.64 raeburn 472: $r->print($pubdirscript);
473: }
474:
475: sub dircontrols {
1.160.2.4 raeburn 476: my ($r,$uname,$udom,$thisdisfn, $current_disk_usage, $disk_quota) = @_;
1.84 www 477: my %lt=&Apache::lonlocal::texthash(
478: cnpd => 'Cannot publish directory',
479: cnrd => 'Cannot retrieve directory',
480: mcdi => 'Must create new subdirectory inside a directory',
481: pubr => 'Publish this Resource',
482: pubd => 'Publish this Directory',
1.88 raeburn 483: dedr => 'Delete Directory',
1.84 www 484: rtrv => 'Retrieve Old Version',
485: list => 'List Directory',
486: uplo => 'Upload file',
487: dele => 'Delete',
1.113 schafran 488: edit => 'Edit Metadata',
1.84 www 489: sela => 'Select Action',
490: nfil => 'New file',
491: nhtm => 'New HTML file',
492: nprb => 'New problem',
493: npag => 'New assembled page',
494: nseq => 'New assembled sequence',
495: ncrf => 'New custom rights file',
496: nsty => 'New style file',
497: nlib => 'New library file',
1.103 albertel 498: nbt => 'New bridgetask file',
1.84 www 499: nsub => 'New subdirectory',
500: renm => 'Rename current file to',
501: move => 'Move current file to',
502: copy => 'Copy current file to',
503: type => 'Type Name Here',
1.105 albertel 504: go => 'Go',
1.84 www 505: prnt => 'Print contents of directory',
506: crea => 'Create a new directory or LON-CAPA document',
507: acti => 'Actions for current directory',
1.105 albertel 508: updc => 'Upload a new document',
509: pick => 'Please select an action to perform using the new filename',
1.160.2.6! raeburn 510: shcu => 'Shortcuts',
1.84 www 511: );
1.160.2.6! raeburn 512: my %js_lt = &Apache::lonlocal::texthash(
! 513: nanf => 'Name of New File',
! 514: nans => 'Name of New Subdirectory',
! 515: psfn => 'Please specify file name',
! 516: );
! 517: &js_escape(\%js_lt);
1.106 bisitz 518: my $mytype = $lt{'type'}; # avoid conflict with " and ' in javascript
1.160.2.4 raeburn 519: # Calculate free space in bytes.
520: # $disk_quota is in MB and $current_disk_usage is in kB
521: my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
1.64 raeburn 522: $r->print(<<END);
1.117 harmsja 523: <div class="LC_columnSection">
1.116 bisitz 524: <div>
525: <form name="curractions" method="post" action="">
526: <fieldset>
527: <legend>$lt{'acti'}</legend>
528: <select name="dirtask" onchange="currdiract(this.form)">
1.84 www 529: <option>$lt{'sela'}</option>
530: <option value="publish">$lt{'pubd'}</option>
1.113 schafran 531: <option value="editmeta">$lt{'edit'}</option>
1.84 www 532: <option value="printdir">$lt{'prnt'}</option>
1.88 raeburn 533: <option value="delete">$lt{'dedr'}</option>
1.116 bisitz 534: </select>
1.132 www 535: <input type="hidden" name="filename" value="/priv$thisdisfn/" />
1.116 bisitz 536: </fieldset>
537: </form>
1.160.2.6! raeburn 538: <form name="publishdir" method="post" action="/adm/publish">
1.116 bisitz 539: <input type="hidden" name="pubrec" value="" />
540: <input type="hidden" name="filename" value="" />
541: </form>
1.160.2.6! raeburn 542: <form name="printdir" method="post" action="/adm/printout">
1.116 bisitz 543: <input type="hidden" name="postdata" value="" />
544: </form>
545: </div>
546:
1.160.2.3 raeburn 547: <div style="padding-bottom: 2px">
1.160.2.6! raeburn 548: <form name="upublisher" enctype="multipart/form-data" method="post" action="/adm/upload">
1.116 bisitz 549: <fieldset>
550: <legend>$lt{'updc'}</legend>
1.132 www 551: <input type="hidden" name="filename" value="/priv$thisdisfn/" />
1.160.2.6! raeburn 552: <input type="file" name="upfile" class="LC_flUpload" />
1.160.2.4 raeburn 553: <input type="hidden" id="LC_free_space" value="$free_space" />
1.116 bisitz 554: <input type="button" value="$lt{'uplo'}" onclick="checkUpload(this.form)" />
555: </fieldset>
556: </form>
557: </div>
558:
559: <div>
1.160.2.6! raeburn 560: <form name="fileaction" method="post" action="/adm/cfile">
1.116 bisitz 561: <fieldset>
562: <legend>$lt{'crea'}</legend>
563: <span class="LC_nobreak">
1.132 www 564: <input type="hidden" name="filename" value="/priv$thisdisfn/" />
1.105 albertel 565: <script type="text/javascript">
566: function validate_go() {
567: var selected = document.fileaction.action.selectedIndex;
568: if (selected == 0) {
569: alert('$lt{'pick'}');
570: } else {
571: document.fileaction.submit();
572: }
573: }
574: </script>
575: <select name="action">
576: <option value="none">$lt{'sela'}</option>
577: <option value="newfile">$lt{'nfil'}:</option>
578: <option value="newhtmlfile">$lt{'nhtm'}:</option>
579: <option value="newproblemfile">$lt{'nprb'}:</option>
580: <option value="newpagefile">$lt{'npag'}:</option>
581: <option value="newsequencefile">$lt{'nseq'}:</option>
582: <option value="newrightsfile">$lt{'ncrf'}:</option>
583: <option value="newstyfile">$lt{'nsty'}:</option>
584: <option value="newtaskfile">$lt{'nbt'}:</option>
585: <option value="newlibraryfile">$lt{'nlib'}:</option>
586: <option value="newdir">$lt{'nsub'}:</option>
1.160.2.6! raeburn 587: </select> <input type="text" id="newnameid" name="newfilename" placeholder="$lt{'type'}" value="" onfocus="if (this.value == is.empty()) this.value=''" /> <input type="button" value="Go" onclick="validate_go();" />
1.160.2.2 raeburn 588: <br />
1.160.2.6! raeburn 589: <span>$lt{'shcu'}:
1.160.2.2 raeburn 590: <input type="hidden" name="mode"/>
591: <a href="javascript:void(0)" onclick="javascript:validate_action('blank')">
592: <img src="/adm/lonIcons/unknown.gif" title="Create blank problem file"></a>
593: <a href="javascript:void(0)" onclick="javascript:validate_action('problemtempl')">
594: <img src="/adm/lonIcons/problem.gif" title="Create new problem from template"></a>
595: <a href="javascript:void(0)" onclick="javascript:validate_action('blankhtml')">
596: <img src="/adm/lonIcons/html.gif" title="Create new blank HTML file"></a>
597: <a href="javascript:void(0)" onclick="javascript:validate_action('folder')">
598: <img src="/adm/lonIcons/navmap.folder.closed.gif" title="Create new subdirectory"></a>
599: </span>
600: <script type="text/javascript">
601: function validate_action(action){
1.160.2.6! raeburn 602: if (document.getElementById('newnameid')) {
! 603: if (document.getElementById('newnameid').value == '') {
! 604: var newname;
! 605: var prompttext = "$js_lt{'nanf'}";
! 606: if (action == 'folder') {
! 607: prompttext = "$js_lt{'nans'}";
! 608: }
! 609: newname=prompt(prompttext);
! 610: if (newname != '') {
! 611: document.getElementById('newnameid').value = newname;
! 612: }
! 613: }
! 614: if (document.getElementById('newnameid').value != '') {
! 615: if (action == 'blank') {
! 616: document.fileaction.action.value='newproblemfile';
! 617: document.fileaction.mode.value='blank';
! 618: } else if (action == 'problemtempl') {
! 619: document.fileaction.action.value='newproblemfile';
! 620: validate_go();
! 621: } else if (action == 'blankhtml') {
! 622: document.fileaction.action.value='newhtmlfile';
! 623: validate_go();
! 624: } else if (action == 'folder') {
! 625: document.fileaction.action.value='newdir';
! 626: document.fileaction.mode.value='folder';
! 627: }
! 628: fileaction.submit();
! 629: } else {
! 630: alert("$js_lt{'psfn'}");
1.160.2.2 raeburn 631: }
632: }
633: }
634: </script>
1.92 albertel 635: </span>
1.116 bisitz 636: </fieldset>
637: </form>
638: </div>
639: </div>
1.64 raeburn 640: END
641: }
642:
643: sub resourceactions {
644: my ($r,$uname,$udom,$thisdisfn) = @_;
645: $r->print(<<END);
1.160.2.6! raeburn 646: <form name="moveresource" action="/adm/cfile" method="post">
1.64 raeburn 647: <input type="hidden" name="filename" value="" />
648: <input type="hidden" name="newfilename" value="" />
649: <input type="hidden" name="action" value="" />
650: </form>
1.160.2.6! raeburn 651: <form name="delresource" action="/adm/cfile" method="post">
1.64 raeburn 652: <input type="hidden" name="filename" value="" />
653: <input type="hidden" name="action" value="delete" />
654: </form>
1.160.2.6! raeburn 655: <form name="pubresource" action="/adm/publish" method="post">
1.64 raeburn 656: <input type="hidden" name="filename" value="" />
1.80 www 657: <input type="hidden" name="makeobsolete" value="0" />
1.64 raeburn 658: </form>
1.160.2.6! raeburn 659: <form name="printresource" action="/adm/printout" method="post">
1.64 raeburn 660: <input type="hidden" name="postdata" value="" />
661: </form>
1.160.2.6! raeburn 662: <form name="retrieveres" action="/adm/retrieve" method="post">
1.64 raeburn 663: <input type="hidden" name="filename" value="" />
664: </form>
1.160.2.6! raeburn 665: <form name="cleanup" action="/adm/cleanup" method="post">
1.82 www 666: <input type="hidden" name="filename" value="" />
667: </form>
1.64 raeburn 668: END
1.23 foxr 669: }
670:
671: #
672: # Get the title string or "[untitled]" if the file has no title metadata:
673: # Without the latter substitution, it's impossible to examine metadata for
674: # untitled resources. Resources may be legitimately untitled, to prevent
675: # searches from locating them.
676: #
677: # $str = getTitleString($fullname);
678: # $fullname - Fully qualified filename to check.
679: #
680: sub getTitleString {
681: my $fullname = shift;
682: my $title = &Apache::lonnet::metadata($fullname, 'title');
683:
684: unless ($title) {
1.40 www 685: $title = "[".&mt('untitled')."]";
1.23 foxr 686: }
687: return $title;
688: }
689:
1.55 www 690: sub getCopyRightString {
691: my $fullname = shift;
692: return &Apache::lonnet::metadata($fullname, 'copyright');
693: }
1.61 www 694:
695: sub getSourceRightString {
696: my $fullname = shift;
697: return &Apache::lonnet::metadata($fullname, 'sourceavail');
698: }
1.23 foxr 699: #
1.21 foxr 700: # Put out a directory table row:
1.134 raeburn 701: # putdirectory(r, base, here, dirname, modtime, targetdir, bombs, numdir)
702: # r - Apache request object.
703: # reqfile - File in request.
704: # here - Where we are in directory tree.
705: # dirname - Name of directory special file.
706: # modtime - Encoded modification time.
707: # targetdir - Publication target directory.
708: # bombs - Reference to hash of URLs with runtime error messages.
709: # numdir - Reference to scalar used to track number of sub-directories
710: # in directory (used in form name for each "actions" dropdown).
711: #
1.21 foxr 712: sub putdirectory {
1.134 raeburn 713: my ($r, $reqfile, $here, $dirname, $modtime, $targetdir, $bombs, $numdir) = @_;
1.129 www 714:
715: # construct the display filename: the directory name unless ..:
1.133 www 716:
717: my $actionitem;
718:
1.21 foxr 719: my $disfilename = $dirname;
1.130 www 720: # Don't display directory itself, and there is no way up from root directory
1.133 www 721: unless ((($dirname eq '..') && ($reqfile=~/^\/[^\/]+\/[^\/]+$/)) || ($dirname eq '.')) {
1.143 bisitz 722: my $kaputt=0;
1.134 raeburn 723: if (ref($bombs) eq 'HASH') {
1.143 bisitz 724: foreach my $key (keys(%{$bombs})) {
725: my $currentdir = &Apache::lonnet::declutter("$targetdir/$disfilename");
726: if (($key) =~ m{^\Q$currentdir\E/}) { $kaputt=1; last; }
727: }
1.134 raeburn 728: }
1.129 www 729: #
730: # Get the metadata from that directory's default.meta to display titles
731: #
1.52 www 732: %Apache::lonpublisher::metadatafields=();
733: %Apache::lonpublisher::metadatakeys=();
1.129 www 734: &Apache::lonpublisher::metaeval(
735: &Apache::lonnet::getfile($r->dir_config('lonDocRoot').$here.'/'.$dirname.'/default.meta')
736: );
1.133 www 737: if ($dirname eq '..') {
1.109 bisitz 738: $actionitem = &mt('Go to ...');
1.133 www 739: $disfilename = '<i>'.&mt('Parent Directory').'</i>';
1.64 raeburn 740: } else {
741: $actionitem =
1.160.2.6! raeburn 742: '<form name="dirselect_'.$$numdir.'" action="/adm/publish">'.
1.85 albertel 743: '<select name="diraction" onchange="SetPubDir(this.form,document)">'.
1.64 raeburn 744: '<option selected="selected">'.&mt('Select action').'</option>'.
745: '<option value="open">'.&mt('Open').'</option>'.
746: '<option value="publish">'.&mt('Publish').'</option>'.
1.113 schafran 747: '<option value="editmeta">'.&mt('Edit Metadata').'</option>'.
1.77 albertel 748: '<option value="printdir">'.&mt('Print directory').'</option>'.
1.88 raeburn 749: '<option value="delete">'.&mt('Delete directory').'</option>'.
1.64 raeburn 750: '</select>'.
1.129 www 751: '<input type="hidden" name="filename" value="'.&HTML::Entities::encode($here.'/'.$dirname,'<>&"').'/" />'.
1.75 albertel 752: '<input type="hidden" name="openname" value="'.$here.'/'.$dirname.'/" />'.
1.64 raeburn 753: '<input type="hidden" name="postdata" value="" />'.
754: '</form>';
755: $$numdir ++;
756: }
1.92 albertel 757: $r->print('<tr class="LC_browser_folder">'.
1.53 www 758: '<td><img src="'.
1.123 bisitz 759: $Apache::lonnet::perlvar{'lonIconsURL'}.'/navmap.folder.closed.gif" alt="folder" /></td>'.
1.64 raeburn 760: '<td>'.$actionitem.'</td>'.
1.160.2.6! raeburn 761: '<td><span class="LC_filename"><a href="'.&HTML::Entities::encode($here.'/'.$dirname,'<>&"').'/">'.
1.92 albertel 762: $disfilename.'</a></span></td>'.
1.134 raeburn 763: '<td colspan="3">'.($kaputt?&Apache::lonhtmlcommon::authorbombs($targetdir.'/'.$disfilename.'/'):'').$Apache::lonpublisher::metadatafields{'title'});
1.92 albertel 764: if ($Apache::lonpublisher::metadatafields{'subject'} ne '') {
765: $r->print(' <i>'.
766: $Apache::lonpublisher::metadatafields{'subject'}.
767: '</i> ');
768: }
769: $r->print($Apache::lonpublisher::metadatafields{'keywords'}.'</td>'.
1.42 www 770: '<td>'.&Apache::lonlocal::locallocaltime($modtime).'</td>'.
1.152 musolffc 771: '<td></td>'.
1.25 www 772: "</tr>\n");
1.64 raeburn 773: }
1.154 raeburn 774: return;
1.21 foxr 775: }
1.152 musolffc 776:
777: sub getTitle {
778: my ($resdir, $targetdir, $filename, $linkfilename, $meta_same, $bombs) = @_;
779: my $title='';
780: my $titleString = &getTitleString($targetdir.'/'.$filename);
781: if (-e $resdir.'/'.$filename) {
782: $title = '<a href="'.$targetdir.'/'.$filename.
783: '.meta" target="cat">'.$titleString.'</a>';
784: if (!$meta_same) {
785: $title = &mt('Metadata Modified').'<br />'.$title.
786: '<br />'.
787: &Apache::loncommon::modal_link(
788: '/adm/diff?filename='.$linkfilename.'.meta'.'&versiontwo=priv',
789: &mt('Metadata Diffs'),600,500);
790: $title.="\n".'<br />'.
791: &Apache::loncommon::modal_link(
792: '/adm/retrieve?filename='.$linkfilename.'.meta&inhibitmenu=yes&add_modal=yes',
793: &mt('Retrieve Metadata'),600,500);
794: }
795: }
796: # Allow editing metadata of published and unpublished resources
797: $title .= "\n".'<br />' if ($title);
798: $title .= '<a href="'.$linkfilename.'.meta">'.
799: ($$bombs{&Apache::lonnet::declutter($targetdir.'/'.$filename)}?
800: '<img src="/adm/lonMisc/bomb.gif" border="0" alt="'.&mt('bomb').'" />':
801: &mt('Edit Metadata')).
802: '</a>';
803:
804: return ($title, $titleString);
805: }
806:
807:
808: sub isMetaSame {
809: my ($cstr_dir, $resdir, $filename) = @_;
810: my $meta_cmtime = (stat($cstr_dir.'/'.$filename.'.meta'))[9];
811: my $meta_rmtime = (stat($resdir.'/'.$filename.'.meta'))[9];
812: return (&Apache::londiff::are_different_files($resdir.'/'.$filename.'.meta',
813: $cstr_dir.'/'.$filename.'.meta') && $meta_rmtime < $meta_cmtime)
814: ? 0 : 1;
815: }
816:
817:
818: sub getStatus {
819: my ($resdir, $targetdir, $cstr_dir, $filename,
820: $linkfilename, $cmtime, $meta_same) = @_;
1.64 raeburn 821: my $pubstatus = 'unpublished';
1.152 musolffc 822: my $status = &mt('Unpublished');
1.129 www 823:
1.22 foxr 824: if (-e $resdir.'/'.$filename) {
1.152 musolffc 825: my $same = 0;
826: if ((stat($resdir.'/'.$filename))[9] >= $cmtime) {
827: $same = 1;
1.91 www 828: } else {
829: if (&Apache::londiff::are_different_files($resdir.'/'.$filename,
1.95 albertel 830: $cstr_dir.'/'.$filename)) {
1.152 musolffc 831: $same = 0;
1.91 www 832: } else {
1.152 musolffc 833: $same = 1;
1.91 www 834: }
835: }
1.124 bisitz 836:
837: my $rights_status =
838: &mt(&getCopyRightString($targetdir.'/'.$filename)).', ';
839:
840: my %lt_SourceRight = &Apache::lonlocal::texthash(
841: 'open' => 'Source: open',
842: 'closed' => 'Source: closed',
843: );
844: $rights_status .=
845: $lt_SourceRight{&getSourceRightString($targetdir.'/'.$filename)};
846:
1.91 www 847: if ($same) {
1.40 www 848: if (&Apache::lonnet::metadata($targetdir.'/'.$filename,'obsolete')) {
1.64 raeburn 849: $pubstatus = 'obsolete';
1.41 www 850: $status=&mt('Obsolete');
1.95 albertel 851: } else {
852: if (!$meta_same) {
853: $pubstatus = 'metamodified';
854: } else {
855: $pubstatus = 'published';
856: }
857: $status=&mt('Published').
858: '<br />'. $rights_status;
859: }
1.22 foxr 860: } else {
1.64 raeburn 861: $pubstatus = 'modified';
1.95 albertel 862: $status=&mt('Modified').
863: '<br />'. $rights_status;
1.22 foxr 864: if (&Apache::loncommon::fileembstyle(($filename=~/\.(\w+)$/)) eq 'ssi') {
1.139 www 865: $status.='<br />'.
866: &Apache::loncommon::modal_link(
867: '/adm/diff?filename='.$linkfilename.'&versiontwo=priv',
868: &mt('Diffs'),600,500);
1.22 foxr 869: }
1.95 albertel 870: }
1.152 musolffc 871:
1.140 www 872: $status.="\n".'<br />'.
873: &Apache::loncommon::modal_link(
874: '/adm/retrieve?filename='.$linkfilename.'&inhibitmenu=yes&add_modal=yes',&mt('Retrieve'),600,500);
1.22 foxr 875: }
1.152 musolffc 876:
877: return ($status, $pubstatus);
878: }
879:
880:
881: #
882: # Put a table row for a file resource.
883: #
884: sub putresource {
885: my ($r, $udom, $uname, $filename, $thisdisfn, $resdir, $targetdir,
886: $linkdir, $cmtime, $size, $numres, $linkfilename, $title,
887: $status, $pubstatus) = @_;
888: &Apache::lonnet::devalidate_cache_new('meta',$targetdir.'/'.$filename);
1.143 bisitz 889:
1.33 www 890: my $editlink='';
1.38 taceyjo1 891: my $editlink2='';
1.160.2.6! raeburn 892: if ($filename=~/\.(xml|html|htm|xhtml|xhtm|sty|txt|css|js)$/) {
1.146 raeburn 893: $editlink=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=edit">'.&mt('Edit').'</a>)';
1.34 www 894: }
1.136 www 895: if ($filename=~/$LONCAPA::assess_re/) {
1.146 raeburn 896: $editlink=' (<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=editxml">'.&mt('EditXML').'</a>)';
897: $editlink2=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=edit">'.&mt('Edit').'</a>)';
1.43 taceyjo1 898: }
1.82 www 899: if ($filename=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm|sty)$/) {
1.160.2.6! raeburn 900: $editlink.=' (<a href="/adm/cleanup?filename='.$linkfilename.'">'.&mt('Clean Up').')</a>';
1.82 www 901: }
1.43 taceyjo1 902: if ($filename=~/\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) {
1.160.2.6! raeburn 903: $editlink=' (<a href="/adm/cfile?decompress='.$linkfilename.'">'.&mt('Decompress').'</a>)';
1.33 www 904: }
1.152 musolffc 905: my $publish_button = (-e $resdir.'/'.$filename) ? &mt('Re-publish') : &mt('Publish');
1.64 raeburn 906: my $pub_select = '';
907: &create_pubselect($r,\$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres);
1.115 bisitz 908: $r->print(&Apache::loncommon::start_data_table_row().
1.53 www 909: '<td>'.($filename=~/[\#\~]$/?' ':
1.86 albertel 910: '<img src="'.&Apache::loncommon::icon($filename).'" alt="" />').'</td>'.
1.64 raeburn 911: '<td>'.$pub_select.'</td>'.
1.104 albertel 912: '<td><span class="LC_filename">'.
1.160.2.6! raeburn 913: '<a href="'.$linkdir.'/'.$filename.'">'.
1.92 albertel 914: $filename.'</a></span>'.$editlink2.$editlink.
1.22 foxr 915: '</td>'.
916: '<td>'.$title.'</td>'.
1.115 bisitz 917: '<td class="LC_browser_file_'.$pubstatus.'"> </td>'. # Display publication status
918: '<td>'.$status.'</td>'.
1.42 www 919: '<td>'.&Apache::lonlocal::locallocaltime($cmtime).'</td>'.
1.153 raeburn 920: '<td>'.sprintf("%.1f",$size).'</td>'.
1.115 bisitz 921: &Apache::loncommon::end_data_table_row()
922: );
1.154 raeburn 923: return;
1.23 foxr 924: }
1.64 raeburn 925:
926: sub create_pubselect {
927: my ($r,$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres) = @_;
928: $$pub_select = '
929: <form name="resselect_'.$$numres.'" action="">
1.85 albertel 930: <select name="reschoice" onchange="SetResChoice(this.form)">
1.77 albertel 931: <option>'.&mt('Select action').'</option>'.
932: '<option value="copy">'.&mt('Copy').'</option>';
1.68 raeburn 933: if ($pubstatus eq 'obsolete' || $pubstatus eq 'unpublished') {
934: $$pub_select .=
1.77 albertel 935: '<option value="rename">'.&mt('Rename').'</option>'.
936: '<option value="move">'.&mt('Move').'</option>'.
937: '<option value="delete">'.&mt('Delete').'</option>';
1.64 raeburn 938: } else {
939: $$pub_select .= '
1.77 albertel 940: <option value="obsolete">'.&mt('Mark obsolete').'</option>';
1.64 raeburn 941: }
942: # check for versions
943: my $versions = &check_for_versions($r,'/'.$filename,$udom,$uname);
944: if ($versions > 0) {
945: $$pub_select .='
1.77 albertel 946: <option value="retrieve">'.&mt('Retrieve old version').'</option>';
1.64 raeburn 947: }
948: $$pub_select .= '
1.77 albertel 949: <option value="publish">'.$publish_button.'</option>'.
1.82 www 950: '<option value="cleanup">'.&mt('Clean up').'</option>'.
1.77 albertel 951: '<option value="print">'.&mt('Print').'</option>'.
1.68 raeburn 952: '</select>
1.131 www 953: <input type="hidden" name="filename" value="/priv'.
954: &HTML::Entities::encode($thisdisfn.'/'.$filename,'<>&"').'" />
1.96 banghart 955: <input type="hidden" name="dispfilename" value="'.
1.99 albertel 956: &HTML::Entities::encode($filename).'" /></form>';
1.64 raeburn 957: $$numres ++;
958: }
959:
960: sub check_for_versions {
961: my ($r,$fn,$udom,$uname) = @_;
962: my $versions = 0;
963: my $docroot=$r->dir_config('lonDocRoot');
964: my $resfn=$docroot.'/res/'.$udom.'/'.$uname.$fn;
965: my $resdir=$resfn;
966: $resdir=~s/\/[^\/]+$/\//;
967: $fn=~/\/([^\/]+)\.(\w+)$/;
968: my $main=$1;
969: my $suffix=$2;
970: opendir(DIR,$resdir);
971: while (my $filename=readdir(DIR)) {
972: if ($filename=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/) {
973: $versions ++;
974: }
975: }
1.154 raeburn 976: closedir(DIR);
1.64 raeburn 977: return $versions;
978: }
979:
1.4 www 980: 1;
981: __END__
1.17 harris41 982:
983:
1.114 jms 984: =head1 NAME
985:
1.145 raeburn 986: Apache::lonpubdir - Authoring space directory lister
1.114 jms 987:
988: =head1 SYNOPSIS
989:
990: Invoked (for various locations) by /etc/httpd/conf/srm.conf:
991:
1.134 raeburn 992: <LocationMatch "^/+priv.*/$">
1.114 jms 993: PerlAccessHandler Apache::loncacc
994: SetHandler perl-script
995: PerlHandler Apache::lonpubdir
996: ErrorDocument 403 /adm/login
997: ErrorDocument 404 /adm/notfound.html
998: ErrorDocument 406 /adm/unauthorized.html
999: ErrorDocument 500 /adm/errorhandler
1000: </LocationMatch>
1001:
1002: <Location /adm/pubdir>
1003: PerlAccessHandler Apache::lonacc
1004: SetHandler perl-script
1005: PerlHandler Apache::lonpubdir
1006: ErrorDocument 403 /adm/login
1007: ErrorDocument 404 /adm/notfound.html
1008: ErrorDocument 406 /adm/unauthorized.html
1009: ErrorDocument 500 /adm/errorhandler
1010: </Location>
1011:
1012: =head1 INTRODUCTION
1013:
1014: This module publishes a directory of files.
1015:
1016: This is part of the LearningOnline Network with CAPA project
1017: described at http://www.lon-capa.org.
1018:
1019: =head1 HANDLER SUBROUTINE
1020:
1021: This routine is called by Apache and mod_perl.
1022:
1023: =over 4
1024:
1025: =item *
1026:
1027: read in information
1028:
1029: =item *
1030:
1031: start page output
1032:
1033: =item *
1034:
1035: run through list of files and attempt to publish unhidden files
1036:
1037: =back
1038:
1039: =head1 SUBROUTINES:
1040:
1041: =over
1042:
1043: =item startpage($r, $uame, $udom, $thisdisfn)
1044:
1045: Output the header of the page. This includes:
1046: - The HTML header
1047: - The H1/H3 stuff which includes the directory.
1048:
1049: startpage($r, $uame, $udom, $thisdisfn);
1050: $r - The apache request object.
1051: $uname - User name.
1052: $udom - Domain name the user is logged in under.
1053: $thisdisfn - Displayable version of the filename.
1054:
1055: =item getTitleString($fullname)
1056:
1057: Get the title string or "[untitled]" if the file has no title metadata:
1058: Without the latter substitution, it's impossible to examine metadata for
1059: untitled resources. Resources may be legitimately untitled, to prevent
1060: searches from locating them.
1061:
1062: $str = getTitleString($fullname);
1063: $fullname - Fully qualified filename to check.
1064:
1.134 raeburn 1065: =item putdirectory($r, $base, $here, $dirname, $modtime, $targetdir, $bombs,
1066: $numdir)
1.114 jms 1067:
1068: Put out a directory table row:
1069:
1.134 raeburn 1070: $r - Apache request object.
1071: $reqfile - File in request.
1072: $here - Where we are in directory tree.
1073: $dirname - Name of directory special file.
1074: $modtime - Encoded modification time.
1075: targetdir - Publication target directory.
1076: bombs - Reference to hash of URLs with runtime error messages.
1077: numdir - Reference to scalar used to track number of sub-directories
1078: in directory (used in form name for each "actions" dropdown).
1.114 jms 1079:
1080: =back
1081:
1082: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>