|
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" onclick="return CheckSearch();" 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 newsearch %] |
| 131 |
<form id="newsearch"> |
| 132 |
<fieldset class="action"> |
| 133 |
<button onclick="SubmitMe('new'); return false;">New search</button> |
| 134 |
[% IF plugin %] |
| 135 |
<button onclick="window.close();return false;">Close</button> |
| 136 |
[% END %] |
| 137 |
</fieldset> |
| 138 |
</form> |
| 139 |
[% END %] |
| 140 |
|
| 141 |
[% BLOCK table_results %] |
| 142 |
<table> |
| 143 |
<thead> |
| 144 |
<tr> |
| 145 |
<th>Filename</td> |
| 146 |
<th>Size</td> |
| 147 |
<th>Hashvalue</td> |
| 148 |
<th>Category</td> |
| 149 |
[% IF !plugin %]<th>Public</td>[% END %] |
| 150 |
<th>Actions</td> |
| 151 |
</tr> |
| 152 |
</thead> |
| 153 |
<tbody> |
| 154 |
[% FOREACH record IN uploads %] |
| 155 |
<tr> |
| 156 |
<td>[% record.name %]</td> |
| 157 |
<td>[% record.filesize %]</td> |
| 158 |
<td>[% record.hashvalue %]</td> |
| 159 |
<td>[% record.categorycode %]</td> |
| 160 |
[% IF !plugin %] |
| 161 |
<td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td> |
| 162 |
[% END %] |
| 163 |
<td> |
| 164 |
[% IF plugin %] |
| 165 |
<a href="" onclick="Choose('[% record.hashvalue %]'); return false;">Choose</a> |
| 166 |
[% END %] |
| 167 |
<a href="" onclick="SubmitMe( 'download', [% record.id %] ); return false;">Download</a> |
| 168 |
<a href="" onclick="ClearField(); SubmitMe( 'delete', [% record.id %] ); return false;">Delete</a> |
| 169 |
</td> |
| 170 |
</tr> |
| 171 |
[% END %] |
| 172 |
</tbody> |
| 173 |
</table> |
| 174 |
[% END %] |
| 175 |
|
| 176 |
<style type="text/css"> |
| 177 |
#fileuploadstatus,#fileuploadfailed { display : none; } |
| 178 |
#fileuploadstatus { margin:.4em; } |
| 179 |
#fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface %]/[% theme %]/img/progress.png') -300px 0px no-repeat; } |
| 180 |
</style> |
| 181 |
|
| 182 |
<script type="text/javascript"> |
| 183 |
//<![CDATA[ |
| 184 |
var errMESSAGES = [ |
| 185 |
"Error 0: Not in use", |
| 186 |
_("This file already exists (in this category)."), |
| 187 |
_("File could not be created. Check permissions."), |
| 188 |
_("Your koha-conf.xml does not contain a valid upload_path."), |
| 189 |
_("No temporary directory found."), |
| 190 |
_("File could not be read."), |
| 191 |
_("File has been deleted."), |
| 192 |
_("File could not be deleted."), |
| 193 |
]; |
| 194 |
//]]> |
| 195 |
</script> |
| 196 |
<script type="text/javascript" src="[% themelang %]/js/file-upload.js"></script> |
| 197 |
<script type="text/javascript"> |
| 198 |
//<![CDATA[ |
| 199 |
function StartUpload() { |
| 200 |
if( $('#fileToUpload').prop('files').length == 0 ) return; |
| 201 |
$('#fileToUpload').prop('disabled',true); |
| 202 |
$('#fileuploadbutton').hide(); |
| 203 |
$("#fileuploadcancel").show(); |
| 204 |
$("#fileuploadfailed").html(''); |
| 205 |
$("#myalerts").hide(''); |
| 206 |
$("#myalerts").html(''); |
| 207 |
$("#fileuploadstatus").show(); |
| 208 |
$("#uploadedfileid").val(''); |
| 209 |
$("#searchfile").hide(); |
| 210 |
$("#lastbreadcrumb").text( _("Add a new upload") ); |
| 211 |
|
| 212 |
var xtra=''; |
| 213 |
var catg = encodeURIComponent( $("#uploadcategory").val() ); |
| 214 |
if( catg ) xtra= xtra + 'category=' + catg; |
| 215 |
[% IF plugin %] |
| 216 |
xtra = xtra + '&public=1'; |
| 217 |
[% ELSE %] |
| 218 |
if( $('#public').prop('checked') ) xtra = xtra + '&public=1'; |
| 219 |
[% END %] |
| 220 |
xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload ); |
| 221 |
} |
| 222 |
function CancelUpload() { |
| 223 |
if( xhr ) xhr.abort(); |
| 224 |
$("#fileuploadstatus").hide(); |
| 225 |
$('#fileToUpload').prop('disabled', false); |
| 226 |
$('#fileuploadbutton').show(); |
| 227 |
$("#fileuploadcancel").hide(); |
| 228 |
$("#fileuploadfailed").show(); |
| 229 |
$("#fileuploadfailed").text( _("Upload status: Cancelled ") ); |
| 230 |
} |
| 231 |
function cbUpload( status, fileid, err ) { |
| 232 |
$('#fileToUpload').prop('disabled', false); |
| 233 |
if( status=='done' ) { |
| 234 |
var e = err? JSON.stringify(err): ''; |
| 235 |
SubmitMe( 'search', fileid, e ); |
| 236 |
} else { |
| 237 |
$('#fileuploadbutton').show(); |
| 238 |
$("#fileuploadcancel").hide(); |
| 239 |
$("#fileuploadstatus").hide(); |
| 240 |
$("#fileuploadfailed").show(); |
| 241 |
$("#fileuploadfailed").html( _("Upload status: ") + |
| 242 |
( status=='failed'? _("Failed"): |
| 243 |
( status=='denied'? _("Denied"): status )) |
| 244 |
); |
| 245 |
ShowAlerts( err ); |
| 246 |
} |
| 247 |
} |
| 248 |
function ShowAlerts(err) { |
| 249 |
var str = ''; |
| 250 |
for( var file in err ) { |
| 251 |
str= str + '<p>' + file + ': ' + |
| 252 |
errMESSAGES[ err[file] ] + '</p>'; |
| 253 |
} |
| 254 |
if( str ) { |
| 255 |
$('#myalerts').html(str); |
| 256 |
$('#myalerts').show(); |
| 257 |
} |
| 258 |
} |
| 259 |
function CheckSearch() { |
| 260 |
if( $("#term").val()=="" ) { |
| 261 |
alert( _("Please enter a search term.") ); |
| 262 |
return false; |
| 263 |
} |
| 264 |
return true; |
| 265 |
} |
| 266 |
function SubmitMe(op, id, msg ) { |
| 267 |
$("#submitter #op").val( op ); |
| 268 |
$("#submitter #id").val( id ); |
| 269 |
$("#submitter #msg").val( msg ); |
| 270 |
$("#submitter").submit(); |
| 271 |
} |
| 272 |
function ClearField() { |
| 273 |
[% IF plugin %] |
| 274 |
$(window.opener.document).find('#[% index %]').val( '' ); |
| 275 |
[% END %] |
| 276 |
} |
| 277 |
function Choose(hashval) { |
| 278 |
var res = '[% Koha.Preference('OPACBaseURL') %]'; |
| 279 |
res = res.replace( /\/$/, ''); |
| 280 |
res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval; |
| 281 |
[% IF index %] |
| 282 |
$(window.opener.document).find('#[% index %]').val( res ); |
| 283 |
[% END %] |
| 284 |
window.close(); |
| 285 |
} |
| 286 |
$(document).ready(function() { |
| 287 |
[% IF msg %] |
| 288 |
ShowAlerts( [% msg %] ); |
| 289 |
[% END %] |
| 290 |
$("#fileuploadcancel").hide(); |
| 291 |
}); |
| 292 |
//]]> |
| 293 |
</script> |
| 294 |
</head> |
| 295 |
|
| 296 |
<body id="tools_upload" class="tools"> |
| 297 |
[% IF !plugin %] |
| 298 |
[% INCLUDE 'header.inc' %] |
| 299 |
[% INCLUDE 'cat-search.inc' %] |
| 300 |
[% PROCESS breadcrumbs %] |
| 301 |
[% END %] |
| 302 |
|
| 303 |
<div id="doc3" class="yui-t2"> |
| 304 |
<div id="bd"> |
| 305 |
<div id="yui-main"> |
| 306 |
<div class="yui-b"> |
| 307 |
|
| 308 |
<h1>Upload</h1> |
| 309 |
|
| 310 |
<div class="dialog alert" id="myalerts" style="display:none;"></div> |
| 311 |
|
| 312 |
[% PROCESS submitter %] |
| 313 |
[% IF mode == 'new' || mode == 'deleted' %] |
| 314 |
[% PROCESS form_new %] |
| 315 |
[% PROCESS form_search %] |
| 316 |
[% PROCESS closer %] |
| 317 |
[% ELSIF mode == 'report' %] |
| 318 |
[% IF uploads %] |
| 319 |
<h3>Your request gave the following results:</h3> |
| 320 |
[% PROCESS table_results %] |
| 321 |
[% PROCESS closer %] |
| 322 |
[% ELSE %] |
| 323 |
<h4>Sorry, your request had no results.</h4> |
| 324 |
[% PROCESS newsearch %] |
| 325 |
[% END %] |
| 326 |
[% END %] |
| 327 |
|
| 328 |
</div> |
| 329 |
</div> |
| 330 |
</div> |
| 331 |
|
| 332 |
[% INCLUDE 'intranet-bottom.inc' %] |