advanced-uploads.pl 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Copyright (C) 2014 Alex-Daniel Jakimenko <alex.jakimenko@gmail.com>
  2. # This program is free software: you can redistribute it and/or modify it under
  3. # the terms of the GNU General Public License as published by the Free Software
  4. # Foundation, either version 3 of the License, or (at your option) any later
  5. # version.
  6. #
  7. # This program is distributed in the hope that it will be useful, but WITHOUT
  8. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  10. #
  11. # You should have received a copy of the GNU General Public License along with
  12. # this program. If not, see <http://www.gnu.org/licenses/>.
  13. use strict;
  14. use v5.10;
  15. AddModuleDescription('advanced-uploads.pl', 'Advanced File Upload Extension');
  16. our ($q, $HtmlHeaders);
  17. $HtmlHeaders .= '<script type="text/javascript" src="/js/uploader.js"></script>';
  18. *AdvancedUploadsOldGetTextArea = \&GetTextArea;
  19. *GetTextArea = \&AdvancedUploadsNewGetTextArea;
  20. sub AdvancedUploadsNewGetTextArea {
  21. my ($name, $text, $rows) = @_;
  22. return AdvancedUploadsOldGetTextArea(@_) . $q->br() . ($name =~ 'text|aftertext' ? GetUploadForm() : '');
  23. }
  24. sub GetUploadForm {
  25. return $q->span({-class=>'upload'}, $q->label({-for=>'fileToUpload'}, T('Attach file:')),
  26. $q->filefield(-name=>'fileToUpload', -id=>'fileToUpload', -multiple=>'multiple', -onChange=>'fileSelected()', -size=>20),
  27. $q->span({-id=>'fileSize'}, ''),
  28. $q->button(-name=>'uploadButton', -value=>T('Upload'), -onClick=>'uploadFile()'),
  29. $q->span({-id=>'progressNumber'}));
  30. }