Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* Fixed Bug #9176 "UTF-8 in SVGs does not work (patch included)" (tha…

…nks to troehr at php dot net)

* Fixed Bug #10236 "Pie Chart Shading Error when datapoint has 0 value" (thanks to peter_wake at hotmail dot com)
* Fixed Request #11402 "Implement Image_Canvas_SVG::getData()" (thanks to troehr at php dot net)


git-svn-id: https://svn.php.net/repository/pear/packages/Image_Canvas/trunk@238289 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit f14c1b44a29d1b60240a72ba878c9d57b2702760 1 parent fa84978
Jesper Veggerby Hansen authored
Showing with 27 additions and 25 deletions.
  1. +1 −1  Canvas/GD.php
  2. +23 −24 Canvas/SVG.php
  3. +3 −0  docs/ChangeLog
View
2  Canvas/GD.php
@@ -1209,7 +1209,7 @@ function pieslice($params)
$polygon[] = ($y + $ry * sin(deg2rad(max($v1, $v2) % 360)));
}
- if (($fill = $this->_getFillStyle($fillColor, $x - $rx - 1, $y - $ry - 1, $x + $rx + 1, $y + $ry + 1)) !== false) {
+ if (($fill = $this->_getFillStyle($fillColor, $x - $rx - 1, $y - $ry - 1, $x + $rx + 1, $y + $ry + 1)) !== false && count($polygon) > 2)
ImageFilledPolygon($this->_canvas, $polygon, count($polygon) / 2, $fill);
}
View
47 Canvas/SVG.php
@@ -104,9 +104,9 @@ class Image_Canvas_SVG extends Image_Canvas
*
* @param array $param Parameter array
*/
- function Image_Canvas_SVG($param)
+ function Image_Canvas_SVG($params)
{
- parent::Image_Canvas($param);
+ parent::Image_Canvas($params);
$this->_reset();
if (isset($params['encoding'])) {
@@ -856,21 +856,7 @@ function show($param = false)
$attrs = (isset($param['attrs']) && is_array($param['attrs'])) ? $this->_getAttributes($param['attrs']) : null;
- $output = '<?xml version="1.0" encoding="' . $this->_encoding . '"?>' . "\n" .
- '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"' . "\n\t" .
- ' "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">' . "\n" .
- '<svg width="' . $this->_width . '" height="' . $this->_height .
- '" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"' .
- ($attrs ? ' ' . $attrs : '') .
- '>' . "\n" .
- ($this->_defs ?
- ' <defs>' . "\n" .
- $this->_defs .
- ' </defs>' . "\n" :
- ''
- ) .
- $this->_elements .
- '</svg>';
+ $output = $this->getData($param);
header('Content-Type: image/svg+xml');
header('Content-Disposition: inline; filename = "' . basename($_SERVER['PHP_SELF'], '.php') . '.svg"');
@@ -886,9 +872,26 @@ function save($param = false)
{
parent::save($param);
+ $output = $this->getData($param);
+
+ $file = fopen($param['filename'], 'w+');
+ fwrite($file, $output);
+ fclose($file);
+ }
+
+
+ /**
+ * Get SVG data
+ *
+ * @param array $param Parameter array
+ *
+ * @return string
+ */
+ function getData($param = false)
+ {
$attrs = (isset($param['attrs']) && is_array($param['attrs'])) ? $this->_getAttributes($param['attrs']) : null;
- $output = '<?xml version="1.0" encoding="'. $this->_encoding . '"?>' . "\n" .
+ return '<?xml version="1.0" encoding="'. $this->_encoding . '"?>' . "\n" .
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"' . "\n\t" .
' "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">' . "\n" .
'<svg width="' . $this->_width . '" height="' . $this->_height .
@@ -903,12 +906,8 @@ function save($param = false)
) .
$this->_elements .
'</svg>';
-
- $file = fopen($param['filename'], 'w+');
- fwrite($file, $output);
- fclose($file);
- }
-
+ }
+
/**
* Set clipping to occur
*
View
3  docs/ChangeLog
@@ -10,6 +10,9 @@ Version 0.3.1 [2006-xxx-xx] - Jesper Veggerby <pear.nosey@veggerby.dk>
* Fixed Bug #8556 "SVG.php contains typo" (thanks to troehr at php dot net)
* Fixed Bug #8776 "Fatal error: Call to undefined function: imageantialias()"
* Fixed Bug #9070 "factory method causes PHP error if no GD" (thanks to troehr at php dot net)
+ * Fixed Bug #9176 "UTF-8 in SVGs does not work (patch included)" (thanks to troehr at php dot net)
+ * Fixed Bug #10236 "Pie Chart Shading Error when datapoint has 0 value" (thanks to peter_wake at hotmail dot com)
+ * Fixed Request #11402 "Implement Image_Canvas_SVG::getData()" (thanks to troehr at php dot net)
Version 0.3.0 [2006-Mar-02] - Jesper Veggerby <pear.nosey@veggerby.dk>
* Added clipping (GD uses Image_Canvas method involving ImageCopy(), until native support is available throught existing GD functions gdImageSetClip())
Please sign in to comment.
Something went wrong with that request. Please try again.