1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[feature/plupload/integration] Integration of Plupload

This commit is a highly-refactored and up-to-date version of Fyorl's work
which was part of his Google Summer of Code 2012 project "Attachment
Improvements".

PHPBB3-10929
This commit is contained in:
Andreas Fischer
2013-10-11 17:40:16 +02:00
parent 659236a32f
commit 2050a39da7
18 changed files with 827 additions and 9 deletions

View File

@@ -1049,6 +1049,12 @@ class parse_message extends bbcode_firstpass
var $mode;
/**
* The plupload object used for dealing with attachments
* @var \phpbb\plupload\plupload
*/
protected $plupload;
/**
* Init - give message here or manually
*/
@@ -1440,6 +1446,11 @@ class parse_message extends bbcode_firstpass
if ($preview || $refresh || sizeof($error))
{
if (isset($this->plupload) && $this->plupload->is_active())
{
$json_response = new \phpbb\json_response();
}
// Perform actions on temporary attachments
if ($delete_file)
{
@@ -1484,13 +1495,17 @@ class parse_message extends bbcode_firstpass
// Reindex Array
$this->attachment_data = array_values($this->attachment_data);
if (isset($this->plupload) && $this->plupload->is_active())
{
$json_response->send($this->attachment_data);
}
}
}
else if (($add_file || $preview) && $upload_file)
{
if ($num_attachments < $cfg['max_attachments'] || $auth->acl_gets('m_', 'a_', $forum_id))
{
$filedata = upload_attachment($form_name, $forum_id, false, '', $is_message);
$filedata = upload_attachment($form_name, $forum_id, false, '', $is_message, false, $this->plupload);
$error = array_merge($error, $filedata['error']);
if (!sizeof($error))
@@ -1521,12 +1536,32 @@ class parse_message extends bbcode_firstpass
$this->attachment_data = array_merge(array(0 => $new_entry), $this->attachment_data);
$this->message = preg_replace('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#e', "'[attachment='.(\\1 + 1).']\\2[/attachment]'", $this->message);
$this->filename_data['filecomment'] = '';
if (isset($this->plupload) && $this->plupload->is_active())
{
// Send the client the attachment data to maintain state
$json_response->send($this->attachment_data);
}
}
}
else
{
$error[] = $user->lang('TOO_MANY_ATTACHMENTS', (int) $cfg['max_attachments']);
}
if (!empty($error) && isset($this->plupload) && $this->plupload->is_active())
{
// If this is a plupload (and thus ajax) request, give the
// client the first error we have
$json_response->send(array(
'jsonrpc' => '2.0',
'id' => 'id',
'error' => array(
'code' => 105,
'message' => current($error),
),
));
}
}
}
@@ -1687,4 +1722,16 @@ class parse_message extends bbcode_firstpass
$poll['poll_max_options'] = ($poll['poll_max_options'] < 1) ? 1 : (($poll['poll_max_options'] > $config['max_poll_options']) ? $config['max_poll_options'] : $poll['poll_max_options']);
}
/**
* Setter function for passing the plupload object
*
* @param \phpbb\plupload\plupload $plupload The plupload object
*
* @return null
*/
public function set_plupload(\phpbb\plupload\plupload $plupload)
{
$this->plupload = $plupload;
}
}