]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Test page design and internal code improvments
authorDavide Franco <bacula-dev@dflc.ch>
Tue, 25 Jan 2011 18:19:41 +0000 (19:19 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:43:37 +0000 (14:43 +0200)
 - 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
gui/bacula-web/test.php

index 98991f689acc1a5d8d8a0fa914dab86775e912a5..97173764ad7121f1f2dc0f606d4c05cc3798c8c8 100644 (file)
   <div id="nav">
     <a href="index.php" title="Back to the dashboard">Dashboard</a> > Test page
   </div>
-  <div id="main_center">
+<div id="main_center">
        <div class="box">
-         <p class="title">Testing required components</p>
-         
-         <table>
-           <tr>
-             <td width="300">
-                   {php}Check( "php-gettext", "PHP Gettext support", "If you want Bacula-web in your language, please compile PHP with Gettext support" );{/php}
-                 </td>
-               </tr>
-               <tr>
-                 <td>
-                   {php}Check("pear-db", "PEAR DB support", "PEAR DB support not found, please read the Bacula-web installation document");{/php}
-                 </td>
-           </tr>
-               <tr>
-                 <td>
-                 {php}Check( "php-gd", "PHP GD support", "This is required by phplot, please compile php with GD support" );{/php}
-                 </td>
-               </tr>
-               <tr>
-                 <td>
-                       {php}Check( "smarty-cache", "Smarty cache folder write permission", "Smarty template engine need write permissions to templates_c folder" );{/php}
-       </td>
-</tr>
-
-<tr>
-       <td colspan="3">
-               <center>
-                       Testing your graph system capabilities (Bacula-web only use PNG) <br />
-                       <img src="simplegraph.php" /> 
-               </center>
-       </td>
-</tr>
-</table>
+         <p class="title">Required components</p>
+       <table>
+               {foreach from=$checks item=check}
+                 <tr>
+                   <td> <b>{$check.check_label}</b> </td>
+                       <td>{$check.check_descr}</td>
+                       <td> <img src='style/images/{$check.check_result}' width='20' alt=''/></td>
+                 </tr>
+               {/foreach}
+       </table>
+       </div> <!-- end div class=box -->
+       
+       <div class="box">
+         <p class="title">Graph</p>
+       <table>
+         <tr>
+           <td>
+                       <b>Graph system capabilities (Bacula-web only use PNG)</b>
+               </td>
+           <td colspan="2">
+                 <img src="{$graph_test}" alt='' />
+           </td>
+         </tr>
+       </table>
+       </div> <!-- end div class=box -->
+</div> <!-- end div id=main_center -->
 
-         
-       </div>
-  </div>
 </body>
 </html>
index b44ac60e727b4390c1777b56df838fbc0da181a2..cc27d28c43c7c273a457de94c455ad3d5b982b28 100644 (file)
@@ -1,51 +1,69 @@
 <?php
-  require_once ("paths.php");
-  require_once ($smarty_path."Smarty.class.php");
-  require_once ("bweb.inc.php");
+       require_once ("paths.php");
+       require_once ($smarty_path."Smarty.class.php");
+       require_once ("bweb.inc.php");
 
-  $smarty = new Smarty(); 
-  
-  //require_once ("lang.php");
+       $smarty = new Smarty(); 
+
+       //require_once ("lang.php");
 
-  // Smarty configuration
-  $smarty->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 . " </td>";
-               $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 .= "<td width='300'>&nbsp;</td> <td> <img width='25' src='style/images/s_ok.png' />";
-               else
-                       $result .= "<td width='300'>$error_message</td> <td width='35'> <img width='30' src='style/images/s_error.gif' />";
-               
-               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');
 ?>