Bug 13618: Add html filters to all the variables
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / upload-images.tt
index 82f5912..817fee9 100644 (file)
@@ -1,56 +1,14 @@
+[% USE raw %]
+[% USE Asset %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Upload images</title>
 [% INCLUDE 'doc-head-close.inc' %]
-
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/background-job-progressbar.js"></script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/file-upload.js"></script>
-
 <style type="text/css">
     #fileuploadstatus,#fileuploadfailed,#jobpanel,#jobstatus,#jobfailed { display : none; }
 </style>
-
-<script type="text/javascript">
-//<![CDATA[
-function StartUpload() {
-    if( $('#fileToUpload').prop('files').length == 0 ) return;
-    $('#uploadform button.submit').prop('disabled',true);
-    $("#fileuploadstatus").show();
-    $("#uploadedfileid").val('');
-    xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload );
-}
-function cbUpload( status, fileid ) {
-    if( status=='done' ) {
-        $("#uploadedfileid").val( fileid );
-        $('#fileToUpload').prop('disabled',true);
-        $("#processfile").show();
-    } else {
-        $("#fileuploadstatus").hide();
-        $("#fileuploadfailed").show();
-        $("#fileuploadfailed").text( _("Upload status: ") +
-            ( status=='failed'? _("Failed"):
-            ( status=='denied'? _("Denied"): status ))
-        );
-        $("#processfile").hide();
-    }
-}
-$(document).ready(function(){
-       $("#processfile").hide();
-       $("#zipfile").click(function(){
-               $("#bibnum").hide();
-       });
-       $("#image").click(function(){
-               $("#bibnum").show();
-       });
-    $("#uploadfile").validate({
-        submitHandler: function(form) {
-            StartUpload();
-            return false;
-        }
-    });
-});
-//]]>
-</script>
 </head>
+
 <body id="tools_upload-images" class="tools">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
@@ -67,7 +25,7 @@ $(document).ready(function(){
 [% IF ( uploadimage ) %]
 <p>Image upload results :</p>
 <ul>
-    <li>[% total %] images found</li>
+    <li>[% total | html %] images found</li>
     [% IF ( error ) %]
     <div class="dialog alert">
     [% IF ( error == 'UZIPFAIL' ) %]<p><b>Failed to unzip archive.<br />Please ensure you are uploading a valid zip file and try again.</b></p>
@@ -79,7 +37,7 @@ $(document).ready(function(){
     </div>
     </li>
     [% END %]
-    <li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]">View final record</a></li>
+    <li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | html %]">View final record</a></li>
        <li><a href="/cgi-bin/koha/tools/tools-home.pl">Back</a></li>
 </ul>
 <hr />
@@ -129,7 +87,7 @@ $(document).ready(function(){
         <label for="image">Image file</label>
       </li>
       <li class="radio">
-        [% IF ( filetype == 'image' ) %]<span id="bibnum">[% ELSE %]<span id="bibnum" style="display: none">[% END %]<label for="biblionumber">Enter cover biblionumber: </label><input type="text" id="biblionumber" name="biblionumber" value="[% biblionumber %]" size="15" /></span>
+        [% IF ( filetype == 'image' ) %]<span id="bibnum">[% ELSE %]<span id="bibnum" style="display: none">[% END %]<label for="biblionumber">Enter cover biblionumber: </label><input type="text" id="biblionumber" name="biblionumber" value="[% biblionumber | html %]" size="15" /></span>
       </li>
     </ol>
   </fieldset>
@@ -151,4 +109,52 @@ $(document).ready(function(){
 [% INCLUDE 'tools-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% Asset.js("js/tools-menu.js") | $raw %]
+    [% Asset.js("js/background-job-progressbar.js") | $raw %]
+    [% Asset.js("js/file-upload.js") | $raw %]
+    <script type="text/javascript">
+        function StartUpload() {
+            if( $('#fileToUpload').prop('files').length == 0 ) return;
+            $('#uploadform button.submit').prop('disabled',true);
+            $("#fileuploadstatus").show();
+            $("#uploadedfileid").val('');
+            xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload );
+        }
+        function cbUpload( status, fileid, errors ) {
+            if( status=='done' ) {
+                $("#uploadedfileid").val( fileid );
+                $('#fileToUpload').prop('disabled',true);
+                $("#processfile").show();
+            } else {
+                var errMsgs = [ _("Error code 0 not used"), _("File already exists"), _("Directory is not writeable"), _("Root directory for uploads not defined"), _("Temporary directory for uploads not defined") ];
+                var errCode = errors[$('#fileToUpload').prop('files')[0].name].code;
+                $("#fileuploadstatus").hide();
+                $("#fileuploadfailed").show();
+                $("#fileuploadfailed").text( _("Upload status: ") +
+                    ( status=='failed'? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode]:
+                    ( status=='denied'? _("Denied"): status ))
+                );
+                $("#processfile").hide();
+            }
+        }
+        $(document).ready(function(){
+            $("#processfile").hide();
+            $("#zipfile").click(function(){
+                $("#bibnum").hide();
+            });
+            $("#image").click(function(){
+                $("#bibnum").show();
+            });
+            $("#uploadfile").validate({
+                submitHandler: function(form) {
+                    StartUpload();
+                    return false;
+                }
+            });
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]