From fe1888e6c0b6d05e506b0cdc50ad427d1da8787f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 22 Mar 2013 13:45:56 +0100 Subject: [PATCH] [feature/acp] Convert ACP module to new extension system B3P-131 --- .../acp_portal.php => acp/portal_info.php} | 4 +- .../acp_portal.php => acp/portal_module.php} | 50 ++++++++++--------- root/controller/main.php | 12 ++--- .../includes/functions_version_check.php | 11 ++-- 4 files changed, 41 insertions(+), 36 deletions(-) rename root/{includes/acp/info/acp_portal.php => acp/portal_info.php} (87%) rename root/{includes/acp/acp_portal.php => acp/portal_module.php} (93%) diff --git a/root/includes/acp/info/acp_portal.php b/root/acp/portal_info.php similarity index 87% rename from root/includes/acp/info/acp_portal.php rename to root/acp/portal_info.php index d743f8ab..fd04a0e2 100644 --- a/root/includes/acp/info/acp_portal.php +++ b/root/acp/portal_info.php @@ -15,12 +15,12 @@ if (!defined('IN_PHPBB')) /** * @package module_install */ -class acp_portal_info +class phpbb_ext_board3_portal_acp_portal_info { public function module() { return array( - 'filename' => 'acp_portal', + 'filename' => 'phpbb_ext_board3_portal_acp_portal_module', 'title' => 'ACP_PORTAL', 'version' => '2.0.0b2', 'modes' => array( diff --git a/root/includes/acp/acp_portal.php b/root/acp/portal_module.php similarity index 93% rename from root/includes/acp/acp_portal.php rename to root/acp/portal_module.php index 0bce16fd..8eb6f518 100644 --- a/root/includes/acp/acp_portal.php +++ b/root/acp/portal_module.php @@ -15,21 +15,24 @@ if (!defined('IN_PHPBB')) exit; } -class acp_portal +class phpbb_ext_board3_portal_acp_portal_module { public $u_action; public $new_config = array(); protected $c_class; protected $db, $user, $cache, $template, $display_vars, $config, $phpbb_root_path, $portal_root_path, $phpbb_admin_path, $phpEx; + protected $root_path; public function __construct() { global $db, $user, $cache, $template; global $config, $phpbb_root_path, $portal_root_path, $phpbb_admin_path, $phpEx; - $user->add_lang('mods/portal'); + $user->add_lang_ext('board3/portal', 'mods/portal'); - include($phpbb_root_path . 'portal/includes/constants.' . $phpEx); + $this->root_path = $phpbb_root_path . 'ext/board3/portal/'; + + include($this->root_path . 'portal/includes/constants.' . $phpEx); $portal_root_path = PORTAL_ROOT_PATH; $this->db = $db; @@ -39,21 +42,22 @@ class acp_portal $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; $this->phpbb_admin_path = $phpbb_admin_path; + $this->portal_root_path = $this->root_path . 'portal/'; $this->php_ex = $phpEx; if (!function_exists('column_string_const')) { - include($phpbb_root_path . $portal_root_path . 'includes/functions_modules.' . $this->php_ex); + include($this->portal_root_path . 'includes/functions_modules.' . $this->php_ex); } if (!function_exists('mod_version_check')) { - include($phpbb_root_path . $portal_root_path . 'includes/functions_version_check.' . $this->php_ex); + include($this->portal_root_path . 'includes/functions_version_check.' . $this->php_ex); } if(!function_exists('obtain_portal_config')) { - include($phpbb_root_path . $portal_root_path . 'includes/functions.' . $this->php_ex); + include($this->portal_root_path . 'includes/functions.' . $this->php_ex); } } @@ -105,7 +109,7 @@ class acp_portal $class = 'portal_' . $module_data['module_classname'] . '_module'; if (!class_exists($class)) { - include($this->phpbb_root_path . 'portal/modules/portal_' . $module_data['module_classname'] . '.' . $this->php_ex); + include($this->root_path . 'portal/modules/portal_' . $module_data['module_classname'] . '.' . $this->php_ex); } if (!class_exists($class)) { @@ -115,7 +119,7 @@ class acp_portal $this->c_class = new $class(); if ($this->c_class->language) { - $this->user->add_lang('mods/portal/' . $this->c_class->language); + $this->user->add_lang_ext('board3/portal', 'mods/portal/' . $this->c_class->language); } $module_name = $this->user->lang[$this->c_class->name]; $display_vars = $this->c_class->get_template_acp($module_id); @@ -124,7 +128,7 @@ class acp_portal 'MODULE_IMAGE' => $module_data['module_image_src'], 'MODULE_IMAGE_WIDTH' => $module_data['module_image_width'], 'MODULE_IMAGE_HEIGHT' => $module_data['module_image_height'], - 'MODULE_IMAGE_SRC' => ($module_data['module_image_src']) ? $this->phpbb_root_path . 'styles/' . $this->user->theme['theme_path'] . '/theme/images/portal/' . $module_data['module_image_src'] : '', + 'MODULE_IMAGE_SRC' => ($module_data['module_image_src']) ? $this->root_path . 'styles/' . $this->user->theme['theme_path'] . '/theme/images/portal/' . $module_data['module_image_src'] : '', 'MODULE_ENABLED' => ($module_data['module_status']) ? true : false, 'MODULE_SHOW_IMAGE' => (in_array(column_num_string($module_data['module_column']), array('center', 'top', 'bottom'))) ? false : true, )); @@ -155,7 +159,7 @@ class acp_portal else { // only show the mod version check if we are on the General Settings page - mod_version_check(); + mod_version_check($this->phpbb_root_path, $this->root_path); } $this->new_config = $this->config; @@ -396,7 +400,7 @@ class acp_portal if ($add_column) { $submit = (isset($_POST['submit'])) ? true : false; - $directory = $this->phpbb_root_path . 'portal/modules/'; + $directory = $this->root_path . 'portal/modules/'; if ($submit) { @@ -588,7 +592,7 @@ class acp_portal } else { - $directory = $this->phpbb_root_path . 'portal/modules/'; + $directory = $this->root_path . 'portal/modules/'; $portal_modules = obtain_portal_modules(); @@ -607,7 +611,7 @@ class acp_portal $this->c_class = new $class(); if ($this->c_class->language) { - $this->user->add_lang('mods/portal/' . $this->c_class->language); + $this->user->add_lang_ext('board3/portal', 'mods/portal/' . $this->c_class->language); } $template_column = column_num_string($row['module_column']); @@ -680,7 +684,7 @@ class acp_portal $this->template->assign_block_vars('modules_' . $template_column, array( 'MODULE_NAME' => (isset($this->user->lang[$row['module_name']])) ? $this->user->lang[$row['module_name']] : $row['module_name'], - 'MODULE_IMAGE' => ($row['module_image_src']) ? '' . $row['module_name'] . '' : '', + 'MODULE_IMAGE' => ($row['module_image_src']) ? '' . $row['module_name'] . '' : '', 'MODULE_ENABLED' => ($row['module_status']) ? true : false, 'U_DELETE' => $this->u_action . '&module_id=' . $row['module_id'] . '&module_classname=' . $row['module_classname'] . '&action=delete', @@ -693,10 +697,10 @@ class acp_portal } $this->template->assign_vars(array( - 'ICON_MOVE_LEFT' => '' . $this->user->lang['MOVE_LEFT'] . '', - 'ICON_MOVE_LEFT_DISABLED' => '' . $this->user->lang['MOVE_LEFT'] . '', - 'ICON_MOVE_RIGHT' => '' . $this->user->lang['MOVE_RIGHT'] . '', - 'ICON_MOVE_RIGHT_DISABLED' => '' . $this->user->lang['MOVE_RIGHT'] . '', + 'ICON_MOVE_LEFT' => '' . $this->user->lang['MOVE_LEFT'] . '', + 'ICON_MOVE_LEFT_DISABLED' => '' . $this->user->lang['MOVE_LEFT'] . '', + 'ICON_MOVE_RIGHT' => '' . $this->user->lang['MOVE_RIGHT'] . '', + 'ICON_MOVE_RIGHT_DISABLED' => '' . $this->user->lang['MOVE_RIGHT'] . '', )); } @@ -711,9 +715,9 @@ class acp_portal { trigger_error($this->user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } - include($this->phpbb_root_path . 'portal/includes/functions_upload.' . $this->php_ex); + include($this->root_path . 'portal/includes/functions_upload.' . $this->php_ex); // Default upload path is portal/upload/ - $upload_path = $this->phpbb_root_path . 'portal/upload/'; + $upload_path = $this->root_path . 'portal/upload/'; $portal_upload = new portal_upload($upload_path, $this->u_action); @@ -902,7 +906,7 @@ class acp_portal $class = 'portal_' . $module_data['module_classname'] . '_module'; if (!class_exists($class)) { - include($this->phpbb_root_path . 'portal/modules/portal_' . $module_data['module_classname'] . '.' . $this->php_ex); + include($this->root_path . 'portal/modules/portal_' . $module_data['module_classname'] . '.' . $this->php_ex); } if (!class_exists($class)) { @@ -1014,7 +1018,7 @@ class acp_portal $class = 'portal_' . $module_data['module_classname'] . '_module'; if (!class_exists($class)) { - include($this->phpbb_root_path . 'portal/modules/portal_' . $module_data['module_classname'] . '.' . $this->php_ex); + include($this->root_path . 'portal/modules/portal_' . $module_data['module_classname'] . '.' . $this->php_ex); } if (!class_exists($class)) { @@ -1126,7 +1130,7 @@ class acp_portal $module_data = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); - $directory = $this->phpbb_root_path . 'portal/modules/'; + $directory = $this->root_path . 'portal/modules/'; if ($module_data !== false) { diff --git a/root/controller/main.php b/root/controller/main.php index d521f3bf..2a2c3213 100644 --- a/root/controller/main.php +++ b/root/controller/main.php @@ -91,7 +91,7 @@ class phpbb_ext_board3_portal_controller_main } /** - * Extension front handler method. This is called automatically when your extension is accessed + * Extension front handler method. This is called automatically when your extension is accessed * through index.php?ext=example/foobar * @return null */ @@ -105,7 +105,7 @@ class phpbb_ext_board3_portal_controller_main // 1) which extension language folder we're using (it's not smart enough to use its own automatically) // 2) what language file to use $this->user->add_lang_ext('board3/portal', 'mods/portal'); - + /** * get initial data */ @@ -134,7 +134,7 @@ class phpbb_ext_board3_portal_controller_main { continue; } - + $class_name = 'portal_' . $row['module_classname'] . '_module'; if (!class_exists($class_name)) { @@ -146,8 +146,8 @@ class phpbb_ext_board3_portal_controller_main } $module = new $class_name(); - - /** + + /** * Check for permissions before loading anything * the default group of a user always defines his/her permission (KISS) */ @@ -156,7 +156,7 @@ class phpbb_ext_board3_portal_controller_main { continue; } - + if ($module->language) { $this->user->add_lang_ext('board3/portal', 'mods/portal/' . $module->language); diff --git a/root/portal/includes/functions_version_check.php b/root/portal/includes/functions_version_check.php index aa7e7f4e..b8abd7b8 100644 --- a/root/portal/includes/functions_version_check.php +++ b/root/portal/includes/functions_version_check.php @@ -19,23 +19,24 @@ if (!defined('IN_PHPBB')) /** * A copy of Handyman` s MOD version check, to view it on the gallery overview */ -function mod_version_check($return_version = false) +function mod_version_check($phpbb_root_path, $root_path, $return_version = false) { global $user, $template; - global $phpbb_admin_path, $phpEx; + global $phpEx; if (!function_exists('get_remote_file')) { - global $phpbb_root_path; include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); } // load version files $class_functions = array(); - include($phpbb_admin_path . 'mods/board3_portal_check_version.' . $phpEx); + include($root_path . 'adm/mods/board3_portal_check_version.' . $phpEx); $class_name = 'board3_portal_check_version'; - $var = call_user_func(array($class_name, 'version')); + $version_check = new $class_name(); + + $var = call_user_func(array($version_check, 'version')); // Get current and latest version $errstr = '';