mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/16413] Add an option to define CPF FontAwesome contact icon
PHPBB3-16413
This commit is contained in:
parent
9adb7eb9fe
commit
24c3bc3f1f
8 changed files with 76 additions and 2 deletions
|
@ -91,6 +91,8 @@
|
|||
<dd><input type="checkbox" class="radio" id="field_is_contact" name="field_is_contact" value="1"<!-- IF S_FIELD_CONTACT --> checked="checked"<!-- ENDIF --> /></dd>
|
||||
<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>
|
||||
<!-- EVENT acp_profile_contact_last -->
|
||||
</dl>
|
||||
{% EVENT acp_profile_contact_after %}
|
||||
|
|
|
@ -420,5 +420,16 @@ $(function() {
|
|||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Automatically display custom profile fields FontAwesome icon
|
||||
*/
|
||||
$(function() {
|
||||
$('#field_icon').on('keyup blur', function() {
|
||||
var input = $(this).val();
|
||||
var $icon = $(this).next('i');
|
||||
$icon.attr('class', 'icon fa-' + input + ' fa-fw');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
})(jQuery); // Avoid conflicts with other libraries
|
||||
|
|
|
@ -360,6 +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_show_novalue'=> 0,
|
||||
'field_hide' => 0,
|
||||
'field_show_profile'=> 0,
|
||||
|
@ -381,7 +382,7 @@ class acp_profile
|
|||
|
||||
// $exclude contains the data we gather in each step
|
||||
$exclude = array(
|
||||
1 => array('field_ident', 'lang_name', 'lang_explain', 'field_option_none', 'field_show_on_reg', 'field_show_on_pm', 'field_show_on_vt', 'field_show_on_ml', 'field_required', 'field_show_novalue', 'field_hide', 'field_show_profile', 'field_no_view', 'field_is_contact', 'field_contact_desc', 'field_contact_url'),
|
||||
1 => array('field_ident', 'field_icon', 'lang_name', 'lang_explain', 'field_option_none', 'field_show_on_reg', 'field_show_on_pm', 'field_show_on_vt', 'field_show_on_ml', 'field_required', 'field_show_novalue', 'field_hide', 'field_show_profile', 'field_no_view', 'field_is_contact', 'field_contact_desc', 'field_contact_url'),
|
||||
2 => array('field_length', 'field_maxlen', 'field_minlen', 'field_validation', 'field_novalue', 'field_default_value'),
|
||||
3 => array('l_lang_name', 'l_lang_explain', 'l_lang_default_value', 'l_lang_options')
|
||||
);
|
||||
|
@ -428,6 +429,7 @@ class acp_profile
|
|||
$options = $profile_field->prepare_options_form($exclude, $visibility_ary);
|
||||
|
||||
$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);
|
||||
|
@ -648,6 +650,7 @@ 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'],
|
||||
'LANG_NAME' => $cp->vars['lang_name'],
|
||||
'LANG_EXPLAIN' => $cp->vars['lang_explain'],
|
||||
);
|
||||
|
@ -984,6 +987,7 @@ class acp_profile
|
|||
'field_is_contact' => $cp->vars['field_is_contact'],
|
||||
'field_contact_desc' => $cp->vars['field_contact_desc'],
|
||||
'field_contact_url' => $cp->vars['field_contact_url'],
|
||||
'field_icon' => $cp->vars['field_icon'],
|
||||
);
|
||||
|
||||
$field_data = $cp->vars;
|
||||
|
|
|
@ -93,6 +93,8 @@ $lang = array_merge($lang, array(
|
|||
'FIELD_DESCRIPTION' => 'Field description',
|
||||
'FIELD_DESCRIPTION_EXPLAIN' => 'The explanation for this field presented to the user.',
|
||||
'FIELD_DROPDOWN' => 'Dropdown box',
|
||||
'FIELD_ICON' => 'Field icon',
|
||||
'FIELD_ICON_EXPLAIN' => 'Enter the name of a Font Awesome icon to use with the field while displaying in the mini-profile on the topic screen. Leave this field blank to use phpBB default contact image icon.',
|
||||
'FIELD_IDENT' => 'Field identification',
|
||||
'FIELD_IDENT_ALREADY_EXIST' => 'The chosen field identification already exist. Please choose another name.',
|
||||
'FIELD_IDENT_EXPLAIN' => 'The field identification is a name to identify the profile field within the database and the templates.',
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
<?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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
|
||||
class custom_profile_field_contact_icon extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return $this->db_tools->sql_column_exists($this->table_prefix . 'profile_fields', 'field_icon');
|
||||
}
|
||||
|
||||
public static function depends_on()
|
||||
{
|
||||
return ['\phpbb\db\migration\data\v330\v330',];
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
return array(
|
||||
'add_columns' => [
|
||||
$this->table_prefix . 'profile_fields' => [
|
||||
'field_icon' => array('VCHAR:255', ''),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
public function revert_schema()
|
||||
{
|
||||
return array(
|
||||
'drop_columns' => array(
|
||||
$this->table_prefix . 'profile_fields' => array(
|
||||
'field_icon',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -332,6 +332,7 @@ class manager
|
|||
|
||||
$tpl_fields[] = [
|
||||
'PROFILE_FIELD_IDENT' => $field_ident,
|
||||
'PROFILE_FIELD_ICON' => $field_data['field_icon'],
|
||||
'PROFILE_FIELD_TYPE' => $field_data['field_type'],
|
||||
'PROFILE_FIELD_NAME' => $profile_field->get_field_name($field_data['lang_name']),
|
||||
'PROFILE_FIELD_EXPLAIN' => $this->language->lang($field_data['lang_explain']),
|
||||
|
@ -484,6 +485,7 @@ class manager
|
|||
|
||||
$tpl_fields['row'] += [
|
||||
"PROFILE_{$ident_upper}_IDENT" => $ident,
|
||||
"PROFILE_{$ident_upper}_ICON" => $ident_ary['data']['field_icon'],
|
||||
"PROFILE_{$ident_upper}_VALUE" => $value,
|
||||
"PROFILE_{$ident_upper}_VALUE_RAW" => $value_raw,
|
||||
"PROFILE_{$ident_upper}_CONTACT" => $contact_url,
|
||||
|
@ -498,6 +500,7 @@ class manager
|
|||
|
||||
$tpl_fields['blockrow'][] = [
|
||||
'PROFILE_FIELD_IDENT' => $ident,
|
||||
'PROFILE_FIELD_ICON' => $ident_ary['data']['field_icon'],
|
||||
'PROFILE_FIELD_VALUE' => $value,
|
||||
'PROFILE_FIELD_VALUE_RAW' => $value_raw,
|
||||
'PROFILE_FIELD_CONTACT' => $contact_url,
|
||||
|
|
|
@ -193,7 +193,9 @@
|
|||
<!-- ENDIF -->
|
||||
<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.ID == 'pm' %}
|
||||
{% if postrow.contact.ICON %}
|
||||
{{ Icon('font', contact.ICON, '', true, '') }}
|
||||
{% elseif postrow.contact.ID == 'pm' %}
|
||||
{{ Icon('font', 'message', '', true, 'far contact-icon') }}
|
||||
{% elseif postrow.contact.ID == 'email' %}
|
||||
{{ Icon('font', 'at', '', true, 'fas contact-icon') }}
|
||||
|
|
|
@ -2195,6 +2195,7 @@ for ($i = 0, $end = count($post_list); $i < $end; ++$i)
|
|||
{
|
||||
$template->assign_block_vars('postrow.contact', array(
|
||||
'ID' => $field_data['PROFILE_FIELD_IDENT'],
|
||||
'ICON' => $field_data['PROFILE_FIELD_ICON'],
|
||||
'NAME' => $field_data['PROFILE_FIELD_NAME'],
|
||||
'U_CONTACT' => $field_data['PROFILE_FIELD_CONTACT'],
|
||||
));
|
||||
|
|
Loading…
Add table
Reference in a new issue