@@ -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) { |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | function Dwoo_Plugin_replace_compile(Dwoo_Compiler $compiler, $value, $search, $replace, $case_sensitive = true) |
22 | 22 | { |
23 | - if ($case_sensitive == 'false' || (bool)$case_sensitive === false) { |
|
23 | + if ($case_sensitive == 'false' || (bool) $case_sensitive === false) { |
|
24 | 24 | return 'str_ireplace('.$search.', '.$replace.', '.$value.')'; |
25 | 25 | } else { |
26 | 26 | return 'str_replace('.$search.', '.$replace.', '.$value.')'; |
@@ -17,9 +17,9 @@ |
||
17 | 17 | * @date 2008-10-23 |
18 | 18 | * @package Dwoo |
19 | 19 | */ |
20 | -function Dwoo_Plugin_strip_tags_compile(Dwoo_Compiler $compiler, $value, $addspace=true) |
|
20 | +function Dwoo_Plugin_strip_tags_compile(Dwoo_Compiler $compiler, $value, $addspace = true) |
|
21 | 21 | { |
22 | - if ($addspace==='true') { |
|
22 | + if ($addspace === 'true') { |
|
23 | 23 | return "preg_replace('#<[^>]*>#', ' ', $value)"; |
24 | 24 | } else { |
25 | 25 | return "strip_tags($value)"; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @date 2009-07-18 |
25 | 25 | * @package Dwoo |
26 | 26 | */ |
27 | -function Dwoo_Plugin_mailto(Dwoo_Core $dwoo, $address, $text=null, $subject=null, $encode=null, $cc=null, $bcc=null, $newsgroups=null, $followupto=null, $extra=null) |
|
27 | +function Dwoo_Plugin_mailto(Dwoo_Core $dwoo, $address, $text = null, $subject = null, $encode = null, $cc = null, $bcc = null, $newsgroups = null, $followupto = null, $extra = null) |
|
28 | 28 | { |
29 | 29 | if (empty($address)) { |
30 | 30 | return ''; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $address = rtrim($address, '?&'); |
56 | 56 | |
57 | 57 | // output |
58 | - switch($encode) |
|
58 | + switch ($encode) |
|
59 | 59 | { |
60 | 60 | |
61 | 61 | case 'none': |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $len = strlen($str); |
69 | 69 | |
70 | 70 | $out = ''; |
71 | - for ($i=0; $i<$len; $i++) { |
|
71 | + for ($i = 0; $i < $len; $i++) { |
|
72 | 72 | $out .= '%'.bin2hex($str[$i]); |
73 | 73 | } |
74 | 74 | return '<script type="text/javascript">eval(unescape(\''.$out.'\'));</script>'; |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | $len = strlen($str); |
83 | 83 | |
84 | 84 | $out = '<script type="text/javascript">'."\n<!--\ndocument.write(String.fromCharCode("; |
85 | - for ($i=0; $i<$len; $i++) { |
|
85 | + for ($i = 0; $i < $len; $i++) { |
|
86 | 86 | $out .= ord($str[$i]).','; |
87 | 87 | } |
88 | - return rtrim($out, ',') . "));\n-->\n</script>\n"; |
|
88 | + return rtrim($out, ',')."));\n-->\n</script>\n"; |
|
89 | 89 | |
90 | 90 | break; |
91 | 91 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | $out = '<a href="mailto:'; |
98 | 98 | $len = strlen($address); |
99 | - for ($i=0; $i<$len; $i++) { |
|
99 | + for ($i = 0; $i < $len; $i++) { |
|
100 | 100 | if (preg_match('#\w#', $address[$i])) { |
101 | 101 | $out .= '%'.bin2hex($address[$i]); |
102 | 102 | } else { |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | $out .= '" '.$extra.'>'; |
107 | 107 | $len = strlen($text); |
108 | - for ($i=0; $i<$len; $i++) { |
|
108 | + for ($i = 0; $i < $len; $i++) { |
|
109 | 109 | $out .= '&#x'.bin2hex($text[$i]); |
110 | 110 | } |
111 | 111 | return $out.'</a>'; |
@@ -18,7 +18,7 @@ |
||
18 | 18 | * @date 2008-10-23 |
19 | 19 | * @package Dwoo |
20 | 20 | */ |
21 | -function Dwoo_Plugin_indent_compile(Dwoo_Compiler $compiler, $value, $by=4, $char=' ') |
|
21 | +function Dwoo_Plugin_indent_compile(Dwoo_Compiler $compiler, $value, $by = 4, $char = ' ') |
|
22 | 22 | { |
23 | 23 | return "preg_replace('#^#m', '".str_repeat(substr($char, 1, -1), trim($by, '"\''))."', $value)"; |
24 | 24 | } |