summaryrefslogtreecommitdiffstats
path: root/pts-core/objects
diff options
context:
space:
mode:
Diffstat (limited to 'pts-core/objects')
-rw-r--r--pts-core/objects/pts_BarGraph.php16
-rw-r--r--pts-core/objects/pts_CustomGraph.php5
-rw-r--r--pts-core/objects/pts_Graph.php181
-rw-r--r--pts-core/objects/pts_LineGraph.php14
-rw-r--r--pts-core/objects/pts_MultiPassFailGraph.php22
-rw-r--r--pts-core/objects/pts_PassFailGraph.php12
-rw-r--r--pts-core/objects/pts_module.php55
-rw-r--r--pts-core/objects/pts_module_interface.php22
-rw-r--r--pts-core/objects/pts_module_option.php6
-rw-r--r--pts-core/objects/pts_test_tandem_XmlReader.php2
-rw-r--r--pts-core/objects/tandem_XmlReader.php62
-rw-r--r--pts-core/objects/tandem_XmlWriter.php46
12 files changed, 346 insertions, 97 deletions
diff --git a/pts-core/objects/pts_BarGraph.php b/pts-core/objects/pts_BarGraph.php
index a2e3b2e..15775f2 100644
--- a/pts-core/objects/pts_BarGraph.php
+++ b/pts-core/objects/pts_BarGraph.php
@@ -60,17 +60,25 @@ class pts_BarGraph extends pts_CustomGraph
$px_bound_right = $px_bound_left + $this->identifier_width;
if($i == 0)
+ {
$this->draw_line($this->graph_image, $px_bound_left, $px_from_top_start, $px_bound_left, $px_from_top_end, $this->graph_color_notches);
+ }
if($i == (count($this->graph_identifiers) - 1) && $px_bound_right != $this->graph_left_end)
+ {
$px_bound_right = $this->graph_left_end;
+ }
$this->draw_line($this->graph_image, $px_bound_right, $px_from_top_start, $px_bound_right, $px_from_top_end, $this->graph_color_notches);
if($this->graph_font_size_identifiers == $this->minimum_identifier_font)
- $this->write_text_left($this->graph_identifiers[$i], 9, $this->graph_color_headers, $px_bound_left + ceil($this->identifier_width / 2), $px_from_top_end, $px_bound_left + ceil($this->identifier_width / 2), $px_from_top_end, TRUE);
+ {
+ $this->write_text_left($this->graph_identifiers[$i], 9, $this->graph_color_headers, $px_bound_left + ceil($this->identifier_width / 2), $px_from_top_end, $px_bound_left + ceil($this->identifier_width / 2), $px_from_top_end, true);
+ }
else
- $this->write_text_center($this->graph_identifiers[$i], $this->graph_font_size_identifiers, $this->graph_color_headers, $px_bound_left, $px_from_top_end - 5, $px_bound_right, $px_from_top_end - 5, FALSE, TRUE);
+ {
+ $this->write_text_center($this->graph_identifiers[$i], $this->graph_font_size_identifiers, $this->graph_color_headers, $px_bound_left, $px_from_top_end - 5, $px_bound_right, $px_from_top_end - 5, false, true);
+ }
}
}
protected function render_graph_bars()
@@ -92,13 +100,17 @@ class pts_BarGraph extends pts_CustomGraph
$px_bound_right = $px_bound_left + $bar_width;
if($value_plot_top < 1)
+ {
$value_plot_top = 1;
+ }
$this->draw_rectangle_border($this->graph_image, $px_bound_left, $value_plot_top - 1, $px_bound_right, $this->graph_top_end - 1, $this->graph_color_body_light);
$this->draw_rectangle($this->graph_image, $px_bound_left + 1, $value_plot_top, $px_bound_right - 1, $this->graph_top_end - 1, $paint_color);
if($graph_size > 20)
+ {
$this->write_text_center($this->graph_data[$i_o][$i], $this->graph_font_size_bars, $this->graph_color_body_text, $px_bound_left, $value_plot_top + 3, $px_bound_right, $value_plot_top + 3);
+ }
}
}
}
diff --git a/pts-core/objects/pts_CustomGraph.php b/pts-core/objects/pts_CustomGraph.php
index 3e46ff4..59432f2 100644
--- a/pts-core/objects/pts_CustomGraph.php
+++ b/pts-core/objects/pts_CustomGraph.php
@@ -26,9 +26,14 @@ class pts_CustomGraph extends pts_Graph
function __construct($Title, $SubTitle, $YTitle)
{
if(is_file(PTS_USER_DIR . "graph-config.xml"))
+ {
$file = file_get_contents(PTS_USER_DIR . "graph-config.xml");
+ }
else
+ {
$file = "";
+ }
+
$read_config = new tandem_XmlReader($file);
$this->graph_attr_width = pts_read_graph_config(P_GRAPH_SIZE_WIDTH, null, $read_config); // Graph width
diff --git a/pts-core/objects/pts_Graph.php b/pts-core/objects/pts_Graph.php
index 38bc318..911dd79 100644
--- a/pts-core/objects/pts_Graph.php
+++ b/pts-core/objects/pts_Graph.php
@@ -27,7 +27,7 @@ class pts_Graph
var $graph_attr_marks = 6; // Number of marks to make on vertical axis
var $graph_attr_width = 580; // Graph width
var $graph_attr_height = 300; // Graph height
- var $graph_attr_big_border = FALSE; // Border around graph or not
+ var $graph_attr_big_border = false; // Border around graph or not
var $graph_left_start = 20; // Distance in px to start graph from left side
var $graph_left_end_opp = 10; // Distance in px to end graph from right side
@@ -63,10 +63,10 @@ class pts_Graph
// CHANGE DIRECTORY FOR TTF FONT LOCATION INSIDE __construct FUNCTION
// Not user-friendly changes below this line
- var $graph_body_image = FALSE;
- var $graph_hide_identifiers = FALSE;
- var $graph_show_key = FALSE;
- var $graph_background_lines = FALSE;
+ var $graph_body_image = false;
+ var $graph_hide_identifiers = false;
+ var $graph_show_key = false;
+ var $graph_background_lines = false;
var $graph_type = "GRAPH";
var $graph_value_type = "NUMERICAL";
var $graph_image;
@@ -81,7 +81,7 @@ class pts_Graph
var $graph_title;
var $graph_sub_title;
var $graph_y_title;
- var $graph_y_title_hide = FALSE;
+ var $graph_y_title_hide = false;
var $graph_top_end;
var $graph_left_end;
@@ -97,11 +97,17 @@ class pts_Graph
// Directory for TTF Fonts
if(defined("FONT_DIR"))
+ {
putenv("GDFONTPATH=" . FONT_DIR);
- else if(($font_env = getenv("FONT_DIR")) != FALSE)
+ }
+ else if(($font_env = getenv("FONT_DIR")) != false)
+ {
putenv("GDFONTPATH=" . $font_env);
+ }
else
+ {
putenv("GDFONTPATH=" . getcwd());
+ }
}
public function setRenderer($Renderer)
{
@@ -111,7 +117,9 @@ class pts_Graph
$this->graph_left_start += 10;
}
else
+ {
$this->graph_renderer = "PNG";
+ }
}
public function getRenderer()
{
@@ -133,12 +141,16 @@ class pts_Graph
public function loadGraphVersion($data)
{
if(!empty($data))
+ {
$this->graph_version = "Phoronix Test Suite " . $data;
+ }
}
public function loadGraphProportion($data)
{
if($data == "LIB")
+ {
$this->graph_proportion = "Less Is Better";
+ }
//else if($data == "HIB")
// $this->graph_proportion = "More Is Better";
}
@@ -146,23 +158,31 @@ class pts_Graph
{
loadGraphValues($data_array);
}
- public function loadGraphValues($data_array, $data_title = NULL)
+ public function loadGraphValues($data_array, $data_title = null)
{
for($i = 0; $i < count($data_array); $i++)
+ {
if(is_float($data_array[$i]))
+ {
$data_array[$i] = $this->trim_double($data_array[$i], 2);
+ }
+ }
array_push($this->graph_data, $data_array);
if(!empty($data_title))
+ {
array_push($this->graph_data_title, $data_title);
+ }
}
public function setGraphBackgroundPNG($File)
{
$IMG = $this->read_png_image($File);
- if($IMG != FALSE)
+ if($IMG != false)
+ {
$this->graph_body_image = $IMG;
+ }
}
//
@@ -191,12 +211,20 @@ class pts_Graph
$maximum = $this->graph_attr_marks;
foreach($this->graph_data as $graph_set)
+ {
foreach($graph_set as $set_item)
+ {
if((is_numeric($set_item) && $set_item > $maximum) || (!is_numeric($set_item) && strlen($set_item) > strlen($maximum)))
+ {
$maximum = $set_item;
+ }
+ }
+ }
if(is_numeric($maximum))
+ {
$maximum = (floor(round($maximum * 1.35) / $this->graph_attr_marks) + 1) * $this->graph_attr_marks;
+ }
return $maximum;
}
@@ -216,11 +244,14 @@ class pts_Graph
$px_length = 0;
foreach($arr_string as $one_string)
+ {
if(($new_length = strlen($one_string)) > strlen($longest_string))
{
$longest_string = $one_string;
$px_length = $new_length;
}
+ }
+
return $longest_string;
}
protected function update_graph_dimensions($width = -1, $height = -1, $recalculate_offsets = false)
@@ -268,17 +299,21 @@ class pts_Graph
$this->graph_color_body_light = $this->convert_hex_to_type($this->graph_color_body_light);
for($i = 0; $i < count($this->graph_color_paint); $i++)
+ {
$this->graph_color_paint[$i] = $this->convert_hex_to_type($this->graph_color_paint[$i]);
+ }
// Background Color
$this->draw_rectangle($this->graph_image, 0, 0, $this->graph_attr_width, $this->graph_attr_height, $this->graph_color_background);
- if($this->graph_attr_big_border == TRUE)
+ if($this->graph_attr_big_border == true)
+ {
$this->draw_rectangle_border($this->graph_image, 0, 0, $this->graph_attr_width - 1, $this->graph_attr_height - 1, $this->graph_color_border);
+ }
}
protected function render_graph_base()
{
- if(count($this->graph_data_title) > 1 || $this->graph_show_key == TRUE)
+ if(count($this->graph_data_title) > 1 || $this->graph_show_key == true)
{
$num_key_lines = ceil(count($this->graph_data_title) / 4);
$this->graph_top_start = $this->graph_top_start + 8 + ($num_key_lines * 11);
@@ -287,16 +322,15 @@ class pts_Graph
$this->draw_rectangle($this->graph_image, $this->graph_left_start, $this->graph_top_start, $this->graph_left_end, $this->graph_top_end, $this->graph_color_body);
$this->draw_rectangle_border($this->graph_image, $this->graph_left_start, $this->graph_top_start, $this->graph_left_end, $this->graph_top_end, $this->graph_color_notches);
- if($this->graph_body_image != FALSE && $this->graph_renderer == "PNG")
+ if($this->graph_body_image != false && $this->graph_renderer == "PNG")
{
imagecopymerge($this->graph_image, $this->graph_body_image, $this->graph_left_start + (($this->graph_left_end - $this->graph_left_start) / 2) - imagesx($this->graph_body_image) / 2, $this->graph_top_start + (($this->graph_top_end - $this->graph_top_start) / 2) - imagesy($this->graph_body_image) / 2, 0, 0, imagesx($this->graph_body_image), imagesy($this->graph_body_image), 95);
-
}
// Text
$this->write_text_right($this->graph_version, 7, $this->graph_color_body_light, $this->graph_left_end, $this->graph_top_start - 9, $this->graph_left_end, $this->graph_top_start - 9);
$this->write_text_center($this->graph_title, $this->graph_font_size_heading, $this->graph_color_main_headers, $this->graph_left_start, 4, $this->graph_left_end, 4);
- $this->write_text_center($this->graph_sub_title, $this->graph_font_size_sub_heading, $this->graph_color_main_headers, $this->graph_left_start, 26, $this->graph_left_end, 26, FALSE, TRUE);
+ $this->write_text_center($this->graph_sub_title, $this->graph_font_size_sub_heading, $this->graph_color_main_headers, $this->graph_left_start, 26, $this->graph_left_end, 26, false, true);
if(!empty($this->graph_y_title) && !$this->graph_y_title_hide)
{
@@ -305,13 +339,15 @@ class pts_Graph
if(!empty($this->graph_proportion))
{
if(!empty($str))
+ {
$str .= ", ";
+ }
$str .= $this->graph_proportion;
}
$this->write_text_left($str, 7, $this->graph_color_main_headers, $this->graph_left_start, $this->graph_top_start - 9, $this->graph_left_start, $this->graph_top_start - 9);
- //$this->write_text_center($this->graph_y_title, $this->graph_font_size_axis_heading, $this->graph_color_headers, 3, $this->graph_top_start, 3, $this->graph_top_end, TRUE);
+ //$this->write_text_center($this->graph_y_title, $this->graph_font_size_axis_heading, $this->graph_color_headers, 3, $this->graph_top_start, 3, $this->graph_top_end, true);
}
}
protected function render_graph_value_ticks()
@@ -330,14 +366,20 @@ class pts_Graph
$this->write_text_right($display_value, $this->graph_font_size_tick_mark, $this->graph_color_text, $px_from_left_start - 1, $px_from_top - 2, $px_from_left_start - 1, $px_from_top - 2);
- if($i != 0 && $this->graph_background_lines == TRUE)
+ if($i != 0 && $this->graph_background_lines == true)
{
$line_width = 6;
for($y = $px_from_left_end + $line_width; $y < $this->graph_left_end; $y += ($line_width * 2))
+ {
if($y + $line_width < $this->graph_left_end)
+ {
$this->draw_line($this->graph_image, $y, $px_from_top, $y += $line_width, $px_from_top, $this->graph_color_body_light);
+ }
else
+ {
$this->draw_line($this->graph_image, $y, $px_from_top, $y += ($this->graph_left_end - $y) - 1, $px_from_top, $this->graph_color_body_light);
+ }
+ }
}
$display_value += $this->trim_double($this->graph_maximum_value / $this->graph_attr_marks, 2);
@@ -349,10 +391,14 @@ class pts_Graph
// Make room for tick markings, left hand side
if($this->graph_value_type == "NUMERICAL")
+ {
$this->graph_left_start += $this->return_ttf_string_width($this->graph_maximum_value, $this->graph_font, $this->graph_font_size_tick_mark) + 2;
+ }
- if($this->graph_hide_identifiers == TRUE)
+ if($this->graph_hide_identifiers == true)
+ {
$this->graph_top_end += $this->graph_top_end_opp / 2;
+ }
// Do the actual work
$this->render_graph_pre_init();
@@ -360,10 +406,14 @@ class pts_Graph
$this->render_graph_base();
if(!$this->graph_hide_identifiers)
+ {
$this->render_graph_identifiers();
+ }
if($this->graph_value_type == "NUMERICAL")
+ {
$this->render_graph_value_ticks();
+ }
$this->render_graph_key();
$this->render_graph_result();
@@ -380,8 +430,10 @@ class pts_Graph
}
protected function render_graph_key()
{
- if(count($this->graph_data_title) < 2 && $this->graph_show_key == FALSE)
+ if(count($this->graph_data_title) < 2 && $this->graph_show_key == false)
+ {
return;
+ }
$key_counter = 0;
$component_y = $this->graph_top_start - 20;
@@ -403,18 +455,19 @@ class pts_Graph
$this->draw_rectangle_border($this->graph_image, $component_x - 13, $component_y - 5, $component_x - 3, $component_y + 5, $this->graph_color_notches);
if($key_counter % 4 == 0)
+ {
$component_y -= 12;
+ }
}
}
$this->reset_paint_index();
}
protected function render_graph_watermark()
{
- if(empty($this->graph_watermark_text))
- return;
-
- $this->write_text_right($this->graph_watermark_text, 10, $this->graph_color_text, $this->graph_left_end - 2, $this->graph_top_start + 8, $this->graph_left_end - 2, $this->graph_top_start + 8);
-
+ if(!empty($this->graph_watermark_text))
+ {
+ $this->write_text_right($this->graph_watermark_text, 10, $this->graph_color_text, $this->graph_left_end - 2, $this->graph_top_start + 8, $this->graph_left_end - 2, $this->graph_top_start + 8);
+ }
}
protected function return_graph_image()
{
@@ -431,22 +484,32 @@ class pts_Graph
$return = explode(".", $double);
if(count($return) == 1)
+ {
$return[1] = "00";
+ }
if(count($return) == 2 && $accuracy > 0)
{
$strlen = strlen($return[1]);
if($strlen > $accuracy)
+ {
$return[1] = substr($return[1], 0, $accuracy);
+ }
else if($strlen < $accuracy)
+ {
for($i = $strlen; $i < $accuracy; $i++)
+ {
$return[1] .= '0';
+ }
+ }
$return = $return[0] . "." . $return[1];
}
else
+ {
$return = $return[0];
+ }
return $return;
}
@@ -469,14 +532,18 @@ class pts_Graph
imageinterlace($img, true);
if(function_exists("imageantialias"))
+ {
imageantialias($img, true);
+ }
}
else if($this->graph_renderer == "SVG")
{
$img = "<?xml version=\"1.0\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
foreach($this->graph_user_identifiers as $key => $value)
+ {
$img .= "<!-- " . $key . ": " . $value . " -->\n";
+ }
$img .= "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewbox=\"0 0 " . $width . " " . $height . "\" width=\"" . $width . "\" height=\"" . $height . "\">\n\n";
}
@@ -486,42 +553,62 @@ class pts_Graph
protected function render_image(&$img_object, $output_file = null, $quality = 0)
{
if($this->graph_renderer == "PNG")
+ {
imagepng($img_object, $output_file, $quality);
+ }
else if($this->graph_renderer == "SVG")
{
$img_object .= "\n\n</svg>";
if($output_file != null)
+ {
@file_put_contents($output_file, $img_object);
+ }
}
}
protected function read_png_image($File)
{
if($this->graph_renderer == "PNG")
+ {
$img = @imagecreatefrompng($File);
+ }
+ else
+ {
+ $img = null;
+ }
return $img;
}
protected function deinit_image(&$img_object)
{
if($this->graph_renderer == "PNG")
+ {
imagedestroy($img_object);
+ }
else if($this->graph_renderer == "SVG")
+ {
$img_object = null;
+ }
}
protected function convert_hex_to_type($Hex)
{
if($this->graph_renderer == "PNG")
+ {
$color = imagecolorallocate($this->graph_image, hexdec(substr($Hex, 1, 2)), hexdec(substr($Hex, 3, 2)), hexdec(substr($Hex, 5, 2)));
+ }
else if($this->graph_renderer == "SVG")
+ {
$color = $Hex;
+ }
return $color;
}
- protected function write_text_left($text_string, $font_size, $font_color, $bound_x1, $bound_y1, $bound_x2, $bound_y2, $rotate = FALSE)
+ protected function write_text_left($text_string, $font_size, $font_color, $bound_x1, $bound_y1, $bound_x2, $bound_y2, $rotate = false)
{
if(empty($text_string))
+ {
return;
+ }
if($this->graph_renderer == "PNG")
{
@@ -529,7 +616,7 @@ class pts_Graph
$ttf_width = $ttf_dimensions[0];
$ttf_height = $ttf_dimensions[1];
- if($rotate == FALSE)
+ if($rotate == false)
{
$text_x = $bound_x1;
$text_y = $bound_y1 + round($ttf_height / 2);
@@ -549,7 +636,7 @@ class pts_Graph
$ttf_width = $ttf_dimensions[0];
$ttf_height = $ttf_dimensions[1];
- if($rotate == FALSE)
+ if($rotate == false)
{
$text_x = $bound_x1;
$text_y = $bound_y1 + round($ttf_height / 2);
@@ -564,10 +651,12 @@ class pts_Graph
$this->write_svg_text($this->graph_image, $font_size, $rotation, $text_x, $text_y, $font_color, $this->graph_font, $text_string, "LEFT");
}
}
- protected function write_text_right($text_string, $font_size, $font_color, $bound_x1, $bound_y1, $bound_x2, $bound_y2, $rotate_text = FALSE)
+ protected function write_text_right($text_string, $font_size, $font_color, $bound_x1, $bound_y1, $bound_x2, $bound_y2, $rotate_text = false)
{
if(empty($text_string))
+ {
return;
+ }
if($this->graph_renderer == "PNG")
{
@@ -575,10 +664,14 @@ class pts_Graph
$ttf_width = $ttf_dimensions[0];
$ttf_height = $ttf_dimensions[1];
- if($rotate_text == FALSE)
+ if($rotate_text == false)
+ {
$rotation = 0;
+ }
else
+ {
$rotation = 90;
+ }
$text_x = $bound_x2 - $ttf_width;
$text_y = $bound_y1 + round($ttf_height / 2);
@@ -594,10 +687,14 @@ class pts_Graph
$bound_x1 -= 2;
$bound_x2 -= 2;
- if($rotate_text == FALSE)
+ if($rotate_text == false)
+ {
$rotation = 0;
+ }
else
+ {
$rotation = 90;
+ }
$text_x = $bound_x2 - $ttf_width;
$text_y = $bound_y1 + round($ttf_height / 2);
@@ -605,10 +702,12 @@ class pts_Graph
$this->write_svg_text($this->graph_image, $font_size, $rotation, $text_x, $text_y, $font_color, $this->graph_font, $text_string, "RIGHT");
}
}
- protected function write_text_center($text_string, $font_size, $font_color, $bound_x1, $bound_y1, $bound_x2, $bound_y2, $rotate_text = FALSE, $big_type = FALSE)
+ protected function write_text_center($text_string, $font_size, $font_color, $bound_x1, $bound_y1, $bound_x2, $bound_y2, $rotate_text = false, $big_type = false)
{
if(empty($text_string))
+ {
return;
+ }
if($this->graph_renderer == "PNG")
{
@@ -622,7 +721,7 @@ class pts_Graph
$ttf_dimensions = $this->return_ttf_string_dimensions($text_string, $this->graph_font, $font_size, $big_type);
$ttf_width = $ttf_dimensions[0];
- if($rotate_text == FALSE)
+ if($rotate_text == false)
{
$rotation = 0;
$text_x = (($bound_x2 - $bound_x1) / 2) + $bound_x1 - round($ttf_width / 2);
@@ -649,7 +748,7 @@ class pts_Graph
$ttf_dimensions = $this->return_ttf_string_dimensions($text_string, $this->graph_font, $font_size, $big_type);
$ttf_width = $ttf_dimensions[0];
- if($rotate_text == FALSE)
+ if($rotate_text == false)
{
$rotation = 0;
$text_x = (($bound_x2 - $bound_x1) / 2) + $bound_x1 - round($ttf_width / 2);
@@ -697,16 +796,22 @@ class pts_Graph
protected function draw_rectangle(&$img_object, $x1, $y1, $width, $height, $background_color)
{
if($this->graph_renderer == "PNG")
+ {
imagefilledrectangle($img_object, $x1, $y1, $width, $height, $background_color);
+ }
else if($this->graph_renderer == "SVG")
{
$width = $width - $x1;
$height = $height - $y1;
if($width < 0)
+ {
$x1 += $width;
+ }
if($height < 0)
+ {
$y1 += $height;
+ }
$img_object .= "<rect x=\"" . $x1 . "\" y=\"" . $y1 . "\" width=\"" . abs($width) . "\" height=\"" . abs($height) . "\" fill=\"" . $background_color . "\" />\n";
}
@@ -714,18 +819,26 @@ class pts_Graph
protected function draw_rectangle_border(&$img_object, $x1, $y1, $width, $height, $color)
{
if($this->graph_renderer == "PNG")
+ {
imagerectangle($img_object, $x1, $y1, $width, $height, $color);
+ }
else if($this->graph_renderer == "SVG")
+ {
$img_object .= "<rect x=\"" . $x1 . "\" y=\"" . $y1 . "\" width=\"" . ($width - $x1) . "\" height=\"" . ($height - $y1) . "\" fill=\"transparent\" stroke=\"" . $color . "\" stroke-width=\"1px\" />\n";
+ }
}
protected function draw_line(&$img_object, $left_start, $top_start, $from_left, $from_top, $color)
{
if($this->graph_renderer == "PNG")
+ {
imageline($img_object, $left_start, $top_start, $from_left, $from_top, $color);
+ }
else if($this->graph_renderer == "SVG")
+ {
$img_object .= "<line x1=\"" . $left_start . "\" y1=\"" . $top_start . "\" x2=\"" . $from_left . "\" y2=\"" . $from_top . "\" stroke=\"" . $color . "\" stroke-width=\"1px\" />\n";
+ }
}
- protected function return_ttf_string_dimensions($String, $Font, $Size, $Big = FALSE)
+ protected function return_ttf_string_dimensions($String, $Font, $Size, $Big = false)
{
if($this->graph_renderer == "PNG" && function_exists("imagettfbbox"))
{
@@ -733,7 +846,9 @@ class pts_Graph
$box_width = $box_array[4] - $box_array[6];
if($Big)
+ {
$box_array = imagettfbbox($Size, 0, $Font, "AZ@![]()@|_");
+ }
$box_height = $box_array[1] - $box_array[7];
}
else if($this->graph_renderer == "SVG")
diff --git a/pts-core/objects/pts_LineGraph.php b/pts-core/objects/pts_LineGraph.php
index 09ce2ff..9955009 100644
--- a/pts-core/objects/pts_LineGraph.php
+++ b/pts-core/objects/pts_LineGraph.php
@@ -30,8 +30,8 @@ class pts_LineGraph extends pts_CustomGraph
{
parent::__construct($Title, $SubTitle, $YTitle);
$this->graph_type = "LINE_GRAPH";
- $this->graph_show_key = TRUE;
- $this->graph_background_lines = TRUE;
+ $this->graph_show_key = true;
+ $this->graph_background_lines = true;
}
protected function render_graph_pre_init()
{
@@ -63,9 +63,13 @@ class pts_LineGraph extends pts_CustomGraph
$this->draw_line($this->graph_image, $px_from_left, $px_from_top_start, $px_from_left, $px_from_top_end, $this->graph_color_notches);
if($this->graph_font_size_identifiers == $this->minimum_identifier_font)
- $this->write_text_left($this->graph_identifiers[$i], 9, $this->graph_color_headers, $px_from_left, $px_from_top_end + 2, $px_from_left, $px_from_top_end + 2, TRUE);
+ {
+ $this->write_text_left($this->graph_identifiers[$i], 9, $this->graph_color_headers, $px_from_left, $px_from_top_end + 2, $px_from_left, $px_from_top_end + 2, true);
+ }
else
+ {
$this->write_text_center($this->graph_identifiers[$i], $this->graph_font_size_identifiers, $this->graph_color_headers, $px_from_left, $px_from_top_end + 2, $px_from_left, $px_from_top_end + 2);
+ }
}
}
protected function renderGraphLines()
@@ -84,10 +88,14 @@ class pts_LineGraph extends pts_CustomGraph
$px_from_left = $this->graph_left_start + ($this->identifier_width * ($i + 1));
if($px_from_left > $this->graph_left_end)
+ {
$px_from_left = $this->graph_left_end - 1;
+ }
if($value_plot_top >= $this->graph_top_end)
+ {
$value_plot_top = $this->graph_top_end - 1;
+ }
if($previous_placement != -1 && $previous_offset != -1)
{
diff --git a/pts-core/objects/pts_MultiPassFailGraph.php b/pts-core/objects/pts_MultiPassFailGraph.php
index c188ee7..e123aac 100644
--- a/pts-core/objects/pts_MultiPassFailGraph.php
+++ b/pts-core/objects/pts_MultiPassFailGraph.php
@@ -25,11 +25,11 @@ class pts_MultiPassFailGraph extends pts_CustomGraph
{
public function __construct($Title, $SubTitle, $YTitle)
{
- $this->graph_y_title_hide = TRUE;
+ $this->graph_y_title_hide = true;
parent::__construct($Title, $SubTitle, $YTitle, true);
$this->graph_type = "MULTI_PASS_FAIL";
$this->graph_value_type = "ABSTRACT";
- $this->graph_hide_identifiers = TRUE;
+ $this->graph_hide_identifiers = true;
}
protected function render_graph_passfail()
{
@@ -48,10 +48,14 @@ class pts_MultiPassFailGraph extends pts_CustomGraph
$main_font_size = $this->graph_font_size_bars;
$main_greatest_length = $this->find_longest_string($this->graph_identifiers);
while(($this->return_ttf_string_width($main_greatest_length, $this->graph_font, $main_font_size) > ($main_width - 8)) || $this->return_ttf_string_height($main_greatest_length, $this->graph_font, $main_font_size) > ($line_height - 4))
+ {
$main_font_size -= 0.5;
+ }
if(($new_size = $this->return_ttf_string_width($main_greatest_length, $this->graph_font, $main_font_size)) < ($main_width - 12))
+ {
$main_width = $new_size + 10;
+ }
$identifiers_total_width = $graph_width - $main_width - 2;
@@ -59,7 +63,9 @@ class pts_MultiPassFailGraph extends pts_CustomGraph
$identifiers_width = floor($identifiers_total_width / count($headings));
$headings_font_size = $this->graph_font_size_bars;
while(($this->return_ttf_string_width($this->find_longest_string($headings), $this->graph_font, $headings_font_size) > ($identifiers_width - 2)) || $this->return_ttf_string_height($this->graph_maximum_value, $this->graph_font, $headings_font_size) > ($line_height - 4))
+ {
$headings_font_size -= 0.5;
+ }
for($j = 0; $j < count($this->graph_data[0]); $j++)
{
@@ -68,19 +74,27 @@ class pts_MultiPassFailGraph extends pts_CustomGraph
for($i = 0; $i < count($headings) && $i < count($results); $i++)
{
if($results[$i] == "PASS")
+ {
$paint_color = $pass_color;
+ }
else
+ {
$paint_color = $fail_color;
+ }
$this_bottom_end = $this->graph_top_start + $vertical_border + (($j + 1) * $line_height) + $heading_height + 1;
if($this_bottom_end >= $this->graph_top_end - $vertical_border)
+ {
$this_bottom_end = $this->graph_top_end - $vertical_border - 1;
+ }
else if($j == (count($this->graph_data[0]) - 1) && $this_bottom_end < $this->graph_top_end - $vertical_border)
+ {
$this_bottom_end = $this->graph_top_end - $vertical_border - 1;
+ }
$this->draw_rectangle($this->graph_image, $this->graph_left_end - $horizontal_border - ($i * $identifiers_width), $this->graph_top_start + $vertical_border + ($j * $line_height) + $heading_height, $this->graph_left_end - $horizontal_border - (($i + 1) * $identifiers_width), $this_bottom_end, $paint_color);
- $this->write_text_center($results[$i], $this->graph_font_size_bars, $this->graph_color_body_text, $this->graph_left_end - $horizontal_border - ($i * $identifiers_width) - $identifiers_width, $this->graph_top_start + $vertical_border + ($j * $line_height) + $heading_height + ($line_height / 2) - ($line_ttf_height / 2), $this->graph_left_end - $horizontal_border - ($i * $identifiers_width), $this->graph_top_start + $vertical_border + ($j * $line_height) + $heading_height + ($line_height / 2) - ($line_ttf_height / 2));
+ $this->write_text_center($results[$i], $this->graph_font_size_bars, $this->graph_color_body_text, $this->graph_left_end - $horizontal_border - ($i * $identifiers_width) - $identifiers_width, $this->graph_top_start + $vertical_border + ($j * $line_height) + $heading_height + ($line_height / 2) - ($line_ttf_height / 2), $this->graph_left_end - $horizontal_border - ($i * $identifiers_width), $this->graph_top_start + $vertical_border + ($j * $line_height) + $heading_height + ($line_height / 2) - ($line_ttf_height / 2));
}
}
@@ -96,7 +110,7 @@ class pts_MultiPassFailGraph extends pts_CustomGraph
for($i = 0; $i < count($this->graph_identifiers); $i++)
{
$this->draw_line($this->graph_image, $this->graph_left_start + $horizontal_border, $this->graph_top_start + $vertical_border + ($i * $line_height) + $heading_height, $this->graph_left_end - $horizontal_border, $this->graph_top_start + $vertical_border + ($i * $line_height) + $heading_height, $this->graph_color_body_light);
- $this->write_text_right($this->graph_identifiers[$i], $main_font_size, $this->graph_color_headers, $this->graph_left_start + $horizontal_border + $main_width, $this->graph_top_start + $vertical_border + ($i * $line_height) + $heading_height + ($line_height / 2) - 2, $this->graph_left_start + $horizontal_border + $main_width, $this->graph_top_start + $vertical_border + ($i * $line_height) + $heading_height + ($line_height / 2) - 2, FALSE);
+ $this->write_text_right($this->graph_identifiers[$i], $main_font_size, $this->graph_color_headers, $this->graph_left_start + $horizontal_border + $main_width, $this->graph_top_start + $vertical_border + ($i * $line_height) + $heading_height + ($line_height / 2) - 2, $this->graph_left_start + $horizontal_border + $main_width, $this->graph_top_start + $vertical_border + ($i * $line_height) + $heading_height + ($line_height / 2) - 2, false);
}
$this->draw_line($this->graph_image, $this->graph_left_start + $horizontal_border, $this->graph_top_start + $vertical_border, $this->graph_left_end - $horizontal_border, $this->graph_top_start + $vertical_border, $this->graph_color_body_light);
diff --git a/pts-core/objects/pts_PassFailGraph.php b/pts-core/objects/pts_PassFailGraph.php
index 7ddd6e2..fe2fa1a 100644
--- a/pts-core/objects/pts_PassFailGraph.php
+++ b/pts-core/objects/pts_PassFailGraph.php
@@ -28,7 +28,7 @@ class pts_PassFailGraph extends pts_CustomGraph
parent::__construct($Title, $SubTitle, $YTitle);
$this->graph_type = "PASS_FAIL";
$this->graph_value_type = "ABSTRACT";
- $this->graph_hide_identifiers = TRUE;
+ $this->graph_hide_identifiers = true;
$this->graph_data_title = array("PASSED", "FAILED");
}
protected function render_graph_passfail()
@@ -46,15 +46,21 @@ class pts_PassFailGraph extends pts_CustomGraph
$fail_color = $this->next_paint_color();
for($i = 2; $i <= sqrt($identifier_count); $i++)
+ {
if(intval($identifier_count / $i) == ($identifier_count / $i))
+ {
$columns = $i;
+ }
+ }
$identifiers_per_column = $identifier_count / $columns;
$identifier_height = floor(($graph_height - (($identifiers_per_column - 1) * $spacing)) / $identifiers_per_column);
$identifier_width = floor(($graph_width - (($columns - 1) * $spacing)) / $columns);
while($this->return_ttf_string_width($this->graph_maximum_value, $this->graph_font, $font_size) > ($identifier_width - 8) || $this->return_ttf_string_height($this->graph_maximum_value, $this->graph_font, $font_size) > ($identifier_height - 4))
+ {
$font_size -= 0.5;
+ }
for($c = 0; $c < $columns; $c++)
{
@@ -70,9 +76,13 @@ class pts_PassFailGraph extends pts_CustomGraph
$this_vertical_end = $this->graph_top_start + $vertical_border + ($i * ($identifier_height + $spacing)) + $identifier_height;
if($this_value == "PASS")
+ {
$paint_color = $pass_color;
+ }
else
+ {
$paint_color = $fail_color;
+ }
$this->draw_rectangle_border($this->graph_image, $this_horizontal_start, $this_vertical_start, $this_horizontal_end, $this_vertical_end, $this->graph_color_body_light);
$this->draw_rectangle($this->graph_image, $this_horizontal_start + 1, $this_vertical_start + 1, $this_horizontal_end - 1, $this_vertical_end - 1, $paint_color);
diff --git a/pts-core/objects/pts_module.php b/pts-core/objects/pts_module.php
index 6608a9e..4c9f20f 100644
--- a/pts-core/objects/pts_module.php
+++ b/pts-core/objects/pts_module.php
@@ -28,7 +28,9 @@ class pts_module
$prefix_dir = PTS_USER_DIR . "module-files/";
if(!is_dir($prefix_dir))
+ {
mkdir($prefix_dir);
+ }
return $prefix_dir . str_replace("_", "-", self::module_name()) . "/";
}
@@ -58,7 +60,9 @@ class pts_module
for($i = 0; $i < count($module_options) && $value == ""; $i++)
{
if($module_options[$i]->get_identifier() == $identifier)
+ {
$value = $module_options[$i]->get_default_value();
+ }
}
}
@@ -68,40 +72,54 @@ class pts_module
{
pts_module_config_init(array(self::module_name() . "__" . $identifier => $value));
}
- public static function save_file($file, $contents = NULL, $append = false)
+ public static function save_file($file, $contents = null, $append = false)
{
// Saves a file for a module
$save_base_dir = self::save_dir();
if(!is_dir($save_base_dir))
+ {
mkdir($save_base_dir);
+ }
if(($extra_dir = dirname($file)) != "." && !is_dir($save_base_dir . $extra_dir))
+ {
mkdir($save_base_dir . $extra_dir);
+ }
if($append)
{
if(is_file($save_base_dir . $file))
- if(file_put_contents($save_base_dir . $file, $contents . "\n", FILE_APPEND) != FALSE)
+ {
+ if(file_put_contents($save_base_dir . $file, $contents . "\n", FILE_APPEND) != false)
+ {
return $save_base_dir . $file;
+ }
+ }
}
else
{
- if(file_put_contents($save_base_dir . $file, $contents) != FALSE)
+ if(file_put_contents($save_base_dir . $file, $contents) != false)
+ {
return $save_base_dir . $file;
+ }
}
- return FALSE;
+ return false;
}
public static function read_file($file)
{
$file = self::save_dir() . $file;
if(is_file($file))
+ {
$file = file_get_contents($file);
+ }
else
- $file = FALSE;
+ {
+ $file = false;
+ }
return $file;
}
@@ -109,8 +127,7 @@ class pts_module
{
$file = self::save_dir() . $file;
- if(is_file($file))
- return unlink($file);
+ return is_file($file) && unlink($file);
}
public static function copy_file($from_file, $to_file)
{
@@ -119,16 +136,24 @@ class pts_module
$save_base_dir = self::save_dir();
if(!is_dir($save_base_dir))
+ {
mkdir($save_base_dir);
+ }
if(($extra_dir = dirname($to_file)) != "." && !is_dir($save_base_dir . $extra_dir))
+ {
mkdir($save_base_dir . $extra_dir);
+ }
if(is_file($from_file) && (!is_file($save_base_dir . $to_file) || md5_file($from_file) != md5_file($save_base_dir . $to_file)))
+ {
if(copy($from_file, $save_base_dir . $to_file))
+ {
return $save_base_dir . $to_file;
+ }
+ }
- return FALSE;
+ return false;
}
public static function pts_fork_function($function)
{
@@ -137,7 +162,9 @@ class pts_module
public static function pts_timed_function($time, $function)
{
if($time <= 5 || $time > 300)
+ {
return;
+ }
if(function_exists("pcntl_fork"))
{
@@ -158,22 +185,28 @@ class pts_module
eval(self::module_name() . "::" . $function . "();"); // TODO: This can be cleaned up once PHP 5.3.0+ is out there and adopted
if($time > 0)
+ {
sleep($time);
+ }
else if($time == -1)
+ {
$loop_continue = false;
+ }
}
exit(0);
}
}
}
else
+ {
echo pts_string_header("NOTICE: php-pcntl must be installed for the " . self::module_name() . " module.");
+ }
}
private static function module_name()
{
$module_name = "unknown";
- if($GLOBALS["PTS_MODULE_CURRENT"] != FALSE)
+ if($GLOBALS["PTS_MODULE_CURRENT"] != false)
{
$module_name = $GLOBALS["PTS_MODULE_CURRENT"];
}
@@ -182,8 +215,12 @@ class pts_module
$bt = debug_backtrace();
for($i = 0; $i < count($bt) && $module_name == "unknown"; $i++)
+ {
if($bt[$i]["class"] != "pts_module")
+ {
$module_name = $bt[$i]["class"];
+ }
+ }
}
return $module_name;
diff --git a/pts-core/objects/pts_module_interface.php b/pts-core/objects/pts_module_interface.php
index 2ee80b6..4b6dd83 100644
--- a/pts-core/objects/pts_module_interface.php
+++ b/pts-core/objects/pts_module_interface.php
@@ -43,11 +43,11 @@ class pts_module_interface
// General Functions
//
- public static function __startup($obj = NULL)
+ public static function __startup($obj = null)
{
return;
}
- public static function __shutdown($obj = NULL)
+ public static function __shutdown($obj = null)
{
return;
}
@@ -56,19 +56,19 @@ class pts_module_interface
// Installation Functions
//
- public static function __pre_install_process($obj = NULL)
+ public static function __pre_install_process($obj = null)
{
return;
}
- public static function __pre_test_install($obj = NULL)
+ public static function __pre_test_install($obj = null)
{
return;
}
- public static function __post_test_install($obj = NULL)
+ public static function __post_test_install($obj = null)
{
return;
}
- public static function __post_install_process($obj = NULL)
+ public static function __post_install_process($obj = null)
{
return;
}
@@ -77,23 +77,23 @@ class pts_module_interface
// Run Functions
//
- public static function __pre_run_process($obj = NULL)
+ public static function __pre_run_process($obj = null)
{
return;
}
- public static function __pre_test_run($obj = NULL)
+ public static function __pre_test_run($obj = null)
{
return;
}
- public static function __interim_test_run($obj = NULL)
+ public static function __interim_test_run($obj = null)
{
return;
}
- public static function __post_test_run($obj = NULL)
+ public static function __post_test_run($obj = null)
{
return;
}
- public static function __post_run_process($obj = NULL)
+ public static function __post_run_process($obj = null)
{
return;
}
diff --git a/pts-core/objects/pts_module_option.php b/pts-core/objects/pts_module_option.php
index aa28509..15990b0 100644
--- a/pts-core/objects/pts_module_option.php
+++ b/pts-core/objects/pts_module_option.php
@@ -54,7 +54,9 @@ class pts_module_option
$question_string = $this->get_question();
if($this->default_value != null)
+ {
$question_string .= " [" . $this->default_value . "]";
+ }
$question_string .= ": ";
@@ -66,12 +68,16 @@ class pts_module_option
if(is_array($this->option_supported_values))
{
if(in_array($input, $this->option_supported_values))
+ {
$supported = true;
+ }
}
else if($this->option_supported_values == OPTION_NUMERIC)
{
if(is_numeric($input))
+ {
$supported = true;
+ }
}
else if(empty($input) && $this->default_value != null)
{
diff --git a/pts-core/objects/pts_test_tandem_XmlReader.php b/pts-core/objects/pts_test_tandem_XmlReader.php
index 21d1542..0595bd9 100644
--- a/pts-core/objects/pts_test_tandem_XmlReader.php
+++ b/pts-core/objects/pts_test_tandem_XmlReader.php
@@ -41,7 +41,9 @@ class pts_test_tandem_XmlReader extends tandem_XmlReader
$test_below_tag = $test_below_parser->getXMLValue($XML_TAG);
if(!empty($test_below_tag))
+ {
$fallback_value = $test_below_tag;
+ }
}
}
diff --git a/pts-core/objects/tandem_XmlReader.php b/pts-core/objects/tandem_XmlReader.php
index 81071d8..dd36631 100644
--- a/pts-core/objects/tandem_XmlReader.php
+++ b/pts-core/objects/tandem_XmlReader.php
@@ -27,22 +27,22 @@
class tandem_XmlReader
{
var $XML_DATA = "";
- var $XML_FILE_TIME = NULL;
- var $XML_FILE_NAME = NULL;
+ var $XML_FILE_TIME = null;
+ var $XML_FILE_NAME = null;
- var $XML_CACHE_FILE = FALSE; // Cache the entire XML file being parsed
- var $XML_CACHE_TAGS = TRUE; // Cache the tags that are being called
+ var $XML_CACHE_FILE = false; // Cache the entire XML file being parsed
+ var $XML_CACHE_TAGS = true; // Cache the tags that are being called
- var $NO_TAG_FALLBACK_VALUE = NULL;
+ var $NO_TAG_FALLBACK_VALUE = null;
- function __construct($XML, $DO_CACHE = TRUE)
+ function __construct($XML, $DO_CACHE = true)
{
if(is_file($XML))
{
if(!$DO_CACHE)
{
- $this->XML_CACHE_FILE = FALSE;
- $this->XML_CACHE_TAGS = FALSE;
+ $this->XML_CACHE_FILE = false;
+ $this->XML_CACHE_TAGS = false;
}
// If you're going to be banging XML files hard through the course of the script, you'll want to flush the PHP file cache
@@ -51,29 +51,33 @@ class tandem_XmlReader
$this->XML_FILE_TIME = filemtime($XML);
$this->XML_FILE_NAME = $XML;
- if($this->XML_CACHE_FILE == TRUE && isset($GLOBALS["XML_CACHE"]["FILE"][$this->XML_FILE_NAME][$this->XML_FILE_TIME]))
+ if($this->XML_CACHE_FILE == true && isset($GLOBALS["XML_CACHE"]["FILE"][$this->XML_FILE_NAME][$this->XML_FILE_TIME]))
+ {
$this->XML_DATA = $GLOBALS["XML_CACHE"]["FILE"][$this->XML_FILE_NAME][$this->XML_FILE_TIME];
+ }
if(empty($this->XML_DATA))
{
$this->XML_DATA = file_get_contents($XML);
- if($this->XML_CACHE_FILE == TRUE)
+ if($this->XML_CACHE_FILE == true)
+ {
$GLOBALS["XML_CACHE"]["FILE"][$this->XML_FILE_NAME][$this->XML_FILE_TIME] = $this->XML_DATA;
+ }
}
}
else
{
- $this->XML_CACHE_FILE = FALSE;
- $this->XML_CACHE_TAGS = FALSE;
+ $this->XML_CACHE_FILE = false;
+ $this->XML_CACHE_TAGS = false;
$this->XML_DATA = $XML;
}
}
function getStatement($STATEMENT_NAME)
{
- return $this->listStatements(TRUE, $STATEMENT_NAME);
+ return $this->listStatements(true, $STATEMENT_NAME);
}
- function listStatements($SEARCH_DO = FALSE, $SEARCH_QUERY = "")
+ function listStatements($SEARCH_DO = false, $SEARCH_QUERY = "")
{
preg_match_all("'<!--(.*?) -->'si", $this->XML_DATA, $statement_maches);
$return_array = array();
@@ -108,14 +112,18 @@ class tandem_XmlReader
{
return $this->getValue($XML_TAG) != null;
}
- function getValue($FULL_XML_TAG, $XML_TAG = null, $XML_MATCH = null, $DO_CACHE = TRUE, $FALLBACK_PROCESS = FALSE)
+ function getValue($FULL_XML_TAG, $XML_TAG = null, $XML_MATCH = null, $DO_CACHE = true, $FALLBACK_PROCESS = false)
{
if($XML_TAG == null)
+ {
$XML_TAG = $FULL_XML_TAG;
+ }
if($XML_MATCH == null)
+ {
$XML_MATCH = $this->XML_DATA;
+ }
- if($this->XML_CACHE_TAGS == TRUE && $DO_CACHE && isset($GLOBALS["XML_CACHE"]["TAGS"][$this->XML_FILE_NAME][$this->XML_FILE_TIME][$XML_TAG]))
+ if($this->XML_CACHE_TAGS == true && $DO_CACHE && isset($GLOBALS["XML_CACHE"]["TAGS"][$this->XML_FILE_NAME][$this->XML_FILE_TIME][$XML_TAG]))
{
$XML_MATCH = $GLOBALS["XML_CACHE"]["TAGS"][$this->XML_FILE_NAME][$this->XML_FILE_TIME][$XML_TAG];
}
@@ -126,7 +134,9 @@ class tandem_XmlReader
preg_match("'<$xml_step>(.*?)</$xml_step>'si", $XML_MATCH, $new_match);
if(count($new_match) > 1)
+ {
$XML_MATCH = $new_match[1];
+ }
else
{
if(!$FALLBACK_PROCESS)
@@ -134,12 +144,16 @@ class tandem_XmlReader
$XML_MATCH = $this->handleXmlZeroTagFallback($FULL_XML_TAG);
}
else
+ {
$XML_MATCH = $this->NO_TAG_FALLBACK_VALUE;
+ }
}
}
- if($this->XML_CACHE_TAGS == TRUE && $DO_CACHE)
+ if($this->XML_CACHE_TAGS == true && $DO_CACHE)
+ {
$GLOBALS["XML_CACHE"]["TAGS"][$this->XML_FILE_NAME][$this->XML_FILE_TIME][$XML_TAG] = $XML_MATCH;
+ }
}
return $XML_MATCH;
@@ -162,7 +176,9 @@ class tandem_XmlReader
$this_xml = $XML_MATCH;
for($i = 0; $i < count($xml_steps) - 2; $i++)
- $this_xml = $this->getValue($XML_TAG, $xml_steps[$i], $this_xml, FALSE);
+ {
+ $this_xml = $this->getValue($XML_TAG, $xml_steps[$i], $this_xml, false);
+ }
$next_xml_step = $xml_steps[count($xml_steps) - 2];
preg_match_all("'<$next_xml_step>(.*?)</$next_xml_step>'si", $this_xml, $xml_matches);
@@ -175,7 +191,7 @@ class tandem_XmlReader
{
if($extraction_tags_count == 1)
{
- $this_item = $this->getValue($XML_TAG, $extraction_tags[0], $xml_matches[1][$i], FALSE);
+ $this_item = $this->getValue($XML_TAG, $extraction_tags[0], $xml_matches[1][$i], false);
array_push($return_array, $this_item);
}
else
@@ -183,11 +199,13 @@ class tandem_XmlReader
if($i == 0)
{
foreach($extraction_tags as $extract)
+ {
$return_array[$extract] = array();
+ }
}
foreach($extraction_tags as $extract)
{
- $this_item = $this->getValue($XML_TAG, $extract, $xml_matches[1][$i], FALSE);
+ $this_item = $this->getValue($XML_TAG, $extract, $xml_matches[1][$i], false);
array_push($return_array[$extract], $this_item);
}
}
@@ -196,11 +214,11 @@ class tandem_XmlReader
}
function setFileCaching($BOOL)
{
- $this->XML_CACHE_FILE = ($BOOL == TRUE);
+ $this->XML_CACHE_FILE = ($BOOL == true);
}
function setTagCaching($BOOL)
{
- $this->XML_CACHE_TAGS = ($BOOL == TRUE);
+ $this->XML_CACHE_TAGS = ($BOOL == true);
}
function setCaching($BOOL)
{
diff --git a/pts-core/objects/tandem_XmlWriter.php b/pts-core/objects/tandem_XmlWriter.php
index 476eaa0..49bbe24 100644
--- a/pts-core/objects/tandem_XmlWriter.php
+++ b/pts-core/objects/tandem_XmlWriter.php
@@ -34,7 +34,7 @@ class tandem_XmlWriter
var $FORMAT_XML;
var $XSL_BINDING = null;
- function __construct($READ_FROM_XML = "", $NOT_IMPLEMENTED = "", $NICE_FORMATTING = TRUE)
+ function __construct($READ_FROM_XML = "", $NOT_IMPLEMENTED = "", $NICE_FORMATTING = true)
{
$this->FORMAT_XML = $NICE_FORMATTING;
}
@@ -46,21 +46,29 @@ class tandem_XmlWriter
{
$this->XML_CHECKSUM = true;
}
- function addXmlObject($XML_LOCATION, $UNIQUE_IDENTIFIER = 0, $XML_VALUE, $STD_STEP = null, $STEP_ID = null)
+ function addXmlObject($XML_LOCATION, $UNIQUE_IDENTIFIER = 0, $XML_VALUE = "", $STD_STEP = null, $STEP_ID = null)
{
$xml_array = array();
$alt_step = -1;
$steps = 0;
if($STD_STEP == null)
+ {
$STD_STEP = 2;
+ }
if($STEP_ID == null)
+ {
$STEP_ID = $UNIQUE_IDENTIFIER;
+ }
- if(array_search("$UNIQUE_IDENTIFIER,$XML_LOCATION", $this->XML_STRING_PATHS) !== FALSE)
+ if(array_search($UNIQUE_IDENTIFIER . "," . $XML_LOCATION, $this->XML_STRING_PATHS) !== false)
+ {
$alt_step = 2;
+ }
else
- array_push($this->XML_STRING_PATHS, "$UNIQUE_IDENTIFIER,$XML_LOCATION");
+ {
+ array_push($this->XML_STRING_PATHS, $UNIQUE_IDENTIFIER . "," . $XML_LOCATION);
+ }
$xml_steps = explode('/', $XML_LOCATION);
foreach(array_reverse($xml_steps) as $current_tag)
@@ -72,12 +80,18 @@ class tandem_XmlWriter
$xml_array = $XML_VALUE;
}
if(!empty($current_tag))
+ {
$xml_array = array("$current_tag" => $xml_array);
+ }
if($steps == $STD_STEP)
- $xml_array = array("id_$UNIQUE_IDENTIFIER" => $xml_array);
+ {
+ $xml_array = array("id_" . $UNIQUE_IDENTIFIER => $xml_array);
+ }
if($steps == $alt_step)
- $xml_array = array("id_$STEP_ID" => $xml_array);
+ {
+ $xml_array = array("id_" . $STEP_ID => $xml_array);
+ }
}
$this->XML_OBJECTS = array_merge_recursive($this->XML_OBJECTS, $xml_array);
@@ -93,7 +107,7 @@ class tandem_XmlWriter
foreach($statements_to_print as $statement)
{
- $return_string .= "<!-- $statement -->" . "\n";
+ $return_string .= "<!-- " . $statement . " -->\n";
}
return $return_string;
@@ -105,7 +119,9 @@ class tandem_XmlWriter
$this->addStatement("Generated", date("Y-m-d H:i:s"));
if($this->XML_CHECKSUM)
+ {
$this->addStatement("Checksum", md5($formatted_xml));
+ }
return "<?xml version=\"1.0\"?>\n" . $this->getXSL() . $this->getXMLStatements() . $formatted_xml;
}
@@ -128,7 +144,7 @@ class tandem_XmlWriter
{
if(!is_array($value))
{
- $formatted_xml .= $this->getXMLTabs($TIMES_DEEP) . "<$key>$value</$key>" . $this->getXMLBreaks();
+ $formatted_xml .= $this->getXMLTabs($TIMES_DEEP) . "<" . $key . ">" . $value . "</" . $key . ">" . $this->getXMLBreaks();
}
else
{
@@ -138,9 +154,9 @@ class tandem_XmlWriter
}
else
{
- $formatted_xml .= $this->getXMLTabs($TIMES_DEEP) . "<$key>" . $this->getXMLBreaks();
+ $formatted_xml .= $this->getXMLTabs($TIMES_DEEP) . "<" . $key . ">" . $this->getXMLBreaks();
$formatted_xml .= $this->getXMLBelow($value, $TIMES_DEEP + 1);
- $formatted_xml .= $this->getXMLTabs($TIMES_DEEP) . "</$key>" . $this->getXMLBreaks();
+ $formatted_xml .= $this->getXMLTabs($TIMES_DEEP) . "</" . $key . ">" . $this->getXMLBreaks();
}
}
}
@@ -149,20 +165,26 @@ class tandem_XmlWriter
}
function getXMLTabs($TIMES_DEEP)
{
- if($this->FORMAT_XML !== TRUE)
+ if($this->FORMAT_XML !== true)
+ {
return;
+ }
$return_format = "";
for($i = 0; $i < $TIMES_DEEP; $i++)
+ {
$return_format .= "\t";
+ }
return $return_format;
}
function getXMLBreaks()
{
- if($this->FORMAT_XML !== TRUE)
+ if($this->FORMAT_XML !== true)
+ {
return;
+ }
return "\n";
}