archires.map.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /*
  3. * @version $Id: archires.map.php 234 2019-12-12 14:34:31Z yllen $
  4. -------------------------------------------------------------------------
  5. LICENSE
  6. This file is part of Archires plugin for GLPI.
  7. Archires is free software: you can redistribute it and/or modify
  8. it under the terms of the GNU Affero General Public License as published by
  9. the Free Software Foundation, either version 3 of the License, or
  10. (at your option) any later version.
  11. Archires is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU Affero General Public License for more details.
  15. You should have received a copy of the GNU Affero General Public License
  16. along with Archires. If not, see <http://www.gnu.org/licenses/>.
  17. @package archires
  18. @author Nelly Mahu-Lasson, Xavier Caillaud
  19. @copyright Copyright (c) 2016-2021 Archires plugin team
  20. @license AGPL License 3.0 or (at your option) any later version
  21. http://www.gnu.org/licenses/agpl-3.0-standalone.html
  22. @link https://forge.glpi-project.org/projects/archires
  23. @since version 2.2
  24. --------------------------------------------------------------------------
  25. */
  26. include ("../../../inc/includes.php");
  27. $PluginArchiresView = new PluginArchiresView();
  28. $PluginArchiresPrototype = new PluginArchiresPrototype();
  29. $PluginArchiresView->getFromDB($_GET["plugin_archires_views_id"]);
  30. if (isset($_GET["format"])) {
  31. $format = $_GET["format"];
  32. } else {
  33. $format = $PluginArchiresView->fields["format"];
  34. }
  35. if ($format == PluginArchiresView::PLUGIN_ARCHIRES_JPEG_FORMAT) {
  36. $format_graph = "jpeg";
  37. } else if ($format == PluginArchiresView::PLUGIN_ARCHIRES_PNG_FORMAT) {
  38. $format_graph = "png";
  39. } else if ($format == PluginArchiresView::PLUGIN_ARCHIRES_GIF_FORMAT) {
  40. $format_graph = "gif";
  41. } else if ($format == PluginArchiresView::PLUGIN_ARCHIRES_SVG_FORMAT) {
  42. $format_graph = "svg";
  43. }
  44. $object = $_GET["querytype"];
  45. $obj = new $object();
  46. $obj->getFromDB($_GET["id"]);
  47. $object_view = $obj->fields["plugin_archires_views_id"];
  48. if (!isset($_GET["plugin_archires_views_id"])) {
  49. $plugin_archires_views_id = $object_view;
  50. } else {
  51. $plugin_archires_views_id = $_GET["plugin_archires_views_id"];
  52. }
  53. $output_data = $PluginArchiresPrototype->createGraph($format_graph,$obj,$plugin_archires_views_id);
  54. if ($format == PluginArchiresView::PLUGIN_ARCHIRES_SVG_FORMAT) {
  55. header("Content-type: image/svg+xml");
  56. header('Content-Disposition: attachment; filename="image.svg"');
  57. } else {
  58. header("Content-Type: image/".$format_graph."");
  59. }
  60. header("Content-Length: ".strlen($output_data));
  61. echo $output_data;