@@ -36,9 +36,9 @@ |
||
36 | 36 | */ |
37 | 37 | function PluginStripTagsCompile(Compiler $compiler, $value, $addspace = true) |
38 | 38 | { |
39 | - if ($addspace === 'true') { |
|
40 | - return "preg_replace('#<[^>]*>#', ' ', $value)"; |
|
41 | - } else { |
|
42 | - return "strip_tags($value)"; |
|
43 | - } |
|
39 | + if ($addspace === 'true') { |
|
40 | + return "preg_replace('#<[^>]*>#', ' ', $value)"; |
|
41 | + } else { |
|
42 | + return "strip_tags($value)"; |
|
43 | + } |
|
44 | 44 | } |
@@ -29,17 +29,17 @@ |
||
29 | 29 | */ |
30 | 30 | function PluginReverse(Core $dwoo, $value, $preserve_keys = false) |
31 | 31 | { |
32 | - if (is_array($value)) { |
|
33 | - return array_reverse($value, $preserve_keys); |
|
34 | - } elseif (($charset = $dwoo->getCharset()) === 'iso-8859-1') { |
|
35 | - return strrev((string)$value); |
|
36 | - } else { |
|
37 | - $strlen = mb_strlen($value); |
|
38 | - $out = ''; |
|
39 | - while ($strlen --) { |
|
40 | - $out .= mb_substr($value, $strlen, 1, $charset); |
|
41 | - } |
|
32 | + if (is_array($value)) { |
|
33 | + return array_reverse($value, $preserve_keys); |
|
34 | + } elseif (($charset = $dwoo->getCharset()) === 'iso-8859-1') { |
|
35 | + return strrev((string)$value); |
|
36 | + } else { |
|
37 | + $strlen = mb_strlen($value); |
|
38 | + $out = ''; |
|
39 | + while ($strlen --) { |
|
40 | + $out .= mb_substr($value, $strlen, 1, $charset); |
|
41 | + } |
|
42 | 42 | |
43 | - return $out; |
|
44 | - } |
|
43 | + return $out; |
|
44 | + } |
|
45 | 45 | } |
@@ -32,11 +32,11 @@ |
||
32 | 32 | if (is_array($value)) { |
33 | 33 | return array_reverse($value, $preserve_keys); |
34 | 34 | } elseif (($charset = $dwoo->getCharset()) === 'iso-8859-1') { |
35 | - return strrev((string)$value); |
|
35 | + return strrev((string) $value); |
|
36 | 36 | } else { |
37 | 37 | $strlen = mb_strlen($value); |
38 | 38 | $out = ''; |
39 | - while ($strlen --) { |
|
39 | + while ($strlen--) { |
|
40 | 40 | $out .= mb_substr($value, $strlen, 1, $charset); |
41 | 41 | } |
42 | 42 |
@@ -28,5 +28,5 @@ |
||
28 | 28 | */ |
29 | 29 | function PluginCatCompile(Compiler $compiler, $value, array $rest) |
30 | 30 | { |
31 | - return '(' . $value . ').(' . implode(').(', $rest) . ')'; |
|
31 | + return '(' . $value . ').(' . implode(').(', $rest) . ')'; |
|
32 | 32 | } |
@@ -28,5 +28,5 @@ |
||
28 | 28 | */ |
29 | 29 | function PluginCatCompile(Compiler $compiler, $value, array $rest) |
30 | 30 | { |
31 | - return '(' . $value . ').(' . implode(').(', $rest) . ')'; |
|
31 | + return '('.$value.').('.implode(').(', $rest).')'; |
|
32 | 32 | } |
@@ -34,56 +34,56 @@ |
||
34 | 34 | */ |
35 | 35 | class PluginCycle extends Plugin |
36 | 36 | { |
37 | - protected $cycles = array(); |
|
37 | + protected $cycles = array(); |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $name |
|
41 | - * @param null $values |
|
42 | - * @param bool $print |
|
43 | - * @param bool $advance |
|
44 | - * @param string $delimiter |
|
45 | - * @param null $assign |
|
46 | - * @param bool $reset |
|
47 | - * |
|
48 | - * @return null |
|
49 | - */ |
|
50 | - public function process($name = 'default', $values = null, $print = true, $advance = true, $delimiter = ',', $assign = null, $reset = false) |
|
51 | - { |
|
52 | - if ($values !== null) { |
|
53 | - if (is_string($values)) { |
|
54 | - $values = explode($delimiter, $values); |
|
55 | - } |
|
39 | + /** |
|
40 | + * @param string $name |
|
41 | + * @param null $values |
|
42 | + * @param bool $print |
|
43 | + * @param bool $advance |
|
44 | + * @param string $delimiter |
|
45 | + * @param null $assign |
|
46 | + * @param bool $reset |
|
47 | + * |
|
48 | + * @return null |
|
49 | + */ |
|
50 | + public function process($name = 'default', $values = null, $print = true, $advance = true, $delimiter = ',', $assign = null, $reset = false) |
|
51 | + { |
|
52 | + if ($values !== null) { |
|
53 | + if (is_string($values)) { |
|
54 | + $values = explode($delimiter, $values); |
|
55 | + } |
|
56 | 56 | |
57 | - if (!isset($this->cycles[$name]) || $this->cycles[$name]['values'] !== $values) { |
|
58 | - $this->cycles[$name]['index'] = 0; |
|
59 | - } |
|
57 | + if (!isset($this->cycles[$name]) || $this->cycles[$name]['values'] !== $values) { |
|
58 | + $this->cycles[$name]['index'] = 0; |
|
59 | + } |
|
60 | 60 | |
61 | - $this->cycles[$name]['values'] = array_values($values); |
|
62 | - } elseif (isset($this->cycles[$name])) { |
|
63 | - $values = $this->cycles[$name]['values']; |
|
64 | - } |
|
61 | + $this->cycles[$name]['values'] = array_values($values); |
|
62 | + } elseif (isset($this->cycles[$name])) { |
|
63 | + $values = $this->cycles[$name]['values']; |
|
64 | + } |
|
65 | 65 | |
66 | - if ($reset) { |
|
67 | - $this->cycles[$name]['index'] = 0; |
|
68 | - } |
|
66 | + if ($reset) { |
|
67 | + $this->cycles[$name]['index'] = 0; |
|
68 | + } |
|
69 | 69 | |
70 | - if ($print) { |
|
71 | - $out = $values[$this->cycles[$name]['index']]; |
|
72 | - } else { |
|
73 | - $out = null; |
|
74 | - } |
|
70 | + if ($print) { |
|
71 | + $out = $values[$this->cycles[$name]['index']]; |
|
72 | + } else { |
|
73 | + $out = null; |
|
74 | + } |
|
75 | 75 | |
76 | - if ($advance) { |
|
77 | - if ($this->cycles[$name]['index'] >= count($values) - 1) { |
|
78 | - $this->cycles[$name]['index'] = 0; |
|
79 | - } else { |
|
80 | - ++ $this->cycles[$name]['index']; |
|
81 | - } |
|
82 | - } |
|
76 | + if ($advance) { |
|
77 | + if ($this->cycles[$name]['index'] >= count($values) - 1) { |
|
78 | + $this->cycles[$name]['index'] = 0; |
|
79 | + } else { |
|
80 | + ++ $this->cycles[$name]['index']; |
|
81 | + } |
|
82 | + } |
|
83 | 83 | |
84 | - if ($assign === null) { |
|
85 | - return $out; |
|
86 | - } |
|
87 | - $this->core->assignInScope($out, $assign); |
|
88 | - } |
|
84 | + if ($assign === null) { |
|
85 | + return $out; |
|
86 | + } |
|
87 | + $this->core->assignInScope($out, $assign); |
|
88 | + } |
|
89 | 89 | } |
@@ -74,10 +74,10 @@ |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | if ($advance) { |
77 | - if ($this->cycles[$name]['index'] >= count($values) - 1) { |
|
77 | + if ($this->cycles[$name]['index'] >= count($values)-1) { |
|
78 | 78 | $this->cycles[$name]['index'] = 0; |
79 | 79 | } else { |
80 | - ++ $this->cycles[$name]['index']; |
|
80 | + ++$this->cycles[$name]['index']; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 |
@@ -26,26 +26,26 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function PluginExtendsCheckCompile(Compiler $compiler, $file) |
28 | 28 | { |
29 | - preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m); |
|
30 | - $resource = $m[1]; |
|
31 | - $identifier = $m[2]; |
|
29 | + preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m); |
|
30 | + $resource = $m[1]; |
|
31 | + $identifier = $m[2]; |
|
32 | 32 | |
33 | - $tpl = $compiler->getDwoo()->templateFactory($resource, $identifier); |
|
33 | + $tpl = $compiler->getDwoo()->templateFactory($resource, $identifier); |
|
34 | 34 | |
35 | - if ($tpl === null) { |
|
36 | - throw new CompilationException($compiler, 'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.'); |
|
37 | - } elseif ($tpl === false) { |
|
38 | - throw new CompilationException($compiler, 'Load Templates : Resource "' . $resource . '" does not support includes.'); |
|
39 | - } |
|
35 | + if ($tpl === null) { |
|
36 | + throw new CompilationException($compiler, 'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.'); |
|
37 | + } elseif ($tpl === false) { |
|
38 | + throw new CompilationException($compiler, 'Load Templates : Resource "' . $resource . '" does not support includes.'); |
|
39 | + } |
|
40 | 40 | |
41 | - $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n"; |
|
41 | + $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n"; |
|
42 | 42 | |
43 | - $modCheck = $tpl->getIsModifiedCode(); |
|
43 | + $modCheck = $tpl->getIsModifiedCode(); |
|
44 | 44 | |
45 | - if ($modCheck) { |
|
46 | - $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }'; |
|
47 | - } else { |
|
48 | - $out .= 'try { |
|
45 | + if ($modCheck) { |
|
46 | + $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }'; |
|
47 | + } else { |
|
48 | + $out .= 'try { |
|
49 | 49 | $tpl = $this->templateFactory("' . $resource . '", "' . $identifier . '"); |
50 | 50 | } catch (Dwoo\Exception $e) { |
51 | 51 | $this->triggerError(\'Load Templates : Resource <em>' . $resource . '</em> was not added to Dwoo, can not extend <em>' . $identifier . '</em>\', E_USER_WARNING); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | elseif ($tpl === false) |
56 | 56 | $this->triggerError(\'Load Templates : Resource "' . $resource . '" does not support extends.\', E_USER_WARNING); |
57 | 57 | if ($tpl->getUid() != "' . $tpl->getUid() . '") { ob_end_clean(); return false; }'; |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - return $out; |
|
60 | + return $out; |
|
61 | 61 | } |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | $tpl = $compiler->getDwoo()->templateFactory($resource, $identifier); |
49 | 49 | |
50 | 50 | if ($tpl === null) { |
51 | - throw new CompilationException($compiler, 'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.'); |
|
51 | + throw new CompilationException($compiler, 'Load Templates : Resource "'.$resource.':'.$identifier.'" not found.'); |
|
52 | 52 | } elseif ($tpl === false) { |
53 | - throw new CompilationException($compiler, 'Load Templates : Resource "' . $resource . '" does not support includes.'); |
|
53 | + throw new CompilationException($compiler, 'Load Templates : Resource "'.$resource.'" does not support includes.'); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | $cmp = clone $compiler; |
@@ -62,23 +62,23 @@ discard block |
||
62 | 62 | $compiler->addUsedPlugin($plugin, $type); |
63 | 63 | } |
64 | 64 | |
65 | - $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n"; |
|
65 | + $out = '\'\';// checking for modification in '.$resource.':'.$identifier."\r\n"; |
|
66 | 66 | |
67 | 67 | $modCheck = $tpl->getIsModifiedCode(); |
68 | 68 | |
69 | 69 | if ($modCheck) { |
70 | - $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }'; |
|
70 | + $out .= 'if (!('.$modCheck.')) { ob_end_clean(); return false; }'; |
|
71 | 71 | } else { |
72 | 72 | $out .= 'try { |
73 | - $tpl = $this->templateFactory("' . $resource . '", "' . $identifier . '"); |
|
73 | + $tpl = $this->templateFactory("' . $resource.'", "'.$identifier.'"); |
|
74 | 74 | } catch (Dwoo\Exception $e) { |
75 | - $this->triggerError(\'Load Templates : Resource <em>' . $resource . '</em> was not added to Dwoo, can not extend <em>' . $identifier . '</em>\', E_USER_WARNING); |
|
75 | + $this->triggerError(\'Load Templates : Resource <em>' . $resource.'</em> was not added to Dwoo, can not extend <em>'.$identifier.'</em>\', E_USER_WARNING); |
|
76 | 76 | } |
77 | 77 | if ($tpl === null) |
78 | - $this->triggerError(\'Load Templates : Resource "' . $resource . ':' . $identifier . '" was not found.\', E_USER_WARNING); |
|
78 | + $this->triggerError(\'Load Templates : Resource "' . $resource.':'.$identifier.'" was not found.\', E_USER_WARNING); |
|
79 | 79 | elseif ($tpl === false) |
80 | - $this->triggerError(\'Load Templates : Resource "' . $resource . '" does not support extends.\', E_USER_WARNING); |
|
81 | -if ($tpl->getUid() != "' . $tpl->getUid() . '") { ob_end_clean(); return false; }'; |
|
80 | + $this->triggerError(\'Load Templates : Resource "' . $resource.'" does not support extends.\', E_USER_WARNING); |
|
81 | +if ($tpl->getUid() != "' . $tpl->getUid().'") { ob_end_clean(); return false; }'; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | return $out; |
@@ -37,5 +37,5 @@ |
||
37 | 37 | */ |
38 | 38 | function PluginWhitespaceCompile(Compiler $compiler, $value, $with = ' ') |
39 | 39 | { |
40 | - return "preg_replace('#\s+#'.(strcasecmp(\$this->charset, 'utf-8')===0?'u':''), $with, $value)"; |
|
40 | + return "preg_replace('#\s+#'.(strcasecmp(\$this->charset, 'utf-8')===0?'u':''), $with, $value)"; |
|
41 | 41 | } |
@@ -31,5 +31,5 @@ |
||
31 | 31 | */ |
32 | 32 | function PluginWordwrapCompile(Compiler $compiler, $value, $length = 80, $break = "\n", $cut = false) |
33 | 33 | { |
34 | - return 'wordwrap(' . $value . ',' . $length . ',' . $break . ',' . $cut . ')'; |
|
34 | + return 'wordwrap(' . $value . ',' . $length . ',' . $break . ',' . $cut . ')'; |
|
35 | 35 | } |
@@ -31,5 +31,5 @@ |
||
31 | 31 | */ |
32 | 32 | function PluginWordwrapCompile(Compiler $compiler, $value, $length = 80, $break = "\n", $cut = false) |
33 | 33 | { |
34 | - return 'wordwrap(' . $value . ',' . $length . ',' . $break . ',' . $cut . ')'; |
|
34 | + return 'wordwrap('.$value.','.$length.','.$break.','.$cut.')'; |
|
35 | 35 | } |
@@ -28,5 +28,5 @@ |
||
28 | 28 | */ |
29 | 29 | function PluginCountSentencesCompile(Compiler $compiler, $value) |
30 | 30 | { |
31 | - return "preg_match_all('#[\w\pL]\.(?![\w\pL])#u', $value, \$tmp)"; |
|
31 | + return "preg_match_all('#[\w\pL]\.(?![\w\pL])#u', $value, \$tmp)"; |
|
32 | 32 | } |
@@ -33,25 +33,25 @@ |
||
33 | 33 | */ |
34 | 34 | function PluginTruncate(Core $dwoo, $value, $length = 80, $etc = '...', $break = false, $middle = false) |
35 | 35 | { |
36 | - if ($length == 0) { |
|
37 | - return ''; |
|
38 | - } |
|
36 | + if ($length == 0) { |
|
37 | + return ''; |
|
38 | + } |
|
39 | 39 | |
40 | - $value = (string)$value; |
|
41 | - $etc = (string)$etc; |
|
42 | - $length = (int)$length; |
|
40 | + $value = (string)$value; |
|
41 | + $etc = (string)$etc; |
|
42 | + $length = (int)$length; |
|
43 | 43 | |
44 | - if (strlen($value) < $length) { |
|
45 | - return $value; |
|
46 | - } |
|
44 | + if (strlen($value) < $length) { |
|
45 | + return $value; |
|
46 | + } |
|
47 | 47 | |
48 | - $length = max($length - strlen($etc), 0); |
|
49 | - if ($break === false && $middle === false) { |
|
50 | - $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1)); |
|
51 | - } |
|
52 | - if ($middle === false) { |
|
53 | - return substr($value, 0, $length) . $etc; |
|
54 | - } |
|
48 | + $length = max($length - strlen($etc), 0); |
|
49 | + if ($break === false && $middle === false) { |
|
50 | + $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1)); |
|
51 | + } |
|
52 | + if ($middle === false) { |
|
53 | + return substr($value, 0, $length) . $etc; |
|
54 | + } |
|
55 | 55 | |
56 | - return substr($value, 0, ceil($length / 2)) . $etc . substr($value, - floor($length / 2)); |
|
56 | + return substr($value, 0, ceil($length / 2)) . $etc . substr($value, - floor($length / 2)); |
|
57 | 57 | } |
@@ -37,21 +37,21 @@ |
||
37 | 37 | return ''; |
38 | 38 | } |
39 | 39 | |
40 | - $value = (string)$value; |
|
41 | - $etc = (string)$etc; |
|
42 | - $length = (int)$length; |
|
40 | + $value = (string) $value; |
|
41 | + $etc = (string) $etc; |
|
42 | + $length = (int) $length; |
|
43 | 43 | |
44 | 44 | if (strlen($value) < $length) { |
45 | 45 | return $value; |
46 | 46 | } |
47 | 47 | |
48 | - $length = max($length - strlen($etc), 0); |
|
48 | + $length = max($length-strlen($etc), 0); |
|
49 | 49 | if ($break === false && $middle === false) { |
50 | - $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1)); |
|
50 | + $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length+1)); |
|
51 | 51 | } |
52 | 52 | if ($middle === false) { |
53 | - return substr($value, 0, $length) . $etc; |
|
53 | + return substr($value, 0, $length).$etc; |
|
54 | 54 | } |
55 | 55 | |
56 | - return substr($value, 0, ceil($length / 2)) . $etc . substr($value, - floor($length / 2)); |
|
56 | + return substr($value, 0, ceil($length/2)).$etc.substr($value, - floor($length/2)); |
|
57 | 57 | } |