Bonjour,
Je veux utiliser BlueImp FileUploader, j'ai donc fait un test dans mon environnement et fait quelques adaptations (accès base de données, tatouage des images, entre autre).
Tout fonctionne comme je le souhaite.
Maintenant je veux mettre BlueImp FileUploader dans mon site qui utilise smarty et là oups c'est la cata à l'affichage.
Pas terrible. En mettant en commentaire l'implémentation de la class
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 {"files":[]}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!--<html lang="fr" xmlns:v="http://rdf.data-vocabulary.org/#" > --> <html> <head> <meta name="robots" content="noindex" /> <meta name="robots" content="nofollow" />
L'affichage est correct mais bien sur BlueImp FileUploader ne fonctionne pas
Code : Sélectionner tout - Visualiser dans une fenêtre à part $upload_handler = new UploadHandler();
Après quelques recherche, effectivement BlueImp FileUploader utilise son propre système de template.
Bon apparement ce ne serait pas si terrible, il suffirait de ...comme expliqué ici et là idem
Et c'est maintenant que j'ai pris 10 ans en 3 jours.
Pas très doué je suis, jeune padawan aussi en jquery.
J'ai donc qu'en même supprimé le code qui me gênait dans le html
Ensuite je suis allé, dans main.js coller
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 <!-- The template to display files available for upload --> <script id="template-upload" type="text/x-tmpl"> {% for (var i=0, file; file=o.files[i]; i++) { %} <tr class="template-upload fade"> <td class="preview"><span class="fade"></span></td> <td class="name"><span>{%=file.name%}</span></td> <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td> {% if (file.error) { %} <td class="error" colspan="2"><span class="label label-important">Error</span> {%=file.error%}</td> {% } else if (o.files.valid && !i) { %} <td> <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div> </td> <td>{% if (!o.options.autoUpload) { %} <button class="btn btn-primary start"> <i class="icon-upload icon-white"></i> <span>Start</span> </button> {% } %}</td> {% } else { %} <td colspan="2"></td> {% } %} <td>{% if (!i) { %} <button class="btn btn-warning cancel"> <i class="icon-ban-circle icon-white"></i> <span>Cancel</span> </button> {% } %}</td> </tr> {% } %} </script> <!-- The template to display files available for download --> <script id="template-download" type="text/x-tmpl"> {% for (var i=0, file; file=o.files[i]; i++) { %} <tr class="template-download fade"> {% if (file.error) { %} <td></td> <td class="name"><span>{%=file.name%}</span></td> <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td> <td class="error" colspan="2"><span class="label label-important">Error</span> {%=file.error%}</td> {% } else { %} <td class="preview">{% if (file.thumbnail_url) { %} <a href="{%=file.url%}" title="{%=file.name%}" data-gallery="gallery" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a> {% } %}</td> <td class="name"> <a href="{%=file.url%}" title="{%=file.name%}" data-gallery="{%=file.thumbnail_url&&'gallery'%}" download="{%=file.name%}">{%=file.name%}</a> </td> <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td> <td colspan="2"></td> {% } %} <td> <button class="btn btn-danger delete" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}"{% if (file.delete_with_credentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}> <i class="icon-trash icon-white"></i> <span>Delete</span> </button> <input type="checkbox" name="delete" value="1" class="toggle"> </td> </tr> {% } %} </script>
J'ai décommenté l'implémentation de la class et toujours le même problème;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 $('#fileupload').fileupload({ filesContainer: $('#upload_files_container'), uploadTemplateId: null, downloadTemplateId: null, uploadTemplate: function (o) { var rows = $(); $.each(o.files, function (index, file) { var row = $('<tr class="template-upload fade">' + '<td class="preview"><span class="fade"></span></td>' + '<td class="name"></td>' + '<td class="size"></td>' + (file.error ? '<td class="error" colspan="2"></td>' : '<td><div class="progress">' + '<div class="bar" style="width:0%;"></div></div></td>' + '<td class="start"><button>Start</button></td>' ) + '<td class="cancel"><button>Cancel</button></td></tr>'); row.find('.name').text(file.name); row.find('.size').text(o.formatFileSize(file.size)); if (file.error) { row.find('.error').text( locale.fileupload.errors[file.error] || file.error ); } rows = rows.add(row); }); return rows; }, downloadTemplate: function (o) { var rows = $(); $.each(o.files, function (index, file) { var row = $('<tr class="template-download fade">' + (file.error ? '<td></td><td class="name"></td>' + '<td class="size"></td><td class="error" colspan="2"></td>' : '<td class="preview"></td>' + '<td class="name"><a></a></td>' + '<td class="size"></td><td colspan="2"></td>' ) + '<td class="delete"><button>Delete</button> ' + '<input type="checkbox" name="delete" value="1"></td></tr>'); row.find('.size').text(o.formatFileSize(file.size)); if (file.error) { row.find('.name').text(file.name); row.find('.error').text( locale.fileupload.errors[file.error] || file.error ); } else { row.find('.name a').text(file.name); if (file.thumbnail_url) { row.find('.preview').append('<a><img></a>') .find('img').prop('src', file.thumbnail_url); row.find('a').prop('rel', 'gallery'); } row.find('a').prop('href', file.url); row.find('.delete button') .attr('data-type', file.delete_type) .attr('data-url', file.delete_url); } rows = rows.add(row); }); return rows; } });
Quelqu'un a-t-il intégré BlueImp FileUploader avec smarty ?
Merci d'avance pour votre guidage.
Partager