[ticket/16413] Add icon background color option

PHPBB3-16413
This commit is contained in:
rxu 2025-05-12 14:47:55 +07:00
parent 24c3bc3f1f
commit 95da75d82c
No known key found for this signature in database
GPG key ID: 8117904FEDEFDD17
5 changed files with 30 additions and 19 deletions

View file

@ -92,7 +92,7 @@
<dd><input class="text medium" type="text" name="field_contact_desc" id="field_contact_desc" value="{FIELD_CONTACT_DESC}" /> <label for="field_contact_desc">{L_FIELD_CONTACT_DESC}</label></dd>
<dd><input class="text medium" type="text" name="field_contact_url" id="field_contact_url" value="{FIELD_CONTACT_URL}" /> <label for="field_contact_url">{L_FIELD_CONTACT_URL}</label></dd>
<dt><label for="field_icon">{{ lang('FIELD_ICON') ~ lang('COLON') }}</label><br /><span>{{ lang('FIELD_ICON_EXPLAIN') }}</span></dt>
<dd><input name="field_icon" id="field_icon" type="text" size="15" maxlength="255" value="{{ FIELD_ICON }}" placeholder="files-o" /><i style="font:16px FontAwesome;margin:0 6px;vertical-align: middle;" class="icon fa-{{ FIELD_ICON }} fa-fw"></i></dd>
<dd><input name="field_icon" id="field_icon" type="text" size="15" maxlength="255" value="{{ FIELD_ICON }}" placeholder="files-o" />{{ Icon('font', FIELD_ICON, '', true, {'style': 'color: #' ~ FIELD_ICON_COLOR}) }}</dd>
<!-- EVENT acp_profile_contact_last -->
</dl>
{% EVENT acp_profile_contact_after %}

View file

@ -360,7 +360,7 @@ class acp_profile
$field_row = array_merge($profile_field->get_default_option_values(), array(
'field_ident' => str_replace(' ', '_', utf8_clean_string($request->variable('field_ident', '', true))),
'field_required' => 0,
'field_icon' => '',
'field_icon' => json_encode(['name' => '', 'color' => '']),
'field_show_novalue'=> 0,
'field_hide' => 0,
'field_show_profile'=> 0,
@ -428,8 +428,12 @@ class acp_profile
$options = $profile_field->prepare_options_form($exclude, $visibility_ary);
$field_icon_data = json_decode($field_row['field_icon'], true);
$cp->vars['field_icon'] = json_encode([
'name' => $request->variable('field_icon', $field_icon_data['name'] ?: ''),
'color' => $request->variable('field_icon_color', $field_icon_data['color'] ?: ''),
]);
$cp->vars['field_ident'] = ($action == 'create' && $step == 1) ? utf8_clean_string($request->variable('field_ident', $field_row['field_ident'], true)) : $request->variable('field_ident', $field_row['field_ident']);
$cp->vars['field_icon'] = $request->variable('field_icon', $field_row['field_icon']);
$cp->vars['lang_name'] = $request->variable('lang_name', $field_row['lang_name'], true);
$cp->vars['lang_explain'] = $request->variable('lang_explain', $field_row['lang_explain'], true);
$cp->vars['lang_default_value'] = $request->variable('lang_default_value', $field_row['lang_default_value'], true);
@ -632,6 +636,7 @@ class acp_profile
{
// Create basic options - only small differences between field types
case 1:
$field_icon_data = json_decode($cp->vars['field_icon'], true);
$template_vars = array(
'S_STEP_ONE' => true,
'S_FIELD_REQUIRED' => ($cp->vars['field_required']) ? true : false,
@ -650,7 +655,8 @@ class acp_profile
'L_LANG_SPECIFIC' => sprintf($user->lang['LANG_SPECIFIC_OPTIONS'], $config['default_lang']),
'FIELD_TYPE' => $profile_field->get_name(),
'FIELD_IDENT' => $cp->vars['field_ident'],
'FIELD_ICON' => $cp->vars['field_icon'],
'FIELD_ICON' => $field_icon_data['name'],
'FIELD_ICON_COLOR' => $field_icon_data['color'],
'LANG_NAME' => $cp->vars['lang_name'],
'LANG_EXPLAIN' => $cp->vars['lang_explain'],
);

View file

@ -1,17 +1,17 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\db\migration\data\v330;
namespace phpbb\db\migration\data\v400;
class custom_profile_field_contact_icon extends \phpbb\db\migration\migration
{
@ -22,7 +22,9 @@ class custom_profile_field_contact_icon extends \phpbb\db\migration\migration
public static function depends_on()
{
return ['\phpbb\db\migration\data\v330\v330',];
return [
'\phpbb\db\migration\data\v400\dev',
];
}
public function update_schema()
@ -30,7 +32,7 @@ class custom_profile_field_contact_icon extends \phpbb\db\migration\migration
return array(
'add_columns' => [
$this->table_prefix . 'profile_fields' => [
'field_icon' => array('VCHAR:255', ''),
'field_icon' => array('VCHAR:255', json_encode(['name' => '', 'color' => ''])),
],
],
);

View file

@ -194,7 +194,8 @@
<a href="<!-- IF postrow.contact.U_CONTACT -->{postrow.contact.U_CONTACT}<!-- ELSE -->{postrow.U_POST_AUTHOR}<!-- ENDIF -->" title="{postrow.contact.NAME}"<!-- IF $S_LAST_CELL --> class="last-cell"<!-- ENDIF -->>
{% EVENT viewtopic_body_contact_icon_prepend %}
{% if postrow.contact.ICON %}
{{ Icon('font', contact.ICON, '', true, '') }}
{% set color = postrow.contact.ICON_COLOR ? ('color: #' ~ contact.ICON_COLOR) : '' %}
{{ Icon('font', contact.ICON, '', true, '', '', {'style': color}) }}
{% elseif postrow.contact.ID == 'pm' %}
{{ Icon('font', 'message', '', true, 'far contact-icon') }}
{% elseif postrow.contact.ID == 'email' %}

View file

@ -2193,9 +2193,11 @@ for ($i = 0, $end = count($post_list); $i < $end; ++$i)
if ($field_data['S_PROFILE_CONTACT'])
{
$icon_data = json_decode($field_data['PROFILE_FIELD_ICON'], true);
$template->assign_block_vars('postrow.contact', array(
'ID' => $field_data['PROFILE_FIELD_IDENT'],
'ICON' => $field_data['PROFILE_FIELD_ICON'],
'ICON' => $icon_data['name'],
'ICON_COLOR'=> $icon_data['color'],
'NAME' => $field_data['PROFILE_FIELD_NAME'],
'U_CONTACT' => $field_data['PROFILE_FIELD_CONTACT'],
));