Bug 6874: Clean up file URL generation
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / cataloguing / value_builder / upload.tt
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5     <title>Upload plugin</title>
6     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7     <script type="text/javascript" src="[% interface %]/lib/jquery/jquery.js"></script>
8     <link rel="stylesheet" type="text/css" href="[% themelang %]/css/staff-global.css" />
9     <script type="text/javascript">
10       function ValidateForm() {
11         var filename = document.forms["UploadForm"]["uploaded_file"].value;
12         var selected = 0;
13         var value;
14         $('form').each(function() {
15           value = $(this).find('input[type="radio"][name="dir"]:checked').val();
16           if (value) {
17             selected = 1;
18           }
19         });
20         if (!filename && !selected) {
21           alert("Please select a file and its destination.");
22           return false;
23         }
24         else if (!filename) {
25           alert("Please select a file to upload.");
26           return false;
27         }
28         else if (!selected) {
29           alert("Please select a file destination.");
30           return false;
31         }
32         else {
33           return true;
34         }
35       }
36     </script>
37
38 </head>
39 <body>
40 [% IF ( success ) %]
41
42     <script type="text/javascript">
43         function report() {
44             var doc   = opener.document;
45             var field = doc.getElementById("[% index %]");
46             field.value =  "[% return %]";
47         }
48         $(document).ready(function() {
49             report();
50         });
51     </script>
52
53
54     The file [% uploaded_file | html %] has been successfully uploaded.
55     <p><input type="button" value="close" onclick="window.close();" /></p>
56
57 [% ELSE %]
58
59     [% IF ( MissingURL ) %]
60         <p>Error: The OPAC system preference OPACBaseURL is not configured.</p>
61         <p><input type="button" value="close" onclick="window.close();" /></p>
62     [% ELSIF ( error ) %]
63         <p>Error: Failed to upload file. See logs for details.</p>
64         <p><input type="button" value="close" onclick="window.close();" /></p>
65     [% ELSE %]
66         [%# This block display recursively a directory tree in variable 'dirs' %]
67         [% BLOCK list_dirs %]
68             [% IF dirs.size %]
69                 <ul>
70                     [% FOREACH dir IN dirs %]
71                         <li style="list-style-type:none">
72                             <input type="radio" name="dir" id="[% dir.value %]" value="[% dir.value %]">
73                                 <label for="[% dir.value %]">
74                                     [% IF (dir.name == '/') %]
75                                         <em>(root)</em>
76                                     [% ELSE %]
77                                         [% dir.name %]
78                                     [% END %]
79                                 </label>
80                             </input>
81                             [% INCLUDE list_dirs dirs=dir.dirs %]
82                         </li>
83                     [% END %]
84                 </ul>
85             [% END %]
86         [% END %]
87
88         [% IF (error_upload_path_not_configured) %]
89           <h2>Configuration error</h2>
90           <p>Configuration variable 'upload_path' is not configured.</p>
91           <p>Please configure it in your koha-conf.xml</p>
92         [% ELSE %]
93           [% IF (error_nothing_selected) %]
94               <p class="error">Error: You have to choose the file to upload and select where to upload the file.</p>
95           [% END %]
96           [% IF (error_no_file_selected) %]
97               <p class="error">Error: You have to choose the file to upload.</p>
98           [% END %]
99           [% IF (error_no_dir_selected) %]
100               <p class="error">Error: You have to select where to upload the file.</p>
101           [% END %]
102           [% IF (dangling) %]
103               <p class="error">Error: The URL has no file to retrieve.</p>
104           [% END %]
105           <h2>Please select the file to upload : </h2>
106           <form name="UploadForm" method="post" enctype="multipart/form-data" action="/cgi-bin/koha/cataloguing/plugin_launcher.pl" onsubmit="return ValidateForm()">
107               [% filefield %]
108               <h3>Choose where to upload the file</h3>
109               [% INCLUDE list_dirs dirs = dirs_tree %]
110               <input type="hidden" name="from_popup" value="1" />
111               <input type="hidden" name="plugin_name" value="upload.pl" />
112               <input type="hidden" name="index" value="[% index %]" />
113               <input type="submit" value="Upload file">
114               <input type="button" value="Cancel" onclick="window.close();" />
115           </form>
116         [% END %]
117     [% END %]
118
119 [% END %]
120
121 </body>
122 </html>