1: # The LearningOnline Network with CAPA
2: # Construction Space Buttons for Top Frame
3: #
4: # Copyright Michigan State University Board of Trustees
5: #
6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
7: #
8: # LON-CAPA is free software; you can redistribute it and/or modify
9: # it under the terms of the GNU General Public License as published by
10: # the Free Software Foundation; either version 2 of the License, or
11: # (at your option) any later version.
12: #
13: # LON-CAPA is distributed in the hope that it will be useful,
14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: # GNU General Public License for more details.
17: #
18: # You should have received a copy of the GNU General Public License
19: # along with LON-CAPA; if not, write to the Free Software
20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21: #
22: # /home/httpd/html/adm/gpl.txt
23: #
24: # http://www.lon-capa.org/
25: #
26: ###
27:
28: package Apache::lonpubmenu;
29: use Apache::lonlocal;
30: use Apache::loncommon;
31:
32: sub handler {
33: my $r = shift;
34: my %lt=&Apache::lonlocal::texthash(
35: cnpd => 'Cannot publish directory',
36: cnrd => 'Cannot retrieve directory',
37: mcdi => 'Must create new subdirectory inside a directory',
38: pubr => 'Publish this Resource',
39: pubd => 'Publish this Directory',
40: rtrv => 'Retrieve Old Version',
41: pubs => 'Publish with Subdirectories',
42: list => 'List Directory',
43: uplo => 'Upload file',
44: dele => 'Delete',
45: edit => 'Edit Catalog Information',
46: sela => 'Select Action',
47: nfil => 'New file',
48: nhtm => 'New HTML file',
49: nprb => 'New problem',
50: npag => 'New assembled page',
51: nseq => 'New assembled sequence',
52: ncrf => 'New custom rights file',
53: nsty => 'New style file',
54: nsub => 'New subdirectory',
55: renm => 'Rename current file to',
56: move => 'Move current file to',
57: copy => 'Copy current file to',
58: type => 'Type Name Here',
59: go => 'Go',
60: prnt => 'Print'
61: );
62: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['disp']);
63: my $disp = $ENV{'form.disp'};
64: # set defaults for parent directory in case frameloc is unable to determine directory
65: my $defaultdir = '/priv/'.$ENV{'user.name'}.'/';
66: if ($ENV{'request.role'} =~ m#^ca\./[^/]+/([^/]+)#) {
67: $defaultdir = '/priv/'.$1.'/';
68: }
69: $r->print(<<"ENDONE");
70: <html>
71: <head>
72: <title>LON-CAPA Publishing Frame</title>
73: <script type="text/javascript">
74: //<!--
75: function frameloc() {
76: if (parent.LONCAPAToBePublished.location.pathname.indexOf("/~")!=-1) {
77: parent.lastknownpriv=parent.LONCAPAToBePublished.location.pathname;
78: }
79: // alert ('We are at '+parent.lastknownpriv);
80: return unescape(parent.lastknownpriv);
81: }
82:
83: function getdfilename() {
84: var currloc = frameloc();
85: var currdir;
86: if (currloc.indexOf("/") != -1) {
87: var loclength = currloc.length;
88: var lastslash = currloc.lastIndexOf("/");
89: if (loclength == lastslash+1) {
90: return;
91: }
92: else {
93: currdir = currloc.substring(0,lastslash+1);
94: if (currdir.indexOf("~") != -1) {
95: currdir = currdir.substring(currdir.indexOf("~")+1,currdir.length);
96: currdir = "/priv/"+currdir
97: top.location=currdir
98: return;
99: }
100: }
101: }
102: top.location="$defaultdir";
103: }
104:
105: function getufilename() {
106: document.upublisher.filename.value=frameloc();
107: if (document.upublisher.filename.value.indexOf('/adm/pubdir')!=-1) {
108: document.upublisher.filename.value=document.dpublisher.filename.value;
109: }
110: document.upublisher.submit();
111: }
112:
113: function getactionfilename() {
114: document.fileaction.filename.value=frameloc();
115: var test=document.fileaction.action.selectedIndex;
116: if (test == 8) { // trying to create a directory
117: if (document.fileaction.filename.value.indexOf('/adm/pubdir')!=-1) {
118: document.fileaction.filename.value=document.dpublisher.filename.value;
119: }
120: if ((document.fileaction.filename.value.charAt(
121: document.fileaction.filename.value.length-1)!='/') &&
122: (document.fileaction.filename.value.indexOf('/adm/pubdir')==-1)) {
123: alert('$lt{'mcdi'}');
124: return;
125: }
126: }
127: document.fileaction.submit();
128: }
129:
130: function getcurseed() {
131: if (parent.LONCAPAToBePublished.document.lonhomework
132: &&
133: parent.LONCAPAToBePublished.document.lonhomework.rndseed
134: &&
135: parent.LONCAPAToBePublished.document.lonhomework.rndseed.value) {
136: return parent.LONCAPAToBePublished.document.lonhomework.rndseed.value;
137: }
138: return 0;
139: }
140:
141: function getproblemtype() {
142: if (parent.LONCAPAToBePublished.document.lonhomework) {
143: var optionelement;
144: var valueIndex=0;
145: for (var optionIndex=0;
146: optionIndex < parent.LONCAPAToBePublished.document.lonhomework.problemtype.options.length;
147: optionIndex++)
148: {
149: optionElement=parent.LONCAPAToBePublished.document.lonhomework.problemtype.options[optionIndex];
150: if (optionElement.selected) {
151: return optionElement.value;
152: }
153: }
154: }
155: return 0;
156: }
157:
158: function getpostdata() {
159: document.printout.postdata.value=frameloc();
160: document.printout.curseed.value=getcurseed();
161: document.printout.problemtype.value=getproblemtype();
162: document.printout.submit();
163: }
164: ENDONE
165:
166: if ($disp eq 'dir') {
167: $r->print(<<"ENDDIR");
168: function getdirname() {
169: document.publishdir.filename.value=frameloc();
170: pubdir(document.publishdir)
171: }
172:
173: function getsubdirname() {
174: document.publishsubdir.filename.value=frameloc();
175: pubrecdir(document.publishsubdir)
176: }
177:
178: function geteditcat() {
179: top.location=frameloc()+'default.meta'
180: }
181:
182: function pubdir(theform) {
183: if (confirm('Publish complete directory?')) {
184: forcepub(theform)
185: theform.submit();
186: }
187: }
188: function pubrecdir(theform) {
189: if (confirm('Publish directory and all subdirectories?')) {
190: forcepub(theform);
191: theform.submit();
192: }
193: }
194:
195: function forcepub(theform) {
196: if (confirm('Force publication of unmodified files? - OK=yes; Cancel=No.')) {
197: theform.forcerepub.value="ON";
198: }
199: }
200: ENDDIR
201: } else {
202: $r->print(<<"ENDRES");
203: function getfilename() {
204: document.publisher.filename.value=frameloc();
205: if ((document.publisher.filename.value.charAt(
206: document.publisher.filename.value.length-1)!='/') &&
207: (document.publisher.filename.value.indexOf('/adm/pubdir')==-1)) {
208: document.publisher.submit();
209: } else {
210: alert('$lt{'cnpd'}');
211: }
212: }
213:
214: function getrfilename() {
215: document.rpublisher.filename.value=frameloc();
216: if ((document.rpublisher.filename.value.charAt(
217: document.rpublisher.filename.value.length-1)!='/') &&
218: (document.rpublisher.filename.value.indexOf('/adm/pubdir')==-1)) {
219: document.rpublisher.submit();
220: } else {
221: alert('$lt{'cnrd'}');
222: }
223: }
224:
225: function getdelfilename() {
226: document.del.filename.value=frameloc();
227: document.del.submit();
228: }
229: ENDRES
230: }
231: $r->print(<<"END");
232: //-->
233: </script>
234: </head>
235: <body bgcolor="#ccffdd" text='#002200' link='#003333' vlink='#006666'>
236: <table border="0" align="center"><tr><th bgcolor="#004400" height="20">
237: <table border="0" cellspacing="2" cellpadding="2"><tr valign="middle">
238: <td bgcolor="#ccddaa" align="center">
239: END
240: if ($disp eq 'dir') {
241: $r->print('
242: <form name="publishdir" action="/adm/publish" target="_parent" method="post">
243: <input type="hidden" name="filename" value="" />
244: <input type="hidden" name="forcerepub" value="NO" />
245: <input type="button" value="'.$lt{'pubd'}.'" onclick="getdirname();" />
246: </form>
247: ');
248: } else {
249: $r->print('
250: <form name="publisher" action="/adm/publish" target="_parent" method="post">
251: <input type="hidden" name="filename" value="" />
252: <input type="button" value="'.$lt{'pubr'}.'" onclick="getfilename();" />
253: </form>
254: ');
255: }
256: $r->print(<<"ENDTWO");
257: </form>
258: </td>
259: <td bgcolor="#ccddaa" align="center">
260: <form name="dpublisher" action="/adm/pubdir" target="LONCAPAToBePublished" method="post">
261: <input type="hidden" name="filename" value="" />
262: <input type="button" value="$lt{'list'}" onclick="getdfilename();" />
263: </form>
264: </td>
265: <td bgcolor="#ccddaa" valign="top" align="center">
266: <form name="upublisher" action="/adm/upload" target="_parent"
267: method="post" enctype="multipart/form-data">
268: <input type="hidden" name="filename" value="" />
269: <input type="file" name="upfile" size="20" />
270: <input type="button" value="$lt{'uplo'}" onclick="getufilename();" />
271: </form>
272: </td>
273: <td rowspan="2" bgcolor="#ccddaa" align="center">
274: <form name="printout" target="_parent" action="/adm/printout" method="post" onsubmit="getpostdata();">
275: <input type="hidden" name="postdata" value="" />
276: <input type="hidden" name="curseed" value="" />
277: <input type="hidden" name="problemtype" value="" />
278: <input type="button" value="$lt{'prnt'}" onclick="getpostdata();" />
279: </form>
280: </td>
281: </tr>
282: <tr valign="middle">
283: ENDTWO
284: if ($disp eq 'dir') {
285: $r->print(<<"ENDDIR");
286: <td bgcolor="#ccddaa" align="center">
287: <form name="publishsubdir" action="/adm/publish" target="_parent" method="post">
288: <input type="hidden" name="filename" value="" />
289: <input type="hidden" name="forcerepub" value="NO" />
290: <input type="hidden" name="pubrec" value="1" />
291: <input type="button" value="$lt{'pubs'}" onclick="getsubdirname();" />
292: </form>
293: </td>
294: <td bgcolor="#ccddaa">
295: <form name="editcat" action="/adm/cfile" target="_parent" method="post">
296: <input type="hidden" name="filename" value="" />
297: <input type="button" value="$lt{'edit'}" onclick="geteditcat();" />
298: </form>
299: </td>
300: ENDDIR
301: } else {
302: $r->print(<<"ENDFILE");
303: <td bgcolor="#ccddaa" align="center">
304: <form name="rpublisher" action="/adm/retrieve" target="_parent" method="post">
305: <input type="hidden" name="filename" value="" />
306: <input type="button" value="$lt{'rtrv'}" onclick="getrfilename();" />
307: </form>
308: </td>
309: <td bgcolor="#ccddaa">
310: <form name="del" action="/adm/cfile" target="_parent" method="post">
311: <input type="hidden" name="filename" value="" />
312: <input type="hidden" name="action" value="delete" />
313: <input type="button" value="$lt{'dele'}" onclick="getdelfilename();" />
314: </form>
315: </td>
316: ENDFILE
317: }
318: $r->print(<<"ENDOPTIONS");
319: <td bgcolor="#ccddaa" align="center">
320: <form name="fileaction" action="/adm/cfile" target="_parent" method="post" onsubmit="getactionfilename();">
321: <nobr>
322: <input type="hidden" name="filename" value="" />
323: <select name="action">
324: <option value="Select Action">$lt{'sela'}</option>
325: <option value="newfile">$lt{'nfil'}:</option>
326: <option value="newhtmlfile">$lt{'nhtm'}:</option>
327: <option value="newproblemfile">$lt{'nprb'}:</option>
328: <option value="newpagefile">$lt{'npag'}:</option>
329: <option value="newsequencefile">$lt{'nseq'}:</option>
330: <option value="newrightsfile">$lt{'ncrf'}:</option>
331: <option value="newstyfile">$lt{'nsty'}:</option>
332: <option value="newdir">$lt{'nsub'}:</option>
333: ENDOPTIONS
334: if ($disp ne 'dir') {
335: $r->print(<<"ENDPROBOPS");
336: <option value="rename">$lt{'renm'}:</option>
337: <option value="move">$lt{'move'}:</option>
338: <option value="copy">$lt{'copy'}:</option>
339: ENDPROBOPS
340: }
341: $r->print(<<"ENDPAGE");
342: </select> <input type="text" name="newfilename" value="$lt{'type'}" onfocus="if (this.value == '$lt{'type'}') this.value=''" /> <input type="button" value="$lt{'go'}" onclick="getactionfilename();" />
343: </nobr>
344: </form>
345: </td>
346: </tr>
347: </table>
348: </th>
349: </tr>
350: </table>
351: </body>
352: </html>
353: ENDPAGE
354: }
355:
356: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>