--- loncom/publisher/lonpubdir.pm	2004/12/02 18:38:37	1.67
+++ loncom/publisher/lonpubdir.pm	2004/12/10 18:26:49	1.72
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construction Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.67 2004/12/02 18:38:37 raeburn Exp $
+# $Id: lonpubdir.pm,v 1.72 2004/12/10 18:26:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -94,6 +94,8 @@ sub handler {
   if ($ENV{'environment.remote'} eq 'off') {
       &dircontrols($r,$uname,$udom,$thisdisfn);    # Put out actions for directory, 
                                                # browse/upload + new file page.
+  } else {
+      &pubbuttons($r,$uname,$thisdisfn);
   }
   &resourceactions($r,$uname,$udom,$thisdisfn); #Put out form used for printing/deletion etc.
 
@@ -193,19 +195,19 @@ sub startpage {
     $r->print('<html><head><title>LON-CAPA Construction Space</title></head>');
 
     my $pagetitle;
-    my $formaction='/priv/'.$uname.'/'.$thisdisfn.'/';
+    my $formaction='/priv/'.$uname.$thisdisfn.'/';
     $formaction=~s/\/+/\//g;
     $pagetitle .= &Apache::loncommon::help_open_menu('','','','',3,'Authoring').
-        '<font face="Arial, Helvetica, sans-serif"><b>Construction Space</b>:</font>&nbsp;'.
+        '<font face="Arial, Helvetica, sans-serif" size="+1"><b>Construction Space</b>:</font>&nbsp;'.
         '<form name="dirs" method="post" action="'.$formaction.
-        '" target="_parent">'.
-        &Apache::lonhtmlcommon::crumbs($uname.'/'.$thisdisfn.'/','_top','/priv','','+1').
+        '" target="_parent"><tt><b>'.
+        &Apache::lonhtmlcommon::crumbs($uname.$thisdisfn.'/','_top','/priv','','+1',1)."</b></tt><br />".
         &Apache::lonhtmlcommon::select_recent('construct','recent',
                  'this.form.action=this.form.recent.value;this.form.submit()').
               '</form>';
     &Apache::lonhtmlcommon::store_recent('construct',$formaction,$formaction);
     if ($ENV{'environment.remote'} eq 'off') {
-	$ENV{'request.noversionuri'}=$currdir;
+	$ENV{'request.noversionuri'}=$currdir.'/';
 	$r->print(&Apache::loncommon::bodytag('Construction Space',undef,undef,undef,undef,undef,$pagetitle));
     } else {
 	$r->print($pagetitle);
@@ -214,7 +216,7 @@ sub startpage {
 <script>
 // Store directory location for menu bar to find
 
-parent.lastknownpriv='/~$uname/$thisdisfn/';
+parent.lastknownpriv='/~$uname$thisdisfn/';
 
 // Confirmation dialogues
 
@@ -278,7 +280,7 @@ parent.lastknownpriv='/~$uname/$thisdisf
         if (theform.diraction.options[theform.diraction.selectedIndex].value == "editcat") {
             top.location=theform.filename.value+'default.meta'
         }
-        if (theform.diraction.options[theform.diraction.selectedIndex].value == "print") {
+        if (theform.diraction.options[theform.diraction.selectedIndex].value == "printdir") {
             theform.action = '/adm/printout'
             theform.postdata.value = theform.filename.value
             theform.submit()
@@ -298,22 +300,21 @@ parent.lastknownpriv='/~$uname/$thisdisf
       if (activity == 'delete') {
           var delform = document.delresource
           delform.filename.value = theform.filename.value
-          if (confirm("Are you sure you want to delete "+theform.filename.value+"?")) {
-              delform.submit()
-          }
+          delform.submit()
       }
       if (activity == 'obsolete') {
-          alert("Mark as obsolete - still to be implemented") 
+          var pubform = document.pubresource
+          pubform.filename.value = theform.filename.value
+          alert("You will be taken to the publication page.\\nCheck the 'Obsolete' checkbox at the bottom of the page, and click 'Finalize Publication'.")
+          pubform.submit()
       }
       if (activity == 'print') {
-          document.printresource.postdata = theform.filename.value
-          document.printresource.curseed = getcurseed()
-          document.printresource.problemtype = getproblemtype()
+          document.printresource.postdata.value = theform.filename.value
           document.printresource.submit()
       }
       if (activity == 'retrieve') {
-          retrieveres.filename.value = theform.filename.value
-          retrieveres.submit()
+          document.retrieveres.filename.value = theform.filename.value
+          document.retrieveres.submit()
       }
       return
     }
@@ -327,34 +328,6 @@ parent.lastknownpriv='/~$uname/$thisdisf
         document.moveresource.action.value = activity
         document.moveresource.submit();
     }
-
-    function getcurseed() {
-      if (parent.document.lonhomework
-           &&
-          parent.document.lonhomework.rndseed
-           &&
-          parent.document.lonhomework.rndseed.value) {
-              return parent.document.lonhomework.rndseed.value;
-      }
-      return 0;
-    }
-                                                                                                      
-    function getproblemtype() {
-        if (parent.document.lonhomework) {
-            var optionelement;
-            var valueIndex=0;
-            for (var optionIndex=0;
-                optionIndex < parent.document.lonhomework.problemtype.options.length;
-                optionIndex++)
-            {
-                optionElement=parent.document.lonhomework.problemtype.options[optionIndex];
-                if (optionElement.selected) {
-                    return optionElement.value;
-                }
-            }
-        }
-        return 0;
-    }
 </script>
 ENDPUBDIRSCRIPT
     $r->print($pubdirscript);
@@ -370,9 +343,9 @@ sub dircontrols {
     $r->print(<<END);
         <table cellspacing="4" cellpadding="4" width="100%">
          <tr>
-          <td bgcolor="#DDDDDD" align="middle"><b>Actions for current directory</b></td>
-          <td bgcolor="#DDDDDD" align="middle"><b>Upload a new document</b></td>
-          <td bgcolor="#DDDDDD" align="middle"><b>Create a new directory or LON-CAPA document</b></td>
+          <td bgcolor="#DDDDDD" align="middle"><font face="Arial, Helvetica, sans-serif" size="-1"><b>Actions for current directory</b></font></td>
+          <td bgcolor="#DDDDDD" align="middle"><font face="Arial, Helvetica, sans-serif" size="-1"><b>Upload a new document</b></font></td>
+          <td bgcolor="#DDDDDD" align="middle"><font face="Arial, Helvetica, sans-serif" size="-1"><b>Create a new directory or LON-CAPA document</b></font></td>
         </tr>
         <tr>
          <td bgcolor="#ccddaa" valign="top" align="center">
@@ -393,8 +366,6 @@ sub dircontrols {
           </form>
           <form name="printdir" method="post" action="/adm/printout" target="_parent">
            <input type="hidden" name="postdata" value="" />
-           <input type="hidden" name="curseed" value="0" />
-           <input type="hidden" name="problemtype" value="0" />
           </form>
          </td>
          <td bgcolor="#ccddaa" valign="top" align="center">
@@ -409,7 +380,7 @@ sub dircontrols {
 	      <nobr>
 		<input type="hidden" name="filename" value="/~$uname$thisdisfn/" />
 		  <select name="action">
-		    <option>Select action</option>
+		    <option>Select Action</option>
 		    <option value="newfile">New file:</option>
 		    <option value="newhtmlfile">New HTML file:</option>
 		    <option value="newproblemfile">New problem:</option>
@@ -424,11 +395,25 @@ sub dircontrols {
 	  </td>
          </tr>
         </table>
-        <br />
-        <br />
 END
 }
 
+sub pubbuttons {
+    my ($r,$uname,$thisdisfn) = @_;
+    $r->print('<form method="post" action="/adm/publish" target="_parent">'.
+              '<table><tr><td><input type="hidden" name="filename" value="/~'.
+               $uname.$thisdisfn.'/" />'.
+              '<input type="button" onClick="pubdir(this.form);" value="'.
+&mt('Publish Directory').'" />'.
+              '<input type="hidden" name="pubrec" value="" />'.
+              '<input type="hidden" name="forcerepub" value="NO" />'.
+              '<input type="button" onClick="pubrecdir(this.form);" value="'.
+&mt('Publish Directory and Sub Directories').'" /></td><td>'.
+'<input type="button" onClick="window.location='."'/~".
+               $uname.$thisdisfn."/default.meta'".'" value="'.
+&mt('Edit Directory Catalog Information').'" /></td></tr></table></form>');
+}
+
 sub resourceactions {
     my ($r,$uname,$udom,$thisdisfn) = @_;
     $r->print(<<END);
@@ -448,8 +433,6 @@ sub resourceactions {
        </form>
        <form name="printresource" action="/adm/printout" target="_parent" method="post">
            <input type="hidden" name="postdata" value="" />
-           <input type="hidden" name="curseed" value="" />
-           <input type="hidden" name="problemtype" value="" />
        </form>
        <form name="retrieveres" action="/adm/retrieve" target="_parent" method="post">
            <input type="hidden" name="filename" value="" />
@@ -534,8 +517,6 @@ sub putdirectory {
                      '<input type="hidden" name="filename" value="'.$dirpath.'/'.$dirname.'/" />'.
                      '<input type="hidden" name="pubrec" value="" />'.
                      '<input type="hidden" name="forcerepub" value="" />'.
-                     '<input type="hidden" name="curseed" value="0" />'.
-                     '<input type="hidden" name="problemtype" value="0" />'.
                      '<input type="hidden" name="postdata" value="" />'.
                    '</form>';
             $$numdir ++;
@@ -649,20 +630,16 @@ sub create_pubselect {
 <form name="resselect_'.$$numres.'" action="">
 <select name="reschoice"  onChange="SetResChoice(this.form)">
 <option>'.&mt('Select action').
+'<option value="copy"/>'.&mt('Copy');
+    if ($pubstatus eq 'obsolete' || $pubstatus eq 'unpublished') {
+        $$pub_select .= 
 '<option value="rename"/>'.&mt('Rename').
 '<option value="move"/>'.&mt('Move').
-'<option value="copy"/>'.&mt('Copy').
-'<option value="publish"/>'.$publish_button;
-    if ($pubstatus eq 'obsolete' || $pubstatus eq 'unpublished') {
-        $$pub_select .= '
-<option value="delete"/>'.&mt('Delete');
+'<option value="delete"/>'.&mt('Delete');
     } else {
         $$pub_select .= '
 <option value="obsolete"/>'.&mt('Mark obsolete');
     }
-    $$pub_select .= '
-<option value="print"/>'.&mt('Print');
-
 # check for versions
     my $versions = &check_for_versions($r,'/'.$filename,$udom,$uname);
     if ($versions > 0) {
@@ -670,9 +647,11 @@ sub create_pubselect {
 <option value="retrieve"/>'.&mt('Retrieve old version');
     }
     $$pub_select .= '
-</select>
+<option value="publish"/>'.$publish_button.
+'<option value="print"/>'.&mt('Print').
+'</select>
 <input type="hidden" name="filename" value="/~'.
- $uname.'/'.$thisdisfn.'/'.$filename.'"></form>';
+ $uname.$thisdisfn.'/'.$filename.'"></form>';
     $$numres ++;
 }