From 333ee274b5fb6c587e101a755d862188d6422dab Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 26 Nov 2014 14:49:57 +0100 Subject: [PATCH 1/3] [ticket/334] Try to resolve functions for portal modules in acp B3P-334 --- acp/portal_module.php | 16 ++++++++++++++-- language/de/portal_acp.php | 1 + language/en/portal_acp.php | 1 + language/nl/portal_acp.php | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/acp/portal_module.php b/acp/portal_module.php index 25bbc296..c55f2a8c 100644 --- a/acp/portal_module.php +++ b/acp/portal_module.php @@ -184,8 +184,20 @@ class portal_module { if (!is_array($null['submit'])) { - $func = array($this->c_class, $null['submit']); - $args = ($module_id != 0) ? array($config_name, $module_id) : $config_name; + if (method_exists($this->c_class, $null['submit'])) + { + $func = array($this->c_class, $null['submit']); + $args = ($module_id != 0) ? array($config_name, $module_id) : $config_name; + } + else if (function_exists($null['submit'])) + { + $func = $null['submit']; + $args = ($module_id != 0) ? array($cfg_array[$config_name], $config_name, $module_id) : $config_name; + } + else + { + throw new \RuntimeException($this->user->lang('UNKNOWN_MODULE_METHOD', $module_data['module_classname'])); + } } else { diff --git a/language/de/portal_acp.php b/language/de/portal_acp.php index 02ff40dc..c290a1b5 100644 --- a/language/de/portal_acp.php +++ b/language/de/portal_acp.php @@ -74,6 +74,7 @@ $lang = array_merge($lang, array( 'MODULE_STATUS' => 'Aktiviere Modul', 'MODULE_ADD_ONCE' => 'Diese Modul kann nur ein Mal hinzugefügt werden.', 'MODULE_IMAGE_ERROR' => 'Während dem Prüfen des Modul Bildes sind ein oder mehrere Fehler aufgetreten:', + 'UNKNOWN_MODULE_METHOD' => 'Die Modul Methode des %1$s Moduls konnte nicht gefunden werden.', // general 'ACP_PORTAL_CONFIG_INFO' => 'Allgemeine Einstellungen', diff --git a/language/en/portal_acp.php b/language/en/portal_acp.php index 97d28a71..b2fd1dfc 100644 --- a/language/en/portal_acp.php +++ b/language/en/portal_acp.php @@ -73,6 +73,7 @@ $lang = array_merge($lang, array( 'MODULE_STATUS' => 'Enable module', 'MODULE_ADD_ONCE' => 'This module can only be added once.', 'MODULE_IMAGE_ERROR' => 'There was an error while checking for the module image:', + 'UNKNOWN_MODULE_METHOD' => 'The %1$s module’s module method couldn’t be resolved.', // general 'ACP_PORTAL_CONFIG_INFO' => 'General settings', diff --git a/language/nl/portal_acp.php b/language/nl/portal_acp.php index a194f770..2698fe0e 100644 --- a/language/nl/portal_acp.php +++ b/language/nl/portal_acp.php @@ -68,6 +68,7 @@ $lang = array_merge($lang, array( 'MODULE_STATUS' => 'Module inschakelen', 'MODULE_ADD_ONCE' => 'Deze module kan maar één keer worden toegevoegd.', 'MODULE_IMAGE_ERROR' => 'Er is een fout opgetreden tijdens het controleren van de module afbeelding:', + 'UNKNOWN_MODULE_METHOD' => 'De methode van de %1$s module kan niet worden gevonden.', // general 'ACP_PORTAL_CONFIG_INFO' => 'Algemene instellingen', 'ACP_PORTAL_GENERAL_TITLE' => 'Portaal beheer', From 420d389c279e0ef7d925b41e92a65fe37795f4af Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 26 Nov 2014 14:53:29 +0100 Subject: [PATCH 2/3] [ticket/334] Allow specifying flash clock instead of using the standard clock B3P-334 --- config/modules.yml | 3 ++ modules/clock.php | 45 ++++++++++++++++++- .../template/portal/modules/clock_side.html | 10 +++++ .../template/portal/modules/clock_side.html | 12 +++++ tests/unit/acp/move_module_test.php | 2 +- 5 files changed, 70 insertions(+), 2 deletions(-) diff --git a/config/modules.yml b/config/modules.yml index 4b219a24..77e11098 100644 --- a/config/modules.yml +++ b/config/modules.yml @@ -59,6 +59,9 @@ services: board3.portal.module.clock: class: board3\portal\modules\clock + arguments: + - @config + - @template tags: - { name: board3.portal.module } diff --git a/modules/clock.php b/modules/clock.php index a0a74c3e..aff0be3b 100644 --- a/modules/clock.php +++ b/modules/clock.php @@ -41,11 +41,33 @@ class clock extends module_base */ public $language = 'portal_clock_module'; + /** @var \phpbb\config\config */ + protected $config; + + /** @var \phpbb\template\template */ + protected $template; + + /** + * Constructor for clock module + * + * @param \phpbb\config\config $config phpBB config + * @param \phpbb\template\template $template phpBB template + */ + public function __construct($config, $template) + { + $this->config = $config; + $this->template = $template; + } + /** * {@inheritdoc} */ public function get_template_side($module_id) { + if (isset($this->config['board3_clock_src_' . $module_id]) && !empty($this->config['board3_clock_src_' . $module_id])) + { + $this->template->assign_var('B3P_CLOCK_SRC', $this->config['board3_clock_src_' . $module_id]); + } return 'clock_side.html'; } @@ -56,7 +78,28 @@ class clock extends module_base { return array( 'title' => 'ACP_PORTAL_CLOCK_SETTINGS', - 'vars' => array(), + 'vars' => array( + 'legend1' => 'ACP_PORTAL_CLOCK_SETTINGS', + 'board3_clock_src_' . $module_id => array('lang' => 'ACP_PORTAL_CLOCK_SRC', 'validate' => 'string', 'type' => 'text:50:200', 'explain' => true, 'submit_type' => 'custom', 'submit' => 'check_file_src'), + ), ); } + + /** + * {@inheritdoc} + */ + public function install($module_id) + { + $this->config->set('board3_clock_src_' . $module_id, ''); + return true; + } + + /** + * {@inheritdoc} + */ + public function uninstall($module_id, $db) + { + $this->config->delete('board3_clock_src_' . $module_id); + return true; + } } diff --git a/styles/prosilver/template/portal/modules/clock_side.html b/styles/prosilver/template/portal/modules/clock_side.html index db28ca6a..8ffa536e 100644 --- a/styles/prosilver/template/portal/modules/clock_side.html +++ b/styles/prosilver/template/portal/modules/clock_side.html @@ -1,4 +1,5 @@ {$LR_BLOCK_H_L} {$TITLE}{$LR_BLOCK_H_R} +
@@ -29,4 +30,13 @@
+ +
+
+ + + + +
+ {$LR_BLOCK_F_L}{$LR_BLOCK_F_R} diff --git a/styles/subsilver2/template/portal/modules/clock_side.html b/styles/subsilver2/template/portal/modules/clock_side.html index 3f6d3834..f750757a 100644 --- a/styles/subsilver2/template/portal/modules/clock_side.html +++ b/styles/subsilver2/template/portal/modules/clock_side.html @@ -1,6 +1,7 @@ {$LR_BLOCK_H_L} {$TITLE}{$LR_BLOCK_H_R} + + + +
@@ -29,8 +30,19 @@
+
+ + + + +
+ + {$LR_BLOCK_F_L}{$LR_BLOCK_F_R} diff --git a/tests/unit/acp/move_module_test.php b/tests/unit/acp/move_module_test.php index d2f1c2e4..b8e13d31 100644 --- a/tests/unit/acp/move_module_test.php +++ b/tests/unit/acp/move_module_test.php @@ -34,7 +34,7 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data $config = new \phpbb\config\config(array()); $phpbb_container->set('board3.portal.module_collection', array( - new \board3\portal\modules\clock(), + new \board3\portal\modules\clock($config, $template), new \board3\portal\modules\birthday_list($config, $template, $this->db, $user), new \board3\portal\modules\welcome($config, new \phpbb_mock_request, $this->db, $user, $phpbb_root_path, $phpEx), new \board3\portal\modules\donation($config, $template, $user), From 876e0e95de5265fdc9c5e9345ce799dbd261467b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 26 Nov 2014 14:53:56 +0100 Subject: [PATCH 3/3] [ticket/334] Add clock setting in v210_rc1 migration B3P-334 --- migrations/v210_rc1.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/migrations/v210_rc1.php b/migrations/v210_rc1.php index 52c41f82..86040193 100644 --- a/migrations/v210_rc1.php +++ b/migrations/v210_rc1.php @@ -21,6 +21,23 @@ class v210_rc1 extends \phpbb\db\migration\migration return array( array('config.remove', array('board3_phpbb_menu')), array('config.update', array('board3_portal_version', '2.1.0-rc1')), + array('custom', array(array($this, 'add_clock_setting'))), ); } + + /** + * Adds clock settings to already installed clock modules + */ + public function add_clock_setting() + { + $sql = 'SELECT module_id + FROM ' . $this->table_prefix . "portal_modules + WHERE module_classname = '\\\board3\\\portal\\\modules\\\clock'"; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $this->config->set('board3_clock_src_' . $row['module_id'], ''); + } + $this->db->sql_freeresult($result); + } }