function generateImage($params) { // Default values of parameters $image = ""; $export = "png"; $f_name = ""; $class = ""; $title = ""; $unit = ''; $raw_datas = array(); $withdata = 0; foreach ($params as $key => $val) { ${$key} = $val; } ob_start(); if ($export == "odt") { $show_graph = PluginMreportingConfig::showGraphConfigValue($f_name, $class); if ($show_graph) { $path = GLPI_PLUGIN_DOC_DIR . "/mreporting/" . $f_name . ".png"; imagepng($image, $path); } $common = new PluginMreportingCommon(); $options[] = array("title" => $title, "f_name" => $f_name, "class" => $class, "randname" => $randname, "raw_datas" => $raw_datas, "withdata" => $withdata); $common->generateOdt($options); return true; } else { if ($export == "odtall") { $show_graph = PluginMreportingConfig::showGraphConfigValue($f_name, $class); if ($show_graph) { $path = GLPI_PLUGIN_DOC_DIR . "/mreporting/" . $f_name . ".png"; imagepng($image, $path); } if (isset($raw_datas['datas'])) { $_SESSION['glpi_plugin_mreporting_odtarray'][] = array("title" => $title, "f_name" => $f_name, "class" => $class, "randname" => $randname, "raw_datas" => $raw_datas, "withdata" => $withdata); } return true; } else { imagepng($image); $contents = ob_get_contents(); ob_end_clean(); return $contents; } } }
/** * end Graph : Show graph datas array, setup link, export * * @params $options ($opt, export, datas, unit, labels2, flip_data) */ static function endGraph($options) { global $LANG, $CFG_GLPI; $opt = array(); $export = false; $datas = array(); $unit = ''; $labels2 = array(); $flip_data = false; foreach ($options as $k => $v) { ${$k} = $v; } $randname = false; if (isset($opt['randname']) && $opt['randname'] !== false) { $randname = $opt['randname']; $_REQUEST['short_classname'] = $opt['short_classname']; $_REQUEST['f_name'] = $opt['f_name']; $_REQUEST['gtype'] = $opt['gtype']; $_REQUEST['randname'] = $opt['randname']; //End Script for graph display //if $randname exists $config = PluginMreportingConfig::initConfigParams($opt['f_name'], "PluginMreporting" . $opt['short_classname']); if (!$export && ($config['graphtype'] == 'GLPI' && $CFG_GLPI['default_graphtype'] == 'svg' || $config['graphtype'] == 'SVG')) { echo "}\n showGraph{$randname}();\n </script>"; echo "</div>"; } } $request_string = PluginMreportingMisc::getRequestString($_REQUEST); if ($export != "odtall") { if ($randname !== false && !$export) { $show_graph = PluginMreportingConfig::showGraphConfigValue($opt['f_name'], $opt['class']); self::showGraphDatas($datas, $unit, $labels2, $flip_data, $show_graph); } if (!$export) { if (isset($_REQUEST['f_name']) && $_REQUEST['f_name'] != "test") { echo "<div class='graph_bottom'>"; echo "<span style='float:left'>"; echo "<br><br>"; PluginMreportingMisc::showNavigation(); echo "</span>"; echo "<span style='float:right'>"; if (plugin_mreporting_haveRight('config', 'w')) { echo "<b>" . $LANG['plugin_mreporting']["config"][0] . "</b> : "; echo " <a href='config.form.php?name=" . $opt['f_name'] . "&classname=" . $opt['class'] . "' target='_blank'>"; echo "<img src='../pics/config.png' class='title_pics'/></a>"; } if ($randname !== false) { echo "<br><br>"; echo "<form method='post' action='export.php?{$request_string}' \n style='margin: 0; padding: 0' target='_blank' id='export_form'>"; echo "<b>" . __("Export") . "</b> : "; $params = array('myname' => 'ext', 'ajax_page' => $CFG_GLPI["root_doc"] . "/plugins/mreporting/ajax/dropdownExport.php", 'class' => __CLASS__, 'span' => 'show_ext', 'gtype' => $_REQUEST['gtype'], 'show_graph' => $show_graph, 'randname' => $randname); self::dropdownExt($params); echo "<span id='show_ext'>"; echo "</span>"; Html::Closeform(); } echo "</span>"; } echo "<div style='clear:both;'></div>"; echo "</div>"; if (isset($_REQUEST['f_name']) && $_REQUEST['f_name'] != "test") { echo "</div></div>"; } } if ($randname == false) { echo "</div>"; } } //destroy specific palette unset($_SESSION['mreporting']['colors']); }