diff options
author | Cesar G <prototech91@gmail.com> | 2013-11-27 14:48:38 -0800 |
---|---|---|
committer | Cesar G <prototech91@gmail.com> | 2014-01-17 19:20:36 -0800 |
commit | 9c1cacae42d5d993a004a311089d7ac943002dc5 (patch) | |
tree | 37d96df33f4f91810086c68db2015d673388de80 /phpBB | |
parent | 708622a0bba1656f8538767ab8d0e0260075dddc (diff) | |
download | forums-9c1cacae42d5d993a004a311089d7ac943002dc5.tar forums-9c1cacae42d5d993a004a311089d7ac943002dc5.tar.gz forums-9c1cacae42d5d993a004a311089d7ac943002dc5.tar.bz2 forums-9c1cacae42d5d993a004a311089d7ac943002dc5.tar.xz forums-9c1cacae42d5d993a004a311089d7ac943002dc5.zip |
[ticket/11915] Provide the URL to the attachment when it's uploaded.
PHPBB3-11915
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/assets/javascript/plupload.js | 37 | ||||
-rw-r--r-- | phpBB/includes/message_parser.php | 4 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/posting_attach_body.html | 2 |
3 files changed, 29 insertions, 14 deletions
diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index 594b88bae5..d0bf545dbc 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -142,15 +142,17 @@ phpbb.plupload.setData = function(data) { /** * Update the attachment data in the HTML and the phpbb & phpbb.plupload objects. * - * @param array data Array containing the new data to use. - * @param string action The action that required the update. Used to update the inline attachment bbcodes. - * @param int index The index from phpbb.plupload_ids that was affected by the action. + * @param array data Array containing the new data to use. + * @param string action The action that required the update. Used to update the inline attachment bbcodes. + * @param int index The index from phpbb.plupload_ids that was affected by the action. + * @param array downloadUrl Optional array of download urls to update. * @return undefined */ -phpbb.plupload.update = function (data, action, index) { +phpbb.plupload.update = function (data, action, index, downloadUrl) { + phpbb.plupload.updateBbcode(action, index); phpbb.plupload.setData(data); - phpbb.plupload.updateRows(); + phpbb.plupload.updateRows(downloadUrl); phpbb.plupload.clearParams(); phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData()); }; @@ -158,11 +160,12 @@ phpbb.plupload.update = function (data, action, index) { /** * Update the relevant elements and hidden data for all attachments. * + * @param array downloadUrl Optional array of download urls to update. * @return undefined */ -phpbb.plupload.updateRows = function () { +phpbb.plupload.updateRows = function (downloadUrl) { for (var i = 0; i < phpbb.plupload.ids.length; i++) { - phpbb.plupload.updateRow(i); + phpbb.plupload.updateRow(i, downloadUrl); } }; @@ -193,11 +196,21 @@ phpbb.plupload.insertRow = function(file) { * Update the relevant elements and hidden data for an attachment. * * @param int index The index from phpbb.plupload.ids of the attachment to edit. + * @param array downloadUrl Optional array of download urls to update. * @return undefined */ -phpbb.plupload.updateRow = function (index) { - var attach = phpbb.plupload.data[index]; - var row = $('[data-attach-id="' + attach.attach_id + '"]'); +phpbb.plupload.updateRow = function (index, downloadUrl) { + var attach = phpbb.plupload.data[index], + row = $('[data-attach-id="' + attach.attach_id + '"]'); + + // Add the link to the file + if (typeof downloadUrl !== 'undefined' && typeof downloadUrl[index] !== 'undefined') { + var url = downloadUrl[index].replace('&', '&'), + link = $('<a></a>'); + + link.attr('href', url).html(attach.real_filename); + row.find('.file-name').html(link) + } row.find('textarea').attr('name', 'comment_list[' + index + ']'); row.find('.file-inline-bbcode').attr('onclick', 'attach_inline(' + index + ',\'' + attach.real_filename + '\');'); @@ -637,12 +650,12 @@ uploader.bind('FileUploaded', function(up, file, response) { if (typeof error !== 'undefined') { phpbb.plupload.fileError(file, error); } else if (file.status === plupload.DONE) { - file.attachment_data = json[0]; + file.attachment_data = json['data'][0]; row.attr('data-attach-id', file.attachment_data.attach_id); row.find('.file-inline-bbcode').show(); row.find('.file-status').addClass('file-uploaded'); - phpbb.plupload.update(json, 'addition', 0); + phpbb.plupload.update(json['data'], 'addition', 0, [json['download_url']]); } }); diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index c964e1a5e2..ad6743b3a3 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1582,8 +1582,10 @@ class parse_message extends bbcode_firstpass if (isset($this->plupload) && $this->plupload->is_active()) { + $download_url = append_sid("{$phpbb_root_path}download/file.{$phpEx}", 'mode=view&id=' . $new_entry['attach_id']); + // Send the client the attachment data to maintain state - $json_response->send($this->attachment_data); + $json_response->send(array('data' => $this->attachment_data, 'download_url' => $download_url)); } } } diff --git a/phpBB/styles/prosilver/template/posting_attach_body.html b/phpBB/styles/prosilver/template/posting_attach_body.html index af215bb710..2af0686ac8 100644 --- a/phpBB/styles/prosilver/template/posting_attach_body.html +++ b/phpBB/styles/prosilver/template/posting_attach_body.html @@ -55,7 +55,7 @@ <!-- BEGIN attach_row --> <tr class="attach-row" data-attach-id="{attach_row.ATTACH_ID}"> <td class="attach-name"> - <a class="file-name" href="{attach_row.U_VIEW_ATTACHMENT}">{attach_row.FILENAME}</a> + <span class="file-name"><a href="{attach_row.U_VIEW_ATTACHMENT}">{attach_row.FILENAME}</a></span> <span class="attach-controls"> <!-- IF S_INLINE_ATTACHMENT_OPTIONS --><input type="button" value="{L_PLACE_INLINE}" onclick="attach_inline({attach_row.ASSOC_INDEX}, '{attach_row.A_FILENAME}');" class="button2 file-inline-bbcode" /> <!-- ENDIF --> <input type="submit" name="delete_file[{attach_row.ASSOC_INDEX}]" value="{L_DELETE_FILE}" class="button2 file-delete" /> |