From af855daa5214d87b5d68c52a952e698e9a339005 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 27 Aug 2009 16:57:19 +0000 Subject: [PATCH] 2009-08-27 Miguel de Dios * index.php: add comments for more readable. * include/functions_extensions.php, extensions/update_manager.php, extensions/hello, extensions/hello/icon.png, extensions/hello.php, operation/menu.php, godmode/menu.php: change the mecanic to add extensions into menu, now you can add extension with icon and into the submenu in any position of submenu. Change the example "hello" for to show as be. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1885 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 ++++++++ pandora_console/extensions/hello.php | 14 ++++++++++- pandora_console/extensions/hello/icon.png | Bin 0 -> 808 bytes pandora_console/extensions/update_manager.php | 2 +- pandora_console/godmode/menu.php | 11 +++++++++ .../include/functions_extensions.php | 23 ++++++++++++------ pandora_console/index.php | 3 +++ pandora_console/operation/menu.php | 22 +++++++++++++++++ 8 files changed, 76 insertions(+), 9 deletions(-) create mode 100755 pandora_console/extensions/hello/icon.png diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a00e79cb5f..b42aa245e8 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2009-08-27 Miguel de Dios + + * index.php: add comments for more readable. + * include/functions_extensions.php, extensions/update_manager.php, + extensions/hello, extensions/hello/icon.png, extensions/hello.php, + operation/menu.php, godmode/menu.php: change the mecanic to add extensions + into menu, now you can add extension with icon and into the submenu in any + position of submenu. Change the example "hello" for to show as be. + + 2009-08-26 Miguel de Dios * operation/extensions.php, godmode/extensions.php: fix hidden bug that show diff --git a/pandora_console/extensions/hello.php b/pandora_console/extensions/hello.php index 3aa70eb3cb..61c183d733 100644 --- a/pandora_console/extensions/hello.php +++ b/pandora_console/extensions/hello.php @@ -20,9 +20,21 @@ function hello_extension_main () { echo "This is a sample of minimal extension"; } +function test() { + echo "

TEST

"; +} + /* This adds a option in the operation menu */ -add_operation_menu_option ('Hello plugin!'); +//add_operation_menu_option ('Hello plugin!'); +add_godmode_menu_option (__('Hello plugin'), 'PM','gagente',"hello/icon.png"); +/** + * 'estado' is a option of menu you can see in 'operation/menu.php' + */ +add_operation_menu_option(__('Hello plugin'), 'estado',"hello/icon.png"); + /* This sets the function to be called when the extension is selected in the operation menu */ add_extension_main_function ('hello_extension_main'); + +add_extension_godmode_function('prueba'); ?> diff --git a/pandora_console/extensions/hello/icon.png b/pandora_console/extensions/hello/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..a7b479f249303f246211f01cbb4627227de01e78 GIT binary patch literal 808 zcmV+@1K0eCP)Px#24YJ`L;wH)0002_L%V+f000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iXM< z4G$GFM|5)l001>~MObu0Z*6U5Zgc=BV<{jqFfcSAN?~htVjxp=Wod3@ataDVa%Ew3 zWn>_CX>@2HRA^-&M@dakklBlG0007KNklvl;qCjFCWN;${7G(rlsQ7Pak>(^q4l3i! z)A5`4?ro(RPKCeKy>QOqa=3&d#O?S)244qo8~`b(6$KURa5{SNFJgA=;As6-I$6e3WF zprD{%>kr;nZ=QmL4cYJ~%aSU*8D``6DT-uUAX!mhI8;sGWgeG|lt@}!Z_Jy*78LS( zl^p@#>;+U%#TKX7maLevCK*+y;Ej0`;)rmHb>UqhO~b5_)A6s0G{+cLv39xQcEcunrJj4KUUswc56&#<`R6^3jmgwu9LqplCVxnJSs4TEO_#h_$0000 0) { + $menu[$extmenu['fatherId']]['sub'][$extmenu['sec2']]["text"] = __($extmenu['name']); + $menu[$extmenu['fatherId']]['sub'][$extmenu['sec2']]["refr"] = 60; + $menu[$extmenu['fatherId']]['sub'][$extmenu['sec2']]["icon"] = $extmenu['icon']; + $menu[$extmenu['fatherId']]['sub'][$extmenu['sec2']]["sec"] = 'gextensions'; + $menu[$extmenu['fatherId']]['sub'][$extmenu['sec2']]["extension"] = true; + $menu[$extmenu['fatherId']]['hasExtensions'] = true; + } + } } $menu["gextensions"]["sub"] = $sub; diff --git a/pandora_console/include/functions_extensions.php b/pandora_console/include/functions_extensions.php index 472651008f..0434eace43 100644 --- a/pandora_console/include/functions_extensions.php +++ b/pandora_console/include/functions_extensions.php @@ -79,7 +79,8 @@ function is_extension ($page) { } /** - * TODO: Document extensions + * Scan the EXTENSIONS_DIR or ENTERPRISE_DIR.'/'.EXTENSIONS_DIR for search + * the files extensions. * * @param bool $enterprise */ @@ -128,7 +129,7 @@ function get_extensions ($enterprise = false) { } /** - * Load the basic configurations of extension and add extensions into menu. + * TODO: Document extensions * * @param array $extensions */ @@ -145,9 +146,11 @@ function load_extensions ($extensions) { /** * TODO: Document extensions * - * @param string $name + * @param string name + * @param string fatherId + * @param string icon */ -function add_operation_menu_option ($name) { +function add_operation_menu_option ($name, $fatherId = null, $icon = null) { global $config; global $extension_file; @@ -157,16 +160,20 @@ function add_operation_menu_option ($name) { $option_menu['name'] = substr ($name, 0, 15); $extension = &$config['extensions'][$extension_file]; $option_menu['sec2'] = $extension['dir'].'/'.substr ($extension_file, 0, -4); + $option_menu['fatherId'] = $fatherId; + $option_menu['icon'] = $icon; $extension['operation_menu'] = $option_menu; } /** * TODO: Document extensions * - * @param string $name - * @param string $acl + * @param string name + * @param string acl + * @param string fatherId + * @param string icon */ -function add_godmode_menu_option ($name, $acl) { +function add_godmode_menu_option ($name, $acl,$fatherId = null, $icon = null) { global $config; global $extension_file; @@ -177,6 +184,8 @@ function add_godmode_menu_option ($name, $acl) { $option_menu['name'] = substr ($name, 0, 15); $extension = &$config['extensions'][$extension_file]; $option_menu['sec2'] = $extension['dir'].'/'.substr ($extension_file, 0, -4); + $option_menu['fatherId'] = $fatherId; + $option_menu['icon'] = $icon; $extension['godmode_menu'] = $option_menu; } diff --git a/pandora_console/index.php b/pandora_console/index.php index faffeb5835..4c6d857661 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -61,6 +61,9 @@ if (file_exists (ENTERPRISE_DIR."/load_enterprise.php")) { include (ENTERPRISE_DIR."/load_enterprise.php"); } +/** + * Load the basic configurations of extension and add extensions into menu. + */ load_extensions ($config['extensions']); if (!empty ($config["https"]) && empty ($_SERVER['HTTPS'])) { diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index e13cba9bb8..02c916bfec 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -199,5 +199,27 @@ if (give_acl ($config['id_user'], 0, "AR")) { } } +/** + * Add the extensions + */ + //debugPrint($config['extensions']); + foreach($config['extensions'] as $extension) { + $operationModeMenu = $extension['operation_menu']; + if ($operationModeMenu == null) + continue; + + if (array_key_exists('fatherId',$operationModeMenu)) { + if (strlen($operationModeMenu['fatherId']) > 0) { + $menu[$operationModeMenu['fatherId']]['sub'][$operationModeMenu['sec2']]["text"] = __($operationModeMenu['name']); + $menu[$operationModeMenu['fatherId']]['sub'][$operationModeMenu['sec2']]["refr"] = 60; + $menu[$operationModeMenu['fatherId']]['sub'][$operationModeMenu['sec2']]["icon"] = $operationModeMenu['icon']; + $menu[$operationModeMenu['fatherId']]['sub'][$operationModeMenu['sec2']]["sec"] = 'extensions'; + $menu[$operationModeMenu['fatherId']]['sub'][$operationModeMenu['sec2']]["extension"] = true; + $menu[$operationModeMenu['fatherId']]['hasExtensions'] = true; + } + } + } + + print_menu ($menu); ?>