aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCesar G <prototech91@gmail.com>2013-12-18 19:23:14 -0800
committerCesar G <prototech91@gmail.com>2014-01-17 19:25:12 -0800
commitebc2d1dd1bd2a102ee8c8f1b134068e7a1f75c00 (patch)
tree7fee820c60db574ed58d85c5ad1445f74e686ce2
parent9a21dec1b609db71bd9ed6b3b74c16d2d8418029 (diff)
downloadforums-ebc2d1dd1bd2a102ee8c8f1b134068e7a1f75c00.tar
forums-ebc2d1dd1bd2a102ee8c8f1b134068e7a1f75c00.tar.gz
forums-ebc2d1dd1bd2a102ee8c8f1b134068e7a1f75c00.tar.bz2
forums-ebc2d1dd1bd2a102ee8c8f1b134068e7a1f75c00.tar.xz
forums-ebc2d1dd1bd2a102ee8c8f1b134068e7a1f75c00.zip
[ticket/11915] Pass the data to the template instead of scraping HTML for it.
PHPBB3-11915
-rw-r--r--phpBB/assets/javascript/plupload.js36
-rw-r--r--phpBB/posting.php5
-rw-r--r--phpBB/styles/prosilver/template/plupload.html1
3 files changed, 7 insertions, 35 deletions
diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js
index f84a8b0a56..6b37b009a4 100644
--- a/phpBB/assets/javascript/plupload.js
+++ b/phpBB/assets/javascript/plupload.js
@@ -1,5 +1,5 @@
plupload.addI18n(phpbb.plupload.i18n);
-phpbb.plupload.data = phpbb.plupload.ids = [];
+phpbb.plupload.ids = [];
(function($) { // Avoid conflicts with other libraries
@@ -19,9 +19,8 @@ phpbb.plupload.initialize = function() {
// Show multi-file upload options.
$('#attach-panel-multi').show();
- // Gather existing attachment data from HTML.
- var data = phpbb.plupload.getDataFromHtml();
- phpbb.plupload.setData(data);
+ // Set attachment data.
+ phpbb.plupload.setData(phpbb.plupload.data);
phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData());
// Initialize the Plupload uploader.
@@ -85,35 +84,6 @@ phpbb.plupload.getSerializedData = function() {
};
/**
- * Grab all attachment data present in the HTML. This assumes
- * that all revelant data is present in form elements that have a name that follows
- * the naming convention of attachment_data[index][property]
- *
- * @return array An array containing all gathered data in the form of
- * array(index => object(property: value))
- */
-phpbb.plupload.getDataFromHtml = function() {
- var data = [],
- form = phpbb.plupload.form;
-
- for (var i = 0; i < form.length; i++) {
- if (form[i].name.indexOf('attachment_data[') !== 0) {
- continue;
- }
-
- var matches = form[i].name.match(/attachment_data\[(\d+)\]\[([^\]]+)\]/);
- var index = matches[1];
- var property = matches[2];
-
- if (typeof data[index] === 'undefined') {
- data[index] = {};
- }
- data[index][property] = form[i].value;
- }
- return data;
-};
-
-/**
* Get the index from the phpbb.plupload.data array where the given
* attachment id appears.
*
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 6066511d1c..902f1b2175 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -1548,8 +1548,9 @@ $template->assign_vars(array(
'S_BBCODE_QUOTE' => $quote_status,
'S_POST_ACTION' => $s_action,
- 'S_HIDDEN_FIELDS' => $s_hidden_fields)
-);
+ 'S_HIDDEN_FIELDS' => $s_hidden_fields,
+ 'S_ATTACH_DATA' => json_encode($message_parser->attachment_data),
+));
/**
* This event allows you to modify template variables for the posting screen
diff --git a/phpBB/styles/prosilver/template/plupload.html b/phpBB/styles/prosilver/template/plupload.html
index b7c6e42ab9..21acae1c44 100644
--- a/phpBB/styles/prosilver/template/plupload.html
+++ b/phpBB/styles/prosilver/template/plupload.html
@@ -61,6 +61,7 @@ phpbb.plupload = {
},
order: '{ATTACH_ORDER}',
maxFiles: {MAX_ATTACHMENTS},
+ data: {S_ATTACH_DATA},
}
//]]>
</script>