@@ -29,5 +29,5 @@ |
||
29 | 29 | */ |
30 | 30 | function PluginStringFormatCompile(Compiler $compiler, $value, $format) |
31 | 31 | { |
32 | - return 'sprintf(' . $format . ',' . $value . ')'; |
|
32 | + return 'sprintf(' . $format . ',' . $value . ')'; |
|
33 | 33 | } |
@@ -29,5 +29,5 @@ |
||
29 | 29 | */ |
30 | 30 | function PluginStringFormatCompile(Compiler $compiler, $value, $format) |
31 | 31 | { |
32 | - return 'sprintf(' . $format . ',' . $value . ')'; |
|
32 | + return 'sprintf('.$format.','.$value.')'; |
|
33 | 33 | } |
@@ -29,5 +29,5 @@ |
||
29 | 29 | */ |
30 | 30 | function PluginDefaultCompile(Compiler $compiler, $value, $default = '') |
31 | 31 | { |
32 | - return '(($tmp = ' . $value . ')===null||$tmp===\'\' ? ' . $default . ' : $tmp)'; |
|
32 | + return '(($tmp = ' . $value . ')===null||$tmp===\'\' ? ' . $default . ' : $tmp)'; |
|
33 | 33 | } |
@@ -29,5 +29,5 @@ |
||
29 | 29 | */ |
30 | 30 | function PluginDefaultCompile(Compiler $compiler, $value, $default = '') |
31 | 31 | { |
32 | - return '(($tmp = ' . $value . ')===null||$tmp===\'\' ? ' . $default . ' : $tmp)'; |
|
32 | + return '(($tmp = '.$value.')===null||$tmp===\'\' ? '.$default.' : $tmp)'; |
|
33 | 33 | } |
@@ -29,5 +29,5 @@ |
||
29 | 29 | */ |
30 | 30 | function PluginAssignCompile(Compiler $compiler, $value, $var) |
31 | 31 | { |
32 | - return '$this->assignInScope(' . $value . ', ' . $var . ')'; |
|
32 | + return '$this->assignInScope(' . $value . ', ' . $var . ')'; |
|
33 | 33 | } |
@@ -29,5 +29,5 @@ |
||
29 | 29 | */ |
30 | 30 | function PluginAssignCompile(Compiler $compiler, $value, $var) |
31 | 31 | { |
32 | - return '$this->assignInScope(' . $value . ', ' . $var . ')'; |
|
32 | + return '$this->assignInScope('.$value.', '.$var.')'; |
|
33 | 33 | } |
@@ -28,5 +28,5 @@ |
||
28 | 28 | */ |
29 | 29 | function PluginUpperCompile(Compiler $compiler, $value) |
30 | 30 | { |
31 | - return 'mb_strtoupper((string) ' . $value . ', $this->charset)'; |
|
31 | + return 'mb_strtoupper((string) ' . $value . ', $this->charset)'; |
|
32 | 32 | } |
@@ -28,5 +28,5 @@ |
||
28 | 28 | */ |
29 | 29 | function PluginUpperCompile(Compiler $compiler, $value) |
30 | 30 | { |
31 | - return 'mb_strtoupper((string) ' . $value . ', $this->charset)'; |
|
31 | + return 'mb_strtoupper((string) '.$value.', $this->charset)'; |
|
32 | 32 | } |
@@ -28,5 +28,5 @@ |
||
28 | 28 | */ |
29 | 29 | function PluginSafeCompile(Compiler $compiler, $var) |
30 | 30 | { |
31 | - return preg_replace('#\(is_string\(\$tmp=(.+)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#', '$1', $var); |
|
31 | + return preg_replace('#\(is_string\(\$tmp=(.+)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#', '$1', $var); |
|
32 | 32 | } |
@@ -28,5 +28,5 @@ |
||
28 | 28 | */ |
29 | 29 | function PluginOptionalCompile(Compiler $compiler, $value) |
30 | 30 | { |
31 | - return $value; |
|
31 | + return $value; |
|
32 | 32 | } |
@@ -34,61 +34,61 @@ |
||
34 | 34 | */ |
35 | 35 | class PluginCounter extends Plugin |
36 | 36 | { |
37 | - protected $counters = array(); |
|
37 | + protected $counters = array(); |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $name |
|
41 | - * @param null $start |
|
42 | - * @param null $skip |
|
43 | - * @param null $direction |
|
44 | - * @param null $print |
|
45 | - * @param null $assign |
|
46 | - * |
|
47 | - * @return mixed |
|
48 | - */ |
|
49 | - public function process($name = 'default', $start = null, $skip = null, $direction = null, $print = null, $assign = null) |
|
50 | - { |
|
51 | - // init counter |
|
52 | - if (!isset($this->counters[$name])) { |
|
53 | - $this->counters[$name] = array( |
|
54 | - 'count' => $start === null ? 1 : (int)$start, |
|
55 | - 'skip' => $skip === null ? 1 : (int)$skip, |
|
56 | - 'print' => $print === null ? true : (bool)$print, |
|
57 | - 'assign' => $assign === null ? null : (string)$assign, |
|
58 | - 'direction' => strtolower($direction) === 'down' ? - 1 : 1, |
|
59 | - ); |
|
60 | - } // increment |
|
61 | - else { |
|
62 | - // override setting if present |
|
63 | - if ($skip !== null) { |
|
64 | - $this->counters[$name]['skip'] = (int)$skip; |
|
65 | - } |
|
39 | + /** |
|
40 | + * @param string $name |
|
41 | + * @param null $start |
|
42 | + * @param null $skip |
|
43 | + * @param null $direction |
|
44 | + * @param null $print |
|
45 | + * @param null $assign |
|
46 | + * |
|
47 | + * @return mixed |
|
48 | + */ |
|
49 | + public function process($name = 'default', $start = null, $skip = null, $direction = null, $print = null, $assign = null) |
|
50 | + { |
|
51 | + // init counter |
|
52 | + if (!isset($this->counters[$name])) { |
|
53 | + $this->counters[$name] = array( |
|
54 | + 'count' => $start === null ? 1 : (int)$start, |
|
55 | + 'skip' => $skip === null ? 1 : (int)$skip, |
|
56 | + 'print' => $print === null ? true : (bool)$print, |
|
57 | + 'assign' => $assign === null ? null : (string)$assign, |
|
58 | + 'direction' => strtolower($direction) === 'down' ? - 1 : 1, |
|
59 | + ); |
|
60 | + } // increment |
|
61 | + else { |
|
62 | + // override setting if present |
|
63 | + if ($skip !== null) { |
|
64 | + $this->counters[$name]['skip'] = (int)$skip; |
|
65 | + } |
|
66 | 66 | |
67 | - if ($direction !== null) { |
|
68 | - $this->counters[$name]['direction'] = strtolower($direction) === 'down' ? - 1 : 1; |
|
69 | - } |
|
67 | + if ($direction !== null) { |
|
68 | + $this->counters[$name]['direction'] = strtolower($direction) === 'down' ? - 1 : 1; |
|
69 | + } |
|
70 | 70 | |
71 | - if ($print !== null) { |
|
72 | - $this->counters[$name]['print'] = (bool)$print; |
|
73 | - } |
|
71 | + if ($print !== null) { |
|
72 | + $this->counters[$name]['print'] = (bool)$print; |
|
73 | + } |
|
74 | 74 | |
75 | - if ($assign !== null) { |
|
76 | - $this->counters[$name]['assign'] = (string)$assign; |
|
77 | - } |
|
75 | + if ($assign !== null) { |
|
76 | + $this->counters[$name]['assign'] = (string)$assign; |
|
77 | + } |
|
78 | 78 | |
79 | - if ($start !== null) { |
|
80 | - $this->counters[$name]['count'] = (int)$start; |
|
81 | - } else { |
|
82 | - $this->counters[$name]['count'] += ($this->counters[$name]['skip'] * $this->counters[$name]['direction']); |
|
83 | - } |
|
84 | - } |
|
79 | + if ($start !== null) { |
|
80 | + $this->counters[$name]['count'] = (int)$start; |
|
81 | + } else { |
|
82 | + $this->counters[$name]['count'] += ($this->counters[$name]['skip'] * $this->counters[$name]['direction']); |
|
83 | + } |
|
84 | + } |
|
85 | 85 | |
86 | - $out = $this->counters[$name]['count']; |
|
86 | + $out = $this->counters[$name]['count']; |
|
87 | 87 | |
88 | - if ($this->counters[$name]['assign'] !== null) { |
|
89 | - $this->core->assignInScope($out, $this->counters[$name]['assign']); |
|
90 | - } elseif ($this->counters[$name]['print'] === true) { |
|
91 | - return $out; |
|
92 | - } |
|
93 | - } |
|
88 | + if ($this->counters[$name]['assign'] !== null) { |
|
89 | + $this->core->assignInScope($out, $this->counters[$name]['assign']); |
|
90 | + } elseif ($this->counters[$name]['print'] === true) { |
|
91 | + return $out; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | } |
@@ -51,35 +51,35 @@ |
||
51 | 51 | // init counter |
52 | 52 | if (!isset($this->counters[$name])) { |
53 | 53 | $this->counters[$name] = array( |
54 | - 'count' => $start === null ? 1 : (int)$start, |
|
55 | - 'skip' => $skip === null ? 1 : (int)$skip, |
|
56 | - 'print' => $print === null ? true : (bool)$print, |
|
57 | - 'assign' => $assign === null ? null : (string)$assign, |
|
58 | - 'direction' => strtolower($direction) === 'down' ? - 1 : 1, |
|
54 | + 'count' => $start === null ? 1 : (int) $start, |
|
55 | + 'skip' => $skip === null ? 1 : (int) $skip, |
|
56 | + 'print' => $print === null ? true : (bool) $print, |
|
57 | + 'assign' => $assign === null ? null : (string) $assign, |
|
58 | + 'direction' => strtolower($direction) === 'down' ? -1 : 1, |
|
59 | 59 | ); |
60 | 60 | } // increment |
61 | 61 | else { |
62 | 62 | // override setting if present |
63 | 63 | if ($skip !== null) { |
64 | - $this->counters[$name]['skip'] = (int)$skip; |
|
64 | + $this->counters[$name]['skip'] = (int) $skip; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | if ($direction !== null) { |
68 | - $this->counters[$name]['direction'] = strtolower($direction) === 'down' ? - 1 : 1; |
|
68 | + $this->counters[$name]['direction'] = strtolower($direction) === 'down' ? -1 : 1; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | if ($print !== null) { |
72 | - $this->counters[$name]['print'] = (bool)$print; |
|
72 | + $this->counters[$name]['print'] = (bool) $print; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | if ($assign !== null) { |
76 | - $this->counters[$name]['assign'] = (string)$assign; |
|
76 | + $this->counters[$name]['assign'] = (string) $assign; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | if ($start !== null) { |
80 | - $this->counters[$name]['count'] = (int)$start; |
|
80 | + $this->counters[$name]['count'] = (int) $start; |
|
81 | 81 | } else { |
82 | - $this->counters[$name]['count'] += ($this->counters[$name]['skip'] * $this->counters[$name]['direction']); |
|
82 | + $this->counters[$name]['count'] += ($this->counters[$name]['skip']*$this->counters[$name]['direction']); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 |
@@ -30,22 +30,22 @@ |
||
30 | 30 | */ |
31 | 31 | function PluginRegexReplace(Core $dwoo, $value, $search, $replace) |
32 | 32 | { |
33 | - $search = (array)$search; |
|
34 | - $cnt = count($search); |
|
33 | + $search = (array)$search; |
|
34 | + $cnt = count($search); |
|
35 | 35 | |
36 | - for ($i = 0; $i < $cnt; ++ $i) { |
|
37 | - // Credits for this to Monte Ohrt who made smarty's regex_replace modifier |
|
38 | - if (($pos = strpos($search[$i], "\0")) !== false) { |
|
39 | - $search[$i] = substr($search[$i], 0, $pos); |
|
40 | - } |
|
36 | + for ($i = 0; $i < $cnt; ++ $i) { |
|
37 | + // Credits for this to Monte Ohrt who made smarty's regex_replace modifier |
|
38 | + if (($pos = strpos($search[$i], "\0")) !== false) { |
|
39 | + $search[$i] = substr($search[$i], 0, $pos); |
|
40 | + } |
|
41 | 41 | |
42 | - if (preg_match('#[a-z\s]+$#is', $search[$i], $m) && (strpos($m[0], 'e') !== false)) { |
|
43 | - $search[$i] = substr($search[$i], 0, - strlen($m[0])) . str_replace(array( |
|
44 | - 'e', |
|
45 | - ' ' |
|
46 | - ), '', $m[0]); |
|
47 | - } |
|
48 | - } |
|
42 | + if (preg_match('#[a-z\s]+$#is', $search[$i], $m) && (strpos($m[0], 'e') !== false)) { |
|
43 | + $search[$i] = substr($search[$i], 0, - strlen($m[0])) . str_replace(array( |
|
44 | + 'e', |
|
45 | + ' ' |
|
46 | + ), '', $m[0]); |
|
47 | + } |
|
48 | + } |
|
49 | 49 | |
50 | - return preg_replace($search, $replace, $value); |
|
50 | + return preg_replace($search, $replace, $value); |
|
51 | 51 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | function PluginRegexReplace(Core $dwoo, $value, $search, $replace) |
32 | 32 | { |
33 | - $search = (array)$search; |
|
33 | + $search = (array) $search; |
|
34 | 34 | $cnt = count($search); |
35 | 35 | |
36 | 36 | for ($i = 0; $i < $cnt; ++ $i) { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | if (preg_match('#[a-z\s]+$#is', $search[$i], $m) && (strpos($m[0], 'e') !== false)) { |
43 | - $search[$i] = substr($search[$i], 0, - strlen($m[0])) . str_replace(array( |
|
43 | + $search[$i] = substr($search[$i], 0, - strlen($m[0])).str_replace(array( |
|
44 | 44 | 'e', |
45 | 45 | ' ' |
46 | 46 | ), '', $m[0]); |
@@ -30,52 +30,52 @@ |
||
30 | 30 | */ |
31 | 31 | function PluginDateFormat(Core $dwoo, $value, $format = '%b %e, %Y', $default = null) |
32 | 32 | { |
33 | - if (!empty($value)) { |
|
34 | - // convert if it's not a valid unix timestamp |
|
35 | - if (preg_match('#^-?\d{1,10}$#', $value) === 0) { |
|
36 | - $value = strtotime($value); |
|
37 | - } |
|
38 | - } elseif (!empty($default)) { |
|
39 | - // convert if it's not a valid unix timestamp |
|
40 | - if (preg_match('#^-?\d{1,10}$#', $default) === 0) { |
|
41 | - $value = strtotime($default); |
|
42 | - } else { |
|
43 | - $value = $default; |
|
44 | - } |
|
45 | - } else { |
|
46 | - return ''; |
|
47 | - } |
|
33 | + if (!empty($value)) { |
|
34 | + // convert if it's not a valid unix timestamp |
|
35 | + if (preg_match('#^-?\d{1,10}$#', $value) === 0) { |
|
36 | + $value = strtotime($value); |
|
37 | + } |
|
38 | + } elseif (!empty($default)) { |
|
39 | + // convert if it's not a valid unix timestamp |
|
40 | + if (preg_match('#^-?\d{1,10}$#', $default) === 0) { |
|
41 | + $value = strtotime($default); |
|
42 | + } else { |
|
43 | + $value = $default; |
|
44 | + } |
|
45 | + } else { |
|
46 | + return ''; |
|
47 | + } |
|
48 | 48 | |
49 | - // Credits for that windows compat block to Monte Ohrt who made smarty's date_format plugin |
|
50 | - if (DIRECTORY_SEPARATOR == '\\') { |
|
51 | - $_win_from = array( |
|
52 | - '%D', |
|
53 | - '%h', |
|
54 | - '%n', |
|
55 | - '%r', |
|
56 | - '%R', |
|
57 | - '%t', |
|
58 | - '%T' |
|
59 | - ); |
|
60 | - $_win_to = array( |
|
61 | - '%m/%d/%y', |
|
62 | - '%b', |
|
63 | - "\n", |
|
64 | - '%I:%M:%S %p', |
|
65 | - '%H:%M', |
|
66 | - "\t", |
|
67 | - '%H:%M:%S' |
|
68 | - ); |
|
69 | - if (strpos($format, '%e') !== false) { |
|
70 | - $_win_from[] = '%e'; |
|
71 | - $_win_to[] = sprintf('%\' 2d', date('j', $value)); |
|
72 | - } |
|
73 | - if (strpos($format, '%l') !== false) { |
|
74 | - $_win_from[] = '%l'; |
|
75 | - $_win_to[] = sprintf('%\' 2d', date('h', $value)); |
|
76 | - } |
|
77 | - $format = str_replace($_win_from, $_win_to, $format); |
|
78 | - } |
|
49 | + // Credits for that windows compat block to Monte Ohrt who made smarty's date_format plugin |
|
50 | + if (DIRECTORY_SEPARATOR == '\\') { |
|
51 | + $_win_from = array( |
|
52 | + '%D', |
|
53 | + '%h', |
|
54 | + '%n', |
|
55 | + '%r', |
|
56 | + '%R', |
|
57 | + '%t', |
|
58 | + '%T' |
|
59 | + ); |
|
60 | + $_win_to = array( |
|
61 | + '%m/%d/%y', |
|
62 | + '%b', |
|
63 | + "\n", |
|
64 | + '%I:%M:%S %p', |
|
65 | + '%H:%M', |
|
66 | + "\t", |
|
67 | + '%H:%M:%S' |
|
68 | + ); |
|
69 | + if (strpos($format, '%e') !== false) { |
|
70 | + $_win_from[] = '%e'; |
|
71 | + $_win_to[] = sprintf('%\' 2d', date('j', $value)); |
|
72 | + } |
|
73 | + if (strpos($format, '%l') !== false) { |
|
74 | + $_win_from[] = '%l'; |
|
75 | + $_win_to[] = sprintf('%\' 2d', date('h', $value)); |
|
76 | + } |
|
77 | + $format = str_replace($_win_from, $_win_to, $format); |
|
78 | + } |
|
79 | 79 | |
80 | - return strftime($format, $value); |
|
80 | + return strftime($format, $value); |
|
81 | 81 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | '%t', |
58 | 58 | '%T' |
59 | 59 | ); |
60 | - $_win_to = array( |
|
60 | + $_win_to = array( |
|
61 | 61 | '%m/%d/%y', |
62 | 62 | '%b', |
63 | 63 | "\n", |