Code

Updated graph handling
[gosa.git] / gosa-core / plugins / generic / statistics / graphClasses / class_statChart.inc
1 <?php
3 class statChart{
5     // Graph data 
6     var $statisticData = array();       // Via rpc received stats
7     
8     // Font used in graphs
9     var $font = "./themes/default/fonts/LiberationSans-Regular.ttf";
10     var $graphData = array();    
11     var $graphID = 0;
12     var $enableCaching = TRUE;
13     
14     var $skipSeries = array();
16     function __construct(&$config,$gData = array())
17     {
18         $this->config = $config;
20         // Collect category translations
21         $this->catTranslations = array();
22         foreach($this->config->configRegistry->getListOfPlugins() as $plugin => $data){
23             if(isset($data['plCategory'])){
24                 foreach($data['plCategory'] as $id => $name){
25                     if(!is_numeric($id)){
26                         $this->catTranslations[$id] = $name['description'];
27                     }
28                 }
29             }
30         }
31     }
34     function setGraphData($data)
35     {
36         $this->graphData = $data;
37     }
40     /*! \brief      This method tries to translate category names.
41      *  @param      The category name to translate
42      *  @return     String  The translated category names.
43      */
44     function getCategoryTranslation($name)
45     {
46         $ret ="";
48         // We do not have a category for systems directly, so we've to map all system types to 'System'.
49         // If we do not map to _(Systems) the graph legend will be half screen width.
50         if($name == "systems"){
51             return(_("Systems"));
52         }
54         // Walk through category names and try to find a translation.
55         $cat = trim($name);
56         if(isset($this->catTranslations[$cat])){
57             $cat = _($this->catTranslations[$cat]);
58         }elseif(!empty($cat)){
59             $cat = _($cat);
60         }
61         return($cat); 
62     }
65     function getGraphID()
66     {
67         return($this->graphID);
68     }
70     function getSeriesList()
71     {
72         return($this->seriesList);
73     }
75     function getSeriesSelector()
76     {
77         $str = "<input type='hidden' name='{$this->gID}_posted' value='1'>";
78         $list = $this->getSeriesList();
79         foreach($list as $key => $item){
80             $checked = (in_array($key, $this->skipSeries))? '': 'checked';
81             $str .= "<span style='padding-right:20px'>".
82                     "   <input type='checkbox' name='addSeries_{$this->gID}_{$key}' value='1'".
83                     "       onClick=\"document.mainform.submit();\" ".
84                     "       {$checked}>{$item}".
85                     "   </span>";
86         }
87         return($str);
88     }
90     function save_object()
91     {
92         if(!isset($_POST["{$this->gID}_posted"])) return;
94         // Get series to enable or disable
95         foreach($this->seriesList as $seriesName => $seriesDesc){
96             if(!isset($_POST["addSeries_{$this->gID}_{$seriesName}"])){
97                 $this->skipSeries[] = $seriesName;
98             }
99         }
100     }
102 ?>