Koha/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt
Owen Leonard 2813e1e276
Bug 34796: Improve translation of title tags: Tools - Additional tools
This patch modifies templates for tools under the "Additional tools"
heading so that title tags can be more easily translated. The patch also
makes some modifications to titles, breadcrumb navigation, and page
headers in order to make them more consistent with each other and with
other similar pages.

To test, apply the patch and go to Tools. Test each page below and each
variation of the page to confirm that titles, breadcrumbs, and page
headers look correct.

- Calendar
- CSV profiles
  - Main page
    - New CSV profile
    - Modify CSV profile
    - Confirm deletion of CSV profile
- Log viewer
  - Search results
- News, HTML customizations, and pages
  - Create and modify each content type: news, pages, HTML
    customizations
- Task scheduler
- Quote editor
  - Main page
  - New quote
  - Edit quote
  - Import quotes
- Uploads
  - Main page
  - Upload file
  - Delete file
  - Search for file
- Access files
- OPAC problem reports (with OPACReportProblem enabled)

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-10-09 11:41:22 -03:00

536 lines
20 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE Koha %]
[% USE KohaDates %]
[% USE TablesSettings %]
[% USE AuthorisedValues %]
[%- USE KohaSpan -%]
[% PROCESS 'i18n.inc' %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% FILTER collapse %]
[% IF mode == 'new' || mode == 'deleted' %]
[% t("Uploads") | html %] &rsaquo;
[% ELSE %]
[% END %]
[% IF mode == 'report' %]
[% t("Results") | html %] &rsaquo;
[% t("Uploads") | html %] &rsaquo;
[% END %]
[% t("Tools") | html %] &rsaquo;
[% t("Koha") | html %]
[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK plugin_pars %]
[% IF plugin %]
<input type="hidden" name="plugin" value="1" />
<input type="hidden" name="index" value="[% index | html %]" />
[% END %]
[% END %]
[% BLOCK form_new %]
<form method="post" action="/cgi-bin/koha/tools/upload.pl" id="uploadfile" enctype="multipart/form-data">
[% PROCESS plugin_pars %]
<fieldset class="rows" id="uploadform">
<legend>Upload new files</legend>
<ol>
<li>
<div id="fileuploadform">
<label for="fileToUpload">Select files: </label>
<input type="file" id="fileToUpload" name="fileToUpload" multiple/>
</div>
</li>
[% IF uploadcategories %]
<li>
<label for="uploadcategory">Category: </label>
<select id="uploadcategory" name="uploadcategory">
[% IF !plugin %]
<option value=""></option>
[% END %]
[% FOREACH cat IN uploadcategories %]
<option value="[% cat.code | html %]">[% cat.name | html %]</option>
[% END %]
</select>
</li>
[% END %]
[% IF !plugin %]
<li>
[% IF uploadcategories %]
<div class="hint">Note: For temporary uploads do not select a category.</div>
[% ELSE %]
<div class="hint">
Note: No upload categories are defined.
[% IF ( CAN_user_parameters_manage_auth_values ) -%]
[% av_UPLOAD_link = BLOCK %]<a href='/cgi-bin/koha/admin/authorised_values.pl?searchfield=UPLOAD'>UPLOAD</a>[% END %]
<span>Add values to the [% av_UPLOAD_link | $raw | $KohaSpan %] authorized value category otherwise all uploads will be marked as temporary.</span>
[% ELSE -%]
<span>An administrator must add values to the UPLOAD authorized value category otherwise all uploads will be marked as temporary.</span>
[% END %]
</div>
[% END %]
</li>
[% END %]
<li>
[% IF plugin %]
<input type="hidden" id="public" name="public" value="1"/>
[% ELSE %]
<label id="public_cb">Allow public downloads:</label>
<input type="checkbox" id="public" name="public" />
[% END %]
</li>
</ol>
</fieldset>
<fieldset class="action">
<button id="fileuploadbutton" class="btn btn-primary">Upload</button>
<button id="fileuploadcancel" class="btn btn-link">Cancel</button>
</fieldset>
<div id="fileuploadpanel">
<div id="fileuploadstatus" class="progress_panel">Upload progress:
<progress id="fileuploadprogress" max="100" value="0">
</progress>
<span class="fileuploadpercent">0</span>%
</div>
<div id="fileuploadfailed"></div>
</div>
</form>
[% END %]
[% BLOCK form_browse %]
[% IF uploadcategories %]
<form method="post" id="browsefile" action="/cgi-bin/koha/tools/upload.pl">
[% PROCESS plugin_pars %]
<input type="hidden" name="op" value="browse"/>
<fieldset class="brief">
<h4>Search uploads by category</h4>
<ol>
<li>
<label for="browsecategory">Category: </label>
<select id="browsecategory" name="browsecategory" required="required">
<option value="">Choose</option>
[% FOREACH cat IN uploadcategories %]
[% IF cat.code == browsecategory %]
<option value="[% cat.code | html %]" selected="selected">[% cat.name | html %]</option>
[% ELSE -%]
<option value="[% cat.code | html %]">[% cat.name | html %]</option>
[% END %]
[% END %]
</select>
</li>
</ol>
</fieldset>
<fieldset class="action">
<button id="browsebutton" class="btn btn-primary">Search</button>
</fieldset>
</form>
[% END %]
[% END %]
[% BLOCK form_search %]
<form method="post" id="searchfile" action="/cgi-bin/koha/tools/upload.pl">
[% PROCESS plugin_pars %]
<input type="hidden" name="op" value="search"/>
<fieldset class="brief">
<h4>Search uploads by name or hashvalue</h4>
<ol>
<li>
<label for="term">Search term: </label>
<input type="text" id="term" name="term" value=""/>
</li>
</ol>
</fieldset>
<fieldset class="action">
<button id="searchbutton" class="btn btn-primary">Search</button>
</fieldset>
</form>
[% END %]
[% BLOCK submitter %]
<form id="submitter" style="display:none;" method="post">
[% PROCESS plugin_pars %]
<input type="hidden" name="op" id="op" value=""/>
<input type="hidden" name="id" id="id" value="" />
<input type="hidden" name="msg" id="msg" value="" />
</form>
[% END %]
[% BLOCK closer %]
[% IF plugin %]
<div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
[% END %]
[% END %]
[% BLOCK back %]
[% IF !plugin %]
<form id="back">
<fieldset class="action">
<button class="btn btn-default">Back</button>
</fieldset>
</form>
[% END %]
[% END %]
[% BLOCK newsearch %]
<form id="newsearch">
<fieldset class="action">
<button id="new_search" class="btn btn-default">New search</button>
</fieldset>
</form>
[% IF plugin %]
<div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
[% END %]
[% END %]
[% BLOCK table_results %]
<div class="page-section">
<table id="uploadresults">
<thead>
<tr>
<th>Filename</th>
<th>Size</th>
<th>Hashvalue</th>
<th>Date added</th>
<th>Category</th>
[% IF !plugin %]<th>Public</th>[% END %]
[% IF !plugin %]<th>Temporary</th>[% END %]
<th class="NoSort noExport">Actions</th>
</tr>
</thead>
<tbody>
[% FOREACH record IN uploads %]
<tr>
<td>[% record.filename | html %]</td>
<td>[% record.filesize | html %]</td>
<td>[% record.hashvalue | html %]</td>
<td data-order="[% record.dtcreated | html %]">[% record.dtcreated | $KohaDates with_hours = 1 %]</td>
<td>
<a href="/cgi-bin/koha/tools/upload.pl?op=browse&browsecategory=[% record.uploadcategorycode | uri %]">[% AuthorisedValues.GetByCode( 'UPLOAD', record.uploadcategorycode ) | html %]</a>
</td>
[% IF !plugin %]
<td>
[% IF record.public %]
<a href="[% Koha.Preference('OPACBaseURL') | url %]/cgi-bin/koha/opac-retrieve-file.pl?id=[% record.hashvalue | uri %]" class="get-file" data-toggle="tooltip"><i class="fa fa-link" aria-hidden="true"></i> Yes</a>
[% ELSE %]
No
[% END %]
</td>
<td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td>
[% END %]
<td class="actions">
[% IF plugin %]
<button class="btn btn-default btn-xs choose_entry" data-record-hashvalue="[% record.hashvalue | html %]"><i class="fa fa-plus"></i> Choose</button>
[% END %]
<button class="btn btn-default btn-xs download_entry" data-record-id="[% record.id | html %]"><i class="fa fa-download"></i> Download</button>
[% IF record.owner == owner || CAN_user_tools_upload_manage %]
<button class="btn btn-default btn-xs delete_entry" data-record-id="[% record.id | html %]"><i class="fa fa-trash-can"></i> Delete</button>
[% END %]
</td>
</tr>
[% END %]
</tbody>
</table>
</div> <!-- /.page-section -->
[% END %]
<style>
#fileuploadstatus,#fileuploadfailed { display : none; }
#fileuploadstatus { margin:.4em; }
#fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface | html %]/[% theme | html %]/img/progress.png') -300px 0px no-repeat; }
</style>
</head>
[% IF ( plugin ) %]
<body id="tools_upload" class="tools">
<div class="main container-fluid">
<div class="row">
<div class="col-sm-12">
<main>
[% ELSE %]
<body id="tools_upload" class="tools">
[% WRAPPER 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
[% END %]
[% WRAPPER 'sub-header.inc' %]
[% WRAPPER breadcrumbs %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
[% END %]
[% IF mode == 'new' || mode == 'deleted' %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
<span>Uploads</span>
[% END %]
[% ELSE %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/tools/upload.pl">Uploads</a>
[% END %]
[% END %]
[% IF mode == 'report' %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
<span>Results</span>
[% END %]
[% END %]
[% END #/ WRAPPER breadcrumbs %]
[% END #/ WRAPPER sub-header.inc %]
<div class="main container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-push-2">
<main>
[% END %]
<h1>Uploads</h1>
<div class="dialog alert" id="myalerts" style="display:none;"></div>
[% PROCESS submitter %]
[% IF mode == 'new' || mode == 'deleted' %]
[% PROCESS form_new %]
<div class="row">
[% IF uploadcategories %]
<div class="col-xs-6">
[% PROCESS form_browse %]
</div>
<div class="col-xs-6">
[% ELSE %]
<div class="col-xs-12">
[% END %]
[% PROCESS form_search %]
</div>
</div>
[% PROCESS closer %]
[% ELSIF mode == 'report' %]
<div id="toolbar" class="btn-toolbar">
<a href="/cgi-bin/koha/tools/upload.pl" class="btn btn-default">Upload file</a>
</div>
[% IF uploads %]
<h3>Your request gave the following results:</h3>
[% PROCESS table_results %]
[% PROCESS closer %]
[% PROCESS back %]
[% ELSE %]
<h4>Sorry, your request had no results.</h4>
[% PROCESS newsearch %]
[% END %]
[% END %]
[% IF !plugin %]
</main>
</div> <!-- /.col-sm-10.col-sm-push-2 -->
<div class="col-sm-2 col-sm-pull-10">
<aside>
[% IF mode == 'report' %]
[% PROCESS form_browse %]
[% PROCESS form_search %]
[% END %]
[% INCLUDE 'tools-menu.inc' %]
</aside>
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
</div> <!-- /.row -->
[% ELSE %]
</main>
</div> <!-- .col-sm-12 -->
</div> <!-- /.row -->
[% END %]
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/tools-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
[% Asset.js("js/file-upload.js") | $raw %]
[% INCLUDE 'columns_settings.inc' %]
<script>
function StartUpload() {
if( $('#fileToUpload').prop('files').length == 0 ) return;
$('#fileToUpload').prop('disabled',true);
$('#fileuploadbutton').hide();
$("#fileuploadcancel").show();
$("#fileuploadfailed").html('');
$("#myalerts").hide('');
$("#myalerts").html('');
$("#fileuploadstatus").show();
$("#uploadedfileid").val('');
$("#searchfile").hide();
$("#lastbreadcrumb").text( _("Add a new upload") );
var cat, xtra='';
if( $("#uploadcategory").val() )
cat = encodeURIComponent( $("#uploadcategory").val() );
if( cat ) xtra= 'category=' + cat + '&';
[% IF plugin %]
xtra = xtra + 'public=1&temp=0';
[% ELSE %]
if( !cat ) xtra = 'temp=1&';
if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
[% END %]
xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
}
function CancelUpload() {
if( xhr ) xhr.abort();
$("#fileuploadstatus").hide();
$('#fileToUpload').prop('disabled', false);
$('#fileuploadbutton').show();
$("#fileuploadcancel").hide();
$("#fileuploadfailed").show();
$("#fileuploadfailed").text( _("Upload status: Cancelled ") );
}
function cbUpload( status, fileid, err ) {
$('#fileToUpload').prop('disabled', false);
if( status=='done' ) {
var e = err? JSON.stringify(err): '';
SubmitMe( 'search', fileid, e );
} else {
$('#fileuploadbutton').show();
$("#fileuploadcancel").hide();
$("#fileuploadstatus").hide();
$("#fileuploadfailed").show();
$("#fileuploadfailed").html( _("Upload status: ") +
( status=='failed'? _("Failed"):
( status=='denied'? _("Denied"): status ))
);
ShowAlerts( err );
}
}
function ShowAlerts(err) {
var str = '';
for( var file in err ) {
str= str + '<p>' + file + ': ' +
errMESSAGES( err[file].code ) + '</p>';
}
if( str ) {
$('#myalerts').html(str);
$('#myalerts').show();
}
}
function errMESSAGES(code) {
var rv;
switch(code) {
case 'UPLERR_ALREADY_EXISTS':
rv = _("This file already exists (in this category).");
break;
case 'UPLERR_CANNOT_WRITE':
rv = _("File could not be created. Check permissions.");
break;
case 'UPLERR_NO_ROOT_DIR':
rv = _("Your koha-conf.xml does not contain a valid upload_path.");
break;
case 'UPLERR_NO_TEMP_DIR':
rv = _("No temporary directory found.");
break;
case 'UPLERR_FILE_NOT_READ':
rv = _("File could not be read.");
break;
case 'UPL_FILE_DELETED': // An alert, no error
rv = _("File has been deleted.");
break;
case 'UPLERR_FILE_NOT_DELETED':
rv = _("File or upload record could not be deleted.");
break;
default:
rv = code;
}
return rv;
}
function CheckSearch() {
if( $("#term").val()=="" ) {
alert( _("Please enter a search term.") );
return false;
}
return true;
}
function SubmitMe(op, id, msg ) {
$("#submitter #op").val( op );
$("#submitter #id").val( id );
$("#submitter #msg").val( msg );
$("#submitter").submit();
}
function DeleteEntry(id) {
if( !confirm( _("Do you really want to delete this upload?") ))
return false;
ClearField();
SubmitMe( 'delete', id );
}
function ClearField() {
[% IF plugin %]
$(window.opener.document).find('#[% index | html %]').val( '' );
[% END %]
}
function Choose(hashval) {
var res = '[% Koha.Preference('OPACBaseURL') | html %]';
res = res.replace( /\/$/, '');
res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
[% IF index %]
$(window.opener.document).find('#[% index | html %]').val( res );
[% END %]
window.close();
}
var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'upload', 'uploadresults', 'json' ) | $raw %];
[% IF plugin %]
table_settings['columns'].splice(6, 1);
table_settings['columns'].splice(5, 1);
[% END %]
$(document).ready(function() {
KohaTable("uploadresults",{
}, table_settings);
[% IF msg %]
ShowAlerts( [% msg | html %] );
[% END %]
$("#fileuploadcancel").hide();
$("#public_cb").click(function() {
$("#public").click();
});
$("#fileuploadbutton").on("click",function(e){
e.preventDefault();
StartUpload();
});
$("#fileuploadcancel").on("click",function(e){
e.preventDefault();
CancelUpload();
});
$("#searchbutton").on("click",function(){
return CheckSearch();
});
$("#uploadresults tbody").on("click",".choose_entry",function(e){
e.preventDefault();
var record_hashvalue = $(this).data("record-hashvalue");
Choose( record_hashvalue );
});
$("#uploadresults tbody").on("click",".download_entry",function(e){
e.preventDefault();
var record_id = $(this).data("record-id");
SubmitMe( 'download', record_id );
});
$("#uploadresults tbody").on("click",".delete_entry",function(e){
e.preventDefault();
var record_id = $(this).data("record-id");
DeleteEntry( record_id );
});
$("#new_search").on("click",function(e){
e.preventDefault();
SubmitMe('new');
});
if ( window.isSecureContext ) {
$(".get-file").on("click", function(e){
e.preventDefault();
if( navigator.clipboard && navigator.clipboard.writeText){
navigator.clipboard.writeText( $(this).attr("href") );
$(this).attr("data-original-title", _( "Link copied to the clipboard" ) )
.tooltip("show");
}
});
$(".get-file").tooltip({
delay: { "show": 100, "hide": 500 }
}).on("hidden.bs.tooltip", function(){
$(this).attr("data-original-title", _( "Copy link to this file" ) );
});
}
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]