mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-26 03:48:53 +00:00
[ticket/11915] Pass the data to the template instead of scraping HTML for it.
PHPBB3-11915
This commit is contained in:
parent
9a21dec1b6
commit
ebc2d1dd1b
3 changed files with 7 additions and 35 deletions
|
@ -1,5 +1,5 @@
|
||||||
plupload.addI18n(phpbb.plupload.i18n);
|
plupload.addI18n(phpbb.plupload.i18n);
|
||||||
phpbb.plupload.data = phpbb.plupload.ids = [];
|
phpbb.plupload.ids = [];
|
||||||
|
|
||||||
(function($) { // Avoid conflicts with other libraries
|
(function($) { // Avoid conflicts with other libraries
|
||||||
|
|
||||||
|
@ -19,9 +19,8 @@ phpbb.plupload.initialize = function() {
|
||||||
// Show multi-file upload options.
|
// Show multi-file upload options.
|
||||||
$('#attach-panel-multi').show();
|
$('#attach-panel-multi').show();
|
||||||
|
|
||||||
// Gather existing attachment data from HTML.
|
// Set attachment data.
|
||||||
var data = phpbb.plupload.getDataFromHtml();
|
phpbb.plupload.setData(phpbb.plupload.data);
|
||||||
phpbb.plupload.setData(data);
|
|
||||||
phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData());
|
phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData());
|
||||||
|
|
||||||
// Initialize the Plupload uploader.
|
// Initialize the Plupload uploader.
|
||||||
|
@ -84,35 +83,6 @@ phpbb.plupload.getSerializedData = function() {
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* Get the index from the phpbb.plupload.data array where the given
|
||||||
* attachment id appears.
|
* attachment id appears.
|
||||||
|
|
|
@ -1548,8 +1548,9 @@ $template->assign_vars(array(
|
||||||
'S_BBCODE_QUOTE' => $quote_status,
|
'S_BBCODE_QUOTE' => $quote_status,
|
||||||
|
|
||||||
'S_POST_ACTION' => $s_action,
|
'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
|
* This event allows you to modify template variables for the posting screen
|
||||||
|
|
|
@ -61,6 +61,7 @@ phpbb.plupload = {
|
||||||
},
|
},
|
||||||
order: '{ATTACH_ORDER}',
|
order: '{ATTACH_ORDER}',
|
||||||
maxFiles: {MAX_ATTACHMENTS},
|
maxFiles: {MAX_ATTACHMENTS},
|
||||||
|
data: {S_ATTACH_DATA},
|
||||||
}
|
}
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Reference in a new issue