Example #1
0
 /**
  * show Graph : Show graph
  *
  * @params $options ($opt, export)
  * @params $opt (classname, short_classname, f_name, gtype)
  */
 function showGraph($opt, $export = false)
 {
     global $LANG, $CFG_GLPI;
     PluginMreportingCommon::title($opt);
     //check the format display charts configured in glpi
     $opt = $this->initParams($opt, $export);
     $config = PluginMreportingConfig::initConfigParams($opt['f_name'], "PluginMreporting" . $opt['short_classname']);
     if ($config['graphtype'] == 'PNG' || $config['graphtype'] == 'GLPI' && $CFG_GLPI['default_graphtype'] == 'png') {
         $graph = new PluginMreportingGraphpng();
     } elseif ($config['graphtype'] == 'SVG' || $config['graphtype'] == 'GLPI' && $CFG_GLPI['default_graphtype'] == 'svg') {
         $graph = new PluginMreportingGraph();
     }
     //dynamic instanciation of class passed by 'short_classname' GET parameter
     $classname = 'PluginMreporting' . $opt['short_classname'];
     $obj = new $classname();
     //dynamic call of method passed by 'f_name' GET parameter with previously instancied class
     $datas = $obj->{$opt}['f_name']();
     //show graph (pgrah type determined by first entry of explode of camelcase of function name
     $title_func = $LANG['plugin_mreporting'][$opt['short_classname']][$opt['f_name']]['title'];
     $des_func = "";
     if (isset($LANG['plugin_mreporting'][$opt['short_classname']][$opt['f_name']]['desc'])) {
         $des_func = $LANG['plugin_mreporting'][$opt['short_classname']][$opt['f_name']]['desc'];
     }
     $opt['class'] = $classname;
     $opt['withdata'] = 1;
     $params = array("raw_datas" => $datas, "title" => $title_func, "desc" => $des_func, "export" => $export, "opt" => $opt);
     $graph->{'show' . $opt['gtype']}($params);
 }