From e8d32dd018868c079555f504a51a847a02b45a3f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 25 Jul 2014 00:18:34 +0200 Subject: [PATCH] [ticket/289] Add methods for loading language files and displaying online list --- controller/main.php | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/controller/main.php b/controller/main.php index d4e9bb9d..28cb9370 100644 --- a/controller/main.php +++ b/controller/main.php @@ -177,10 +177,9 @@ class main continue; } - if ($language_file = $module->get_language()) - { - $this->user->add_lang_ext('board3/portal', 'modules/' . $language_file); - } + // Load module language file + $this->load_module_language($module); + if ($row['module_column'] == column_string_num('left') && $this->config['board3_left_column']) { $template_module = $module->get_template_side($row['module_id']); @@ -215,10 +214,7 @@ class main $this->assign_module_vars($row, $template_module); // Check if we need to show the online list - if ($row['module_classname'] === '\board3\portal\modules\whois_online') - { - $display_online = true; - } + $display_online = $this->check_online_list($row['module_classname'], $display_online); unset($template_module); } @@ -267,6 +263,30 @@ class main } } + /** + * Return true if online list should be displayed + * + * @return mixed True if online list should be display, current value + * if unsure + */ + protected function check_online_list($module_classname, $display_online) + { + return ($module_classname === '\board3\portal\modules\whois_online') ? true : $display_online; + } + + /** + * Load language file of module + * + * @param object $module Module of which language file should be loaded + */ + protected function load_module_language($module) + { + if ($language_file = $module->get_language()) + { + $this->user->add_lang_ext('board3/portal', 'modules/' . $language_file); + } + } + /** * Assign template vars for portal *