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

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

View file

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

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

View file

@ -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', '&copy; phpBB Group', 'subSilver', 2817);
INSERT INTO phpbb_styles_template (template_id, template_name, template_copyright, template_path, bbcode_bitfield) VALUES (1, 'subSilver', '&copy; phpBB Group', 'subSilver', 5634);
# MSSQL IDENTITY phpbb_styles_template OFF #

View file

@ -518,6 +518,8 @@ $lang += array(
'VIEW_TOPIC_POST' => '1 Post',
'VIEW_TOPIC_POSTS' => '%d Posts',
'MISSING_INLINE_ATTACHMENT' => 'The Attachment <b>%s</b> 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',

View file

@ -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 .= '<option value="' . $i . '">' . $attachment['real_filename'] . '</option>';
}
$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'])
{

View file

@ -28,6 +28,23 @@
</div>
<!-- END code_close -->
<!-- BEGIN inline_attachment_open -->
</div>
<table class="tablebg" width="100%" cellspacing="1">
<tr>
<td class="row3"><b class="genmed">{L_ATTACHMENT}: </b></td>
</tr>
<tr>
<td class="row2">
<!-- END inline_attachment_open -->
<!-- BEGIN inline_attachment_close -->
</td>
</tr>
</table>
<div class="postbody">
<!-- END inline_attachment_close -->
<!-- BEGIN b_open --><strong><!-- END b_open -->
<!-- BEGIN b_close --></strong><!-- END b_close -->

View file

@ -9,12 +9,20 @@
<tr>
<td class="row1"><b class="genmed">{L_FILENAME}</b></td>
<td class="row2"><input class="post" type="file" name="fileupload" size="40" maxlength="{FILESIZE}" value="{FILENAME}" /></td>
<td class="row2"><input class="post" type="file" name="fileupload" size="40" maxlength="{FILESIZE}" value="{FILENAME}" class="btnlite" /></td>
</tr>
<tr>
<td class="row1"><b class="genmed">{L_FILE_COMMENT}</b></td>
<td class="row2"><textarea class="post" name="filecomment" rows="3" cols="35" wrap="virtual" size="40">{FILE_COMMENT}</textarea>&nbsp;
<input class="btnlite" type="submit" name="add_file" value="{L_ADD_FILE}" /></td>
<td class="row2"><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td><textarea class="post" name="filecomment" rows="3" cols="35" wrap="virtual" size=40>{FILE_COMMENT}</textarea>&nbsp;</td>
<td valign="top"><table border="0" cellspacing="4" cellpadding="0">
<tr>
<td><input class="btnlite" type="submit" style="width:150px" name="add_file" value="{L_ADD_FILE}" /></td>
</tr></table>
</td>
</tr></table>
</td>
</tr>
<!-- IF S_HAS_ATTACHMENTS -->
@ -23,15 +31,25 @@
</tr>
<!-- BEGIN attach_row -->
<tr>
<tr>
<td class="row1"><b class="genmed">{L_FILENAME}</b></td>
<td class="row2"><a class="genmed" href="{attach_row.U_VIEW_ATTACHMENT}" target="_blank">{attach_row.FILENAME}</a></td>
</tr>
<tr>
<tr>
<td class="row1"><b class="genmed">{L_FILE_COMMENT}</b></td>
<td class="row2"><textarea class="post" name="comment_list[{attach_row.ASSOC_INDEX}]" rows="3" cols="35" wrap="virtual" size=40>{attach_row.FILE_COMMENT}</textarea> &nbsp;
<input class="btnlite" type="submit" name="edit_comment[{attach_row.ASSOC_INDEX}]" value="{L_UPDATE_COMMENT}" /> &nbsp;
<input class="btnlite" type="submit" name="delete_file[{attach_row.ASSOC_INDEX}]" value="{L_DELETE_FILE}" /></td>
<td class="row2"><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td><textarea class="post" name="comment_list[{attach_row.ASSOC_INDEX}]" rows="3" cols="35" wrap="virtual" size=40>{attach_row.FILE_COMMENT}</textarea>&nbsp;</td>
<td valign="top"><table border="0" cellspacing="4" cellpadding="0">
<tr>
<td><input class="btnlite" type="submit" style="width:150px" name="edit_comment[{attach_row.ASSOC_INDEX}]" value="{L_UPDATE_COMMENT}" /></td>
</tr>
<tr>
<td><input class="btnlite" type="submit" style="width:150px" name="delete_file[{attach_row.ASSOC_INDEX}]" value="{L_DELETE_FILE}" /></td>
</tr></table>
</td>
</tr></table>
</td>
</tr>
{attach_row.S_HIDDEN}
<!-- END attach_row -->

View file

@ -236,6 +236,13 @@ function checkForm()
</tr>
</table></td>
</tr>
<!-- IF S_INLINE_ATTACHMENT_OPTIONS -->
<tr>
<td class="row1"><b class="genmed">{L_ATTACHMENTS}:</b></td>
<td class="row2"><select name="attachments">{S_INLINE_ATTACHMENT_OPTIONS}</select>&nbsp;<input type="button" class="btnbbcode" accesskey="a" value="{L_PLACE_INLINE}" name="attachinline" onclick="attach_inline();" />
</td>
</tr>
<!-- ENDIF -->
<tr>
<td class="row1" valign="top"><b class="genmed">{L_OPTIONS}:</b><br /><table cellspacing="2" cellpadding="0" border="0">
<tr>
@ -319,7 +326,7 @@ function checkForm()
<!-- IF S_TOPIC_TYPE_ANNOUNCE or S_TOPIC_TYPE_STICKY -->
<tr>
<td class="row1"><b class="genmed">{L_STICK_TOPIC_FOR}</b><br /><span class="gensmall">{L_STICKY_ANNOUNCE_TIME_LIMIT}</span></td>
<td class="row1"><b class="genmed">{L_STICK_TOPIC_FOR}:</b><br /><span class="gensmall">{L_STICKY_ANNOUNCE_TIME_LIMIT}</span></td>
<td class="row2"><input class="post" type="text" name="topic_time_limit" size="3" maxlength="3" value="{TOPIC_TIME_LIMIT}" />&nbsp;<b class="gen">{L_DAYS}</b> <span class="gensmall">{L_STICK_TOPIC_FOR_EXPLAIN}</span></td>
</tr>
<!-- ENDIF -->

View file

@ -31,12 +31,21 @@
<td class="row1"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><span class="postbody">{PREVIEW_MESSAGE}</span>
<!-- IF S_HAS_ATTACHMENTS -->
<!-- IF S_HAS_ATTACHMENTS -->
<br clear="all" /><br />
<table class="tablebg" width="100%" cellspacing="1">
<tr>
<td class="row3"><b class="genmed">{L_ATTACHMENTS}: </b></td>
</tr>
<!-- BEGIN attachment -->
<br /><br /><hr />{attachment.DISPLAY_ATTACHMENT}
<tr>
<td class="row2">{attachment.DISPLAY_ATTACHMENT}</td>
</tr>
<!-- END attachment -->
<!-- ENDIF -->
<!-- IF PREVIEW_SIGNATURE --><span class="postbody"><br />_________________<br />{PREVIEW_SIGNATURE}</span><!-- ENDIF --></td>
</table>
<!-- ENDIF -->
<!-- IF PREVIEW_SIGNATURE --><span class="postbody"><br />_________________<br />{PREVIEW_SIGNATURE}</span><!-- ENDIF --></td>
</tr>
</table></td>
</tr>