From 5a138d4c0464b591177cf523ebb8e0603e32d650 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Mon, 28 Dec 2009 15:47:42 +0100 Subject: replace duplicate code by function rrd_options --- type/Default.class.php | 12 +++++++++--- type/GenericIO.class.php | 8 +------- type/GenericStacked.class.php | 8 +------- 3 files changed, 11 insertions(+), 17 deletions(-) (limited to 'type') diff --git a/type/Default.class.php b/type/Default.class.php index f40d12d..817521a 100644 --- a/type/Default.class.php +++ b/type/Default.class.php @@ -84,9 +84,7 @@ class Type_Default { } } - function rrd_gen_graph() { - $filename = $this->get_filename(); - + function rrd_options() { $rrdgraph[] = '/usr/bin/rrdtool graph - -a PNG'; $rrdgraph[] = sprintf('-w %d', is_numeric($this->width) ? $this->width : 400); $rrdgraph[] = sprintf('-h %d', is_numeric($this->heigth) ? $this->heigth : 175); @@ -95,6 +93,14 @@ class Type_Default { $rrdgraph[] = sprintf('-v "%s"', $this->rrd_vertical); $rrdgraph[] = sprintf('-s -%d', is_numeric($this->seconds) ? $this->seconds : 86400); + return $rrdgraph; + } + + function rrd_gen_graph() { + $filename = $this->get_filename(); + + $rrdgraph = $this->rrd_options(); + if (is_array($this->args['tinstance'])) $array = is_array($this->order) ? $this->order : $this->args['tinstance']; else diff --git a/type/GenericIO.class.php b/type/GenericIO.class.php index 573abde..e91cb16 100644 --- a/type/GenericIO.class.php +++ b/type/GenericIO.class.php @@ -7,13 +7,7 @@ class Type_GenericIO extends Type_Default { function rrd_gen_graph() { $filename = $this->get_filename(); - $rrdgraph[] = '/usr/bin/rrdtool graph - -a PNG'; - $rrdgraph[] = sprintf('-w %d', is_numeric($this->width) ? $this->width : 400); - $rrdgraph[] = sprintf('-h %d', is_numeric($this->heigth) ? $this->heigth : 175); - $rrdgraph[] = '-l 0'; - $rrdgraph[] = sprintf('-t "%s"', $this->rrd_title); - $rrdgraph[] = sprintf('-v "%s"', $this->rrd_vertical); - $rrdgraph[] = sprintf('-s -%d', is_numeric($this->seconds) ? $this->seconds : 86400); + $rrdgraph = $this->rrd_options(); if ($this->scale) $raw = '_raw'; diff --git a/type/GenericStacked.class.php b/type/GenericStacked.class.php index 28f0552..f024336 100644 --- a/type/GenericStacked.class.php +++ b/type/GenericStacked.class.php @@ -5,13 +5,7 @@ require_once 'Default.class.php'; class Type_GenericStacked extends Type_Default { function rrd_gen_graph() { - $rrdgraph[] = '/usr/bin/rrdtool graph - -a PNG'; - $rrdgraph[] = sprintf('-w %d', is_numeric($this->width) ? $this->width : 400); - $rrdgraph[] = sprintf('-h %d', is_numeric($this->heigth) ? $this->heigth : 175); - $rrdgraph[] = '-l 0'; - $rrdgraph[] = sprintf('-t "%s"', $this->rrd_title); - $rrdgraph[] = sprintf('-v "%s"', $this->rrd_vertical); - $rrdgraph[] = sprintf('-s -%d', is_numeric($this->seconds) ? $this->seconds : 86400); + $rrdgraph = $this->rrd_options(); if (is_array($this->args['tinstance'])) if (is_array($this->order)) -- cgit v1.1