diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 2d74c4ebbc..b574ad835d 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2014-08-14 Miguel de Dios + + * include/functions_clippy.php, + include/help/clippy/godmode_agentes_modificar_agente.php, + include/help/clippy/homepage.php, + include/help/clippy/module_unknow.php, + include/help/clippy/godmode_agentes_configurar_agente.php, + include/javascript/intro.js: some fixes and improves in the clippy. + 2014-08-14 Koichiro Kikuchi * pandora_console_install: Refactored code and added "fakeroot" diff --git a/pandora_console/include/functions_clippy.php b/pandora_console/include/functions_clippy.php index fab87370ef..a86abfe697 100644 --- a/pandora_console/include/functions_clippy.php +++ b/pandora_console/include/functions_clippy.php @@ -32,16 +32,21 @@ function clippy_start($sec2) { if (is_file("include/help/clippy/" . $sec2 . ".php")) { require("include/help/clippy/" . $sec2 . ".php"); - clippy_start_page(); + $tours = clippy_start_page(); + clippy_write_javascript_helps_steps($tours); } //Add homepage for all pages for to show the "task sugestions" require("include/help/clippy/homepage.php"); - clippy_start_page_homepage(); + + $tours = clippy_start_page_homepage(); + clippy_write_javascript_helps_steps($tours); } else { require("include/help/clippy/homepage.php"); - clippy_start_page_homepage(); + + $tours = clippy_start_page_homepage(); + clippy_write_javascript_helps_steps($tours); } } @@ -49,38 +54,66 @@ function clippy_clean_help() { set_cookie('clippy', null); } -function clippy_write_javascript_helps_steps($helps, - $force_first_step_by_default = true) { +function clippy_write_javascript_helps_steps($tours) { global $config; + $first_step_by_default = false; + if (isset($tours['first_step_by_default'])) + $first_step_by_default = $tours['first_step_by_default']; + + //For the help context instead the clippy + $help_context = false; + if (isset($tours['help_context'])) + $help_context = $tours['help_context']; + + if ($help_context) { + $name_obj_js_tour = '{clippy_obj}'; + } + else { + $name_obj_js_tour = 'intro'; + } + $clippy = get_cookie('clippy', false); set_cookie('clippy', null); //Get the help steps from a task - $steps = $helps[$clippy]['steps']; - if ($force_first_step_by_default) { + $steps = $tours['tours'][$clippy]['steps']; + if ($first_step_by_default) { if (empty($steps)) { //Get the first by default - $temp = reset($helps); + $temp = reset($tours['tours']); $steps = $temp['steps']; } } - $conf = $helps[$clippy]['conf']; - if ($force_first_step_by_default) { + if ($help_context) { + + foreach ($steps as $iterator => $step) { + $init_step_context = false; + if (isset($step['init_step_context'])) + $init_step_context = $step['init_step_context']; + + if ($init_step_context) { + unset($steps[$iterator]['init_step_context']); + $steps[$iterator]['element'] = '{clippy}'; + } + } + } + + $conf = $tours['tours'][$clippy]['conf']; + if ($first_step_by_default) { if (empty($conf)) { //Get the first by default - $temp = reset($helps); + $temp = reset($tours['tours']); $conf = $temp['conf']; } } if (!empty($steps)) { - $name_obj_tour = 'intro'; - if (!empty($conf['name_obj_tour'])) { - $name_obj_tour = $conf['name_obj_tour']; + if (!empty($conf['name_obj_js_tour'])) { + $name_obj_js_tour = $conf['name_obj_js_tour']; } $autostart = true; @@ -93,17 +126,36 @@ function clippy_write_javascript_helps_steps($helps, $other_js = $conf['other_js']; } + $exit_js = ''; + if (!empty($conf['exit_js'])) { + $exit_js = $conf['exit_js']; + } + $complete_js = ''; + if (!empty($conf['complete_js'])) { + $complete_js = $conf['complete_js']; + } + $show_bullets = 0; + if (!empty($conf['show_bullets'])) { + $show_bullets = (int)$conf['show_bullets']; + } + $show_step_numbers = 0; + if (!empty($conf['show_step_numbers'])) { + $show_step_numbers = (int)$conf['show_step_numbers']; + } + + $help_context = false; + ?> '; diff --git a/pandora_console/include/help/clippy/godmode_agentes_configurar_agente.php b/pandora_console/include/help/clippy/godmode_agentes_configurar_agente.php index d962d44593..440994839a 100644 --- a/pandora_console/include/help/clippy/godmode_agentes_configurar_agente.php +++ b/pandora_console/include/help/clippy/godmode_agentes_configurar_agente.php @@ -20,107 +20,109 @@ */ function clippy_start_page() { - $helps = array(); + + $return_tours = array(); + $return_tours['first_step_by_default'] = false; + $return_tours['tours'] = array(); //================================================================== //Help tour about the monitoring with a ping (step 3) //------------------------------------------------------------------ - $helps['monitoring_server_step_3'] = array(); - $helps['monitoring_server_step_3']['steps'] = array(); - $helps['monitoring_server_step_3']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_3'] = array(); + $return_tours['tours']['monitoring_server_step_3']['steps'] = array(); + $return_tours['tours']['monitoring_server_step_3']['steps'][] = array( 'element'=> '#clippy', 'intro' => __('Now you must go to modules, don\'t worry I teach you.') ); - $helps['monitoring_server_step_3']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_3']['steps'][] = array( 'element'=> "img[alt='Modules']", 'intro' => __('Please click in this tab.') ); - $helps['monitoring_server_step_3']['conf'] = array(); - $helps['monitoring_server_step_3']['conf']['showBullets'] = 0; - $helps['monitoring_server_step_3']['conf']['showStepNumbers'] = 0; - $helps['monitoring_server_step_3']['conf']['next_help'] = 'monitoring_server_step_4'; + $return_tours['tours']['monitoring_server_step_3']['conf'] = array(); + $return_tours['tours']['monitoring_server_step_3']['conf']['show_bullets'] = 0; + $return_tours['tours']['monitoring_server_step_3']['conf']['show_step_numbers'] = 0; + $return_tours['tours']['monitoring_server_step_3']['conf']['next_help'] = 'monitoring_server_step_4'; //================================================================== //================================================================== //Help tour about the monitoring with a ping (step 4) //------------------------------------------------------------------ - $helps['monitoring_server_step_4'] = array(); - $helps['monitoring_server_step_4']['steps'] = array(); - $helps['monitoring_server_step_4']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_4'] = array(); + $return_tours['tours']['monitoring_server_step_4']['steps'] = array(); + $return_tours['tours']['monitoring_server_step_4']['steps'][] = array( 'element'=> '#clippy', 'intro' => __('Now you must create the module, don\'t worry I teach you.') ); - $helps['monitoring_server_step_4']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_4']['steps'][] = array( 'element'=> "#moduletype", 'intro' => __('Choose the network server module.') ); - $helps['monitoring_server_step_4']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_4']['steps'][] = array( 'element'=> "input[name='updbutton']", 'intro' => __('And click in this button.') ); - $helps['monitoring_server_step_4']['conf'] = array(); - $helps['monitoring_server_step_4']['conf']['showBullets'] = 0; - $helps['monitoring_server_step_4']['conf']['showStepNumbers'] = 0; - $helps['monitoring_server_step_4']['conf']['next_help'] = 'monitoring_server_step_5'; + $return_tours['tours']['monitoring_server_step_4']['conf'] = array(); + $return_tours['tours']['monitoring_server_step_4']['conf']['show_bullets'] = 0; + $return_tours['tours']['monitoring_server_step_4']['conf']['show_step_numbers'] = 0; + $return_tours['tours']['monitoring_server_step_4']['conf']['next_help'] = 'monitoring_server_step_5'; //================================================================== //================================================================== //Help tour about the monitoring with a ping (step 5) //------------------------------------------------------------------ - $helps['monitoring_server_step_5'] = array(); - $helps['monitoring_server_step_5']['steps'] = array(); - $helps['monitoring_server_step_5']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_5'] = array(); + $return_tours['tours']['monitoring_server_step_5']['steps'] = array(); + $return_tours['tours']['monitoring_server_step_5']['steps'][] = array( 'element'=> '#clippy', 'intro' => __('Now you must create the module, don\'t worry I teach you.') ); - $helps['monitoring_server_step_5']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_5']['steps'][] = array( 'element'=> '#clippy', 'intro' => __('We are going to fill the form.') ); - $helps['monitoring_server_step_5']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_5']['steps'][] = array( 'element'=> "#network_component_group", 'intro' => __('Please choose the Network Management.') ); - $helps['monitoring_server_step_5']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_5']['steps'][] = array( 'element'=> "#network_component", 'intro' => __('And choose the component with the name "Host Alive".') ); - $helps['monitoring_server_step_5']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_5']['steps'][] = array( 'element'=> "input[name='name']", 'intro' => __('You can change the name.') ); - $helps['monitoring_server_step_5']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_5']['steps'][] = array( 'element'=> "input[name='ip_target']", 'intro' => __('Check if this IP is the address of your machine.') ); - $helps['monitoring_server_step_5']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_5']['steps'][] = array( 'element'=> "input[name='crtbutton']", 'intro' => __('And only to finish it is clicking this button.') ); - $helps['monitoring_server_step_5']['conf'] = array(); - $helps['monitoring_server_step_5']['conf']['showBullets'] = 0; - $helps['monitoring_server_step_5']['conf']['showStepNumbers'] = 0; - $helps['monitoring_server_step_5']['conf']['next_help'] = 'monitoring_server_step_6'; + $return_tours['tours']['monitoring_server_step_5']['conf'] = array(); + $return_tours['tours']['monitoring_server_step_5']['conf']['show_bullets'] = 0; + $return_tours['tours']['monitoring_server_step_5']['conf']['show_step_numbers'] = 0; + $return_tours['tours']['monitoring_server_step_5']['conf']['next_help'] = 'monitoring_server_step_6'; //================================================================== //================================================================== //Help tour about the monitoring with a ping (step 6) //------------------------------------------------------------------ - $helps['monitoring_server_step_6'] = array(); - $helps['monitoring_server_step_6']['steps'] = array(); - $helps['monitoring_server_step_6']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_6'] = array(); + $return_tours['tours']['monitoring_server_step_6']['steps'] = array(); + $return_tours['tours']['monitoring_server_step_6']['steps'][] = array( 'element'=> '#clippy', 'intro' => __('Now, your module is just created.
And the status color is blue.
This meaning of blue status is the module is not executed for first time.
In the next seconds if there is not a problem, the status color will change to red or green.') ); - $helps['monitoring_server_step_6']['conf'] = array(); - $helps['monitoring_server_step_6']['conf']['showBullets'] = 0; - $helps['monitoring_server_step_6']['conf']['showStepNumbers'] = 0; + $return_tours['tours']['monitoring_server_step_6']['conf'] = array(); + $return_tours['tours']['monitoring_server_step_6']['conf']['show_bullets'] = 0; + $return_tours['tours']['monitoring_server_step_6']['conf']['show_step_numbers'] = 0; //================================================================== - - clippy_write_javascript_helps_steps($helps, false); + return $return_tours; } ?> \ No newline at end of file diff --git a/pandora_console/include/help/clippy/godmode_agentes_modificar_agente.php b/pandora_console/include/help/clippy/godmode_agentes_modificar_agente.php index 914b56df3e..b62046c0f6 100644 --- a/pandora_console/include/help/clippy/godmode_agentes_modificar_agente.php +++ b/pandora_console/include/help/clippy/godmode_agentes_modificar_agente.php @@ -21,51 +21,53 @@ function clippy_start_page() { - $helps = array(); + $return_tours = array(); + $return_tours['first_step_by_default'] = false; + $return_tours['tours'] = array(); //================================================================== //Help tour about the monitoring with a ping (step 1) //------------------------------------------------------------------ - $helps['monitoring_server_step_1'] = array(); - $helps['monitoring_server_step_1']['steps'] = array(); - $helps['monitoring_server_step_1']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_1'] = array(); + $return_tours['tours']['monitoring_server_step_1']['steps'] = array(); + $return_tours['tours']['monitoring_server_step_1']['steps'][] = array( 'element'=> '#clippy', - 'intro' => __('I show how to monitoring a server.') + 'intro' => __('I show how to ping a server.') ); - $helps['monitoring_server_step_1']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_1']['steps'][] = array( 'element'=> 'input[name="search"]', 'intro' => __('Please type a agent to save the modules for monitoring a server.') ); - $helps['monitoring_server_step_1']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_1']['steps'][] = array( 'element'=> 'input[name="srcbutton"]', 'intro' => __('Maybe if you typped correctly the name, you can see the agent.') ); - $helps['monitoring_server_step_1']['conf'] = array(); - $helps['monitoring_server_step_1']['conf']['showBullets'] = 0; - $helps['monitoring_server_step_1']['conf']['showStepNumbers'] = 1; - $helps['monitoring_server_step_1']['conf']['next_help'] = 'monitoring_server_step_2'; + $return_tours['tours']['monitoring_server_step_1']['conf'] = array(); + $return_tours['tours']['monitoring_server_step_1']['conf']['show_bullets'] = 0; + $return_tours['tours']['monitoring_server_step_1']['conf']['show_step_numbers'] = 1; + $return_tours['tours']['monitoring_server_step_1']['conf']['next_help'] = 'monitoring_server_step_2'; //================================================================== //================================================================== //Help tour about the monitoring with a ping (step 2) //------------------------------------------------------------------ - $helps['monitoring_server_step_2'] = array(); - $helps['monitoring_server_step_2']['steps'] = array(); - $helps['monitoring_server_step_2']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_2'] = array(); + $return_tours['tours']['monitoring_server_step_2']['steps'] = array(); + $return_tours['tours']['monitoring_server_step_2']['steps'][] = array( 'element'=> '#clippy', 'intro' => __('Please choose the agent that you have searched.') ); - $helps['monitoring_server_step_2']['steps'][] = array( + $return_tours['tours']['monitoring_server_step_2']['steps'][] = array( 'element'=> '#agent_list', 'intro' => __('Choose the agent, please click in the name.') ); - $helps['monitoring_server_step_2']['conf'] = array(); - $helps['monitoring_server_step_2']['conf']['showBullets'] = 0; - $helps['monitoring_server_step_2']['conf']['showStepNumbers'] = 0; - $helps['monitoring_server_step_2']['conf']['next_help'] = 'monitoring_server_step_3'; + $return_tours['tours']['monitoring_server_step_2']['conf'] = array(); + $return_tours['tours']['monitoring_server_step_2']['conf']['show_bullets'] = 0; + $return_tours['tours']['monitoring_server_step_2']['conf']['show_step_numbers'] = 0; + $return_tours['tours']['monitoring_server_step_2']['conf']['next_help'] = 'monitoring_server_step_3'; //================================================================== - clippy_write_javascript_helps_steps($helps, false); + return $return_tours; } ?> \ No newline at end of file diff --git a/pandora_console/include/help/clippy/homepage.php b/pandora_console/include/help/clippy/homepage.php index 3afa3f0519..57e04352a1 100644 --- a/pandora_console/include/help/clippy/homepage.php +++ b/pandora_console/include/help/clippy/homepage.php @@ -26,49 +26,62 @@ function clippy_start_page_homepage() { clippy_clean_help(); - $helps = array(); + $return_tours = array(); + $return_tours['first_step_by_default'] = true; + $return_tours['tours'] = array(); + //================================================================== //Help tour with the some task for to help the user. //------------------------------------------------------------------ - $helps['homepage'] = array(); - $helps['homepage']['steps'] = array(); - $helps['homepage']['steps'][] = array( + $return_tours['tours']['homepage'] = array(); + $return_tours['tours']['homepage']['steps'] = array(); + $return_tours['tours']['homepage']['steps'][] = array( 'element'=> '#clippy', 'intro' => __('Could I help you?

I am Pandorin, the annoying clippy for Pandora. You could follow my advices for to make common and basic tasks in Pandora.') . + '
'. + html_print_checkbox_extended + ('clippy_is_annoying', 1, $clippy_is_annoying, false, + 'set_clippy_annoying()', '', true) . + __('Please the clippy is annoying, I don\'t want see.') . + '
' . '
' . html_print_image('images/pandorin.png', true) . '
' ); - $helps['homepage']['steps'][] = array( + $return_tours['tours']['homepage']['steps'][] = array( 'element'=> '#clippy', 'intro' => __('What task do you want to do?') . '

' . '' . - '
'. - html_print_checkbox_extended - ('clippy_is_annoying', 1, $clippy_is_annoying, false, - 'set_clippy_annoying()', '', true) . - __('Please the clippy is annoying, I don\'t want see.') . - '
' + '
  • ' . __('Monitoring a Windows server with remote WMI') . '
  • ' . + '' ); - $helps['homepage']['conf'] = array(); - $helps['homepage']['conf']['showBullets'] = 0; - $helps['homepage']['conf']['showStepNumbers'] = 0; - $helps['homepage']['conf']['name_obj_tour'] = 'intro_homepage'; - $helps['homepage']['conf']['other_js'] = " + $return_tours['tours']['homepage']['conf'] = array(); + $return_tours['tours']['homepage']['conf']['show_bullets'] = 0; + $return_tours['tours']['homepage']['conf']['show_step_numbers'] = 0; + $return_tours['tours']['homepage']['conf']['name_obj_js_tour'] = 'intro_homepage'; + $return_tours['tours']['homepage']['conf']['other_js'] = " + var started = 0; + function show_clippy() { - intro_homepage.start(); + if (intro_homepage.started()) { + started = 1; + } + else { + started = 0; + } + + if (started == 0) + intro_homepage.start(); } function set_clippy_annoying() { @@ -84,22 +97,22 @@ function clippy_start_page_homepage() { } "; if ($config['logged']) { - $helps['homepage']['conf']['autostart'] = true; + $return_tours['tours']['homepage']['conf']['autostart'] = true; } else { - $helps['homepage']['conf']['autostart'] = false; + $return_tours['tours']['homepage']['conf']['autostart'] = false; } if ($config["tutorial_mode"] == 'on_demand') { - $helps['homepage']['conf']['autostart'] = false; + $return_tours['tours']['homepage']['conf']['autostart'] = false; } if ($clippy_is_annoying === 1) { - $helps['homepage']['conf']['autostart'] = false; + $return_tours['tours']['homepage']['conf']['autostart'] = false; } //================================================================== - clippy_write_javascript_helps_steps($helps); + return $return_tours; } ?> \ No newline at end of file diff --git a/pandora_console/include/help/clippy/module_unknow.php b/pandora_console/include/help/clippy/module_unknow.php index ced9c476e7..677d4bb552 100644 --- a/pandora_console/include/help/clippy/module_unknow.php +++ b/pandora_console/include/help/clippy/module_unknow.php @@ -20,15 +20,19 @@ */ function clippy_module_unknow() { - $helps = array(); + + $return_tours = array(); + $return_tours['first_step_by_default'] = true; + $return_tours['help_context'] = true; + $return_tours['tours'] = array(); //================================================================== //Help tour about the monitoring with a ping (step 3) //------------------------------------------------------------------ - $helps['module_unknow'] = array(); - $helps['module_unknow']['steps'] = array(); - $helps['module_unknow']['steps'][] = array( - 'element'=> '{clippy}', //The template to replace with the autogenerate id + $return_tours['tours']['module_unknow'] = array(); + $return_tours['tours']['module_unknow']['steps'] = array(); + $return_tours['tours']['module_unknow']['steps'][] = array( + 'init_step_context' => true, 'intro' => '' . '' . '' . '
    ' . @@ -43,13 +47,12 @@ function clippy_module_unknow() { '
    ' ); - $helps['module_unknow']['conf'] = array(); - $helps['module_unknow']['conf']['autostart'] = false; - $helps['module_unknow']['conf']['showBullets'] = 0; - $helps['module_unknow']['conf']['showStepNumbers'] = 0; - $helps['module_unknow']['conf']['name_obj_tour'] = '{clippy_obj}'; + $return_tours['tours']['module_unknow']['conf'] = array(); + $return_tours['tours']['module_unknow']['conf']['autostart'] = false; + $return_tours['tours']['module_unknow']['conf']['show_bullets'] = 0; + $return_tours['tours']['module_unknow']['conf']['show_step_numbers'] = 0; //================================================================== - clippy_write_javascript_helps_steps($helps, true); + return $return_tours; } ?> \ No newline at end of file diff --git a/pandora_console/include/javascript/intro.js b/pandora_console/include/javascript/intro.js index 27343b89b6..28d5ad95b4 100644 --- a/pandora_console/include/javascript/intro.js +++ b/pandora_console/include/javascript/intro.js @@ -57,7 +57,9 @@ /* Scroll to highlighted element? */ scrollToElement: true, /* Set the overlay opacity */ - overlayOpacity: 0.8 + overlayOpacity: 0.8, + /* Set the flag of status of intro js*/ + flag_started: false, }; } @@ -372,7 +374,9 @@ } else if (document.detachEvent) { //IE document.detachEvent('onkeydown', this._onKeyDown); } - + + this._options['flag_started'] = false; + //set the step to zero this._currentStep = undefined; } @@ -980,6 +984,11 @@ return this; }, start: function () { + this._options['flag_started'] = true; + + if (this._introStartCallback != undefined) + this._introStartCallback.call(this); + _introForElement.call(this, this._targetElement); return this; }, @@ -1034,6 +1043,14 @@ } return this; }, + onstart: function(providedCallback) { + if (typeof (providedCallback) === 'function') { + this._introStartCallback = providedCallback; + } else { + throw new Error('Provided callback for onstart was not a function.'); + } + return this; + }, onexit: function(providedCallback) { if (typeof (providedCallback) === 'function') { this._introExitCallback = providedCallback; @@ -1041,6 +1058,9 @@ throw new Error('Provided callback for onexit was not a function.'); } return this; + }, + started: function() { + return this._options['flag_started']; } };