diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 350a968cc3..da2ae00a75 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2009-01-26 Esteban Sanchez + + * include/functions_ui.php: print_alert_template_example() now + replaces also the value. + + * godmode/alerts/configure_alert_template.php: Removed first render + example using javascript. + + * godmode/alerts/alert_templates.php: Removed parameter replacement + since it's now done in the function. + 2009-01-24 Raul Mateos * install.php: Added code to show current console URL in step 3. diff --git a/pandora_console/godmode/alerts/alert_templates.php b/pandora_console/godmode/alerts/alert_templates.php index 8dcbcf5a2a..e45184d0f0 100644 --- a/pandora_console/godmode/alerts/alert_templates.php +++ b/pandora_console/godmode/alerts/alert_templates.php @@ -44,12 +44,7 @@ if (defined ('AJAX')) { echo get_alert_templates_type_name ($template['type']); echo '
'; - $example = print_alert_template_example ($template['id'], true); - - $example = str_replace ('', $template['value'], $example); - $example = str_replace ('', $template['max_value'], $example); - $example = str_replace ('', $template['min_value'], $example); - echo $example; + echo print_alert_template_example ($template['id'], true); echo '
'; diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index 439734ed2f..a23ac6f055 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -548,7 +548,6 @@ function render_example () { } $(document).ready (function () { - render_example (); $("#text-time_from, #text-time_to").timeEntry ({ spinnerImage: 'images/time-entry.png', spinnerSize: [20, 20, 0] diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index d6af549c89..b648f5118d 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -323,48 +323,51 @@ function print_alert_template_example ($id_alert_template, $return = false) { $output .= ' '; $output .= ''; + $template = get_alert_template ($id_alert_template); - if ($id_alert_template) { - $template = get_alert_template ($id_alert_template); + switch ($template['type']) { + case 'equal': + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is '); + break; + case 'not_equal': + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is not '); + break; + case 'regex': + if ($template['matches_value']) + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value matches '); + else + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value doesn\'t match '); + $value = $template['value']; + break; + case 'max_min': + if ($template['matches_value']) + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is between and '); + else + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is not between and '); + break; + case 'max': + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is over '); - switch ($template['type']) { - case 'not_equal': - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value is '); - break; - case 'equal': - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value is not '); - break; - case 'regex': - if ($template['matches_value']) - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value matches '); - else - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value doesn\'t match '); - $value = $template['value']; - break; - case 'max_min': - if ($template['matches_value']) - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value is between and '); - else - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value is not between and '); - break; - case 'max': - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value is over '); - - break; - case 'min': - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value is under '); - break; - } + break; + case 'min': + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is under '); + break; } + /* Replace span elements with real values. This is done in such way to avoid + duplicating strings and make it easily modificable via Javascript. */ + $output = str_replace ('', $template['value'], $output); + $output = str_replace ('', $template['max_value'], $output); + $output = str_replace ('', $template['min_value'], $output); + $output .= ''; if ($return) return $output;