Annotation of loncom/publisher/lonpubdir.pm, revision 1.154

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

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