@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined('ODTPHP_PATHTOPCLZIP')) define('ODTPHP_PATHTOPCLZIP','pclzip/'); |
|
2 | +if (! defined('ODTPHP_PATHTOPCLZIP')) { |
|
3 | + define('ODTPHP_PATHTOPCLZIP','pclzip/'); |
|
4 | +} |
|
3 | 5 | require_once ODTPHP_PATHTOPCLZIP.'pclzip.lib.php'; |
4 | 6 | require_once 'ZipInterface.php'; |
5 | 7 | class PclZipProxyException extends Exception |
@@ -32,7 +34,10 @@ discard block |
||
32 | 34 | throw new PclZipProxyException('PclZip class not loaded - PclZip library |
33 | 35 | is required for using PclZipProxy'); ; |
34 | 36 | } |
35 | - if ($forcedir) $this->tmpdir=preg_replace('|[//\/]$|','',$forcedir); // $this->tmpdir must not contains / at the end |
|
37 | + if ($forcedir) { |
|
38 | + $this->tmpdir=preg_replace('|[//\/]$|','',$forcedir); |
|
39 | + } |
|
40 | + // $this->tmpdir must not contains / at the end |
|
36 | 41 | } |
37 | 42 | |
38 | 43 | /** |
@@ -72,7 +72,10 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | $md5uniqid = md5(uniqid()); |
75 | - if ($this->config['PATH_TO_TMP']) $this->tmpdir = preg_replace('|[\/]$|', '', $this->config['PATH_TO_TMP']); // Remove last \ or / |
|
75 | + if ($this->config['PATH_TO_TMP']) { |
|
76 | + $this->tmpdir = preg_replace('|[\/]$|', '', $this->config['PATH_TO_TMP']); |
|
77 | + } |
|
78 | + // Remove last \ or / |
|
76 | 79 | $this->tmpdir .= ($this->tmpdir?'/':'').$md5uniqid; |
77 | 80 | $this->tmpfile = $this->tmpdir.'/'.$md5uniqid.'.odt'; // We keep .odt extension to allow OpenOffice usage during debug. |
78 | 81 | |
@@ -88,7 +91,9 @@ discard block |
||
88 | 91 | |
89 | 92 | // Load zip proxy |
90 | 93 | $zipHandler = $this->config['ZIP_PROXY']; |
91 | - if (!defined('PCLZIP_TEMPORARY_DIR')) define('PCLZIP_TEMPORARY_DIR', $this->tmpdir); |
|
94 | + if (!defined('PCLZIP_TEMPORARY_DIR')) { |
|
95 | + define('PCLZIP_TEMPORARY_DIR', $this->tmpdir); |
|
96 | + } |
|
92 | 97 | include_once 'zip/'.$zipHandler.'.php'; |
93 | 98 | if (! class_exists($this->config['ZIP_PROXY'])) { |
94 | 99 | throw new OdfException($this->config['ZIP_PROXY'] . ' class not found - check your php settings'); |
@@ -230,8 +235,12 @@ discard block |
||
230 | 235 | */ |
231 | 236 | private function _replaceHtmlWithOdtTag($tags, &$customStyles, &$fontDeclarations, $encode = false, $charset = '') |
232 | 237 | { |
233 | - if ($customStyles == null) $customStyles = array(); |
|
234 | - if ($fontDeclarations == null) $fontDeclarations = array(); |
|
238 | + if ($customStyles == null) { |
|
239 | + $customStyles = array(); |
|
240 | + } |
|
241 | + if ($fontDeclarations == null) { |
|
242 | + $fontDeclarations = array(); |
|
243 | + } |
|
235 | 244 | |
236 | 245 | $odtResult = ''; |
237 | 246 | |
@@ -589,7 +598,9 @@ discard block |
||
589 | 598 | $reg = '@\[!--\sIF\s' . $key . '\s--\](.*)(\[!--\sELSE\s' . $key . '\s--\](.*))?\[!--\sENDIF\s' . $key . '\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
590 | 599 | preg_match_all($reg, $this->contentXml, $matches, PREG_SET_ORDER); |
591 | 600 | 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 |
592 | - if (!empty($match[3])) $this->contentXml = str_replace($match[0], $match[3], $this->contentXml); |
|
601 | + if (!empty($match[3])) { |
|
602 | + $this->contentXml = str_replace($match[0], $match[3], $this->contentXml); |
|
603 | + } |
|
593 | 604 | } |
594 | 605 | // Cleanup the other conditional blocks (all the others where there were no ELSE clause, we can just remove them altogether) |
595 | 606 | $this->contentXml = preg_replace($reg, '', $this->contentXml); |
@@ -602,9 +613,15 @@ discard block |
||
602 | 613 | } |
603 | 614 | |
604 | 615 | // Static substitution |
605 | - if ($type == 'content') $this->contentXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->contentXml); |
|
606 | - if ($type == 'styles') $this->stylesXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->stylesXml); |
|
607 | - if ($type == 'meta') $this->metaXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->metaXml); |
|
616 | + if ($type == 'content') { |
|
617 | + $this->contentXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->contentXml); |
|
618 | + } |
|
619 | + if ($type == 'styles') { |
|
620 | + $this->stylesXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->stylesXml); |
|
621 | + } |
|
622 | + if ($type == 'meta') { |
|
623 | + $this->metaXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->metaXml); |
|
624 | + } |
|
608 | 625 | } |
609 | 626 | |
610 | 627 | /** |
@@ -745,7 +762,9 @@ discard block |
||
745 | 762 | */ |
746 | 763 | public function setMetaData() |
747 | 764 | { |
748 | - if (empty($this->creator)) $this->creator=''; |
|
765 | + if (empty($this->creator)) { |
|
766 | + $this->creator=''; |
|
767 | + } |
|
749 | 768 | |
750 | 769 | $this->metaXml = preg_replace('/<dc:date>.*<\/dc:date>/', '<dc:date>'.gmdate("Y-m-d\TH:i:s").'</dc:date>', $this->metaXml); |
751 | 770 | $this->metaXml = preg_replace('/<dc:creator>.*<\/dc:creator>/', '<dc:creator>'.htmlspecialchars($this->creator).'</dc:creator>', $this->metaXml); |
@@ -813,7 +832,9 @@ discard block |
||
813 | 832 | { |
814 | 833 | global $conf; |
815 | 834 | |
816 | - if ( $name == "" ) $name = "temp".md5(uniqid()); |
|
835 | + if ( $name == "" ) { |
|
836 | + $name = "temp".md5(uniqid()); |
|
837 | + } |
|
817 | 838 | |
818 | 839 | dol_syslog(get_class($this).'::exportAsAttachedPDF $name='.$name, LOG_DEBUG); |
819 | 840 | $this->saveToDisk($name); |
@@ -88,10 +88,16 @@ discard block |
||
88 | 88 | { |
89 | 89 | // To provide debug information on line number processed |
90 | 90 | global $count; |
91 | - if (empty($count)) $count=1; |
|
92 | - else $count++; |
|
91 | + if (empty($count)) { |
|
92 | + $count=1; |
|
93 | + } else { |
|
94 | + $count++; |
|
95 | + } |
|
93 | 96 | |
94 | - if (empty($this->savxml)) $this->savxml = $this->xml; // Sav content of line at first line merged, so we will reuse original for next steps |
|
97 | + if (empty($this->savxml)) { |
|
98 | + $this->savxml = $this->xml; |
|
99 | + } |
|
100 | + // Sav content of line at first line merged, so we will reuse original for next steps |
|
95 | 101 | $this->xml = $this->savxml; |
96 | 102 | $tmpvars = $this->vars; // Store into $tmpvars so we won't modify this->vars when completing data with empty values |
97 | 103 | |
@@ -123,7 +129,9 @@ discard block |
||
123 | 129 | $reg = '@\[!--\sIF\s' . $key . '\s--\](.*)(\[!--\sELSE\s' . $key . '\s--\](.*))?\[!--\sENDIF\s' . $key . '\s--\]@smU'; // U modifier = all quantifiers are non-greedy |
124 | 130 | preg_match_all($reg, $this->xml, $matches, PREG_SET_ORDER); |
125 | 131 | 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 |
126 | - if (!empty($match[3])) $this->xml = str_replace($match[0], $match[3], $this->xml); |
|
132 | + if (!empty($match[3])) { |
|
133 | + $this->xml = str_replace($match[0], $match[3], $this->xml); |
|
134 | + } |
|
127 | 135 | } |
128 | 136 | // Cleanup the other conditional blocks (all the others where there were no ELSE clause, we can just remove them altogether) |
129 | 137 | $this->xml = preg_replace($reg, '', $this->xml); |
@@ -113,7 +113,9 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | if ($counter > 0) { |
116 | - if (!$continueCallBack()) break; |
|
116 | + if (!$continueCallBack()) { |
|
117 | + break; |
|
118 | + } |
|
117 | 119 | } |
118 | 120 | |
119 | 121 | } |
@@ -140,9 +142,11 @@ discard block |
||
140 | 142 | // Create a new index. |
141 | 143 | $listeners = []; |
142 | 144 | $listenersPriority = []; |
143 | - if (isset($this->listeners[$eventName])) foreach ($this->listeners[$eventName] as $listener) { |
|
145 | + if (isset($this->listeners[$eventName])) { |
|
146 | + foreach ($this->listeners[$eventName] as $listener) { |
|
144 | 147 | |
145 | 148 | $listenersPriority[] = $listener[0]; |
149 | + } |
|
146 | 150 | $listeners[] = $listener[1]; |
147 | 151 | |
148 | 152 | } |
@@ -105,7 +105,9 @@ |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | if ($counter > 0) { |
108 | - if (!$continueCallBack()) break; |
|
108 | + if (!$continueCallBack()) { |
|
109 | + break; |
|
110 | + } |
|
109 | 111 | } |
110 | 112 | |
111 | 113 | } |
@@ -25,8 +25,9 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public static function contains($haystack, $needle, $caseSensitive = true) |
27 | 27 | { |
28 | - if (empty($needle)) |
|
29 | - return true; |
|
28 | + if (empty($needle)) { |
|
29 | + return true; |
|
30 | + } |
|
30 | 31 | return $caseSensitive |
31 | 32 | ? strpos($haystack, $needle) !== false |
32 | 33 | : stripos($haystack, $needle) !== false; |
@@ -62,7 +63,9 @@ discard block |
||
62 | 63 | } |
63 | 64 | |
64 | 65 | // @CHANGE LDR |
65 | - if (!is_string($haystack)) return false; |
|
66 | + if (!is_string($haystack)) { |
|
67 | + return false; |
|
68 | + } |
|
66 | 69 | |
67 | 70 | return (substr($haystack, -$length) === $needle); |
68 | 71 | } |
@@ -25,9 +25,13 @@ |
||
25 | 25 | { |
26 | 26 | $copy = array(); |
27 | 27 | foreach ($arr as $key => $value) { |
28 | - if (is_array($value)) $copy[$key] = static::copy($value); |
|
29 | - else if (is_object($value)) $copy[$key] = clone $value; |
|
30 | - else $copy[$key] = $value; |
|
28 | + if (is_array($value)) { |
|
29 | + $copy[$key] = static::copy($value); |
|
30 | + } else if (is_object($value)) { |
|
31 | + $copy[$key] = clone $value; |
|
32 | + } else { |
|
33 | + $copy[$key] = $value; |
|
34 | + } |
|
31 | 35 | } |
32 | 36 | return $copy; |
33 | 37 | } |
@@ -549,7 +549,9 @@ |
||
549 | 549 | case 'string' : |
550 | 550 | case 'password' : //password fields with string |
551 | 551 | case 'search' : //search field with string |
552 | - if (is_bool($input)) $input = $input ? 'true' : 'false'; |
|
552 | + if (is_bool($input)) { |
|
553 | + $input = $input ? 'true' : 'false'; |
|
554 | + } |
|
553 | 555 | if (!is_string($input)) { |
554 | 556 | $error .= '. Expecting alpha numeric value'; |
555 | 557 | break; |
@@ -231,8 +231,9 @@ discard block |
||
231 | 231 | } |
232 | 232 | $fLen = strlen($fullPath); |
233 | 233 | if ($tSlash) { |
234 | - if ($fLen != $tLen && !Text::beginsWith($fullPath, $target . '/')) |
|
235 | - continue; |
|
234 | + if ($fLen != $tLen && !Text::beginsWith($fullPath, $target . '/')) { |
|
235 | + continue; |
|
236 | + } |
|
236 | 237 | } elseif ($fLen > $tLen + 1 && $fullPath[$tLen + 1] != '{' && !Text::beginsWith($fullPath, '{')) { |
237 | 238 | //when mapped to root exclude paths that have static parts |
238 | 239 | //they are listed else where under that static part name |
@@ -244,8 +245,9 @@ discard block |
||
244 | 245 | } |
245 | 246 | foreach (static::$excludedPaths as $exclude) { |
246 | 247 | if (empty($exclude)) { |
247 | - if ($fullPath == $exclude) |
|
248 | - continue 2; |
|
248 | + if ($fullPath == $exclude) { |
|
249 | + continue 2; |
|
250 | + } |
|
249 | 251 | } elseif (Text::beginsWith($fullPath, $exclude)) { |
250 | 252 | continue 2; |
251 | 253 | } |
@@ -283,8 +285,9 @@ discard block |
||
283 | 285 | } |
284 | 286 | $nickname = $this->_nickname($route); |
285 | 287 | $index = static::$placeFormatExtensionBeforeDynamicParts && $pos > 0 ? $pos : 0; |
286 | - if (!empty($parts[$index])) |
|
287 | - $parts[$index] .= $this->formatString; |
|
288 | + if (!empty($parts[$index])) { |
|
289 | + $parts[$index] .= $this->formatString; |
|
290 | + } |
|
288 | 291 | |
289 | 292 | $fullPath = implode('/', $parts); |
290 | 293 | $description = isset( |
@@ -388,8 +391,9 @@ discard block |
||
388 | 391 | if (!$count) { |
389 | 392 | throw new RestException(404); |
390 | 393 | } |
391 | - if (!is_null($r)) |
|
392 | - $r->models = $this->_models; |
|
394 | + if (!is_null($r)) { |
|
395 | + $r->models = $this->_models; |
|
396 | + } |
|
393 | 397 | usort( |
394 | 398 | $r->apis, |
395 | 399 | function ($a, $b) { |
@@ -681,8 +685,9 @@ discard block |
||
681 | 685 | // Create default object that includes parameters to be submitted |
682 | 686 | $defaultObject = new \StdClass(); |
683 | 687 | foreach ($this->_bodyParam['names'] as $name => $values) { |
684 | - if (!$values->required) |
|
685 | - continue; |
|
688 | + if (!$values->required) { |
|
689 | + continue; |
|
690 | + } |
|
686 | 691 | if (class_exists($values->dataType)) { |
687 | 692 | $myClassName = $values->dataType; |
688 | 693 | $defaultObject->$name = new $myClassName(); |
@@ -706,8 +711,9 @@ discard block |
||
706 | 711 | } |
707 | 712 | $properties = array(); |
708 | 713 | if (!$instance) { |
709 | - if (!class_exists($className)) |
|
710 | - return; |
|
714 | + if (!class_exists($className)) { |
|
715 | + return; |
|
716 | + } |
|
711 | 717 | $instance = new $className(); |
712 | 718 | } |
713 | 719 | $data = get_object_vars($instance); |
@@ -828,8 +834,12 @@ discard block |
||
828 | 834 | } |
829 | 835 | return 'array'; |
830 | 836 | } |
831 | - if (is_bool($o)) return 'boolean'; |
|
832 | - if (is_numeric($o)) return is_float($o) ? 'float' : 'int'; |
|
837 | + if (is_bool($o)) { |
|
838 | + return 'boolean'; |
|
839 | + } |
|
840 | + if (is_numeric($o)) { |
|
841 | + return is_float($o) ? 'float' : 'int'; |
|
842 | + } |
|
833 | 843 | return 'string'; |
834 | 844 | } |
835 | 845 | |
@@ -879,8 +889,9 @@ discard block |
||
879 | 889 | */ |
880 | 890 | public function index() |
881 | 891 | { |
882 | - if (!static::$accessControlFunction && Defaults::$accessControlFunction) |
|
883 | - static::$accessControlFunction = Defaults::$accessControlFunction; |
|
892 | + if (!static::$accessControlFunction && Defaults::$accessControlFunction) { |
|
893 | + static::$accessControlFunction = Defaults::$accessControlFunction; |
|
894 | + } |
|
884 | 895 | $version = $this->restler->getRequestedApiVersion(); |
885 | 896 | $allRoutes = Util::nestedValue(Routes::toArray(), "v$version"); |
886 | 897 | $r = $this->_resourceListing(); |
@@ -934,8 +945,9 @@ discard block |
||
934 | 945 | foreach ($allRoutes as $fullPath => $routes) { |
935 | 946 | $path = explode('/', $fullPath); |
936 | 947 | $resource = isset($path[0]) ? $path[0] : ''; |
937 | - if ($resource == 'resources' || Text::endsWith($resource, 'index')) |
|
938 | - continue; |
|
948 | + if ($resource == 'resources' || Text::endsWith($resource, 'index')) { |
|
949 | + continue; |
|
950 | + } |
|
939 | 951 | foreach ($routes as $httpMethod => $route) { |
940 | 952 | if (in_array($httpMethod, static::$excludedHttpMethods)) { |
941 | 953 | continue; |
@@ -946,8 +958,9 @@ discard block |
||
946 | 958 | |
947 | 959 | foreach (static::$excludedPaths as $exclude) { |
948 | 960 | if (empty($exclude)) { |
949 | - if ($fullPath == $exclude) |
|
950 | - continue 2; |
|
961 | + if ($fullPath == $exclude) { |
|
962 | + continue 2; |
|
963 | + } |
|
951 | 964 | } elseif (Text::beginsWith($fullPath, $exclude)) { |
952 | 965 | continue 2; |
953 | 966 | } |