@@ -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); |