diff --git a/phpBB/adm/admin_bbcodes.php b/phpBB/adm/admin_bbcodes.php index 0ecf9b5ee7..e0977e094e 100644 --- a/phpBB/adm/admin_bbcodes.php +++ b/phpBB/adm/admin_bbcodes.php @@ -206,9 +206,9 @@ switch ($mode) $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); - if (empty($row['min_id']) || $row['min_id'] > 12) + if (empty($row['min_id']) || $row['min_id'] >= NUM_CORE_BBCODES) { - $bbcode_id = 12; + $bbcode_id = NUM_CORE_BBCODES + 1; } else { diff --git a/phpBB/common.php b/phpBB/common.php index 4fd057420a..754183b025 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -146,6 +146,10 @@ define('THUMB_CAT', 4); // Not used within the database, only while displaying p // BBCode UID length define('BBCODE_UID_LEN', 5); +// Number of core BBCodes +define('NUM_CORE_BBCODES', 12); + +// Profile Field Types define('FIELD_INT', 1); define('FIELD_STRING', 2); define('FIELD_TEXT', 3); diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 67a211df0a..f2df2803b9 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -127,7 +127,7 @@ class bbcode } $bbcode_ids[] = $bbcode_id; - if ($bbcode_id > 11) + if ($bbcode_id > NUM_CORE_BBCODES) { $sql .= (($sql) ? ',' : '') . $bbcode_id; } @@ -253,6 +253,12 @@ class bbcode )); } break; + case 12: + $this->bbcode_cache[$bbcode_id] = array('preg' => array( + '#\[attachment=([0-9]+):$uid\]#' => $this->bbcode_tpl('inline_attachment_open', $bbcode_id), + '#\[\/attachment:$uid\]#' => $this->bbcode_tpl('inline_attachment_close', $bbcode_id) + )); + break; default: if (isset($rowset[$bbcode_id])) { diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index f66ec0d74f..3f0bee5d39 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -331,14 +331,15 @@ function display_forums($root_data = '', $display_moderators = TRUE) } // Display Attachments -function display_attachments($blockname, $attachment_data, &$update_count, $force_physical = false) +function display_attachments($blockname, $attachment_data, &$update_count, $force_physical = false, $return = false) { global $extensions, $template, $cache, $attachment_tpl; global $config, $user, $phpbb_root_path, $phpEx, $SID, $censors; // $starttime = explode(' ', microtime()); // $starttime = $starttime[1] + $starttime[0]; - + $return_tpl = array(); + $blocks = array(WM_CAT => 'WM_STREAM', RM_CAT => 'RM_STREAM', THUMB_CAT => 'THUMBNAIL', IMAGE_CAT => 'IMAGE'); if (!isset($attachment_tpl)) @@ -428,7 +429,7 @@ function display_attachments($blockname, $attachment_data, &$update_count, $forc // Replace {L_*} lang strings $tpl = preg_replace('/{L_([A-Z_]+)}/e', "(!empty(\$user->lang['\$1'])) ? \$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $tpl); - $template->assign_block_vars('postrow.attachment', array( + $template->assign_block_vars($blockname, array( 'SHOW_ATTACHMENT' => $tpl) ); } @@ -549,12 +550,20 @@ function display_attachments($blockname, $attachment_data, &$update_count, $forc // Replace {L_*} lang strings $tpl = preg_replace('/{L_([A-Z_]+)}/e', "(!empty(\$user->lang['\$1'])) ? \$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $tpl); - $template->assign_block_vars($blockname, array( - 'DISPLAY_ATTACHMENT' => $tpl) - ); + if (!$return) + { + $template->assign_block_vars($blockname, array( + 'DISPLAY_ATTACHMENT' => $tpl) + ); + } + else + { + $return_tpl[] = $tpl; + } } } + return $return_tpl; // $mtime = explode(' ', microtime()); // $totaltime = $mtime[0] + $mtime[1] - $starttime; } diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index ec3f4cd841..bfd50c54cb 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -165,6 +165,7 @@ class parse_message $this->bbcodes = array( 'code' => array('bbcode_id' => 8, 'regexp' => array('#\[code(?:=([a-z]+))?\](.+\[/code\])#ise' => "\$this->bbcode_code('\$1', '\$2')")), 'quote' => array('bbcode_id' => 0, 'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#ise' => "\$this->bbcode_quote('\$0')")), + 'attachment'=> array('bbcode_id' => 12, 'regexp' => array('#\[attachment=([0-9]+)\](.*?)\[/attachment\]#ise' => "\$this->bbcode_attachment('\$1', '\$2')")), 'b' => array('bbcode_id' => 1, 'regexp' => array('#\[b\](.*?)\[/b\]#is' => '[b:' . $this->bbcode_uid . ']$1[/b:' . $this->bbcode_uid . ']')), 'i' => array('bbcode_id' => 2, 'regexp' => array('#\[i\](.*?)\[/i\]#is' => '[i:' . $this->bbcode_uid . ']$1[/i:' . $this->bbcode_uid . ']')), 'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url=?(.*?)?\](.*?)\[/url\]#ise' => "\$this->validate_url('\$1', '\$2')")), @@ -200,6 +201,12 @@ class parse_message } } + function bbcode_attachment($stx, $in) + { + $out = '[attachment=' . $stx . ':' . $this->bbcode_uid . ']' . $in . '[/attachment:' . $this->bbcode_uid . ']'; + return $out; + } + // Expects the argument to start right after the opening [code] tag and to end with [/code] function bbcode_code($stx, $in) { @@ -673,7 +680,8 @@ class parse_message function parse_attachments($mode, $post_id, $submit, $preview, $refresh) { - global $config, $_FILES, $_POST, $auth, $user; + global $config, $auth, $user; + global $_FILES, $_POST; $error = array(); @@ -708,6 +716,8 @@ class parse_message ); $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'] = ''; // This Variable is set to false here, because Attachments are entered into the @@ -750,7 +760,8 @@ class parse_message } unset($this->attachment_data[$index]); - + $this->message = preg_replace('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#e', "(\\1 == \$index) ? '' : ((\\1 > \$index) ? '[attachment=' . (\\1 - 1) . ']\\2[/attachment]' : '\\0')", $this->message); + // Reindex Array $this->attachment_data = array_values($this->attachment_data); } @@ -789,6 +800,7 @@ class parse_message ); $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'] = ''; } } diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 59f2d6d51b..16830ff7b2 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -283,7 +283,7 @@ INSERT INTO phpbb_styles_imageset (imageset_id, imageset_name, imageset_copyrigh # MSSQL IDENTITY phpbb_styles_template ON # # -- phpbb_styles_template -INSERT INTO phpbb_styles_template (template_id, template_name, template_copyright, template_path, bbcode_bitfield) VALUES (1, 'subSilver', '© phpBB Group', 'subSilver', 2817); +INSERT INTO phpbb_styles_template (template_id, template_name, template_copyright, template_path, bbcode_bitfield) VALUES (1, 'subSilver', '© phpBB Group', 'subSilver', 5634); # MSSQL IDENTITY phpbb_styles_template OFF # diff --git a/phpBB/language/en/lang_main.php b/phpBB/language/en/lang_main.php index 35d3115a97..9bea9dccef 100644 --- a/phpBB/language/en/lang_main.php +++ b/phpBB/language/en/lang_main.php @@ -518,6 +518,8 @@ $lang += array( 'VIEW_TOPIC_POST' => '1 Post', 'VIEW_TOPIC_POSTS' => '%d Posts', + + 'MISSING_INLINE_ATTACHMENT' => 'The Attachment %s is no longer available' ); // posting @@ -623,6 +625,7 @@ $lang += array( 'POSTED_ATTACHMENTS'=> 'Posted attachments', 'UPDATE_COMMENT' => 'Update comment', 'DELETE_FILE' => 'Delete File', + 'PLACE_INLINE' => 'Place Inline', 'DISABLE_HTML' => 'Disable HTML', 'DISABLE_BBCODE' => 'Disable BBCode', diff --git a/phpBB/posting.php b/phpBB/posting.php index 2c1836d051..3732615140 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -197,7 +197,6 @@ if ($sql) $db->sql_freeresult($result); } - if ($poster_id == ANONYMOUS || !$poster_id) { $username = (in_array($mode, array('quote', 'edit', 'delete'))) ? trim($post_username) : ''; @@ -561,6 +560,8 @@ if ($submit || $preview || $refresh) $refresh = true; } + // Parse Attachments - before checksum is calculated + $message_parser->parse_attachments($mode, $post_id, $submit, $preview, $refresh); // Grab md5 'checksum' of new message $message_md5 = md5($message_parser->message); @@ -572,8 +573,6 @@ if ($submit || $preview || $refresh) $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $img_status, $flash_status, $quote_status); } - $message_parser->parse_attachments($mode, $post_id, $submit, $preview, $refresh); - if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('f_ignoreflood', $forum_id)) { // Flood check @@ -899,6 +898,19 @@ if ($enable_icons) } } +// Generate inline attachment select box +if (sizeof($message_parser->attachment_data)) +{ + $s_inline_attachment_options = ''; + foreach ($message_parser->attachment_data as $i => $attachment) + { + + $s_inline_attachment_options .= ''; + } + + $template->assign_var('S_INLINE_ATTACHMENT_OPTIONS', $s_inline_attachment_options); +} + // Topic type selection ... only for first post in topic. $topic_type_toggle = false; if ($mode == 'post' || ($mode == 'edit' && $post_id == $topic_first_post_id)) @@ -1900,7 +1912,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_ WHERE post_id = ' . $data['post_id']); } - // Update Poll Tables and Attachment Entries + // Update Poll Tables if ($poll['poll_options']) { $cur_poll_options = array(); @@ -1950,7 +1962,8 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_ if (count($attach_data) && $data['post_id'] && in_array($mode, array('post', 'reply', 'quote', 'edit'))) { $space_taken = $files_added = 0; - foreach ($attach_data as $attach_row) + + foreach ($attach_data as $pos => $attach_row) { if ($attach_row['attach_id']) { diff --git a/phpBB/styles/subSilver/template/bbcode.html b/phpBB/styles/subSilver/template/bbcode.html index 80ecd0b349..914d685b79 100644 --- a/phpBB/styles/subSilver/template/bbcode.html +++ b/phpBB/styles/subSilver/template/bbcode.html @@ -28,6 +28,23 @@ + + + + + + + + + +
{L_ATTACHMENT}:
+ + + +
+
+ + diff --git a/phpBB/styles/subSilver/template/posting_attach_body.html b/phpBB/styles/subSilver/template/posting_attach_body.html index 243428209a..707570953a 100644 --- a/phpBB/styles/subSilver/template/posting_attach_body.html +++ b/phpBB/styles/subSilver/template/posting_attach_body.html @@ -9,12 +9,20 @@ {L_FILENAME} - + {L_FILE_COMMENT} -   - + + + + +
  + + +
+
+ @@ -23,15 +31,25 @@ - + {L_FILENAME} {attach_row.FILENAME} - + {L_FILE_COMMENT} -   -   - + + + + +
  + + + + + +
+
+ {attach_row.S_HIDDEN} diff --git a/phpBB/styles/subSilver/template/posting_body.html b/phpBB/styles/subSilver/template/posting_body.html index 7f4e49836e..7303077712 100644 --- a/phpBB/styles/subSilver/template/posting_body.html +++ b/phpBB/styles/subSilver/template/posting_body.html @@ -236,6 +236,13 @@ function checkForm() + + + {L_ATTACHMENTS}: +   + + + {L_OPTIONS}:
@@ -319,7 +326,7 @@ function checkForm() - + diff --git a/phpBB/styles/subSilver/template/posting_preview.html b/phpBB/styles/subSilver/template/posting_preview.html index ac464a278d..d8270dbd25 100644 --- a/phpBB/styles/subSilver/template/posting_preview.html +++ b/phpBB/styles/subSilver/template/posting_preview.html @@ -31,12 +31,21 @@
{L_STICK_TOPIC_FOR}
{L_STICKY_ANNOUNCE_TIME_LIMIT}
{L_STICK_TOPIC_FOR}:
{L_STICKY_ANNOUNCE_TIME_LIMIT}
 {L_DAYS} {L_STICK_TOPIC_FOR_EXPLAIN}
{PREVIEW_MESSAGE} - + +

+ + + + + -


{attachment.DISPLAY_ATTACHMENT} + + + - -
_________________
{PREVIEW_SIGNATURE}
+
{L_ATTACHMENTS}:
{attachment.DISPLAY_ATTACHMENT}
+ +
_________________
{PREVIEW_SIGNATURE}