--- loncom/publisher/lonpubdir.pm	2005/06/23 22:24:54	1.84
+++ loncom/publisher/lonpubdir.pm	2006/04/18 22:38:08	1.90
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construction Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.84 2005/06/23 22:24:54 www Exp $
+# $Id: lonpubdir.pm,v 1.90 2006/04/18 22:38:08 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -111,7 +111,7 @@ sub handler {
             '<th bgcolor="#DDDDDD">'.&mt('Title').'</th>'.
 	    '<th bgcolor="#DDDDDD">'.&mt('Status').'</th>'.
             '<th bgcolor="#DDDDDD">'.&mt('Last Modified').
-	    '</th></tr>');
+	    '</th></tr>'."\n");
 
   my $filename;
   my $dirptr=16384;		# Mask indicating a directory in stat.cmode.
@@ -137,7 +137,7 @@ sub handler {
   }
   closedir(DIR);
 
-  $r->print('</table></body></html>');
+  $r->print('</table>'.&Apache::loncommon::end_page());
   return OK;  
 }
 #
@@ -191,13 +191,10 @@ sub startpage {
     my $currdir = '/priv/'.$uname.$thisdisfn;
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
-    my $html=&Apache::lonxml::xmlbegin();
-    $r->print($html.'<head><title>LON-CAPA Construction Space</title></head>');
 
-    my $pagetitle;
     my $formaction='/priv/'.$uname.$thisdisfn.'/';
-    $formaction=~s/\/+/\//g;
-    $pagetitle .= &Apache::loncommon::help_open_menu('','','','',3,'Authoring').
+    $formaction=~s|/+|/|g;
+    my $pagetitle .= &Apache::loncommon::help_open_menu('','','','',3,'Authoring').
         '<font face="Arial, Helvetica, sans-serif" size="+1"><b>Construction Space</b>:</font>&nbsp;'.
         '<form name="dirs" method="post" action="'.$formaction.
         '" target="_parent"><tt><b>'.
@@ -208,10 +205,14 @@ sub startpage {
     &Apache::lonhtmlcommon::store_recent('construct',$formaction,$formaction);
     if ($env{'environment.remote'} eq 'off') {
 	$env{'request.noversionuri'}=$currdir.'/';
-	$r->print(&Apache::loncommon::bodytag('Construction Space',undef,undef,undef,undef,undef,$pagetitle));
+	$r->print(&Apache::loncommon::start_page('Construction Space',undef,
+						 {'body_title' =>
+						      $pagetitle,}));
     } else {
+	$r->print(&Apache::loncommon::start_page('Construction Space',undef));
 	$r->print($pagetitle);
     }
+
     my $pubdirscript=(<<ENDPUBDIRSCRIPT);
 <script type="text/javascript">
 top.document.title = '$thisdisfn/ - LON-CAPA Construction Space';
@@ -233,6 +234,11 @@ parent.lastknownpriv='/~$uname$thisdisfn
             document.printdir.postdata.value=theform.filename.value
             document.printdir.submit();
         }
+        if (theform.dirtask.options[theform.dirtask.selectedIndex].value == "delete") {
+              var delform = document.delresource
+              delform.filename.value = theform.filename.value
+              delform.submit()
+        }
     }
   
     function checkUpload(theform) {
@@ -259,6 +265,11 @@ parent.lastknownpriv='/~$uname$thisdisfn
             theform.postdata.value = theform.filename.value
             theform.submit()
         }
+        if (theform.diraction.options[theform.diraction.selectedIndex].value == "delete") {
+              var delform = document.delresource
+              delform.filename.value = theform.filename.value
+              delform.submit()
+        }
         return
     }
     function SetResChoice(theform) {
@@ -325,8 +336,8 @@ sub dircontrols {
                                        mcdi => 'Must create new subdirectory inside a directory',
                                        pubr => 'Publish this Resource',
                                        pubd => 'Publish this Directory',
+                                       dedr => 'Delete Directory',
                                        rtrv => 'Retrieve Old Version',
-                                       pubs => 'Publish with Subdirectories',
                                        list => 'List Directory',
                                        uplo => 'Upload file',  
                                        dele => 'Delete',
@@ -354,18 +365,19 @@ sub dircontrols {
     $r->print(<<END);
         <table cellspacing="4" cellpadding="4" width="100%">
          <tr>
-          <td bgcolor="#DDDDDD" align="middle"><font face="Arial, Helvetica, sans-serif" size="-1"><b>$lt{'acti'}</b></font></td>
-          <td bgcolor="#DDDDDD" align="middle"><font face="Arial, Helvetica, sans-serif" size="-1"><b>$lt{'updc'}</b></font></td>
-          <td bgcolor="#DDDDDD" align="middle"><font face="Arial, Helvetica, sans-serif" size="-1"><b>$lt{'crea'}</b></font></td>
+          <td bgcolor="#DDDDDD" align="center"><font face="Arial, Helvetica, sans-serif" size="-1"><b>$lt{'acti'}</b></font></td>
+          <td bgcolor="#DDDDDD" align="center"><font face="Arial, Helvetica, sans-serif" size="-1"><b>$lt{'updc'}</b></font></td>
+          <td bgcolor="#DDDDDD" align="center"><font face="Arial, Helvetica, sans-serif" size="-1"><b>$lt{'crea'}</b></font></td>
         </tr>
         <tr>
          <td bgcolor="#ccddaa" valign="top" align="center">
           <form name="curractions" method="post" action="">
-           <select name="dirtask" onChange="currdiract(this.form)">
+           <select name="dirtask" onchange="currdiract(this.form)">
             <option>$lt{'sela'}</option>
             <option value="publish">$lt{'pubd'}</option>
             <option value="editcat">$lt{'edit'}</option>
             <option value="printdir">$lt{'prnt'}</option>
+            <option value="delete">$lt{'dedr'}</option>
            </select>
            <input type="hidden" name="filename" value="/~$uname$thisdisfn/" />
           </form>
@@ -414,7 +426,7 @@ sub pubbuttons {
               '<table><tr><td><input type="hidden" name="filename" value="/~'.
                $uname.$thisdisfn.'/" />'.
               '<input type="submit" value="'.&mt('Publish Directory').'" /></td><td>'.
-'<input type="button" onClick="window.location='."'/~".
+'<input type="button" onclick="window.location='."'/~".
                $uname.$thisdisfn."/default.meta'".'" value="'.
 &mt('Edit Directory Catalog Information').'" /></td></tr></table></form>');
 }
@@ -513,15 +525,15 @@ sub putdirectory {
             $actionitem = 
                     '<form name="dirselect_'.$$numdir.
                     '" action="/adm/publish" target="_parent">'.
-                    '<select name="diraction" onChange="SetPubDir(this.form,document)">'.
+                    '<select name="diraction" onchange="SetPubDir(this.form,document)">'.
                       '<option selected="selected">'.&mt('Select action').'</option>'.
                       '<option value="open">'.&mt('Open').'</option>'.
                       '<option value="publish">'.&mt('Publish').'</option>'.
-                      '<option value="publishsub">'.&mt('Publish with subdirectories').'</option>'.
                       '<option value="editcat">'.&mt('Edit catalog information').'</option>'.
                       '<option value="printdir">'.&mt('Print directory').'</option>'.
+                      '<option value="delete">'.&mt('Delete directory').'</option>'.
                     '</select>'.
-                     '<input type="hidden" name="filename" value="'.$dirpath.'/'.$dirname.'/" />'.
+                     '<input type="hidden" name="filename" value="'.&HTML::Entities::encode($dirpath.'/'.$dirname,'<>&"').'/" />'.
                      '<input type="hidden" name="openname" value="'.$here.'/'.$dirname.'/" />'.
                      '<input type="hidden" name="postdata" value="" />'.
                    '</form>';
@@ -529,9 +541,9 @@ sub putdirectory {
         }
 	$r->print('<tr bgcolor="#CCCCFF">'.
 		  '<td><img src="'.
-		  $Apache::lonnet::perlvar{'lonIconsURL'}.'/folder_closed.gif" /></td>'.
+		  $Apache::lonnet::perlvar{'lonIconsURL'}.'/folder_closed.gif" alt="folder" /></td>'.
 		  '<td>'.$actionitem.'</td>'.
-		  '<td><font face="arial"><a href="'.$here.'/'.$dirname.'/" target="_parent">'.
+		  '<td><font face="arial"><a href="'.&HTML::Entities::encode($here.'/'.$dirname,'<>&"').'/" target="_parent">'.
 		  $disfilename.'</a></font></td>'.
 		        '<td colspan="2">'.($kaputt?&Apache::lonhtmlcommon::authorbombs($resdir.'/'.$disfilename.'/'):'').$Apache::lonpublisher::metadatafields{'title'}.' <i>'.
 		  $Apache::lonpublisher::metadatafields{'subject'}.'</i> '.
@@ -597,7 +609,7 @@ sub putresource {
 	    }
 	}
 	$title.="\n".'<br /><a href="/~'.$uname.$thisdisfn.'/'.$filename.'.meta">'. 
-	    ($$bombs{$targetdir.'/'.$filename}?'<img src="/adm/lonMisc/bomb.gif" border="0" />':'Edit Metadata').'</a>';
+	    ($$bombs{$targetdir.'/'.$filename}?'<img src="/adm/lonMisc/bomb.gif" border="0" alt="bomb" />':'Edit Metadata').'</a>';
 	$status.="\n".'<br /><a href="/adm/retrieve?filename=/~'.$uname.
 	    $thisdisfn.'/'.$filename.'" target="_parent">'.&mt('Retrieve').'</a>';
     }
@@ -622,7 +634,7 @@ sub putresource {
     &create_pubselect($r,\$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres);
     $r->print('<tr bgcolor="'.$bgcolor.'">'.
 	      '<td>'.($filename=~/[\#\~]$/?'&nbsp;':
-		      '<img src="'.&Apache::loncommon::icon($filename).'" /></td>').
+		      '<img src="'.&Apache::loncommon::icon($filename).'" alt="" />').'</td>'.
               '<td>'.$pub_select.'</td>'.
 	      '<td><font face="arial">'.
 	      '<a href="'.$linkdir.'/'.$filename.'" target="_parent">'.
@@ -639,7 +651,7 @@ sub create_pubselect {
     my ($r,$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres) = @_;
     $$pub_select = '
 <form name="resselect_'.$$numres.'" action="">
-<select name="reschoice"  onChange="SetResChoice(this.form)">
+<select name="reschoice"  onchange="SetResChoice(this.form)">
 <option>'.&mt('Select action').'</option>'.
 '<option value="copy">'.&mt('Copy').'</option>';
     if ($pubstatus eq 'obsolete' || $pubstatus eq 'unpublished') {
@@ -663,7 +675,7 @@ sub create_pubselect {
 '<option value="print">'.&mt('Print').'</option>'.
 '</select>
 <input type="hidden" name="filename" value="/~'.
- $uname.$thisdisfn.'/'.$filename.'" /></form>';
+ &HTML::Entities::encode($uname.$thisdisfn.'/'.$filename,'<>&"').'" /></form>';
     $$numres ++;
 }