2013-06-07 11:44:37 +02:00
|
|
|
<?php
|
2013-06-11 11:09:28 +02:00
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
2013-06-07 11:44:37 +02:00
|
|
|
|
|
|
|
namespace Icinga\Web\Hook;
|
|
|
|
|
2014-08-27 09:35:43 +02:00
|
|
|
use Icinga\Exception\ProgrammingError;
|
|
|
|
|
2013-06-07 11:44:37 +02:00
|
|
|
/**
|
|
|
|
* Icinga Web Grapher Hook base class
|
|
|
|
*
|
|
|
|
* Extend this class if you want to integrate your graphing solution nicely into
|
|
|
|
* Icinga Web
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2013 Icinga-Web Team <info@icinga.org>
|
|
|
|
* @author Icinga-Web Team <info@icinga.org>
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
|
|
|
*/
|
2014-08-27 09:35:43 +02:00
|
|
|
abstract class GrapherHook
|
2013-06-07 11:44:37 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Whether this grapher provides preview images
|
|
|
|
*
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
protected $hasPreviews = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor must live without arguments right now
|
|
|
|
*
|
|
|
|
* Therefore the constructor is final, we might change our opinion about
|
|
|
|
* this one far day
|
|
|
|
*/
|
|
|
|
final public function __construct()
|
|
|
|
{
|
|
|
|
$this->init();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether this grapher provides preview images
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function hasPreviews()
|
|
|
|
{
|
|
|
|
return $this->hasPreviews;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Overwrite this function if you want to do some initialization stuff
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function init()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether a graph for the given host[, service [, plot]] exists
|
|
|
|
*
|
2014-08-27 09:35:43 +02:00
|
|
|
* @param string $host
|
|
|
|
* @param string $service
|
|
|
|
* @param string $plot
|
|
|
|
*
|
2013-06-07 11:44:37 +02:00
|
|
|
* @return bool
|
|
|
|
*/
|
2014-08-27 09:35:43 +02:00
|
|
|
public function has($host, $service = null, $plot = null)
|
2013-06-07 11:44:37 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a preview image for the given host[, service [, plot]] exists
|
|
|
|
*
|
2014-08-27 09:35:43 +02:00
|
|
|
* @param string $host
|
|
|
|
* @param string $service
|
|
|
|
* @param string $plot
|
2013-06-07 11:44:37 +02:00
|
|
|
*
|
2014-08-27 09:35:43 +02:00
|
|
|
* @return string
|
|
|
|
*
|
|
|
|
* @throws ProgrammingError
|
2013-06-07 11:44:37 +02:00
|
|
|
*/
|
2014-08-27 09:35:43 +02:00
|
|
|
public function getPreviewHtml($host, $service = null, $plot = null)
|
2013-06-07 11:44:37 +02:00
|
|
|
{
|
2014-08-27 09:35:43 +02:00
|
|
|
throw new ProgrammingError('This backend has no preview images');
|
2013-06-07 11:44:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-08-27 09:35:43 +02:00
|
|
|
* Whether a tiny graph for the given host[, service [, plot]] exists
|
2013-06-07 11:44:37 +02:00
|
|
|
*
|
2014-08-27 09:35:43 +02:00
|
|
|
* @param string $host
|
|
|
|
* @param string $service
|
|
|
|
* @param string $plot
|
2013-06-07 11:44:37 +02:00
|
|
|
*
|
2014-08-27 09:35:43 +02:00
|
|
|
* @return bool
|
2013-06-07 11:44:37 +02:00
|
|
|
*/
|
2014-08-27 09:35:43 +02:00
|
|
|
public function hasTinyPreview($host, $service = null, $plot = null)
|
2013-06-07 11:44:37 +02:00
|
|
|
{
|
2014-08-27 09:35:43 +02:00
|
|
|
return false;
|
2013-06-07 11:44:37 +02:00
|
|
|
}
|
2014-08-27 09:35:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a tiny preview image for the given host[, service [, plot]] exists
|
|
|
|
*
|
|
|
|
* @param string $host
|
|
|
|
* @param string $service
|
|
|
|
* @param string $plot
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*
|
|
|
|
* @throws ProgrammingError
|
|
|
|
*/
|
|
|
|
public function getTinyPreviewHtml($host, $service = null, $plot = null)
|
|
|
|
{
|
|
|
|
throw new ProgrammingError('This backend has no tiny preview images');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get URL pointing to the grapher
|
|
|
|
*
|
|
|
|
* WARNING: We are not sure yet whether this will remain as is
|
|
|
|
*
|
|
|
|
* @param string $host
|
|
|
|
* @param string $service
|
|
|
|
* @param string $plot
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract function getGraphUrl($host, $service = null, $plot = null);
|
2013-06-07 11:44:37 +02:00
|
|
|
}
|