[fusion-commits] r3054 - sandbox/php8/lib/tcpdf
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Tue May 31 07:46:24 PDT 2022
Author: jng
Date: 2022-05-31 07:46:24 -0700 (Tue, 31 May 2022)
New Revision: 3054
Modified:
sandbox/php8/lib/tcpdf/tcpdf.php
Log:
Fix up tcpdf for PHP8 compatibility
Modified: sandbox/php8/lib/tcpdf/tcpdf.php
===================================================================
--- sandbox/php8/lib/tcpdf/tcpdf.php 2022-05-31 14:07:21 UTC (rev 3053)
+++ sandbox/php8/lib/tcpdf/tcpdf.php 2022-05-31 14:46:24 UTC (rev 3054)
@@ -76,7 +76,7 @@
// dullus for text Justification.
// Bob Vincent (pillarsdotnet at users.sourceforge.net) for <li> value attribute.
// Patrick Benny for text stretch suggestion on Cell().
-// Johannes Güntert for JavaScript support.
+// Johannes G�ntert for JavaScript support.
// Denis Van Nuffelen for Dynamic Form.
// Jacek Czekaj for multibyte justification
// Anthony Ferrara for the reintroduction of legacy image methods.
@@ -87,7 +87,7 @@
// Mohamad Ali Golkar, Saleh AlMatrafe, Charles Abbott for Arabic and Persian support.
// Moritz Wagner and Andreas Wurmser for graphic functions.
// Andrew Whitehead for core fonts support.
-// Esteban Joël Marín for OpenType font conversion.
+// Esteban Jo�l Mar�n for OpenType font conversion.
// Teus Hagen for several suggestions and fixes.
// Yukihiro Nakadaira for CID-0 CJK fonts fixes.
// Kosmas Papachristos for some CSS improvements.
@@ -2997,7 +2997,7 @@
if (empty($orientation)) {
$orientation = $default_orientation;
} else {
- $orientation = strtoupper($orientation{0});
+ $orientation = strtoupper($orientation[0]);
}
if (in_array($orientation, $valid_orientations) AND ($orientation != $default_orientation)) {
$this->CurOrientation = $orientation;
@@ -6715,7 +6715,7 @@
* @param $cellpadding (float) Internal cell padding, if empty uses default cell padding.
* @param $border (mixed) Indicates if borders must be drawn around the cell. The value can be a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul> or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> or an array of line styles for each border group - for example: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))
* @return float Return the minimal height needed for multicell method for printing the $txt param.
- * @author Alexander Escalona Fernández, Nicola Asuni
+ * @author Alexander Escalona Fern�ndez, Nicola Asuni
* @public
* @since 4.5.011
*/
@@ -6822,7 +6822,7 @@
* @param $cellpadding (float) Internal cell padding, if empty uses default cell padding.
* @param $border (mixed) Indicates if borders must be drawn around the cell. The value can be a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul> or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> or an array of line styles for each border group - for example: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))
* @return float Return the minimal height needed for multicell method for printing the $txt param.
- * @author Nicola Asuni, Alexander Escalona Fernández
+ * @author Nicola Asuni, Alexander Escalona Fern�ndez
* @public
*/
public function getStringHeight($w, $txt, $reseth=false, $autopadding=true, $cellpadding='', $border=0) {
@@ -7346,7 +7346,7 @@
return chr($c);
} elseif ($c <= 0x7F) {
// one byte
- return chr($c);
+ return chr(intval($c));
} elseif ($c <= 0x7FF) {
// two bytes
return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F);
@@ -7515,7 +7515,7 @@
$cached_file = false;
}
} else { // image file
- if ($file{0} === '*') {
+ if ($file[0] === '*') {
// image as external stream
$file = substr($file, 1);
$exurl = $file;
@@ -7604,7 +7604,7 @@
// height difference
$hdiff = ($oldh - $h);
// vertical alignment
- switch (strtoupper($fitbox{1})) {
+ switch (strtoupper($fitbox[1])) {
case 'T': {
break;
}
@@ -7625,7 +7625,7 @@
// width difference
$wdiff = ($oldw - $w);
// horizontal alignment
- switch (strtoupper($fitbox{0})) {
+ switch (strtoupper($fitbox[0])) {
case 'L': {
if ($this->rtl) {
$x -= $wdiff;
@@ -7912,7 +7912,7 @@
public function set_mqr($mqr) {
if (!defined('PHP_VERSION_ID')) {
$version = PHP_VERSION;
- define('PHP_VERSION_ID', (($version{0} * 10000) + ($version{2} * 100) + $version{4}));
+ define('PHP_VERSION_ID', (($version[0] * 10000) + ($version[2] * 100) + $version[4]));
}
if (PHP_VERSION_ID < 50300) {
@set_magic_quotes_runtime($mqr);
@@ -7927,7 +7927,7 @@
public function get_mqr() {
if (!defined('PHP_VERSION_ID')) {
$version = PHP_VERSION;
- define('PHP_VERSION_ID', (($version{0} * 10000) + ($version{2} * 100) + $version{4}));
+ define('PHP_VERSION_ID', (($version[0] * 10000) + ($version[2] * 100) + $version[4]));
}
if (PHP_VERSION_ID < 50300) {
return @get_magic_quotes_runtime();
@@ -8062,7 +8062,7 @@
if (count($icc) > 0) {
ksort($icc);
$icc = implode('', $icc);
- if ((ord($icc{36}) != 0x61) OR (ord($icc{37}) != 0x63) OR (ord($icc{38}) != 0x73) OR (ord($icc{39}) != 0x70)) {
+ if ((ord($icc[36]) != 0x61) OR (ord($icc[37]) != 0x63) OR (ord($icc[38]) != 0x73) OR (ord($icc[39]) != 0x70)) {
// invalid ICC profile
$icc = false;
}
@@ -8146,9 +8146,9 @@
// read transparency info
$t = $this->rfread($f, $n);
if ($ct == 0) {
- $trns = array(ord($t{1}));
+ $trns = array(ord($t[1]));
} elseif ($ct == 2) {
- $trns = array(ord($t{1}), ord($t{3}), ord($t{5}));
+ $trns = array(ord($t[1]), ord($t[3]), ord($t[5]));
} else {
$pos = strpos($t, chr(0));
if ($pos !== false) {
@@ -8494,7 +8494,7 @@
$dest = $dest ? 'D' : 'F';
}
$dest = strtoupper($dest);
- if ($dest{0} != 'F') {
+ if ($dest[0] != 'F') {
$name = preg_replace('/[\s]+/', '_', $name);
$name = preg_replace('/[^a-zA-Z0-9_\.-]/', '', $name);
}
@@ -11263,7 +11263,7 @@
$font = file_get_contents($fontfile);
$compressed = (substr($file, -2) == '.z');
if ((!$compressed) AND (isset($info['length2']))) {
- $header = (ord($font{0}) == 128);
+ $header = (ord($font[0]) == 128);
if ($header) {
// strip first binary header
$font = substr($font, 6);
@@ -13396,7 +13396,7 @@
* @public
*/
public function addHtmlLink($url, $name, $fill=false, $firstline=false, $color='', $style=-1, $firstblock=false) {
- if (!$this->empty_string($url) AND ($url{0} == '#')) {
+ if (!$this->empty_string($url) AND ($url[0] == '#')) {
// convert url to internal link
$lnkdata = explode(',', $url);
if (isset($lnkdata[0])) {
@@ -13521,7 +13521,7 @@
}
return $returncolor;
}
- if ($color{0} != '#') {
+ if ($color[0] != '#') {
// COLOR NAME
if (isset($this->webcolor[$color])) {
// web color
@@ -14793,7 +14793,7 @@
}
/**
- * Append a cubic Bézier curve to the current path. The curve shall extend from the current point to the point (x3, y3), using (x1, y1) and (x2, y2) as the Bézier control points.
+ * Append a cubic B�zier curve to the current path. The curve shall extend from the current point to the point (x3, y3), using (x1, y1) and (x2, y2) as the B�zier control points.
* The new current point shall be (x3, y3).
* @param $x1 (float) Abscissa of control point 1.
* @param $y1 (float) Ordinate of control point 1.
@@ -14809,7 +14809,7 @@
}
/**
- * Append a cubic Bézier curve to the current path. The curve shall extend from the current point to the point (x3, y3), using the current point and (x2, y2) as the Bézier control points.
+ * Append a cubic B�zier curve to the current path. The curve shall extend from the current point to the point (x3, y3), using the current point and (x2, y2) as the B�zier control points.
* The new current point shall be (x3, y3).
* @param $x2 (float) Abscissa of control point 2.
* @param $y2 (float) Ordinate of control point 2.
@@ -14823,7 +14823,7 @@
}
/**
- * Append a cubic Bézier curve to the current path. The curve shall extend from the current point to the point (x3, y3), using (x1, y1) and (x3, y3) as the Bézier control points.
+ * Append a cubic B�zier curve to the current path. The curve shall extend from the current point to the point (x3, y3), using (x1, y1) and (x3, y3) as the B�zier control points.
* The new current point shall be (x3, y3).
* @param $x1 (float) Abscissa of control point 1.
* @param $y1 (float) Ordinate of control point 1.
@@ -16193,7 +16193,7 @@
/**
* Create a javascript PDF string.
* @protected
- * @author Johannes Güntert, Nicola Asuni
+ * @author Johannes G�ntert, Nicola Asuni
* @since 5.9.098 (2011-06-23)
*/
protected function _putdests() {
@@ -16380,7 +16380,7 @@
* Adds a javascript
* @param $script (string) Javascript code
* @public
- * @author Johannes Güntert, Nicola Asuni
+ * @author Johannes G�ntert, Nicola Asuni
* @since 2.1.002 (2008-02-12)
*/
public function IncludeJS($script) {
@@ -16409,7 +16409,7 @@
/**
* Create a javascript PDF string.
* @protected
- * @author Johannes Güntert, Nicola Asuni
+ * @author Johannes G�ntert, Nicola Asuni
* @since 2.1.002 (2008-02-12)
*/
protected function _putjavascript() {
@@ -18350,7 +18350,7 @@
* @param $col1 (array) first color (Grayscale, RGB or CMYK components).
* @param $col2 (array) second color (Grayscale, RGB or CMYK components).
* @param $coords (array) array of the form (x1, y1, x2, y2) which defines the gradient vector (see linear_gradient_coords.jpg). The default value is from left to right (x1=0, y1=0, x2=1, y2=0).
- * @author Andreas Würmser, Nicola Asuni
+ * @author Andreas W�rmser, Nicola Asuni
* @since 3.1.000 (2008-06-09)
* @public
*/
@@ -18368,7 +18368,7 @@
* @param $col1 (array) first color (Grayscale, RGB or CMYK components).
* @param $col2 (array) second color (Grayscale, RGB or CMYK components).
* @param $coords (array) array of the form (fx, fy, cx, cy, r) where (fx, fy) is the starting point of the gradient with color1, (cx, cy) is the center of the circle with color2, and r is the radius of the circle (see radial_gradient_coords.jpg). (fx, fy) should be inside the circle, otherwise some areas will not be defined.
- * @author Andreas Würmser, Nicola Asuni
+ * @author Andreas W�rmser, Nicola Asuni
* @since 3.1.000 (2008-06-09)
* @public
*/
@@ -18391,7 +18391,7 @@
* @param $coords_min (array) minimum value used by the coordinates. If a coordinate's value is smaller than this it will be cut to coords_min. default: 0
* @param $coords_max (array) maximum value used by the coordinates. If a coordinate's value is greater than this it will be cut to coords_max. default: 1
* @param $antialias (boolean) A flag indicating whether to filter the shading function to prevent aliasing artifacts.
- * @author Andreas Würmser, Nicola Asuni
+ * @author Andreas W�rmser, Nicola Asuni
* @since 3.1.000 (2008-06-09)
* @public
*/
@@ -18483,7 +18483,7 @@
* @param $y (float) ordinate of the top left corner of the rectangle.
* @param $w (float) width of the rectangle.
* @param $h (float) height of the rectangle.
- * @author Andreas Würmser, Nicola Asuni
+ * @author Andreas W�rmser, Nicola Asuni
* @since 3.1.000 (2008-06-09)
* @protected
*/
@@ -18884,7 +18884,7 @@
// check page for no-write regions and adapt page margins if necessary
list($x, $y) = $this->checkPageRegions($h, $x, $y);
$k = $this->k;
- if ($file{0} === '@') { // image from string
+ if ($file[0] === '@') { // image from string
$data = substr($file, 1);
} else { // EPS/AI file
$data = file_get_contents($file);
@@ -18997,7 +18997,7 @@
$cnt = count($lines);
for ($i=0; $i < $cnt; ++$i) {
$line = $lines[$i];
- if (($line == '') OR ($line{0} == '%')) {
+ if (($line == '') OR ($line[0] == '%')) {
continue;
}
$len = strlen($line);
@@ -19989,19 +19989,19 @@
// remove empty blocks
$cssdata = preg_replace('/([^\}\{]+)\{\}/', '', $cssdata);
// replace media type parenthesis
- $cssdata = preg_replace('/@media[\s]+([^\{]*)\{/i', '@media \\1§', $cssdata);
- $cssdata = preg_replace('/\}\}/si', '}§', $cssdata);
+ $cssdata = preg_replace('/@media[\s]+([^\{]*)\{/i', '@media \\1�', $cssdata);
+ $cssdata = preg_replace('/\}\}/si', '}�', $cssdata);
// trim string
$cssdata = trim($cssdata);
// find media blocks (all, braille, embossed, handheld, print, projection, screen, speech, tty, tv)
$cssblocks = array();
$matches = array();
- if (preg_match_all('/@media[\s]+([^\§]*)§([^§]*)§/i', $cssdata, $matches) > 0) {
+ if (preg_match_all('/@media[\s]+([^\�]*)�([^�]*)�/i', $cssdata, $matches) > 0) {
foreach ($matches[1] as $key => $type) {
$cssblocks[$type] = $matches[2][$key];
}
// remove media blocks
- $cssdata = preg_replace('/@media[\s]+([^\§]*)§([^§]*)§/i', '', $cssdata);
+ $cssdata = preg_replace('/@media[\s]+([^\�]*)�([^�]*)�/i', '', $cssdata);
}
// keep 'all' and 'print' media, other media types are discarded
if (isset($cssblocks['all']) AND !empty($cssblocks['all'])) {
@@ -20093,7 +20093,7 @@
$attrib = strtolower(trim($attrib[0]));
if (!empty($attrib)) {
// check if matches class, id, attribute, pseudo-class or pseudo-element
- switch ($attrib{0}) {
+ switch ($attrib[0]) {
case '.': { // class
if (in_array(substr($attrib, 1), $class)) {
$valid = true;
@@ -20160,7 +20160,7 @@
break;
}
case ':': { // pseudo-class or pseudo-element
- if ($attrib{1} == ':') { // pseudo-element
+ if ($attrib[1] == ':') { // pseudo-element
// pseudo-elements are not supported!
// (::first-line, ::first-letter, ::before, ::after)
} else { // pseudo-class
@@ -20837,7 +20837,7 @@
$tagname = strtolower($tag[1]);
// check if we are inside a table header
if ($tagname == 'thead') {
- if ($element{0} == '/') {
+ if ($element[0] == '/') {
$thead = false;
} else {
$thead = true;
@@ -20852,7 +20852,7 @@
} else {
$dom[$key]['block'] = false;
}
- if ($element{0} == '/') {
+ if ($element[0] == '/') {
// *** closing html tag
$dom[$key]['opening'] = false;
$dom[$key]['parent'] = end($level);
@@ -20948,7 +20948,8 @@
// get attributes
preg_match_all('/([^=\s]*)[\s]*=[\s]*"([^"]*)"/', $element, $attr_array, PREG_PATTERN_ORDER);
$dom[$key]['attribute'] = array(); // reset attribute array
- while (list($id, $name) = each($attr_array[1])) {
+ //while (list($id, $name) = each($attr_array[1])) {
+ foreach($attr_array[1] as $id => $name) {
$dom[$key]['attribute'][strtolower($name)] = $attr_array[2][$id];
}
if (!empty($css)) {
@@ -20961,7 +20962,8 @@
// get style attributes
preg_match_all('/([^;:\s]*):([^;]*)/', $dom[$key]['attribute']['style'], $style_array, PREG_PATTERN_ORDER);
$dom[$key]['style'] = array(); // reset style attribute array
- while (list($id, $name) = each($style_array[1])) {
+ //while (list($id, $name) = each($style_array[1])) {
+ foreach($attr_array[1] as $id => $name) {
// in case of duplicate attribute the last replace the previous
$dom[$key]['style'][strtolower($name)] = trim($style_array[2][$id]);
}
@@ -21066,15 +21068,15 @@
}
// font style
if (isset($dom[$key]['style']['font-weight'])) {
- if (strtolower($dom[$key]['style']['font-weight']{0}) == 'n') {
+ if (strtolower($dom[$key]['style']['font-weight'][0]) == 'n') {
if (strpos($dom[$key]['fontstyle'], 'B') !== false) {
$dom[$key]['fontstyle'] = str_replace('B', '', $dom[$key]['fontstyle']);
}
- } elseif (strtolower($dom[$key]['style']['font-weight']{0}) == 'b') {
+ } elseif (strtolower($dom[$key]['style']['font-weight'][0]) == 'b') {
$dom[$key]['fontstyle'] .= 'B';
}
}
- if (isset($dom[$key]['style']['font-style']) AND (strtolower($dom[$key]['style']['font-style']{0}) == 'i')) {
+ if (isset($dom[$key]['style']['font-style']) AND (strtolower($dom[$key]['style']['font-style'][0]) == 'i')) {
$dom[$key]['fontstyle'] .= 'I';
}
// font color
@@ -21093,13 +21095,13 @@
foreach ($decors as $dec) {
$dec = trim($dec);
if (!$this->empty_string($dec)) {
- if ($dec{0} == 'u') {
+ if ($dec[0] == 'u') {
// underline
$dom[$key]['fontstyle'] .= 'U';
- } elseif ($dec{0} == 'l') {
+ } elseif ($dec[0] == 'l') {
// line-trough
$dom[$key]['fontstyle'] .= 'D';
- } elseif ($dec{0} == 'o') {
+ } elseif ($dec[0] == 'o') {
// overline
$dom[$key]['fontstyle'] .= 'O';
}
@@ -21118,7 +21120,7 @@
}
// check for text alignment
if (isset($dom[$key]['style']['text-align'])) {
- $dom[$key]['align'] = strtoupper($dom[$key]['style']['text-align']{0});
+ $dom[$key]['align'] = strtoupper($dom[$key]['style']['text-align'][0]);
}
// check for CSS border properties
if (isset($dom[$key]['style']['border'])) {
@@ -21282,9 +21284,9 @@
// font size
if (isset($dom[$key]['attribute']['size'])) {
if ($key > 0) {
- if ($dom[$key]['attribute']['size']{0} == '+') {
+ if ($dom[$key]['attribute']['size'][0] == '+') {
$dom[$key]['fontsize'] = $dom[($dom[$key]['parent'])]['fontsize'] + intval(substr($dom[$key]['attribute']['size'], 1));
- } elseif ($dom[$key]['attribute']['size']{0} == '-') {
+ } elseif ($dom[$key]['attribute']['size'][0] == '-') {
$dom[$key]['fontsize'] = $dom[($dom[$key]['parent'])]['fontsize'] - intval(substr($dom[$key]['attribute']['size'], 1));
} else {
$dom[$key]['fontsize'] = intval($dom[$key]['attribute']['size']);
@@ -21326,10 +21328,10 @@
if (($dom[$key]['value'] == 'pre') OR ($dom[$key]['value'] == 'tt')) {
$dom[$key]['fontname'] = $this->default_monospaced_font;
}
- if (($dom[$key]['value']{0} == 'h') AND (intval($dom[$key]['value']{1}) > 0) AND (intval($dom[$key]['value']{1}) < 7)) {
+ if (($dom[$key]['value'][0] == 'h') AND (intval($dom[$key]['value'][1]) > 0) AND (intval($dom[$key]['value'][1]) < 7)) {
// headings h1, h2, h3, h4, h5, h6
if (!isset($dom[$key]['attribute']['size']) AND !isset($dom[$key]['style']['font-size'])) {
- $headsize = (4 - intval($dom[$key]['value']{1})) * 2;
+ $headsize = (4 - intval($dom[$key]['value'][1])) * 2;
$dom[$key]['fontsize'] = $dom[0]['fontsize'] + $headsize;
}
if (!isset($dom[$key]['style']['font-weight'])) {
@@ -21391,7 +21393,7 @@
}
// check for text alignment
if (isset($dom[$key]['attribute']['align']) AND (!$this->empty_string($dom[$key]['attribute']['align'])) AND ($dom[$key]['value'] !== 'img')) {
- $dom[$key]['align'] = strtoupper($dom[$key]['attribute']['align']{0});
+ $dom[$key]['align'] = strtoupper($dom[$key]['attribute']['align'][0]);
}
// check for text rendering mode (the following attributes do not exist in HTML)
if (isset($dom[$key]['attribute']['stroke'])) {
@@ -22143,7 +22145,7 @@
// justify block
if (!$this->empty_string($this->lispacer)) {
$this->lispacer = '';
- continue;
+ continue 2;
}
preg_match('/([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]('.$strpiece[1][0].')[\s](re)([\s]*)/x', $pmid, $xmatches);
$currentxpos = $xmatches[1];
@@ -23116,7 +23118,7 @@
}
case 'img': {
if (isset($tag['attribute']['src'])) {
- if ($tag['attribute']['src']{0} === '@') {
+ if ($tag['attribute']['src'][0] === '@') {
// data stream
$tag['attribute']['src'] = '@'.base64_decode(substr($tag['attribute']['src'], 1));
$type = '';
@@ -23178,7 +23180,7 @@
$imglink = '';
if (isset($this->HREF['url']) AND !$this->empty_string($this->HREF['url'])) {
$imglink = $this->HREF['url'];
- if ($imglink{0} == '#') {
+ if ($imglink[0] == '#') {
// convert url to internal link
$lnkdata = explode(',', $imglink);
if (isset($lnkdata[0])) {
@@ -27144,7 +27146,7 @@
// convert SVG to raster image using GD or ImageMagick libraries
return $this->Image($file, $x, $y, $w, $h, 'SVG', $link, $align, true, 300, $palign, false, false, $border, false, false, false);
}
- if ($file{0} === '@') { // image from string
+ if ($file[0] === '@') { // image from string
$this->svgdir = '';
$svgdata = substr($file, 1);
} else { // SVG file
@@ -28054,7 +28056,7 @@
}
break;
}
- case 'Q': { // quadratic Bézier curveto
+ case 'Q': { // quadratic B�zier curveto
foreach ($params as $ck => $cp) {
$params[$ck] = $cp;
if ((($ck + 1) % 4) == 0) {
@@ -28080,7 +28082,7 @@
}
break;
}
- case 'T': { // shorthand/smooth quadratic Bézier curveto
+ case 'T': { // shorthand/smooth quadratic B�zier curveto
foreach ($params as $ck => $cp) {
$params[$ck] = $cp;
if (($ck % 2) != 0) {
@@ -28631,7 +28633,7 @@
$img = '@'.base64_decode(substr($img, strlen($m[0])));
} else {
// fix image path
- if (!$this->empty_string($this->svgdir) AND (($img{0} == '.') OR (basename($img) == $img))) {
+ if (!$this->empty_string($this->svgdir) AND (($img[0] == '.') OR (basename($img) == $img))) {
// replace relative path with full server path
$img = $this->svgdir.'/'.$img;
}
More information about the fusion-commits
mailing list