diff options
author | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2015-10-14 08:40:01 +0200 |
---|---|---|
committer | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2015-10-14 08:40:01 +0200 |
commit | cac090b659a90749a8ea6ed7f62af980ffe7c60d (patch) | |
tree | 154e581503145a6a7b9223850d05bb85626defe7 /phpBB/includes/message_parser.php | |
parent | 359ef56e3538cb91f11587f77ecfc4bc423ebd96 (diff) | |
parent | bb2634b5e5bdee53118eff8cdba3fea73932ff47 (diff) | |
download | forums-cac090b659a90749a8ea6ed7f62af980ffe7c60d.tar forums-cac090b659a90749a8ea6ed7f62af980ffe7c60d.tar.gz forums-cac090b659a90749a8ea6ed7f62af980ffe7c60d.tar.bz2 forums-cac090b659a90749a8ea6ed7f62af980ffe7c60d.tar.xz forums-cac090b659a90749a8ea6ed7f62af980ffe7c60d.zip |
Merge pull request #3913 from marc1706/ticket/14168
[ticket/14168] Refactor attachment management functions into classes
* marc1706/ticket/14168: (36 commits)
[ticket/14168] Correctly state return type of upload and upload_attachment
[ticket/14168] Use attachment manager instead of separate classes
[ticket/14168] Fix docblock in manager
[ticket/14168] Add more test cases for attachment manager
[ticket/14168] Add new test method and more tests
[ticket/14168] Fix tabs in manager and add test file
[ticket/14168] Fix tests after rebase
[ticket/14168] Add attachment manager service
[ticket/14168] Use correct docblock
[ticket/14168] Add services_attachment.yml to services.yml
[ticket/14168] Minor coding style fixes
[ticket/14168] Move attachment service definitions to services_attachment
[ticket/14168] Improve code coverage in upload class
[ticket/14168] Move image check and don't use trigger_error()
[ticket/14168] Add tests for init_error() during upload
[ticket/14168] Add basic test file for attachments upload
[ticket/14168] Fix CS issue
[ticket/14168] No longer use deprecated functions in core files
[ticket/14168] Move phpbb_unlink() into attachment delete class
[ticket/14168] Reset sequence before tests in delete tests
...
Diffstat (limited to 'phpBB/includes/message_parser.php')
-rw-r--r-- | phpBB/includes/message_parser.php | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 31fc1577a2..059037168d 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1141,12 +1141,6 @@ class parse_message extends bbcode_firstpass protected $plupload; /** - * The mimetype guesser object used for attachment mimetypes - * @var \phpbb\mimetype\guesser - */ - protected $mimetype_guesser; - - /** * Init - give message here or manually */ function parse_message($message = '') @@ -1541,6 +1535,7 @@ class parse_message extends bbcode_firstpass function parse_attachments($form_name, $mode, $forum_id, $submit, $preview, $refresh, $is_message = false) { global $config, $auth, $user, $phpbb_root_path, $phpEx, $db, $request; + global $phpbb_container; $error = array(); @@ -1576,7 +1571,9 @@ class parse_message extends bbcode_firstpass { if ($num_attachments < $cfg['max_attachments'] || $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id)) { - $filedata = upload_attachment($form_name, $forum_id, false, '', $is_message); + /** @var \phpbb\attachment\manager $attachment_manager */ + $attachment_manager = $phpbb_container->get('attachment.manager'); + $filedata = $attachment_manager->upload($form_name, $forum_id, false, '', $is_message); $error = $filedata['error']; if ($filedata['post_attach'] && !sizeof($error)) @@ -1646,6 +1643,9 @@ class parse_message extends bbcode_firstpass if ($index !== false && !empty($this->attachment_data[$index])) { + /** @var \phpbb\attachment\manager $attachment_manager */ + $attachment_manager = $phpbb_container->get('attachment.manager'); + // delete selected attachment if ($this->attachment_data[$index]['is_orphan']) { @@ -1660,11 +1660,11 @@ class parse_message extends bbcode_firstpass if ($row) { - phpbb_unlink($row['physical_filename'], 'file'); + $attachment_manager->unlink($row['physical_filename'], 'file'); if ($row['thumbnail']) { - phpbb_unlink($row['physical_filename'], 'thumbnail'); + $attachment_manager->unlink($row['physical_filename'], 'thumbnail'); } $db->sql_query('DELETE FROM ' . ATTACHMENTS_TABLE . ' WHERE attach_id = ' . (int) $this->attachment_data[$index]['attach_id']); @@ -1672,7 +1672,7 @@ class parse_message extends bbcode_firstpass } else { - delete_attachments('attach', array(intval($this->attachment_data[$index]['attach_id']))); + $attachment_manager->delete('attach', $this->attachment_data[$index]['attach_id']); } unset($this->attachment_data[$index]); @@ -1692,7 +1692,9 @@ class parse_message extends bbcode_firstpass { if ($num_attachments < $cfg['max_attachments'] || $auth->acl_gets('m_', 'a_', $forum_id)) { - $filedata = upload_attachment($form_name, $forum_id, false, '', $is_message, false, $this->mimetype_guesser, $this->plupload); + /** @var \phpbb\attachment\manager $attachment_manager */ + $attachment_manager = $phpbb_container->get('attachment.manager'); + $filedata = $attachment_manager->upload($form_name, $forum_id, false, '', $is_message); $error = array_merge($error, $filedata['error']); if (!sizeof($error)) @@ -1981,18 +1983,6 @@ class parse_message extends bbcode_firstpass } /** - * Setter function for passing the mimetype_guesser object - * - * @param \phpbb\mimetype\guesser $mimetype_guesser The mimetype_guesser object - * - * @return null - */ - public function set_mimetype_guesser(\phpbb\mimetype\guesser $mimetype_guesser) - { - $this->mimetype_guesser = $mimetype_guesser; - } - - /** * Function to perform custom bbcode validation by extensions * can be used in bbcode_init() to assign regexp replacement * Example: 'regexp' => array('#\[b\](.*?)\[/b\]#uise' => "\$this->validate_bbcode_by_extension('\$1')") |