From: Davide Franco Date: Tue, 25 Jan 2011 18:19:41 +0000 (+0100) Subject: bacula-web: Test page design and internal code improvments X-Git-Tag: Release-5.2.1~544 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=994b7ce0da8a75364f55f278f861f1d99cd894d0;p=bacula%2Fbacula 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 --- 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'); ?>