aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-01-17 10:12:30 +0100
committerJoas Schilling <nickvergessen@gmx.de>2014-01-17 10:12:30 +0100
commit5e2ffe0d5cc4b7280b0bf51202cdbde4fca1e03b (patch)
treeac82f26a33bb8a912138f912b71f528a86780f7a
parent9653764fb15de3e3126466c98525c121a8a3ac0b (diff)
downloadforums-5e2ffe0d5cc4b7280b0bf51202cdbde4fca1e03b.tar
forums-5e2ffe0d5cc4b7280b0bf51202cdbde4fca1e03b.tar.gz
forums-5e2ffe0d5cc4b7280b0bf51202cdbde4fca1e03b.tar.bz2
forums-5e2ffe0d5cc4b7280b0bf51202cdbde4fca1e03b.tar.xz
forums-5e2ffe0d5cc4b7280b0bf51202cdbde4fca1e03b.zip
[ticket/11201] Add abstract base class with shared methods
PHPBB3-11201
-rw-r--r--phpBB/phpbb/profilefields/type/type_base.php52
-rw-r--r--phpBB/phpbb/profilefields/type/type_bool.php2
-rw-r--r--phpBB/phpbb/profilefields/type/type_date.php23
-rw-r--r--phpBB/phpbb/profilefields/type/type_dropdown.php23
-rw-r--r--phpBB/phpbb/profilefields/type/type_int.php23
-rw-r--r--phpBB/phpbb/profilefields/type/type_string.php2
-rw-r--r--phpBB/phpbb/profilefields/type/type_string_common.php23
-rw-r--r--phpBB/phpbb/profilefields/type/type_text.php2
8 files changed, 59 insertions, 91 deletions
diff --git a/phpBB/phpbb/profilefields/type/type_base.php b/phpBB/phpbb/profilefields/type/type_base.php
new file mode 100644
index 0000000000..00e8d74327
--- /dev/null
+++ b/phpBB/phpbb/profilefields/type/type_base.php
@@ -0,0 +1,52 @@
+<?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;
+
+abstract class type_base implements type_interface
+{
+ /**
+ *
+ */
+ public function __construct(\phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)
+ {
+ $this->request = $request;
+ $this->template = $template;
+ $this->user = $user;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function get_field_ident($field_data)
+ {
+ return 'pf_' . $field_data['field_ident'];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function get_language_options_input($field_data)
+ {
+ $field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true);
+ $field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true);
+ $field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true);
+ $field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => ''), true);
+
+ return $field_data;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function prepare_options_form(&$exclude_options, &$visibility_options)
+ {
+ return $this->request->variable('lang_options', '', true);
+ }
+}
diff --git a/phpBB/phpbb/profilefields/type/type_bool.php b/phpBB/phpbb/profilefields/type/type_bool.php
index f27c5af1ee..4cfd147ea2 100644
--- a/phpBB/phpbb/profilefields/type/type_bool.php
+++ b/phpBB/phpbb/profilefields/type/type_bool.php
@@ -9,7 +9,7 @@
namespace phpbb\profilefields\type;
-class type_bool implements type_interface
+class type_bool extends type_base
{
/**
*
diff --git a/phpBB/phpbb/profilefields/type/type_date.php b/phpBB/phpbb/profilefields/type/type_date.php
index 37b8db2779..a2c9111351 100644
--- a/phpBB/phpbb/profilefields/type/type_date.php
+++ b/phpBB/phpbb/profilefields/type/type_date.php
@@ -9,7 +9,7 @@
namespace phpbb\profilefields\type;
-class type_date implements type_interface
+class type_date extends type_base
{
/**
*
@@ -258,25 +258,4 @@ class type_date implements type_interface
return $options;
}
-
- /**
- * {@inheritDoc}
- */
- public function get_language_options_input($field_data)
- {
- $field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true);
- $field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true);
- $field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true);
- $field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => ''), true);
-
- return $field_data;
- }
-
- /**
- * {@inheritDoc}
- */
- public function prepare_options_form(&$exclude_options, &$visibility_options)
- {
- return $this->request->variable('lang_options', '', true);
- }
}
diff --git a/phpBB/phpbb/profilefields/type/type_dropdown.php b/phpBB/phpbb/profilefields/type/type_dropdown.php
index 25671c88fa..2119443a7a 100644
--- a/phpBB/phpbb/profilefields/type/type_dropdown.php
+++ b/phpBB/phpbb/profilefields/type/type_dropdown.php
@@ -9,7 +9,7 @@
namespace phpbb\profilefields\type;
-class type_dropdown implements type_interface
+class type_dropdown extends type_base
{
/**
*
@@ -179,14 +179,6 @@ class type_dropdown implements type_interface
/**
* {@inheritDoc}
*/
- public function get_field_ident($field_data)
- {
- return 'pf_' . $field_data['field_ident'];
- }
-
- /**
- * {@inheritDoc}
- */
public function get_database_column_type()
{
return 'UINT';
@@ -213,19 +205,6 @@ class type_dropdown implements type_interface
/**
* {@inheritDoc}
*/
- public function get_language_options_input($field_data)
- {
- $field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true);
- $field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true);
- $field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true);
- $field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => ''), true);
-
- return $field_data;
- }
-
- /**
- * {@inheritDoc}
- */
public function prepare_options_form(&$exclude_options, &$visibility_options)
{
$exclude_options[1][] = 'lang_options';
diff --git a/phpBB/phpbb/profilefields/type/type_int.php b/phpBB/phpbb/profilefields/type/type_int.php
index 35f021f0fa..2cd9d3b2c4 100644
--- a/phpBB/phpbb/profilefields/type/type_int.php
+++ b/phpBB/phpbb/profilefields/type/type_int.php
@@ -9,7 +9,7 @@
namespace phpbb\profilefields\type;
-class type_int implements type_interface
+class type_int extends type_base
{
/**
*
@@ -183,25 +183,4 @@ class type_int implements type_interface
return $options;
}
-
- /**
- * {@inheritDoc}
- */
- public function get_language_options_input($field_data)
- {
- $field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true);
- $field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true);
- $field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true);
- $field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => ''), true);
-
- return $field_data;
- }
-
- /**
- * {@inheritDoc}
- */
- public function prepare_options_form(&$exclude_options, &$visibility_options)
- {
- return $this->request->variable('lang_options', '', true);
- }
}
diff --git a/phpBB/phpbb/profilefields/type/type_string.php b/phpBB/phpbb/profilefields/type/type_string.php
index ee2eb8b760..66157ddc20 100644
--- a/phpBB/phpbb/profilefields/type/type_string.php
+++ b/phpBB/phpbb/profilefields/type/type_string.php
@@ -9,7 +9,7 @@
namespace phpbb\profilefields\type;
-class type_string extends type_string_common implements type_interface
+class type_string extends type_string_common
{
/**
*
diff --git a/phpBB/phpbb/profilefields/type/type_string_common.php b/phpBB/phpbb/profilefields/type/type_string_common.php
index a6145e910b..d322099c34 100644
--- a/phpBB/phpbb/profilefields/type/type_string_common.php
+++ b/phpBB/phpbb/profilefields/type/type_string_common.php
@@ -9,7 +9,7 @@
namespace phpbb\profilefields\type;
-abstract class type_string_common
+abstract class type_string_common extends type_base
{
/**
* Return possible validation options
@@ -105,27 +105,6 @@ abstract class type_string_common
/**
* {@inheritDoc}
*/
- public function get_field_ident($field_data)
- {
- return 'pf_' . $field_data['field_ident'];
- }
-
- /**
- * {@inheritDoc}
- */
- public function get_language_options_input($field_data)
- {
- $field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true);
- $field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true);
- $field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true);
- $field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => ''), true);
-
- return $field_data;
- }
-
- /**
- * {@inheritDoc}
- */
public function prepare_options_form(&$exclude_options, &$visibility_options)
{
$exclude_options[1][] = 'lang_default_value';
diff --git a/phpBB/phpbb/profilefields/type/type_text.php b/phpBB/phpbb/profilefields/type/type_text.php
index 7aea982f6f..309ed88818 100644
--- a/phpBB/phpbb/profilefields/type/type_text.php
+++ b/phpBB/phpbb/profilefields/type/type_text.php
@@ -9,7 +9,7 @@
namespace phpbb\profilefields\type;
-class type_text extends type_string_common implements type_interface
+class type_text extends type_string_common
{
/**
*