2014-02-06 18:39:39 +01:00
< ? php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
require_once ( '../include/functions_visual_map.php' );
class Visualmap {
private $correct_acl = false ;
private $acl = " RR " ;
private $id = 0 ;
private $visual_map = null ;
function __construct () {
$system = System :: getInstance ();
if ( $system -> checkACL ( $this -> acl )) {
$this -> correct_acl = true ;
}
else {
$this -> correct_acl = false ;
}
}
private function getFilters () {
$system = System :: getInstance ();
$this -> id = ( int ) $system -> getRequest ( 'id' , 0 );
}
public function show () {
if ( ! $this -> correct_acl ) {
$this -> show_fail_acl ();
}
else {
$this -> getFilters ();
$this -> visualmap = db_get_row ( 'tlayout' ,
'id' , $this -> id );
$this -> show_visualmap ();
}
}
private function show_fail_acl () {
2014-10-15 18:12:51 +02:00
$error [ 'type' ] = 'onStart' ;
2014-02-06 18:39:39 +01:00
$error [ 'title_text' ] = __ ( 'You don\'t have access to this page' );
$error [ 'content_text' ] = __ ( 'Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database' );
2014-10-15 18:12:51 +02:00
if ( class_exists ( " HomeEnterprise " ))
$home = new HomeEnterprise ();
else
$home = new Home ();
2014-02-06 18:39:39 +01:00
$home -> show ( $error );
}
public function ajax ( $parameter2 = false ) {
$system = System :: getInstance ();
if ( ! $this -> correct_acl ) {
return ;
}
else {
switch ( $parameter2 ) {
case 'render_map' :
$map_id = $system -> getRequest ( 'map_id' , '0' );
$width = $system -> getRequest ( 'width' , '400' );
2014-10-13 17:49:22 +02:00
$height = $system -> getRequest ( 'height' , '400' );
visual_map_print_visual_map ( $map_id , false , true , $width , $height );
2014-02-06 18:39:39 +01:00
exit ;
}
}
}
private function show_visualmap () {
$ui = Ui :: getInstance ();
$system = System :: getInstance ();
$ui -> createPage ();
$ui -> createDefaultHeader (
sprintf ( " %s " ,
$this -> visualmap [ 'name' ]),
$ui -> createHeaderButton (
array ( 'icon' => 'back' ,
'pos' => 'left' ,
'text' => __ ( 'Back' ),
'href' => 'index.php?page=visualmaps' )));
$ui -> showFooter ( false );
$ui -> beginContent ();
ob_start ();
$rendered_map = '<div id="rendered_visual_map">' ;
$rendered_map .= html_print_image ( 'images/spinner.gif' , true );
$rendered_map .= '</div>' ;
ob_clean ();
$ui -> contentAddHtml ( $rendered_map );
$ui -> contentAddHtml ( " <script type= \" text/javascript \" >
function ajax_load_map () {
2014-02-10 18:03:08 +01:00
$ ( '#rendered_visual_map' ) . html ( '<div style=\"text-align: center\"> " . __(' Loading ... ') . "<br /><img src=\"images/ajax-loader.gif\" /></div>' );
2014-02-06 18:39:39 +01:00
var map_max_width = window . innerWidth * 0.90 ;
var map_max_height = ( window . innerHeight - 47 ) * 0.90 ;
var original_width = " . $this->visualmap ['width'] . " ;
var original_height = " . $this->visualmap ['height'] . " ;
var map_width = map_max_width ;
var map_height = original_height / ( original_width / map_width );
if ( map_height > map_max_height ) {
map_height = map_max_height ;
map_width = original_width / ( original_height / map_height );
}
postvars = {};
postvars [ \ " action \" ] = \" ajax \" ;
postvars [ \ " parameter1 \" ] = \" visualmap \" ;
postvars [ \ " parameter2 \" ] = \" render_map \" ;
postvars [ \ " map_id \" ] = \" " . $this -> id . " \" ;
postvars [ \ " width \" ] = map_width;
2014-10-13 17:49:22 +02:00
postvars [ \ " height \" ] = map_height;
2014-02-06 18:39:39 +01:00
$ . post ( \ " index.php \" ,
postvars ,
function ( data ) {
$ ( '#rendered_visual_map' ) . html ( data );
},
\ " html \" );
}
ajax_load_map ();
2014-02-10 18:03:08 +01:00
// Detect orientation change to refresh dinamic content
$ ( window ) . on ({
orientationchange : function ( e ) {
ajax_load_map ();
}
2014-02-06 18:39:39 +01:00
});
</ script > " );
$ui -> endContent ();
$ui -> showPage ();
}
}
?>