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

inline attachment capability...

git-svn-id: file:///svn/phpbb/trunk@4819 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2004-02-08 18:02:17 +00:00
parent b9bf2fe751
commit d7735d2587
12 changed files with 128 additions and 30 deletions

View File

@@ -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]))
{

View File

@@ -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;
}

View File

@@ -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 . ']<!-- 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'] = '';
}
}