Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foxido patch 1 #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/invoicepdfpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@

/**
* TCPDF class wrapper, set/overrides oxid specific functionality
*
*
* @deprecated since v5.3 (2016-08-06); class will be moved to the InvoicePDF module.
*/
class InvoicepdfPDF extends \TCPDF
Expand Down Expand Up @@ -378,4 +378,4 @@ public function SetFont($family, $style = '', $size = 0, $fontfile = '')

parent::SetFont($family, $style, $size, $fontfile);
}
}
}
106 changes: 77 additions & 29 deletions core/tcpdf/tcpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,7 @@ public function setTempRTL($mode) {
}

/**

* Set the last cell height.
* @param float $h cell height.
* @author Nicola Asuni
Expand Down Expand Up @@ -3668,9 +3669,9 @@ public function removeSHY($txt='') {
* UTF-8 (hex): 0xC2 0xAD (c2ad)
* UTF-8 character: chr(194).chr(173)
*/
$txt = preg_replace('/([\\xc2]{1}[\\xad]{1})/', '', $txt);
$txt = preg_replace('/([\\xc2][1][\\xad][1])/', '', $txt);
if (!$this->isunicode) {
$txt = preg_replace('/([\\xad]{1})/', '', $txt);
$txt = preg_replace('/([\\xad][1])/', '', $txt);
}
return $txt;
}
Expand Down Expand Up @@ -4725,6 +4726,7 @@ public function Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $alig
return $this->ImagePngAlpha($file, $x, $y, $w, $h, 'PNG', $link, $align, $resize, $dpi, $palign);
}
}

if (!$info) {
if (function_exists($gdfunction)) {
// GD library
Expand Down Expand Up @@ -6092,6 +6094,7 @@ protected function _putannotsobjs() {
if ($info !== false) {
$annots .= ' /IX '.$info['n'].' 0 R';
}

}
if (isset($pl['opt']['mk']['if']) AND (is_array($pl['opt']['mk']['if'])) AND !empty($pl['opt']['mk']['if'])) {
$annots .= ' /IF <<';
Expand Down Expand Up @@ -7659,7 +7662,7 @@ public function getPDFData() {
* @access public
*/
public function addHtmlLink($url, $name, $fill=0, $firstline=false, $color='', $style=-1) {
if (!$this->empty_string($url) AND ($url[0] == '#')) {
if (!$this->empty_string[$url] AND ($url[0] == '#')) {
// convert url to internal link
$page = intval(substr($url, 1));
$url = $this->AddLink();
Expand Down Expand Up @@ -10395,6 +10398,7 @@ protected function getAnnotOptFromJSProp($prop) {
* @access public
* @author Nicola Asuni
* @since 4.8.000 (2009-09-06)

*/
public function setFormDefaultProp($prop=array()) {
$this->default_form_prop = $prop;
Expand Down Expand Up @@ -11918,7 +11922,7 @@ public function ImageEps($file, $x='', $y='', $w=0, $h=0, $link='', $useBounding
case 'V':
case 'L':
case 'C': {
$line[$len-1] = strtolower($cmd);
$line[$len-1] = strtolower[$cmd];
$this->_out($line);
break;
}
Expand Down Expand Up @@ -12812,7 +12816,7 @@ protected function getHtmlDomArray($html) {
$decors = explode(' ', strtolower($dom[$key]['style']['text-decoration']));
foreach ($decors as $dec) {
$dec = trim($dec);
if (!$this->empty_string($dec)) {
if (!$this->empty_string[$dec]) {
if ($dec[0] == 'u') {
$dom[$key]['fontstyle'] .= 'U';
} elseif ($dec[0] == 'l') {
Expand Down Expand Up @@ -13384,9 +13388,16 @@ public function writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=fal
}
// justify block
$pmid = preg_replace_callback('/([0-9\.\+\-]*)[\s]('.$strpiece[1][0].')[\s]('.$strpiece[2][0].')([\s]*)/x',
create_function('$matches', 'global $spacew;


function($matches){
'global $spacew;
$newx = sprintf("%.2F",(floatval($matches[1]) + $spacew));
return "".$newx." ".$matches[2]." x*#!#*x".$matches[3].$matches[4];'), $pmid, 1);
return $newx." ".$matches[2]." x*#!#*x".$matches[3].$matches[4]';
}
,$pmid, 1);


break;
}
case 're': {
Expand All @@ -13395,9 +13406,17 @@ public function writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=fal
$currentxpos = $xmatches[1];
// justify block
$pmid = preg_replace_callback('/([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]('.$strpiece[1][0].')[\s]('.$strpiece[2][0].')([\s]*)/x',
create_function('$matches', 'global $spacew;


function($matches)
{
'global $spacew;
$newx = sprintf("%.2F",(floatval($matches[1]) + $spacew));
return "".$newx." ".$matches[2]." ".$matches[3]." ".$matches[4]." x*#!#*x".$matches[5].$matches[6];'), $pmid, 1);
return $newx." ".$matches[2]." ".$matches[3]." ".$matches[4]." x*#!#*x".$matches[5].$matches[6]';
}
,$pmid, 1);


break;
}
case 'c': {
Expand All @@ -13406,11 +13425,18 @@ public function writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=fal
$currentxpos = $xmatches[1];
// justify block
$pmid = preg_replace_callback('/([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]('.$strpiece[1][0].')[\s]('.$strpiece[2][0].')([\s]*)/x',
create_function('$matches', 'global $spacew;
$newx1 = sprintf("%.3F",(floatval($matches[1]) + $spacew));
$newx2 = sprintf("%.3F",(floatval($matches[3]) + $spacew));
$newx3 = sprintf("%.3F",(floatval($matches[5]) + $spacew));
return "".$newx1." ".$matches[2]." ".$newx2." ".$matches[4]." ".$newx3." ".$matches[6]." x*#!#*x".$matches[7].$matches[8];'), $pmid, 1);


function($matches)
{
'global $spacew;
$newx1 = sprintf("%.3F",(floatval($matches[1]) + $spacew));
$newx2 = sprintf("%.3F",(floatval($matches[3]) + $spacew));
$newx3 = sprintf("%.3F",(floatval($matches[5]) + $spacew));
return $newx1." ".$matches[2]." ".$newx2." ".$matches[4]." ".$newx3." ".$matches[6]." x*#!#*x".$matches[7].$matches[8]';
}
,$pmid, 1);

break;
}
}
Expand All @@ -13435,10 +13461,18 @@ public function writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=fal
$pmidtemp = preg_replace('/[\\\][\(]/x', '\\#!#OP#!#', $pmidtemp);
$pmidtemp = preg_replace('/[\\\][\)]/x', '\\#!#CP#!#', $pmidtemp);
$pmid = preg_replace_callback("/\[\(([^\)]*)\)\]/x",
create_function('$matches', 'global $spacew;


function($matches)
{
'global $spacew;
$matches[1] = str_replace("#!#OP#!#", "(", $matches[1]);
$matches[1] = str_replace("#!#CP#!#", ")", $matches[1]);
return "[(".str_replace(chr(0).chr(32), ") ".($spacew)." (", $matches[1]).")]";'), $pmidtemp);
return "[(".str_replace(chr(0).chr(32), ") ".($spacew)." (", $matches[1]).")]"';
}
,$pmidtemp);


$this->setPageBuffer($startlinepage, $pstart."\n".$pmid."\n".$pend);
$endlinepos = strlen($pstart."\n".$pmid."\n");
} else {
Expand Down Expand Up @@ -15638,17 +15672,26 @@ public function movePage($frompage, $topage) {
$jfrompage = $frompage;
$jtopage = $topage;
$this->javascript = preg_replace_callback('/this\.addField\(\'([^\']*)\',\'([^\']*)\',([0-9]+)/',
create_function('$matches', 'global $jfrompage, $jtopage;
$pagenum = intval($matches[3]) + 1;
if (($pagenum >= $jtopage) AND ($pagenum < $jfrompage)) {
$newpage = ($pagenum + 1);
} elseif ($pagenum == $jfrompage) {
$newpage = $jtopage;
} else {
$newpage = $pagenum;
}
--$newpage;
return "this.addField(\'".$matches[1]."\',\'".$matches[2]."\',".$newpage."";'), $tmpjavascript);



function($matches, $jtopage)
{
'global $jfrompage;
$pagenum = intval($matches[3]) + 1;
if (($pagenum >= $jtopage) AND ($pagenum < $jfrompage)) {
$newpage = ($pagenum + 1);
} elseif ($pagenum == $jfrompage) {
$newpage = $jtopage;
} else {
$newpage = $pagenum;
}
--$newpage;
return "this.addField(\'".$matches[1]."\',\'".$matches[2]."\',".$newpage.""';
}
,$tmpjavascript);


// return to last page
$this->lastPage(true);
return true;
Expand Down Expand Up @@ -15775,7 +15818,9 @@ public function deletePage($page) {
global $jpage;
$jpage = $page;
$this->javascript = preg_replace_callback('/this\.addField\(\'([^\']*)\',\'([^\']*)\',([0-9]+)/',
create_function('$matches', 'global $jpage;
function($matches)
{
'global $jpage;
$pagenum = intval($matches[3]) + 1;
if ($pagenum >= $jpage) {
$newpage = ($pagenum - 1);
Expand All @@ -15785,7 +15830,10 @@ public function deletePage($page) {
$newpage = $pagenum;
}
--$newpage;
return "this.addField(\'".$matches[1]."\',\'".$matches[2]."\',".$newpage."";'), $tmpjavascript);
return "this.addField(\'".$matches[1]."\',\'".$matches[2]."\',".$newpage.""';
}
,$tmpjavascript);

// return to last page
$this->lastPage(true);
return true;
Expand Down
3 changes: 2 additions & 1 deletion models/invoicepdfoxorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ protected function _replaceExtendedChars($sValue, $blReverse = false)

$aTransTbl = array_flip($aTransTbl) + array_flip($aReplace);
$sValue = strtr($sValue, $aTransTbl);
$sValue = getStr()->preg_replace_callback('/\&\#([0-9]+)\;/m', function ($matches) { return chr($matches[1]); }, $sValue);
$sValue = getStr()->preg_replace_callback('/\&\#([0-9]+)\;/m', function($matches){'return chr(\$matches[1])';} , $sValue);
}

return $sValue;
Expand Down Expand Up @@ -722,4 +722,5 @@ public function getPaymentTerm()

return $iPaymentTerm;
}

}