Fixed get_post() support for numeric fields.
[fa-stable.git] / reporting / includes / tcpdf.php
index 48504eb945a7db15c5e70b8cb009410b583e87ee..803416a89396111855d865e50df1725f1a8b1dfd 100644 (file)
   *    and
   *    if (!defined("K_RE_PATTERN_ARABIC"))
   * 4. Parameter $unicode in constructor renamed to $uni.
-  * 4. Header function renamed to Header1 (due to conflict with FrontReport Header)
+  * 5. Header function renamed to Header1 (due to conflict with FrontReport Header)
+  * 6. Line 6190, SetLineWidth (cast of values to avoid problem in PHP 5.2.6
+  * 7. Line 6261. ereg replaced by preg_match (with start and end delimiter)
+  * 8. Lines 8642,9256 and 9348. split replaced by preg_split.
   * -------------------------------------------------------------------------------
   */
 if (!defined("K_PATH_FONTS"))
-       define ("K_PATH_FONTS", '../reporting/fonts/');
-define ("K_PATH_CACHE", '../reporting/fonts/');
+       define ("K_PATH_FONTS", dirname(__FILE__)."/../fonts/");
+define ("K_PATH_CACHE", dirname(__FILE__)."/../fonts/");
 define("K_CELL_HEIGHT_RATIO", 1.25);
 
 //require_once(dirname(__FILE__).'/config/tcpdf_config.php');
@@ -1109,7 +1112,7 @@ if (!class_exists('TCPDF')) {
                 * @param boolean $unicode TRUE means that the input text is unicode (default = true)
                 * @param String $encoding charset encoding; default is UTF-8
                 */
-               function TCPDF($orientation='P', $unit='mm', $format='A4', $uni=true, $encoding="UTF-8") {
+               function __construct($orientation='P', $unit='mm', $format='A4', $uni=true, $encoding="UTF-8") {
                        if ($uni) // Fix for FrontAccounting
                        {
                                global $unicode, $unicode_mirror, $unicode_arlet, $laa_array, $diacritics;
@@ -3594,8 +3597,8 @@ if (!class_exists('TCPDF')) {
                                if ($type == "jpg") {
                                        $type = "jpeg";
                                }
-                               $mqr = get_magic_quotes_runtime();
-                               set_magic_quotes_runtime(0);
+                               $mqr = ini_get('magic_quotes_runtime');
+                               ini_set('magic_quotes_runtime', 0);
                                // Specific image handlers
                                $mtd = '_parse'.$type;
                                // GD image handler function
@@ -3622,7 +3625,7 @@ if (!class_exists('TCPDF')) {
                                        //If false, we cannot process image
                                        return;
                                }
-                               set_magic_quotes_runtime($mqr);
+                               ini_set('magic_quotes_runtime', $mqr);
                                $info['i'] = count($this->images) + 1;
                                // add image to document
                                $this->images[$file] = $info;
@@ -4502,8 +4505,8 @@ if (!class_exists('TCPDF')) {
                                $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
                                $this->_out('endobj');
                        }
-                       $mqr = get_magic_quotes_runtime();
-                       set_magic_quotes_runtime(0);
+                       $mqr = ini_get('magic_quotes_runtime');
+                       ini_set('magic_quotes_runtime', 0);
                        foreach($this->FontFiles as $file => $info) {
                                //Font file embedding
                                $this->_newobj();
@@ -4533,7 +4536,7 @@ if (!class_exists('TCPDF')) {
                                $this->_putstream($font);
                                $this->_out('endobj');
                        }
-                       set_magic_quotes_runtime($mqr);
+                       ini_set('magic_quotes_runtime', $mqr);
                        foreach($this->fonts as $k => $font) {
                                //Font objects
                                $this->fonts[$k]['n'] = $this->n + 1;
@@ -4687,7 +4690,7 @@ if (!class_exists('TCPDF')) {
                function _putimages() {
                        $filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
                        reset($this->images);
-                       while (list($file, $info) = each($this->images)) {
+                       foreach ($this->images as $file => $info) {
                                $this->_newobj();
                                $this->images[$file]['n'] = $this->n;
                                $this->_out('<</Type /XObject');
@@ -5728,10 +5731,7 @@ if (!class_exists('TCPDF')) {
                 * @return string converted
                 */
                function unhtmlentities($text_to_convert) {
-                       if (!$this->isunicode) {
-                               return html_entity_decode($text_to_convert);
-                       }
-                       return html_entity_decode_php4($text_to_convert);
+                       return html_entity_decode($text_to_convert, ENT_QUOTES, $this->encoding);
                }
 
                // ENCRYPTION METHODS ----------------------------------
@@ -6190,7 +6190,15 @@ if (!class_exists('TCPDF')) {
                function SetLineWidth($width) {
                        //Set line width
                        $this->LineWidth = $width;
-                       $this->linestyleWidth = sprintf('%.2f w', ($width * $this->k));
+                       //$this->linestyleWidth = sprintf('%.2f w', ($width * $this->k));
+                       // FrontAccounting fix
+                       // My PHP 5.2.6 environment gave an "Unsupported operand types"
+                       // error for the multiplication on the next line some of the
+                       // time when this method is called - I debugged and sometimes
+                       // the $width parameter is some sort of weird array.  I don't
+                       // understand what's going on, but casting it to a (float) seems
+                       // to "fix" the problem.  -Jason Maas, 2009/09/25
+                       $this->linestyleWidth = sprintf('%.2f w', ((float) $width * (float) $this->k));
                        $this->_out($this->linestyleWidth);
                }
 
@@ -6249,7 +6257,7 @@ if (!class_exists('TCPDF')) {
                        if (isset($dash)) {
                                $dash_string = "";
                                if ($dash) {
-                                       if (ereg("^.+,", $dash)) {
+                                       if (preg_match("/^.+,/", $dash)) {
                                                $tab = explode(",", $dash);
                                        } else {
                                                $tab = array($dash);
@@ -7754,7 +7762,7 @@ if (!class_exists('TCPDF')) {
                        $k = $this->k;
                        $this->javascript .= sprintf("f".$name."=this.addField('%s','%s',%d,[%.2f,%.2f,%.2f,%.2f]);", $name, $type, $this->PageNo()-1, $x*$k, ($this->h-$y)*$k+1, ($x+$w)*$k, ($this->h-$y-$h)*$k+1)."\n";
                        $this->javascript .= "f".$name.".textSize=".$this->FontSizePt.";\n";
-                       while (list($key, $val) = each($prop)) {
+                       foreach ($prop as $key => $val) {
                                if (strcmp(substr($key,-5),"Color") == 0) {
                                        $val = $this->_JScolor($val);
                                } else {
@@ -8629,7 +8637,7 @@ if (!class_exists('TCPDF')) {
                                $this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F cm', $scale_x, 0, 0, $scale_y, $x1*(1-$scale_x), $y2*(1-$scale_y)));
                        }
                        // handle pc/unix/mac line endings
-                       $lines = split("\r\n|[\r\n]", $data);
+                       $lines = preg_split("/\r\n|[\r\n]/", $data);
                        $u=0;
                        $cnt = count($lines);
                        for ($i=0; $i < $cnt; $i++) {
@@ -9228,7 +9236,7 @@ if (!class_exists('TCPDF')) {
                                                // get attributes
                                                preg_match_all('/([^=\s]*)=["\']?([^"\']*)["\']?/', $element, $attr_array, PREG_PATTERN_ORDER);
                                                $dom[$key]['attribute'] = array(); // reset attribute array
-                                               while (list($id, $name) = each($attr_array[1])) {
+                                               foreach ($attr_array[1] as $id => $name) {
                                                        $dom[$key]['attribute'][strtolower($name)] = $attr_array[2][$id];
                                                }
                                                // split style attributes
@@ -9236,14 +9244,14 @@ if (!class_exists('TCPDF')) {
                                                        // 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])) {
+                                                       foreach ($style_array[1] as $id => $name) {
                                                                $dom[$key]['style'][strtolower($name)] = trim($style_array[2][$id]);
                                                        }
                                                        // --- get some style attributes ---
                                                        if (isset($dom[$key]['style']['font-family'])) {
                                                                // font family
                                                                if (isset($dom[$key]['style']['font-family'])) {
-                                                                       $fontslist = split(",", strtolower($dom[$key]['style']['font-family']));
+                                                                       $fontslist = preg_split("/,/", strtolower($dom[$key]['style']['font-family']));
                                                                        foreach($fontslist as $font) {
                                                                                $font = trim(strtolower($font));
                                                                                if (in_array($font, $this->fontlist)){
@@ -9335,7 +9343,7 @@ if (!class_exists('TCPDF')) {
                                                if ($dom[$key]['value'] == "font") {
                                                        // font family
                                                        if (isset($dom[$key]['attribute']['face'])) {
-                                                               $fontslist = split(",", strtolower($dom[$key]['attribute']['face']));
+                                                               $fontslist = preg_split("/,/", strtolower($dom[$key]['attribute']['face']));
                                                                foreach($fontslist as $font) {
                                                                        $font = trim(strtolower($font));
                                                                        if (in_array($font, $this->fontlist)){
@@ -10419,4 +10427,3 @@ if (!class_exists('TCPDF')) {
 //============================================================+
 // END OF FILE
 //============================================================+
-?>