@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @date 2009-07-18 |
21 | 21 | * @package Dwoo |
22 | 22 | */ |
23 | -function Dwoo_Plugin_truncate(Dwoo_Core $dwoo, $value, $length=80, $etc='...', $break=false, $middle=false) |
|
23 | +function Dwoo_Plugin_truncate(Dwoo_Core $dwoo, $value, $length = 80, $etc = '...', $break = false, $middle = false) |
|
24 | 24 | { |
25 | 25 | if ($length == 0) { |
26 | 26 | return ''; |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | return $value; |
35 | 35 | } |
36 | 36 | |
37 | - $length = max($length - strlen($etc), 0); |
|
37 | + $length = max($length-strlen($etc), 0); |
|
38 | 38 | if ($break === false && $middle === false) { |
39 | 39 | $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length+1)); |
40 | 40 | } |
41 | 41 | if ($middle === false) { |
42 | - return substr($value, 0, $length) . $etc; |
|
42 | + return substr($value, 0, $length).$etc; |
|
43 | 43 | } |
44 | - return substr($value, 0, ceil($length/2)) . $etc . substr($value, -floor($length/2)); |
|
44 | + return substr($value, 0, ceil($length/2)).$etc.substr($value, -floor($length/2)); |
|
45 | 45 | } |
@@ -17,9 +17,9 @@ |
||
17 | 17 | * @date 2008-10-23 |
18 | 18 | * @package Dwoo |
19 | 19 | */ |
20 | -function Dwoo_Plugin_count_characters_compile(Dwoo_Compiler $compiler, $value, $count_spaces=false) |
|
20 | +function Dwoo_Plugin_count_characters_compile(Dwoo_Compiler $compiler, $value, $count_spaces = false) |
|
21 | 21 | { |
22 | - if ($count_spaces==='false') { |
|
22 | + if ($count_spaces === 'false') { |
|
23 | 23 | return 'preg_match_all(\'#[^\s\pZ]#u\', '.$value.', $tmp)'; |
24 | 24 | } else { |
25 | 25 | return 'mb_strlen('.$value.', $this->charset)'; |
@@ -17,19 +17,19 @@ |
||
17 | 17 | * @date 2009-07-18 |
18 | 18 | * @package Dwoo |
19 | 19 | */ |
20 | -function Dwoo_Plugin_capitalize(Dwoo_Core $dwoo, $value, $numwords=false) |
|
20 | +function Dwoo_Plugin_capitalize(Dwoo_Core $dwoo, $value, $numwords = false) |
|
21 | 21 | { |
22 | - if ($numwords || preg_match('#^[^0-9]+$#',$value)) |
|
22 | + if ($numwords || preg_match('#^[^0-9]+$#', $value)) |
|
23 | 23 | { |
24 | - return mb_convert_case((string) $value,MB_CASE_TITLE, $dwoo->getCharset()); |
|
24 | + return mb_convert_case((string) $value, MB_CASE_TITLE, $dwoo->getCharset()); |
|
25 | 25 | } else { |
26 | 26 | $bits = explode(' ', (string) $value); |
27 | 27 | $out = ''; |
28 | 28 | while (list(,$v) = each($bits)) { |
29 | 29 | if (preg_match('#^[^0-9]+$#', $v)) { |
30 | - $out .= ' '.mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset()); |
|
30 | + $out .= ' '.mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset()); |
|
31 | 31 | } else { |
32 | - $out .= ' '.$v; |
|
32 | + $out .= ' '.$v; |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 |
@@ -70,5 +70,5 @@ |
||
70 | 70 | // parse condition |
71 | 71 | $condition = Dwoo_Plugin_if::replaceKeywords($rest, $tokens, $compiler); |
72 | 72 | |
73 | - return '(('.implode(' ', $condition).') ? '.($trueResult===true ? implode(' ', $condition) : $trueResult).' : '.$falseResult.')'; |
|
73 | + return '(('.implode(' ', $condition).') ? '.($trueResult === true ? implode(' ', $condition) : $trueResult).' : '.$falseResult.')'; |
|
74 | 74 | } |
@@ -24,9 +24,9 @@ |
||
24 | 24 | */ |
25 | 25 | function Dwoo_Plugin_return_compile(Dwoo_Compiler $compiler, array $rest = array()) |
26 | 26 | { |
27 | - $out = array(); |
|
28 | - foreach ($rest as $var => $val) { |
|
29 | - $out[] = '$this->setReturnValue('.var_export($var, true).', '.$val.')'; |
|
30 | - } |
|
31 | - return '('.implode('.', $out).')'; |
|
27 | + $out = array(); |
|
28 | + foreach ($rest as $var => $val) { |
|
29 | + $out[] = '$this->setReturnValue('.var_export($var, true).', '.$val.')'; |
|
30 | + } |
|
31 | + return '('.implode('.', $out).')'; |
|
32 | 32 | } |
33 | 33 | \ No newline at end of file |
@@ -59,7 +59,7 @@ |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | if (count($rest)) { |
62 | - $vars = $rest + $vars; |
|
62 | + $vars = $rest+$vars; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | $clone = clone $dwoo; |
@@ -17,7 +17,7 @@ |
||
17 | 17 | * @date 2008-10-23 |
18 | 18 | * @package Dwoo |
19 | 19 | */ |
20 | -function Dwoo_Plugin_default_compile(Dwoo_Compiler $compiler, $value, $default='') |
|
20 | +function Dwoo_Plugin_default_compile(Dwoo_Compiler $compiler, $value, $default = '') |
|
21 | 21 | { |
22 | 22 | return '(($tmp = '.$value.')===null||$tmp===\'\' ? '.$default.' : $tmp)'; |
23 | 23 | } |
@@ -28,13 +28,12 @@ discard block |
||
28 | 28 | * @date 2008-10-23 |
29 | 29 | * @package Dwoo |
30 | 30 | */ |
31 | -function Dwoo_Plugin_math_compile(Dwoo_Compiler $compiler, $equation, $format='', $assign='', array $rest=array()) |
|
31 | +function Dwoo_Plugin_math_compile(Dwoo_Compiler $compiler, $equation, $format = '', $assign = '', array $rest = array()) |
|
32 | 32 | { |
33 | 33 | /** |
34 | 34 | * Holds the allowed function, characters, operators and constants |
35 | 35 | */ |
36 | - $allowed = array |
|
37 | - ( |
|
36 | + $allowed = array( |
|
38 | 37 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', |
39 | 38 | '+', '-', '/', '*', '.', ' ', '<<', '>>', '%', '&', '^', '|', '~', |
40 | 39 | 'abs(', 'ceil(', 'floor(', 'exp(', 'log10(', |
@@ -45,8 +44,7 @@ discard block |
||
45 | 44 | /** |
46 | 45 | * Holds the functions that can accept multiple arguments |
47 | 46 | */ |
48 | - $funcs = array |
|
49 | - ( |
|
47 | + $funcs = array( |
|
50 | 48 | 'round(', 'log(', 'pow(', |
51 | 49 | 'max(', 'min(', 'rand(', |
52 | 50 | ); |
@@ -64,12 +62,12 @@ discard block |
||
64 | 62 | $substr = substr($equation, 0, $ptr); |
65 | 63 | if (array_search($substr, $allowed) !== false) { |
66 | 64 | // allowed string |
67 | - $out.=$substr; |
|
65 | + $out .= $substr; |
|
68 | 66 | $equation = substr($equation, $ptr); |
69 | 67 | $ptr = 0; |
70 | 68 | } elseif (array_search($substr, $funcs) !== false) { |
71 | 69 | // allowed func |
72 | - $out.=$substr; |
|
70 | + $out .= $substr; |
|
73 | 71 | $equation = substr($equation, $ptr); |
74 | 72 | $ptr = 0; |
75 | 73 | $allowcomma++; |
@@ -78,7 +76,7 @@ discard block |
||
78 | 76 | } |
79 | 77 | } elseif (isset($rest[$substr])) { |
80 | 78 | // variable |
81 | - $out.=$rest[$substr]; |
|
79 | + $out .= $rest[$substr]; |
|
82 | 80 | $equation = substr($equation, $ptr); |
83 | 81 | $ptr = 0; |
84 | 82 | } elseif ($substr === $open) { |
@@ -87,28 +85,28 @@ discard block |
||
87 | 85 | if (empty($m)) { |
88 | 86 | preg_match('#.*?'.str_replace('.', '\\.', $close).'#', substr($equation, 2), $m); |
89 | 87 | } |
90 | - $out.=substr($m[0], 0, -2); |
|
88 | + $out .= substr($m[0], 0, -2); |
|
91 | 89 | $equation = substr($equation, strlen($m[0])+2); |
92 | 90 | $ptr = 0; |
93 | - } elseif ($substr==='(') { |
|
91 | + } elseif ($substr === '(') { |
|
94 | 92 | // opening parenthesis |
95 | - if ($allowcomma>0) { |
|
93 | + if ($allowcomma > 0) { |
|
96 | 94 | $allowcomma++; |
97 | 95 | } |
98 | 96 | |
99 | - $out.=$substr; |
|
97 | + $out .= $substr; |
|
100 | 98 | $equation = substr($equation, $ptr); |
101 | 99 | $ptr = 0; |
102 | - } elseif ($substr===')') { |
|
100 | + } elseif ($substr === ')') { |
|
103 | 101 | // closing parenthesis |
104 | - if ($allowcomma>0) { |
|
102 | + if ($allowcomma > 0) { |
|
105 | 103 | $allowcomma--; |
106 | - if ($allowcomma===0) { |
|
104 | + if ($allowcomma === 0) { |
|
107 | 105 | array_pop($allowed); |
108 | 106 | } |
109 | 107 | } |
110 | 108 | |
111 | - $out.=$substr; |
|
109 | + $out .= $substr; |
|
112 | 110 | $equation = substr($equation, $ptr); |
113 | 111 | $ptr = 0; |
114 | 112 | } elseif ($ptr >= strlen($equation)) { |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | public static function compile(Dwoo_Compiler $compiler, $file) |
28 | 28 | { |
29 | 29 | list($l, $r) = $compiler->getDelimiters(); |
30 | - self::$l = preg_quote($l,'/'); |
|
31 | - self::$r = preg_quote($r,'/'); |
|
30 | + self::$l = preg_quote($l, '/'); |
|
31 | + self::$r = preg_quote($r, '/'); |
|
32 | 32 | self::$regex = '/ |
33 | 33 | '.self::$l.'block\s(["\']?)(.+?)\1'.self::$r.'(?:\r?\n?) |
34 | 34 | ((?: |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | self::$r = '\s*'.self::$r; |
50 | 50 | } |
51 | 51 | $inheritanceTree = array(array('source'=>$compiler->getTemplateSource())); |
52 | - $curPath = dirname($compiler->getDwoo()->getTemplate()->getResourceIdentifier()) . DIRECTORY_SEPARATOR; |
|
52 | + $curPath = dirname($compiler->getDwoo()->getTemplate()->getResourceIdentifier()).DIRECTORY_SEPARATOR; |
|
53 | 53 | $curTpl = $compiler->getDwoo()->getTemplate(); |
54 | 54 | |
55 | 55 | while (!empty($file)) { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $inheritanceTree[] = $newParent; |
91 | 91 | |
92 | 92 | if (preg_match('/^'.self::$l.'extends(?:\(?\s*|\s+)(?:file=)?\s*((["\']).+?\2|\S+?)\s*\)?\s*?'.self::$r.'/i', $parent->getSource(), $match)) { |
93 | - $curPath = dirname($identifier) . DIRECTORY_SEPARATOR; |
|
93 | + $curPath = dirname($identifier).DIRECTORY_SEPARATOR; |
|
94 | 94 | if (isset($match[2]) && $match[2] == '"') { |
95 | 95 | $file = '"'.str_replace('"', '\\"', substr($match[1], 1, -1)).'"'; |
96 | 96 | } elseif (isset($match[2]) && $match[2] == "'") { |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | if (preg_match(self::$regex, $matches[3])) { |
143 | - return preg_replace_callback(self::$regex, array('Dwoo_Plugin_extends', 'replaceBlock'), $matches[3] ); |
|
143 | + return preg_replace_callback(self::$regex, array('Dwoo_Plugin_extends', 'replaceBlock'), $matches[3]); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | if (self::$lastReplacement) { |