From 2203614991dc6e3f7177b4d02acbb7c71e39e631 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Jul 2014 23:56:33 +0200 Subject: [PATCH] [ticket/289] Add method for assigning module template variables --- controller/main.php | 59 +++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/controller/main.php b/controller/main.php index 18f54ff9..d4e9bb9d 100644 --- a/controller/main.php +++ b/controller/main.php @@ -212,29 +212,7 @@ class main } // Custom Blocks that have been defined in the ACP will return an array instead of just the name of the template file - if (is_array($template_module)) - { - $this->template->assign_block_vars('modules_' . column_num_string($row['module_column']), array( - 'TEMPLATE_FILE' => 'portal/modules/' . $template_module['template'], - 'IMAGE_SRC' => $this->path_helper->get_web_root_path() . $this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/' . $template_module['image_src'], - 'TITLE' => $template_module['title'], - 'CODE' => $template_module['code'], - 'MODULE_ID' => $row['module_id'], - 'IMAGE_WIDTH' => $row['module_image_width'], - 'IMAGE_HEIGHT' => $row['module_image_height'], - )); - } - else - { - $this->template->assign_block_vars('modules_' . column_num_string($row['module_column']), array( - 'TEMPLATE_FILE' => 'portal/modules/' . $template_module, - 'IMAGE_SRC' => $this->path_helper->get_web_root_path() . $this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/' . $row['module_image_src'], - 'IMAGE_WIDTH' => $row['module_image_width'], - 'IMAGE_HEIGHT' => $row['module_image_height'], - 'MODULE_ID' => $row['module_id'], - 'TITLE' => (isset($this->user->lang[$row['module_name']])) ? $this->user->lang[$row['module_name']] : utf8_normalize_nfc($row['module_name']), - )); - } + $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') @@ -310,6 +288,41 @@ class main )); } + /** + * Assign module's template vars + * + * @param array $row Database row of module + * @param mixed $template_module Template data as returned by module + * + * @return null + */ + protected function assign_module_vars($row, $template_module) + { + if (is_array($template_module)) + { + $this->template->assign_block_vars('modules_' . column_num_string($row['module_column']), array( + 'TEMPLATE_FILE' => 'portal/modules/' . $template_module['template'], + 'IMAGE_SRC' => $this->path_helper->get_web_root_path() . $this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/' . $template_module['image_src'], + 'TITLE' => $template_module['title'], + 'CODE' => $template_module['code'], + 'MODULE_ID' => $row['module_id'], + 'IMAGE_WIDTH' => $row['module_image_width'], + 'IMAGE_HEIGHT' => $row['module_image_height'], + )); + } + else + { + $this->template->assign_block_vars('modules_' . column_num_string($row['module_column']), array( + 'TEMPLATE_FILE' => 'portal/modules/' . $template_module, + 'IMAGE_SRC' => $this->path_helper->get_web_root_path() . $this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/' . $row['module_image_src'], + 'IMAGE_WIDTH' => $row['module_image_width'], + 'IMAGE_HEIGHT' => $row['module_image_height'], + 'MODULE_ID' => $row['module_id'], + 'TITLE' => (isset($this->user->lang[$row['module_name']])) ? $this->user->lang[$row['module_name']] : utf8_normalize_nfc($row['module_name']), + )); + } + } + /** * Check module count and related config setting *