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

[ticket/17326] Add font icon field for custom BBCodes

Adds a new field to the custom BBCode add/edit form that
allows admins to define a Font Awesome icon to be displayed
instead of the BBCodes name on the posting.php editor page.

PHPBB-17326
This commit is contained in:
Daniel James
2024-06-25 16:36:49 +01:00
committed by Marc Alexander
parent f6c9d15b0c
commit f5bb065a4d
8 changed files with 92 additions and 4 deletions

View File

@@ -44,12 +44,12 @@ class acp_bbcodes
switch ($action)
{
case 'add':
$bbcode_match = $bbcode_tpl = $bbcode_helpline = '';
$bbcode_match = $bbcode_tpl = $bbcode_helpline = $bbcode_font_icon = '';
$display_on_posting = 0;
break;
case 'edit':
$sql = 'SELECT bbcode_match, bbcode_tpl, display_on_posting, bbcode_helpline
$sql = 'SELECT bbcode_match, bbcode_tpl, display_on_posting, bbcode_helpline, bbcode_font_icon
FROM ' . BBCODES_TABLE . '
WHERE bbcode_id = ' . $bbcode_id;
$result = $db->sql_query($sql);
@@ -65,6 +65,7 @@ class acp_bbcodes
$bbcode_tpl = htmlspecialchars($row['bbcode_tpl'], ENT_COMPAT);
$display_on_posting = $row['display_on_posting'];
$bbcode_helpline = $row['bbcode_helpline'];
$bbcode_font_icon = $row['bbcode_font_icon'];
break;
case 'modify':
@@ -88,6 +89,7 @@ class acp_bbcodes
$bbcode_match = $request->variable('bbcode_match', '');
$bbcode_tpl = html_entity_decode($request->variable('bbcode_tpl', '', true), ENT_COMPAT);
$bbcode_helpline = $request->variable('bbcode_helpline', '', true);
$bbcode_font_icon = $request->variable('bbcode_font_icon', '');
break;
}
@@ -106,6 +108,7 @@ class acp_bbcodes
'BBCODE_MATCH' => $bbcode_match,
'BBCODE_TPL' => $bbcode_tpl,
'BBCODE_HELPLINE' => $bbcode_helpline,
'BBCODE_FONT_ICON' => $bbcode_font_icon,
'DISPLAY_ON_POSTING' => $display_on_posting,
);
@@ -157,6 +160,7 @@ class acp_bbcodes
* @var string bbcode_match The bbcode usage string to match
* @var string bbcode_tpl The bbcode HTML replacement string
* @var string bbcode_helpline The bbcode help line string
* @var string bbcode_font_icon The name of the Font Awesome BBCode icon
* @var array hidden_fields Array of hidden fields for use when
* submitting form when $warn_unsafe is true
* @since 3.1.0-a3
@@ -169,6 +173,7 @@ class acp_bbcodes
'bbcode_match',
'bbcode_tpl',
'bbcode_helpline',
'bbcode_font_icon',
'hidden_fields',
);
extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_modify_create', compact($vars)));
@@ -232,6 +237,11 @@ class acp_bbcodes
trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (strlen($bbcode_font_icon) > 50)
{
trigger_error($user->lang['BBCODE_FONT_ICON_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
}
/**
* Replace Emojis and other 4bit UTF-8 chars not allowed by MySQL to UCR/NCR.
* Using their Numeric Character Reference's Hexadecimal notation.
@@ -244,6 +254,7 @@ class acp_bbcodes
'bbcode_tpl' => $bbcode_tpl,
'display_on_posting' => $display_on_posting,
'bbcode_helpline' => $bbcode_helpline,
'bbcode_font_icon' => $bbcode_font_icon,
'first_pass_match' => $data['first_pass_match'],
'first_pass_replace' => $data['first_pass_replace'],
'second_pass_match' => $data['second_pass_match'],
@@ -328,6 +339,7 @@ class acp_bbcodes
'bbcode_match' => $bbcode_match,
'bbcode_tpl' => htmlspecialchars($bbcode_tpl, ENT_COMPAT),
'bbcode_helpline' => $bbcode_helpline,
'bbcode_font_icon' => $bbcode_font_icon,
'display_on_posting' => $display_on_posting,
)))
, 'confirm_bbcode.html');

View File

@@ -1081,7 +1081,7 @@ function display_custom_bbcodes()
$num_predefined_bbcodes = NUM_PREDEFINED_BBCODES;
$sql_ary = [
'SELECT' => 'b.bbcode_id, b.bbcode_tag, b.bbcode_helpline, b.bbcode_match',
'SELECT' => 'b.bbcode_id, b.bbcode_tag, b.bbcode_helpline, b.bbcode_font_icon, b.bbcode_match',
'FROM' => [BBCODES_TABLE => 'b'],
'WHERE' => 'b.display_on_posting = 1',
'ORDER_BY' => 'b.bbcode_tag',
@@ -1124,6 +1124,7 @@ function display_custom_bbcodes()
'BBCODE_TAG' => $row['bbcode_tag'],
'BBCODE_TAG_CLEAN' => str_replace('=', '-', $row['bbcode_tag']),
'BBCODE_HELPLINE' => $row['bbcode_helpline'],
'BBCODE_FONT_ICON' => $row['bbcode_font_icon'],
];
/**