Line 0
Link Here
|
|
|
1 |
[% INCLUDE 'doc-head-open.inc' %] |
2 |
[% USE Koha %] |
3 |
[% IF plugin %] |
4 |
<title>Upload plugin</title> |
5 |
[% ELSE %] |
6 |
<title>Koha › Tools › Upload</title> |
7 |
[% END %] |
8 |
[% INCLUDE 'doc-head-close.inc' %] |
9 |
|
10 |
[% BLOCK plugin_pars %] |
11 |
[% IF plugin %] |
12 |
<input type="hidden" name="plugin" value="1" /> |
13 |
<input type="hidden" name="index" value="[% index %]" /> |
14 |
[% END %] |
15 |
[% END %] |
16 |
|
17 |
[% BLOCK breadcrumbs %] |
18 |
<div id="breadcrumbs"> |
19 |
<a href="/cgi-bin/koha/mainpage.pl">Home</a> |
20 |
› |
21 |
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> |
22 |
› |
23 |
<a href="/cgi-bin/koha/tools/upload.pl">Upload</a> |
24 |
› |
25 |
<span id="lastbreadcrumb"> |
26 |
[% IF mode=='new' || mode =='deleted'%] |
27 |
Add new upload or search |
28 |
[% ELSE %] |
29 |
Results |
30 |
[% END %] |
31 |
</span> |
32 |
</div> |
33 |
[% END %] |
34 |
|
35 |
[% BLOCK form_new %] |
36 |
<form method="post" action="[% SCRIPT_NAME %]" id="uploadfile" enctype="multipart/form-data"> |
37 |
[% PROCESS plugin_pars %] |
38 |
<fieldset class="rows" id="uploadform"> |
39 |
<legend>Upload new files</legend> |
40 |
<ol> |
41 |
<li> |
42 |
<div id="fileuploadform"> |
43 |
<label for="fileToUpload">Select files: </label> |
44 |
<input type="file" id="fileToUpload" name="fileToUpload" multiple/> |
45 |
</div> |
46 |
</li> |
47 |
<li> |
48 |
<label for="uploadcategory">Category: </label> |
49 |
<select id="uploadcategory" name="uploadcategory"> |
50 |
[% IF !plugin %] |
51 |
<option value="" disabled hidden selected></option> |
52 |
[% END %] |
53 |
[% FOREACH cat IN uploadcategories %] |
54 |
<option value="[% cat.code %]">[% cat.name %]</option> |
55 |
[% END %] |
56 |
</select> |
57 |
</li> |
58 |
[% IF !plugin %] |
59 |
<li> |
60 |
<div class="hint">Note: For temporary uploads do not select a category. The file will not be made available for public downloading.</div> |
61 |
</li> |
62 |
[% END %] |
63 |
<li> |
64 |
[% IF plugin %] |
65 |
<input type="hidden" id="public" name="public" value="1"/> |
66 |
[% ELSE %] |
67 |
<label> </label> |
68 |
<input type="checkbox" id="public" name="public"> |
69 |
Allow public downloads |
70 |
</input> |
71 |
[% END %] |
72 |
</li> |
73 |
</ol> |
74 |
<fieldset class="action"> |
75 |
<button id="fileuploadbutton" onclick="StartUpload(); return false;">Upload</button> |
76 |
<button id="fileuploadcancel" onclick="CancelUpload(); return false;">Cancel</button> |
77 |
</fieldset> |
78 |
</fieldset> |
79 |
<div id="fileuploadpanel"> |
80 |
<div id="fileuploadstatus">Upload progress: |
81 |
<progress id="fileuploadprogress" min="0" max="100" value="0"> |
82 |
</progress> |
83 |
<span class="fileuploadpercent">0</span>% |
84 |
</div> |
85 |
<div id="fileuploadfailed"></div> |
86 |
</div> |
87 |
</form> |
88 |
[% END %] |
89 |
|
90 |
[% BLOCK form_search %] |
91 |
<form method="post" id="searchfile" action="[% SCRIPT_NAME %]" enctype="multipart/form-data"> |
92 |
[% PROCESS plugin_pars %] |
93 |
<input type="hidden" name="op" value="search"/> |
94 |
<fieldset class="rows"> |
95 |
<legend>Search uploads by name or hashvalue</legend> |
96 |
<ol> |
97 |
<li> |
98 |
<label for="searchupload">Search term: </label> |
99 |
<input type="text" id="term" name="term" value=""/> |
100 |
</li> |
101 |
<li> |
102 |
<fieldset class="action"> |
103 |
<button id="searchbutton" class="submit">Search</button> |
104 |
</fieldset> |
105 |
</li> |
106 |
</ol> |
107 |
</fieldset> |
108 |
</form> |
109 |
[% END %] |
110 |
|
111 |
[% BLOCK submitter %] |
112 |
<form id="submitter" style="display:none;" method="post"> |
113 |
[% PROCESS plugin_pars %] |
114 |
<input type="hidden" name="op" id="op" value=""/> |
115 |
<input type="hidden" name="id" id="id" value="" /> |
116 |
<input type="hidden" name="msg" id="msg" value="" /> |
117 |
</form> |
118 |
[% END %] |
119 |
|
120 |
[% BLOCK closer %] |
121 |
[% IF plugin %] |
122 |
<form id="closer"> |
123 |
<fieldset class="action"> |
124 |
<button onclick="window.close();return false;">Close</button> |
125 |
</fieldset> |
126 |
</form> |
127 |
[% END %] |
128 |
[% END %] |
129 |
|
130 |
[% BLOCK table_results %] |
131 |
<table> |
132 |
<thead> |
133 |
<tr> |
134 |
<th>Filename</td> |
135 |
<th>Size</td> |
136 |
<th>Hashvalue</td> |
137 |
<th>Category</td> |
138 |
<th>Public</td> |
139 |
<th>Actions</td> |
140 |
</tr> |
141 |
</thead> |
142 |
<tbody> |
143 |
[% FOREACH record IN uploads %] |
144 |
<tr> |
145 |
<td>[% record.name %]</td> |
146 |
<td>[% record.filesize %]</td> |
147 |
<td>[% record.hashvalue %]</td> |
148 |
<td>[% record.categorycode %]</td> |
149 |
<td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td> |
150 |
<td> |
151 |
[% IF plugin %] |
152 |
<a href="" onclick="Choose('[% record.hashvalue %]'); return false;">Choose</a> |
153 |
[% END %] |
154 |
<a href="" onclick="SubmitMe( 'download', [% record.id %] ); return false;">Download</a> |
155 |
<a href="" onclick="ClearField(); SubmitMe( 'delete', [% record.id %] ); return false;">Delete</a> |
156 |
</td> |
157 |
</tr> |
158 |
[% END %] |
159 |
</tbody> |
160 |
</table> |
161 |
[% END %] |
162 |
|
163 |
<style type="text/css"> |
164 |
#fileuploadstatus,#fileuploadfailed { display : none; } |
165 |
#fileuploadstatus { margin:.4em; } |
166 |
#fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface %]/[% theme %]/img/progress.png') -300px 0px no-repeat; } |
167 |
</style> |
168 |
|
169 |
<script type="text/javascript"> |
170 |
//<![CDATA[ |
171 |
var errMESSAGES = [ |
172 |
"Error 0: Not in use", |
173 |
_("This file already exists (in this category)."), |
174 |
_("File could not be created. Check permissions."), |
175 |
_("Your koha-conf.xml does not contain a valid upload_path."), |
176 |
_("No temporary directory found."), |
177 |
_("File could not be read."), |
178 |
_("File has been deleted."), |
179 |
_("File could not be deleted."), |
180 |
]; |
181 |
//]]> |
182 |
</script> |
183 |
<script type="text/javascript" src="[% themelang %]/js/file-upload.js"></script> |
184 |
<script type="text/javascript"> |
185 |
//<![CDATA[ |
186 |
function StartUpload() { |
187 |
if( $('#fileToUpload').prop('files').length == 0 ) return; |
188 |
$('#fileToUpload').prop('disabled',true); |
189 |
$('#fileuploadbutton').hide(); |
190 |
$("#fileuploadcancel").show(); |
191 |
$("#fileuploadfailed").html(''); |
192 |
$("#myalerts").hide(''); |
193 |
$("#myalerts").html(''); |
194 |
$("#fileuploadstatus").show(); |
195 |
$("#uploadedfileid").val(''); |
196 |
$("#searchfile").hide(); |
197 |
$("#lastbreadcrumb").text( _("Add a new upload") ); |
198 |
|
199 |
var xtra=''; |
200 |
if( $("#uploadcategory").val() ) |
201 |
xtra= xtra + 'category=' + $("#uploadcategory").val(); |
202 |
if( $('#public').prop('checked') || $('#public').val() ) |
203 |
// the second condition refers to the plugin environment |
204 |
xtra = xtra + '&public=1'; |
205 |
xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload ); |
206 |
} |
207 |
function CancelUpload() { |
208 |
if( xhr ) xhr.abort(); |
209 |
$("#fileuploadstatus").hide(); |
210 |
$('#fileToUpload').prop('disabled', false); |
211 |
$('#fileuploadbutton').show(); |
212 |
$("#fileuploadcancel").hide(); |
213 |
$("#fileuploadfailed").show(); |
214 |
$("#fileuploadfailed").text( _("Upload status: Cancelled ") ); |
215 |
} |
216 |
function cbUpload( status, fileid, err ) { |
217 |
if( status=='done' ) { |
218 |
var e = err? JSON.stringify(err): ''; |
219 |
SubmitMe( 'search', fileid, e ); |
220 |
} else { |
221 |
$('#fileToUpload').prop('disabled', false); |
222 |
$('#fileuploadbutton').show(); |
223 |
$("#fileuploadcancel").hide(); |
224 |
$("#fileuploadstatus").hide(); |
225 |
$("#fileuploadfailed").show(); |
226 |
$("#fileuploadfailed").html( _("Upload status: ") + |
227 |
( status=='failed'? _("Failed"): |
228 |
( status=='denied'? _("Denied"): status )) |
229 |
); |
230 |
ShowAlerts( err ); |
231 |
} |
232 |
} |
233 |
function ShowAlerts(err) { |
234 |
var str = ''; |
235 |
for( var file in err ) { |
236 |
str= str + '<p>' + file + ': ' + |
237 |
errMESSAGES[ err[file] ] + '</p>'; |
238 |
} |
239 |
$('#myalerts').html(str); |
240 |
$('#myalerts').show(); |
241 |
} |
242 |
function SubmitMe(op, id, msg ) { |
243 |
$("#submitter #op").val( op ); |
244 |
$("#submitter #id").val( id ); |
245 |
$("#submitter #msg").val( msg ); |
246 |
$("#submitter").submit(); |
247 |
} |
248 |
function ClearField() { |
249 |
[% IF plugin %] |
250 |
$(window.opener.document).find('#[% index %]').val( '' ); |
251 |
[% END %] |
252 |
} |
253 |
function Choose(hashval) { |
254 |
var res = '[% Koha.Preference('OPACBaseURL') %]'; |
255 |
res = res.replace( /\/$/, ''); |
256 |
res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval; |
257 |
[% IF index %] |
258 |
$(window.opener.document).find('#[% index %]').val( res ); |
259 |
[% END %] |
260 |
window.close(); |
261 |
} |
262 |
$(document).ready(function() { |
263 |
[% IF msg %] |
264 |
ShowAlerts( [% msg %] ); |
265 |
[% END %] |
266 |
$("#fileuploadcancel").hide(); |
267 |
}); |
268 |
//]]> |
269 |
</script> |
270 |
</head> |
271 |
|
272 |
<body id="tools_upload" class="tools"> |
273 |
[% IF !plugin %] |
274 |
[% INCLUDE 'header.inc' %] |
275 |
[% INCLUDE 'cat-search.inc' %] |
276 |
[% PROCESS breadcrumbs %] |
277 |
[% END %] |
278 |
|
279 |
<div id="doc3" class="yui-t2"> |
280 |
<div id="bd"> |
281 |
<div id="yui-main"> |
282 |
<div class="yui-b"> |
283 |
|
284 |
<h1>Upload</h1> |
285 |
|
286 |
<div class="dialog alert" id="myalerts" style="display:none;"></div> |
287 |
|
288 |
[% PROCESS submitter %] |
289 |
[% IF mode == 'new' || mode == 'deleted' %] |
290 |
[% PROCESS form_new %] |
291 |
[% PROCESS form_search %] |
292 |
[% ELSIF mode == 'report' %] |
293 |
[% IF uploads %] |
294 |
<h3>Your request gave the following results:</h3> |
295 |
[% PROCESS table_results %] |
296 |
[% ELSE %] |
297 |
<h4>Sorry, your request had no results.</h4> |
298 |
[% END %] |
299 |
[% END %] |
300 |
[% PROCESS closer %] |
301 |
|
302 |
</div> |
303 |
</div> |
304 |
</div> |
305 |
|
306 |
[% INCLUDE 'intranet-bottom.inc' %] |