mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/16413] Adjust code and language entry, add test
PHPBB3-16413
This commit is contained in:
parent
299d6a0030
commit
71f0a3cb62
4 changed files with 70 additions and 4 deletions
|
@ -92,9 +92,9 @@
|
|||
<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" />{{ Icon('font', FIELD_ICON, '', true, 'acp-icon', {'style': 'margin:0 6px;' ~ (FIELD_ICON_COLOR ? (' color: #' ~ FIELD_ICON_COLOR ~ ';') : '')}) }}</dd>
|
||||
<dd><input name="field_icon" id="field_icon" type="text" size="15" maxlength="255" value="{{ FIELD_ICON }}" placeholder="{{ lang('FIELD_ICON') }}" />{{ Icon('font', FIELD_ICON, '', true, 'acp-icon', {'style': 'margin:0 6px;' ~ (FIELD_ICON_COLOR ? (' color: #' ~ FIELD_ICON_COLOR ~ ';') : '')}) }}</dd>
|
||||
<dd>
|
||||
<input name="field_icon_color" type="text" id="contact_field_icon_bgcolor" value="{{ FIELD_ICON_COLOR }}" size="6" maxlength="6" placeholder="{{ lang('FIELD_ICON_COLOR') }}" />
|
||||
<input name="field_icon_color" type="text" id="contact_field_icon_bgcolor" value="{{ FIELD_ICON_COLOR }}" size="7" maxlength="6" placeholder="{{ lang('FIELD_ICON_COLOR') }}" />
|
||||
<input type="color" id="field_icon_color_picker" aria-label="{{ lang('FIELD_ICON_COLOR') }}">
|
||||
</dd>
|
||||
<!-- EVENT acp_profile_contact_last -->
|
||||
|
|
|
@ -382,7 +382,7 @@ class acp_profile
|
|||
|
||||
// $exclude contains the data we gather in each step
|
||||
$exclude = array(
|
||||
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'),
|
||||
1 => array('field_ident', 'field_icon', 'field_icon_color', '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')
|
||||
);
|
||||
|
|
|
@ -95,7 +95,7 @@ $lang = array_merge($lang, array(
|
|||
'FIELD_DROPDOWN' => 'Dropdown box',
|
||||
'FIELD_ICON' => 'Field icon',
|
||||
'FIELD_ICON_COLOR' => 'Icon colour',
|
||||
'FIELD_ICON_EXPLAIN' => 'Enter the name of a Font Awesome icon to use if displaying as a contact field option above is set. Optionally, set the icon colour in 6-value hexadecimal format or choose it using the colour picker next to the icon colour field (only effective when Font Awesome icon name is set). Leave Font Awesome icon field blank to use phpBB default contact field icon if any (this will also empty the icon colour field).',
|
||||
'FIELD_ICON_EXPLAIN' => 'Enter a Font Awesome icon name to display with this contact field. Optionally, set its colour using a 6-digit hex code or the colour picker. Leave blank to use phpBB’s default icon and clear the colour.',
|
||||
'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.',
|
||||
|
|
66
tests/functional/profile_field_contact_icon_test.php
Normal file
66
tests/functional/profile_field_contact_icon_test.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class phpbb_functional_profile_field_contact_icon_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
$this->add_lang('acp/profile');
|
||||
}
|
||||
|
||||
public function test_add_contact_field_icon()
|
||||
{
|
||||
// Custom profile fields page
|
||||
$crawler = self::request('GET', 'adm/index.php?i=acp_profile&mode=profile&sid=' . $this->sid);
|
||||
|
||||
// Get any contact profile field, f.e. phpbb_twitter
|
||||
$twitter_field = $crawler->filter('tbody tr')
|
||||
->reduce(
|
||||
function ($node, $i) {
|
||||
$text = $node->text();
|
||||
return ((bool) strpos($text, 'phpbb_twitter'));
|
||||
});
|
||||
|
||||
$twitter_edit_url = $twitter_field->filter('.actions a')->eq(2)->attr('href');
|
||||
|
||||
$crawler = self::request('GET', 'adm/' . $twitter_edit_url . '&sid=' . $this->sid);
|
||||
|
||||
$this->assertStringContainsString('phpbb_twitter', $crawler->text());
|
||||
|
||||
$form = $crawler->selectButton('Profile type specific options')->form([
|
||||
'field_icon' => 'twitter',
|
||||
'field_icon_color' => '1da1f2',
|
||||
]);
|
||||
$crawler= self::submit($form);
|
||||
|
||||
$this->assertStringContainsString('Profile type specific options', $crawler->text());
|
||||
|
||||
$form = $crawler->selectButton('Save')->form();
|
||||
$crawler= self::submit($form);
|
||||
$this->assertContainsLang('CHANGED_PROFILE_FIELD', $crawler->text());
|
||||
|
||||
// Ensure contact filed icon was saved correctly
|
||||
$crawler = self::request('GET', 'adm/' . $twitter_edit_url . '&sid=' . $this->sid);
|
||||
$this->assertEquals('twitter', $crawler->filter('#field_icon')->attr('value'));
|
||||
$this->assertEquals('1da1f2', $crawler->filter('#contact_field_icon_bgcolor')->attr('value'));
|
||||
$this->assertEquals(1, $crawler->filter('i.fa-twitter')->count());
|
||||
$this->assertStringContainsString('#1da1f2;', $crawler->filter('i.fa-twitter')->attr('style'));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue