From 35ec997afd01b2474bbc54d94684b9f081811a3b Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Tue, 25 Jan 2011 19:19:41 +0100 Subject: [PATCH] bacula-web: Test page design and internal code improvments - THe test page's graph use the BGraph classe from now - Seriously improved internal php code - Improved test page design - Splitted required components and graph in the test page --- gui/bacula-web/templates/test.tpl | 64 ++++++++++------------- gui/bacula-web/test.php | 84 +++++++++++++++++++------------ 2 files changed, 78 insertions(+), 70 deletions(-) diff --git a/gui/bacula-web/templates/test.tpl b/gui/bacula-web/templates/test.tpl index 98991f689a..97173764ad 100644 --- a/gui/bacula-web/templates/test.tpl +++ b/gui/bacula-web/templates/test.tpl @@ -10,44 +10,34 @@ -
+
-

Testing required components

- - - - - - - - - - - - - - - - - - -
- {php}Check( "php-gettext", "PHP Gettext support", "If you want Bacula-web in your language, please compile PHP with Gettext support" );{/php} -
- {php}Check("pear-db", "PEAR DB support", "PEAR DB support not found, please read the Bacula-web installation document");{/php} -
- {php}Check( "php-gd", "PHP GD support", "This is required by phplot, please compile php with GD support" );{/php} -
- {php}Check( "smarty-cache", "Smarty cache folder write permission", "Smarty template engine need write permissions to templates_c folder" );{/php} -
-
- Testing your graph system capabilities (Bacula-web only use PNG)
- -
-
+

Required components

+ + {foreach from=$checks item=check} + + + + + + {/foreach} +
{$check.check_label} {$check.check_descr}
+
+ +
+

Graph

+ + + + + +
+ Graph system capabilities (Bacula-web only use PNG) + + +
+
+
- -
- diff --git a/gui/bacula-web/test.php b/gui/bacula-web/test.php index b44ac60e72..cc27d28c43 100644 --- a/gui/bacula-web/test.php +++ b/gui/bacula-web/test.php @@ -1,51 +1,69 @@ compile_check = true; - $smarty->debugging = false; - $smarty->force_compile = true; + // Smarty configuration + $smarty->compile_check = true; + $smarty->debugging = false; + $smarty->force_compile = true; - $smarty->template_dir = "./templates"; - $smarty->compile_dir = "./templates_c"; - $smarty->config_dir = "./configs"; + $smarty->template_dir = "./templates"; + $smarty->compile_dir = "./templates_c"; + $smarty->config_dir = "./configs"; - function Check( $support, $description, $error_message ) - { - $result = $description . " "; - $ok = false; - - switch( $support ) + // Check result icon + $check_result = array( true => 's_ok.png', false => 's_error.gif' ); + + // Checks list + $check_list = array( array( 'check_cmd' => 'php-gettext', + 'check_label' => 'PHP - Gettext support', + 'check_descr' => 'If you want Bacula-web in your language, please compile PHP with Gettext support' ), + array( 'check_cmd' => 'pear-db', + 'check_label' => 'PEAR DB module', + 'check_descr' => 'PEAR DB support not found, please read the Bacula-web installation document'), + array( 'check_cmd' => 'php-gd', + 'check_label' => 'PHP - GD support', + 'check_descr' => 'This is required by phplot, please compile php with GD support'), + array( 'check_cmd' => 'smarty-cache', + 'check_label' => 'Smarty cache folder write permission', + 'check_descr' => 'Smarty template engine need write permissions to templates_c folder') + ); + + // Doing all checks + foreach( $check_list as &$check ) { + switch( $check['check_cmd'] ) { case 'php-gettext': - if( function_exists( 'gettext') ) - $ok = true; + $check['check_result'] = $check_result[ function_exists( 'gettext') ]; break; case 'php-gd': - if( function_exists( 'gd_info') ) - $ok = true; + $check['check_result'] = $check_result[ function_exists( 'gd_info') ]; break; case 'pear-db': - if ( class_exists('DB') ) - $ok = true; + $check['check_result'] = $check_result[ class_exists('DB') ]; break; case 'smarty-cache': - if ( is_writable( "./templates_c" ) ) - $ok = true; + $check['check_result'] = $check_result[ is_writable( "./templates_c" ) ]; break; } - if( $ok ) - $result .= "  "; - else - $result .= "$error_message "; - - echo $result; } + // Generate test graph + $data = array( array('test', 100, 100, 200, 100), array('test1', 150, 100, 150, 100 ) ); + $graph = new BGraph( "graph3.png" ); + $graph->SetColors( array('green', 'red' ) ); + + $graph->SetData( $data, 'pie', 'text-data-single' ); + $graph->SetGraphSize( 400, 230 ); + + $graph->Render(); + + // Parse to template + $smarty->assign( 'checks', $check_list ); + $smarty->assign('graph_test', $graph->Get_Image_file() ); $smarty->display('test.tpl'); ?> -- 2.39.5