@@ -29,26 +29,26 @@ |
||
29 | 29 | */ |
30 | 30 | class PluginReverse extends Plugin |
31 | 31 | { |
32 | - /** |
|
33 | - * @param string $value |
|
34 | - * @param bool $preserve_keys |
|
35 | - * |
|
36 | - * @return array|string |
|
37 | - */ |
|
38 | - public function process($value, $preserve_keys = false) |
|
39 | - { |
|
40 | - if (is_array($value)) { |
|
41 | - return array_reverse($value, $preserve_keys); |
|
42 | - } elseif (($charset = $this->core->getCharset()) === 'iso-8859-1') { |
|
43 | - return strrev((string)$value); |
|
44 | - } |
|
32 | + /** |
|
33 | + * @param string $value |
|
34 | + * @param bool $preserve_keys |
|
35 | + * |
|
36 | + * @return array|string |
|
37 | + */ |
|
38 | + public function process($value, $preserve_keys = false) |
|
39 | + { |
|
40 | + if (is_array($value)) { |
|
41 | + return array_reverse($value, $preserve_keys); |
|
42 | + } elseif (($charset = $this->core->getCharset()) === 'iso-8859-1') { |
|
43 | + return strrev((string)$value); |
|
44 | + } |
|
45 | 45 | |
46 | - $strlen = mb_strlen($value); |
|
47 | - $out = ''; |
|
48 | - while ($strlen --) { |
|
49 | - $out .= mb_substr($value, $strlen, 1, $charset); |
|
50 | - } |
|
46 | + $strlen = mb_strlen($value); |
|
47 | + $out = ''; |
|
48 | + while ($strlen --) { |
|
49 | + $out .= mb_substr($value, $strlen, 1, $charset); |
|
50 | + } |
|
51 | 51 | |
52 | - return $out; |
|
53 | - } |
|
52 | + return $out; |
|
53 | + } |
|
54 | 54 | } |
55 | 55 | \ No newline at end of file |
@@ -31,15 +31,15 @@ |
||
31 | 31 | */ |
32 | 32 | class PluginSpacify extends Plugin implements ICompilable |
33 | 33 | { |
34 | - /** |
|
35 | - * @param Compiler $compiler |
|
36 | - * @param string $value |
|
37 | - * @param string $space_char |
|
38 | - * |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public static function compile(Compiler $compiler, $value, $space_char = ' ') |
|
42 | - { |
|
43 | - return 'implode(' . $space_char . ', str_split(' . $value . ', 1))'; |
|
44 | - } |
|
34 | + /** |
|
35 | + * @param Compiler $compiler |
|
36 | + * @param string $value |
|
37 | + * @param string $space_char |
|
38 | + * |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public static function compile(Compiler $compiler, $value, $space_char = ' ') |
|
42 | + { |
|
43 | + return 'implode(' . $space_char . ', str_split(' . $value . ', 1))'; |
|
44 | + } |
|
45 | 45 | } |
46 | 46 | \ No newline at end of file |
@@ -30,14 +30,14 @@ |
||
30 | 30 | */ |
31 | 31 | class PluginUpper extends Plugin implements ICompilable |
32 | 32 | { |
33 | - /** |
|
34 | - * @param Compiler $compiler |
|
35 | - * @param string $value |
|
36 | - * |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public static function compile(Compiler $compiler, $value) |
|
40 | - { |
|
41 | - return 'mb_strtoupper((string) ' . $value . ', $this->charset)'; |
|
42 | - } |
|
33 | + /** |
|
34 | + * @param Compiler $compiler |
|
35 | + * @param string $value |
|
36 | + * |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public static function compile(Compiler $compiler, $value) |
|
40 | + { |
|
41 | + return 'mb_strtoupper((string) ' . $value . ', $this->charset)'; |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -30,14 +30,14 @@ |
||
30 | 30 | */ |
31 | 31 | class PluginOptional extends Plugin implements ICompilable |
32 | 32 | { |
33 | - /** |
|
34 | - * @param Compiler $compiler |
|
35 | - * @param string $value |
|
36 | - * |
|
37 | - * @return mixed |
|
38 | - */ |
|
39 | - public static function compile(Compiler $compiler, $value) |
|
40 | - { |
|
41 | - return $value; |
|
42 | - } |
|
33 | + /** |
|
34 | + * @param Compiler $compiler |
|
35 | + * @param string $value |
|
36 | + * |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | + public static function compile(Compiler $compiler, $value) |
|
40 | + { |
|
41 | + return $value; |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -32,15 +32,15 @@ |
||
32 | 32 | class PluginAssign extends Plugin implements ICompilable |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * @param Compiler $compiler |
|
37 | - * @param mixed $value |
|
38 | - * @param mixed $var |
|
39 | - * |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public static function compile(Compiler $compiler, $value, $var) |
|
43 | - { |
|
44 | - return '$this->assignInScope(' . $value . ', ' . $var . ')'; |
|
45 | - } |
|
35 | + /** |
|
36 | + * @param Compiler $compiler |
|
37 | + * @param mixed $value |
|
38 | + * @param mixed $var |
|
39 | + * |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public static function compile(Compiler $compiler, $value, $var) |
|
43 | + { |
|
44 | + return '$this->assignInScope(' . $value . ', ' . $var . ')'; |
|
45 | + } |
|
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -30,14 +30,14 @@ |
||
30 | 30 | */ |
31 | 31 | class PluginLower extends Plugin implements ICompilable |
32 | 32 | { |
33 | - /** |
|
34 | - * @param Compiler $compiler |
|
35 | - * @param string $value |
|
36 | - * |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public static function compile(Compiler $compiler, $value) |
|
40 | - { |
|
41 | - return 'mb_strtolower((string) ' . $value . ', $this->charset)'; |
|
42 | - } |
|
33 | + /** |
|
34 | + * @param Compiler $compiler |
|
35 | + * @param string $value |
|
36 | + * |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public static function compile(Compiler $compiler, $value) |
|
40 | + { |
|
41 | + return 'mb_strtolower((string) ' . $value . ', $this->charset)'; |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -30,53 +30,53 @@ |
||
30 | 30 | */ |
31 | 31 | class PluginFetch extends Plugin |
32 | 32 | { |
33 | - /** |
|
34 | - * @param string $file |
|
35 | - * @param null $assign |
|
36 | - * |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public function process($file, $assign = null) |
|
40 | - { |
|
41 | - if ($file === '') { |
|
42 | - return ''; |
|
43 | - } |
|
33 | + /** |
|
34 | + * @param string $file |
|
35 | + * @param null $assign |
|
36 | + * |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public function process($file, $assign = null) |
|
40 | + { |
|
41 | + if ($file === '') { |
|
42 | + return ''; |
|
43 | + } |
|
44 | 44 | |
45 | - if ($policy = $this->core->getSecurityPolicy()) { |
|
46 | - while (true) { |
|
47 | - if (preg_match('{^([a-z]+?)://}i', $file)) { |
|
48 | - $this->core->triggerError('The security policy prevents you to read files from external sources.', |
|
49 | - E_USER_WARNING); |
|
50 | - } |
|
45 | + if ($policy = $this->core->getSecurityPolicy()) { |
|
46 | + while (true) { |
|
47 | + if (preg_match('{^([a-z]+?)://}i', $file)) { |
|
48 | + $this->core->triggerError('The security policy prevents you to read files from external sources.', |
|
49 | + E_USER_WARNING); |
|
50 | + } |
|
51 | 51 | |
52 | - $file = realpath($file); |
|
53 | - $dirs = $policy->getAllowedDirectories(); |
|
54 | - foreach ($dirs as $dir => $dummy) { |
|
55 | - if (strpos($file, $dir) === 0) { |
|
56 | - break 2; |
|
57 | - } |
|
58 | - } |
|
59 | - $this->core->triggerError('The security policy prevents you to read <em>' . $file . '</em>', |
|
60 | - E_USER_WARNING); |
|
61 | - } |
|
62 | - } |
|
63 | - $file = str_replace(array( |
|
64 | - "\t", |
|
65 | - "\n", |
|
66 | - "\r" |
|
67 | - ), |
|
68 | - array( |
|
69 | - '\\t', |
|
70 | - '\\n', |
|
71 | - '\\r' |
|
72 | - ), |
|
73 | - $file); |
|
52 | + $file = realpath($file); |
|
53 | + $dirs = $policy->getAllowedDirectories(); |
|
54 | + foreach ($dirs as $dir => $dummy) { |
|
55 | + if (strpos($file, $dir) === 0) { |
|
56 | + break 2; |
|
57 | + } |
|
58 | + } |
|
59 | + $this->core->triggerError('The security policy prevents you to read <em>' . $file . '</em>', |
|
60 | + E_USER_WARNING); |
|
61 | + } |
|
62 | + } |
|
63 | + $file = str_replace(array( |
|
64 | + "\t", |
|
65 | + "\n", |
|
66 | + "\r" |
|
67 | + ), |
|
68 | + array( |
|
69 | + '\\t', |
|
70 | + '\\n', |
|
71 | + '\\r' |
|
72 | + ), |
|
73 | + $file); |
|
74 | 74 | |
75 | - $out = file_get_contents($file); |
|
75 | + $out = file_get_contents($file); |
|
76 | 76 | |
77 | - if ($assign === null) { |
|
78 | - return $out; |
|
79 | - } |
|
80 | - $this->core->assignInScope($out, $assign); |
|
81 | - } |
|
77 | + if ($assign === null) { |
|
78 | + return $out; |
|
79 | + } |
|
80 | + $this->core->assignInScope($out, $assign); |
|
81 | + } |
|
82 | 82 | } |
83 | 83 | \ No newline at end of file |
@@ -33,17 +33,17 @@ |
||
33 | 33 | */ |
34 | 34 | class PluginWordwrap extends Plugin implements ICompilable |
35 | 35 | { |
36 | - /** |
|
37 | - * @param Compiler $compiler |
|
38 | - * @param string $value |
|
39 | - * @param int $length |
|
40 | - * @param string $break |
|
41 | - * @param bool $cut |
|
42 | - * |
|
43 | - * @return string |
|
44 | - */ |
|
45 | - public static function compile(Compiler $compiler, $value, $length = 80, $break = "\n", $cut = false) |
|
46 | - { |
|
47 | - return 'wordwrap(' . $value . ',' . $length . ',' . $break . ',' . $cut . ')'; |
|
48 | - } |
|
36 | + /** |
|
37 | + * @param Compiler $compiler |
|
38 | + * @param string $value |
|
39 | + * @param int $length |
|
40 | + * @param string $break |
|
41 | + * @param bool $cut |
|
42 | + * |
|
43 | + * @return string |
|
44 | + */ |
|
45 | + public static function compile(Compiler $compiler, $value, $length = 80, $break = "\n", $cut = false) |
|
46 | + { |
|
47 | + return 'wordwrap(' . $value . ',' . $length . ',' . $break . ',' . $cut . ')'; |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -32,21 +32,21 @@ |
||
32 | 32 | */ |
33 | 33 | class PluginReplace extends Plugin implements ICompilable |
34 | 34 | { |
35 | - /** |
|
36 | - * @param Compiler $compiler |
|
37 | - * @param string $value |
|
38 | - * @param string $search |
|
39 | - * @param string $replace |
|
40 | - * @param bool $case_sensitive |
|
41 | - * |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public static function compile(Compiler $compiler, $value, $search, $replace, $case_sensitive = true) |
|
45 | - { |
|
46 | - if ($case_sensitive == 'false' || (bool)$case_sensitive === false) { |
|
47 | - return 'str_ireplace(' . $search . ', ' . $replace . ', ' . $value . ')'; |
|
48 | - } else { |
|
49 | - return 'str_replace(' . $search . ', ' . $replace . ', ' . $value . ')'; |
|
50 | - } |
|
51 | - } |
|
35 | + /** |
|
36 | + * @param Compiler $compiler |
|
37 | + * @param string $value |
|
38 | + * @param string $search |
|
39 | + * @param string $replace |
|
40 | + * @param bool $case_sensitive |
|
41 | + * |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public static function compile(Compiler $compiler, $value, $search, $replace, $case_sensitive = true) |
|
45 | + { |
|
46 | + if ($case_sensitive == 'false' || (bool)$case_sensitive === false) { |
|
47 | + return 'str_ireplace(' . $search . ', ' . $replace . ', ' . $value . ')'; |
|
48 | + } else { |
|
49 | + return 'str_replace(' . $search . ', ' . $replace . ', ' . $value . ')'; |
|
50 | + } |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | \ No newline at end of file |