@@ -31,18 +31,18 @@ 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' |
38 | 38 | ); |
39 | 39 | protected $file; |
40 | - protected $contentXml; // To store content of content.xml file |
|
41 | - protected $metaXml; // To store content of meta.xml file |
|
42 | - protected $stylesXml; // To store content of styles.xml file |
|
43 | - protected $manifestXml; // To store content of META-INF/manifest.xml file |
|
40 | + protected $contentXml; // To store content of content.xml file |
|
41 | + protected $metaXml; // To store content of meta.xml file |
|
42 | + protected $stylesXml; // To store content of styles.xml file |
|
43 | + protected $manifestXml; // To store content of META-INF/manifest.xml file |
|
44 | 44 | protected $tmpfile; |
45 | - protected $tmpdir=''; |
|
45 | + protected $tmpdir = ''; |
|
46 | 46 | protected $images = array(); |
47 | 47 | protected $vars = array(); |
48 | 48 | protected $segments = array(); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | public $creator; |
51 | 51 | public $title; |
52 | 52 | public $subject; |
53 | - public $userdefined=array(); |
|
53 | + public $userdefined = array(); |
|
54 | 54 | |
55 | 55 | const PIXEL_TO_CM = 0.026458333; |
56 | 56 | const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/s'; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | { |
69 | 69 | clearstatcache(); |
70 | 70 | |
71 | - if (! is_array($config)) { |
|
71 | + if (!is_array($config)) { |
|
72 | 72 | throw new OdfException('Configuration data must be provided as array'); |
73 | 73 | } |
74 | 74 | foreach ($config as $configKey => $configValue) { |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | $md5uniqid = md5(uniqid()); |
81 | - if ($this->config['PATH_TO_TMP']) $this->tmpdir = preg_replace('|[\/]$|', '', $this->config['PATH_TO_TMP']); // Remove last \ or / |
|
82 | - $this->tmpdir .= ($this->tmpdir?'/':'').$md5uniqid; |
|
83 | - $this->tmpfile = $this->tmpdir.'/'.$md5uniqid.'.odt'; // We keep .odt extension to allow OpenOffice usage during debug. |
|
81 | + if ($this->config['PATH_TO_TMP']) $this->tmpdir = preg_replace('|[\/]$|', '', $this->config['PATH_TO_TMP']); // Remove last \ or / |
|
82 | + $this->tmpdir .= ($this->tmpdir ? '/' : '').$md5uniqid; |
|
83 | + $this->tmpfile = $this->tmpdir.'/'.$md5uniqid.'.odt'; // We keep .odt extension to allow OpenOffice usage during debug. |
|
84 | 84 | |
85 | 85 | // A working directory is required for some zip proxy like PclZipProxy |
86 | - if (in_array($this->config['ZIP_PROXY'], array('PclZipProxy')) && ! is_dir($this->config['PATH_TO_TMP'])) { |
|
86 | + if (in_array($this->config['ZIP_PROXY'], array('PclZipProxy')) && !is_dir($this->config['PATH_TO_TMP'])) { |
|
87 | 87 | throw new OdfException('Temporary directory '.$this->config['PATH_TO_TMP'].' must exists'); |
88 | 88 | } |
89 | 89 | |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | $zipHandler = $this->config['ZIP_PROXY']; |
97 | 97 | if (!defined('PCLZIP_TEMPORARY_DIR')) define('PCLZIP_TEMPORARY_DIR', $this->tmpdir); |
98 | 98 | include_once 'zip/'.$zipHandler.'.php'; |
99 | - if (! class_exists($this->config['ZIP_PROXY'])) { |
|
100 | - throw new OdfException($this->config['ZIP_PROXY'] . ' class not found - check your php settings'); |
|
99 | + if (!class_exists($this->config['ZIP_PROXY'])) { |
|
100 | + throw new OdfException($this->config['ZIP_PROXY'].' class not found - check your php settings'); |
|
101 | 101 | } |
102 | 102 | $this->file = new $zipHandler($this->tmpdir); |
103 | 103 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function setVars($key, $value, $encode = true, $charset = 'ISO-8859') |
146 | 146 | { |
147 | - $tag = $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']; |
|
147 | + $tag = $this->config['DELIMITER_LEFT'].$key.$this->config['DELIMITER_RIGHT']; |
|
148 | 148 | |
149 | 149 | // TODO Warning string may be: |
150 | 150 | // <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> |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | // Check if the value includes html tags |
181 | 181 | if ($this->_hasHtmlTag($value) === true) { |
182 | - $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 |
|
182 | + $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 |
|
183 | 183 | |
184 | 184 | // Default styles for strong/b, i/em, u, s, sub & sup |
185 | 185 | $automaticStyles = array( |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $convertedValue = $this->_replaceHtmlWithOdtTag($this->_getDataFromHtml($value), $customStyles, $fontDeclarations, $encode, $charset); |
198 | 198 | |
199 | 199 | foreach ($customStyles as $key => $val) { |
200 | - array_push($automaticStyles, '<style:style style:name="customStyle' . $key . '" style:family="text">' . $val . '</style:style>'); |
|
200 | + array_push($automaticStyles, '<style:style style:name="customStyle'.$key.'" style:family="text">'.$val.'</style:style>'); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | // Join the styles and add them to the content xml |
@@ -207,16 +207,16 @@ discard block |
||
207 | 207 | $styles .= $style; |
208 | 208 | } |
209 | 209 | } |
210 | - $this->contentXml = str_replace('</office:automatic-styles>', $styles . '</office:automatic-styles>', $this->contentXml); |
|
210 | + $this->contentXml = str_replace('</office:automatic-styles>', $styles.'</office:automatic-styles>', $this->contentXml); |
|
211 | 211 | |
212 | 212 | // Join the font declarations and add them to the content xml |
213 | 213 | $fonts = ''; |
214 | 214 | foreach ($fontDeclarations as $font) { |
215 | - if (strpos($this->contentXml, 'style:name="' . $font . '"') === false) { |
|
216 | - $fonts .= '<style:font-face style:name="' . $font . '" svg:font-family="\'' . $font . '\'" />'; |
|
215 | + if (strpos($this->contentXml, 'style:name="'.$font.'"') === false) { |
|
216 | + $fonts .= '<style:font-face style:name="'.$font.'" svg:font-family="\''.$font.'\'" />'; |
|
217 | 217 | } |
218 | 218 | } |
219 | - $this->contentXml = str_replace('</office:font-face-decls>', $fonts . '</office:font-face-decls>', $this->contentXml); |
|
219 | + $this->contentXml = str_replace('</office:font-face-decls>', $fonts.'</office:font-face-decls>', $this->contentXml); |
|
220 | 220 | } else { |
221 | 221 | $convertedValue = $this->encode_chars($convertedValue, $encode, $charset); |
222 | 222 | $convertedValue = preg_replace('/(\r\n|\r|\n)/i', "<text:line-break/>", $convertedValue); |
@@ -253,23 +253,23 @@ discard block |
||
253 | 253 | break; |
254 | 254 | case 'strong': |
255 | 255 | case 'b': |
256 | - $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>'; |
|
256 | + $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>'; |
|
257 | 257 | break; |
258 | 258 | case 'i': |
259 | 259 | case 'em': |
260 | - $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>'; |
|
260 | + $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>'; |
|
261 | 261 | break; |
262 | 262 | case 'u': |
263 | - $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>'; |
|
263 | + $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>'; |
|
264 | 264 | break; |
265 | 265 | case 's': |
266 | - $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>'; |
|
266 | + $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>'; |
|
267 | 267 | break; |
268 | 268 | case 'sub': |
269 | - $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>'; |
|
269 | + $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>'; |
|
270 | 270 | break; |
271 | 271 | case 'sup': |
272 | - $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>'; |
|
272 | + $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>'; |
|
273 | 273 | break; |
274 | 274 | case 'span': |
275 | 275 | if (isset($tag['attributes']['style'])) { |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | if (!in_array($fontName, $fontDeclarations)) { |
285 | 285 | array_push($fontDeclarations, $fontName); |
286 | 286 | } |
287 | - $odtStyles .= '<style:text-properties style:font-name="' . $fontName . '" />'; |
|
287 | + $odtStyles .= '<style:text-properties style:font-name="'.$fontName.'" />'; |
|
288 | 288 | break; |
289 | 289 | case 'font-size': |
290 | 290 | if (preg_match('/([0-9]+)\s?(px|pt)/', $styleValue, $matches)) { |
@@ -292,12 +292,12 @@ discard block |
||
292 | 292 | if ($matches[2] == 'px') { |
293 | 293 | $fontSize = round($fontSize * 0.75); |
294 | 294 | } |
295 | - $odtStyles .= '<style:text-properties fo:font-size="' . $fontSize . 'pt" style:font-size-asian="' . $fontSize . 'pt" style:font-size-complex="' . $fontSize . 'pt" />'; |
|
295 | + $odtStyles .= '<style:text-properties fo:font-size="'.$fontSize.'pt" style:font-size-asian="'.$fontSize.'pt" style:font-size-complex="'.$fontSize.'pt" />'; |
|
296 | 296 | } |
297 | 297 | break; |
298 | 298 | case 'color': |
299 | 299 | if (preg_match('/#[0-9A-Fa-f]{3}(?:[0-9A-Fa-f]{3})?/', $styleValue)) { |
300 | - $odtStyles .= '<style:text-properties fo:color="' . $styleValue . '" />'; |
|
300 | + $odtStyles .= '<style:text-properties fo:color="'.$styleValue.'" />'; |
|
301 | 301 | } |
302 | 302 | break; |
303 | 303 | } |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | // Generate a unique id for the style (using microtime and random because some CPUs are really fast...) |
307 | 307 | $key = floatval(str_replace('.', '', microtime(true))) + rand(0, 10); |
308 | 308 | $customStyles[$key] = $odtStyles; |
309 | - $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>'; |
|
309 | + $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>'; |
|
310 | 310 | } |
311 | 311 | } |
312 | 312 | break; |
@@ -443,24 +443,24 @@ discard block |
||
443 | 443 | public function htmlToUTFAndPreOdf($value) |
444 | 444 | { |
445 | 445 | // We decode into utf8, entities |
446 | - $value=dol_html_entity_decode($value, ENT_QUOTES|ENT_HTML5); |
|
446 | + $value = dol_html_entity_decode($value, ENT_QUOTES | ENT_HTML5); |
|
447 | 447 | |
448 | 448 | // We convert html tags |
449 | - $ishtml=dol_textishtml($value); |
|
449 | + $ishtml = dol_textishtml($value); |
|
450 | 450 | if ($ishtml) { |
451 | 451 | // If string is "MYPODUCT - Desc <strong>bold</strong> with é accent<br />\n<br />\nUn texto en español ?" |
452 | 452 | // Result after clean must be "MYPODUCT - Desc bold with é accent\n\nUn texto en español ?" |
453 | 453 | |
454 | 454 | // We want to ignore \n and we want all <br> to be \n |
455 | - $value=preg_replace('/(\r\n|\r|\n)/i', '', $value); |
|
456 | - $value=preg_replace('/<br>/i', "\n", $value); |
|
457 | - $value=preg_replace('/<br\s+[^<>\/]*>/i', "\n", $value); |
|
458 | - $value=preg_replace('/<br\s+[^<>\/]*\/>/i', "\n", $value); |
|
455 | + $value = preg_replace('/(\r\n|\r|\n)/i', '', $value); |
|
456 | + $value = preg_replace('/<br>/i', "\n", $value); |
|
457 | + $value = preg_replace('/<br\s+[^<>\/]*>/i', "\n", $value); |
|
458 | + $value = preg_replace('/<br\s+[^<>\/]*\/>/i', "\n", $value); |
|
459 | 459 | |
460 | 460 | //$value=preg_replace('/<strong>/','__lt__text:p text:style-name=__quot__bold__quot____gt__',$value); |
461 | 461 | //$value=preg_replace('/<\/strong>/','__lt__/text:p__gt__',$value); |
462 | 462 | |
463 | - $value=dol_string_nohtmltag($value, 0); |
|
463 | + $value = dol_string_nohtmltag($value, 0); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | return $value; |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | $balise = str_replace('row.', '', $matches2[1]); |
537 | 537 | // Move segment tags around the row |
538 | 538 | $replace = array( |
539 | - '[!-- BEGIN ' . $matches2[1] . ' --]' => '', |
|
540 | - '[!-- END ' . $matches2[1] . ' --]' => '', |
|
541 | - '<table:table-row' => '[!-- BEGIN ' . $balise . ' --]<table:table-row', |
|
542 | - '</table:table-row>' => '</table:table-row>[!-- END ' . $balise . ' --]' |
|
539 | + '[!-- BEGIN '.$matches2[1].' --]' => '', |
|
540 | + '[!-- END '.$matches2[1].' --]' => '', |
|
541 | + '<table:table-row' => '[!-- BEGIN '.$balise.' --]<table:table-row', |
|
542 | + '</table:table-row>' => '</table:table-row>[!-- END '.$balise.' --]' |
|
543 | 543 | ); |
544 | 544 | $replacedXML = str_replace(array_keys($replace), array_values($replace), $matches[0][$i]); |
545 | 545 | $this->contentXml = str_replace($matches[0][$i], $replacedXML, $this->contentXml); |
@@ -557,14 +557,14 @@ discard block |
||
557 | 557 | private function _parse($type = 'content') |
558 | 558 | { |
559 | 559 | // Search all tags found into condition to complete $this->vars, so we will proceed all tests even if not defined |
560 | - $reg='@\[!--\sIF\s([{}a-zA-Z0-9\.\,_]+)\s--\]@smU'; |
|
560 | + $reg = '@\[!--\sIF\s([{}a-zA-Z0-9\.\,_]+)\s--\]@smU'; |
|
561 | 561 | $matches = array(); |
562 | 562 | preg_match_all($reg, $this->contentXml, $matches, PREG_SET_ORDER); |
563 | 563 | |
564 | 564 | //var_dump($this->vars);exit; |
565 | 565 | foreach ($matches as $match) { // For each match, if there is no entry into this->vars, we add it |
566 | - if (! empty($match[1]) && ! isset($this->vars[$match[1]])) { |
|
567 | - $this->vars[$match[1]] = ''; // Not defined, so we set it to '', we just need entry into this->vars for next loop |
|
566 | + if (!empty($match[1]) && !isset($this->vars[$match[1]])) { |
|
567 | + $this->vars[$match[1]] = ''; // Not defined, so we set it to '', we just need entry into this->vars for next loop |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | //var_dump($this->vars);exit; |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | // Remove the IF tag |
580 | 580 | $this->contentXml = str_replace('[!-- IF '.$key.' --]', '', $this->contentXml); |
581 | 581 | // Remove everything between the ELSE tag (if it exists) and the ENDIF tag |
582 | - $reg = '@(\[!--\sELSE\s' . $key . '\s--\](.*))?\[!--\sENDIF\s' . $key . '\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
|
582 | + $reg = '@(\[!--\sELSE\s'.$key.'\s--\](.*))?\[!--\sENDIF\s'.$key.'\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
|
583 | 583 | $this->contentXml = preg_replace($reg, '', $this->contentXml); |
584 | 584 | /*if ($sav != $this->contentXml) |
585 | 585 | { |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | //dol_syslog("Var ".$key." is not defined, we remove the IF, ELSE and ENDIF "); |
593 | 593 | //$sav=$this->contentXml; |
594 | 594 | // Find all conditional blocks for this variable: from IF to ELSE and to ENDIF |
595 | - $reg = '@\[!--\sIF\s' . $key . '\s--\](.*)(\[!--\sELSE\s' . $key . '\s--\](.*))?\[!--\sENDIF\s' . $key . '\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
|
595 | + $reg = '@\[!--\sIF\s'.$key.'\s--\](.*)(\[!--\sELSE\s'.$key.'\s--\](.*))?\[!--\sENDIF\s'.$key.'\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
|
596 | 596 | preg_match_all($reg, $this->contentXml, $matches, PREG_SET_ORDER); |
597 | 597 | 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 |
598 | 598 | if (!empty($match[3])) $this->contentXml = str_replace($match[0], $match[3], $this->contentXml); |
@@ -622,12 +622,12 @@ discard block |
||
622 | 622 | */ |
623 | 623 | public function mergeSegment(Segment $segment) |
624 | 624 | { |
625 | - if (! array_key_exists($segment->getName(), $this->segments)) { |
|
626 | - throw new OdfException($segment->getName() . 'cannot be parsed, has it been set yet ?'); |
|
625 | + if (!array_key_exists($segment->getName(), $this->segments)) { |
|
626 | + throw new OdfException($segment->getName().'cannot be parsed, has it been set yet ?'); |
|
627 | 627 | } |
628 | 628 | $string = $segment->getName(); |
629 | 629 | // $reg = '@<text:p[^>]*>\[!--\sBEGIN\s' . $string . '\s--\](.*)\[!--.+END\s' . $string . '\s--\]<\/text:p>@smU'; |
630 | - $reg = '@\[!--\sBEGIN\s' . $string . '\s--\](.*)\[!--.+END\s' . $string . '\s--\]@smU'; |
|
630 | + $reg = '@\[!--\sBEGIN\s'.$string.'\s--\](.*)\[!--.+END\s'.$string.'\s--\]@smU'; |
|
631 | 631 | $this->contentXml = preg_replace($reg, $segment->getXmlParsed(), $this->contentXml); |
632 | 632 | return $this; |
633 | 633 | } |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | */ |
640 | 640 | public function printVars() |
641 | 641 | { |
642 | - return print_r('<pre>' . print_r($this->vars, true) . '</pre>', true); |
|
642 | + return print_r('<pre>'.print_r($this->vars, true).'</pre>', true); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | */ |
661 | 661 | public function printDeclaredSegments() |
662 | 662 | { |
663 | - return '<pre>' . print_r(implode(' ', array_keys($this->segments)), true) . '</pre>'; |
|
663 | + return '<pre>'.print_r(implode(' ', array_keys($this->segments)), true).'</pre>'; |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | { |
697 | 697 | if ($file !== null && is_string($file)) { |
698 | 698 | if (file_exists($file) && !(is_file($file) && is_writable($file))) { |
699 | - throw new OdfException('Permission denied : can\'t create ' . $file); |
|
699 | + throw new OdfException('Permission denied : can\'t create '.$file); |
|
700 | 700 | } |
701 | 701 | $this->_save(); |
702 | 702 | copy($this->tmpfile, $file); |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | */ |
714 | 714 | private function _save() |
715 | 715 | { |
716 | - $res=$this->file->open($this->tmpfile); // tmpfile is odt template |
|
716 | + $res = $this->file->open($this->tmpfile); // tmpfile is odt template |
|
717 | 717 | $this->_parse('content'); |
718 | 718 | $this->_parse('styles'); |
719 | 719 | $this->_parse('meta'); |
@@ -721,23 +721,23 @@ discard block |
||
721 | 721 | $this->setMetaData(); |
722 | 722 | //print $this->metaXml;exit; |
723 | 723 | |
724 | - if (! $this->file->addFromString('content.xml', $this->contentXml)) { |
|
724 | + if (!$this->file->addFromString('content.xml', $this->contentXml)) { |
|
725 | 725 | throw new OdfException('Error during file export addFromString content'); |
726 | 726 | } |
727 | - if (! $this->file->addFromString('meta.xml', $this->metaXml)) { |
|
727 | + if (!$this->file->addFromString('meta.xml', $this->metaXml)) { |
|
728 | 728 | throw new OdfException('Error during file export addFromString meta'); |
729 | 729 | } |
730 | - if (! $this->file->addFromString('styles.xml', $this->stylesXml)) { |
|
730 | + if (!$this->file->addFromString('styles.xml', $this->stylesXml)) { |
|
731 | 731 | throw new OdfException('Error during file export addFromString styles'); |
732 | 732 | } |
733 | 733 | |
734 | 734 | foreach ($this->images as $imageKey => $imageValue) { |
735 | 735 | // Add the image inside the ODT document |
736 | - $this->file->addFile($imageKey, 'Pictures/' . $imageValue); |
|
736 | + $this->file->addFile($imageKey, 'Pictures/'.$imageValue); |
|
737 | 737 | // 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) |
738 | 738 | $this->addImageToManifest($imageValue); |
739 | 739 | } |
740 | - if (! $this->file->addFromString('./META-INF/manifest.xml', $this->manifestXml)) { |
|
740 | + if (!$this->file->addFromString('./META-INF/manifest.xml', $this->manifestXml)) { |
|
741 | 741 | throw new OdfException('Error during file export: manifest.xml'); |
742 | 742 | } |
743 | 743 | $this->file->close(); |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | */ |
752 | 752 | public function setMetaData() |
753 | 753 | { |
754 | - if (empty($this->creator)) $this->creator=''; |
|
754 | + if (empty($this->creator)) $this->creator = ''; |
|
755 | 755 | |
756 | 756 | $this->metaXml = preg_replace('/<dc:date>.*<\/dc:date>/', '<dc:date>'.gmdate("Y-m-d\TH:i:s").'</dc:date>', $this->metaXml); |
757 | 757 | $this->metaXml = preg_replace('/<dc:creator>.*<\/dc:creator>/', '<dc:creator>'.htmlspecialchars($this->creator).'</dc:creator>', $this->metaXml); |
@@ -797,8 +797,8 @@ discard block |
||
797 | 797 | throw new OdfException("headers already sent ($filename at $linenum)"); |
798 | 798 | } |
799 | 799 | |
800 | - if ( $name == "" ) { |
|
801 | - $name = md5(uniqid()) . ".odt"; |
|
800 | + if ($name == "") { |
|
801 | + $name = md5(uniqid()).".odt"; |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | header('Content-type: application/vnd.oasis.opendocument.text'); |
@@ -819,18 +819,18 @@ discard block |
||
819 | 819 | { |
820 | 820 | global $conf; |
821 | 821 | |
822 | - if ( $name == "" ) $name = "temp".md5(uniqid()); |
|
822 | + if ($name == "") $name = "temp".md5(uniqid()); |
|
823 | 823 | |
824 | 824 | dol_syslog(get_class($this).'::exportAsAttachedPDF $name='.$name, LOG_DEBUG); |
825 | 825 | $this->saveToDisk($name); |
826 | 826 | |
827 | - $execmethod=(empty($conf->global->MAIN_EXEC_USE_POPEN)?1:2); // 1 or 2 |
|
827 | + $execmethod = (empty($conf->global->MAIN_EXEC_USE_POPEN) ? 1 : 2); // 1 or 2 |
|
828 | 828 | // Method 1 sometimes hang the server. |
829 | 829 | |
830 | 830 | |
831 | 831 | // Export to PDF using LibreOffice |
832 | 832 | if (getDolGlobalString('MAIN_ODT_AS_PDF') == 'libreoffice') { |
833 | - dol_mkdir($conf->user->dir_temp); // We must be sure the directory exists and is writable |
|
833 | + dol_mkdir($conf->user->dir_temp); // We must be sure the directory exists and is writable |
|
834 | 834 | |
835 | 835 | // We delete and recreate a subdir because the soffice may have change pemrissions on it |
836 | 836 | dol_delete_dir_recursive($conf->user->dir_temp.'/odtaspdf'); |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | // using windows libreoffice that must be in path |
841 | 841 | // using linux/mac libreoffice that must be in path |
842 | 842 | // Note PHP Config "fastcgi.impersonate=0" must set to 0 - Default is 1 |
843 | - $command ='soffice --headless -env:UserInstallation=file:\''.$conf->user->dir_temp.'/odtaspdf\' --convert-to pdf --outdir '. escapeshellarg(dirname($name)). " ".escapeshellarg($name); |
|
843 | + $command = 'soffice --headless -env:UserInstallation=file:\''.$conf->user->dir_temp.'/odtaspdf\' --convert-to pdf --outdir '.escapeshellarg(dirname($name))." ".escapeshellarg($name); |
|
844 | 844 | } elseif (preg_match('/unoconv/', getDolGlobalString('MAIN_ODT_AS_PDF'))) { |
845 | 845 | // If issue with unoconv, see https://github.com/dagwieers/unoconv/issues/87 |
846 | 846 | |
@@ -870,13 +870,13 @@ discard block |
||
870 | 870 | //$command = '/usr/bin/unoconv -vvv '.escapeshellcmd($name); |
871 | 871 | } else { |
872 | 872 | // deprecated old method using odt2pdf.sh (native, jodconverter, ...) |
873 | - $tmpname=preg_replace('/\.odt/i', '', $name); |
|
873 | + $tmpname = preg_replace('/\.odt/i', '', $name); |
|
874 | 874 | |
875 | 875 | if (getDolGlobalString('MAIN_DOL_SCRIPTS_ROOT')) { |
876 | - $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')); |
|
876 | + $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')); |
|
877 | 877 | } else { |
878 | 878 | 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); |
879 | - $command = '../../scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($tmpname).' '.(is_numeric(getDolGlobalString('MAIN_ODT_AS_PDF'))?'jodconverter':getDolGlobalString('MAIN_ODT_AS_PDF')); |
|
879 | + $command = '../../scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($tmpname).' '.(is_numeric(getDolGlobalString('MAIN_ODT_AS_PDF')) ? 'jodconverter' : getDolGlobalString('MAIN_ODT_AS_PDF')); |
|
880 | 880 | } |
881 | 881 | } |
882 | 882 | |
@@ -889,14 +889,14 @@ discard block |
||
889 | 889 | // $result = $utils->executeCLI($command, $outputfile); and replace test on $execmethod. |
890 | 890 | // $retval will be $result['result'] |
891 | 891 | // $errorstring will be $result['output'] |
892 | - $retval=0; $output_arr=array(); |
|
892 | + $retval = 0; $output_arr = array(); |
|
893 | 893 | if ($execmethod == 1) { |
894 | 894 | exec($command, $output_arr, $retval); |
895 | 895 | } |
896 | 896 | if ($execmethod == 2) { |
897 | 897 | $outputfile = DOL_DATA_ROOT.'/odt2pdf.log'; |
898 | 898 | |
899 | - $ok=0; |
|
899 | + $ok = 0; |
|
900 | 900 | $handle = fopen($outputfile, 'w'); |
901 | 901 | if ($handle) { |
902 | 902 | dol_syslog(get_class($this)."Run command ".$command, LOG_DEBUG); |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | while (!feof($handlein)) { |
906 | 906 | $read = fgets($handlein); |
907 | 907 | fwrite($handle, $read); |
908 | - $output_arr[]=$read; |
|
908 | + $output_arr[] = $read; |
|
909 | 909 | } |
910 | 910 | pclose($handlein); |
911 | 911 | fclose($handle); |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | |
916 | 916 | if ($retval == 0) { |
917 | 917 | dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG); |
918 | - $filename=''; $linenum=0; |
|
918 | + $filename = ''; $linenum = 0; |
|
919 | 919 | |
920 | 920 | if (php_sapi_name() != 'cli') { // If we are in a web context (not into CLI context) |
921 | 921 | if (headers_sent($filename, $linenum)) { |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | } |
924 | 924 | |
925 | 925 | if (!empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { |
926 | - $name=preg_replace('/\.od(x|t)/i', '', $name); |
|
926 | + $name = preg_replace('/\.od(x|t)/i', '', $name); |
|
927 | 927 | header('Content-type: application/pdf'); |
928 | 928 | header('Content-Disposition: attachment; filename="'.$name.'.pdf"'); |
929 | 929 | readfile($name.".pdf"); |
@@ -938,13 +938,13 @@ discard block |
||
938 | 938 | dol_syslog(get_class($this).'::exportAsAttachedPDF $output_arr='.var_export($output_arr, true), LOG_DEBUG); |
939 | 939 | |
940 | 940 | if ($retval == 126) { |
941 | - throw new OdfException('Permission execute convert script : ' . $command); |
|
941 | + throw new OdfException('Permission execute convert script : '.$command); |
|
942 | 942 | } else { |
943 | - $errorstring=''; |
|
943 | + $errorstring = ''; |
|
944 | 944 | foreach ($output_arr as $line) { |
945 | - $errorstring.= $line."<br>"; |
|
945 | + $errorstring .= $line."<br>"; |
|
946 | 946 | } |
947 | - 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); |
|
947 | + 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); |
|
948 | 948 | } |
949 | 949 | } |
950 | 950 | } |
@@ -998,11 +998,11 @@ discard block |
||
998 | 998 | if ($handle = opendir($dir)) { |
999 | 999 | while (($file = readdir($handle)) !== false) { |
1000 | 1000 | if ($file != '.' && $file != '..') { |
1001 | - if (is_dir($dir . '/' . $file)) { |
|
1002 | - $this->_rrmdir($dir . '/' . $file); |
|
1003 | - rmdir($dir . '/' . $file); |
|
1001 | + if (is_dir($dir.'/'.$file)) { |
|
1002 | + $this->_rrmdir($dir.'/'.$file); |
|
1003 | + rmdir($dir.'/'.$file); |
|
1004 | 1004 | } else { |
1005 | - unlink($dir . '/' . $file); |
|
1005 | + unlink($dir.'/'.$file); |
|
1006 | 1006 | } |
1007 | 1007 | } |
1008 | 1008 | } |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | */ |
1019 | 1019 | public function getvalue($valuename) |
1020 | 1020 | { |
1021 | - $searchreg="/\\[".$valuename."\\](.*)\\[\\/".$valuename."\\]/"; |
|
1021 | + $searchreg = "/\\[".$valuename."\\](.*)\\[\\/".$valuename."\\]/"; |
|
1022 | 1022 | $matches = array(); |
1023 | 1023 | preg_match($searchreg, $this->contentXml, $matches); |
1024 | 1024 | $this->contentXml = preg_replace($searchreg, "", $this->contentXml); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | // This convert an embedd file with src="/viewimage.php?modulepart... into a cid link |
265 | 265 | // TODO Exclude viewimage used for the read tracker ? |
266 | 266 | $findimg = $this->findHtmlImages($dolibarr_main_data_root.'/medias'); |
267 | - if ($findimg<0) { |
|
267 | + if ($findimg < 0) { |
|
268 | 268 | dol_syslog("CMailFile::CMailfile: Error on findHtmlImages"); |
269 | 269 | $this->error = 'ErrorInAddAttachementsImageBaseOnMedia'; |
270 | 270 | return; |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | // Search into the body for <img src="data:image/ext;base64,..." to replace them with an embedded file |
276 | 276 | // This convert an embedded file with src="data:image... into a cid link + attached file |
277 | 277 | $resultImageData = $this->findHtmlImagesIsSrcData($upload_dir_tmp); |
278 | - if ($resultImageData<0) { |
|
278 | + if ($resultImageData < 0) { |
|
279 | 279 | dol_syslog("CMailFile::CMailfile: Error on findHtmlImagesInSrcData"); |
280 | 280 | $this->error = 'ErrorInAddAttachementsImageBaseOnMedia'; |
281 | 281 | return; |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | } |
334 | 334 | } |
335 | 335 | if ($emailtoadd && preg_match('/'.preg_quote($emailtoadd, '/').'/i', $to)) { |
336 | - $emailtoadd = ''; // Email already in the "To" |
|
336 | + $emailtoadd = ''; // Email already in the "To" |
|
337 | 337 | } |
338 | 338 | if ($emailtoadd) { |
339 | 339 | $listofemailstoadd[$key] = $emailtoadd; |
@@ -996,19 +996,19 @@ discard block |
||
996 | 996 | $res = true; |
997 | 997 | $from = $this->smtps->getFrom('org'); |
998 | 998 | if ($res && !$from) { |
999 | - $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=" . getDolGlobalString($keyforsmtpport)." - Sender address '$from' invalid"; |
|
999 | + $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".getDolGlobalString($keyforsmtpport)." - Sender address '$from' invalid"; |
|
1000 | 1000 | dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); |
1001 | 1001 | $res = false; |
1002 | 1002 | } |
1003 | 1003 | $dest = $this->smtps->getTo(); |
1004 | 1004 | if ($res && !$dest) { |
1005 | - $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=" . getDolGlobalString($keyforsmtpport)." - Recipient address '$dest' invalid"; |
|
1005 | + $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".getDolGlobalString($keyforsmtpport)." - Recipient address '$dest' invalid"; |
|
1006 | 1006 | dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); |
1007 | 1007 | $res = false; |
1008 | 1008 | } |
1009 | 1009 | |
1010 | 1010 | if ($res) { |
1011 | - dol_syslog("CMailFile::sendfile: sendMsg, HOST=".$server.", PORT=" . getDolGlobalString($keyforsmtpport), LOG_DEBUG); |
|
1011 | + dol_syslog("CMailFile::sendfile: sendMsg, HOST=".$server.", PORT=".getDolGlobalString($keyforsmtpport), LOG_DEBUG); |
|
1012 | 1012 | |
1013 | 1013 | if (getDolGlobalString('MAIN_MAIL_DEBUG')) { |
1014 | 1014 | $this->smtps->setDebug(true); |
@@ -1021,8 +1021,8 @@ discard block |
||
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | $smtperrorcode = 0; |
1024 | - if (! $result) { |
|
1025 | - $smtperrorcode = $this->smtps->lastretval; // SMTP error code |
|
1024 | + if (!$result) { |
|
1025 | + $smtperrorcode = $this->smtps->lastretval; // SMTP error code |
|
1026 | 1026 | dol_syslog("CMailFile::sendfile: mail SMTP error code ".$smtperrorcode, LOG_WARNING); |
1027 | 1027 | |
1028 | 1028 | if ($smtperrorcode == '421') { // Try later |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | } |
1041 | 1041 | } |
1042 | 1042 | |
1043 | - $result = $this->smtps->getErrors(); // applicative error code (not SMTP error code) |
|
1043 | + $result = $this->smtps->getErrors(); // applicative error code (not SMTP error code) |
|
1044 | 1044 | if (empty($this->error) && empty($result)) { |
1045 | 1045 | dol_syslog("CMailFile::sendfile: mail end success", LOG_DEBUG); |
1046 | 1046 | $res = true; |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | if (empty($this->error)) { |
1049 | 1049 | $this->error = $result; |
1050 | 1050 | } |
1051 | - dol_syslog("CMailFile::sendfile: mail end error with smtps lib to HOST=".$server.", PORT=" . getDolGlobalString($keyforsmtpport)." - ".$this->error, LOG_ERR); |
|
1051 | + dol_syslog("CMailFile::sendfile: mail end error with smtps lib to HOST=".$server.", PORT=".getDolGlobalString($keyforsmtpport)." - ".$this->error, LOG_ERR); |
|
1052 | 1052 | $res = false; |
1053 | 1053 | |
1054 | 1054 | if (getDolGlobalString('MAIN_MAIL_DEBUG')) { |
@@ -1177,7 +1177,7 @@ discard block |
||
1177 | 1177 | $this->mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($this->logger)); |
1178 | 1178 | } |
1179 | 1179 | |
1180 | - dol_syslog("CMailFile::sendfile: mailer->send, HOST=".$server.", PORT=" . getDolGlobalString($keyforsmtpport), LOG_DEBUG); |
|
1180 | + dol_syslog("CMailFile::sendfile: mailer->send, HOST=".$server.", PORT=".getDolGlobalString($keyforsmtpport), LOG_DEBUG); |
|
1181 | 1181 | |
1182 | 1182 | // send mail |
1183 | 1183 | $failedRecipients = array(); |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | $res = true; |
1194 | 1194 | if (!empty($this->error) || !empty($this->errors) || !$result) { |
1195 | 1195 | if (!empty($failedRecipients)) { |
1196 | - $this->errors[] = 'Transport failed for the following addresses: "' . join('", "', $failedRecipients) . '".'; |
|
1196 | + $this->errors[] = 'Transport failed for the following addresses: "'.join('", "', $failedRecipients).'".'; |
|
1197 | 1197 | } |
1198 | 1198 | dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); |
1199 | 1199 | $res = false; |
@@ -1287,7 +1287,7 @@ discard block |
||
1287 | 1287 | |
1288 | 1288 | if (@is_writeable($dolibarr_main_data_root)) { // Avoid fatal error on fopen with open_basedir |
1289 | 1289 | $outputfile = $dolibarr_main_data_root."/dolibarr_mail.log"; |
1290 | - $fp = fopen($outputfile, "w"); // overwrite |
|
1290 | + $fp = fopen($outputfile, "w"); // overwrite |
|
1291 | 1291 | |
1292 | 1292 | if ($this->sendmode == 'mail') { |
1293 | 1293 | fputs($fp, $this->headers); |
@@ -1546,7 +1546,7 @@ discard block |
||
1546 | 1546 | // Similar code to forge a text from html is also in smtps.class.php |
1547 | 1547 | $strContentAltText = preg_replace("/<br\s*[^>]*>/", " ", $strContent); |
1548 | 1548 | // TODO We could replace <img ...> with [Filename.ext] like Gmail do. |
1549 | - $strContentAltText = html_entity_decode(strip_tags($strContentAltText)); // Remove any HTML tags |
|
1549 | + $strContentAltText = html_entity_decode(strip_tags($strContentAltText)); // Remove any HTML tags |
|
1550 | 1550 | $strContentAltText = trim(wordwrap($strContentAltText, 75, !getDolGlobalString('MAIN_FIX_FOR_BUGGED_MTA') ? "\r\n" : "\n")); |
1551 | 1551 | |
1552 | 1552 | // Check if html header already in message, if not complete the message |
@@ -1929,7 +1929,7 @@ discard block |
||
1929 | 1929 | // We save the image to send in disk |
1930 | 1930 | $filecontent = $matches[2][$key]; |
1931 | 1931 | |
1932 | - $cid = 'cid000'.dol_hash($filecontent, 'md5'); // The id must not change if image is same |
|
1932 | + $cid = 'cid000'.dol_hash($filecontent, 'md5'); // The id must not change if image is same |
|
1933 | 1933 | |
1934 | 1934 | $destfiletmp = $images_dir.'/'.$cid.'.'.$ext; |
1935 | 1935 |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55), |
180 | 180 | 'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60, 'csslist'=>'nowraponall'), |
181 | 181 | 'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>!getDolGlobalString('ORDER_DISABLE_DELIVERY_DATE'), 'position'=>65, 'csslist'=>'nowraponall'), |
182 | - 'c.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>-1, 'position'=>66 , 'enabled'=>isModEnabled("expedition")), |
|
182 | + 'c.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>-1, 'position'=>66, 'enabled'=>isModEnabled("expedition")), |
|
183 | 183 | 'c.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>-1, 'position'=>67), |
184 | 184 | 'c.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>-1, 'position'=>68), |
185 | 185 | 'c.fk_input_reason'=>array('label'=>"Channel", 'checked'=>-1, 'position'=>69), |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130), |
203 | 203 | 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES')), 'position'=>135), |
204 | 204 | 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES')), 'position'=>140), |
205 | - 'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(isModEnabled("expedition")), 'position'=>990), |
|
205 | + 'shippable'=>array('label'=>"Shippable", 'checked'=>1, 'enabled'=>(isModEnabled("expedition")), 'position'=>990), |
|
206 | 206 | 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'enabled'=>(!getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')), 'position'=>995), |
207 | 207 | 'c.import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>999), |
208 | 208 | 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000) |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | } |
320 | 320 | $uploaddir = $conf->commande->multidir_output[$conf->entity]; |
321 | 321 | $triggersendname = 'ORDER_SENTBYMAIL'; |
322 | - $year=""; |
|
323 | - $month=""; |
|
322 | + $year = ""; |
|
323 | + $month = ""; |
|
324 | 324 | include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; |
325 | 325 | |
326 | 326 | if ($massaction == 'confirm_createbills') { // Create bills from orders. |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $TFactThirdNbLines = array(); |
336 | 336 | |
337 | 337 | $nb_bills_created = 0; |
338 | - $lastid= 0; |
|
338 | + $lastid = 0; |
|
339 | 339 | $lastref = ''; |
340 | 340 | |
341 | 341 | $db->begin(); |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | if ($searchCategoryCustomerOperator == 0) { |
1021 | 1021 | $searchCategoryCustomerSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie = ".((int) $searchCategoryCustomer).")"; |
1022 | 1022 | } else { |
1023 | - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); |
|
1023 | + $listofcategoryid .= ($listofcategoryid ? ', ' : '').((int) $searchCategoryCustomer); |
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | } |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | if ($searchCategoryProductOperator == 0) { |
1051 | 1051 | $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; |
1052 | 1052 | } else { |
1053 | - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); |
|
1053 | + $listofcategoryid .= ($listofcategoryid ? ', ' : '').((int) $searchCategoryProduct); |
|
1054 | 1054 | } |
1055 | 1055 | } |
1056 | 1056 | } |
@@ -2616,13 +2616,13 @@ discard block |
||
2616 | 2616 | print '<td class="center">'; |
2617 | 2617 | if (!empty($show_shippable_command) && isModEnabled('stock')) { |
2618 | 2618 | if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) { |
2619 | - $generic_commande->getLinesArray(); // Load array ->lines |
|
2620 | - $generic_commande->loadExpeditions(); // Load array ->expeditions |
|
2619 | + $generic_commande->getLinesArray(); // Load array ->lines |
|
2620 | + $generic_commande->loadExpeditions(); // Load array ->expeditions |
|
2621 | 2621 | |
2622 | 2622 | $numlines = count($generic_commande->lines); // Loop on each line of order |
2623 | 2623 | for ($lig = 0; $lig < $numlines; $lig++) { |
2624 | 2624 | if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) { |
2625 | - $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id]; |
|
2625 | + $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id]; |
|
2626 | 2626 | } else { |
2627 | 2627 | $reliquat = $generic_commande->lines[$lig]->qty; |
2628 | 2628 | } |
@@ -65,20 +65,20 @@ discard block |
||
65 | 65 | // Get Parameters |
66 | 66 | $socid = GETPOST('socid', 'int'); |
67 | 67 | |
68 | -$action = GETPOST('action', 'aZ09'); |
|
68 | +$action = GETPOST('action', 'aZ09'); |
|
69 | 69 | $massaction = GETPOST('massaction', 'alpha'); |
70 | 70 | $show_files = GETPOST('show_files', 'int'); |
71 | -$confirm = GETPOST('confirm', 'alpha'); |
|
71 | +$confirm = GETPOST('confirm', 'alpha'); |
|
72 | 72 | $cancel = GETPOST('cancel', 'alpha'); |
73 | -$toselect = GETPOST('toselect', 'array'); |
|
73 | +$toselect = GETPOST('toselect', 'array'); |
|
74 | 74 | $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'proposallist'; |
75 | -$mode = GETPOST('mode', 'alpha'); |
|
75 | +$mode = GETPOST('mode', 'alpha'); |
|
76 | 76 | |
77 | 77 | // Search Fields |
78 | 78 | $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); |
79 | 79 | $search_user = GETPOST('search_user', 'int'); |
80 | 80 | $search_sale = GETPOST('search_sale', 'int'); |
81 | -$search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); |
|
81 | +$search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); |
|
82 | 82 | $search_refcustomer = GETPOST('search_refcustomer', 'alpha'); |
83 | 83 | $search_refproject = GETPOST('search_refproject', 'alpha'); |
84 | 84 | $search_project = GETPOST('search_project', 'alpha'); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $search_date_endday = GETPOST('search_date_endday', 'int'); |
107 | 107 | $search_date_endmonth = GETPOST('search_date_endmonth', 'int'); |
108 | 108 | $search_date_endyear = GETPOST('search_date_endyear', 'int'); |
109 | -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver |
|
109 | +$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver |
|
110 | 110 | $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); |
111 | 111 | $search_date_end_startday = GETPOST('search_date_end_startday', 'int'); |
112 | 112 | $search_date_end_startmonth = GETPOST('search_date_end_startmonth', 'int'); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $search_date_end_endday = GETPOST('search_date_end_endday', 'int'); |
115 | 115 | $search_date_end_endmonth = GETPOST('search_date_end_endmonth', 'int'); |
116 | 116 | $search_date_end_endyear = GETPOST('search_date_end_endyear', 'int'); |
117 | -$search_date_end_start = dol_mktime(0, 0, 0, $search_date_end_startmonth, $search_date_end_startday, $search_date_end_startyear); // Use tzserver |
|
117 | +$search_date_end_start = dol_mktime(0, 0, 0, $search_date_end_startmonth, $search_date_end_startday, $search_date_end_startyear); // Use tzserver |
|
118 | 118 | $search_date_end_end = dol_mktime(23, 59, 59, $search_date_end_endmonth, $search_date_end_endday, $search_date_end_endyear); |
119 | 119 | $search_date_delivery_startday = GETPOST('search_date_delivery_startday', 'int'); |
120 | 120 | $search_date_delivery_startmonth = GETPOST('search_date_delivery_startmonth', 'int'); |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | if ($searchCategoryCustomerOperator == 0) { |
754 | 754 | $searchCategoryCustomerSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie = ".((int) $searchCategoryCustomer).")"; |
755 | 755 | } else { |
756 | - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); |
|
756 | + $listofcategoryid .= ($listofcategoryid ? ', ' : '').((int) $searchCategoryCustomer); |
|
757 | 757 | } |
758 | 758 | } |
759 | 759 | } |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | if ($searchCategoryProductOperator == 0) { |
784 | 784 | $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."propaldet as pd WHERE pd.fk_propal = p.rowid AND pd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; |
785 | 785 | } else { |
786 | - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); |
|
786 | + $listofcategoryid .= ($listofcategoryid ? ', ' : '').((int) $searchCategoryProduct); |
|
787 | 787 | } |
788 | 788 | } |
789 | 789 | } |
@@ -1067,15 +1067,15 @@ discard block |
||
1067 | 1067 | 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), |
1068 | 1068 | ); |
1069 | 1069 | if ($permissiontosendbymail) { |
1070 | - $arrayofmassactions['presend']=img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"); |
|
1070 | + $arrayofmassactions['presend'] = img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"); |
|
1071 | 1071 | } |
1072 | 1072 | if ($permissiontovalidate) { |
1073 | - $arrayofmassactions['prevalidate']=img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"); |
|
1073 | + $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"); |
|
1074 | 1074 | } |
1075 | 1075 | if ($permissiontoclose) { |
1076 | - $arrayofmassactions['presign']=img_picto('', 'propal', 'class="pictofixedwidth"').$langs->trans("Sign"); |
|
1077 | - $arrayofmassactions['nopresign']=img_picto('', 'propal', 'class="pictofixedwidth"').$langs->trans("NoSign"); |
|
1078 | - $arrayofmassactions['setbilled'] =img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("ClassifyBilled"); |
|
1076 | + $arrayofmassactions['presign'] = img_picto('', 'propal', 'class="pictofixedwidth"').$langs->trans("Sign"); |
|
1077 | + $arrayofmassactions['nopresign'] = img_picto('', 'propal', 'class="pictofixedwidth"').$langs->trans("NoSign"); |
|
1078 | + $arrayofmassactions['setbilled'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("ClassifyBilled"); |
|
1079 | 1079 | } |
1080 | 1080 | if ($permissiontodelete) { |
1081 | 1081 | $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | |
137 | 137 | $sql .= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p"; |
138 | 138 | $sql .= " ON p.rowid = d.fk_projet"; |
139 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe AS s ON s.rowid = d.fk_soc"; |
|
140 | -$sql .= " WHERE d.entity IN (". getEntity('donation') . ")"; |
|
139 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe AS s ON s.rowid = d.fk_soc"; |
|
140 | +$sql .= " WHERE d.entity IN (".getEntity('donation').")"; |
|
141 | 141 | |
142 | 142 | if ($search_status != '' && $search_status != '-4') { |
143 | 143 | $sql .= " AND d.fk_statut IN (".$db->sanitize($search_status).")"; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | // Output page |
209 | 209 | // -------------------------------------------------------------------- |
210 | 210 | |
211 | -llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll |
|
211 | +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll |
|
212 | 212 | |
213 | 213 | // Example : Adding jquery code |
214 | 214 | // print '<script type="text/javascript"> |
@@ -83,46 +83,46 @@ discard block |
||
83 | 83 | $counter++; |
84 | 84 | $fileContent = null; |
85 | 85 | $refPath = $this->_langDir.$this->_refLang.self::DIR_SEPARATOR.$file; |
86 | - $fileContent = file($refPath, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); |
|
87 | - print "Processing file " . $file . ", with ".count($fileContent)." lines<br>\n"; |
|
86 | + $fileContent = file($refPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
87 | + print "Processing file ".$file.", with ".count($fileContent)." lines<br>\n"; |
|
88 | 88 | |
89 | 89 | // Define target dirs |
90 | - $targetlangs=array($this->_destlang); |
|
90 | + $targetlangs = array($this->_destlang); |
|
91 | 91 | if ($this->_destlang == 'all') { |
92 | - $targetlangs=array(); |
|
92 | + $targetlangs = array(); |
|
93 | 93 | |
94 | 94 | // If we must process all languages |
95 | - $arraytmp=dol_dir_list($this->_langDir, 'directories', 0); |
|
95 | + $arraytmp = dol_dir_list($this->_langDir, 'directories', 0); |
|
96 | 96 | foreach ($arraytmp as $dirtmp) { |
97 | 97 | if ($dirtmp['name'] === $this->_refLang) { |
98 | - continue; // We discard source language |
|
98 | + continue; // We discard source language |
|
99 | 99 | } |
100 | - $tmppart=explode('_', $dirtmp['name']); |
|
100 | + $tmppart = explode('_', $dirtmp['name']); |
|
101 | 101 | if (preg_match('/^en/i', $dirtmp['name'])) { |
102 | - continue; // We discard en_* languages |
|
102 | + continue; // We discard en_* languages |
|
103 | 103 | } |
104 | 104 | if (preg_match('/^fr/i', $dirtmp['name'])) { |
105 | - continue; // We discard fr_* languages |
|
105 | + continue; // We discard fr_* languages |
|
106 | 106 | } |
107 | 107 | if (preg_match('/^es/i', $dirtmp['name'])) { |
108 | - continue; // We discard es_* languages |
|
108 | + continue; // We discard es_* languages |
|
109 | 109 | } |
110 | 110 | if (preg_match('/ca_ES/i', $dirtmp['name'])) { |
111 | - continue; // We discard es_CA language |
|
111 | + continue; // We discard es_CA language |
|
112 | 112 | } |
113 | 113 | if (preg_match('/pt_BR/i', $dirtmp['name'])) { |
114 | - continue; // We discard pt_BR language |
|
114 | + continue; // We discard pt_BR language |
|
115 | 115 | } |
116 | 116 | if (preg_match('/nl_BE/i', $dirtmp['name'])) { |
117 | - continue; // We discard nl_BE language |
|
117 | + continue; // We discard nl_BE language |
|
118 | 118 | } |
119 | 119 | if (preg_match('/^\./i', $dirtmp['name'])) { |
120 | - continue; // We discard files .* |
|
120 | + continue; // We discard files .* |
|
121 | 121 | } |
122 | 122 | if (preg_match('/^CVS/i', $dirtmp['name'])) { |
123 | - continue; // We discard CVS |
|
123 | + continue; // We discard CVS |
|
124 | 124 | } |
125 | - $targetlangs[]=$dirtmp['name']; |
|
125 | + $targetlangs[] = $dirtmp['name']; |
|
126 | 126 | } |
127 | 127 | //var_dump($targetlangs); |
128 | 128 | } |
@@ -133,27 +133,27 @@ discard block |
||
133 | 133 | |
134 | 134 | $destPath = $this->_langDir.$my_destlang.self::DIR_SEPARATOR.$file; |
135 | 135 | // Check destination file presence |
136 | - if (! file_exists($destPath)) { |
|
136 | + if (!file_exists($destPath)) { |
|
137 | 137 | // No file present, we generate file |
138 | - echo "File not found: " . $destPath . ". We generate it.<br>\n"; |
|
138 | + echo "File not found: ".$destPath.". We generate it.<br>\n"; |
|
139 | 139 | $this->createTranslationFile($destPath, $my_destlang); |
140 | 140 | } else { |
141 | - echo "Updating file: " . $destPath . "<br>\n"; |
|
141 | + echo "Updating file: ".$destPath."<br>\n"; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | // Translate lines |
145 | - $fileContentDest = file($destPath, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); |
|
146 | - $newlines=0; |
|
145 | + $fileContentDest = file($destPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
146 | + $newlines = 0; |
|
147 | 147 | foreach ($fileContent as $line) { |
148 | 148 | $key = $this->getLineKey($line); |
149 | 149 | $value = $this->getLineValue($line); |
150 | 150 | if ($key && $value) { |
151 | - $newlines+=$this->translateFileLine($fileContentDest, $file, $key, $value, $my_destlang); |
|
151 | + $newlines += $this->translateFileLine($fileContentDest, $file, $key, $value, $my_destlang); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | 155 | $this->updateTranslationFile($destPath, $file, $my_destlang); |
156 | - echo "New translated lines: " . $newlines . "<br>\n"; |
|
156 | + echo "New translated lines: ".$newlines."<br>\n"; |
|
157 | 157 | //if ($counter ==3) die('fim'); |
158 | 158 | } |
159 | 159 | } |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | { |
172 | 172 | $this->_time_end = date('Y-m-d H:i:s'); |
173 | 173 | |
174 | - if (isset($this->_translatedFiles[$file]) && count($this->_translatedFiles[$file])>0) { |
|
174 | + if (isset($this->_translatedFiles[$file]) && count($this->_translatedFiles[$file]) > 0) { |
|
175 | 175 | $fp = fopen($destPath, 'a'); |
176 | 176 | fwrite($fp, "\n"); |
177 | 177 | fwrite($fp, "\n"); |
178 | 178 | fwrite($fp, "// START - Lines generated via autotranslator.php tool (".$this->_time.").\n"); |
179 | 179 | fwrite($fp, "// Reference language: ".$this->_refLang." -> ".$my_destlang."\n"); |
180 | 180 | foreach ($this->_translatedFiles[$file] as $line) { |
181 | - fwrite($fp, $line . "\n"); |
|
181 | + fwrite($fp, $line."\n"); |
|
182 | 182 | } |
183 | 183 | fwrite($fp, "// STOP - Lines generated via autotranslator.php tool (".$this->_time_end.").\n"); |
184 | 184 | fclose($fp); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | fwrite($fp, "/*\n"); |
200 | 200 | fwrite($fp, " * Language code: {$my_destlang}\n"); |
201 | 201 | fwrite($fp, " * Automatic generated via autotranslator.php tool\n"); |
202 | - fwrite($fp, " * Generation date " . $this->_time. "\n"); |
|
202 | + fwrite($fp, " * Generation date ".$this->_time."\n"); |
|
203 | 203 | fwrite($fp, " */\n"); |
204 | 204 | fclose($fp); |
205 | 205 | return; |
@@ -230,27 +230,27 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | if ($key == 'CHARSET') { |
233 | - $val=$this->_outputpagecode; |
|
233 | + $val = $this->_outputpagecode; |
|
234 | 234 | } elseif (preg_match('/^Format/', $key)) { |
235 | - $val=$value; |
|
236 | - } elseif ($value=='-') { |
|
237 | - $val=$value; |
|
235 | + $val = $value; |
|
236 | + } elseif ($value == '-') { |
|
237 | + $val = $value; |
|
238 | 238 | } else { |
239 | 239 | // If not translated then translate |
240 | 240 | if ($this->_outputpagecode == 'UTF-8') { |
241 | - $val=$this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2)); |
|
241 | + $val = $this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2)); |
|
242 | 242 | } else { |
243 | - $val=mb_convert_encoding($this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2)), 'ISO-8859-1'); |
|
243 | + $val = mb_convert_encoding($this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2)), 'ISO-8859-1'); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | - $val=trim($val); |
|
247 | + $val = trim($val); |
|
248 | 248 | |
249 | 249 | if (empty($val)) { |
250 | 250 | return 0; |
251 | 251 | } |
252 | 252 | |
253 | - $this->_translatedFiles[$file][] = $key . '=' . $val ; |
|
253 | + $this->_translatedFiles[$file][] = $key.'='.$val; |
|
254 | 254 | return 1; |
255 | 255 | } |
256 | 256 | |
@@ -288,8 +288,8 @@ discard block |
||
288 | 288 | { |
289 | 289 | $dir = new DirectoryIterator($this->_langDir.$lang); |
290 | 290 | while ($dir->valid()) { |
291 | - if (!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) { |
|
292 | - $files[] = $dir->getFilename(); |
|
291 | + if (!$dir->isDot() && $dir->isFile() && !preg_match('/^\./', $dir->getFilename())) { |
|
292 | + $files[] = $dir->getFilename(); |
|
293 | 293 | } |
294 | 294 | $dir->next(); |
295 | 295 | } |
@@ -307,20 +307,20 @@ discard block |
||
307 | 307 | private function translateTexts($src_texts, $src_lang, $dest_lang) |
308 | 308 | { |
309 | 309 | // We want to be sure that src_lang and dest_lang are using 2 chars only |
310 | - $tmp=explode('_', $src_lang); |
|
310 | + $tmp = explode('_', $src_lang); |
|
311 | 311 | if (!empty($tmp[1]) && $tmp[0] == $tmp[1]) { |
312 | - $src_lang=$tmp[0]; |
|
312 | + $src_lang = $tmp[0]; |
|
313 | 313 | } |
314 | - $tmp=explode('_', $dest_lang); |
|
314 | + $tmp = explode('_', $dest_lang); |
|
315 | 315 | if (!empty($tmp[1]) && $tmp[0] == $tmp[1]) { |
316 | - $dest_lang=$tmp[0]; |
|
316 | + $dest_lang = $tmp[0]; |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | //setting language pair |
320 | 320 | $lang_pair = $src_lang.'|'.$dest_lang; |
321 | 321 | |
322 | - $src_text_to_translate=preg_replace('/%s/', 'SSSSS', implode('', $src_texts)); |
|
323 | - $src_text_to_translate=preg_replace('/'.preg_quote('\n\n').'/', ' NNNNN ', $src_text_to_translate); |
|
322 | + $src_text_to_translate = preg_replace('/%s/', 'SSSSS', implode('', $src_texts)); |
|
323 | + $src_text_to_translate = preg_replace('/'.preg_quote('\n\n').'/', ' NNNNN ', $src_text_to_translate); |
|
324 | 324 | |
325 | 325 | // Define GET URL v1 |
326 | 326 | //$url = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode($src_text_to_translate)."&langpair=".urlencode($lang_pair); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | // Send request |
333 | 333 | //print "Url to translate: ".$url."\n"; |
334 | 334 | |
335 | - if (! function_exists("curl_init")) { |
|
335 | + if (!function_exists("curl_init")) { |
|
336 | 336 | print "Error, your PHP does not support curl functions.\n"; |
337 | 337 | die(); |
338 | 338 | } |
@@ -354,10 +354,10 @@ discard block |
||
354 | 354 | return false; |
355 | 355 | } |
356 | 356 | |
357 | - $rep=$json['data']['translations'][0]['translatedText']; |
|
358 | - $rep=preg_replace('/SSSSS/i', '%s', $rep); |
|
359 | - $rep=preg_replace('/NNNNN/i', '\n\n', $rep); |
|
360 | - $rep=preg_replace('/'/i', '\'', $rep); |
|
357 | + $rep = $json['data']['translations'][0]['translatedText']; |
|
358 | + $rep = preg_replace('/SSSSS/i', '%s', $rep); |
|
359 | + $rep = preg_replace('/NNNNN/i', '\n\n', $rep); |
|
360 | + $rep = preg_replace('/'/i', '\'', $rep); |
|
361 | 361 | |
362 | 362 | //print "OK ".join('',$src_texts).' => '.$rep."\n"; |
363 | 363 |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | global $conf, $user, $langs, $db; |
28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
30 | -require_once dirname(__FILE__) . '/../../htdocs/master.inc.php'; |
|
31 | -require_once dirname(__FILE__) . '/../../htdocs/core/class/CMailFile.class.php'; |
|
32 | -require_once dirname(__FILE__) . '/../../htdocs/core/lib/files.lib.php'; |
|
30 | +require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
|
31 | +require_once dirname(__FILE__).'/../../htdocs/core/class/CMailFile.class.php'; |
|
32 | +require_once dirname(__FILE__).'/../../htdocs/core/lib/files.lib.php'; |
|
33 | 33 | |
34 | 34 | if (empty($user->id)) { |
35 | 35 | print "Load permissions for admin user nb 1\n"; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $this->savlangs = $langs; |
72 | 72 | $this->savdb = $db; |
73 | 73 | |
74 | - print __METHOD__ . " db->type=" . $db->type . " user->id=" . $user->id; |
|
74 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
75 | 75 | //print " - db ".$db->db; |
76 | 76 | print "\n"; |
77 | 77 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | global $conf, $user, $langs, $db; |
87 | 87 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
88 | 88 | |
89 | - print __METHOD__ . "\n"; |
|
89 | + print __METHOD__."\n"; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | global $conf, $user, $langs, $db; |
100 | 100 | $db->rollback(); |
101 | 101 | |
102 | - print __METHOD__ . "\n"; |
|
102 | + print __METHOD__."\n"; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | $langs = $this->savlangs; |
116 | 116 | $db = $this->savdb; |
117 | 117 | |
118 | - $conf->global->MAIN_DISABLE_ALL_MAILS = 1; // If I comment/remove this lien, unit test still works alone but failed when ran from AllTest. Don't know why. |
|
118 | + $conf->global->MAIN_DISABLE_ALL_MAILS = 1; // If I comment/remove this lien, unit test still works alone but failed when ran from AllTest. Don't know why. |
|
119 | 119 | |
120 | - print __METHOD__ . "\n"; |
|
120 | + print __METHOD__."\n"; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function tearDown(): void |
129 | 129 | { |
130 | - print __METHOD__ . "\n"; |
|
130 | + print __METHOD__."\n"; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | $localobject = new CMailFile('Test', '[email protected]', '[email protected]', 'Message txt', array(), array(), array(), '', '', 1, 0); |
147 | 147 | |
148 | 148 | $result = $localobject->sendfile(); |
149 | - print __METHOD__ . " result=" . $result . "\n"; |
|
150 | - $this->assertFalse($result); // False because mail send disabled |
|
149 | + print __METHOD__." result=".$result."\n"; |
|
150 | + $this->assertFalse($result); // False because mail send disabled |
|
151 | 151 | |
152 | 152 | return $result; |
153 | 153 | } |
@@ -169,42 +169,42 @@ discard block |
||
169 | 169 | |
170 | 170 | $src = 'John Doe <[email protected]>'; |
171 | 171 | $result = $localobject->getValidAddress($src, 0); |
172 | - print __METHOD__ . " result=" . $result . "\n"; |
|
172 | + print __METHOD__." result=".$result."\n"; |
|
173 | 173 | $this->assertEquals($result, 'John Doe <[email protected]>'); |
174 | 174 | |
175 | 175 | $src = 'John Doe <[email protected]>'; |
176 | 176 | $result = $localobject->getValidAddress($src, 1); |
177 | - print __METHOD__ . " result=" . $result . "\n"; |
|
177 | + print __METHOD__." result=".$result."\n"; |
|
178 | 178 | $this->assertEquals($result, '<[email protected]>'); |
179 | 179 | |
180 | 180 | $src = 'John Doe <[email protected]>'; |
181 | 181 | $result = $localobject->getValidAddress($src, 2); |
182 | - print __METHOD__ . " result=" . $result . "\n"; |
|
182 | + print __METHOD__." result=".$result."\n"; |
|
183 | 183 | $this->assertEquals($result, '[email protected]'); |
184 | 184 | |
185 | 185 | $src = 'John Doe <[email protected]>'; |
186 | 186 | $result = $localobject->getValidAddress($src, 3, 0); |
187 | - print __METHOD__ . " result=" . $result . "\n"; |
|
187 | + print __METHOD__." result=".$result."\n"; |
|
188 | 188 | $this->assertEquals($result, '"John Doe" <[email protected]>'); |
189 | 189 | |
190 | 190 | $src = 'John Doe <[email protected]>'; |
191 | 191 | $result = $localobject->getValidAddress($src, 3, 1); |
192 | - print __METHOD__ . " result=" . $result . "\n"; |
|
192 | + print __METHOD__." result=".$result."\n"; |
|
193 | 193 | $this->assertEquals($result, '"=?UTF-8?B?Sm9obiBEb2U=?=" <[email protected]>'); |
194 | 194 | |
195 | 195 | $src = 'John Doe <[email protected]>'; |
196 | 196 | $result = $localobject->getValidAddress($src, 4); |
197 | - print __METHOD__ . " result=" . $result . "\n"; |
|
197 | + print __METHOD__." result=".$result."\n"; |
|
198 | 198 | $this->assertEquals($result, 'John Doe'); |
199 | 199 | |
200 | 200 | $src = 'John Doe <[email protected]>, John Doe2 <[email protected]>, John Doe3 <[email protected]>'; |
201 | 201 | $result = $localobject->getValidAddress($src, 4); |
202 | - print __METHOD__ . " result=" . $result . "\n"; |
|
202 | + print __METHOD__." result=".$result."\n"; |
|
203 | 203 | $this->assertEquals($result, 'John Doe,John Doe2,John Doe3'); |
204 | 204 | |
205 | 205 | $src = 'John Doe <[email protected]>, John Doe2 <[email protected]>, John Doe3 <[email protected]>'; |
206 | 206 | $result = $localobject->getValidAddress($src, 4, 0, 2); |
207 | - print __METHOD__ . " result=" . $result . "\n"; |
|
207 | + print __METHOD__." result=".$result."\n"; |
|
208 | 208 | $this->assertEquals($result, 'John Doe,John Doe2...'); |
209 | 209 | |
210 | 210 | return $result; |
@@ -226,9 +226,9 @@ discard block |
||
226 | 226 | $conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS = 1; |
227 | 227 | $conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA = 1; |
228 | 228 | |
229 | - dol_delete_dir_recursive(DOL_DATA_ROOT . '/medias/image'); |
|
230 | - dol_mkdir(DOL_DATA_ROOT . '/medias/image'); |
|
231 | - dol_copy(dirname(__FILE__) . '/img250x20.png', DOL_DATA_ROOT . '/medias/image/img250x20.png'); |
|
229 | + dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/image'); |
|
230 | + dol_mkdir(DOL_DATA_ROOT.'/medias/image'); |
|
231 | + dol_copy(dirname(__FILE__).'/img250x20.png', DOL_DATA_ROOT.'/medias/image/img250x20.png'); |
|
232 | 232 | |
233 | 233 | $msg = '<html><body>'; |
234 | 234 | $msg .= '<img alt="" src="/viewimage.php?modulepart=medias&entity=1&file=image/img250x20.png" style="height:39px; width:150px" />'; |
@@ -239,31 +239,31 @@ discard block |
||
239 | 239 | $localobject = new CMailFile('Test', '[email protected]', '[email protected]', $msg, array(), array(), array(), '', '', 0, -1, '', '', '', '', 'standard', '', '/tmp'); |
240 | 240 | |
241 | 241 | $result = count($localobject->html_images); |
242 | - print __METHOD__ . " result count image detected in the mail=" . $result . "\n"; |
|
242 | + print __METHOD__." result count image detected in the mail=".$result."\n"; |
|
243 | 243 | $this->assertEquals($result, 2); |
244 | 244 | |
245 | 245 | |
246 | 246 | foreach ($localobject->html_images as $i => $val) |
247 | 247 | if ($localobject->html_images[$i]) { |
248 | 248 | if (preg_match('/img250x20\.png/i', $localobject->html_images[$i]['fullpath'])) { |
249 | - print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n"; |
|
249 | + print __METHOD__." content type must be image png =".$localobject->html_images[$i]['content_type']."\n"; |
|
250 | 250 | $this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png'); |
251 | 251 | |
252 | - print __METHOD__ . " type must be cidfromurl =" . $localobject->html_images[$i]['type'] . "\n"; |
|
252 | + print __METHOD__." type must be cidfromurl =".$localobject->html_images[$i]['type']."\n"; |
|
253 | 253 | $this->assertEquals($localobject->html_images[$i]['type'], 'cidfromurl'); |
254 | 254 | |
255 | 255 | $fileSize = 9744; |
256 | - print __METHOD__ . " File size must be =" . $fileSize . "\n"; |
|
256 | + print __METHOD__." File size must be =".$fileSize."\n"; |
|
257 | 257 | $this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize); |
258 | 258 | } elseif (preg_match('/\.png/i', $localobject->html_images[$i]['fullpath'])) { |
259 | - print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n"; |
|
259 | + print __METHOD__." content type must be image png =".$localobject->html_images[$i]['content_type']."\n"; |
|
260 | 260 | $this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png'); |
261 | 261 | |
262 | - print __METHOD__ . " type must be cidfromdata =" . $localobject->html_images[$i]['type'] . "\n"; |
|
262 | + print __METHOD__." type must be cidfromdata =".$localobject->html_images[$i]['type']."\n"; |
|
263 | 263 | $this->assertEquals($localobject->html_images[$i]['type'], 'cidfromdata'); |
264 | 264 | |
265 | 265 | $fileSize = 85; |
266 | - print __METHOD__ . " File size must be =" . $fileSize . "\n"; |
|
266 | + print __METHOD__." File size must be =".$fileSize."\n"; |
|
267 | 267 | $this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize); |
268 | 268 | } |
269 | 269 | } |