aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-02-02 16:05:01 +0100
committerJoas Schilling <nickvergessen@gmx.de>2014-02-02 16:13:04 +0100
commitcacd43bfbd547d711bfdd4c424adfef9d20528e7 (patch)
tree3163e60787cceac8501f97a57e2e0adcc0fe65dc /phpBB
parent7bcbdfc1b15e0d014a22c76bb1eab6ccbc3d6dc7 (diff)
downloadforums-cacd43bfbd547d711bfdd4c424adfef9d20528e7.tar
forums-cacd43bfbd547d711bfdd4c424adfef9d20528e7.tar.gz
forums-cacd43bfbd547d711bfdd4c424adfef9d20528e7.tar.bz2
forums-cacd43bfbd547d711bfdd4c424adfef9d20528e7.tar.xz
forums-cacd43bfbd547d711bfdd4c424adfef9d20528e7.zip
[ticket/11201] Remove dependency from types on the manager
PHPBB3-11201
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/config/profilefields.yml21
-rw-r--r--phpBB/phpbb/profilefields/manager.php53
-rw-r--r--phpBB/phpbb/profilefields/type/type_base.php22
-rw-r--r--phpBB/phpbb/profilefields/type/type_bool.php12
-rw-r--r--phpBB/phpbb/profilefields/type/type_date.php12
-rw-r--r--phpBB/phpbb/profilefields/type/type_dropdown.php14
6 files changed, 48 insertions, 86 deletions
diff --git a/phpBB/config/profilefields.yml b/phpBB/config/profilefields.yml
index 8044bc8bc5..b73d4b64c0 100644
--- a/phpBB/config/profilefields.yml
+++ b/phpBB/config/profilefields.yml
@@ -1,20 +1,20 @@
services:
profilefields.manager:
- class: \phpbb\profilefields\manager
+ class: phpbb\profilefields\manager
arguments:
- @auth
- @dbal.conn
- @request
- @template
+ - @profilefields.type_collection
- @user
- %tables.profile_fields%
- %tables.profile_fields_language%
- %tables.profile_fields_data%
calls:
- - [set_type_collection, [@profilefields.type_collection]]
profilefields.lang_helper:
- class: \phpbb\profilefields\lang_helper
+ class: phpbb\profilefields\lang_helper
arguments:
- @dbal.conn
- %tables.profile_fields_options_language%
@@ -27,10 +27,9 @@ services:
- { name: service_collection, tag: profilefield.type }
profilefields.type.bool:
- class: \phpbb\profilefields\type\type_bool
+ class: phpbb\profilefields\type\type_bool
arguments:
- @profilefields.lang_helper
- - @profilefields.manager
- @request
- @template
- @user
@@ -38,9 +37,8 @@ services:
- { name: profilefield.type }
profilefields.type.date:
- class: \phpbb\profilefields\type\type_date
+ class: phpbb\profilefields\type\type_date
arguments:
- - @profilefields.manager
- @request
- @template
- @user
@@ -48,10 +46,9 @@ services:
- { name: profilefield.type }
profilefields.type.dropdown:
- class: \phpbb\profilefields\type\type_dropdown
+ class: phpbb\profilefields\type\type_dropdown
arguments:
- @profilefields.lang_helper
- - @profilefields.manager
- @request
- @template
- @user
@@ -59,7 +56,7 @@ services:
- { name: profilefield.type }
profilefields.type.int:
- class: \phpbb\profilefields\type\type_int
+ class: phpbb\profilefields\type\type_int
arguments:
- @request
- @template
@@ -68,7 +65,7 @@ services:
- { name: profilefield.type }
profilefields.type.string:
- class: \phpbb\profilefields\type\type_string
+ class: phpbb\profilefields\type\type_string
arguments:
- @request
- @template
@@ -77,7 +74,7 @@ services:
- { name: profilefield.type }
profilefields.type.text:
- class: \phpbb\profilefields\type\type_text
+ class: phpbb\profilefields\type\type_text
arguments:
- @request
- @template
diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php
index 9f64e1dcf7..7564c920c9 100644
--- a/phpBB/phpbb/profilefields/manager.php
+++ b/phpBB/phpbb/profilefields/manager.php
@@ -40,6 +40,12 @@ class manager
protected $template;
/**
+ * Service Collection object
+ * @var \phpbb\di\service_collection
+ */
+ protected $type_collection;
+
+ /**
* User object
* @var \phpbb\user
*/
@@ -60,17 +66,19 @@ class manager
* @param \phpbb\db\driver\driver $db Database object
* @param \phpbb\request\request $request Request object
* @param \phpbb\template\template $template Template object
+ * @param \phpbb\di\service_collection $type_collection
* @param \phpbb\user $user User object
* @param string $fields_table
* @param string $fields_language_table
* @param string $fields_data_table
*/
- public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver $db, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, $fields_table, $fields_language_table, $fields_data_table)
+ public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver $db, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\di\service_collection $type_collection, \phpbb\user $user, $fields_table, $fields_language_table, $fields_data_table)
{
$this->auth = $auth;
$this->db = $db;
$this->request = $request;
$this->template = $template;
+ $this->type_collection = $type_collection;
$this->user = $user;
$this->fields_table = $fields_table;
@@ -79,20 +87,6 @@ class manager
}
/**
- * Setter for the type collection
- *
- * We need to set the type collection later,
- * in order to avoid a circular dependency
- *
- * @param \phpbb\di\service_collection $type_collection
- * @return null
- */
- public function set_type_collection(\phpbb\di\service_collection $type_collection)
- {
- $this->type_collection = $type_collection;
- }
-
- /**
* Assign editable fields to template, mode can be profile (for profile change) or register (for registration)
* Called by ucp_profile and ucp_register
*/
@@ -131,8 +125,8 @@ class manager
while ($row = $this->db->sql_fetchrow($result))
{
// Return templated field
- $tpl_snippet = $this->process_field_row('change', $row);
$profile_field = $this->type_collection[$row['field_type']];
+ $tpl_snippet = $profile_field->process_field_row('change', $row);
$this->template->assign_block_vars('profile_fields', array(
'LANG_NAME' => $this->user->lang($row['lang_name']),
@@ -352,33 +346,6 @@ class manager
}
/**
- * Return Templated value/field. Possible values for $mode are:
- * change == user is able to set/enter profile values; preview == just show the value
- */
- public function process_field_row($mode, $profile_row)
- {
- $preview_options = ($mode == 'preview') ? $this->vars['lang_options'] : false;
-
- // set template filename
- $this->template->set_filenames(array(
- 'cp_body' => 'custom_profile_fields.html',
- ));
-
- // empty previously filled blockvars
- foreach ($this->type_collection as $field_key => $field_type)
- {
- $this->template->destroy_block_vars($field_type->get_name_short());
- }
-
- // Assign template variables
- $profile_field = $this->type_collection[$profile_row['field_type']];
- $profile_field->generate_field($profile_row, $preview_options);
-
- // Return templated data
- return $this->template->assign_display('cp_body');
- }
-
- /**
* Build Array for user insertion into custom profile fields table
*/
public function build_insert_sql_array($cp_data)
diff --git a/phpBB/phpbb/profilefields/type/type_base.php b/phpBB/phpbb/profilefields/type/type_base.php
index 6961d208e9..248a89e5ac 100644
--- a/phpBB/phpbb/profilefields/type/type_base.php
+++ b/phpBB/phpbb/profilefields/type/type_base.php
@@ -142,4 +142,26 @@ abstract class type_base implements type_interface
{
return;
}
+
+ /**
+ * Return templated value/field. Possible values for $mode are:
+ * change == user is able to set/enter profile values; preview == just show the value
+ */
+ public function process_field_row($mode, $profile_row)
+ {
+ $preview_options = ($mode == 'preview') ? $profile_row['lang_options'] : false;
+
+ // set template filename
+ $this->template->set_filenames(array(
+ 'cp_' . $this->get_name_short() . '_body' => 'custom_profile_fields.html',
+ ));
+
+ // empty previously filled blockvars
+ $this->template->destroy_block_vars($this->get_name_short());
+
+ // Assign template variables
+ $this->generate_field($profile_row, $preview_options);
+
+ return $this->template->assign_display('cp_' . $this->get_name_short() . '_body');
+ }
}
diff --git a/phpBB/phpbb/profilefields/type/type_bool.php b/phpBB/phpbb/profilefields/type/type_bool.php
index 6b34d6923f..47a5ed4992 100644
--- a/phpBB/phpbb/profilefields/type/type_bool.php
+++ b/phpBB/phpbb/profilefields/type/type_bool.php
@@ -18,12 +18,6 @@ class type_bool extends type_base
protected $lang_helper;
/**
- * Profile fields object
- * @var \phpbb\profilefields\manager
- */
- protected $profilefields;
-
- /**
* Request object
* @var \phpbb\request\request
*/
@@ -45,16 +39,14 @@ class type_bool extends type_base
* Construct
*
* @param \phpbb\profilefields\lang_helper $lang_helper Profile fields language helper
- * @param \phpbb\profilefields\manager $manager Profile fields object
* @param \phpbb\request\request $request Request object
* @param \phpbb\template\template $template Template object
* @param \phpbb\user $user User object
* @param string $language_table Table where the language strings are stored
*/
- public function __construct(\phpbb\profilefields\lang_helper $lang_helper, \phpbb\profilefields\manager $manager, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)
+ public function __construct(\phpbb\profilefields\lang_helper $lang_helper, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)
{
$this->lang_helper = $lang_helper;
- $this->manager = $manager;
$this->request = $request;
$this->template = $template;
$this->user = $user;
@@ -88,7 +80,7 @@ class type_bool extends type_base
$options = array(
0 => array('TITLE' => $this->user->lang['FIELD_TYPE'], 'EXPLAIN' => $this->user->lang['BOOL_TYPE_EXPLAIN'], 'FIELD' => '<label><input type="radio" class="radio" name="field_length" value="1"' . (($field_data['field_length'] == 1) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $this->user->lang['RADIO_BUTTONS'] . '</label><label><input type="radio" class="radio" name="field_length" value="2"' . (($field_data['field_length'] == 2) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $this->user->lang['CHECKBOX'] . '</label>'),
- 1 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => $this->manager->process_field_row('preview', $profile_row)),
+ 1 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row)),
);
return $options;
diff --git a/phpBB/phpbb/profilefields/type/type_date.php b/phpBB/phpbb/profilefields/type/type_date.php
index a71e6fde68..409c2e7be0 100644
--- a/phpBB/phpbb/profilefields/type/type_date.php
+++ b/phpBB/phpbb/profilefields/type/type_date.php
@@ -12,12 +12,6 @@ namespace phpbb\profilefields\type;
class type_date extends type_base
{
/**
- * Profile fields object
- * @var \phpbb\profilefields\manager
- */
- protected $manager;
-
- /**
* Request object
* @var \phpbb\request\request
*/
@@ -38,15 +32,13 @@ class type_date extends type_base
/**
* Construct
*
- * @param \phpbb\profilefields\manager $manager Profile fields object
* @param \phpbb\request\request $request Request object
* @param \phpbb\template\template $template Template object
* @param \phpbb\user $user User object
* @param string $language_table Table where the language strings are stored
*/
- public function __construct(\phpbb\profilefields\manager $manager, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)
+ public function __construct(\phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)
{
- $this->manager = $manager;
$this->request = $request;
$this->template = $template;
$this->user = $user;
@@ -87,7 +79,7 @@ class type_date extends type_base
}
$options = array(
- 0 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => $this->manager->process_field_row('preview', $profile_row)),
+ 0 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row)),
1 => array('TITLE' => $this->user->lang['ALWAYS_TODAY'], 'FIELD' => '<label><input type="radio" class="radio" name="always_now" value="1"' . (($s_checked) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $this->user->lang['YES'] . '</label><label><input type="radio" class="radio" name="always_now" value="0"' . ((!$s_checked) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $this->user->lang['NO'] . '</label>'),
);
diff --git a/phpBB/phpbb/profilefields/type/type_dropdown.php b/phpBB/phpbb/profilefields/type/type_dropdown.php
index aee19fda30..9a6545249d 100644
--- a/phpBB/phpbb/profilefields/type/type_dropdown.php
+++ b/phpBB/phpbb/profilefields/type/type_dropdown.php
@@ -18,12 +18,6 @@ class type_dropdown extends type_base
protected $lang_helper;
/**
- * Profile fields object
- * @var \phpbb\profilefields\manager
- */
- protected $manager;
-
- /**
* Request object
* @var \phpbb\request\request
*/
@@ -45,16 +39,14 @@ class type_dropdown extends type_base
* Construct
*
* @param \phpbb\profilefields\lang_helper $lang_helper Profile fields language helper
- * @param \phpbb\profilefields\manager $manager Profile fields object
* @param \phpbb\request\request $request Request object
* @param \phpbb\template\template $template Template object
* @param \phpbb\user $user User object
* @param string $language_table Table where the language strings are stored
*/
- public function __construct(\phpbb\profilefields\lang_helper $lang_helper, \phpbb\profilefields\manager $manager, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)
+ public function __construct(\phpbb\profilefields\lang_helper $lang_helper, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)
{
$this->lang_helper = $lang_helper;
- $this->manager = $manager;
$this->request = $request;
$this->template = $template;
$this->user = $user;
@@ -91,8 +83,8 @@ class type_dropdown extends type_base
$profile_row[1]['field_default_value'] = $field_data['field_novalue'];
$options = array(
- 0 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => $this->manager->process_field_row('preview', $profile_row[0])),
- 1 => array('TITLE' => $this->user->lang['NO_VALUE_OPTION'], 'EXPLAIN' => $this->user->lang['NO_VALUE_OPTION_EXPLAIN'], 'FIELD' => $this->manager->process_field_row('preview', $profile_row[1])),
+ 0 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row[0])),
+ 1 => array('TITLE' => $this->user->lang['NO_VALUE_OPTION'], 'EXPLAIN' => $this->user->lang['NO_VALUE_OPTION_EXPLAIN'], 'FIELD' => $this->process_field_row('preview', $profile_row[1])),
);
return $options;