File:  [LON-CAPA] / loncom / publisher / lonpubdir.pm
Revision 1.160.2.5: download - view: text, annotated - select for diffs
Tue Aug 13 19:27:43 2019 UTC (4 years, 9 months ago) by raeburn
Branches: version_2_11_X
CVS tags: version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3
Diff to branchpoint 1.160: preferred, unified
- For 2.11
  Changes in 1.160.2.4 backport had changes from 1.169 not needed in 2.11

    1: # The LearningOnline Network with CAPA
    2: # Authoring Space Directory Lister
    3: #
    4: # $Id: lonpubdir.pm,v 1.160.2.5 2019/08/13 19:27:43 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: 
   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:     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,
   94:                                                  'author'); # expressed in MB
   95: 
   96:     # Put out the start of page.
   97:     &startpage($r, $uname, $udom, $thisdisfn, $current_disk_usage, $disk_quota);
   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)) {
  110:         @files = grep(!/^\.+$/,readdir(DIR));
  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: 
  118:     # Put out actions for directory, browse/upload + new file page.
  119:     &dircontrols($r,$uname,$udom,$thisdisfn, $current_disk_usage, $disk_quota);
  120:     &resourceactions($r,$uname,$udom,$thisdisfn); # Put out form used for printing/deletion etc.
  121: 
  122:     my $numdir = 0;
  123:     my $numres = 0;
  124:   
  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: 
  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: 
  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 = ('&nbsp;&#9650;','&nbsp;&#9660;','');
  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}.'"' : '')
  197:             .'><a href="'.$linkdir.'/?sortby='.$key.'&amp;sortorder='
  198:             .((($sortby eq $key) && ($sortorder ne 'rev')) ? 'rev' : '').'">'
  199:             .$columns{$key}{text}.$arrows[$idx].'</a></th>' :
  200:             '<th>'.$columns{$key}{text}.'</th>');
  201:     }
  202:     $r->print(&Apache::loncommon::start_data_table()
  203:         .&Apache::loncommon::start_data_table_header_row() . $output
  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) {
  210:         # Skip .DS_Store, .DAV and hidden files
  211:         my ($extension) = ($filename=~/\.(\w+)$/);
  212:         next if (($filename eq '.DS_Store')
  213:                 || ($filename eq '.DAV')
  214:                 || (&Apache::loncommon::fileembstyle($extension) eq 'hdn')
  215:                 || ($filename =~ /^\._/));
  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:         }
  236: 
  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() );
  311: 
  312:     return OK;
  313: }
  314: 
  315: 
  316: 
  317: #   Output the header of the page.  This includes:
  318: #   - The HTML header 
  319: #   - The H1/H3  stuff which includes the directory.
  320: #
  321: #     startpage($r, $uame, $udom, $thisdisfn, $current_disk_usage, $disk_quota);
  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.
  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"
  329: 
  330: sub startpage {
  331:     my ($r, $uname, $udom, $thisdisfn, $current_disk_usage, $disk_quota) = @_;
  332:     &Apache::loncommon::content_type($r,'text/html');
  333:     $r->send_http_header;
  334: 
  335:     my $formaction='/priv'.$thisdisfn.'/';
  336:     $formaction=~s|/+|/|g;
  337:     &Apache::lonhtmlcommon::store_recent('construct',$formaction,$formaction);
  338: 
  339:     &Apache::lonhtmlcommon::clear_breadcrumbs();
  340:     &Apache::lonhtmlcommon::add_breadcrumb({
  341:         'text'  => 'Authoring Space',
  342:         'href'  => &Apache::loncommon::authorspace($formaction),
  343:     });
  344:     # breadcrumbs (and tools) will be created 
  345:     # in start_page->bodytag->innerregister
  346: 
  347:     $env{'request.noversionuri'}=$formaction;
  348:     $r->print(&Apache::loncommon::start_page('Authoring Space'));
  349: 
  350:     my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
  351:     my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,"$londocroot/priv/$udom/$uname");
  352:     my $disk_quota = &Apache::loncommon::get_user_quota($uname,$udom,'author'); #expressed in MB
  353:     $disk_quota = 1024 * $disk_quota; # convert from MB to kB
  354: 
  355:     $r->print(&Apache::loncommon::head_subbox(
  356:                      '<div style="float:right;padding-top:0;margin-top;0">'
  357:                     .&Apache::lonhtmlcommon::display_usage($current_disk_usage,
  358:                                                            $disk_quota,'authoring')
  359:                     .'</div>'
  360:                     .&Apache::loncommon::CSTR_pageheader()));
  361: 
  362:     my $esc_thisdisfn = &Apache::loncommon::escape_single($thisdisfn);
  363:     my $doctitle = 'LON-CAPA '.&mt('Authoring Space');
  364:     my $newname = &mt('New Name');
  365:     my $pubdirscript=(<<ENDPUBDIRSCRIPT);
  366: <script type="text/javascript">
  367: top.document.title = '$esc_thisdisfn/ - $doctitle';
  368: // Store directory location for menu bar to find
  369: 
  370: parent.lastknownpriv='/priv$esc_thisdisfn/';
  371: 
  372: // Confirmation dialogues
  373: 
  374:     function currdiract(theform) {
  375:         if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'publish') {
  376:             document.publishdir.filename.value = theform.filename.value;
  377: 	    document.publishdir.submit();
  378:         }
  379:         if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'editmeta') {
  380:             top.location=theform.filename.value+'default.meta'
  381:         }
  382:         if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'printdir' ) {
  383:             document.printdir.postdata.value=theform.filename.value
  384:             document.printdir.submit();
  385:         }
  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:         }
  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") {
  403:             top.location = theform.openname.value
  404:             return
  405:         }
  406:         if (theform.diraction.options[theform.diraction.selectedIndex].value == "publish") {
  407:             theform.submit();
  408:         }
  409:         if (theform.diraction.options[theform.diraction.selectedIndex].value == "editmeta") {
  410:             top.location=theform.filename.value+'default.meta'
  411:         }
  412:         if (theform.diraction.options[theform.diraction.selectedIndex].value == "printdir") {
  413:             theform.action = '/adm/printout'
  414:             theform.postdata.value = theform.filename.value
  415:             theform.submit()
  416:         }
  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:         }
  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
  437:           delform.submit()
  438:       }
  439:       if (activity == 'obsolete') {
  440:           var pubform = document.pubresource
  441:           pubform.filename.value = theform.filename.value
  442:           pubform.makeobsolete.value=1;
  443:           pubform.submit()
  444:       }
  445:       if (activity == 'print') {
  446:           document.printresource.postdata.value = theform.filename.value
  447:           document.printresource.submit()
  448:       }
  449:       if (activity == 'retrieve') {
  450:           document.retrieveres.filename.value = theform.filename.value
  451:           document.retrieveres.submit()
  452:       }
  453:       if (activity == 'cleanup') {
  454:           document.cleanup.filename.value = theform.filename.value
  455:           document.cleanup.submit()
  456:       }
  457:       return
  458:     }
  459:     function changename(theform,activity) {
  460:         var oldname=theform.dispfilename.value;
  461:         var newname=prompt('$newname',oldname);
  462:         if (newname == "" || !newname || newname == oldname)  {
  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:     }
  470: </script>
  471: ENDPUBDIRSCRIPT
  472:     $r->print($pubdirscript);
  473: }
  474: 
  475: sub dircontrols {
  476:     my ($r,$uname,$udom,$thisdisfn, $current_disk_usage, $disk_quota) = @_;
  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',
  483:                                        dedr => 'Delete Directory',
  484:                                        rtrv => 'Retrieve Old Version',
  485:                                        list => 'List Directory',
  486:                                        uplo => 'Upload file',  
  487:                                        dele => 'Delete',
  488:                                        edit => 'Edit Metadata', 
  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',
  498:                                        nbt  => 'New bridgetask file',
  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',
  504:                                        go   => 'Go',
  505:                                        prnt => 'Print contents of directory',
  506:                                        crea => 'Create a new directory or LON-CAPA document',
  507: 				       acti => 'Actions for current directory',
  508: 				       updc => 'Upload a new document',
  509: 				       pick => 'Please select an action to perform using the new filename',
  510:                                       );
  511:     my $mytype = $lt{'type'}; # avoid conflict with " and ' in javascript
  512:     # Calculate free space in bytes.
  513:     # $disk_quota is in MB and $current_disk_usage is in kB
  514:     my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
  515:     $r->print(<<END);
  516: <div class="LC_columnSection">
  517:   <div>
  518:     <form name="curractions" method="post" action="">
  519:       <fieldset>
  520:         <legend>$lt{'acti'}</legend>
  521:         <select name="dirtask" onchange="currdiract(this.form)">
  522:             <option>$lt{'sela'}</option>
  523:             <option value="publish">$lt{'pubd'}</option>
  524:             <option value="editmeta">$lt{'edit'}</option>
  525:             <option value="printdir">$lt{'prnt'}</option>
  526:             <option value="delete">$lt{'dedr'}</option>
  527:         </select>
  528:         <input type="hidden" name="filename" value="/priv$thisdisfn/" />
  529:       </fieldset>
  530:     </form>
  531:     <form name="publishdir" method="post" action="/adm/publish" target="_parent">
  532:       <input type="hidden" name="pubrec" value="" />
  533:       <input type="hidden" name="filename" value="" />
  534:     </form>
  535:     <form name="printdir" method="post" action="/adm/printout" target="_parent">
  536:       <input type="hidden" name="postdata" value="" />
  537:     </form>
  538:   </div>
  539: 
  540:   <div style="padding-bottom: 2px">
  541:     <form name="upublisher" enctype="multipart/form-data" method="post" action="/adm/upload" target="_parent">
  542:       <fieldset>
  543:         <legend>$lt{'updc'}</legend>
  544:         <input type="hidden" name="filename" value="/priv$thisdisfn/" />
  545:         <input type="file" name="upfile" class="LC_flUpload" size="20" />
  546:         <input type="hidden" id="LC_free_space" value="$free_space" />
  547:         <input type="button" value="$lt{'uplo'}"  onclick="checkUpload(this.form)" />
  548:       </fieldset>
  549:     </form>
  550:   </div>
  551: 
  552:   <div>
  553:     <form name="fileaction" method="post" action="/adm/cfile" target="_parent">
  554:       <fieldset>
  555:               <legend>$lt{'crea'}</legend>
  556: 	      <span class="LC_nobreak">
  557: 		<input type="hidden" name="filename" value="/priv$thisdisfn/" />
  558:                   <script type="text/javascript">
  559:                     function validate_go() {
  560:                         var selected = document.fileaction.action.selectedIndex;
  561:                         if (selected == 0) {
  562:                             alert('$lt{'pick'}');
  563:                         } else {
  564:                             document.fileaction.submit();
  565:                         }
  566:                     }
  567:                   </script>
  568: 		  <select name="action">
  569: 		    <option value="none">$lt{'sela'}</option>
  570: 		    <option value="newfile">$lt{'nfil'}:</option>
  571: 		    <option value="newhtmlfile">$lt{'nhtm'}:</option>
  572: 		    <option value="newproblemfile">$lt{'nprb'}:</option>
  573:                     <option value="newpagefile">$lt{'npag'}:</option>
  574:                     <option value="newsequencefile">$lt{'nseq'}:</option>
  575:                     <option value="newrightsfile">$lt{'ncrf'}:</option>
  576:                     <option value="newstyfile">$lt{'nsty'}:</option>
  577:                     <option value="newtaskfile">$lt{'nbt'}:</option>
  578:                     <option value="newlibraryfile">$lt{'nlib'}:</option>
  579: 	            <option value="newdir">$lt{'nsub'}:</option>
  580: 		  </select>&nbsp;<input type="text" name="newfilename" placeholder="$lt{'type'}" value="" onfocus="if (this.value == is.empty()) this.value=''" />&nbsp;<input type="button" value="Go" onclick="validate_go();" />
  581:                 <br />
  582:                 <span>Quickactions:
  583:                  <input type="hidden" name="mode"/>
  584:                  <a href="javascript:void(0)" onclick="javascript:validate_action('blank')">
  585:                     <img src="/adm/lonIcons/unknown.gif" title="Create blank problem file"></a>
  586:                  <a href="javascript:void(0)" onclick="javascript:validate_action('problemtempl')">
  587:                     <img src="/adm/lonIcons/problem.gif" title="Create new problem from template"></a>
  588:                  <a href="javascript:void(0)" onclick="javascript:validate_action('blankhtml')">
  589:                     <img src="/adm/lonIcons/html.gif" title="Create new blank HTML file"></a>
  590:                  <a href="javascript:void(0)" onclick="javascript:validate_action('folder')">
  591:                     <img src="/adm/lonIcons/navmap.folder.closed.gif" title="Create new subdirectory"></a>
  592:                 </span>
  593:                  <script type="text/javascript">
  594:                      function validate_action(action){
  595: 
  596:                          if (document.getElementsByName(\'newfilename\')[0].value != \'\'){
  597:                              if (action == "blank") {
  598:                                                                  document.fileaction.action.value=\'newproblemfile\';
  599:                                                                  document.fileaction.mode.value=\'blank\';
  600:                                                          } else if (action == "problemtempl") {
  601:                                                                  document.fileaction.action.value=\'newproblemfile\';
  602:                                  validate_go();
  603:                              } else if (action == "blankhtml") {
  604:                                  document.fileaction.action.value=\'newhtmlfile\';
  605:                                  validate_go();
  606:                              } else if (action == "folder") {
  607:                                  document.fileaction.action.value=\'newdir\';
  608:                                  document.fileaction.mode.value=\'folder\';
  609:                              }
  610:                              fileaction.submit();
  611:                          } else {
  612:                              alert(\'Please specify file name.\');
  613:                              // TODO: ask for filename? if so, do some refactoring
  614: 
  615:                          }
  616:                      }
  617:                  </script>
  618: 		 </span>
  619:       </fieldset>
  620:     </form>
  621:   </div>
  622: </div>
  623: END
  624: }
  625: 
  626: sub resourceactions {
  627:     my ($r,$uname,$udom,$thisdisfn) = @_;
  628:     $r->print(<<END);
  629:        <form name="moveresource" action="/adm/cfile" target="_parent" method="post">
  630:          <input type="hidden" name="filename" value="" />
  631:          <input type="hidden" name="newfilename" value="" />
  632:          <input type="hidden" name="action" value="" />
  633:        </form>
  634:        <form name="delresource" action="/adm/cfile" target="_parent" method="post">
  635:          <input type="hidden" name="filename" value="" />
  636:          <input type="hidden" name="action" value="delete" />
  637:        </form>
  638:        <form name="pubresource" action="/adm/publish" target="_parent" method="post">
  639:          <input type="hidden" name="filename" value="" />
  640:          <input type="hidden" name="makeobsolete" value="0" />
  641:        </form>
  642:        <form name="printresource" action="/adm/printout" target="_parent" method="post">
  643:            <input type="hidden" name="postdata" value="" />
  644:        </form>
  645:        <form name="retrieveres" action="/adm/retrieve" target="_parent" method="post">
  646:            <input type="hidden" name="filename" value="" />
  647:        </form>
  648:        <form name="cleanup" action="/adm/cleanup" target="_parent" method="post">
  649:            <input type="hidden" name="filename" value="" />
  650:        </form>
  651: END
  652: }
  653: 
  654: #
  655: #   Get the title string or "[untitled]" if the file has no title metadata:
  656: #   Without the latter substitution, it's impossible to examine metadata for
  657: #   untitled resources.  Resources may be legitimately untitled, to prevent
  658: #   searches from locating them.
  659: #
  660: #   $str = getTitleString($fullname);
  661: #       $fullname - Fully qualified filename to check.
  662: #
  663: sub getTitleString {
  664:     my $fullname = shift;
  665:     my $title    = &Apache::lonnet::metadata($fullname, 'title');
  666: 
  667:     unless ($title) {
  668: 	$title = "[".&mt('untitled')."]";
  669:     }
  670:     return $title;
  671: }
  672: 
  673: sub getCopyRightString {
  674:     my $fullname = shift;
  675:     return &Apache::lonnet::metadata($fullname, 'copyright');
  676: }
  677: 
  678: sub getSourceRightString {
  679:     my $fullname = shift;
  680:     return &Apache::lonnet::metadata($fullname, 'sourceavail');
  681: }
  682: #
  683: #  Put out a directory table row:
  684: #    putdirectory(r, base, here, dirname, modtime, targetdir, bombs, numdir)
  685: #      r         - Apache request object.
  686: #      reqfile   - File in request.
  687: #      here      - Where we are in directory tree.
  688: #      dirname   - Name of directory special file.
  689: #      modtime   - Encoded modification time.
  690: #      targetdir - Publication target directory.
  691: #      bombs     - Reference to hash of URLs with runtime error messages.
  692: #      numdir    - Reference to scalar used to track number of sub-directories
  693: #                  in directory (used in form name for each "actions" dropdown).
  694: #
  695: sub putdirectory {
  696:     my ($r, $reqfile, $here, $dirname, $modtime, $targetdir, $bombs, $numdir) = @_;
  697: 
  698: # construct the display filename: the directory name unless ..:
  699:    
  700:     my $actionitem;
  701:  
  702:     my $disfilename = $dirname;
  703: # Don't display directory itself, and there is no way up from root directory
  704:     unless ((($dirname eq '..') && ($reqfile=~/^\/[^\/]+\/[^\/]+$/)) || ($dirname eq '.')) {
  705:         my $kaputt=0;
  706:         if (ref($bombs) eq 'HASH') {
  707:             foreach my $key (keys(%{$bombs})) {
  708:                 my $currentdir = &Apache::lonnet::declutter("$targetdir/$disfilename");
  709:                 if (($key) =~ m{^\Q$currentdir\E/}) { $kaputt=1; last; }
  710:             }
  711:         }
  712: #
  713: # Get the metadata from that directory's default.meta to display titles
  714: #
  715: 	%Apache::lonpublisher::metadatafields=();
  716: 	%Apache::lonpublisher::metadatakeys=();
  717: 	&Apache::lonpublisher::metaeval(
  718:                  &Apache::lonnet::getfile($r->dir_config('lonDocRoot').$here.'/'.$dirname.'/default.meta')
  719:                                        );
  720:         if ($dirname eq '..') {
  721:             $actionitem = &mt('Go to ...');
  722:             $disfilename = '<i>'.&mt('Parent Directory').'</i>';
  723:         } else {
  724:             $actionitem = 
  725:                     '<form name="dirselect_'.$$numdir.
  726:                     '" action="/adm/publish" target="_parent">'.
  727:                     '<select name="diraction" onchange="SetPubDir(this.form,document)">'.
  728:                       '<option selected="selected">'.&mt('Select action').'</option>'.
  729:                       '<option value="open">'.&mt('Open').'</option>'.
  730:                       '<option value="publish">'.&mt('Publish').'</option>'.
  731:                       '<option value="editmeta">'.&mt('Edit Metadata').'</option>'.
  732:                       '<option value="printdir">'.&mt('Print directory').'</option>'.
  733:                       '<option value="delete">'.&mt('Delete directory').'</option>'.
  734:                     '</select>'.
  735:                      '<input type="hidden" name="filename" value="'.&HTML::Entities::encode($here.'/'.$dirname,'<>&"').'/" />'.
  736:                      '<input type="hidden" name="openname" value="'.$here.'/'.$dirname.'/" />'.
  737:                      '<input type="hidden" name="postdata" value="" />'.
  738:                    '</form>';
  739:             $$numdir ++;
  740:         }
  741: 	$r->print('<tr class="LC_browser_folder">'.
  742: 		  '<td><img src="'.
  743: 		  $Apache::lonnet::perlvar{'lonIconsURL'}.'/navmap.folder.closed.gif" alt="folder" /></td>'.
  744: 		  '<td>'.$actionitem.'</td>'.
  745: 		  '<td><span class="LC_filename"><a href="'.&HTML::Entities::encode($here.'/'.$dirname,'<>&"').'/" target="_parent">'.
  746: 		  $disfilename.'</a></span></td>'.
  747: 		        '<td colspan="3">'.($kaputt?&Apache::lonhtmlcommon::authorbombs($targetdir.'/'.$disfilename.'/'):'').$Apache::lonpublisher::metadatafields{'title'});
  748: 	if ($Apache::lonpublisher::metadatafields{'subject'} ne '') {
  749: 	    $r->print(' <i>'.
  750: 		      $Apache::lonpublisher::metadatafields{'subject'}.
  751: 		      '</i> ');
  752: 	}
  753: 	$r->print($Apache::lonpublisher::metadatafields{'keywords'}.'</td>'.
  754: 		  '<td>'.&Apache::lonlocal::locallocaltime($modtime).'</td>'.
  755: 	          '<td></td>'.
  756: 		  "</tr>\n");
  757:     }
  758:     return;
  759: }
  760: 
  761: sub getTitle {
  762:     my ($resdir, $targetdir, $filename, $linkfilename, $meta_same, $bombs) = @_;
  763:     my $title='';
  764:     my $titleString = &getTitleString($targetdir.'/'.$filename);
  765:     if (-e $resdir.'/'.$filename) {
  766: 	$title = '<a href="'.$targetdir.'/'.$filename.
  767: 	    '.meta" target="cat">'.$titleString.'</a>';
  768:         if (!$meta_same) {
  769: 	    $title = &mt('Metadata Modified').'<br />'.$title.
  770: 		'<br />'.
  771:                 &Apache::loncommon::modal_link(
  772:                     '/adm/diff?filename='.$linkfilename.'.meta'.'&amp;versiontwo=priv',
  773:                     &mt('Metadata Diffs'),600,500);
  774: 	    $title.="\n".'<br />'.
  775:                 &Apache::loncommon::modal_link(
  776:                     '/adm/retrieve?filename='.$linkfilename.'.meta&amp;inhibitmenu=yes&amp;add_modal=yes',
  777:                     &mt('Retrieve Metadata'),600,500);
  778:         } 
  779:     }
  780:     # Allow editing metadata of published and unpublished resources
  781:     $title .= "\n".'<br />' if ($title);
  782:     $title .= '<a href="'.$linkfilename.'.meta">'.
  783:               ($$bombs{&Apache::lonnet::declutter($targetdir.'/'.$filename)}?
  784:                   '<img src="/adm/lonMisc/bomb.gif" border="0" alt="'.&mt('bomb').'" />':
  785:                   &mt('Edit Metadata')).
  786:               '</a>';
  787: 
  788:     return ($title, $titleString);
  789: }
  790: 
  791: 
  792: sub isMetaSame {
  793:     my ($cstr_dir, $resdir, $filename) = @_;
  794:     my $meta_cmtime = (stat($cstr_dir.'/'.$filename.'.meta'))[9];
  795:     my $meta_rmtime = (stat($resdir.'/'.$filename.'.meta'))[9];
  796:     return (&Apache::londiff::are_different_files($resdir.'/'.$filename.'.meta',
  797:             $cstr_dir.'/'.$filename.'.meta') && $meta_rmtime < $meta_cmtime) 
  798:         ? 0 : 1;
  799: }
  800:     
  801: 
  802: sub getStatus {    
  803:     my ($resdir, $targetdir, $cstr_dir, $filename,  
  804:             $linkfilename, $cmtime, $meta_same) = @_;
  805:     my $pubstatus = 'unpublished';
  806:     my $status = &mt('Unpublished');
  807: 
  808:     if (-e $resdir.'/'.$filename) {
  809:         my $same = 0;
  810:         if ((stat($resdir.'/'.$filename))[9] >= $cmtime) {
  811:             $same = 1;
  812:         } else {
  813:            if (&Apache::londiff::are_different_files($resdir.'/'.$filename,
  814: 						     $cstr_dir.'/'.$filename)) {
  815:               $same = 0;
  816:            } else {
  817:               $same = 1;
  818:            }
  819:         }
  820: 
  821:         my $rights_status =
  822:             &mt(&getCopyRightString($targetdir.'/'.$filename)).', ';
  823: 
  824:         my %lt_SourceRight = &Apache::lonlocal::texthash(
  825:                'open'   => 'Source: open',
  826:                'closed' => 'Source: closed',
  827:         );
  828:         $rights_status .=
  829:             $lt_SourceRight{&getSourceRightString($targetdir.'/'.$filename)};
  830: 
  831: 	if ($same) {
  832: 	    if (&Apache::lonnet::metadata($targetdir.'/'.$filename,'obsolete')) {
  833:                 $pubstatus = 'obsolete';
  834: 		$status=&mt('Obsolete');
  835:             } else {
  836: 		if (!$meta_same) {
  837: 		    $pubstatus = 'metamodified';
  838: 		} else {
  839: 		    $pubstatus = 'published';
  840: 		}
  841: 		$status=&mt('Published').
  842: 		    '<br />'. $rights_status;
  843: 	    }
  844: 	} else {
  845:             $pubstatus = 'modified';
  846: 	    $status=&mt('Modified').
  847: 		'<br />'. $rights_status;
  848: 	    if (&Apache::loncommon::fileembstyle(($filename=~/\.(\w+)$/)) eq 'ssi') {
  849: 		$status.='<br />'.
  850:                          &Apache::loncommon::modal_link(
  851:                              '/adm/diff?filename='.$linkfilename.'&amp;versiontwo=priv',
  852:                              &mt('Diffs'),600,500);
  853: 	    }
  854: 	} 
  855: 
  856: 	$status.="\n".'<br />'.
  857:              &Apache::loncommon::modal_link(
  858:                  '/adm/retrieve?filename='.$linkfilename.'&amp;inhibitmenu=yes&amp;add_modal=yes',&mt('Retrieve'),600,500);
  859:     }
  860: 
  861:     return ($status, $pubstatus);
  862: }
  863: 
  864: 
  865: #
  866: #   Put a table row for a file resource.
  867: #
  868: sub putresource {
  869:     my ($r, $udom, $uname, $filename, $thisdisfn, $resdir, $targetdir, 
  870:             $linkdir, $cmtime, $size, $numres, $linkfilename, $title, 
  871:             $status, $pubstatus) = @_;
  872:     &Apache::lonnet::devalidate_cache_new('meta',$targetdir.'/'.$filename);
  873: 
  874:     my $editlink='';
  875:     my $editlink2='';
  876:     if ($filename=~/\.(xml|html|htm|xhtml|xhtm|sty)$/) {
  877: 	$editlink=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&amp;problemmode=edit">'.&mt('Edit').'</a>)';
  878:     }
  879:     if ($filename=~/$LONCAPA::assess_re/) {
  880: 	$editlink=' (<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&amp;problemmode=editxml">'.&mt('EditXML').'</a>)';
  881: 	$editlink2=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&amp;problemmode=edit">'.&mt('Edit').'</a>)';
  882:     }
  883:     if ($filename=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm|sty)$/) {
  884: 	$editlink.=' (<a href="/adm/cleanup?filename='.$linkfilename.'" target="_parent">'.&mt('Clean Up').')</a>';
  885:     }
  886:     if ($filename=~/\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) {
  887: 	$editlink=' (<a target="_parent" href="/adm/cfile?decompress='.$linkfilename.'">'.&mt('Decompress').'</a>)';
  888:     }
  889:     my $publish_button = (-e $resdir.'/'.$filename) ? &mt('Re-publish') : &mt('Publish');
  890:     my $pub_select = '';
  891:     &create_pubselect($r,\$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres);
  892:     $r->print(&Apache::loncommon::start_data_table_row().
  893: 	      '<td>'.($filename=~/[\#\~]$/?'&nbsp;':
  894: 		      '<img src="'.&Apache::loncommon::icon($filename).'" alt="" />').'</td>'.
  895:               '<td>'.$pub_select.'</td>'.
  896: 	      '<td><span class="LC_filename">'.
  897: 	      '<a href="'.$linkdir.'/'.$filename.'" target="_parent">'.
  898:                $filename.'</a></span>'.$editlink2.$editlink.
  899: 	      '</td>'.
  900: 	      '<td>'.$title.'</td>'.
  901:               '<td class="LC_browser_file_'.$pubstatus.'">&nbsp;&nbsp;</td>'. # Display publication status
  902:               '<td>'.$status.'</td>'.
  903: 	      '<td>'.&Apache::lonlocal::locallocaltime($cmtime).'</td>'.
  904: 	      '<td>'.sprintf("%.1f",$size).'</td>'.
  905: 	      &Apache::loncommon::end_data_table_row()
  906:     );
  907:     return;
  908: }
  909: 
  910: sub create_pubselect {
  911:     my ($r,$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres) = @_;
  912:     $$pub_select = '
  913: <form name="resselect_'.$$numres.'" action="">
  914: <select name="reschoice"  onchange="SetResChoice(this.form)">
  915: <option>'.&mt('Select action').'</option>'.
  916: '<option value="copy">'.&mt('Copy').'</option>';
  917:     if ($pubstatus eq 'obsolete' || $pubstatus eq 'unpublished') {
  918:         $$pub_select .= 
  919: '<option value="rename">'.&mt('Rename').'</option>'.
  920: '<option value="move">'.&mt('Move').'</option>'.
  921: '<option value="delete">'.&mt('Delete').'</option>';
  922:     } else {
  923:         $$pub_select .= '
  924: <option value="obsolete">'.&mt('Mark obsolete').'</option>';
  925:     }
  926: # check for versions
  927:     my $versions = &check_for_versions($r,'/'.$filename,$udom,$uname);
  928:     if ($versions > 0) {
  929:         $$pub_select .='
  930: <option value="retrieve">'.&mt('Retrieve old version').'</option>';
  931:     }
  932:     $$pub_select .= '
  933: <option value="publish">'.$publish_button.'</option>'.
  934: '<option value="cleanup">'.&mt('Clean up').'</option>'.
  935: '<option value="print">'.&mt('Print').'</option>'.
  936: '</select>
  937: <input type="hidden" name="filename" value="/priv'.
  938:  &HTML::Entities::encode($thisdisfn.'/'.$filename,'<>&"').'" />
  939:  <input type="hidden" name="dispfilename" value="'.
  940:  &HTML::Entities::encode($filename).'" /></form>';
  941:     $$numres ++;
  942: }
  943: 
  944: sub check_for_versions {
  945:     my ($r,$fn,$udom,$uname) = @_;
  946:     my $versions = 0;
  947:     my $docroot=$r->dir_config('lonDocRoot');
  948:     my $resfn=$docroot.'/res/'.$udom.'/'.$uname.$fn;
  949:     my $resdir=$resfn;
  950:     $resdir=~s/\/[^\/]+$/\//;
  951:     $fn=~/\/([^\/]+)\.(\w+)$/;
  952:     my $main=$1;
  953:     my $suffix=$2;
  954:     opendir(DIR,$resdir);
  955:     while (my $filename=readdir(DIR)) {
  956:         if ($filename=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/) {
  957:             $versions ++;        
  958:         }
  959:     }
  960:     closedir(DIR);
  961:     return $versions;
  962: }
  963: 
  964: 1;
  965: __END__
  966: 
  967: 
  968: =head1 NAME
  969: 
  970: Apache::lonpubdir - Authoring space directory lister
  971: 
  972: =head1 SYNOPSIS
  973: 
  974: Invoked (for various locations) by /etc/httpd/conf/srm.conf:
  975: 
  976:  <LocationMatch "^/+priv.*/$">
  977:  PerlAccessHandler       Apache::loncacc
  978:  SetHandler perl-script
  979:  PerlHandler Apache::lonpubdir
  980:  ErrorDocument     403 /adm/login
  981:  ErrorDocument     404 /adm/notfound.html
  982:  ErrorDocument     406 /adm/unauthorized.html
  983:  ErrorDocument	  500 /adm/errorhandler
  984:  </LocationMatch>
  985: 
  986:  <Location /adm/pubdir>
  987:  PerlAccessHandler       Apache::lonacc
  988:  SetHandler perl-script
  989:  PerlHandler Apache::lonpubdir
  990:  ErrorDocument     403 /adm/login
  991:  ErrorDocument     404 /adm/notfound.html
  992:  ErrorDocument     406 /adm/unauthorized.html
  993:  ErrorDocument	  500 /adm/errorhandler
  994:  </Location>
  995: 
  996: =head1 INTRODUCTION
  997: 
  998: This module publishes a directory of files.
  999: 
 1000: This is part of the LearningOnline Network with CAPA project
 1001: described at http://www.lon-capa.org.
 1002: 
 1003: =head1 HANDLER SUBROUTINE
 1004: 
 1005: This routine is called by Apache and mod_perl.
 1006: 
 1007: =over 4
 1008: 
 1009: =item *
 1010: 
 1011: read in information
 1012: 
 1013: =item *
 1014: 
 1015: start page output
 1016: 
 1017: =item *
 1018: 
 1019: run through list of files and attempt to publish unhidden files
 1020: 
 1021: =back
 1022: 
 1023: =head1 SUBROUTINES:
 1024: 
 1025: =over
 1026: 
 1027: =item startpage($r, $uame, $udom, $thisdisfn)
 1028: 
 1029: Output the header of the page.  This includes:
 1030:  - The HTML header 
 1031:  - The H1/H3  stuff which includes the directory.
 1032:  
 1033:     startpage($r, $uame, $udom, $thisdisfn);
 1034:         $r     - The apache request object.
 1035:         $uname - User name.
 1036:         $udom  - Domain name the user is logged in under.
 1037:         $thisdisfn - Displayable version of the filename.
 1038: 
 1039: =item getTitleString($fullname)
 1040: 
 1041:     Get the title string or "[untitled]" if the file has no title metadata:
 1042:     Without the latter substitution, it's impossible to examine metadata for
 1043:     untitled resources.  Resources may be legitimately untitled, to prevent
 1044:     searches from locating them.
 1045:     
 1046:     $str = getTitleString($fullname);
 1047:         $fullname - Fully qualified filename to check.
 1048: 
 1049: =item putdirectory($r, $base, $here, $dirname, $modtime, $targetdir, $bombs,
 1050:                    $numdir)
 1051: 
 1052:     Put out a directory table row:
 1053:     
 1054:         $r        - Apache request object.
 1055:         $reqfile  - File in request.
 1056:         $here     - Where we are in directory tree.
 1057:         $dirname  - Name of directory special file.
 1058:         $modtime  - Encoded modification time.
 1059:         targetdir - Publication target directory.
 1060:         bombs     - Reference to hash of URLs with runtime error messages.
 1061:         numdir    - Reference to scalar used to track number of sub-directories
 1062:                     in directory (used in form name for each "actions" dropdown).
 1063: 
 1064: =back
 1065: 
 1066: =cut

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>