mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/12187] Add URL type for profile fields
PHPBB3-12187
This commit is contained in:
parent
76409388af
commit
a2f2629e2a
9 changed files with 105 additions and 2 deletions
3
phpBB/adm/style/profilefields/url.html
Normal file
3
phpBB/adm/style/profilefields/url.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<!-- BEGIN url -->
|
||||||
|
<input type="url" class="inputbox autowidth" name="{url.FIELD_IDENT}" id="{url.FIELD_IDENT}" size="{url.FIELD_LENGTH}" maxlength="{url.FIELD_MAXLEN}" value="{url.FIELD_VALUE}" />
|
||||||
|
<!-- END url -->
|
|
@ -80,3 +80,12 @@ services:
|
||||||
- @user
|
- @user
|
||||||
tags:
|
tags:
|
||||||
- { name: profilefield.type }
|
- { name: profilefield.type }
|
||||||
|
|
||||||
|
profilefields.type.url:
|
||||||
|
class: phpbb\profilefields\type\type_url
|
||||||
|
arguments:
|
||||||
|
- @request
|
||||||
|
- @template
|
||||||
|
- @user
|
||||||
|
tags:
|
||||||
|
- { name: profilefield.type }
|
||||||
|
|
|
@ -100,6 +100,7 @@ $lang = array_merge($lang, array(
|
||||||
'FIELD_TEXT' => 'Textarea',
|
'FIELD_TEXT' => 'Textarea',
|
||||||
'FIELD_TYPE' => 'Field type',
|
'FIELD_TYPE' => 'Field type',
|
||||||
'FIELD_TYPE_EXPLAIN' => 'You are not able to change the field type later.',
|
'FIELD_TYPE_EXPLAIN' => 'You are not able to change the field type later.',
|
||||||
|
'FIELD_URL' => 'URL (Link)',
|
||||||
'FIELD_VALIDATION' => 'Field validation',
|
'FIELD_VALIDATION' => 'Field validation',
|
||||||
'FIRST_OPTION' => 'First option',
|
'FIRST_OPTION' => 'First option',
|
||||||
|
|
||||||
|
|
|
@ -209,6 +209,7 @@ $lang = array_merge($lang, array(
|
||||||
'FIELD_INVALID_CHARS_ALPHA_ONLY' => 'The field “%s” has invalid characters, only alphanumeric characters are allowed.',
|
'FIELD_INVALID_CHARS_ALPHA_ONLY' => 'The field “%s” has invalid characters, only alphanumeric characters are allowed.',
|
||||||
'FIELD_INVALID_CHARS_SPACERS_ONLY' => 'The field “%s” has invalid characters, only alphanumeric, space or -+_[] characters are allowed.',
|
'FIELD_INVALID_CHARS_SPACERS_ONLY' => 'The field “%s” has invalid characters, only alphanumeric, space or -+_[] characters are allowed.',
|
||||||
'FIELD_INVALID_DATE' => 'The field “%s” has an invalid date.',
|
'FIELD_INVALID_DATE' => 'The field “%s” has an invalid date.',
|
||||||
|
'FIELD_INVALID_URL' => 'The field “%s” has an invalid url.',
|
||||||
'FIELD_INVALID_VALUE' => 'The field “%s” has an invalid value.',
|
'FIELD_INVALID_VALUE' => 'The field “%s” has an invalid value.',
|
||||||
|
|
||||||
'FOE_MESSAGE' => 'Message from foe',
|
'FOE_MESSAGE' => 'Message from foe',
|
||||||
|
|
|
@ -61,7 +61,7 @@ class type_int extends type_base
|
||||||
0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_length" size="5" value="' . $field_data['field_length'] . '" />'),
|
0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_length" size="5" value="' . $field_data['field_length'] . '" />'),
|
||||||
1 => array('TITLE' => $this->user->lang['MIN_FIELD_NUMBER'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_minlen" size="5" value="' . $field_data['field_minlen'] . '" />'),
|
1 => array('TITLE' => $this->user->lang['MIN_FIELD_NUMBER'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_minlen" size="5" value="' . $field_data['field_minlen'] . '" />'),
|
||||||
2 => array('TITLE' => $this->user->lang['MAX_FIELD_NUMBER'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_maxlen" size="5" value="' . $field_data['field_maxlen'] . '" />'),
|
2 => array('TITLE' => $this->user->lang['MAX_FIELD_NUMBER'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_maxlen" size="5" value="' . $field_data['field_maxlen'] . '" />'),
|
||||||
3 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => '<input type="post" name="field_default_value" value="' . $field_data['field_default_value'] . '" />'),
|
3 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => '<input type="number" name="field_default_value" value="' . $field_data['field_default_value'] . '" />'),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $options;
|
return $options;
|
||||||
|
|
|
@ -109,7 +109,7 @@ class type_string extends type_string_common
|
||||||
$default_value = $profile_row['lang_default_value'];
|
$default_value = $profile_row['lang_default_value'];
|
||||||
$profile_row['field_value'] = ($this->request->is_set($field_ident)) ? $this->request->variable($field_ident, $default_value, true) : ((!isset($this->user->profile_fields[$field_ident]) || $preview_options !== false) ? $default_value : $this->user->profile_fields[$field_ident]);
|
$profile_row['field_value'] = ($this->request->is_set($field_ident)) ? $this->request->variable($field_ident, $default_value, true) : ((!isset($this->user->profile_fields[$field_ident]) || $preview_options !== false) ? $default_value : $this->user->profile_fields[$field_ident]);
|
||||||
|
|
||||||
$this->template->assign_block_vars('string', array_change_key_case($profile_row, CASE_UPPER));
|
$this->template->assign_block_vars($this->get_name_short(), array_change_key_case($profile_row, CASE_UPPER));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
83
phpBB/phpbb/profilefields/type/type_url.php
Normal file
83
phpBB/phpbb/profilefields/type/type_url.php
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package phpBB
|
||||||
|
* @copyright (c) 2014 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\profilefields\type;
|
||||||
|
|
||||||
|
class type_url extends type_string
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_name_short()
|
||||||
|
{
|
||||||
|
return 'url';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_options($default_lang_id, $field_data)
|
||||||
|
{
|
||||||
|
$options = array(
|
||||||
|
0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" name="field_length" size="5" value="' . $field_data['field_length'] . '" />'),
|
||||||
|
1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" name="field_minlen" size="5" value="' . $field_data['field_minlen'] . '" />'),
|
||||||
|
2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" name="field_maxlen" size="5" value="' . $field_data['field_maxlen'] . '" />'),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_default_option_values()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'field_length' => 40,
|
||||||
|
'field_minlen' => 0,
|
||||||
|
'field_maxlen' => 200,
|
||||||
|
'field_validation' => '',
|
||||||
|
'field_novalue' => '',
|
||||||
|
'field_default_value' => '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_profile_value($field_value, $field_data)
|
||||||
|
{
|
||||||
|
if (!$field_value && !$field_data['field_show_novalue'])
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $field_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function validate_profile_field(&$field_value, $field_data)
|
||||||
|
{
|
||||||
|
$field_value = trim($field_value);
|
||||||
|
|
||||||
|
if ($field_value === '' && !$field_data['field_required'])
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!preg_match('#^' . get_preg_expression('url') . '$#i', $field_value))
|
||||||
|
{
|
||||||
|
return $this->user->lang('FIELD_INVALID_URL', $this->get_field_name($field_data['lang_name']));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
3
phpBB/styles/prosilver/template/profilefields/url.html
Normal file
3
phpBB/styles/prosilver/template/profilefields/url.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<!-- BEGIN url -->
|
||||||
|
<input type="url" class="inputbox autowidth" name="{url.FIELD_IDENT}" id="{url.FIELD_IDENT}" size="{url.FIELD_LENGTH}" maxlength="{url.FIELD_MAXLEN}" value="{url.FIELD_VALUE}" />
|
||||||
|
<!-- END url -->
|
3
phpBB/styles/subsilver2/template/profilefields/url.html
Normal file
3
phpBB/styles/subsilver2/template/profilefields/url.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<!-- BEGIN url -->
|
||||||
|
<input type="url" class="post" name="{url.FIELD_IDENT}" id="{url.FIELD_IDENT}" size="{url.FIELD_LENGTH}" maxlength="{url.FIELD_MAXLEN}" value="{url.FIELD_VALUE}" />
|
||||||
|
<!-- END url -->
|
Loading…
Add table
Reference in a new issue