File:  [LON-CAPA] / loncom / publisher / lonpubdir.pm
Revision 1.160.2.6: download - view: text, annotated - select for diffs
Wed Jul 3 21:05:49 2024 UTC (11 days, 13 hours ago) by raeburn
Branches: version_2_11_X
CVS tags: version_2_11_5
Diff to branchpoint 1.160: preferred, unified
- For 2.11
  Backport 1.174, 1.175, 1.182

    1: # The LearningOnline Network with CAPA
    2: # Authoring Space Directory Lister
    3: #
    4: # $Id: lonpubdir.pm,v 1.160.2.6 2024/07/03 21:05:49 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:                                        shcu => 'Shortcuts',
  511:                                       );
  512:     my %js_lt = &Apache::lonlocal::texthash(
  513:                                        nanf => 'Name of New File',
  514:                                        nans => 'Name of New Subdirectory',
  515:                                        psfn => 'Please specify file name',
  516:     );
  517:     &js_escape(\%js_lt);
  518:     my $mytype = $lt{'type'}; # avoid conflict with " and ' in javascript
  519:     # Calculate free space in bytes.
  520:     # $disk_quota is in MB and $current_disk_usage is in kB
  521:     my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
  522:     $r->print(<<END);
  523: <div class="LC_columnSection">
  524:   <div>
  525:     <form name="curractions" method="post" action="">
  526:       <fieldset>
  527:         <legend>$lt{'acti'}</legend>
  528:         <select name="dirtask" onchange="currdiract(this.form)">
  529:             <option>$lt{'sela'}</option>
  530:             <option value="publish">$lt{'pubd'}</option>
  531:             <option value="editmeta">$lt{'edit'}</option>
  532:             <option value="printdir">$lt{'prnt'}</option>
  533:             <option value="delete">$lt{'dedr'}</option>
  534:         </select>
  535:         <input type="hidden" name="filename" value="/priv$thisdisfn/" />
  536:       </fieldset>
  537:     </form>
  538:     <form name="publishdir" method="post" action="/adm/publish">
  539:       <input type="hidden" name="pubrec" value="" />
  540:       <input type="hidden" name="filename" value="" />
  541:     </form>
  542:     <form name="printdir" method="post" action="/adm/printout">
  543:       <input type="hidden" name="postdata" value="" />
  544:     </form>
  545:   </div>
  546: 
  547:   <div style="padding-bottom: 2px">
  548:     <form name="upublisher" enctype="multipart/form-data" method="post" action="/adm/upload">
  549:       <fieldset>
  550:         <legend>$lt{'updc'}</legend>
  551:         <input type="hidden" name="filename" value="/priv$thisdisfn/" />
  552:         <input type="file" name="upfile" class="LC_flUpload" />
  553:         <input type="hidden" id="LC_free_space" value="$free_space" />
  554:         <input type="button" value="$lt{'uplo'}"  onclick="checkUpload(this.form)" />
  555:       </fieldset>
  556:     </form>
  557:   </div>
  558: 
  559:   <div>
  560:     <form name="fileaction" method="post" action="/adm/cfile">
  561:       <fieldset>
  562:               <legend>$lt{'crea'}</legend>
  563: 	      <span class="LC_nobreak">
  564: 		<input type="hidden" name="filename" value="/priv$thisdisfn/" />
  565:                   <script type="text/javascript">
  566:                     function validate_go() {
  567:                         var selected = document.fileaction.action.selectedIndex;
  568:                         if (selected == 0) {
  569:                             alert('$lt{'pick'}');
  570:                         } else {
  571:                             document.fileaction.submit();
  572:                         }
  573:                     }
  574:                   </script>
  575: 		  <select name="action">
  576: 		    <option value="none">$lt{'sela'}</option>
  577: 		    <option value="newfile">$lt{'nfil'}:</option>
  578: 		    <option value="newhtmlfile">$lt{'nhtm'}:</option>
  579: 		    <option value="newproblemfile">$lt{'nprb'}:</option>
  580:                     <option value="newpagefile">$lt{'npag'}:</option>
  581:                     <option value="newsequencefile">$lt{'nseq'}:</option>
  582:                     <option value="newrightsfile">$lt{'ncrf'}:</option>
  583:                     <option value="newstyfile">$lt{'nsty'}:</option>
  584:                     <option value="newtaskfile">$lt{'nbt'}:</option>
  585:                     <option value="newlibraryfile">$lt{'nlib'}:</option>
  586: 	            <option value="newdir">$lt{'nsub'}:</option>
  587: 		  </select>&nbsp;<input type="text" id="newnameid" name="newfilename" placeholder="$lt{'type'}" value="" onfocus="if (this.value == is.empty()) this.value=''" />&nbsp;<input type="button" value="Go" onclick="validate_go();" />
  588:                 <br />
  589:                 <span>$lt{'shcu'}:
  590:                  <input type="hidden" name="mode"/>
  591:                  <a href="javascript:void(0)" onclick="javascript:validate_action('blank')">
  592:                     <img src="/adm/lonIcons/unknown.gif" title="Create blank problem file"></a>
  593:                  <a href="javascript:void(0)" onclick="javascript:validate_action('problemtempl')">
  594:                     <img src="/adm/lonIcons/problem.gif" title="Create new problem from template"></a>
  595:                  <a href="javascript:void(0)" onclick="javascript:validate_action('blankhtml')">
  596:                     <img src="/adm/lonIcons/html.gif" title="Create new blank HTML file"></a>
  597:                  <a href="javascript:void(0)" onclick="javascript:validate_action('folder')">
  598:                     <img src="/adm/lonIcons/navmap.folder.closed.gif" title="Create new subdirectory"></a>
  599:                 </span>
  600:                  <script type="text/javascript">
  601:                      function validate_action(action){
  602:                          if (document.getElementById('newnameid')) {
  603:                              if (document.getElementById('newnameid').value == '') {
  604:                                  var newname;
  605:                                  var prompttext = "$js_lt{'nanf'}";
  606:                                  if (action == 'folder') {
  607:                                      prompttext = "$js_lt{'nans'}";
  608:                                  }
  609:                                  newname=prompt(prompttext);
  610:                                  if (newname != '') {
  611:                                      document.getElementById('newnameid').value = newname;
  612:                                  }
  613:                              }
  614:                              if (document.getElementById('newnameid').value != '') {
  615:                                  if (action == 'blank') {
  616:                                      document.fileaction.action.value='newproblemfile';
  617:                                      document.fileaction.mode.value='blank';
  618:                                  } else if (action == 'problemtempl') {
  619:                                      document.fileaction.action.value='newproblemfile';
  620:                                      validate_go();
  621:                                  } else if (action == 'blankhtml') {
  622:                                      document.fileaction.action.value='newhtmlfile';
  623:                                      validate_go();
  624:                                  } else if (action == 'folder') {
  625:                                      document.fileaction.action.value='newdir';
  626:                                      document.fileaction.mode.value='folder';
  627:                                  }
  628:                                  fileaction.submit();
  629:                              } else {
  630:                                  alert("$js_lt{'psfn'}");
  631:                              }
  632:                          }
  633:                      }
  634:                  </script>
  635: 		 </span>
  636:       </fieldset>
  637:     </form>
  638:   </div>
  639: </div>
  640: END
  641: }
  642: 
  643: sub resourceactions {
  644:     my ($r,$uname,$udom,$thisdisfn) = @_;
  645:     $r->print(<<END);
  646:        <form name="moveresource" action="/adm/cfile" method="post">
  647:          <input type="hidden" name="filename" value="" />
  648:          <input type="hidden" name="newfilename" value="" />
  649:          <input type="hidden" name="action" value="" />
  650:        </form>
  651:        <form name="delresource" action="/adm/cfile" method="post">
  652:          <input type="hidden" name="filename" value="" />
  653:          <input type="hidden" name="action" value="delete" />
  654:        </form>
  655:        <form name="pubresource" action="/adm/publish" method="post">
  656:          <input type="hidden" name="filename" value="" />
  657:          <input type="hidden" name="makeobsolete" value="0" />
  658:        </form>
  659:        <form name="printresource" action="/adm/printout" method="post">
  660:            <input type="hidden" name="postdata" value="" />
  661:        </form>
  662:        <form name="retrieveres" action="/adm/retrieve" method="post">
  663:            <input type="hidden" name="filename" value="" />
  664:        </form>
  665:        <form name="cleanup" action="/adm/cleanup" method="post">
  666:            <input type="hidden" name="filename" value="" />
  667:        </form>
  668: END
  669: }
  670: 
  671: #
  672: #   Get the title string or "[untitled]" if the file has no title metadata:
  673: #   Without the latter substitution, it's impossible to examine metadata for
  674: #   untitled resources.  Resources may be legitimately untitled, to prevent
  675: #   searches from locating them.
  676: #
  677: #   $str = getTitleString($fullname);
  678: #       $fullname - Fully qualified filename to check.
  679: #
  680: sub getTitleString {
  681:     my $fullname = shift;
  682:     my $title    = &Apache::lonnet::metadata($fullname, 'title');
  683: 
  684:     unless ($title) {
  685: 	$title = "[".&mt('untitled')."]";
  686:     }
  687:     return $title;
  688: }
  689: 
  690: sub getCopyRightString {
  691:     my $fullname = shift;
  692:     return &Apache::lonnet::metadata($fullname, 'copyright');
  693: }
  694: 
  695: sub getSourceRightString {
  696:     my $fullname = shift;
  697:     return &Apache::lonnet::metadata($fullname, 'sourceavail');
  698: }
  699: #
  700: #  Put out a directory table row:
  701: #    putdirectory(r, base, here, dirname, modtime, targetdir, bombs, numdir)
  702: #      r         - Apache request object.
  703: #      reqfile   - File in request.
  704: #      here      - Where we are in directory tree.
  705: #      dirname   - Name of directory special file.
  706: #      modtime   - Encoded modification time.
  707: #      targetdir - Publication target directory.
  708: #      bombs     - Reference to hash of URLs with runtime error messages.
  709: #      numdir    - Reference to scalar used to track number of sub-directories
  710: #                  in directory (used in form name for each "actions" dropdown).
  711: #
  712: sub putdirectory {
  713:     my ($r, $reqfile, $here, $dirname, $modtime, $targetdir, $bombs, $numdir) = @_;
  714: 
  715: # construct the display filename: the directory name unless ..:
  716:    
  717:     my $actionitem;
  718:  
  719:     my $disfilename = $dirname;
  720: # Don't display directory itself, and there is no way up from root directory
  721:     unless ((($dirname eq '..') && ($reqfile=~/^\/[^\/]+\/[^\/]+$/)) || ($dirname eq '.')) {
  722:         my $kaputt=0;
  723:         if (ref($bombs) eq 'HASH') {
  724:             foreach my $key (keys(%{$bombs})) {
  725:                 my $currentdir = &Apache::lonnet::declutter("$targetdir/$disfilename");
  726:                 if (($key) =~ m{^\Q$currentdir\E/}) { $kaputt=1; last; }
  727:             }
  728:         }
  729: #
  730: # Get the metadata from that directory's default.meta to display titles
  731: #
  732: 	%Apache::lonpublisher::metadatafields=();
  733: 	%Apache::lonpublisher::metadatakeys=();
  734: 	&Apache::lonpublisher::metaeval(
  735:                  &Apache::lonnet::getfile($r->dir_config('lonDocRoot').$here.'/'.$dirname.'/default.meta')
  736:                                        );
  737:         if ($dirname eq '..') {
  738:             $actionitem = &mt('Go to ...');
  739:             $disfilename = '<i>'.&mt('Parent Directory').'</i>';
  740:         } else {
  741:             $actionitem = 
  742:                     '<form name="dirselect_'.$$numdir.'" action="/adm/publish">'. 
  743:                     '<select name="diraction" onchange="SetPubDir(this.form,document)">'.
  744:                       '<option selected="selected">'.&mt('Select action').'</option>'.
  745:                       '<option value="open">'.&mt('Open').'</option>'.
  746:                       '<option value="publish">'.&mt('Publish').'</option>'.
  747:                       '<option value="editmeta">'.&mt('Edit Metadata').'</option>'.
  748:                       '<option value="printdir">'.&mt('Print directory').'</option>'.
  749:                       '<option value="delete">'.&mt('Delete directory').'</option>'.
  750:                     '</select>'.
  751:                      '<input type="hidden" name="filename" value="'.&HTML::Entities::encode($here.'/'.$dirname,'<>&"').'/" />'.
  752:                      '<input type="hidden" name="openname" value="'.$here.'/'.$dirname.'/" />'.
  753:                      '<input type="hidden" name="postdata" value="" />'.
  754:                    '</form>';
  755:             $$numdir ++;
  756:         }
  757: 	$r->print('<tr class="LC_browser_folder">'.
  758: 		  '<td><img src="'.
  759: 		  $Apache::lonnet::perlvar{'lonIconsURL'}.'/navmap.folder.closed.gif" alt="folder" /></td>'.
  760: 		  '<td>'.$actionitem.'</td>'.
  761: 		  '<td><span class="LC_filename"><a href="'.&HTML::Entities::encode($here.'/'.$dirname,'<>&"').'/">'.
  762: 		  $disfilename.'</a></span></td>'.
  763: 		        '<td colspan="3">'.($kaputt?&Apache::lonhtmlcommon::authorbombs($targetdir.'/'.$disfilename.'/'):'').$Apache::lonpublisher::metadatafields{'title'});
  764: 	if ($Apache::lonpublisher::metadatafields{'subject'} ne '') {
  765: 	    $r->print(' <i>'.
  766: 		      $Apache::lonpublisher::metadatafields{'subject'}.
  767: 		      '</i> ');
  768: 	}
  769: 	$r->print($Apache::lonpublisher::metadatafields{'keywords'}.'</td>'.
  770: 		  '<td>'.&Apache::lonlocal::locallocaltime($modtime).'</td>'.
  771: 	          '<td></td>'.
  772: 		  "</tr>\n");
  773:     }
  774:     return;
  775: }
  776: 
  777: sub getTitle {
  778:     my ($resdir, $targetdir, $filename, $linkfilename, $meta_same, $bombs) = @_;
  779:     my $title='';
  780:     my $titleString = &getTitleString($targetdir.'/'.$filename);
  781:     if (-e $resdir.'/'.$filename) {
  782: 	$title = '<a href="'.$targetdir.'/'.$filename.
  783: 	    '.meta" target="cat">'.$titleString.'</a>';
  784:         if (!$meta_same) {
  785: 	    $title = &mt('Metadata Modified').'<br />'.$title.
  786: 		'<br />'.
  787:                 &Apache::loncommon::modal_link(
  788:                     '/adm/diff?filename='.$linkfilename.'.meta'.'&amp;versiontwo=priv',
  789:                     &mt('Metadata Diffs'),600,500);
  790: 	    $title.="\n".'<br />'.
  791:                 &Apache::loncommon::modal_link(
  792:                     '/adm/retrieve?filename='.$linkfilename.'.meta&amp;inhibitmenu=yes&amp;add_modal=yes',
  793:                     &mt('Retrieve Metadata'),600,500);
  794:         } 
  795:     }
  796:     # Allow editing metadata of published and unpublished resources
  797:     $title .= "\n".'<br />' if ($title);
  798:     $title .= '<a href="'.$linkfilename.'.meta">'.
  799:               ($$bombs{&Apache::lonnet::declutter($targetdir.'/'.$filename)}?
  800:                   '<img src="/adm/lonMisc/bomb.gif" border="0" alt="'.&mt('bomb').'" />':
  801:                   &mt('Edit Metadata')).
  802:               '</a>';
  803: 
  804:     return ($title, $titleString);
  805: }
  806: 
  807: 
  808: sub isMetaSame {
  809:     my ($cstr_dir, $resdir, $filename) = @_;
  810:     my $meta_cmtime = (stat($cstr_dir.'/'.$filename.'.meta'))[9];
  811:     my $meta_rmtime = (stat($resdir.'/'.$filename.'.meta'))[9];
  812:     return (&Apache::londiff::are_different_files($resdir.'/'.$filename.'.meta',
  813:             $cstr_dir.'/'.$filename.'.meta') && $meta_rmtime < $meta_cmtime) 
  814:         ? 0 : 1;
  815: }
  816:     
  817: 
  818: sub getStatus {    
  819:     my ($resdir, $targetdir, $cstr_dir, $filename,  
  820:             $linkfilename, $cmtime, $meta_same) = @_;
  821:     my $pubstatus = 'unpublished';
  822:     my $status = &mt('Unpublished');
  823: 
  824:     if (-e $resdir.'/'.$filename) {
  825:         my $same = 0;
  826:         if ((stat($resdir.'/'.$filename))[9] >= $cmtime) {
  827:             $same = 1;
  828:         } else {
  829:            if (&Apache::londiff::are_different_files($resdir.'/'.$filename,
  830: 						     $cstr_dir.'/'.$filename)) {
  831:               $same = 0;
  832:            } else {
  833:               $same = 1;
  834:            }
  835:         }
  836: 
  837:         my $rights_status =
  838:             &mt(&getCopyRightString($targetdir.'/'.$filename)).', ';
  839: 
  840:         my %lt_SourceRight = &Apache::lonlocal::texthash(
  841:                'open'   => 'Source: open',
  842:                'closed' => 'Source: closed',
  843:         );
  844:         $rights_status .=
  845:             $lt_SourceRight{&getSourceRightString($targetdir.'/'.$filename)};
  846: 
  847: 	if ($same) {
  848: 	    if (&Apache::lonnet::metadata($targetdir.'/'.$filename,'obsolete')) {
  849:                 $pubstatus = 'obsolete';
  850: 		$status=&mt('Obsolete');
  851:             } else {
  852: 		if (!$meta_same) {
  853: 		    $pubstatus = 'metamodified';
  854: 		} else {
  855: 		    $pubstatus = 'published';
  856: 		}
  857: 		$status=&mt('Published').
  858: 		    '<br />'. $rights_status;
  859: 	    }
  860: 	} else {
  861:             $pubstatus = 'modified';
  862: 	    $status=&mt('Modified').
  863: 		'<br />'. $rights_status;
  864: 	    if (&Apache::loncommon::fileembstyle(($filename=~/\.(\w+)$/)) eq 'ssi') {
  865: 		$status.='<br />'.
  866:                          &Apache::loncommon::modal_link(
  867:                              '/adm/diff?filename='.$linkfilename.'&amp;versiontwo=priv',
  868:                              &mt('Diffs'),600,500);
  869: 	    }
  870: 	} 
  871: 
  872: 	$status.="\n".'<br />'.
  873:              &Apache::loncommon::modal_link(
  874:                  '/adm/retrieve?filename='.$linkfilename.'&amp;inhibitmenu=yes&amp;add_modal=yes',&mt('Retrieve'),600,500);
  875:     }
  876: 
  877:     return ($status, $pubstatus);
  878: }
  879: 
  880: 
  881: #
  882: #   Put a table row for a file resource.
  883: #
  884: sub putresource {
  885:     my ($r, $udom, $uname, $filename, $thisdisfn, $resdir, $targetdir, 
  886:             $linkdir, $cmtime, $size, $numres, $linkfilename, $title, 
  887:             $status, $pubstatus) = @_;
  888:     &Apache::lonnet::devalidate_cache_new('meta',$targetdir.'/'.$filename);
  889: 
  890:     my $editlink='';
  891:     my $editlink2='';
  892:     if ($filename=~/\.(xml|html|htm|xhtml|xhtm|sty|txt|css|js)$/) {
  893: 	$editlink=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&amp;problemmode=edit">'.&mt('Edit').'</a>)';
  894:     }
  895:     if ($filename=~/$LONCAPA::assess_re/) {
  896: 	$editlink=' (<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&amp;problemmode=editxml">'.&mt('EditXML').'</a>)';
  897: 	$editlink2=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&amp;problemmode=edit">'.&mt('Edit').'</a>)';
  898:     }
  899:     if ($filename=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm|sty)$/) {
  900: 	$editlink.=' (<a href="/adm/cleanup?filename='.$linkfilename.'">'.&mt('Clean Up').')</a>';
  901:     }
  902:     if ($filename=~/\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) {
  903: 	$editlink=' (<a href="/adm/cfile?decompress='.$linkfilename.'">'.&mt('Decompress').'</a>)';
  904:     }
  905:     my $publish_button = (-e $resdir.'/'.$filename) ? &mt('Re-publish') : &mt('Publish');
  906:     my $pub_select = '';
  907:     &create_pubselect($r,\$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres);
  908:     $r->print(&Apache::loncommon::start_data_table_row().
  909: 	      '<td>'.($filename=~/[\#\~]$/?'&nbsp;':
  910: 		      '<img src="'.&Apache::loncommon::icon($filename).'" alt="" />').'</td>'.
  911:               '<td>'.$pub_select.'</td>'.
  912: 	      '<td><span class="LC_filename">'.
  913: 	      '<a href="'.$linkdir.'/'.$filename.'">'.
  914:                $filename.'</a></span>'.$editlink2.$editlink.
  915: 	      '</td>'.
  916: 	      '<td>'.$title.'</td>'.
  917:               '<td class="LC_browser_file_'.$pubstatus.'">&nbsp;&nbsp;</td>'. # Display publication status
  918:               '<td>'.$status.'</td>'.
  919: 	      '<td>'.&Apache::lonlocal::locallocaltime($cmtime).'</td>'.
  920: 	      '<td>'.sprintf("%.1f",$size).'</td>'.
  921: 	      &Apache::loncommon::end_data_table_row()
  922:     );
  923:     return;
  924: }
  925: 
  926: sub create_pubselect {
  927:     my ($r,$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres) = @_;
  928:     $$pub_select = '
  929: <form name="resselect_'.$$numres.'" action="">
  930: <select name="reschoice"  onchange="SetResChoice(this.form)">
  931: <option>'.&mt('Select action').'</option>'.
  932: '<option value="copy">'.&mt('Copy').'</option>';
  933:     if ($pubstatus eq 'obsolete' || $pubstatus eq 'unpublished') {
  934:         $$pub_select .= 
  935: '<option value="rename">'.&mt('Rename').'</option>'.
  936: '<option value="move">'.&mt('Move').'</option>'.
  937: '<option value="delete">'.&mt('Delete').'</option>';
  938:     } else {
  939:         $$pub_select .= '
  940: <option value="obsolete">'.&mt('Mark obsolete').'</option>';
  941:     }
  942: # check for versions
  943:     my $versions = &check_for_versions($r,'/'.$filename,$udom,$uname);
  944:     if ($versions > 0) {
  945:         $$pub_select .='
  946: <option value="retrieve">'.&mt('Retrieve old version').'</option>';
  947:     }
  948:     $$pub_select .= '
  949: <option value="publish">'.$publish_button.'</option>'.
  950: '<option value="cleanup">'.&mt('Clean up').'</option>'.
  951: '<option value="print">'.&mt('Print').'</option>'.
  952: '</select>
  953: <input type="hidden" name="filename" value="/priv'.
  954:  &HTML::Entities::encode($thisdisfn.'/'.$filename,'<>&"').'" />
  955:  <input type="hidden" name="dispfilename" value="'.
  956:  &HTML::Entities::encode($filename).'" /></form>';
  957:     $$numres ++;
  958: }
  959: 
  960: sub check_for_versions {
  961:     my ($r,$fn,$udom,$uname) = @_;
  962:     my $versions = 0;
  963:     my $docroot=$r->dir_config('lonDocRoot');
  964:     my $resfn=$docroot.'/res/'.$udom.'/'.$uname.$fn;
  965:     my $resdir=$resfn;
  966:     $resdir=~s/\/[^\/]+$/\//;
  967:     $fn=~/\/([^\/]+)\.(\w+)$/;
  968:     my $main=$1;
  969:     my $suffix=$2;
  970:     opendir(DIR,$resdir);
  971:     while (my $filename=readdir(DIR)) {
  972:         if ($filename=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/) {
  973:             $versions ++;        
  974:         }
  975:     }
  976:     closedir(DIR);
  977:     return $versions;
  978: }
  979: 
  980: 1;
  981: __END__
  982: 
  983: 
  984: =head1 NAME
  985: 
  986: Apache::lonpubdir - Authoring space directory lister
  987: 
  988: =head1 SYNOPSIS
  989: 
  990: Invoked (for various locations) by /etc/httpd/conf/srm.conf:
  991: 
  992:  <LocationMatch "^/+priv.*/$">
  993:  PerlAccessHandler       Apache::loncacc
  994:  SetHandler perl-script
  995:  PerlHandler Apache::lonpubdir
  996:  ErrorDocument     403 /adm/login
  997:  ErrorDocument     404 /adm/notfound.html
  998:  ErrorDocument     406 /adm/unauthorized.html
  999:  ErrorDocument	  500 /adm/errorhandler
 1000:  </LocationMatch>
 1001: 
 1002:  <Location /adm/pubdir>
 1003:  PerlAccessHandler       Apache::lonacc
 1004:  SetHandler perl-script
 1005:  PerlHandler Apache::lonpubdir
 1006:  ErrorDocument     403 /adm/login
 1007:  ErrorDocument     404 /adm/notfound.html
 1008:  ErrorDocument     406 /adm/unauthorized.html
 1009:  ErrorDocument	  500 /adm/errorhandler
 1010:  </Location>
 1011: 
 1012: =head1 INTRODUCTION
 1013: 
 1014: This module publishes a directory of files.
 1015: 
 1016: This is part of the LearningOnline Network with CAPA project
 1017: described at http://www.lon-capa.org.
 1018: 
 1019: =head1 HANDLER SUBROUTINE
 1020: 
 1021: This routine is called by Apache and mod_perl.
 1022: 
 1023: =over 4
 1024: 
 1025: =item *
 1026: 
 1027: read in information
 1028: 
 1029: =item *
 1030: 
 1031: start page output
 1032: 
 1033: =item *
 1034: 
 1035: run through list of files and attempt to publish unhidden files
 1036: 
 1037: =back
 1038: 
 1039: =head1 SUBROUTINES:
 1040: 
 1041: =over
 1042: 
 1043: =item startpage($r, $uame, $udom, $thisdisfn)
 1044: 
 1045: Output the header of the page.  This includes:
 1046:  - The HTML header 
 1047:  - The H1/H3  stuff which includes the directory.
 1048:  
 1049:     startpage($r, $uame, $udom, $thisdisfn);
 1050:         $r     - The apache request object.
 1051:         $uname - User name.
 1052:         $udom  - Domain name the user is logged in under.
 1053:         $thisdisfn - Displayable version of the filename.
 1054: 
 1055: =item getTitleString($fullname)
 1056: 
 1057:     Get the title string or "[untitled]" if the file has no title metadata:
 1058:     Without the latter substitution, it's impossible to examine metadata for
 1059:     untitled resources.  Resources may be legitimately untitled, to prevent
 1060:     searches from locating them.
 1061:     
 1062:     $str = getTitleString($fullname);
 1063:         $fullname - Fully qualified filename to check.
 1064: 
 1065: =item putdirectory($r, $base, $here, $dirname, $modtime, $targetdir, $bombs,
 1066:                    $numdir)
 1067: 
 1068:     Put out a directory table row:
 1069:     
 1070:         $r        - Apache request object.
 1071:         $reqfile  - File in request.
 1072:         $here     - Where we are in directory tree.
 1073:         $dirname  - Name of directory special file.
 1074:         $modtime  - Encoded modification time.
 1075:         targetdir - Publication target directory.
 1076:         bombs     - Reference to hash of URLs with runtime error messages.
 1077:         numdir    - Reference to scalar used to track number of sub-directories
 1078:                     in directory (used in form name for each "actions" dropdown).
 1079: 
 1080: =back
 1081: 
 1082: =cut

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