@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | class Odf |
| 32 | 32 | { |
| 33 | 33 | protected $config = array( |
| 34 | - 'ZIP_PROXY' => 'PclZipProxy', // PclZipProxy, PhpZipProxy |
|
| 34 | + 'ZIP_PROXY' => 'PclZipProxy', // PclZipProxy, PhpZipProxy |
|
| 35 | 35 | 'DELIMITER_LEFT' => '{', |
| 36 | 36 | 'DELIMITER_RIGHT' => '}', |
| 37 | 37 | 'PATH_TO_TMP' => '/tmp' |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | clearstatcache(); |
| 108 | 108 | |
| 109 | - if (! is_array($config)) { |
|
| 109 | + if (!is_array($config)) { |
|
| 110 | 110 | throw new OdfException('Configuration data must be provided as array'); |
| 111 | 111 | } |
| 112 | 112 | foreach ($config as $configKey => $configValue) { |
@@ -116,12 +116,12 @@ 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 / |
|
| 120 | - $this->tmpdir .= ($this->tmpdir?'/':'').$md5uniqid; |
|
| 121 | - $this->tmpfile = $this->tmpdir.'/'.$md5uniqid.'.odt'; // We keep .odt extension to allow OpenOffice usage during debug. |
|
| 119 | + if ($this->config['PATH_TO_TMP']) $this->tmpdir = preg_replace('|[\/]$|', '', $this->config['PATH_TO_TMP']); // Remove last \ or / |
|
| 120 | + $this->tmpdir .= ($this->tmpdir ? '/' : '').$md5uniqid; |
|
| 121 | + $this->tmpfile = $this->tmpdir.'/'.$md5uniqid.'.odt'; // We keep .odt extension to allow OpenOffice usage during debug. |
|
| 122 | 122 | |
| 123 | 123 | // A working directory is required for some zip proxy like PclZipProxy |
| 124 | - if (in_array($this->config['ZIP_PROXY'], array('PclZipProxy')) && ! is_dir($this->config['PATH_TO_TMP'])) { |
|
| 124 | + if (in_array($this->config['ZIP_PROXY'], array('PclZipProxy')) && !is_dir($this->config['PATH_TO_TMP'])) { |
|
| 125 | 125 | throw new OdfException('Temporary directory '.$this->config['PATH_TO_TMP'].' must exists'); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -141,8 +141,8 @@ discard block |
||
| 141 | 141 | if (!defined('PCLZIP_TEMPORARY_DIR')) define('PCLZIP_TEMPORARY_DIR', $this->tmpdir); |
| 142 | 142 | |
| 143 | 143 | include_once 'zip/'.$zipHandler.'.php'; |
| 144 | - if (! class_exists($this->config['ZIP_PROXY'])) { |
|
| 145 | - throw new OdfException($this->config['ZIP_PROXY'] . ' class not found - check your php settings'); |
|
| 144 | + if (!class_exists($this->config['ZIP_PROXY'])) { |
|
| 145 | + throw new OdfException($this->config['ZIP_PROXY'].' class not found - check your php settings'); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | $this->file = new $zipHandler($this->tmpdir); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public function setVars($key, $value, $encode = true, $charset = 'ISO-8859') |
| 194 | 194 | { |
| 195 | - $tag = $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']; |
|
| 195 | + $tag = $this->config['DELIMITER_LEFT'].$key.$this->config['DELIMITER_RIGHT']; |
|
| 196 | 196 | |
| 197 | 197 | // TODO Warning string may be: |
| 198 | 198 | // <text:span text:style-name="T13">{</text:span><text:span text:style-name="T12">aaa</text:span><text:span text:style-name="T13">}</text:span> |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | // Check if the value includes html tags |
| 229 | 229 | if ($this->_hasHtmlTag($value) === true) { |
| 230 | - $value = strip_tags($value, '<br><strong><b><i><em><u><s><sub><sup><span>'); // remove html tags except the one into the list in second parameter |
|
| 230 | + $value = strip_tags($value, '<br><strong><b><i><em><u><s><sub><sup><span>'); // remove html tags except the one into the list in second parameter |
|
| 231 | 231 | |
| 232 | 232 | // Default styles for strong/b, i/em, u, s, sub & sup |
| 233 | 233 | $automaticStyles = array( |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $convertedValue = $this->_replaceHtmlWithOdtTag($this->_getDataFromHtml($value), $customStyles, $fontDeclarations, $encode, $charset); |
| 246 | 246 | |
| 247 | 247 | foreach ($customStyles as $key => $val) { |
| 248 | - array_push($automaticStyles, '<style:style style:name="customStyle' . $key . '" style:family="text">' . $val . '</style:style>'); |
|
| 248 | + array_push($automaticStyles, '<style:style style:name="customStyle'.$key.'" style:family="text">'.$val.'</style:style>'); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // Join the styles and add them to the content xml |
@@ -255,16 +255,16 @@ discard block |
||
| 255 | 255 | $styles .= $style; |
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | - $this->contentXml = str_replace('</office:automatic-styles>', $styles . '</office:automatic-styles>', $this->contentXml); |
|
| 258 | + $this->contentXml = str_replace('</office:automatic-styles>', $styles.'</office:automatic-styles>', $this->contentXml); |
|
| 259 | 259 | |
| 260 | 260 | // Join the font declarations and add them to the content xml |
| 261 | 261 | $fonts = ''; |
| 262 | 262 | foreach ($fontDeclarations as $font) { |
| 263 | - if (strpos($this->contentXml, 'style:name="' . $font . '"') === false) { |
|
| 264 | - $fonts .= '<style:font-face style:name="' . $font . '" svg:font-family="\'' . $font . '\'" />'; |
|
| 263 | + if (strpos($this->contentXml, 'style:name="'.$font.'"') === false) { |
|
| 264 | + $fonts .= '<style:font-face style:name="'.$font.'" svg:font-family="\''.$font.'\'" />'; |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | - $this->contentXml = str_replace('</office:font-face-decls>', $fonts . '</office:font-face-decls>', $this->contentXml); |
|
| 267 | + $this->contentXml = str_replace('</office:font-face-decls>', $fonts.'</office:font-face-decls>', $this->contentXml); |
|
| 268 | 268 | } else { |
| 269 | 269 | $convertedValue = $this->encode_chars($convertedValue, $encode, $charset); |
| 270 | 270 | $convertedValue = preg_replace('/(\r\n|\r|\n)/i', "<text:line-break/>", $convertedValue); |
@@ -301,23 +301,23 @@ discard block |
||
| 301 | 301 | break; |
| 302 | 302 | case 'strong': |
| 303 | 303 | case 'b': |
| 304 | - $odtResult .= '<text:span text:style-name="boldText">' . ($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)) . '</text:span>'; |
|
| 304 | + $odtResult .= '<text:span text:style-name="boldText">'.($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)).'</text:span>'; |
|
| 305 | 305 | break; |
| 306 | 306 | case 'i': |
| 307 | 307 | case 'em': |
| 308 | - $odtResult .= '<text:span text:style-name="italicText">' . ($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)) . '</text:span>'; |
|
| 308 | + $odtResult .= '<text:span text:style-name="italicText">'.($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)).'</text:span>'; |
|
| 309 | 309 | break; |
| 310 | 310 | case 'u': |
| 311 | - $odtResult .= '<text:span text:style-name="underlineText">' . ($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)) . '</text:span>'; |
|
| 311 | + $odtResult .= '<text:span text:style-name="underlineText">'.($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)).'</text:span>'; |
|
| 312 | 312 | break; |
| 313 | 313 | case 's': |
| 314 | - $odtResult .= '<text:span text:style-name="strikethroughText">' . ($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)) . '</text:span>'; |
|
| 314 | + $odtResult .= '<text:span text:style-name="strikethroughText">'.($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)).'</text:span>'; |
|
| 315 | 315 | break; |
| 316 | 316 | case 'sub': |
| 317 | - $odtResult .= '<text:span text:style-name="subText">' . ($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)) . '</text:span>'; |
|
| 317 | + $odtResult .= '<text:span text:style-name="subText">'.($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)).'</text:span>'; |
|
| 318 | 318 | break; |
| 319 | 319 | case 'sup': |
| 320 | - $odtResult .= '<text:span text:style-name="supText">' . ($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)) . '</text:span>'; |
|
| 320 | + $odtResult .= '<text:span text:style-name="supText">'.($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)).'</text:span>'; |
|
| 321 | 321 | break; |
| 322 | 322 | case 'span': |
| 323 | 323 | if (isset($tag['attributes']['style'])) { |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | if (!in_array($fontName, $fontDeclarations)) { |
| 333 | 333 | array_push($fontDeclarations, $fontName); |
| 334 | 334 | } |
| 335 | - $odtStyles .= '<style:text-properties style:font-name="' . $fontName . '" />'; |
|
| 335 | + $odtStyles .= '<style:text-properties style:font-name="'.$fontName.'" />'; |
|
| 336 | 336 | break; |
| 337 | 337 | case 'font-size': |
| 338 | 338 | if (preg_match('/([0-9]+)\s?(px|pt)/', $styleValue, $matches)) { |
@@ -340,21 +340,21 @@ discard block |
||
| 340 | 340 | if ($matches[2] == 'px') { |
| 341 | 341 | $fontSize = round($fontSize * 0.75); |
| 342 | 342 | } |
| 343 | - $odtStyles .= '<style:text-properties fo:font-size="' . $fontSize . 'pt" style:font-size-asian="' . $fontSize . 'pt" style:font-size-complex="' . $fontSize . 'pt" />'; |
|
| 343 | + $odtStyles .= '<style:text-properties fo:font-size="'.$fontSize.'pt" style:font-size-asian="'.$fontSize.'pt" style:font-size-complex="'.$fontSize.'pt" />'; |
|
| 344 | 344 | } |
| 345 | 345 | break; |
| 346 | 346 | case 'color': |
| 347 | 347 | if (preg_match('/#[0-9A-Fa-f]{3}(?:[0-9A-Fa-f]{3})?/', $styleValue)) { |
| 348 | - $odtStyles .= '<style:text-properties fo:color="' . $styleValue . '" />'; |
|
| 348 | + $odtStyles .= '<style:text-properties fo:color="'.$styleValue.'" />'; |
|
| 349 | 349 | } |
| 350 | 350 | break; |
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | if (strlen($odtStyles) > 0) { |
| 354 | 354 | // Generate a unique id for the style (using microtime and random because some CPUs are really fast...) |
| 355 | - $key = str_replace('.', '', (string) microtime(true)) . uniqid(mt_rand()); |
|
| 355 | + $key = str_replace('.', '', (string) microtime(true)).uniqid(mt_rand()); |
|
| 356 | 356 | $customStyles[$key] = $odtStyles; |
| 357 | - $odtResult .= '<text:span text:style-name="customStyle' . $key . '">' . ($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)) . '</text:span>'; |
|
| 357 | + $odtResult .= '<text:span text:style-name="customStyle'.$key.'">'.($tag['children'] != null ? $this->_replaceHtmlWithOdtTag($tag['children'], $customStyles, $fontDeclarations, $encode) : $this->encode_chars($tag['innerText'], $encode, $charset)).'</text:span>'; |
|
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | break; |
@@ -493,24 +493,24 @@ discard block |
||
| 493 | 493 | public function htmlToUTFAndPreOdf($value) |
| 494 | 494 | { |
| 495 | 495 | // We decode into utf8, entities |
| 496 | - $value=dol_html_entity_decode($value, ENT_QUOTES|ENT_HTML5); |
|
| 496 | + $value = dol_html_entity_decode($value, ENT_QUOTES | ENT_HTML5); |
|
| 497 | 497 | |
| 498 | 498 | // We convert html tags |
| 499 | - $ishtml=dol_textishtml($value); |
|
| 499 | + $ishtml = dol_textishtml($value); |
|
| 500 | 500 | if ($ishtml) { |
| 501 | 501 | // If string is "MYPODUCT - Desc <strong>bold</strong> with é accent<br />\n<br />\nUn texto en español ?" |
| 502 | 502 | // Result after clean must be "MYPODUCT - Desc bold with é accent\n\nUn texto en español ?" |
| 503 | 503 | |
| 504 | 504 | // We want to ignore \n and we want all <br> to be \n |
| 505 | - $value=preg_replace('/(\r\n|\r|\n)/i', '', $value); |
|
| 506 | - $value=preg_replace('/<br>/i', "\n", $value); |
|
| 507 | - $value=preg_replace('/<br\s+[^<>\/]*>/i', "\n", $value); |
|
| 508 | - $value=preg_replace('/<br\s+[^<>\/]*\/>/i', "\n", $value); |
|
| 505 | + $value = preg_replace('/(\r\n|\r|\n)/i', '', $value); |
|
| 506 | + $value = preg_replace('/<br>/i', "\n", $value); |
|
| 507 | + $value = preg_replace('/<br\s+[^<>\/]*>/i', "\n", $value); |
|
| 508 | + $value = preg_replace('/<br\s+[^<>\/]*\/>/i', "\n", $value); |
|
| 509 | 509 | |
| 510 | 510 | //$value=preg_replace('/<strong>/','__lt__text:p text:style-name=__quot__bold__quot____gt__',$value); |
| 511 | 511 | //$value=preg_replace('/<\/strong>/','__lt__/text:p__gt__',$value); |
| 512 | 512 | |
| 513 | - $value=dol_string_nohtmltag($value, 0); |
|
| 513 | + $value = dol_string_nohtmltag($value, 0); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | return $value; |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | * @throws OdfException |
| 544 | 544 | * @return odf |
| 545 | 545 | */ |
| 546 | - public function setImage($key, $value, float $ratio=1) |
|
| 546 | + public function setImage($key, $value, float $ratio = 1) |
|
| 547 | 547 | { |
| 548 | 548 | $filename = strtok(strrchr($value, '/'), '/.'); |
| 549 | 549 | $file = substr(strrchr($value, '/'), 1); |
@@ -587,10 +587,10 @@ discard block |
||
| 587 | 587 | $balise = str_replace('row.', '', $matches2[1]); |
| 588 | 588 | // Move segment tags around the row |
| 589 | 589 | $replace = array( |
| 590 | - '[!-- BEGIN ' . $matches2[1] . ' --]' => '', |
|
| 591 | - '[!-- END ' . $matches2[1] . ' --]' => '', |
|
| 592 | - '<table:table-row' => '[!-- BEGIN ' . $balise . ' --]<table:table-row', |
|
| 593 | - '</table:table-row>' => '</table:table-row>[!-- END ' . $balise . ' --]' |
|
| 590 | + '[!-- BEGIN '.$matches2[1].' --]' => '', |
|
| 591 | + '[!-- END '.$matches2[1].' --]' => '', |
|
| 592 | + '<table:table-row' => '[!-- BEGIN '.$balise.' --]<table:table-row', |
|
| 593 | + '</table:table-row>' => '</table:table-row>[!-- END '.$balise.' --]' |
|
| 594 | 594 | ); |
| 595 | 595 | $replacedXML = str_replace(array_keys($replace), array_values($replace), $matches[0][$i]); |
| 596 | 596 | $this->contentXml = str_replace($matches[0][$i], $replacedXML, $this->contentXml); |
@@ -613,13 +613,13 @@ discard block |
||
| 613 | 613 | else return; |
| 614 | 614 | |
| 615 | 615 | // Search all tags found into condition to complete $this->vars, so we will proceed all tests even if not defined |
| 616 | - $reg='@\[!--\sIF\s([\[\]{}a-zA-Z0-9\.\,_]+)\s--\]@smU'; |
|
| 616 | + $reg = '@\[!--\sIF\s([\[\]{}a-zA-Z0-9\.\,_]+)\s--\]@smU'; |
|
| 617 | 617 | $matches = array(); |
| 618 | 618 | preg_match_all($reg, $xml, $matches, PREG_SET_ORDER); |
| 619 | 619 | |
| 620 | 620 | foreach ($matches as $match) { // For each match, if there is no entry into this->vars, we add it |
| 621 | - if (! empty($match[1]) && ! isset($this->vars[$match[1]])) { |
|
| 622 | - $this->vars[$match[1]] = ''; // Not defined, so we set it to '', we just need entry into this->vars for next loop |
|
| 621 | + if (!empty($match[1]) && !isset($this->vars[$match[1]])) { |
|
| 622 | + $this->vars[$match[1]] = ''; // Not defined, so we set it to '', we just need entry into this->vars for next loop |
|
| 623 | 623 | } |
| 624 | 624 | } |
| 625 | 625 | |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | // Remove the IF tag |
| 634 | 634 | $xml = str_replace('[!-- IF '.$key.' --]', '', $xml); |
| 635 | 635 | // Remove everything between the ELSE tag (if it exists) and the ENDIF tag |
| 636 | - $reg = '@(\[!--\sELSE\s' . preg_quote($key, '@') . '\s--\](.*))?\[!--\sENDIF\s' . preg_quote($key, '@') . '\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
|
| 636 | + $reg = '@(\[!--\sELSE\s'.preg_quote($key, '@').'\s--\](.*))?\[!--\sENDIF\s'.preg_quote($key, '@').'\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
|
| 637 | 637 | $xml = preg_replace($reg, '', $xml); |
| 638 | 638 | /*if ($sav != $xml) |
| 639 | 639 | { |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | //dol_syslog("Var ".$key." is not defined, we remove the IF, ELSE and ENDIF "); |
| 647 | 647 | //$sav=$xml; |
| 648 | 648 | // Find all conditional blocks for this variable: from IF to ELSE and to ENDIF |
| 649 | - $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 |
|
| 649 | + $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 | 650 | preg_match_all($reg, $xml, $matches, PREG_SET_ORDER); |
| 651 | 651 | 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 | 652 | if (!empty($match[3])) $xml = str_replace($match[0], $match[3], $xml); |
@@ -674,12 +674,12 @@ discard block |
||
| 674 | 674 | */ |
| 675 | 675 | public function mergeSegment(Segment $segment) |
| 676 | 676 | { |
| 677 | - if (! array_key_exists($segment->getName(), $this->segments)) { |
|
| 678 | - throw new OdfException($segment->getName() . 'cannot be parsed, has it been set yet ?'); |
|
| 677 | + if (!array_key_exists($segment->getName(), $this->segments)) { |
|
| 678 | + throw new OdfException($segment->getName().'cannot be parsed, has it been set yet ?'); |
|
| 679 | 679 | } |
| 680 | 680 | $string = $segment->getName(); |
| 681 | 681 | // $reg = '@<text:p[^>]*>\[!--\sBEGIN\s' . $string . '\s--\](.*)\[!--.+END\s' . $string . '\s--\]<\/text:p>@smU'; |
| 682 | - $reg = '@\[!--\sBEGIN\s' . $string . '\s--\](.*)\[!--.+END\s' . $string . '\s--\]@smU'; |
|
| 682 | + $reg = '@\[!--\sBEGIN\s'.$string.'\s--\](.*)\[!--.+END\s'.$string.'\s--\]@smU'; |
|
| 683 | 683 | $this->contentXml = preg_replace($reg, $segment->getXmlParsed(), $this->contentXml); |
| 684 | 684 | return $this; |
| 685 | 685 | } |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | */ |
| 692 | 692 | public function printVars() |
| 693 | 693 | { |
| 694 | - return print_r('<pre>' . print_r($this->vars, true) . '</pre>', true); |
|
| 694 | + return print_r('<pre>'.print_r($this->vars, true).'</pre>', true); |
|
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | /** |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | */ |
| 713 | 713 | public function printDeclaredSegments() |
| 714 | 714 | { |
| 715 | - return '<pre>' . print_r(implode(' ', array_keys($this->segments)), true) . '</pre>'; |
|
| 715 | + return '<pre>'.print_r(implode(' ', array_keys($this->segments)), true).'</pre>'; |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | /** |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | { |
| 749 | 749 | if ($file !== null && is_string($file)) { |
| 750 | 750 | if (file_exists($file) && !(is_file($file) && is_writable($file))) { |
| 751 | - throw new OdfException('Permission denied : can\'t create ' . $file); |
|
| 751 | + throw new OdfException('Permission denied : can\'t create '.$file); |
|
| 752 | 752 | } |
| 753 | 753 | $this->_save(); |
| 754 | 754 | copy($this->tmpfile, $file); |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | */ |
| 766 | 766 | private function _save() |
| 767 | 767 | { |
| 768 | - $res=$this->file->open($this->tmpfile); // tmpfile is odt template |
|
| 768 | + $res = $this->file->open($this->tmpfile); // tmpfile is odt template |
|
| 769 | 769 | |
| 770 | 770 | $this->_parse('content'); |
| 771 | 771 | $this->_parse('styles'); |
@@ -774,26 +774,26 @@ discard block |
||
| 774 | 774 | $this->setMetaData(); |
| 775 | 775 | //print $this->metaXml;exit; |
| 776 | 776 | |
| 777 | - if (! $this->file->addFromString('content.xml', $this->contentXml)) { |
|
| 777 | + if (!$this->file->addFromString('content.xml', $this->contentXml)) { |
|
| 778 | 778 | throw new OdfException('Error during file export addFromString content'); |
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | // NOTE: After the first addFromString() that do the first $this->pclzip->delete, when using pclzip handler, the zip/oft file is corrupted (no way to edit it with Fileroller). |
| 782 | 782 | |
| 783 | - if (! $this->file->addFromString('meta.xml', $this->metaXml)) { |
|
| 783 | + if (!$this->file->addFromString('meta.xml', $this->metaXml)) { |
|
| 784 | 784 | throw new OdfException('Error during file export addFromString meta'); |
| 785 | 785 | } |
| 786 | - if (! $this->file->addFromString('styles.xml', $this->stylesXml)) { |
|
| 786 | + if (!$this->file->addFromString('styles.xml', $this->stylesXml)) { |
|
| 787 | 787 | throw new OdfException('Error during file export addFromString styles'); |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | foreach ($this->images as $imageKey => $imageValue) { |
| 791 | 791 | // Add the image inside the ODT document |
| 792 | - $this->file->addFile($imageKey, 'Pictures/' . $imageValue); |
|
| 792 | + $this->file->addFile($imageKey, 'Pictures/'.$imageValue); |
|
| 793 | 793 | // Add the image to the Manifest (which maintains a list of images, necessary to avoid "Corrupt ODT file. Repair?" when opening the file with LibreOffice) |
| 794 | 794 | $this->addImageToManifest($imageValue); |
| 795 | 795 | } |
| 796 | - if (! $this->file->addFromString('META-INF/manifest.xml', $this->manifestXml)) { |
|
| 796 | + if (!$this->file->addFromString('META-INF/manifest.xml', $this->manifestXml)) { |
|
| 797 | 797 | throw new OdfException('Error during file export: manifest.xml'); |
| 798 | 798 | } |
| 799 | 799 | $this->file->close(); |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | */ |
| 808 | 808 | public function setMetaData() |
| 809 | 809 | { |
| 810 | - if (empty($this->creator)) $this->creator=''; |
|
| 810 | + if (empty($this->creator)) $this->creator = ''; |
|
| 811 | 811 | |
| 812 | 812 | $this->metaXml = preg_replace('/<dc:date>.*<\/dc:date>/', '<dc:date>'.gmdate("Y-m-d\TH:i:s").'</dc:date>', $this->metaXml); |
| 813 | 813 | $this->metaXml = preg_replace('/<dc:creator>.*<\/dc:creator>/', '<dc:creator>'.htmlspecialchars($this->creator).'</dc:creator>', $this->metaXml); |
@@ -856,8 +856,8 @@ discard block |
||
| 856 | 856 | throw new OdfException("headers already sent ($filename at $linenum)"); |
| 857 | 857 | } |
| 858 | 858 | |
| 859 | - if ( $name == "" ) { |
|
| 860 | - $name = md5(uniqid()) . ".odt"; |
|
| 859 | + if ($name == "") { |
|
| 860 | + $name = md5(uniqid()).".odt"; |
|
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | header('Content-type: application/vnd.oasis.opendocument.text'); |
@@ -879,18 +879,18 @@ discard block |
||
| 879 | 879 | { |
| 880 | 880 | global $conf; |
| 881 | 881 | |
| 882 | - if ( $name == "" ) $name = "temp".md5(uniqid()); |
|
| 882 | + if ($name == "") $name = "temp".md5(uniqid()); |
|
| 883 | 883 | |
| 884 | 884 | dol_syslog(get_class($this).'::exportAsAttachedPDF $name='.$name, LOG_DEBUG); |
| 885 | 885 | $this->saveToDisk($name); |
| 886 | 886 | |
| 887 | - $execmethod = (getDolGlobalString('MAIN_EXEC_USE_POPEN') ? 2 : 1); // 1 or 2 |
|
| 887 | + $execmethod = (getDolGlobalString('MAIN_EXEC_USE_POPEN') ? 2 : 1); // 1 or 2 |
|
| 888 | 888 | // Method 1 sometimes hang the server. |
| 889 | 889 | |
| 890 | 890 | |
| 891 | 891 | // Export to PDF using LibreOffice |
| 892 | 892 | if (getDolGlobalString('MAIN_ODT_AS_PDF') == 'libreoffice') { |
| 893 | - dol_mkdir($conf->user->dir_temp); // We must be sure the directory exists and is writable |
|
| 893 | + dol_mkdir($conf->user->dir_temp); // We must be sure the directory exists and is writable |
|
| 894 | 894 | |
| 895 | 895 | // We delete and recreate a subdir because the soffice may have change pemrissions on it |
| 896 | 896 | $countdeleted = 0; |
@@ -901,7 +901,7 @@ discard block |
||
| 901 | 901 | // using windows libreoffice that must be in path |
| 902 | 902 | // using linux/mac libreoffice that must be in path |
| 903 | 903 | // Note PHP Config "fastcgi.impersonate=0" must set to 0 - Default is 1 |
| 904 | - $command ='soffice --headless -env:UserInstallation=file:'.(getDolGlobalString('MAIN_ODT_ADD_SLASH_FOR_WINDOWS') ? '///' : '').'\''.$conf->user->dir_temp.'/odtaspdf\' --convert-to pdf --outdir '. escapeshellarg(dirname($name)). " ".escapeshellarg($name); |
|
| 904 | + $command = 'soffice --headless -env:UserInstallation=file:'.(getDolGlobalString('MAIN_ODT_ADD_SLASH_FOR_WINDOWS') ? '///' : '').'\''.$conf->user->dir_temp.'/odtaspdf\' --convert-to pdf --outdir '.escapeshellarg(dirname($name))." ".escapeshellarg($name); |
|
| 905 | 905 | } elseif (preg_match('/unoconv/', getDolGlobalString('MAIN_ODT_AS_PDF'))) { |
| 906 | 906 | // If issue with unoconv, see https://github.com/dagwieers/unoconv/issues/87 |
| 907 | 907 | |
@@ -931,13 +931,13 @@ discard block |
||
| 931 | 931 | //$command = '/usr/bin/unoconv -vvv '.escapeshellcmd($name); |
| 932 | 932 | } else { |
| 933 | 933 | // deprecated old method using odt2pdf.sh (native, jodconverter, ...) |
| 934 | - $tmpname=preg_replace('/\.odt/i', '', $name); |
|
| 934 | + $tmpname = preg_replace('/\.odt/i', '', $name); |
|
| 935 | 935 | |
| 936 | 936 | if (getDolGlobalString('MAIN_DOL_SCRIPTS_ROOT')) { |
| 937 | - $command = getDolGlobalString('MAIN_DOL_SCRIPTS_ROOT').'/scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($tmpname).' '.(is_numeric(getDolGlobalString('MAIN_ODT_AS_PDF'))?'jodconverter':getDolGlobalString('MAIN_ODT_AS_PDF')); |
|
| 937 | + $command = getDolGlobalString('MAIN_DOL_SCRIPTS_ROOT').'/scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($tmpname).' '.(is_numeric(getDolGlobalString('MAIN_ODT_AS_PDF')) ? 'jodconverter' : getDolGlobalString('MAIN_ODT_AS_PDF')); |
|
| 938 | 938 | } else { |
| 939 | 939 | dol_syslog(get_class($this).'::exportAsAttachedPDF is used but the constant MAIN_DOL_SCRIPTS_ROOT with path to script directory was not defined.', LOG_WARNING); |
| 940 | - $command = '../../scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($tmpname).' '.(is_numeric(getDolGlobalString('MAIN_ODT_AS_PDF'))?'jodconverter':getDolGlobalString('MAIN_ODT_AS_PDF')); |
|
| 940 | + $command = '../../scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($tmpname).' '.(is_numeric(getDolGlobalString('MAIN_ODT_AS_PDF')) ? 'jodconverter' : getDolGlobalString('MAIN_ODT_AS_PDF')); |
|
| 941 | 941 | } |
| 942 | 942 | } |
| 943 | 943 | |
@@ -950,14 +950,14 @@ discard block |
||
| 950 | 950 | // $result = $utils->executeCLI($command, $outputfile); and replace test on $execmethod. |
| 951 | 951 | // $retval will be $result['result'] |
| 952 | 952 | // $errorstring will be $result['output'] |
| 953 | - $retval=0; $output_arr=array(); |
|
| 953 | + $retval = 0; $output_arr = array(); |
|
| 954 | 954 | if ($execmethod == 1) { |
| 955 | 955 | exec($command, $output_arr, $retval); |
| 956 | 956 | } |
| 957 | 957 | if ($execmethod == 2) { |
| 958 | 958 | $outputfile = DOL_DATA_ROOT.'/odt2pdf.log'; |
| 959 | 959 | |
| 960 | - $ok=0; |
|
| 960 | + $ok = 0; |
|
| 961 | 961 | $handle = fopen($outputfile, 'w'); |
| 962 | 962 | if ($handle) { |
| 963 | 963 | dol_syslog(get_class($this)."Run command ".$command, LOG_DEBUG); |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | while (!feof($handlein)) { |
| 967 | 967 | $read = fgets($handlein); |
| 968 | 968 | fwrite($handle, $read); |
| 969 | - $output_arr[]=$read; |
|
| 969 | + $output_arr[] = $read; |
|
| 970 | 970 | } |
| 971 | 971 | pclose($handlein); |
| 972 | 972 | fclose($handle); |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | |
| 977 | 977 | if ($retval == 0) { |
| 978 | 978 | dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG); |
| 979 | - $filename=''; $linenum=0; |
|
| 979 | + $filename = ''; $linenum = 0; |
|
| 980 | 980 | |
| 981 | 981 | if ($dooutputfordownload) { |
| 982 | 982 | if (php_sapi_name() != 'cli') { // If we are in a web context (not into CLI context) |
@@ -987,8 +987,8 @@ discard block |
||
| 987 | 987 | if (getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { |
| 988 | 988 | $name = preg_replace('/\.od(x|t)/i', '', $name); |
| 989 | 989 | header('Content-type: application/pdf'); |
| 990 | - header('Content-Disposition: attachment; filename="' . basename($name) . '.pdf"'); |
|
| 991 | - readfile($name . ".pdf"); |
|
| 990 | + header('Content-Disposition: attachment; filename="'.basename($name).'.pdf"'); |
|
| 991 | + readfile($name.".pdf"); |
|
| 992 | 992 | } |
| 993 | 993 | } |
| 994 | 994 | } |
@@ -1001,13 +1001,13 @@ discard block |
||
| 1001 | 1001 | dol_syslog(get_class($this).'::exportAsAttachedPDF $output_arr='.var_export($output_arr, true), LOG_DEBUG); |
| 1002 | 1002 | |
| 1003 | 1003 | if ($retval == 126) { |
| 1004 | - throw new OdfException('Permission execute convert script : ' . $command); |
|
| 1004 | + throw new OdfException('Permission execute convert script : '.$command); |
|
| 1005 | 1005 | } else { |
| 1006 | - $errorstring=''; |
|
| 1006 | + $errorstring = ''; |
|
| 1007 | 1007 | foreach ($output_arr as $line) { |
| 1008 | - $errorstring.= $line."<br>"; |
|
| 1008 | + $errorstring .= $line."<br>"; |
|
| 1009 | 1009 | } |
| 1010 | - throw new OdfException('ODT to PDF convert fail (option MAIN_ODT_AS_PDF is '.$conf->global->MAIN_ODT_AS_PDF.', command was '.$command.', retval='.$retval.') : ' . $errorstring); |
|
| 1010 | + throw new OdfException('ODT to PDF convert fail (option MAIN_ODT_AS_PDF is '.$conf->global->MAIN_ODT_AS_PDF.', command was '.$command.', retval='.$retval.') : '.$errorstring); |
|
| 1011 | 1011 | } |
| 1012 | 1012 | } |
| 1013 | 1013 | } |
@@ -1064,11 +1064,11 @@ discard block |
||
| 1064 | 1064 | if ($handle = opendir($dir)) { |
| 1065 | 1065 | while (($file = readdir($handle)) !== false) { |
| 1066 | 1066 | if ($file != '.' && $file != '..') { |
| 1067 | - if (is_dir($dir . '/' . $file)) { |
|
| 1068 | - $this->_rrmdir($dir . '/' . $file); |
|
| 1069 | - rmdir($dir . '/' . $file); |
|
| 1067 | + if (is_dir($dir.'/'.$file)) { |
|
| 1068 | + $this->_rrmdir($dir.'/'.$file); |
|
| 1069 | + rmdir($dir.'/'.$file); |
|
| 1070 | 1070 | } else { |
| 1071 | - unlink($dir . '/' . $file); |
|
| 1071 | + unlink($dir.'/'.$file); |
|
| 1072 | 1072 | } |
| 1073 | 1073 | } |
| 1074 | 1074 | } |
@@ -1084,7 +1084,7 @@ discard block |
||
| 1084 | 1084 | */ |
| 1085 | 1085 | public function getvalue($valuename) |
| 1086 | 1086 | { |
| 1087 | - $searchreg="/\\[".$valuename."\\](.*)\\[\\/".$valuename."\\]/"; |
|
| 1087 | + $searchreg = "/\\[".$valuename."\\](.*)\\[\\/".$valuename."\\]/"; |
|
| 1088 | 1088 | $matches = array(); |
| 1089 | 1089 | preg_match($searchreg, $this->contentXml, $matches); |
| 1090 | 1090 | $this->contentXml = preg_replace($searchreg, "", $this->contentXml); |
@@ -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); |
@@ -17,11 +17,11 @@ |
||
| 17 | 17 | { |
| 18 | 18 | protected $zipArchive; |
| 19 | 19 | protected $filename; |
| 20 | - /** |
|
| 21 | - * Class constructor |
|
| 22 | - * |
|
| 23 | - * @throws PhpZipProxyException |
|
| 24 | - */ |
|
| 20 | + /** |
|
| 21 | + * Class constructor |
|
| 22 | + * |
|
| 23 | + * @throws PhpZipProxyException |
|
| 24 | + */ |
|
| 25 | 25 | public function __construct() |
| 26 | 26 | { |
| 27 | 27 | if (! class_exists('ZipArchive')) { |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct() |
| 26 | 26 | { |
| 27 | - if (! class_exists('ZipArchive')) { |
|
| 27 | + if (!class_exists('ZipArchive')) { |
|
| 28 | 28 | throw new PhpZipProxyException('Zip extension not loaded - check your php settings, PHP5.2 minimum with zip extension |
| 29 | 29 | is required for using PhpZipProxy'); ; |
| 30 | 30 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (! defined('ODTPHP_PATHTOPCLZIP')) { |
|
| 2 | +if (!defined('ODTPHP_PATHTOPCLZIP')) { |
|
| 3 | 3 | define('ODTPHP_PATHTOPCLZIP', DOL_DOCUMENT_ROOT.'/includes/odtphp/zip/pclzip/'); |
| 4 | 4 | } |
| 5 | 5 | require_once ODTPHP_PATHTOPCLZIP.'pclzip.lib.php'; |
@@ -28,13 +28,13 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @throws PclZipProxyException |
| 30 | 30 | */ |
| 31 | - public function __construct($forcedir='') |
|
| 31 | + public function __construct($forcedir = '') |
|
| 32 | 32 | { |
| 33 | - if (! class_exists('PclZip')) { |
|
| 33 | + if (!class_exists('PclZip')) { |
|
| 34 | 34 | throw new PclZipProxyException('PclZip class not loaded - PclZip library |
| 35 | 35 | is required for using PclZipProxy'); ; |
| 36 | 36 | } |
| 37 | - if ($forcedir) $this->tmpdir=preg_replace('|[//\/]$|','',$forcedir); // $this->tmpdir must not contains / at the end |
|
| 37 | + if ($forcedir) $this->tmpdir = preg_replace('|[//\/]$|', '', $forcedir); // $this->tmpdir must not contains / at the end |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | $localname = preg_replace("/(?:\.|\/)*(.*)/", "\\1", $localname); |
| 94 | 94 | $localpath = dirname($localname); |
| 95 | - $tmpfilename = $this->tmpdir . '/' . basename($localname); |
|
| 95 | + $tmpfilename = $this->tmpdir.'/'.basename($localname); |
|
| 96 | 96 | if (false !== file_put_contents($tmpfilename, $contents)) { |
| 97 | 97 | //print "tmpfilename=".$tmpfilename; |
| 98 | 98 | //print "localname=".$localname; |
| 99 | - $res = $this->pclzip->delete(PCLZIP_OPT_BY_NAME, $localname); // after this with pclzip handler, the odt/zip file is ocrrupted. No way to edit the zip with file roller. |
|
| 99 | + $res = $this->pclzip->delete(PCLZIP_OPT_BY_NAME, $localname); // after this with pclzip handler, the odt/zip file is ocrrupted. No way to edit the zip with file roller. |
|
| 100 | 100 | $add = $this->pclzip->add($tmpfilename, |
| 101 | 101 | PCLZIP_OPT_REMOVE_PATH, $this->tmpdir, |
| 102 | 102 | PCLZIP_OPT_ADD_PATH, $localpath); |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | if (isSet($localname)) { |
| 128 | 128 | $localname = preg_replace("/(?:\.|\/)*(.*)/", "\\1", $localname); |
| 129 | 129 | $localpath = dirname($localname); |
| 130 | - $tmpfilename = $this->tmpdir . '/' . basename($localname); |
|
| 130 | + $tmpfilename = $this->tmpdir.'/'.basename($localname); |
|
| 131 | 131 | } else { |
| 132 | 132 | $localname = basename($filename); |
| 133 | - $tmpfilename = $this->tmpdir . '/' . $localname; |
|
| 133 | + $tmpfilename = $this->tmpdir.'/'.$localname; |
|
| 134 | 134 | $localpath = ''; |
| 135 | 135 | } |
| 136 | 136 | if (file_exists($filename)) { |
@@ -135,7 +135,7 @@ |
||
| 135 | 135 | if (!dol_is_file($cmddump)) { // And if file not reachable with its full path |
| 136 | 136 | $reg = array(); |
| 137 | 137 | if (preg_match('/mysqldump(\.exe)?$/', $cmddump, $reg)) { // And if command ends with mysqldump |
| 138 | - $cmddump = 'mysqldump'.(empty($reg[1]) ? '' : $reg[1]); // Then we try the command with no forced path |
|
| 138 | + $cmddump = 'mysqldump'.(empty($reg[1]) ? '' : $reg[1]); // Then we try the command with no forced path |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | } |