File:
[LON-CAPA] /
loncom /
publisher /
lonpubdir.pm
Revision
1.163:
download - view:
text,
annotated -
select for diffs
Mon Jan 19 15:36:11 2015 UTC (9 years, 8 months ago) by
goltermann
Branches:
MAIN
CVS tags:
HEAD
authoring space overhaul
this update tries to improve the user experience of the authoring space.
added codemirror for xml editor and script tags in colorful editor
added possibility to deactivate codemirror in author settings
added dropdown menu to insert problem templates into xml editor (thanks to tobias reinhardt)
added feature of saving current scrollposition on save when editing problems
added possibility to fold blocks in colorful editor, this state will be saved and restored
added shortcuts to create empty problems, html files and directories
and other smaller features and bugfixes
1: # The LearningOnline Network with CAPA
2: # Authoring Space Directory Lister
3: #
4: # $Id: lonpubdir.pm,v 1.163 2015/01/19 15:36:11 goltermann Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28: ###
29:
30: package Apache::lonpubdir;
31:
32: use strict;
33: use Apache::File;
34: use File::Copy;
35: use Apache::Constants qw(:common :http :methods);
36: use Apache::loncommon();
37: use Apache::lonhtmlcommon();
38: use Apache::londiff();
39: use Apache::lonlocal;
40: use Apache::lonmsg;
41: use Apache::lonmenu;
42: use Apache::lonnet;
43: use LONCAPA qw(:DEFAULT :match);
44:
45: sub handler {
46:
47: my $r=shift;
48:
49: # Validate access to the construction space and get username:domain.
50:
51: my ($uname,$udom)=&Apache::lonnet::constructaccess($r->uri);
52: unless (($uname) && ($udom)) {
53: return HTTP_NOT_ACCEPTABLE;
54: }
55:
56: # ----------------------------------------------------------- Start page output
57:
58: my $fn=$r->filename;
59: $fn=~s/\/$//;
60: my $thisdisfn=$fn;
61:
62: my $docroot=$r->dir_config('lonDocRoot'); # Apache londocument root.
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: }
82: $thisdisfn=~s/^\Q$docroot\E\/priv//;
83:
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:
90: &startpage($r, $uname, $udom, $thisdisfn); # Put out the start of page.
91:
92: if (!-d $fn) {
93: if (-e $fn) {
94: $r->print('<p class="LC_info">'.&mt('Requested item is a file not a directory.').'</p>');
95: } else {
96: $r->print('<p class="LC_info">'.&mt('The requested subdirectory does not exist.').'</p>');
97: }
98: $r->print(&Apache::loncommon::end_page());
99: return OK;
100: }
101: my @files;
102: if (opendir(DIR,$fn)) {
103: @files = grep(!/^\.+$/,readdir(DIR));
104: closedir(DIR);
105: } else {
106: $r->print('<p class="LC_error">'.&mt('Could not open directory.').'</p>');
107: $r->print(&Apache::loncommon::end_page());
108: return OK;
109: }
110:
111: &dircontrols($r,$uname,$udom,$thisdisfn); # Put out actions for directory,
112: # browse/upload + new file page.
113: &resourceactions($r,$uname,$udom,$thisdisfn); # Put out form used for printing/deletion etc.
114:
115: my $numdir = 0;
116: my $numres = 0;
117:
118: if ((@files == 0) && ($thisdisfn =~ m{^/$match_domain/$match_username})) {
119: if ($thisdisfn =~ m{^/$match_domain/$match_username$}) {
120: $r->print('<p class="LC_info">'.&mt('This Authoring Space is currently empty.').'</p>');
121: } else {
122: $r->print('<p class="LC_info">'.&mt('This subdirectory is currently empty.').'</p>');
123: }
124: $r->print(&Apache::loncommon::end_page());
125: return OK;
126: }
127:
128: # Retrieving value for "sortby" and "sortorder" from QUERY_STRING
129: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
130: ['sortby','sortorder']);
131:
132: # Sort by name as default, not reversed
133: if (! exists($env{'form.sortby'})) { $env{'form.sortby'} = 'filename' }
134: if (! exists($env{'form.sortorder'})) { $env{'form.sortorder'} = '' }
135: my $sortby = $env{'form.sortby'};
136: my $sortorder = $env{'form.sortorder'};
137:
138: # Order in which columns are displayed from left to right
139: my @order = ('filetype','actions','filename','title',
140: 'pubstatus','cmtime','size');
141:
142: # Up and down arrows to indicate sort order
143: my @arrows = (' ▲',' ▼','');
144:
145: # Default sort order and column title
146: my %columns = (
147: filetype => {
148: order => 'ascending',
149: text => &mt('Type'),
150: },
151: actions => {
152: # Not sortable
153: text => &mt('Actions'),
154: },
155: filename => {
156: order => 'ascending',
157: text => &mt('Name'),
158: },
159: title => {
160: order => 'ascending',
161: text => &mt('Title'),
162: },
163: pubstatus => {
164: order => 'ascending',
165: text => &mt('Status'),
166: colspan => '2',
167: },
168: cmtime => {
169: order => 'descending',
170: text => &mt('Last Modified'),
171: },
172: size => {
173: order => 'ascending',
174: text => &mt('Size').' (kB)',
175: },
176: );
177:
178: # Print column headers
179: my $output = '';
180: foreach my $key (@order) {
181: my $idx;
182: # Append an up or down arrow to sorted column
183: if ($sortby eq $key) {
184: $idx = ($columns{$key}{order} eq 'ascending') ? 0:1;
185: if ($sortorder eq 'rev') { $idx ++; }
186: $idx = $idx%2;
187: } else { $idx = 2; } # No arrow if column is not sorted
188: $output .= (($columns{$key}{order}) ?
189: '<th'.($columns{$key}{colspan} ? ' colspan="'.$columns{$key}{colspan}.'"' : '')
190: .'><a href="'.$linkdir.'/?sortby='.$key.'&sortorder='
191: .((($sortby eq $key) && ($sortorder ne 'rev')) ? 'rev' : '').'">'
192: .$columns{$key}{text}.$arrows[$idx].'</a></th>' :
193: '<th>'.$columns{$key}{text}.'</th>');
194: }
195:
196: my $result = "<script type=\"text/javascript\">
197: sessionStorage.setItem('CSTRcache','".&prepareJsonData($uname,$udom,$thisdisfn)."');
198: localStorage.setItem('CSTRtrans', '".&prepareJsonTranslations()."');
199: </script>";
200: $r->print($result);
201:
202: $r->print('<div id="currentFolder">'.&Apache::loncommon::start_data_table()
203: .'<tr><th colspan="8" id="searchtitle" style="display:none"></th></tr>'
204: .&Apache::loncommon::start_data_table_header_row() . $output
205: .&Apache::loncommon::end_data_table_header_row()
206: );
207:
208: my $dirptr=16384; # Mask indicating a directory in stat.cmode.
209: my $filehash = {};
210: foreach my $filename (@files) {
211: # Skip .DS_Store, .DAV and hidden files
212: my ($extension) = ($filename=~/\.(\w+)$/);
213: next if (($filename eq '.DS_Store')
214: || ($filename eq '.DAV')
215: || (&Apache::loncommon::fileembstyle($extension) eq 'hdn')
216: || ($filename =~ /^\._/));
217:
218: my ($cmode,$csize,$cmtime)=(stat($fn.'/'.$filename))[2,7,9];
219: my $linkfilename = &HTML::Entities::encode('/priv'.$thisdisfn.'/'.$filename,'<>&"');
220: # Identify type of file according to icon used
221: my ($filetype) = (&Apache::loncommon::icon($filename) =~ m{/(\w+).gif$});
222: my $cstr_dir = $r->dir_config('lonDocRoot').'/priv'.$thisdisfn;
223: my $meta_same = &isMetaSame($cstr_dir, $resdir, $filename);
224:
225: # Store size, title, and status for files but not directories
226: my $size = (!($cmode&$dirptr)) ? $csize/1024. : 0;
227: my ($status, $pubstatus, $title, $fulltitle);
228: if (!($cmode&$dirptr)) {
229: ($status, $pubstatus) = &getStatus($resdir, $targetdir, $cstr_dir,
230: $filename, $linkfilename, $cmtime, $meta_same);
231: ($fulltitle, $title) = &getTitle($resdir, $targetdir, $filename,
232: $linkfilename, $meta_same, \%bombs);
233: } else {
234: ($status, $pubstatus) = ('','');
235: ($fulltitle, $title) = ('','');
236: }
237:
238: # This hash will allow sorting
239: $filehash->{ $filename } = {
240: "cmtime" => $cmtime,
241: "size" => $size,
242: "cmode" => $cmode,
243: "filetype" => $filetype,
244: "title" => $title,
245: "fulltitle" => $fulltitle,
246: "status" => $status,
247: "pubstatus" => $pubstatus,
248: "linkfilename" => $linkfilename,
249: }
250: }
251:
252: my @sorted_files;
253: # Sorting by something other than "Name". Name is the secondary key.
254: if ($sortby =~ m{cmtime|size}) { # Numeric fields
255: # First check if order should be reversed
256: if ($sortorder eq "rev") {
257: @sorted_files = sort {
258: $filehash->{$a}->{$sortby} <=> $filehash->{$b}->{$sortby}
259: or
260: uc($a) cmp uc($b)
261: } (keys(%{$filehash}));
262: } else {
263: @sorted_files = sort {
264: $filehash->{$b}->{$sortby} <=> $filehash->{$a}->{$sortby}
265: or
266: uc($a) cmp uc($b)
267: } (keys(%{$filehash}));
268: }
269: } elsif ($sortby =~ m{filetype|title|status}) { # String fields
270: if ($sortorder eq "rev") {
271: @sorted_files = sort {
272: $filehash->{$b}->{$sortby} cmp $filehash->{$a}->{$sortby}
273: or
274: uc($a) cmp uc($b)
275: } (keys(%{$filehash}));
276: } else {
277: @sorted_files = sort {
278: $filehash->{$a}->{$sortby} cmp $filehash->{$b}->{$sortby}
279: or
280: uc($a) cmp uc($b)
281: } (keys(%{$filehash}));
282: }
283:
284: # Sort by "Name" is the default
285: } else {
286: if ($sortorder eq "rev") {
287: @sorted_files = sort {uc($b) cmp uc($a)} (keys(%{$filehash}));
288: } else {
289: @sorted_files = sort {uc($a) cmp uc($b)} (keys(%{$filehash}));
290: }
291: }
292:
293: # Print the sorted resources
294: foreach my $filename (@sorted_files) {
295: if ($filehash->{$filename}->{"cmode"}&$dirptr) { # Directories
296: &putdirectory($r, $thisdisfn, $linkdir, $filename,
297: $filehash->{$filename}->{"cmtime"},
298: $targetdir, \%bombs, \$numdir);
299: } else { # Files
300: &putresource($r, $udom, $uname, $filename, $thisdisfn, $resdir,
301: $targetdir, $linkdir, $filehash->{$filename}->{"cmtime"},
302: $filehash->{$filename}->{"size"}, \$numres,
303: $filehash->{$filename}->{"linkfilename"},
304: $filehash->{$filename}->{"fulltitle"},
305: $filehash->{$filename}->{"status"},
306: $filehash->{$filename}->{"pubstatus"});
307: }
308: }
309:
310: $r->print(&Apache::loncommon::end_data_table()
311: .'</div><div id="otherplaces" style="display:none">'
312: .&Apache::loncommon::start_data_table()
313: .'<tr><th colspan="7">'.&mt('Results in other directories:').'</th></tr>'
314: .'<tr class="LC_header_row" id="otherplacestable">'
315: .'<th>'.&mt('Type').'</th>'
316: .'<th>'.&mt('Directory').'</th>'
317: .'<th>'.&mt('Name').'</th>'
318: .'<th>'.&mt('Title').'</th>'
319: .'<th colspan="2">'.&mt('Status').'</th>'
320: .'<th>'.&mt('Last Modified').'</th>'
321: .'</tr>'
322: .&Apache::loncommon::end_data_table()
323: .'</div>'
324: .&Apache::loncommon::end_page()
325: );
326: return OK;
327: }
328:
329:
330:
331: # Output the header of the page. This includes:
332: # - The HTML header
333: # - The H1/H3 stuff which includes the directory.
334: #
335: # startpage($r, $uame, $udom, $thisdisfn);
336: # $r - The apache request object.
337: # $uname - User name.
338: # $udom - Domain name the user is logged in under.
339: # $thisdisfn - Displayable version of the filename.
340:
341: sub startpage {
342: my ($r, $uname, $udom, $thisdisfn) = @_;
343: &Apache::loncommon::content_type($r,'text/html');
344: $r->send_http_header;
345:
346: my $formaction='/priv'.$thisdisfn.'/';
347: $formaction=~s|/+|/|g;
348: &Apache::lonhtmlcommon::store_recent('construct',$formaction,$formaction);
349:
350: &Apache::lonhtmlcommon::clear_breadcrumbs();
351: &Apache::lonhtmlcommon::add_breadcrumb({
352: 'text' => 'Authoring Space',
353: 'href' => &Apache::loncommon::authorspace($formaction),
354: });
355: # breadcrumbs (and tools) will be created
356: # in start_page->bodytag->innerregister
357:
358: $env{'request.noversionuri'}=$formaction;
359: $r->print(&Apache::loncommon::start_page('Authoring Space'));
360:
361: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
362: my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,"$londocroot/priv/$udom/$uname");
363: my $disk_quota = &Apache::loncommon::get_user_quota($uname,$udom,'author'); #expressed in MB
364: $disk_quota = 1000 * $disk_quota; # convert from MB to kB
365:
366: $r->print(&Apache::loncommon::head_subbox(
367: '<div style="float:right;padding-top:0;margin-top;0">'
368: .&Apache::lonhtmlcommon::display_usage($current_disk_usage,$disk_quota)
369: .'</div>'
370: .&Apache::loncommon::CSTR_pageheader()));
371:
372: my $esc_thisdisfn = &Apache::loncommon::escape_single($thisdisfn);
373: my $doctitle = 'LON-CAPA '.&mt('Authoring Space');
374: my $newname = &mt('New Name');
375: my $pubdirscript=(<<ENDPUBDIRSCRIPT);
376: <script type="text/javascript">
377: top.document.title = '$esc_thisdisfn/ - $doctitle';
378: // Store directory location for menu bar to find
379:
380: parent.lastknownpriv='/priv$esc_thisdisfn/';
381:
382: // Confirmation dialogues
383:
384: function currdiract(theform) {
385: if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'publish') {
386: document.publishdir.filename.value = theform.filename.value;
387: document.publishdir.submit();
388: }
389: if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'editmeta') {
390: top.location=theform.filename.value+'default.meta'
391: }
392: if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'printdir' ) {
393: document.printdir.postdata.value=theform.filename.value
394: document.printdir.submit();
395: }
396: if (theform.dirtask.options[theform.dirtask.selectedIndex].value == "delete") {
397: var delform = document.delresource
398: delform.filename.value = theform.filename.value
399: delform.submit()
400: }
401: }
402:
403: function checkUpload(theform) {
404: if (theform.file == '') {
405: alert("Please use 'Browse..' to choose a file first, before uploading")
406: return
407: }
408: theform.submit()
409: }
410:
411: function SetPubDir(theform,printForm) {
412: if (theform.diraction.options[theform.diraction.selectedIndex].value == "open") {
413: top.location = theform.openname.value
414: return
415: }
416: if (theform.diraction.options[theform.diraction.selectedIndex].value == "publish") {
417: theform.submit();
418: }
419: if (theform.diraction.options[theform.diraction.selectedIndex].value == "editmeta") {
420: top.location=theform.filename.value+'default.meta'
421: }
422: if (theform.diraction.options[theform.diraction.selectedIndex].value == "printdir") {
423: theform.action = '/adm/printout'
424: theform.postdata.value = theform.filename.value
425: theform.submit()
426: }
427: if (theform.diraction.options[theform.diraction.selectedIndex].value == "delete") {
428: var delform = document.delresource
429: delform.filename.value = theform.filename.value
430: delform.submit()
431: }
432: return
433: }
434: function SetResChoice(theform) {
435: var activity = theform.reschoice.options[theform.reschoice.selectedIndex].value
436: if ((activity == 'rename') || (activity == 'copy') || (activity == 'move')) {
437: changename(theform,activity)
438: }
439: if (activity == 'publish') {
440: var pubform = document.pubresource
441: pubform.filename.value = theform.filename.value
442: pubform.submit()
443: }
444: if (activity == 'delete') {
445: var delform = document.delresource
446: delform.filename.value = theform.filename.value
447: delform.submit()
448: }
449: if (activity == 'obsolete') {
450: var pubform = document.pubresource
451: pubform.filename.value = theform.filename.value
452: pubform.makeobsolete.value=1;
453: pubform.submit()
454: }
455: if (activity == 'print') {
456: document.printresource.postdata.value = theform.filename.value
457: document.printresource.submit()
458: }
459: if (activity == 'retrieve') {
460: document.retrieveres.filename.value = theform.filename.value
461: document.retrieveres.submit()
462: }
463: if (activity == 'cleanup') {
464: document.cleanup.filename.value = theform.filename.value
465: document.cleanup.submit()
466: }
467: return
468: }
469: function changename(theform,activity) {
470: var oldname=theform.dispfilename.value;
471: var newname=prompt('$newname',oldname);
472: if (newname == "" || !newname || newname == oldname) {
473: return
474: }
475: document.moveresource.newfilename.value = newname
476: document.moveresource.filename.value = theform.filename.value
477: document.moveresource.action.value = activity
478: document.moveresource.submit();
479: }
480: </script>
481: ENDPUBDIRSCRIPT
482: $r->print($pubdirscript);
483: }
484:
485: sub dircontrols {
486: my ($r,$uname,$udom,$thisdisfn) = @_;
487: my %lt=&Apache::lonlocal::texthash(
488: cnpd => 'Cannot publish directory',
489: cnrd => 'Cannot retrieve directory',
490: mcdi => 'Must create new subdirectory inside a directory',
491: pubr => 'Publish this Resource',
492: pubd => 'Publish this Directory',
493: dedr => 'Delete Directory',
494: rtrv => 'Retrieve Old Version',
495: list => 'List Directory',
496: uplo => 'Upload file',
497: dele => 'Delete',
498: edit => 'Edit Metadata',
499: sela => 'Select Action',
500: nfil => 'New file',
501: nhtm => 'New HTML file',
502: nprb => 'New problem',
503: npag => 'New assembled page',
504: nseq => 'New assembled sequence',
505: ncrf => 'New custom rights file',
506: nsty => 'New style file',
507: nlib => 'New library file',
508: nbt => 'New bridgetask file',
509: nsub => 'New subdirectory',
510: renm => 'Rename current file to',
511: move => 'Move current file to',
512: copy => 'Copy current file to',
513: type => 'Type Name Here',
514: go => 'Go',
515: prnt => 'Print contents of directory',
516: crea => 'Create a new directory or LON-CAPA document',
517: qs => 'Quick Search',
518: cs => 'Case Sensitive',
519: re => 'Regular Expression',
520: acti => 'Actions for current directory',
521: updc => 'Upload a new document',
522: pick => 'Please select an action to perform using the new filename',
523: );
524: my $mytype = $lt{'type'}; # avoid conflict with " and ' in javascript
525: $r->printf(<<END,&Apache::loncommon::help_open_topic('Quicksearch'));
526: <div class="LC_columnSection">
527: <div>
528: <form name="curractions" method="post" action="">
529: <fieldset>
530: <legend>$lt{'acti'}</legend>
531: <select name="dirtask" onchange="currdiract(this.form)">
532: <option>$lt{'sela'}</option>
533: <option value="publish">$lt{'pubd'}</option>
534: <option value="editmeta">$lt{'edit'}</option>
535: <option value="printdir">$lt{'prnt'}</option>
536: <option value="delete">$lt{'dedr'}</option>
537: </select>
538: <input type="hidden" name="filename" value="/priv$thisdisfn/" />
539: </fieldset>
540: </form>
541: <form name="publishdir" method="post" action="/adm/publish" target="_parent">
542: <input type="hidden" name="pubrec" value="" />
543: <input type="hidden" name="filename" value="" />
544: </form>
545: <form name="printdir" method="post" action="/adm/printout" target="_parent">
546: <input type="hidden" name="postdata" value="" />
547: </form>
548: </div>
549:
550: <div>
551: <form name="upublisher" enctype="multipart/form-data" method="post" action="/adm/upload" target="_parent">
552: <fieldset>
553: <legend>$lt{'updc'}</legend>
554: <input type="hidden" name="filename" value="/priv$thisdisfn/" />
555: <input type="file" name="upfile" size="20" />
556: <input type="button" value="$lt{'uplo'}" onclick="checkUpload(this.form)" />
557: </fieldset>
558: </form>
559: </div>
560:
561: <div>
562: <form name="fileaction" method="post" action="/adm/cfile" target="_parent">
563: <fieldset>
564: <legend>$lt{'crea'}</legend>
565: <span class="LC_nobreak">
566: <input type="hidden" name="filename" value="/priv$thisdisfn/" />
567: <script type="text/javascript">
568: function validate_go() {
569: var selected = document.fileaction.action.selectedIndex;
570: if (selected == 0) {
571: alert('$lt{'pick'}');
572: } else {
573: document.fileaction.submit();
574: }
575: }
576: </script>
577: <select name="action">
578: <option value="none">$lt{'sela'}</option>
579: <option value="newfile">$lt{'nfil'}:</option>
580: <option value="newhtmlfile">$lt{'nhtm'}:</option>
581: <option value="newproblemfile">$lt{'nprb'}:</option>
582: <option value="newpagefile">$lt{'npag'}:</option>
583: <option value="newsequencefile">$lt{'nseq'}:</option>
584: <option value="newrightsfile">$lt{'ncrf'}:</option>
585: <option value="newstyfile">$lt{'nsty'}:</option>
586: <option value="newtaskfile">$lt{'nbt'}:</option>
587: <option value="newlibraryfile">$lt{'nlib'}:</option>
588: <option value="newdir">$lt{'nsub'}:</option>
589: </select> <input type="text" name="newfilename" placeholder="$lt{'type'}" value="" onfocus="if (this.value == is.empty()) this.value=''" /> <input type="button" value="Go" onclick="validate_go();" />
590: <br />
591: <span>Quickactions:
592: <input type="hidden" name="mode"/>
593: <a href="javascript:void(0)" onclick="javascript:validate_action('blank')">
594: <img src="/adm/lonIcons/unknown.gif" title="Create blank problem file"></a>
595: <a href="javascript:void(0)" onclick="javascript:validate_action('problemtempl')">
596: <img src="/adm/lonIcons/problem.gif" title="Create new problem from template"></a>
597: <a href="javascript:void(0)" onclick="javascript:validate_action('blankhtml')">
598: <img src="/adm/lonIcons/html.gif" title="Create new blank HTML file"></a>
599: <a href="javascript:void(0)" onclick="javascript:validate_action('folder')">
600: <img src="/adm/lonIcons/navmap.folder.closed.gif" title="Create new subdirectory"></a>
601: </span>
602: <script type="text/javascript">
603: function validate_action(action){
604:
605: if (document.getElementsByName(\'newfilename\')[0].value != \'\'){
606: if (action == "blank") {
607: document.fileaction.action.value=\'newproblemfile\';
608: document.fileaction.mode.value=\'blank\';
609: } else if (action == "problemtempl") {
610: document.fileaction.action.value=\'newproblemfile\';
611: validate_go();
612: } else if (action == "blankhtml") {
613: document.fileaction.action.value=\'newhtmlfile\';
614: validate_go();
615: } else if (action == "folder") {
616: document.fileaction.action.value=\'newdir\';
617: document.fileaction.mode.value=\'folder\';
618: }
619: fileaction.submit();
620: } else {
621: alert(\'Please specify file name.\');
622: // TODO: ask for filename? if so, do some refactoring
623:
624: }
625: }
626: </script>
627: </span>
628: </fieldset>
629: </form>
630: </div>
631: <div>
632: <fieldset style="display:inline">
633: <legend>$lt{'qs'}</legend>
634: <script type="text/javascript" src="/adm/quicksearch/quicksearch.js"></script>
635: <input type="text" id="quickfilter" placeholder="Enter search term" onkeyup="applyFilter()"/>
636: <input type="button" value="Clear" onclick="document.getElementById(\'quickfilter\').value=\'\'; applyFilter()" />
637: %s
638: <br />
639: <label><input type="checkbox" id="casesens" onchange="applyFilter()"/>$lt{'cs'} </label>
640: <label><input type="checkbox" id="regex" onchange="applyFilter()"/>$lt{'re'} </label>
641: </fieldset>
642: </div>
643: </div>
644: END
645: }
646:
647: sub resourceactions {
648: my ($r,$uname,$udom,$thisdisfn) = @_;
649: $r->print(<<END);
650: <form name="moveresource" action="/adm/cfile" target="_parent" method="post">
651: <input type="hidden" name="filename" value="" />
652: <input type="hidden" name="newfilename" value="" />
653: <input type="hidden" name="action" value="" />
654: </form>
655: <form name="delresource" action="/adm/cfile" target="_parent" method="post">
656: <input type="hidden" name="filename" value="" />
657: <input type="hidden" name="action" value="delete" />
658: </form>
659: <form name="pubresource" action="/adm/publish" target="_parent" method="post">
660: <input type="hidden" name="filename" value="" />
661: <input type="hidden" name="makeobsolete" value="0" />
662: </form>
663: <form name="printresource" action="/adm/printout" target="_parent" method="post">
664: <input type="hidden" name="postdata" value="" />
665: </form>
666: <form name="retrieveres" action="/adm/retrieve" target="_parent" method="post">
667: <input type="hidden" name="filename" value="" />
668: </form>
669: <form name="cleanup" action="/adm/cleanup" target="_parent" method="post">
670: <input type="hidden" name="filename" value="" />
671: </form>
672: END
673: }
674:
675: #
676: # Get the title string or "[untitled]" if the file has no title metadata:
677: # Without the latter substitution, it's impossible to examine metadata for
678: # untitled resources. Resources may be legitimately untitled, to prevent
679: # searches from locating them.
680: #
681: # $str = getTitleString($fullname);
682: # $fullname - Fully qualified filename to check.
683: #
684: sub getTitleString {
685: my $fullname = shift;
686: my $title = &Apache::lonnet::metadata($fullname, 'title');
687:
688: unless ($title) {
689: $title = "[".&mt('untitled')."]";
690: }
691: return $title;
692: }
693:
694: sub getCopyRightString {
695: my $fullname = shift;
696: return &Apache::lonnet::metadata($fullname, 'copyright');
697: }
698:
699: sub getSourceRightString {
700: my $fullname = shift;
701: return &Apache::lonnet::metadata($fullname, 'sourceavail');
702: }
703: #
704: # Put out a directory table row:
705: # putdirectory(r, base, here, dirname, modtime, targetdir, bombs, numdir)
706: # r - Apache request object.
707: # reqfile - File in request.
708: # here - Where we are in directory tree.
709: # dirname - Name of directory special file.
710: # modtime - Encoded modification time.
711: # targetdir - Publication target directory.
712: # bombs - Reference to hash of URLs with runtime error messages.
713: # numdir - Reference to scalar used to track number of sub-directories
714: # in directory (used in form name for each "actions" dropdown).
715: #
716: sub putdirectory {
717: my ($r, $reqfile, $here, $dirname, $modtime, $targetdir, $bombs, $numdir) = @_;
718:
719: # construct the display filename: the directory name unless ..:
720:
721: my $actionitem;
722:
723: my $disfilename = $dirname;
724: # Don't display directory itself, and there is no way up from root directory
725: unless ((($dirname eq '..') && ($reqfile=~/^\/[^\/]+\/[^\/]+$/)) || ($dirname eq '.')) {
726: my $kaputt=0;
727: if (ref($bombs) eq 'HASH') {
728: foreach my $key (keys(%{$bombs})) {
729: my $currentdir = &Apache::lonnet::declutter("$targetdir/$disfilename");
730: if (($key) =~ m{^\Q$currentdir\E/}) { $kaputt=1; last; }
731: }
732: }
733: #
734: # Get the metadata from that directory's default.meta to display titles
735: #
736: %Apache::lonpublisher::metadatafields=();
737: %Apache::lonpublisher::metadatakeys=();
738: &Apache::lonpublisher::metaeval(
739: &Apache::lonnet::getfile($r->dir_config('lonDocRoot').$here.'/'.$dirname.'/default.meta')
740: );
741: if ($dirname eq '..') {
742: $actionitem = &mt('Go to ...');
743: $disfilename = '<i>'.&mt('Parent Directory').'</i>';
744: } else {
745: $actionitem =
746: '<form name="dirselect_'.$$numdir.
747: '" action="/adm/publish" target="_parent">'.
748: '<select name="diraction" onchange="SetPubDir(this.form,document)">'.
749: '<option selected="selected">'.&mt('Select action').'</option>'.
750: '<option value="open">'.&mt('Open').'</option>'.
751: '<option value="publish">'.&mt('Publish').'</option>'.
752: '<option value="editmeta">'.&mt('Edit Metadata').'</option>'.
753: '<option value="printdir">'.&mt('Print directory').'</option>'.
754: '<option value="delete">'.&mt('Delete directory').'</option>'.
755: '</select>'.
756: '<input type="hidden" name="filename" value="'.&HTML::Entities::encode($here.'/'.$dirname,'<>&"').'/" />'.
757: '<input type="hidden" name="openname" value="'.$here.'/'.$dirname.'/" />'.
758: '<input type="hidden" name="postdata" value="" />'.
759: '</form>';
760: $$numdir ++;
761: }
762: $r->print('<tr class="LC_browser_folder">'.
763: '<td><img src="'.
764: $Apache::lonnet::perlvar{'lonIconsURL'}.'/navmap.folder.closed.gif" alt="folder" /></td>'.
765: '<td>'.$actionitem.'</td>'.
766: '<td><span class="LC_filename"><a href="'.&HTML::Entities::encode($here.'/'.$dirname,'<>&"').'/" target="_parent">'.
767: $disfilename.'</a></span></td>'.
768: '<td colspan="3">'.($kaputt?&Apache::lonhtmlcommon::authorbombs($targetdir.'/'.$disfilename.'/'):'').$Apache::lonpublisher::metadatafields{'title'});
769: if ($Apache::lonpublisher::metadatafields{'subject'} ne '') {
770: $r->print(' <i>'.
771: $Apache::lonpublisher::metadatafields{'subject'}.
772: '</i> ');
773: }
774: $r->print($Apache::lonpublisher::metadatafields{'keywords'}.'</td>'.
775: '<td>'.&Apache::lonlocal::locallocaltime($modtime).'</td>'.
776: '<td></td>'.
777: "</tr>\n");
778: }
779: return;
780: }
781:
782: sub getTitle {
783: my ($resdir, $targetdir, $filename, $linkfilename, $meta_same, $bombs) = @_;
784: my $title='';
785: my $titleString = &getTitleString($targetdir.'/'.$filename);
786: if (-e $resdir.'/'.$filename) {
787: $title = '<a href="'.$targetdir.'/'.$filename.
788: '.meta" target="cat">'.$titleString.'</a>';
789: if (!$meta_same) {
790: $title = &mt('Metadata Modified').'<br />'.$title.
791: '<br />'.
792: &Apache::loncommon::modal_link(
793: '/adm/diff?filename='.$linkfilename.'.meta'.'&versiontwo=priv',
794: &mt('Metadata Diffs'),600,500);
795: $title.="\n".'<br />'.
796: &Apache::loncommon::modal_link(
797: '/adm/retrieve?filename='.$linkfilename.'.meta&inhibitmenu=yes&add_modal=yes',
798: &mt('Retrieve Metadata'),600,500);
799: }
800: }
801: # Allow editing metadata of published and unpublished resources
802: $title .= "\n".'<br />' if ($title);
803: $title .= '<a href="'.$linkfilename.'.meta">'.
804: ($$bombs{&Apache::lonnet::declutter($targetdir.'/'.$filename)}?
805: '<img src="/adm/lonMisc/bomb.gif" border="0" alt="'.&mt('bomb').'" />':
806: &mt('Edit Metadata')).
807: '</a>';
808:
809: return ($title, $titleString);
810: }
811:
812:
813: sub isMetaSame {
814: my ($cstr_dir, $resdir, $filename) = @_;
815: my $meta_cmtime = (stat($cstr_dir.'/'.$filename.'.meta'))[9];
816: my $meta_rmtime = (stat($resdir.'/'.$filename.'.meta'))[9];
817: return (&Apache::londiff::are_different_files($resdir.'/'.$filename.'.meta',
818: $cstr_dir.'/'.$filename.'.meta') && $meta_rmtime < $meta_cmtime)
819: ? 0 : 1;
820: }
821:
822:
823: sub getStatus {
824: my ($resdir, $targetdir, $cstr_dir, $filename,
825: $linkfilename, $cmtime, $meta_same) = @_;
826: my $pubstatus = 'unpublished';
827: my $status = &mt('Unpublished');
828:
829: if (-e $resdir.'/'.$filename) {
830: my $same = 0;
831: if ((stat($resdir.'/'.$filename))[9] >= $cmtime) {
832: $same = 1;
833: } else {
834: if (&Apache::londiff::are_different_files($resdir.'/'.$filename,
835: $cstr_dir.'/'.$filename)) {
836: $same = 0;
837: } else {
838: $same = 1;
839: }
840: }
841:
842: my $rights_status =
843: &mt(&getCopyRightString($targetdir.'/'.$filename)).', ';
844:
845: my %lt_SourceRight = &Apache::lonlocal::texthash(
846: 'open' => 'Source: open',
847: 'closed' => 'Source: closed',
848: );
849: $rights_status .=
850: $lt_SourceRight{&getSourceRightString($targetdir.'/'.$filename)};
851:
852: if ($same) {
853: if (&Apache::lonnet::metadata($targetdir.'/'.$filename,'obsolete')) {
854: $pubstatus = 'obsolete';
855: $status=&mt('Obsolete');
856: } else {
857: if (!$meta_same) {
858: $pubstatus = 'metamodified';
859: } else {
860: $pubstatus = 'published';
861: }
862: $status=&mt('Published').
863: '<br />'. $rights_status;
864: }
865: } else {
866: $pubstatus = 'modified';
867: $status=&mt('Modified').
868: '<br />'. $rights_status;
869: if (&Apache::loncommon::fileembstyle(($filename=~/\.(\w+)$/)) eq 'ssi') {
870: $status.='<br />'.
871: &Apache::loncommon::modal_link(
872: '/adm/diff?filename='.$linkfilename.'&versiontwo=priv',
873: &mt('Diffs'),600,500);
874: }
875: }
876:
877: $status.="\n".'<br />'.
878: &Apache::loncommon::modal_link(
879: '/adm/retrieve?filename='.$linkfilename.'&inhibitmenu=yes&add_modal=yes',&mt('Retrieve'),600,500);
880: }
881:
882: return ($status, $pubstatus);
883: }
884:
885:
886: #
887: # Put a table row for a file resource.
888: #
889: sub putresource {
890: my ($r, $udom, $uname, $filename, $thisdisfn, $resdir, $targetdir,
891: $linkdir, $cmtime, $size, $numres, $linkfilename, $title,
892: $status, $pubstatus) = @_;
893: &Apache::lonnet::devalidate_cache_new('meta',$targetdir.'/'.$filename);
894:
895: my $editlink='';
896: my $editlink2='';
897: if ($filename=~/\.(xml|html|htm|xhtml|xhtm|sty)$/) {
898: $editlink=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=edit">'.&mt('Edit').'</a>)';
899: }
900: if ($filename=~/$LONCAPA::assess_re/) {
901: $editlink=' (<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=editxml">'.&mt('EditXML').'</a>)';
902: $editlink2=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=edit">'.&mt('Edit').'</a>)';
903: }
904: if ($filename=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm|sty)$/) {
905: $editlink.=' (<a href="/adm/cleanup?filename='.$linkfilename.'" target="_parent">'.&mt('Clean Up').')</a>';
906: }
907: if ($filename=~/\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) {
908: $editlink=' (<a target="_parent" href="/adm/cfile?decompress='.$linkfilename.'">'.&mt('Decompress').'</a>)';
909: }
910: my $publish_button = (-e $resdir.'/'.$filename) ? &mt('Re-publish') : &mt('Publish');
911: my $pub_select = '';
912: &create_pubselect($r,\$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres);
913: $r->print(&Apache::loncommon::start_data_table_row().
914: '<td>'.($filename=~/[\#\~]$/?' ':
915: '<img src="'.&Apache::loncommon::icon($filename).'" alt="" />').'</td>'.
916: '<td>'.$pub_select.'</td>'.
917: '<td><span class="LC_filename">'.
918: '<a href="'.$linkdir.'/'.$filename.'" target="_parent">'.
919: $filename.'</a></span>'.$editlink2.$editlink.
920: '</td>'.
921: '<td>'.$title.'</td>'.
922: '<td class="LC_browser_file_'.$pubstatus.'"> </td>'. # Display publication status
923: '<td>'.$status.'</td>'.
924: '<td>'.&Apache::lonlocal::locallocaltime($cmtime).'</td>'.
925: '<td>'.sprintf("%.1f",$size).'</td>'.
926: &Apache::loncommon::end_data_table_row()
927: );
928: return;
929: }
930:
931: sub create_pubselect {
932: my ($r,$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres) = @_;
933: $$pub_select = '
934: <form name="resselect_'.$$numres.'" action="">
935: <select name="reschoice" onchange="SetResChoice(this.form)">
936: <option>'.&mt('Select action').'</option>'.
937: '<option value="copy">'.&mt('Copy').'</option>';
938: if ($pubstatus eq 'obsolete' || $pubstatus eq 'unpublished') {
939: $$pub_select .=
940: '<option value="rename">'.&mt('Rename').'</option>'.
941: '<option value="move">'.&mt('Move').'</option>'.
942: '<option value="delete">'.&mt('Delete').'</option>';
943: } else {
944: $$pub_select .= '
945: <option value="obsolete">'.&mt('Mark obsolete').'</option>';
946: }
947: # check for versions
948: my $versions = &check_for_versions($r,'/'.$filename,$udom,$uname);
949: if ($versions > 0) {
950: $$pub_select .='
951: <option value="retrieve">'.&mt('Retrieve old version').'</option>';
952: }
953: $$pub_select .= '
954: <option value="publish">'.$publish_button.'</option>'.
955: '<option value="cleanup">'.&mt('Clean up').'</option>'.
956: '<option value="print">'.&mt('Print').'</option>'.
957: '</select>
958: <input type="hidden" name="filename" value="/priv'.
959: &HTML::Entities::encode($thisdisfn.'/'.$filename,'<>&"').'" />
960: <input type="hidden" name="dispfilename" value="'.
961: &HTML::Entities::encode($filename).'" /></form>';
962: $$numres ++;
963: }
964:
965: sub check_for_versions {
966: my ($r,$fn,$udom,$uname) = @_;
967: my $versions = 0;
968: my $docroot=$r->dir_config('lonDocRoot');
969: my $resfn=$docroot.'/res/'.$udom.'/'.$uname.$fn;
970: my $resdir=$resfn;
971: $resdir=~s/\/[^\/]+$/\//;
972: $fn=~/\/([^\/]+)\.(\w+)$/;
973: my $main=$1;
974: my $suffix=$2;
975: opendir(DIR,$resdir);
976: while (my $filename=readdir(DIR)) {
977: if ($filename=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/) {
978: $versions ++;
979: }
980: }
981: closedir(DIR);
982: return $versions;
983: }
984:
985: sub prepareJsonTranslations {
986: my $json =
987: '{"translations":{'.
988: '"edit":"'.&mt('Edit').'",'.
989: '"editxml":"'.&mt('EditXML').'",'.
990: '"editmeta":"'.&mt('Edit Metadata').'",'.
991: '"obsolete":"'.&mt('Obsolete').'",'.
992: '"modified":"'.&mt('Modified').'",'.
993: '"published":"'.&mt('Published').'",'.
994: '"unpublished":"'.&mt('Unpublished').'",'.
995: '"diff":"'.&mt('Diff').'",'.
996: '"retrieve":"'.&mt('Retrieve').'",'.
997: '"directory":"'.&mt('Directory').'",'.
998: '"results":"'.&mt('Show results for keyword:').'"'.
999: '}}';
1000: }
1001:
1002: # gathers all files in the working directory except the ones that are already on screen
1003: sub prepareJsonData {
1004: my ($uname, $udom, $pathToSkip) = @_;
1005: my $path = "/home/httpd/html/priv/$udom/$uname/";
1006:
1007: # maximum number of entries, to limit workload and required storage space
1008: my $entries = 100;
1009: my $firstfile = 1;
1010: my $firstdir = 1;
1011:
1012: my $json = '{"resources":[';
1013: $json .= &prepareJsonData_rec($path, \$entries, \$firstfile, \$firstdir, $pathToSkip);
1014: $json .= ']}';
1015:
1016: # if the json string is invalid the whole search breaks.
1017: # so we want to make sure that the string is valid in any case.
1018: $json =~ s/,\s*,/,/g;
1019: $json =~ s/\}\s*\{/\},\{/g;
1020: $json =~ s/\}\s*,\s*\]/\}\]/g;
1021: return $json;
1022: }
1023:
1024: # recursive part of json file gathering
1025: sub prepareJsonData_rec {
1026: my ($path, $entries, $firstfile, $firstdir, $pathToSkip) = @_;
1027: my $json;
1028: my $skipThisFolder = $path =~ m/$pathToSkip\/$/?1:0;
1029:
1030: my @dirs;
1031: my @resources;
1032: my @ignored = qw(bak log meta save . ..);
1033:
1034: # Phase 1: Gathering
1035: opendir(DIR,$path);
1036: my @files=sort {uc($a) cmp uc($b)} (readdir(DIR));
1037: foreach my $filename (@files) {
1038: next if ($filename eq '.DS_Store');
1039:
1040: # gather all resources
1041: if ($filename !~ /\./) {
1042: # its a folder
1043: push(@dirs, $filename);
1044: } else {
1045: # only push files we dont want to ignore
1046: next if ($skipThisFolder);
1047:
1048: $filename =~ /\.(\w+?)$/;
1049: unless (grep /$1/, @ignored) {
1050: push(@resources, $filename);
1051: }
1052: }
1053: }
1054: closedir(DIR);
1055: # nothing to do here if both lists are empty
1056: return unless ( @dirs || @resources );
1057:
1058: # Phase 2: Working
1059: $$firstfile = 1;
1060:
1061: foreach (@dirs) {
1062: $json .= '{"name":"'.$_.'",'.
1063: '"path":"'.$path.$_.'",'.
1064: '"title":"",'.
1065: '"status":"",'.
1066: '"cmtime":""},';
1067: }
1068:
1069: foreach (@resources) {
1070: last if ($$entries < 1);
1071: my $title = &getTitleString($path.$_);
1072:
1073: my $privpath = $path.$_;
1074: my $respath = $privpath;
1075: $respath =~ s/httpd\/html\/priv\//httpd\/html\/res\//;
1076:
1077: my $cmtime = (stat($privpath))[9];
1078: my $rmtime = (stat($respath))[9];
1079:
1080: unless ($$firstfile) { $json .= ','; } else { $$firstfile = 0; }
1081:
1082: my $status = 'unpublished';
1083:
1084: # if a resource is published, the published version (/html/res/filepath) gets its own modification time
1085: # this is newer or equal then the version in your authoring space (/html/priv/filepath)
1086: if ($rmtime >= $cmtime) {
1087: # obsolete
1088: if (&Apache::lonnet::metadata($respath, 'obsolete')) {
1089: $status = 'obsolete';
1090: }else{
1091: $status = 'published';
1092: }
1093: } else {
1094: $status = 'modified';
1095: }
1096:
1097: $json .= '{"name":"'.$_.'",'.
1098: '"path":"'.$path.'",'.
1099: '"title":"'.$title.'",'.
1100: '"status":"'.$status.'",'.
1101: '"cmtime":"'.&Apache::lonlocal::locallocaltime($cmtime).'"}';
1102: $$entries--;
1103: }
1104:
1105: foreach(@dirs) {
1106: next if ($$entries < 1);
1107: $json .= ',';
1108: $json .= &prepareJsonData_rec
1109: ($path.$_.'/', $entries, $firstfile, $firstdir, $pathToSkip);
1110: }
1111: return $json;
1112: }
1113: 1;
1114: __END__
1115:
1116:
1117: =head1 NAME
1118:
1119: Apache::lonpubdir - Authoring space directory lister
1120:
1121: =head1 SYNOPSIS
1122:
1123: Invoked (for various locations) by /etc/httpd/conf/srm.conf:
1124:
1125: <LocationMatch "^/+priv.*/$">
1126: PerlAccessHandler Apache::loncacc
1127: SetHandler perl-script
1128: PerlHandler Apache::lonpubdir
1129: ErrorDocument 403 /adm/login
1130: ErrorDocument 404 /adm/notfound.html
1131: ErrorDocument 406 /adm/unauthorized.html
1132: ErrorDocument 500 /adm/errorhandler
1133: </LocationMatch>
1134:
1135: <Location /adm/pubdir>
1136: PerlAccessHandler Apache::lonacc
1137: SetHandler perl-script
1138: PerlHandler Apache::lonpubdir
1139: ErrorDocument 403 /adm/login
1140: ErrorDocument 404 /adm/notfound.html
1141: ErrorDocument 406 /adm/unauthorized.html
1142: ErrorDocument 500 /adm/errorhandler
1143: </Location>
1144:
1145: =head1 INTRODUCTION
1146:
1147: This module publishes a directory of files.
1148:
1149: This is part of the LearningOnline Network with CAPA project
1150: described at http://www.lon-capa.org.
1151:
1152: =head1 HANDLER SUBROUTINE
1153:
1154: This routine is called by Apache and mod_perl.
1155:
1156: =over 4
1157:
1158: =item *
1159:
1160: read in information
1161:
1162: =item *
1163:
1164: start page output
1165:
1166: =item *
1167:
1168: run through list of files and attempt to publish unhidden files
1169:
1170: =back
1171:
1172: =head1 SUBROUTINES:
1173:
1174: =over
1175:
1176: =item startpage($r, $uame, $udom, $thisdisfn)
1177:
1178: Output the header of the page. This includes:
1179: - The HTML header
1180: - The H1/H3 stuff which includes the directory.
1181:
1182: startpage($r, $uame, $udom, $thisdisfn);
1183: $r - The apache request object.
1184: $uname - User name.
1185: $udom - Domain name the user is logged in under.
1186: $thisdisfn - Displayable version of the filename.
1187:
1188: =item getTitleString($fullname)
1189:
1190: Get the title string or "[untitled]" if the file has no title metadata:
1191: Without the latter substitution, it's impossible to examine metadata for
1192: untitled resources. Resources may be legitimately untitled, to prevent
1193: searches from locating them.
1194:
1195: $str = getTitleString($fullname);
1196: $fullname - Fully qualified filename to check.
1197:
1198: =item putdirectory($r, $base, $here, $dirname, $modtime, $targetdir, $bombs,
1199: $numdir)
1200:
1201: Put out a directory table row:
1202:
1203: $r - Apache request object.
1204: $reqfile - File in request.
1205: $here - Where we are in directory tree.
1206: $dirname - Name of directory special file.
1207: $modtime - Encoded modification time.
1208: targetdir - Publication target directory.
1209: bombs - Reference to hash of URLs with runtime error messages.
1210: numdir - Reference to scalar used to track number of sub-directories
1211: in directory (used in form name for each "actions" dropdown).
1212:
1213: =back
1214:
1215: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>