Compare commits

...

8 commits

Author SHA1 Message Date
Daniel James
6db2bb6e08 [feature/bbcode-icon-name] Switch font icon tags to twig as well
PHPBB3-17326
2024-06-09 17:20:58 +01:00
Daniel James
303fb8ecc9 [feature/bbcode-icon-name] Update if statement syntax to twig
PHPBB3-17326
2024-06-09 17:18:08 +01:00
Daniel James
be2ea4fa80 [feature/bbcode-icon-name] Reduce font icon input to 50 chars
PHPBB3-17326
2024-06-09 15:53:24 +01:00
Daniel James
3b48879092 [feature/bbcode-icon-name] Switch to twig syntax for l10n
PHPBB3-17326
2024-06-09 15:50:53 +01:00
Daniel James
c3b65fd81a [feature/bbcode-icon-name] Update the frontend template vars
PHPBB3-17326
2024-06-09 15:47:17 +01:00
Daniel James
af0e666be8 [feature/bbcode-icon-name] Update migration to use bbcode font icon
PHPBB3-17326
2024-06-09 12:37:22 +01:00
Daniel James
e4394c0859 [feature/bbcode-icon-name] Add appearance string to languages
PHPBB3-17326
2024-06-09 12:35:40 +01:00
Daniel James
47f3c23f3f [feature/bbcode-icon-name] Update instances to bbcode font icon
PHPBB3-17326
2024-06-09 12:30:46 +01:00
7 changed files with 32 additions and 27 deletions

View file

@ -45,9 +45,13 @@
<dt><label for="display_on_posting">{L_DISPLAY_ON_POSTING}</label></dt> <dt><label for="display_on_posting">{L_DISPLAY_ON_POSTING}</label></dt>
<dd><input type="checkbox" class="radio" name="display_on_posting" id="display_on_posting" value="1"<!-- IF DISPLAY_ON_POSTING --> checked="checked"<!-- ENDIF --> /></dd> <dd><input type="checkbox" class="radio" name="display_on_posting" id="display_on_posting" value="1"<!-- IF DISPLAY_ON_POSTING --> checked="checked"<!-- ENDIF --> /></dd>
</dl> </dl>
</fieldset>
<fieldset>
<legend>{{ lang('APPEARANCE') }}</legend>
<dl> <dl>
<dt><label for="bbcode_icon_name">{L_BBCODE_ICON_NAME}</label><br /><span>{L_BBCODE_ICON_NAME_EXPLAIN}</span></dt> <dt><label for="bbcode_font_icon">{{ lang('BBCODE_FONT_ICON') }}</label><br /><span>{{ lang('BBCODE_FONT_EXPLAIN') }}</span></dt>
<dd><input type="text" name="bbcode_icon_name" id="bbcode_icon_name" value="{{ BBCODE_ICON_NAME }}" /></dd> <dd><input type="text" name="bbcode_font_icon" id="bbcode_font_icon" value="{{ BBCODE_FONT_ICON }}" /></dd>
</dl> </dl>
</fieldset> </fieldset>

View file

@ -44,12 +44,12 @@ class acp_bbcodes
switch ($action) switch ($action)
{ {
case 'add': case 'add':
$bbcode_match = $bbcode_tpl = $bbcode_helpline = $bbcode_icon_name = ''; $bbcode_match = $bbcode_tpl = $bbcode_helpline = $bbcode_font_icon = '';
$display_on_posting = 0; $display_on_posting = 0;
break; break;
case 'edit': case 'edit':
$sql = 'SELECT bbcode_match, bbcode_tpl, display_on_posting, bbcode_helpline, bbcode_icon_name $sql = 'SELECT bbcode_match, bbcode_tpl, display_on_posting, bbcode_helpline, bbcode_font_icon
FROM ' . BBCODES_TABLE . ' FROM ' . BBCODES_TABLE . '
WHERE bbcode_id = ' . $bbcode_id; WHERE bbcode_id = ' . $bbcode_id;
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
@ -65,7 +65,7 @@ class acp_bbcodes
$bbcode_tpl = htmlspecialchars($row['bbcode_tpl'], ENT_COMPAT); $bbcode_tpl = htmlspecialchars($row['bbcode_tpl'], ENT_COMPAT);
$display_on_posting = $row['display_on_posting']; $display_on_posting = $row['display_on_posting'];
$bbcode_helpline = $row['bbcode_helpline']; $bbcode_helpline = $row['bbcode_helpline'];
$bbcode_icon_name = $row['bbcode_icon_name']; $bbcode_font_icon = $row['bbcode_font_icon'];
break; break;
case 'modify': case 'modify':
@ -89,7 +89,7 @@ class acp_bbcodes
$bbcode_match = $request->variable('bbcode_match', ''); $bbcode_match = $request->variable('bbcode_match', '');
$bbcode_tpl = html_entity_decode($request->variable('bbcode_tpl', '', true), ENT_COMPAT); $bbcode_tpl = html_entity_decode($request->variable('bbcode_tpl', '', true), ENT_COMPAT);
$bbcode_helpline = $request->variable('bbcode_helpline', '', true); $bbcode_helpline = $request->variable('bbcode_helpline', '', true);
$bbcode_icon_name = $request->variable('bbcode_icon_name', ''); $bbcode_font_icon = $request->variable('bbcode_font_icon', '');
break; break;
} }
@ -108,7 +108,7 @@ class acp_bbcodes
'BBCODE_MATCH' => $bbcode_match, 'BBCODE_MATCH' => $bbcode_match,
'BBCODE_TPL' => $bbcode_tpl, 'BBCODE_TPL' => $bbcode_tpl,
'BBCODE_HELPLINE' => $bbcode_helpline, 'BBCODE_HELPLINE' => $bbcode_helpline,
'BBCODE_ICON_NAME' => $bbcode_icon_name, 'BBCODE_FONT_ICON' => $bbcode_font_icon,
'DISPLAY_ON_POSTING' => $display_on_posting, 'DISPLAY_ON_POSTING' => $display_on_posting,
); );
@ -159,7 +159,7 @@ class acp_bbcodes
* @var string bbcode_match The bbcode usage string to match * @var string bbcode_match The bbcode usage string to match
* @var string bbcode_tpl The bbcode HTML replacement string * @var string bbcode_tpl The bbcode HTML replacement string
* @var string bbcode_helpline The bbcode help line string * @var string bbcode_helpline The bbcode help line string
* @var string bbcode_icon_name The name of the bbcode FA icon * @var string bbcode_font_icon The name of the bbcode FA icon
* @var array hidden_fields Array of hidden fields for use when * @var array hidden_fields Array of hidden fields for use when
* submitting form when $warn_unsafe is true * submitting form when $warn_unsafe is true
* @since 3.1.0-a3 * @since 3.1.0-a3
@ -172,7 +172,7 @@ class acp_bbcodes
'bbcode_match', 'bbcode_match',
'bbcode_tpl', 'bbcode_tpl',
'bbcode_helpline', 'bbcode_helpline',
'bbcode_icon_name', 'bbcode_font_icon',
'hidden_fields', 'hidden_fields',
); );
extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_modify_create', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_modify_create', compact($vars)));
@ -245,9 +245,9 @@ class acp_bbcodes
trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
} }
if (strlen($bbcode_icon_name) > 255) if (strlen($bbcode_font_icon) > 50)
{ {
trigger_error($user->lang['BBCODE_ICON_NAME_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($user->lang['BBCODE_FONT_ICON_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
} }
/** /**
@ -262,7 +262,7 @@ class acp_bbcodes
'bbcode_tpl' => $bbcode_tpl, 'bbcode_tpl' => $bbcode_tpl,
'display_on_posting' => $display_on_posting, 'display_on_posting' => $display_on_posting,
'bbcode_helpline' => $bbcode_helpline, 'bbcode_helpline' => $bbcode_helpline,
'bbcode_icon_name' => $bbcode_icon_name, 'bbcode_font_icon' => $bbcode_font_icon,
'first_pass_match' => $data['first_pass_match'], 'first_pass_match' => $data['first_pass_match'],
'first_pass_replace' => $data['first_pass_replace'], 'first_pass_replace' => $data['first_pass_replace'],
'second_pass_match' => $data['second_pass_match'], 'second_pass_match' => $data['second_pass_match'],
@ -347,7 +347,7 @@ class acp_bbcodes
'bbcode_match' => $bbcode_match, 'bbcode_match' => $bbcode_match,
'bbcode_tpl' => htmlspecialchars($bbcode_tpl, ENT_COMPAT), 'bbcode_tpl' => htmlspecialchars($bbcode_tpl, ENT_COMPAT),
'bbcode_helpline' => $bbcode_helpline, 'bbcode_helpline' => $bbcode_helpline,
'bbcode_icon_name' => $bbcode_icon_name, 'bbcode_font_icon' => $bbcode_font_icon,
'display_on_posting' => $display_on_posting, 'display_on_posting' => $display_on_posting,
))) )))
, 'confirm_bbcode.html'); , 'confirm_bbcode.html');

View file

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

View file

@ -54,9 +54,9 @@ $lang = array_merge($lang, array(
'BBCODE_HELPLINE_TEXT' => 'Help line text', 'BBCODE_HELPLINE_TEXT' => 'Help line text',
'BBCODE_HELPLINE_TOO_LONG' => 'The help line you entered is too long.', 'BBCODE_HELPLINE_TOO_LONG' => 'The help line you entered is too long.',
'BBCODE_ICON_NAME' => 'Button icon', 'BBCODE_FONT_ICON' => 'BBCode icon',
'BBCODE_ICON_NAME_EXPLAIN' => 'Enter the name of a Font Awesome icon (without the fa prefix) to display instead of the BBCode name appearing on the button. <a href="https://fontawesome.com/v4/icons/">Click here</a> to view the list of available icons.', 'BBCODE_FONT_ICON_EXPLAIN' => 'Enter the name of a Font Awesome icon (without the fa prefix) to display instead of the BBCode name appearing on the button. <a href="https://fontawesome.com/v4/icons/" target="_blank">Click here</a> to view the list of available icons.',
'BBCODE_ICON_NAME_TOO_LONG' => 'The icon name you have entered is too long.', 'BBCODE_FONT_ICON_TOO_LONG' => 'The icon name you have entered is too long.',
'BBCODE_INVALID_TAG_NAME' => 'The BBCode tag name that you selected already exists.', 'BBCODE_INVALID_TAG_NAME' => 'The BBCode tag name that you selected already exists.',
'BBCODE_INVALID' => 'Your BBCode is constructed in an invalid form.', 'BBCODE_INVALID' => 'Your BBCode is constructed in an invalid form.',

View file

@ -84,6 +84,7 @@ $lang = array_merge($lang, array(
'ALL_TOPICS' => 'All Topics', 'ALL_TOPICS' => 'All Topics',
'ALT_TEXT' => 'Alternative text', 'ALT_TEXT' => 'Alternative text',
'AND' => 'And', 'AND' => 'And',
'APPEARANCE' => 'Appearance',
'ARE_WATCHING_FORUM' => 'You have subscribed to be notified of new posts in this forum.', 'ARE_WATCHING_FORUM' => 'You have subscribed to be notified of new posts in this forum.',
'ARE_WATCHING_TOPIC' => 'You have subscribed to be notified of new posts in this topic.', 'ARE_WATCHING_TOPIC' => 'You have subscribed to be notified of new posts in this topic.',
'ASCENDING' => 'Ascending', 'ASCENDING' => 'Ascending',

View file

@ -13,11 +13,11 @@
namespace phpbb\db\migration\data\v33x; namespace phpbb\db\migration\data\v33x;
class add_bbcode_icon_name extends \phpbb\db\migration\migration class add_bbcode_font_icon extends \phpbb\db\migration\migration
{ {
public function effectively_installed() public function effectively_installed()
{ {
return $this->db_tools->sql_column_exists($this->table_prefix . 'bbcodes', 'bbcode_icon_name'); return $this->db_tools->sql_column_exists($this->table_prefix . 'bbcodes', 'bbcode_font_icon');
} }
static public function depends_on() static public function depends_on()
@ -32,7 +32,7 @@ class add_bbcode_icon_name extends \phpbb\db\migration\migration
return [ return [
'add_columns' => [ 'add_columns' => [
$this->table_prefix . 'bbcodes' => [ $this->table_prefix . 'bbcodes' => [
'bbcode_icon_name' => ['VCHAR_UNI:255', ''], 'bbcode_font_icon' => ['VCHAR:50', ''],
], ],
], ],
]; ];
@ -43,7 +43,7 @@ class add_bbcode_icon_name extends \phpbb\db\migration\migration
return [ return [
'drop_columns' => [ 'drop_columns' => [
$this->table_prefix . 'bbcodes' => [ $this->table_prefix . 'bbcodes' => [
'bbcode_icon_name', 'bbcode_font_icon',
], ],
], ],
]; ];

View file

@ -97,11 +97,11 @@
<!-- BEGIN custom_tags --> <!-- BEGIN custom_tags -->
<button type="button" class="button button-secondary bbcode-{custom_tags.BBCODE_TAG_CLEAN}" name="addbbcode{custom_tags.BBCODE_ID}" value="{custom_tags.BBCODE_TAG}" onclick="bbstyle({custom_tags.BBCODE_ID})" title="{{ custom_tags.BBCODE_HELPLINE }}"> <button type="button" class="button button-secondary bbcode-{custom_tags.BBCODE_TAG_CLEAN}" name="addbbcode{custom_tags.BBCODE_ID}" value="{custom_tags.BBCODE_TAG}" onclick="bbstyle({custom_tags.BBCODE_ID})" title="{{ custom_tags.BBCODE_HELPLINE }}">
<!-- IF custom_tags.BBCODE_TAG != '' --> {% if custom_tags.BBCODE_FONT_ICON != '' %}
<i class="icon fa-{custom_tags.BBCODE_ICON_NAME} fa-fw" aria-hidden="true"></i> <i class="icon fa-{{ custom_tags.BBCODE_FONT_ICON }} fa-fw" aria-hidden="true"></i>
<!-- ELSE --> {% else %}
{custom_tags.BBCODE_TAG} {{ custom_tags.BBCODE_TAG }}
<!-- ENDIF --> {% endif %}
</button> </button>
<!-- END custom_tags --> <!-- END custom_tags -->
</div> </div>