diff options
-rw-r--r-- | phpBB/includes/acp/acp_groups.php | 3 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_users.php | 3 | ||||
-rw-r--r-- | phpBB/phpbb/avatar/driver/driver.php | 16 | ||||
-rw-r--r-- | phpBB/phpbb/avatar/driver/driver_interface.php | 14 | ||||
-rw-r--r-- | phpBB/phpbb/avatar/manager.php | 16 | ||||
-rw-r--r-- | tests/avatar/manager_test.php | 5 |
6 files changed, 38 insertions, 19 deletions
diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 41366982d2..c9bb4bee14 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -676,9 +676,8 @@ class acp_groups $driver = $phpbb_avatar_manager->get_driver($current_driver); $avatars_enabled = true; - $config_name = $phpbb_avatar_manager->get_driver_config_name($driver); $template->set_filenames(array( - 'avatar' => "acp_avatar_options_{$config_name}.html", + 'avatar' => $driver->get_acp_template_name(), )); if ($driver->prepare_form($request, $template, $user, $avatar_data, $avatar_error)) diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index b0b8fb1e60..32f5ffdc44 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1919,9 +1919,8 @@ class acp_users $driver = $phpbb_avatar_manager->get_driver($current_driver); $avatars_enabled = true; - $config_name = $phpbb_avatar_manager->get_driver_config_name($driver); $template->set_filenames(array( - 'avatar' => "acp_avatar_options_{$config_name}.html", + 'avatar' => $driver->get_acp_template_name(), )); if ($driver->prepare_form($request, $template, $user, $avatar_data, $error)) diff --git a/phpBB/phpbb/avatar/driver/driver.php b/phpBB/phpbb/avatar/driver/driver.php index c849533166..45681f3e59 100644 --- a/phpBB/phpbb/avatar/driver/driver.php +++ b/phpBB/phpbb/avatar/driver/driver.php @@ -125,6 +125,22 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface } /** + * {@inheritdoc} + */ + public function get_config_name() + { + return preg_replace('#^phpbb\\\\avatar\\\\driver\\\\#', '', get_class($this)); + } + + /** + * {@inheritdoc} + */ + public function get_acp_template_name() + { + return 'acp_avatar_options_' . $this->get_config_name() . '.html'; + } + + /** * Sets the name of the driver. * * @param string $name Driver name diff --git a/phpBB/phpbb/avatar/driver/driver_interface.php b/phpBB/phpbb/avatar/driver/driver_interface.php index 835609745a..7d6c2cff8a 100644 --- a/phpBB/phpbb/avatar/driver/driver_interface.php +++ b/phpBB/phpbb/avatar/driver/driver_interface.php @@ -26,6 +26,13 @@ interface driver_interface public function get_name(); /** + * Returns the config name of the driver. To be used in accessing the CONFIG variables. + * + * @return string Config name of driver. + */ + public function get_config_name(); + + /** * Get the avatar url and dimensions * * @param array $row User data or group data that has been cleaned with @@ -110,4 +117,11 @@ interface driver_interface * @return string Avatar driver's template name */ public function get_template_name(); + + /** + * Get the avatar driver's template name (ACP) + * + * @return string Avatar driver's template name + */ + public function get_acp_template_name(); } diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php index 8d83152ed6..26eb17c265 100644 --- a/phpBB/phpbb/avatar/manager.php +++ b/phpBB/phpbb/avatar/manager.php @@ -246,7 +246,7 @@ class manager */ public function is_enabled($driver) { - $config_name = $this->get_driver_config_name($driver); + $config_name = $driver->get_config_name(); return $this->config["allow_avatar_{$config_name}"]; } @@ -260,7 +260,7 @@ class manager */ public function get_avatar_settings($driver) { - $config_name = $this->get_driver_config_name($driver); + $config_name = $driver->get_config_name(); return array( 'allow_avatar_' . $config_name => array('lang' => 'ALLOW_' . strtoupper(str_replace('\\', '_', $config_name)), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), @@ -268,18 +268,6 @@ class manager } /** - * Get the config name of an avatar driver - * - * @param object $driver Avatar driver object - * - * @return string Avatar driver config name - */ - public function get_driver_config_name($driver) - { - return preg_replace('#^phpbb\\\\avatar\\\\driver\\\\#', '', get_class($driver)); - } - - /** * Replace "error" strings with their real, localized form * * @param \phpbb\user phpBB User object diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 9003f72de2..924f1319a2 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -67,10 +67,13 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case ->method('get_name') ->will($this->returnValue('avatar.driver.foobar')); // barfoo driver can't be mocked with constructor arguments - $this->avatar_barfoo = $this->getMock('\phpbb\avatar\driver\barfoo', array('get_name')); + $this->avatar_barfoo = $this->getMock('\phpbb\avatar\driver\barfoo', array('get_name', 'get_config_name')); $this->avatar_barfoo->expects($this->any()) ->method('get_name') ->will($this->returnValue('avatar.driver.barfoo')); + $this->avatar_barfoo->expects($this->any()) + ->method('get_config_name') + ->will($this->returnValue('barfoo')); $avatar_drivers = array($this->avatar_foobar, $this->avatar_barfoo); $files_factory = new \phpbb\files\factory($phpbb_container); |