--- loncom/publisher/publisher.html	2002/09/16 13:05:50	1.21
+++ loncom/publisher/publisher.html	2009/12/14 15:37:38	1.41
@@ -1,28 +1,36 @@
 <html>
 <head>
 <title>LON-CAPA Publishing Frame</title>
-<script>
+<script type="text/javascript">
+//<!--
+function frameloc() {
+    if (parent.LONCAPAToBePublished.location.pathname.indexOf("/~")!=-1) {
+       parent.lastknownpriv=parent.LONCAPAToBePublished.location.pathname;
+    }
+// alert ('We are at '+parent.lastknownpriv);
+    return unescape(parent.lastknownpriv);
+}
 
 function getfilename() {
-   document.publisher.filename.value=parent.LONCAPAToBePublished.location.href;
+   document.publisher.filename.value=frameloc();
    if ((document.publisher.filename.value.charAt(
         document.publisher.filename.value.length-1)!='/') &&
        (document.publisher.filename.value.indexOf('/adm/pubdir')==-1)) {
         document.publisher.submit();
    } else {
-      alert('Cannot publish directory');
+      alert('MT{Cannot publish directory}');
    }
 }
 
 function getdfilename() {
-  document.dpublisher.filename.value=parent.LONCAPAToBePublished.location.href;
+  document.dpublisher.filename.value=frameloc();
   if (document.dpublisher.filename.value.indexOf('/adm/pubdir')==-1) {
       document.dpublisher.submit();
   }
 }
 
 function getufilename() {
-  document.upublisher.filename.value=parent.LONCAPAToBePublished.location.href;
+  document.upublisher.filename.value=frameloc();
   if (document.upublisher.filename.value.indexOf('/adm/pubdir')!=-1) {
       document.upublisher.filename.value=document.dpublisher.filename.value;
   }
@@ -30,121 +38,161 @@ function getufilename() {
 }
 
 function getrfilename() {
-  document.rpublisher.filename.value=parent.LONCAPAToBePublished.location.href;
+  document.rpublisher.filename.value=frameloc();
    if ((document.rpublisher.filename.value.charAt(
         document.rpublisher.filename.value.length-1)!='/') &&
        (document.rpublisher.filename.value.indexOf('/adm/pubdir')==-1)) {
         document.rpublisher.submit();
    } else {
-      alert('Cannot retrieve directory');
+      alert('MT{Cannot retrieve directory}');
    }
 }
 
-function getdelfilename() {
-  document.del.filename.value=parent.LONCAPAToBePublished.location.href;
-  document.del.submit();
+function getactionfilename() {
+  document.fileaction.filename.value=frameloc();
+  var test=document.fileaction.action.selectedIndex;
+  if (test == 8) { // trying to create a directory
+      if (document.fileaction.filename.value.indexOf('/adm/pubdir')!=-1) {
+          document.fileaction.filename.value=document.dpublisher.filename.value;
+      }
+      if ((document.fileaction.filename.value.charAt(
+           document.fileaction.filename.value.length-1)!='/') &&
+           (document.fileaction.filename.value.indexOf('/adm/pubdir')==-1)) {
+          alert('MT{Must create new subdirectory inside a directory}');
+          return;
+      }
+   }
+   document.fileaction.submit();
 }
 
-function getrenamefilename() {
-  document.rename.filename.value=parent.LONCAPAToBePublished.location.href;
-  document.rename.submit();
+function getdelfilename() {
+  document.del.filename.value=frameloc();
+  document.del.submit();
 }
 
-function getcpfilename() {
-  document.cp.filename.value=parent.LONCAPAToBePublished.location.href;
-  document.cp.submit();
+function getcurseed() {
+  if (parent.LONCAPAToBePublished.document.lonhomework
+       &&
+      parent.LONCAPAToBePublished.document.lonhomework.rndseed
+       &&
+      parent.LONCAPAToBePublished.document.lonhomework.rndseed.value) {
+    return parent.LONCAPAToBePublished.document.lonhomework.rndseed.value;
+  }
+  return 0;
 }
 
-function getnewdirfilename() {
-   document.newdir.filename.value=parent.LONCAPAToBePublished.location.href;
-   if (document.newdir.filename.value.indexOf('/adm/pubdir')!=-1) {
-       document.newdir.filename.value=document.dpublisher.filename.value;
-   }
-   if ((document.newdir.filename.value.charAt(
-        document.newdir.filename.value.length-1)!='/') &&
-       (document.newdir.filename.value.indexOf('/adm/pubdir')==-1)) {
-      alert('Must create new subdirectory inside a directory');
-   } else {
-      document.newdir.submit();
-   }
+function getproblemtype() {
+  if (parent.LONCAPAToBePublished.document.lonhomework
+       &&
+      parent.LONCAPAToBePublished.document.lonhomework.problemtype) {
+    if (parent.LONCAPAToBePublished.document.lonhomework.problemtype.value) {
+      return parent.LONCAPAToBePublished.document.lonhomework.problemtype.value;
+    }
+    if (parent.LONCAPAToBePublished.document.lonhomework.problemtype.options) {
+       var optionelement;
+       var valueIndex=0;
+       for (var optionIndex=0;
+            optionIndex < parent.LONCAPAToBePublished.document.lonhomework.problemtype.options.length;
+	    optionIndex++)
+       {
+           optionElement=parent.LONCAPAToBePublished.document.lonhomework.problemtype.options[optionIndex];
+	   if (optionElement.selected) {
+	      return optionElement.value;
+           }	  
+       } 	  
+    }
+  }
+  return 0;
 }
 
 function getpostdata() {
-  document.printout.postdata.value=parent.LONCAPAToBePublished.location.href;
+  document.printout.postdata.value=frameloc();
+  document.printout.curseed.value=getcurseed();
+  document.printout.problemtype.value=getproblemtype();
   document.printout.submit();
 }
+//-->
 </script>
-</head>
-<body bgcolor="#ccffff" text='#004400' link='#003333' vlink='#006666'>
-<font size="-2">
-<table border=0><tr><th bgcolor="#004400" height=20>
-<table border=0><tr valign="middle">
-<form name="publisher" action="/adm/publish" target="_parent" method="post">
-<td bgcolor="#ccffcc">
-<input type="hidden" name="filename" value="">
-<input type="button" value="Publish this Resource" onClick="getfilename();">
-</td></form>
-<form name="dpublisher" action="/adm/pubdir" target="LONCAPAToBePublished" method="post">
-<td bgcolor="#ccffcc">
-<input type="hidden" name="filename" value="">
-<input type="button" value="List Directory" onClick="getdfilename();">
-</td></form>
-<form name="cp" action="/adm/cfile" target="_parent" method="post" onSubmit="getcpfilename();">
-<td bgcolor="#ccffcc">
-<input type="hidden" name="filename" value="">
-<input type="hidden" name="action" value="copy">
-<input type="text" size=10 name="newfilename" value="">
-<input type="button" value="Copy" onClick="getcpfilename();">
-</td></form>
-<form name="upublisher" action="/adm/upload" target="_parent" 
-method="post" enctype="multipart/form-data">
-<td bgcolor="#ccffcc" valign="top">
-<input type="hidden" name="filename" value="">
-<input type="file" name="upfile" size="10">
-<input type="button" value="Upload file"  onClick="getufilename();">
-</td></form>
-<form name="printout" action="/adm/printout" target="LONCAPAToBePublished"
-method="post" onSubmit="getpostdata();">
-<td rowspan=2 bgcolor="#ccffcc">
-<input type="hidden" name="postdata" value="">
-<input type="button" value="Printout" onClick="getpostdata();">
-</td>
-</form>
-</tr>
-
-<tr valign="middle">
-<form name="rpublisher" action="/adm/retrieve" target="_parent" method="post">
-<td bgcolor="#ccffcc">
-<input type="hidden" name="filename" value="">
-<input type="button" value="Retrieve Old Version" onClick="getrfilename();">
-</td></form>
-<form name="del" action="/adm/cfile" target="_parent" method="post">
-<td bgcolor="#ccffcc">
-<input type="hidden" name="filename" value="">
-<input type="hidden" name="action" value="delete">
-<input type="button" value="Delete" onClick="getdelfilename();">
-</td></form>
-<form name="rename" action="/adm/cfile" target="_parent" method="post" onSubmit="getrenamefilename();">
-<td bgcolor="#ccffcc">
-<input type="hidden" name="filename" value="">
-<input type="hidden" name="action" value="rename">
-<input type="text" size=10 name="newfilename" value="">
-<input type="button" value="Rename" onClick="getrenamefilename();">
-</td></form>
-<form name="newdir" action="/adm/cfile" target="_parent" method="post" onSubmit="getnewdirfilename();">
-<td bgcolor="#ccffcc">
-<input type="hidden" name="filename" value="">
-<input type="hidden" name="action" value="newdir">
-<input type="text" size=10 name="newfilename" value="">
-<input type="button" value="New Subdirectory" onClick="getnewdirfilename();">
-</td></form>
-</tr>
-</table>
-</th></tr></table>
-</font>
-</body>
-</html>
-
-
-
-
+<style>
+table.LC_publisher {
+  border-collapse:collapse;
+}
+.LC_publisher td {
+  border: 1px solid #C0C0C0;
+  padding: 2px;
+}
+</style>
+    </head>
+    <body>
+          <table class="LC_publisher">
+              <tr valign="middle">
+		  <td align="center">
+		    <form name="publisher" action="/adm/publish" target="_parent" method="post">
+		      <input type="hidden" name="filename" value="" />
+	              <input type="button" value="MT{Publish this Resource}" onclick="getfilename();" />
+		    </form>
+		  </td>
+		  <td align="center">
+		    <form name="dpublisher" action="/adm/pubdir" target="LONCAPAToBePublished" method="post">
+		      <input type="hidden" name="filename" value="" />
+		      <input type="button" value="MT{List Directory}" onclick="getdfilename();" />
+		    </form>
+		  </td>
+		  <td valign="top" align="center">
+		    <form name="upublisher" action="/adm/upload" target="_parent"
+			method="post" enctype="multipart/form-data">
+		      <input type="hidden" name="filename" value="" />
+		      <input type="file" name="upfile" size="20" />
+		      <input type="button" value="MT{Upload file}"  onclick="getufilename();" />
+		    </form>
+		  </td>
+		  <td rowspan="2" align="center">
+		    <form name="printout" target="_parent" action="/adm/printout" method="post" onsubmit="getpostdata();">
+		      <input type="hidden" name="postdata" value="" />
+		      <input type="hidden" name="curseed" value="" />
+		      <input type="hidden" name="problemtype" value="" />
+		      <input type="button" value="MT{Print}" onclick="getpostdata();" />
+		    </form>
+		  </td>
+
+		</tr>
+		<tr valign="middle">
+		  <td align="center">
+		    <form name="rpublisher" action="/adm/retrieve" target="_parent" method="post">
+		      <input type="hidden" name="filename" value="" />
+		      <input type="button" value="MT{Retrieve Old Version}" onclick="getrfilename();" />
+		    </form>
+		  </td>
+		  <td>
+		    <form name="del" action="/adm/cfile" target="_parent" method="post">
+		      <input type="hidden" name="filename" value="" />
+		      <input type="hidden" name="action" value="delete" />
+	              <input type="button" value="MT{Delete}" onclick="getdelfilename();" />
+		    </form>
+		  </td>
+		  <td align="center">
+		    <form name="fileaction" action="/adm/cfile" target="_parent" method="post" onsubmit="getactionfilename();">
+		      <nobr>
+			<input type="hidden" name="filename" value="" />
+			  <select name="action">
+			    <option>MT{Select Action}</option>
+			    <option value="newfile">MT{New file}:</option>
+			    <option value="newhtmlfile">MT{New HTML file}:</option>
+			    <option value="newproblemfile">MT{New problem}:</option>
+                            <option value="newpagefile">MT{New assembled page}:</option>
+                            <option value="newsequencefile">MT{New assembled sequence}:</option>
+                            <option value="newrightsfile">MT{New custom rights file}:</option>
+                            <option value="newstyfile">MT{New style file}:</option>
+                            <option value="newlibraryfile">MT{New library file}:</option>
+			    <option value="newdir">MT{New subdirectory}:</option>
+			    <option value="rename">MT{Rename current file to}:</option>
+			    <option value="move">MT{Move current file to}:</option>
+			    <option value="copy">MT{Copy current file to}:</option>
+			  </select>&nbsp;<input type="text" name="newfilename" value="MT{Type Name Here}" onfocus="if (this.value == 'MT{Type Name Here}') this.value=''" />&nbsp;<input type="button" value="MT{Go}" onclick="getactionfilename();" />
+		      </nobr>
+		    </form>
+		   </td>
+		</tr>
+      </table>
+    </body>
+  </html>