aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2004-02-08 18:02:17 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2004-02-08 18:02:17 +0000
commitd7735d2587e68bab42fde8753ee733de76369f72 (patch)
treedcfce4a598d89b72a8469ef4f3538a0668668bee /phpBB/includes
parentb9bf2fe7519aa7aab5278fb882a139f3c823feb0 (diff)
downloadforums-d7735d2587e68bab42fde8753ee733de76369f72.tar
forums-d7735d2587e68bab42fde8753ee733de76369f72.tar.gz
forums-d7735d2587e68bab42fde8753ee733de76369f72.tar.bz2
forums-d7735d2587e68bab42fde8753ee733de76369f72.tar.xz
forums-d7735d2587e68bab42fde8753ee733de76369f72.zip
inline attachment capability...
git-svn-id: file:///svn/phpbb/trunk@4819 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/bbcode.php8
-rw-r--r--phpBB/includes/functions_display.php21
-rw-r--r--phpBB/includes/message_parser.php16
3 files changed, 36 insertions, 9 deletions
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(?:=&quot;(.*?)&quot;)?\](.+)\[/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 . ']<!-- ia' . $stx . ' -->' . $in . '<!-- ia' . $stx . ' -->[/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'] = '';
}
}