From 3cebb18ce8e8e97a6b95b32dbab5740489c840ea Mon Sep 17 00:00:00 2001 From: Shitiz Garg Date: Wed, 18 Jun 2014 19:34:14 +0530 Subject: [PATCH] [ticket/12730] Add Google+ profile field type Google+ has a "+" before a custom URL but doesn't for those which are using their integer ID. To cover that we need to have an extra profile field PHPBB3-12730 --- phpBB/config/profilefields.yml | 9 +++ .../profilefields/type/type_googleplus.php | 56 +++++++++++++++++++ .../template/profilefields/googleplus.html | 3 + .../template/profilefields/googleplus.html | 3 + 4 files changed, 71 insertions(+) create mode 100644 phpBB/phpbb/profilefields/type/type_googleplus.php create mode 100644 phpBB/styles/prosilver/template/profilefields/googleplus.html create mode 100644 phpBB/styles/subsilver2/template/profilefields/googleplus.html diff --git a/phpBB/config/profilefields.yml b/phpBB/config/profilefields.yml index 00f025e141..ce2a84b12b 100644 --- a/phpBB/config/profilefields.yml +++ b/phpBB/config/profilefields.yml @@ -55,6 +55,15 @@ services: tags: - { name: profilefield.type } + profilefields.type.googleplus: + class: phpbb\profilefields\type\type_googleplus + arguments: + - @request + - @template + - @user + tags: + - { name: profilefield.type } + profilefields.type.int: class: phpbb\profilefields\type\type_int arguments: diff --git a/phpBB/phpbb/profilefields/type/type_googleplus.php b/phpBB/phpbb/profilefields/type/type_googleplus.php new file mode 100644 index 0000000000..1bdb04e859 --- /dev/null +++ b/phpBB/phpbb/profilefields/type/type_googleplus.php @@ -0,0 +1,56 @@ + + * @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\profilefields\type; + +class type_googleplus extends type_string +{ + /** + * {@inheritDoc} + */ + public function get_name_short() + { + return 'googleplus'; + } + + /** + * {@inheritDoc} + */ + public function get_default_option_values() + { + return array( + 'field_length' => 20, + 'field_minlen' => 3, + 'field_maxlen' => '', + 'field_validation' => '[\w]+', + 'field_novalue' => '', + 'field_default_value' => '', + ); + } + + /** + * {@inheritDoc} + */ + public function get_profile_contact_value($field_value, $field_data) + { + if (!$field_value && !$field_data['field_show_novalue']) + { + return null; + } + + if (!is_numeric($field_value)) + $field_value = '+' . $field_value; + + return $field_value; + } +} diff --git a/phpBB/styles/prosilver/template/profilefields/googleplus.html b/phpBB/styles/prosilver/template/profilefields/googleplus.html new file mode 100644 index 0000000000..cf457d39ad --- /dev/null +++ b/phpBB/styles/prosilver/template/profilefields/googleplus.html @@ -0,0 +1,3 @@ + + + diff --git a/phpBB/styles/subsilver2/template/profilefields/googleplus.html b/phpBB/styles/subsilver2/template/profilefields/googleplus.html new file mode 100644 index 0000000000..5a98562e2a --- /dev/null +++ b/phpBB/styles/subsilver2/template/profilefields/googleplus.html @@ -0,0 +1,3 @@ + + +