.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2018 Tony Murray
* @author Tony Murray
*/
namespace LibreNMS\Util;
use HTMLPurifier;
use HTMLPurifier_Config;
use LibreNMS\Config;
class Html
{
/**
* Print or return a row of graphs
*
* @param array $graph_array
* @param bool $print
* @return array
*/
public static function graphRow($graph_array, $print = false)
{
if (session('widescreen')) {
if (!array_key_exists('height', $graph_array)) {
$graph_array['height'] = '110';
}
if (!array_key_exists('width', $graph_array)) {
$graph_array['width'] = '215';
}
$periods = Config::get('graphs.mini.widescreen');
} else {
if (!array_key_exists('height', $graph_array)) {
$graph_array['height'] = '100';
}
if (!array_key_exists('width', $graph_array)) {
$graph_array['width'] = '215';
}
$periods = Config::get('graphs.mini.normal');
}
$screen_width = session('screen_width');
if ($screen_width) {
if ($screen_width < 1024 && $screen_width > 700) {
$graph_array['width'] = round(($screen_width - 90) / 2, 0);
} elseif ($screen_width > 1024) {
$graph_array['width'] = round(($screen_width - 90) / count($periods) + 1, 0);
} else {
$graph_array['width'] = $screen_width - 70;
}
}
$graph_array['height'] = round($graph_array['width'] / 2.15);
$graph_data = [];
foreach ($periods as $period => $period_text) {
$graph_array['from'] = Config::get("time.$period");
$graph_array_zoom = $graph_array;
$graph_array_zoom['height'] = '150';
$graph_array_zoom['width'] = '400';
$link_array = $graph_array;
$link_array['page'] = 'graphs';
unset($link_array['height'], $link_array['width']);
$link = Url::generate($link_array);
$full_link = Url::overlibLink($link, Url::lazyGraphTag($graph_array), Url::graphTag($graph_array_zoom), null);
$graph_data[] = $full_link;
if ($print) {
echo "$full_link
";
}
}
return $graph_data;
}
public static function percentageBar($width, $height, $percent, $left_text, $left_colour, $left_background, $right_text, $right_colour, $right_background)
{
if ($percent > '100') {
$size_percent = '100';
} else {
$size_percent = $percent;
}
$output = '
'.$left_text.'
'.$right_text.'
';
return $output;
}
}