@@ -102,8 +102,9 @@ discard block |
||
| 102 | 102 | function setSourceFile($filename) { |
| 103 | 103 | $this->current_filename = $filename; |
| 104 | 104 | |
| 105 | - if (!isset($this->parsers[$filename])) |
|
| 106 | - $this->parsers[$filename] = $this->_getPdfParser($filename); |
|
| 105 | + if (!isset($this->parsers[$filename])) { |
|
| 106 | + $this->parsers[$filename] = $this->_getPdfParser($filename); |
|
| 107 | + } |
|
| 107 | 108 | $this->current_parser =& $this->parsers[$filename]; |
| 108 | 109 | $this->setPDFVersion(max($this->getPDFVersion(), $this->current_parser->getPDFVersion())); |
| 109 | 110 | |
@@ -120,8 +121,9 @@ discard block |
||
| 120 | 121 | $filename = uniqid('tcpdi-'); |
| 121 | 122 | $this->current_filename = $filename; |
| 122 | 123 | |
| 123 | - if (!isset($this->parsers[$filename])) |
|
| 124 | - $this->parsers[$filename] = new tcpdi_parser($pdfdata, $filename); |
|
| 124 | + if (!isset($this->parsers[$filename])) { |
|
| 125 | + $this->parsers[$filename] = new tcpdi_parser($pdfdata, $filename); |
|
| 126 | + } |
|
| 125 | 127 | $this->current_parser =& $this->parsers[$filename]; |
| 126 | 128 | $this->setPDFVersion(max($this->getPDFVersion(), $this->current_parser->getPDFVersion())); |
| 127 | 129 | |
@@ -172,14 +174,16 @@ discard block |
||
| 172 | 174 | |
| 173 | 175 | // check if page already imported |
| 174 | 176 | $pageKey = $fn . '-' . ((int)$pageno) . $boxName; |
| 175 | - if (isset($this->_importedPages[$pageKey])) |
|
| 176 | - return $this->_importedPages[$pageKey]; |
|
| 177 | + if (isset($this->_importedPages[$pageKey])) { |
|
| 178 | + return $this->_importedPages[$pageKey]; |
|
| 179 | + } |
|
| 177 | 180 | |
| 178 | 181 | $parser =& $this->parsers[$fn]; |
| 179 | 182 | $parser->setPageno($pageno); |
| 180 | 183 | |
| 181 | - if (!in_array($boxName, $parser->availableBoxes)) |
|
| 182 | - return $this->Error(sprintf('Unknown box: %s', $boxName)); |
|
| 184 | + if (!in_array($boxName, $parser->availableBoxes)) { |
|
| 185 | + return $this->Error(sprintf('Unknown box: %s', $boxName)); |
|
| 186 | + } |
|
| 183 | 187 | |
| 184 | 188 | $pageboxes = $parser->getPageBoxes($pageno, $this->k); |
| 185 | 189 | |
@@ -190,13 +194,16 @@ discard block |
||
| 190 | 194 | * TrimBox: Default -> CropBox |
| 191 | 195 | * ArtBox: Default -> CropBox |
| 192 | 196 | */ |
| 193 | - if (!isset($pageboxes[$boxName]) && ($boxName == '/BleedBox' || $boxName == '/TrimBox' || $boxName == '/ArtBox')) |
|
| 194 | - $boxName = '/CropBox'; |
|
| 195 | - if (!isset($pageboxes[$boxName]) && $boxName == '/CropBox') |
|
| 196 | - $boxName = '/MediaBox'; |
|
| 197 | + if (!isset($pageboxes[$boxName]) && ($boxName == '/BleedBox' || $boxName == '/TrimBox' || $boxName == '/ArtBox')) { |
|
| 198 | + $boxName = '/CropBox'; |
|
| 199 | + } |
|
| 200 | + if (!isset($pageboxes[$boxName]) && $boxName == '/CropBox') { |
|
| 201 | + $boxName = '/MediaBox'; |
|
| 202 | + } |
|
| 197 | 203 | |
| 198 | - if (!isset($pageboxes[$boxName])) |
|
| 199 | - return false; |
|
| 204 | + if (!isset($pageboxes[$boxName])) { |
|
| 205 | + return false; |
|
| 206 | + } |
|
| 200 | 207 | |
| 201 | 208 | $this->lastUsedPageBox = $boxName; |
| 202 | 209 | |
@@ -228,8 +235,9 @@ discard block |
||
| 228 | 235 | $tpl['w'] = $steps % 2 == 0 ? $_w : $_h; |
| 229 | 236 | $tpl['h'] = $steps % 2 == 0 ? $_h : $_w; |
| 230 | 237 | |
| 231 | - if ($angle < 0) |
|
| 232 | - $angle += 360; |
|
| 238 | + if ($angle < 0) { |
|
| 239 | + $angle += 360; |
|
| 240 | + } |
|
| 233 | 241 | |
| 234 | 242 | $tpl['_rotationAngle'] = $angle * -1; |
| 235 | 243 | } |
@@ -282,10 +290,12 @@ discard block |
||
| 282 | 290 | $annots = $parser->getPageAnnotations(); |
| 283 | 291 | |
| 284 | 292 | if (is_array($annots) && $annots[0] == PDF_TYPE_ARRAY // It's an array |
| 285 | - && is_array($annots[1]) && count($annots[1]) > 1) // It's not empty - there are annotations for this page |
|
| 293 | + && is_array($annots[1]) && count($annots[1]) > 1) { |
|
| 294 | + // It's not empty - there are annotations for this page |
|
| 286 | 295 | { |
| 287 | 296 | if (!isset($this->_obj_stack[$fn])) { |
| 288 | 297 | $this->_obj_stack[$fn] = array(); |
| 298 | + } |
|
| 289 | 299 | } |
| 290 | 300 | |
| 291 | 301 | $this->_importedAnnots[$this->page] = array(); |
@@ -296,10 +306,12 @@ discard block |
||
| 296 | 306 | |
| 297 | 307 | if (is_array($annots) && $annots[0] == PDF_TYPE_OBJECT // We got an object |
| 298 | 308 | && is_array($annots[1]) && $annots[1][0] == PDF_TYPE_ARRAY // It's an array |
| 299 | - && is_array($annots[1][1]) && count($annots[1][1]) > 1) // It's not empty - there are annotations for this page |
|
| 309 | + && is_array($annots[1][1]) && count($annots[1][1]) > 1) { |
|
| 310 | + // It's not empty - there are annotations for this page |
|
| 300 | 311 | { |
| 301 | 312 | if (!isset($this->_obj_stack[$fn])) { |
| 302 | 313 | $this->_obj_stack[$fn] = array(); |
| 314 | + } |
|
| 303 | 315 | } |
| 304 | 316 | |
| 305 | 317 | $this->_importedAnnots[$this->page] = array(); |
@@ -512,8 +524,9 @@ discard block |
||
| 512 | 524 | $this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
| 513 | 525 | if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { |
| 514 | 526 | $this->_out('/Font <<'); |
| 515 | - foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) |
|
| 516 | - $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); |
|
| 527 | + foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) { |
|
| 528 | + $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); |
|
| 529 | + } |
|
| 517 | 530 | $this->_out('>>'); |
| 518 | 531 | } |
| 519 | 532 | if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || |
@@ -521,12 +534,14 @@ discard block |
||
| 521 | 534 | { |
| 522 | 535 | $this->_out('/XObject <<'); |
| 523 | 536 | if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { |
| 524 | - foreach($this->_res['tpl'][$tplidx]['images'] as $image) |
|
| 525 | - $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); |
|
| 537 | + foreach($this->_res['tpl'][$tplidx]['images'] as $image) { |
|
| 538 | + $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); |
|
| 539 | + } |
|
| 526 | 540 | } |
| 527 | 541 | if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { |
| 528 | - foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) |
|
| 529 | - $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); |
|
| 542 | + foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) { |
|
| 543 | + $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); |
|
| 544 | + } |
|
| 530 | 545 | } |
| 531 | 546 | $this->_out('>>'); |
| 532 | 547 | } |
@@ -804,8 +819,9 @@ discard block |
||
| 804 | 819 | $out .= chr(0x0A); |
| 805 | 820 | break; |
| 806 | 821 | case "\r": |
| 807 | - if ($count != $n-1 && $s[$count+1] == "\n") |
|
| 808 | - $count++; |
|
| 822 | + if ($count != $n-1 && $s[$count+1] == "\n") { |
|
| 823 | + $count++; |
|
| 824 | + } |
|
| 809 | 825 | break; |
| 810 | 826 | case "\n": |
| 811 | 827 | break; |
@@ -544,7 +544,9 @@ |
||
| 544 | 544 | if ($line_id <= 0) { |
| 545 | 545 | $error++; |
| 546 | 546 | } |
| 547 | - if (isset($kits_list[$line->fk_product])) $kits_id_cached[$line->fk_product] = $line_id; |
|
| 547 | + if (isset($kits_list[$line->fk_product])) { |
|
| 548 | + $kits_id_cached[$line->fk_product] = $line_id; |
|
| 549 | + } |
|
| 548 | 550 | } else { // with batch management |
| 549 | 551 | if ($this->create_line_batch($line, $line->array_options) <= 0) { |
| 550 | 552 | $error++; |
@@ -116,7 +116,10 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | $md5uniqid = md5(uniqid()); |
| 119 | - if ($this->config['PATH_TO_TMP']) $this->tmpdir = preg_replace('|[\/]$|', '', $this->config['PATH_TO_TMP']); // Remove last \ or / |
|
| 119 | + if ($this->config['PATH_TO_TMP']) { |
|
| 120 | + $this->tmpdir = preg_replace('|[\/]$|', '', $this->config['PATH_TO_TMP']); |
|
| 121 | + } |
|
| 122 | + // Remove last \ or / |
|
| 120 | 123 | $this->tmpdir .= ($this->tmpdir?'/':'').$md5uniqid; |
| 121 | 124 | $this->tmpfile = $this->tmpdir.'/'.$md5uniqid.'.odt'; // We keep .odt extension to allow OpenOffice usage during debug. |
| 122 | 125 | |
@@ -138,7 +141,9 @@ discard block |
||
| 138 | 141 | // Load zip proxy |
| 139 | 142 | $zipHandler = $this->config['ZIP_PROXY']; |
| 140 | 143 | |
| 141 | - if (!defined('PCLZIP_TEMPORARY_DIR')) define('PCLZIP_TEMPORARY_DIR', $this->tmpdir); |
|
| 144 | + if (!defined('PCLZIP_TEMPORARY_DIR')) { |
|
| 145 | + define('PCLZIP_TEMPORARY_DIR', $this->tmpdir); |
|
| 146 | + } |
|
| 142 | 147 | |
| 143 | 148 | include_once 'zip/'.$zipHandler.'.php'; |
| 144 | 149 | if (! class_exists($this->config['ZIP_PROXY'])) { |
@@ -284,8 +289,12 @@ discard block |
||
| 284 | 289 | */ |
| 285 | 290 | private function _replaceHtmlWithOdtTag($tags, &$customStyles, &$fontDeclarations, $encode = false, $charset = '') |
| 286 | 291 | { |
| 287 | - if ($customStyles == null) $customStyles = array(); |
|
| 288 | - if ($fontDeclarations == null) $fontDeclarations = array(); |
|
| 292 | + if ($customStyles == null) { |
|
| 293 | + $customStyles = array(); |
|
| 294 | + } |
|
| 295 | + if ($fontDeclarations == null) { |
|
| 296 | + $fontDeclarations = array(); |
|
| 297 | + } |
|
| 289 | 298 | |
| 290 | 299 | $odtResult = ''; |
| 291 | 300 | |
@@ -607,10 +616,15 @@ discard block |
||
| 607 | 616 | */ |
| 608 | 617 | private function _parse($type = 'content') |
| 609 | 618 | { |
| 610 | - if ($type == 'content') $xml = &$this->contentXml; |
|
| 611 | - elseif ($type == 'styles') $xml = &$this->stylesXml; |
|
| 612 | - elseif ($type == 'meta') $xml = &$this->metaXml; |
|
| 613 | - else return; |
|
| 619 | + if ($type == 'content') { |
|
| 620 | + $xml = &$this->contentXml; |
|
| 621 | + } elseif ($type == 'styles') { |
|
| 622 | + $xml = &$this->stylesXml; |
|
| 623 | + } elseif ($type == 'meta') { |
|
| 624 | + $xml = &$this->metaXml; |
|
| 625 | + } else { |
|
| 626 | + return; |
|
| 627 | + } |
|
| 614 | 628 | |
| 615 | 629 | // Search all tags found into condition to complete $this->vars, so we will proceed all tests even if not defined |
| 616 | 630 | $reg='@\[!--\sIF\s([\[\]{}a-zA-Z0-9\.\,_]+)\s--\]@smU'; |
@@ -649,7 +663,9 @@ discard block |
||
| 649 | 663 | $reg = '@\[!--\sIF\s' . preg_quote($key, '@') . '\s--\](.*)(\[!--\sELSE\s' . preg_quote($key, '@') . '\s--\](.*))?\[!--\sENDIF\s' . preg_quote($key, '@') . '\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
| 650 | 664 | preg_match_all($reg, $xml, $matches, PREG_SET_ORDER); |
| 651 | 665 | foreach ($matches as $match) { // For each match, if there is an ELSE clause, we replace the whole block by the value in the ELSE clause |
| 652 | - if (!empty($match[3])) $xml = str_replace($match[0], $match[3], $xml); |
|
| 666 | + if (!empty($match[3])) { |
|
| 667 | + $xml = str_replace($match[0], $match[3], $xml); |
|
| 668 | + } |
|
| 653 | 669 | } |
| 654 | 670 | // Cleanup the other conditional blocks (all the others where there were no ELSE clause, we can just remove them altogether) |
| 655 | 671 | $xml = preg_replace($reg, '', $xml); |
@@ -807,7 +823,9 @@ discard block |
||
| 807 | 823 | */ |
| 808 | 824 | public function setMetaData() |
| 809 | 825 | { |
| 810 | - if (empty($this->creator)) $this->creator=''; |
|
| 826 | + if (empty($this->creator)) { |
|
| 827 | + $this->creator=''; |
|
| 828 | + } |
|
| 811 | 829 | |
| 812 | 830 | $this->metaXml = preg_replace('/<dc:date>.*<\/dc:date>/', '<dc:date>'.gmdate("Y-m-d\TH:i:s").'</dc:date>', $this->metaXml); |
| 813 | 831 | $this->metaXml = preg_replace('/<dc:creator>.*<\/dc:creator>/', '<dc:creator>'.htmlspecialchars($this->creator).'</dc:creator>', $this->metaXml); |
@@ -879,7 +897,9 @@ discard block |
||
| 879 | 897 | { |
| 880 | 898 | global $conf; |
| 881 | 899 | |
| 882 | - if ( $name == "" ) $name = "temp".md5(uniqid()); |
|
| 900 | + if ( $name == "" ) { |
|
| 901 | + $name = "temp".md5(uniqid()); |
|
| 902 | + } |
|
| 883 | 903 | |
| 884 | 904 | dol_syslog(get_class($this).'::exportAsAttachedPDF $name='.$name, LOG_DEBUG); |
| 885 | 905 | $this->saveToDisk($name); |
@@ -2794,9 +2794,11 @@ |
||
| 2794 | 2794 | $outlangs = $langs; |
| 2795 | 2795 | $margin_rate = GETPOSTISSET('marginforalllines') ? GETPOST('marginforalllines', 'int') : ''; |
| 2796 | 2796 | $mark_rate = GETPOSTISSET('markforalllines') ? GETPOST('markforalllines', 'int') : ''; |
| 2797 | - foreach ($object->lines as &$line) if ($line->subprice > 0) { |
|
| 2797 | + foreach ($object->lines as &$line) { |
|
| 2798 | + if ($line->subprice > 0) { |
|
| 2798 | 2799 | if ($line->special_code == SUBTOTALS_SPECIAL_CODE) { |
| 2799 | 2800 | continue; |
| 2801 | + } |
|
| 2800 | 2802 | } |
| 2801 | 2803 | $subprice_multicurrency = $line->subprice; |
| 2802 | 2804 | if (is_numeric($margin_rate) && $margin_rate > 0) { |
@@ -1703,9 +1703,11 @@ |
||
| 1703 | 1703 | // Define margin |
| 1704 | 1704 | $margin_rate = GETPOSTISSET('marginforalllines') ? GETPOST('marginforalllines', 'int') : ''; |
| 1705 | 1705 | $mark_rate = GETPOSTISSET('markforalllines') ? GETPOST('markforalllines', 'int') : ''; |
| 1706 | - foreach ($object->lines as &$line) if ($line->subprice > 0) { |
|
| 1706 | + foreach ($object->lines as &$line) { |
|
| 1707 | + if ($line->subprice > 0) { |
|
| 1707 | 1708 | if ($line->special_code == SUBTOTALS_SPECIAL_CODE) { |
| 1708 | 1709 | continue; |
| 1710 | + } |
|
| 1709 | 1711 | } |
| 1710 | 1712 | $subprice_multicurrency = $line->subprice; |
| 1711 | 1713 | if (is_numeric($margin_rate) && $margin_rate > 0) { |
@@ -1703,9 +1703,11 @@ |
||
| 1703 | 1703 | // Define margin |
| 1704 | 1704 | $margin_rate = GETPOSTISSET('marginforalllines') ? GETPOST('marginforalllines', 'int') : ''; |
| 1705 | 1705 | $mark_rate = GETPOSTISSET('markforalllines') ? GETPOST('markforalllines', 'int') : ''; |
| 1706 | - foreach ($object->lines as &$line) if ($line->subprice > 0) { |
|
| 1706 | + foreach ($object->lines as &$line) { |
|
| 1707 | + if ($line->subprice > 0) { |
|
| 1707 | 1708 | if ($line->special_code == SUBTOTALS_SPECIAL_CODE) { |
| 1708 | 1709 | continue; |
| 1710 | + } |
|
| 1709 | 1711 | } |
| 1710 | 1712 | $subprice_multicurrency = $line->subprice; |
| 1711 | 1713 | if (is_numeric($margin_rate) && $margin_rate > 0) { |
@@ -1615,7 +1615,9 @@ |
||
| 1615 | 1615 | global $conf, $langs; |
| 1616 | 1616 | |
| 1617 | 1617 | $ltrdirection = 'L'; |
| 1618 | - if ($outputlangs->trans("DIRECTION") == 'rtl') $ltrdirection = 'R'; |
|
| 1618 | + if ($outputlangs->trans("DIRECTION") == 'rtl') { |
|
| 1619 | + $ltrdirection = 'R'; |
|
| 1620 | + } |
|
| 1619 | 1621 | |
| 1620 | 1622 | // Load traductions files required by page |
| 1621 | 1623 | $outputlangs->loadLangs(array("main", "bills", "propal", "companies")); |
@@ -1615,7 +1615,9 @@ |
||
| 1615 | 1615 | global $conf, $langs; |
| 1616 | 1616 | |
| 1617 | 1617 | $ltrdirection = 'L'; |
| 1618 | - if ($outputlangs->trans("DIRECTION") == 'rtl') $ltrdirection = 'R'; |
|
| 1618 | + if ($outputlangs->trans("DIRECTION") == 'rtl') { |
|
| 1619 | + $ltrdirection = 'R'; |
|
| 1620 | + } |
|
| 1619 | 1621 | |
| 1620 | 1622 | // Load traductions files required by page |
| 1621 | 1623 | $outputlangs->loadLangs(array("main", "bills", "propal", "companies")); |
@@ -1615,7 +1615,9 @@ |
||
| 1615 | 1615 | global $conf, $langs; |
| 1616 | 1616 | |
| 1617 | 1617 | $ltrdirection = 'L'; |
| 1618 | - if ($outputlangs->trans("DIRECTION") == 'rtl') $ltrdirection = 'R'; |
|
| 1618 | + if ($outputlangs->trans("DIRECTION") == 'rtl') { |
|
| 1619 | + $ltrdirection = 'R'; |
|
| 1620 | + } |
|
| 1619 | 1621 | |
| 1620 | 1622 | // Load traductions files required by page |
| 1621 | 1623 | $outputlangs->loadLangs(array("main", "bills", "propal", "companies")); |