@@ -22,19 +22,19 @@ |
||
22 | 22 | */ |
23 | 23 | function Dwoo_Plugin_capitalize(Dwoo_Core $dwoo, $value, $numwords = false) |
24 | 24 | { |
25 | - if ($numwords || preg_match('#^[^0-9]+$#', $value)) { |
|
26 | - return mb_convert_case((string) $value, MB_CASE_TITLE, $dwoo->getCharset()); |
|
27 | - } else { |
|
28 | - $bits = explode(' ', (string) $value); |
|
29 | - $out = ''; |
|
30 | - while (list(, $v) = each($bits)) { |
|
31 | - if (preg_match('#^[^0-9]+$#', $v)) { |
|
32 | - $out .= ' '.mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset()); |
|
33 | - } else { |
|
34 | - $out .= ' '.$v; |
|
35 | - } |
|
36 | - } |
|
25 | + if ($numwords || preg_match('#^[^0-9]+$#', $value)) { |
|
26 | + return mb_convert_case((string) $value, MB_CASE_TITLE, $dwoo->getCharset()); |
|
27 | + } else { |
|
28 | + $bits = explode(' ', (string) $value); |
|
29 | + $out = ''; |
|
30 | + while (list(, $v) = each($bits)) { |
|
31 | + if (preg_match('#^[^0-9]+$#', $v)) { |
|
32 | + $out .= ' '.mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset()); |
|
33 | + } else { |
|
34 | + $out .= ' '.$v; |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | - return substr($out, 1); |
|
39 | - } |
|
38 | + return substr($out, 1); |
|
39 | + } |
|
40 | 40 | } |
@@ -21,5 +21,5 @@ |
||
21 | 21 | */ |
22 | 22 | function Dwoo_Plugin_count_sentences_compile(Dwoo_Compiler $compiler, $value) |
23 | 23 | { |
24 | - return "preg_match_all('#[\w\pL]\.(?![\w\pL])#u', $value, \$tmp)"; |
|
24 | + return "preg_match_all('#[\w\pL]\.(?![\w\pL])#u', $value, \$tmp)"; |
|
25 | 25 | } |
@@ -21,5 +21,5 @@ |
||
21 | 21 | */ |
22 | 22 | function Dwoo_Plugin_safe_compile(Dwoo_Compiler $compiler, $var) |
23 | 23 | { |
24 | - return preg_replace('#\(is_string\(\$tmp=(.+)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#', '$1', $var); |
|
24 | + return preg_replace('#\(is_string\(\$tmp=(.+)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#', '$1', $var); |
|
25 | 25 | } |
@@ -22,17 +22,17 @@ |
||
22 | 22 | */ |
23 | 23 | function Dwoo_Plugin_reverse(Dwoo_Core $dwoo, $value, $preserve_keys = false) |
24 | 24 | { |
25 | - if (is_array($value)) { |
|
26 | - return array_reverse($value, $preserve_keys); |
|
27 | - } elseif (($charset = $dwoo->getCharset()) === 'iso-8859-1') { |
|
28 | - return strrev((string) $value); |
|
29 | - } else { |
|
30 | - $strlen = mb_strlen($value); |
|
31 | - $out = ''; |
|
32 | - while ($strlen--) { |
|
33 | - $out .= mb_substr($value, $strlen, 1, $charset); |
|
34 | - } |
|
25 | + if (is_array($value)) { |
|
26 | + return array_reverse($value, $preserve_keys); |
|
27 | + } elseif (($charset = $dwoo->getCharset()) === 'iso-8859-1') { |
|
28 | + return strrev((string) $value); |
|
29 | + } else { |
|
30 | + $strlen = mb_strlen($value); |
|
31 | + $out = ''; |
|
32 | + while ($strlen--) { |
|
33 | + $out .= mb_substr($value, $strlen, 1, $charset); |
|
34 | + } |
|
35 | 35 | |
36 | - return $out; |
|
37 | - } |
|
36 | + return $out; |
|
37 | + } |
|
38 | 38 | } |
@@ -29,17 +29,17 @@ |
||
29 | 29 | */ |
30 | 30 | function Dwoo_Plugin_eval(Dwoo_Core $dwoo, $var, $assign = null) |
31 | 31 | { |
32 | - if ($var == '') { |
|
33 | - return ''; |
|
34 | - } |
|
32 | + if ($var == '') { |
|
33 | + return ''; |
|
34 | + } |
|
35 | 35 | |
36 | - $tpl = new Dwoo_Template_String($var); |
|
37 | - $clone = clone $dwoo; |
|
38 | - $out = $clone->get($tpl, $dwoo->readVar('_parent')); |
|
36 | + $tpl = new Dwoo_Template_String($var); |
|
37 | + $clone = clone $dwoo; |
|
38 | + $out = $clone->get($tpl, $dwoo->readVar('_parent')); |
|
39 | 39 | |
40 | - if ($assign !== null) { |
|
41 | - $dwoo->assignInScope($out, $assign); |
|
42 | - } else { |
|
43 | - return $out; |
|
44 | - } |
|
40 | + if ($assign !== null) { |
|
41 | + $dwoo->assignInScope($out, $assign); |
|
42 | + } else { |
|
43 | + return $out; |
|
44 | + } |
|
45 | 45 | } |
@@ -27,10 +27,10 @@ |
||
27 | 27 | */ |
28 | 28 | function Dwoo_Plugin_return_compile(Dwoo_Compiler $compiler, array $rest = array()) |
29 | 29 | { |
30 | - $out = array(); |
|
31 | - foreach ($rest as $var => $val) { |
|
32 | - $out[] = '$this->setReturnValue('.var_export($var, true).', '.$val.')'; |
|
33 | - } |
|
30 | + $out = array(); |
|
31 | + foreach ($rest as $var => $val) { |
|
32 | + $out[] = '$this->setReturnValue('.var_export($var, true).', '.$val.')'; |
|
33 | + } |
|
34 | 34 | |
35 | - return '('.implode('.', $out).')'; |
|
35 | + return '('.implode('.', $out).')'; |
|
36 | 36 | } |
@@ -21,5 +21,5 @@ |
||
21 | 21 | */ |
22 | 22 | function Dwoo_Plugin_count_paragraphs_compile(Dwoo_Compiler $compiler, $value) |
23 | 23 | { |
24 | - return '(preg_match_all(\'#[\r\n]+#\', '.$value.', $tmp)+1)'; |
|
24 | + return '(preg_match_all(\'#[\r\n]+#\', '.$value.', $tmp)+1)'; |
|
25 | 25 | } |
@@ -21,5 +21,5 @@ |
||
21 | 21 | */ |
22 | 22 | function Dwoo_Plugin_isset_compile(Dwoo_Compiler $compiler, $var) |
23 | 23 | { |
24 | - return '('.$var.' !== null)'; |
|
24 | + return '('.$var.' !== null)'; |
|
25 | 25 | } |
@@ -23,44 +23,44 @@ |
||
23 | 23 | */ |
24 | 24 | function Dwoo_Plugin_escape(Dwoo_Core $dwoo, $value = '', $format = 'html', $charset = null) |
25 | 25 | { |
26 | - if ($charset === null) { |
|
27 | - $charset = $dwoo->getCharset(); |
|
28 | - } |
|
26 | + if ($charset === null) { |
|
27 | + $charset = $dwoo->getCharset(); |
|
28 | + } |
|
29 | 29 | |
30 | - switch ($format) { |
|
30 | + switch ($format) { |
|
31 | 31 | |
32 | - case 'html': |
|
33 | - return htmlspecialchars((string) $value, ENT_QUOTES, $charset); |
|
34 | - case 'htmlall': |
|
35 | - return htmlentities((string) $value, ENT_QUOTES, $charset); |
|
36 | - case 'url': |
|
37 | - return rawurlencode((string) $value); |
|
38 | - case 'urlpathinfo': |
|
39 | - return str_replace('%2F', '/', rawurlencode((string) $value)); |
|
40 | - case 'quotes': |
|
41 | - return preg_replace("#(?<!\\\\)'#", "\\'", (string) $value); |
|
42 | - case 'hex': |
|
43 | - $out = ''; |
|
44 | - $cnt = strlen((string) $value); |
|
45 | - for ($i = 0; $i < $cnt; ++$i) { |
|
46 | - $out .= '%'.bin2hex((string) $value[$i]); |
|
47 | - } |
|
32 | + case 'html': |
|
33 | + return htmlspecialchars((string) $value, ENT_QUOTES, $charset); |
|
34 | + case 'htmlall': |
|
35 | + return htmlentities((string) $value, ENT_QUOTES, $charset); |
|
36 | + case 'url': |
|
37 | + return rawurlencode((string) $value); |
|
38 | + case 'urlpathinfo': |
|
39 | + return str_replace('%2F', '/', rawurlencode((string) $value)); |
|
40 | + case 'quotes': |
|
41 | + return preg_replace("#(?<!\\\\)'#", "\\'", (string) $value); |
|
42 | + case 'hex': |
|
43 | + $out = ''; |
|
44 | + $cnt = strlen((string) $value); |
|
45 | + for ($i = 0; $i < $cnt; ++$i) { |
|
46 | + $out .= '%'.bin2hex((string) $value[$i]); |
|
47 | + } |
|
48 | 48 | |
49 | - return $out; |
|
50 | - case 'hexentity': |
|
51 | - $out = ''; |
|
52 | - $cnt = strlen((string) $value); |
|
53 | - for ($i = 0; $i < $cnt; ++$i) { |
|
54 | - $out .= '&#x'.bin2hex((string) $value[$i]).';'; |
|
55 | - } |
|
49 | + return $out; |
|
50 | + case 'hexentity': |
|
51 | + $out = ''; |
|
52 | + $cnt = strlen((string) $value); |
|
53 | + for ($i = 0; $i < $cnt; ++$i) { |
|
54 | + $out .= '&#x'.bin2hex((string) $value[$i]).';'; |
|
55 | + } |
|
56 | 56 | |
57 | - return $out; |
|
58 | - case 'javascript': |
|
59 | - return strtr((string) $value, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\/')); |
|
60 | - case 'mail': |
|
61 | - return str_replace(array('@', '.'), array(' (AT) ', ' (DOT) '), (string) $value); |
|
62 | - default: |
|
63 | - $dwoo->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript or mail, "'.$format.'" given.', E_USER_WARNING); |
|
57 | + return $out; |
|
58 | + case 'javascript': |
|
59 | + return strtr((string) $value, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\/')); |
|
60 | + case 'mail': |
|
61 | + return str_replace(array('@', '.'), array(' (AT) ', ' (DOT) '), (string) $value); |
|
62 | + default: |
|
63 | + $dwoo->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript or mail, "'.$format.'" given.', E_USER_WARNING); |
|
64 | 64 | |
65 | - } |
|
65 | + } |
|
66 | 66 | } |