@@ -5,17 +5,17 @@ |
||
5 | 5 | */ |
6 | 6 | class HTMLPurifier_URIScheme_news extends HTMLPurifier_URIScheme { |
7 | 7 | |
8 | - public $browsable = false; |
|
9 | - public $may_omit_host = true; |
|
8 | + public $browsable = false; |
|
9 | + public $may_omit_host = true; |
|
10 | 10 | |
11 | - public function doValidate(&$uri, $config, $context) { |
|
12 | - $uri->userinfo = null; |
|
13 | - $uri->host = null; |
|
14 | - $uri->port = null; |
|
15 | - $uri->query = null; |
|
16 | - // typecode check needed on path |
|
17 | - return true; |
|
18 | - } |
|
11 | + public function doValidate(&$uri, $config, $context) { |
|
12 | + $uri->userinfo = null; |
|
13 | + $uri->host = null; |
|
14 | + $uri->port = null; |
|
15 | + $uri->query = null; |
|
16 | + // typecode check needed on path |
|
17 | + return true; |
|
18 | + } |
|
19 | 19 | |
20 | 20 | } |
21 | 21 |
@@ -5,14 +5,14 @@ |
||
5 | 5 | */ |
6 | 6 | class HTMLPurifier_URIScheme_nntp extends HTMLPurifier_URIScheme { |
7 | 7 | |
8 | - public $default_port = 119; |
|
9 | - public $browsable = false; |
|
8 | + public $default_port = 119; |
|
9 | + public $browsable = false; |
|
10 | 10 | |
11 | - public function doValidate(&$uri, $config, $context) { |
|
12 | - $uri->userinfo = null; |
|
13 | - $uri->query = null; |
|
14 | - return true; |
|
15 | - } |
|
11 | + public function doValidate(&$uri, $config, $context) { |
|
12 | + $uri->userinfo = null; |
|
13 | + $uri->query = null; |
|
14 | + return true; |
|
15 | + } |
|
16 | 16 | |
17 | 17 | } |
18 | 18 |
@@ -6,62 +6,62 @@ |
||
6 | 6 | class HTMLPurifier_URISchemeRegistry |
7 | 7 | { |
8 | 8 | |
9 | - /** |
|
10 | - * Retrieve sole instance of the registry. |
|
11 | - * @param $prototype Optional prototype to overload sole instance with, |
|
12 | - * or bool true to reset to default registry. |
|
13 | - * @note Pass a registry object $prototype with a compatible interface and |
|
14 | - * the function will copy it and return it all further times. |
|
15 | - */ |
|
16 | - public static function instance($prototype = null) { |
|
17 | - static $instance = null; |
|
18 | - if ($prototype !== null) { |
|
19 | - $instance = $prototype; |
|
20 | - } elseif ($instance === null || $prototype == true) { |
|
21 | - $instance = new HTMLPurifier_URISchemeRegistry(); |
|
22 | - } |
|
23 | - return $instance; |
|
24 | - } |
|
9 | + /** |
|
10 | + * Retrieve sole instance of the registry. |
|
11 | + * @param $prototype Optional prototype to overload sole instance with, |
|
12 | + * or bool true to reset to default registry. |
|
13 | + * @note Pass a registry object $prototype with a compatible interface and |
|
14 | + * the function will copy it and return it all further times. |
|
15 | + */ |
|
16 | + public static function instance($prototype = null) { |
|
17 | + static $instance = null; |
|
18 | + if ($prototype !== null) { |
|
19 | + $instance = $prototype; |
|
20 | + } elseif ($instance === null || $prototype == true) { |
|
21 | + $instance = new HTMLPurifier_URISchemeRegistry(); |
|
22 | + } |
|
23 | + return $instance; |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Cache of retrieved schemes. |
|
28 | - */ |
|
29 | - protected $schemes = array(); |
|
26 | + /** |
|
27 | + * Cache of retrieved schemes. |
|
28 | + */ |
|
29 | + protected $schemes = array(); |
|
30 | 30 | |
31 | - /** |
|
32 | - * Retrieves a scheme validator object |
|
33 | - * @param $scheme String scheme name like http or mailto |
|
34 | - * @param $config HTMLPurifier_Config object |
|
35 | - * @param $config HTMLPurifier_Context object |
|
36 | - */ |
|
37 | - public function getScheme($scheme, $config, $context) { |
|
38 | - if (!$config) $config = HTMLPurifier_Config::createDefault(); |
|
31 | + /** |
|
32 | + * Retrieves a scheme validator object |
|
33 | + * @param $scheme String scheme name like http or mailto |
|
34 | + * @param $config HTMLPurifier_Config object |
|
35 | + * @param $config HTMLPurifier_Context object |
|
36 | + */ |
|
37 | + public function getScheme($scheme, $config, $context) { |
|
38 | + if (!$config) $config = HTMLPurifier_Config::createDefault(); |
|
39 | 39 | |
40 | - // important, otherwise attacker could include arbitrary file |
|
41 | - $allowed_schemes = $config->get('URI.AllowedSchemes'); |
|
42 | - if (!$config->get('URI.OverrideAllowedSchemes') && |
|
43 | - !isset($allowed_schemes[$scheme]) |
|
44 | - ) { |
|
45 | - return; |
|
46 | - } |
|
40 | + // important, otherwise attacker could include arbitrary file |
|
41 | + $allowed_schemes = $config->get('URI.AllowedSchemes'); |
|
42 | + if (!$config->get('URI.OverrideAllowedSchemes') && |
|
43 | + !isset($allowed_schemes[$scheme]) |
|
44 | + ) { |
|
45 | + return; |
|
46 | + } |
|
47 | 47 | |
48 | - if (isset($this->schemes[$scheme])) return $this->schemes[$scheme]; |
|
49 | - if (!isset($allowed_schemes[$scheme])) return; |
|
48 | + if (isset($this->schemes[$scheme])) return $this->schemes[$scheme]; |
|
49 | + if (!isset($allowed_schemes[$scheme])) return; |
|
50 | 50 | |
51 | - $class = 'HTMLPurifier_URIScheme_' . $scheme; |
|
52 | - if (!class_exists($class)) return; |
|
53 | - $this->schemes[$scheme] = new $class(); |
|
54 | - return $this->schemes[$scheme]; |
|
55 | - } |
|
51 | + $class = 'HTMLPurifier_URIScheme_' . $scheme; |
|
52 | + if (!class_exists($class)) return; |
|
53 | + $this->schemes[$scheme] = new $class(); |
|
54 | + return $this->schemes[$scheme]; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Registers a custom scheme to the cache, bypassing reflection. |
|
59 | - * @param $scheme Scheme name |
|
60 | - * @param $scheme_obj HTMLPurifier_URIScheme object |
|
61 | - */ |
|
62 | - public function register($scheme, $scheme_obj) { |
|
63 | - $this->schemes[$scheme] = $scheme_obj; |
|
64 | - } |
|
57 | + /** |
|
58 | + * Registers a custom scheme to the cache, bypassing reflection. |
|
59 | + * @param $scheme Scheme name |
|
60 | + * @param $scheme_obj HTMLPurifier_URIScheme object |
|
61 | + */ |
|
62 | + public function register($scheme, $scheme_obj) { |
|
63 | + $this->schemes[$scheme] = $scheme_obj; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | } |
67 | 67 |
@@ -35,7 +35,9 @@ discard block |
||
35 | 35 | * @param $config HTMLPurifier_Context object |
36 | 36 | */ |
37 | 37 | public function getScheme($scheme, $config, $context) { |
38 | - if (!$config) $config = HTMLPurifier_Config::createDefault(); |
|
38 | + if (!$config) { |
|
39 | + $config = HTMLPurifier_Config::createDefault(); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // important, otherwise attacker could include arbitrary file |
41 | 43 | $allowed_schemes = $config->get('URI.AllowedSchemes'); |
@@ -45,11 +47,17 @@ discard block |
||
45 | 47 | return; |
46 | 48 | } |
47 | 49 | |
48 | - if (isset($this->schemes[$scheme])) return $this->schemes[$scheme]; |
|
49 | - if (!isset($allowed_schemes[$scheme])) return; |
|
50 | + if (isset($this->schemes[$scheme])) { |
|
51 | + return $this->schemes[$scheme]; |
|
52 | + } |
|
53 | + if (!isset($allowed_schemes[$scheme])) { |
|
54 | + return; |
|
55 | + } |
|
50 | 56 | |
51 | 57 | $class = 'HTMLPurifier_URIScheme_' . $scheme; |
52 | - if (!class_exists($class)) return; |
|
58 | + if (!class_exists($class)) { |
|
59 | + return; |
|
60 | + } |
|
53 | 61 | $this->schemes[$scheme] = new $class(); |
54 | 62 | return $this->schemes[$scheme]; |
55 | 63 | } |
@@ -48,7 +48,7 @@ |
||
48 | 48 | if (isset($this->schemes[$scheme])) return $this->schemes[$scheme]; |
49 | 49 | if (!isset($allowed_schemes[$scheme])) return; |
50 | 50 | |
51 | - $class = 'HTMLPurifier_URIScheme_' . $scheme; |
|
51 | + $class = 'HTMLPurifier_URIScheme_'.$scheme; |
|
52 | 52 | if (!class_exists($class)) return; |
53 | 53 | $this->schemes[$scheme] = new $class(); |
54 | 54 | return $this->schemes[$scheme]; |
@@ -8,95 +8,95 @@ |
||
8 | 8 | class HTMLPurifier_VarParser_Flexible extends HTMLPurifier_VarParser |
9 | 9 | { |
10 | 10 | |
11 | - protected function parseImplementation($var, $type, $allow_null) { |
|
12 | - if ($allow_null && $var === null) return null; |
|
13 | - switch ($type) { |
|
14 | - // Note: if code "breaks" from the switch, it triggers a generic |
|
15 | - // exception to be thrown. Specific errors can be specifically |
|
16 | - // done here. |
|
17 | - case self::MIXED : |
|
18 | - case self::ISTRING : |
|
19 | - case self::STRING : |
|
20 | - case self::TEXT : |
|
21 | - case self::ITEXT : |
|
22 | - return $var; |
|
23 | - case self::INT : |
|
24 | - if (is_string($var) && ctype_digit($var)) $var = (int) $var; |
|
25 | - return $var; |
|
26 | - case self::FLOAT : |
|
27 | - if ((is_string($var) && is_numeric($var)) || is_int($var)) $var = (float) $var; |
|
28 | - return $var; |
|
29 | - case self::BOOL : |
|
30 | - if (is_int($var) && ($var === 0 || $var === 1)) { |
|
31 | - $var = (bool) $var; |
|
32 | - } elseif (is_string($var)) { |
|
33 | - if ($var == 'on' || $var == 'true' || $var == '1') { |
|
34 | - $var = true; |
|
35 | - } elseif ($var == 'off' || $var == 'false' || $var == '0') { |
|
36 | - $var = false; |
|
37 | - } else { |
|
38 | - throw new HTMLPurifier_VarParserException("Unrecognized value '$var' for $type"); |
|
39 | - } |
|
40 | - } |
|
41 | - return $var; |
|
42 | - case self::ALIST : |
|
43 | - case self::HASH : |
|
44 | - case self::LOOKUP : |
|
45 | - if (is_string($var)) { |
|
46 | - // special case: technically, this is an array with |
|
47 | - // a single empty string item, but having an empty |
|
48 | - // array is more intuitive |
|
49 | - if ($var == '') return array(); |
|
50 | - if (strpos($var, "\n") === false && strpos($var, "\r") === false) { |
|
51 | - // simplistic string to array method that only works |
|
52 | - // for simple lists of tag names or alphanumeric characters |
|
53 | - $var = explode(',',$var); |
|
54 | - } else { |
|
55 | - $var = preg_split('/(,|[\n\r]+)/', $var); |
|
56 | - } |
|
57 | - // remove spaces |
|
58 | - foreach ($var as $i => $j) $var[$i] = trim($j); |
|
59 | - if ($type === self::HASH) { |
|
60 | - // key:value,key2:value2 |
|
61 | - $nvar = array(); |
|
62 | - foreach ($var as $keypair) { |
|
63 | - $c = explode(':', $keypair, 2); |
|
64 | - if (!isset($c[1])) continue; |
|
65 | - $nvar[trim($c[0])] = trim($c[1]); |
|
66 | - } |
|
67 | - $var = $nvar; |
|
68 | - } |
|
69 | - } |
|
70 | - if (!is_array($var)) break; |
|
71 | - $keys = array_keys($var); |
|
72 | - if ($keys === array_keys($keys)) { |
|
73 | - if ($type == self::ALIST) return $var; |
|
74 | - elseif ($type == self::LOOKUP) { |
|
75 | - $new = array(); |
|
76 | - foreach ($var as $key) { |
|
77 | - $new[$key] = true; |
|
78 | - } |
|
79 | - return $new; |
|
80 | - } else break; |
|
81 | - } |
|
82 | - if ($type === self::ALIST) { |
|
83 | - trigger_error("Array list did not have consecutive integer indexes", E_USER_WARNING); |
|
84 | - return array_values($var); |
|
85 | - } |
|
86 | - if ($type === self::LOOKUP) { |
|
87 | - foreach ($var as $key => $value) { |
|
88 | - if ($value !== true) { |
|
89 | - trigger_error("Lookup array has non-true value at key '$key'; maybe your input array was not indexed numerically", E_USER_WARNING); |
|
90 | - } |
|
91 | - $var[$key] = true; |
|
92 | - } |
|
93 | - } |
|
94 | - return $var; |
|
95 | - default: |
|
96 | - $this->errorInconsistent(__CLASS__, $type); |
|
97 | - } |
|
98 | - $this->errorGeneric($var, $type); |
|
99 | - } |
|
11 | + protected function parseImplementation($var, $type, $allow_null) { |
|
12 | + if ($allow_null && $var === null) return null; |
|
13 | + switch ($type) { |
|
14 | + // Note: if code "breaks" from the switch, it triggers a generic |
|
15 | + // exception to be thrown. Specific errors can be specifically |
|
16 | + // done here. |
|
17 | + case self::MIXED : |
|
18 | + case self::ISTRING : |
|
19 | + case self::STRING : |
|
20 | + case self::TEXT : |
|
21 | + case self::ITEXT : |
|
22 | + return $var; |
|
23 | + case self::INT : |
|
24 | + if (is_string($var) && ctype_digit($var)) $var = (int) $var; |
|
25 | + return $var; |
|
26 | + case self::FLOAT : |
|
27 | + if ((is_string($var) && is_numeric($var)) || is_int($var)) $var = (float) $var; |
|
28 | + return $var; |
|
29 | + case self::BOOL : |
|
30 | + if (is_int($var) && ($var === 0 || $var === 1)) { |
|
31 | + $var = (bool) $var; |
|
32 | + } elseif (is_string($var)) { |
|
33 | + if ($var == 'on' || $var == 'true' || $var == '1') { |
|
34 | + $var = true; |
|
35 | + } elseif ($var == 'off' || $var == 'false' || $var == '0') { |
|
36 | + $var = false; |
|
37 | + } else { |
|
38 | + throw new HTMLPurifier_VarParserException("Unrecognized value '$var' for $type"); |
|
39 | + } |
|
40 | + } |
|
41 | + return $var; |
|
42 | + case self::ALIST : |
|
43 | + case self::HASH : |
|
44 | + case self::LOOKUP : |
|
45 | + if (is_string($var)) { |
|
46 | + // special case: technically, this is an array with |
|
47 | + // a single empty string item, but having an empty |
|
48 | + // array is more intuitive |
|
49 | + if ($var == '') return array(); |
|
50 | + if (strpos($var, "\n") === false && strpos($var, "\r") === false) { |
|
51 | + // simplistic string to array method that only works |
|
52 | + // for simple lists of tag names or alphanumeric characters |
|
53 | + $var = explode(',',$var); |
|
54 | + } else { |
|
55 | + $var = preg_split('/(,|[\n\r]+)/', $var); |
|
56 | + } |
|
57 | + // remove spaces |
|
58 | + foreach ($var as $i => $j) $var[$i] = trim($j); |
|
59 | + if ($type === self::HASH) { |
|
60 | + // key:value,key2:value2 |
|
61 | + $nvar = array(); |
|
62 | + foreach ($var as $keypair) { |
|
63 | + $c = explode(':', $keypair, 2); |
|
64 | + if (!isset($c[1])) continue; |
|
65 | + $nvar[trim($c[0])] = trim($c[1]); |
|
66 | + } |
|
67 | + $var = $nvar; |
|
68 | + } |
|
69 | + } |
|
70 | + if (!is_array($var)) break; |
|
71 | + $keys = array_keys($var); |
|
72 | + if ($keys === array_keys($keys)) { |
|
73 | + if ($type == self::ALIST) return $var; |
|
74 | + elseif ($type == self::LOOKUP) { |
|
75 | + $new = array(); |
|
76 | + foreach ($var as $key) { |
|
77 | + $new[$key] = true; |
|
78 | + } |
|
79 | + return $new; |
|
80 | + } else break; |
|
81 | + } |
|
82 | + if ($type === self::ALIST) { |
|
83 | + trigger_error("Array list did not have consecutive integer indexes", E_USER_WARNING); |
|
84 | + return array_values($var); |
|
85 | + } |
|
86 | + if ($type === self::LOOKUP) { |
|
87 | + foreach ($var as $key => $value) { |
|
88 | + if ($value !== true) { |
|
89 | + trigger_error("Lookup array has non-true value at key '$key'; maybe your input array was not indexed numerically", E_USER_WARNING); |
|
90 | + } |
|
91 | + $var[$key] = true; |
|
92 | + } |
|
93 | + } |
|
94 | + return $var; |
|
95 | + default: |
|
96 | + $this->errorInconsistent(__CLASS__, $type); |
|
97 | + } |
|
98 | + $this->errorGeneric($var, $type); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | } |
102 | 102 |
@@ -50,7 +50,7 @@ |
||
50 | 50 | if (strpos($var, "\n") === false && strpos($var, "\r") === false) { |
51 | 51 | // simplistic string to array method that only works |
52 | 52 | // for simple lists of tag names or alphanumeric characters |
53 | - $var = explode(',',$var); |
|
53 | + $var = explode(',', $var); |
|
54 | 54 | } else { |
55 | 55 | $var = preg_split('/(,|[\n\r]+)/', $var); |
56 | 56 | } |
@@ -9,7 +9,9 @@ discard block |
||
9 | 9 | { |
10 | 10 | |
11 | 11 | protected function parseImplementation($var, $type, $allow_null) { |
12 | - if ($allow_null && $var === null) return null; |
|
12 | + if ($allow_null && $var === null) { |
|
13 | + return null; |
|
14 | + } |
|
13 | 15 | switch ($type) { |
14 | 16 | // Note: if code "breaks" from the switch, it triggers a generic |
15 | 17 | // exception to be thrown. Specific errors can be specifically |
@@ -21,10 +23,14 @@ discard block |
||
21 | 23 | case self::ITEXT : |
22 | 24 | return $var; |
23 | 25 | case self::INT : |
24 | - if (is_string($var) && ctype_digit($var)) $var = (int) $var; |
|
26 | + if (is_string($var) && ctype_digit($var)) { |
|
27 | + $var = (int) $var; |
|
28 | + } |
|
25 | 29 | return $var; |
26 | 30 | case self::FLOAT : |
27 | - if ((is_string($var) && is_numeric($var)) || is_int($var)) $var = (float) $var; |
|
31 | + if ((is_string($var) && is_numeric($var)) || is_int($var)) { |
|
32 | + $var = (float) $var; |
|
33 | + } |
|
28 | 34 | return $var; |
29 | 35 | case self::BOOL : |
30 | 36 | if (is_int($var) && ($var === 0 || $var === 1)) { |
@@ -46,7 +52,9 @@ discard block |
||
46 | 52 | // special case: technically, this is an array with |
47 | 53 | // a single empty string item, but having an empty |
48 | 54 | // array is more intuitive |
49 | - if ($var == '') return array(); |
|
55 | + if ($var == '') { |
|
56 | + return array(); |
|
57 | + } |
|
50 | 58 | if (strpos($var, "\n") === false && strpos($var, "\r") === false) { |
51 | 59 | // simplistic string to array method that only works |
52 | 60 | // for simple lists of tag names or alphanumeric characters |
@@ -55,29 +63,38 @@ discard block |
||
55 | 63 | $var = preg_split('/(,|[\n\r]+)/', $var); |
56 | 64 | } |
57 | 65 | // remove spaces |
58 | - foreach ($var as $i => $j) $var[$i] = trim($j); |
|
66 | + foreach ($var as $i => $j) { |
|
67 | + $var[$i] = trim($j); |
|
68 | + } |
|
59 | 69 | if ($type === self::HASH) { |
60 | 70 | // key:value,key2:value2 |
61 | 71 | $nvar = array(); |
62 | 72 | foreach ($var as $keypair) { |
63 | 73 | $c = explode(':', $keypair, 2); |
64 | - if (!isset($c[1])) continue; |
|
74 | + if (!isset($c[1])) { |
|
75 | + continue; |
|
76 | + } |
|
65 | 77 | $nvar[trim($c[0])] = trim($c[1]); |
66 | 78 | } |
67 | 79 | $var = $nvar; |
68 | 80 | } |
69 | 81 | } |
70 | - if (!is_array($var)) break; |
|
82 | + if (!is_array($var)) { |
|
83 | + break; |
|
84 | + } |
|
71 | 85 | $keys = array_keys($var); |
72 | 86 | if ($keys === array_keys($keys)) { |
73 | - if ($type == self::ALIST) return $var; |
|
74 | - elseif ($type == self::LOOKUP) { |
|
87 | + if ($type == self::ALIST) { |
|
88 | + return $var; |
|
89 | + } elseif ($type == self::LOOKUP) { |
|
75 | 90 | $new = array(); |
76 | 91 | foreach ($var as $key) { |
77 | 92 | $new[$key] = true; |
78 | 93 | } |
79 | 94 | return $new; |
80 | - } else break; |
|
95 | + } else { |
|
96 | + break; |
|
97 | + } |
|
81 | 98 | } |
82 | 99 | if ($type === self::ALIST) { |
83 | 100 | trigger_error("Array list did not have consecutive integer indexes", E_USER_WARNING); |
@@ -8,18 +8,18 @@ |
||
8 | 8 | class HTMLPurifier_VarParser_Native extends HTMLPurifier_VarParser |
9 | 9 | { |
10 | 10 | |
11 | - protected function parseImplementation($var, $type, $allow_null) { |
|
12 | - return $this->evalExpression($var); |
|
13 | - } |
|
11 | + protected function parseImplementation($var, $type, $allow_null) { |
|
12 | + return $this->evalExpression($var); |
|
13 | + } |
|
14 | 14 | |
15 | - protected function evalExpression($expr) { |
|
16 | - $var = null; |
|
17 | - $result = eval("\$var = $expr;"); |
|
18 | - if ($result === false) { |
|
19 | - throw new HTMLPurifier_VarParserException("Fatal error in evaluated code"); |
|
20 | - } |
|
21 | - return $var; |
|
22 | - } |
|
15 | + protected function evalExpression($expr) { |
|
16 | + $var = null; |
|
17 | + $result = eval("\$var = $expr;"); |
|
18 | + if ($result === false) { |
|
19 | + throw new HTMLPurifier_VarParserException("Fatal error in evaluated code"); |
|
20 | + } |
|
21 | + return $var; |
|
22 | + } |
|
23 | 23 | |
24 | 24 | } |
25 | 25 |
@@ -60,8 +60,7 @@ |
||
60 | 60 | { |
61 | 61 | $body .= $this->_makexml($arrNode); |
62 | 62 | } |
63 | - } |
|
64 | - else if(is_object($value)) |
|
63 | + } else if(is_object($value)) |
|
65 | 64 | { |
66 | 65 | $body = $this->_makexml($value); |
67 | 66 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | { |
20 | 20 | $buff = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; |
21 | 21 | |
22 | - foreach($xml as $nodeName => $nodeItem) |
|
22 | + foreach ($xml as $nodeName => $nodeItem) |
|
23 | 23 | { |
24 | 24 | $buff .= $this->_makexml($nodeItem); |
25 | 25 | } |
@@ -34,16 +34,16 @@ discard block |
||
34 | 34 | function _makexml($node) |
35 | 35 | { |
36 | 36 | $body = ''; |
37 | - foreach($node as $key => $value) |
|
37 | + foreach ($node as $key => $value) |
|
38 | 38 | { |
39 | - switch($key) |
|
39 | + switch ($key) |
|
40 | 40 | { |
41 | 41 | case 'node_name' : break; |
42 | 42 | case 'attrs' : { |
43 | 43 | $attrs = ''; |
44 | - if(isset($value)) |
|
44 | + if (isset($value)) |
|
45 | 45 | { |
46 | - foreach($value as $attrName => $attrValue) |
|
46 | + foreach ($value as $attrName => $attrValue) |
|
47 | 47 | { |
48 | 48 | $attrs .= sprintf(' %s="%s"', $attrName, htmlspecialchars($attrValue, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
49 | 49 | } |
@@ -54,21 +54,21 @@ discard block |
||
54 | 54 | $body = $value; |
55 | 55 | break; |
56 | 56 | default : { |
57 | - if(is_array($value)) |
|
57 | + if (is_array($value)) |
|
58 | 58 | { |
59 | - foreach($value as $idx => $arrNode) |
|
59 | + foreach ($value as $idx => $arrNode) |
|
60 | 60 | { |
61 | 61 | $body .= $this->_makexml($arrNode); |
62 | 62 | } |
63 | 63 | } |
64 | - else if(is_object($value)) |
|
64 | + else if (is_object($value)) |
|
65 | 65 | { |
66 | 66 | $body = $this->_makexml($value); |
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
70 | 70 | } |
71 | - return sprintf('<%s%s>%s</%s>' . "\n", $node->node_name, $attrs, $body, $node->node_name); |
|
71 | + return sprintf('<%s%s>%s</%s>'."\n", $node->node_name, $attrs, $body, $node->node_name); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | } |
@@ -102,8 +102,7 @@ |
||
102 | 102 | if(!file_exists($this->js_file)) |
103 | 103 | { |
104 | 104 | $this->_compile(); |
105 | - } |
|
106 | - else if(filemtime($this->xml_file) > filemtime($this->js_file)) |
|
105 | + } else if(filemtime($this->xml_file) > filemtime($this->js_file)) |
|
107 | 106 | { |
108 | 107 | $this->_compile(); |
109 | 108 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | function XmlJsFilter($path, $xml_file) |
83 | 83 | { |
84 | - if(substr($path, -1) !== '/') |
|
84 | + if (substr($path, -1) !== '/') |
|
85 | 85 | { |
86 | 86 | $path .= '/'; |
87 | 87 | } |
@@ -95,15 +95,15 @@ discard block |
||
95 | 95 | */ |
96 | 96 | function compile() |
97 | 97 | { |
98 | - if(!file_exists($this->xml_file)) |
|
98 | + if (!file_exists($this->xml_file)) |
|
99 | 99 | { |
100 | 100 | return; |
101 | 101 | } |
102 | - if(!file_exists($this->js_file)) |
|
102 | + if (!file_exists($this->js_file)) |
|
103 | 103 | { |
104 | 104 | $this->_compile(); |
105 | 105 | } |
106 | - else if(filemtime($this->xml_file) > filemtime($this->js_file)) |
|
106 | + else if (filemtime($this->xml_file) > filemtime($this->js_file)) |
|
107 | 107 | { |
108 | 108 | $this->_compile(); |
109 | 109 | } |
@@ -136,25 +136,25 @@ discard block |
||
136 | 136 | |
137 | 137 | |
138 | 138 | $field_node = $xml_obj->filter->form->node; |
139 | - if($field_node && !is_array($field_node)) |
|
139 | + if ($field_node && !is_array($field_node)) |
|
140 | 140 | { |
141 | 141 | $field_node = array($field_node); |
142 | 142 | } |
143 | 143 | |
144 | 144 | $parameter_param = $xml_obj->filter->parameter->param; |
145 | - if($parameter_param && !is_array($parameter_param)) |
|
145 | + if ($parameter_param && !is_array($parameter_param)) |
|
146 | 146 | { |
147 | 147 | $parameter_param = array($parameter_param); |
148 | 148 | } |
149 | 149 | |
150 | 150 | $response_tag = $xml_obj->filter->response->tag; |
151 | - if($response_tag && !is_array($response_tag)) |
|
151 | + if ($response_tag && !is_array($response_tag)) |
|
152 | 152 | { |
153 | 153 | $response_tag = array($response_tag); |
154 | 154 | } |
155 | 155 | |
156 | 156 | // If extend_filter exists, result returned by calling the method |
157 | - if($extend_filter) |
|
157 | + if ($extend_filter) |
|
158 | 158 | { |
159 | 159 | // If extend_filter exists, it changes the name of cache not to use cache |
160 | 160 | $this->js_file .= '.nocache.js'; |
@@ -163,24 +163,24 @@ discard block |
||
163 | 163 | list($module_name, $method) = explode('.', $extend_filter); |
164 | 164 | |
165 | 165 | // contibue if both module_name and methos exist. |
166 | - if($module_name && $method) |
|
166 | + if ($module_name && $method) |
|
167 | 167 | { |
168 | 168 | // get model object of the module |
169 | 169 | $oExtendFilter = getModel($module_name); |
170 | 170 | |
171 | 171 | // execute if method exists |
172 | - if(method_exists($oExtendFilter, $method)) |
|
172 | + if (method_exists($oExtendFilter, $method)) |
|
173 | 173 | { |
174 | 174 | // get the result |
175 | 175 | $extend_filter_list = $oExtendFilter->{$method}(TRUE); |
176 | 176 | $extend_filter_count = count($extend_filter_list); |
177 | 177 | |
178 | 178 | // apply lang_value from the result to the variable |
179 | - for($i = 0; $i < $extend_filter_count; $i++) |
|
179 | + for ($i = 0; $i < $extend_filter_count; $i++) |
|
180 | 180 | { |
181 | 181 | $name = $extend_filter_list[$i]->name; |
182 | 182 | $lang_value = $extend_filter_list[$i]->lang; |
183 | - if($lang_value) |
|
183 | + if ($lang_value) |
|
184 | 184 | { |
185 | 185 | $lang->{$name} = $lang_value; |
186 | 186 | } |
@@ -200,15 +200,15 @@ discard block |
||
200 | 200 | $fields = array(); |
201 | 201 | |
202 | 202 | // create custom rule |
203 | - if($rules && $rules->rule) |
|
203 | + if ($rules && $rules->rule) |
|
204 | 204 | { |
205 | - if(!is_array($rules->rule)) |
|
205 | + if (!is_array($rules->rule)) |
|
206 | 206 | { |
207 | 207 | $rules->rule = array($rules->rule); |
208 | 208 | } |
209 | - foreach($rules->rule as $r) |
|
209 | + foreach ($rules->rule as $r) |
|
210 | 210 | { |
211 | - if($r->attrs->type == 'regex') |
|
211 | + if ($r->attrs->type == 'regex') |
|
212 | 212 | { |
213 | 213 | $js_rules[] = "v.cast('ADD_RULE', ['{$r->attrs->name}', {$r->body}]);"; |
214 | 214 | } |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | |
218 | 218 | // generates a field, which is a script of the checked item |
219 | 219 | $node_count = count($field_node); |
220 | - if($node_count) |
|
220 | + if ($node_count) |
|
221 | 221 | { |
222 | - foreach($field_node as $key => $node) |
|
222 | + foreach ($field_node as $key => $node) |
|
223 | 223 | { |
224 | 224 | $attrs = $node->attrs; |
225 | 225 | $target = trim($attrs->target); |
226 | 226 | |
227 | - if(!$target) |
|
227 | + if (!$target) |
|
228 | 228 | { |
229 | 229 | continue; |
230 | 230 | } |
@@ -234,34 +234,34 @@ discard block |
||
234 | 234 | |
235 | 235 | $field = array(); |
236 | 236 | |
237 | - if($attrs->required == 'true') |
|
237 | + if ($attrs->required == 'true') |
|
238 | 238 | { |
239 | 239 | $field[] = 'required:true'; |
240 | 240 | } |
241 | - if($attrs->minlength > 0) |
|
241 | + if ($attrs->minlength > 0) |
|
242 | 242 | { |
243 | - $field[] = 'minlength:' . $attrs->minlength; |
|
243 | + $field[] = 'minlength:'.$attrs->minlength; |
|
244 | 244 | } |
245 | - if($attrs->maxlength > 0) |
|
245 | + if ($attrs->maxlength > 0) |
|
246 | 246 | { |
247 | - $field[] = 'maxlength:' . $attrs->maxlength; |
|
247 | + $field[] = 'maxlength:'.$attrs->maxlength; |
|
248 | 248 | } |
249 | - if($equalto) |
|
249 | + if ($equalto) |
|
250 | 250 | { |
251 | 251 | $field[] = "equalto:'{$attrs->equalto}'"; |
252 | 252 | } |
253 | - if($rule) |
|
253 | + if ($rule) |
|
254 | 254 | { |
255 | 255 | $field[] = "rule:'{$rule}'"; |
256 | 256 | } |
257 | 257 | |
258 | - $fields[] = "'{$target}': {" . implode(',', $field) . "}"; |
|
258 | + $fields[] = "'{$target}': {".implode(',', $field)."}"; |
|
259 | 259 | |
260 | - if(!in_array($target, $target_list)) |
|
260 | + if (!in_array($target, $target_list)) |
|
261 | 261 | { |
262 | 262 | $target_list[] = $target; |
263 | 263 | } |
264 | - if(!$target_type_list[$target]) |
|
264 | + if (!$target_type_list[$target]) |
|
265 | 265 | { |
266 | 266 | $target_type_list[$target] = $filter; |
267 | 267 | } |
@@ -271,12 +271,12 @@ discard block |
||
271 | 271 | // Check extend_filter_item |
272 | 272 | $rule_types = array('homepage' => 'homepage', 'email_address' => 'email'); |
273 | 273 | |
274 | - for($i = 0; $i < $extend_filter_count; $i++) |
|
274 | + for ($i = 0; $i < $extend_filter_count; $i++) |
|
275 | 275 | { |
276 | 276 | $filter_item = $extend_filter_list[$i]; |
277 | 277 | $target = trim($filter_item->name); |
278 | 278 | |
279 | - if(!$target) |
|
279 | + if (!$target) |
|
280 | 280 | { |
281 | 281 | continue; |
282 | 282 | } |
@@ -287,21 +287,21 @@ discard block |
||
287 | 287 | $required = ($filter_item->required == 'true'); |
288 | 288 | |
289 | 289 | $field = array(); |
290 | - if($required) |
|
290 | + if ($required) |
|
291 | 291 | { |
292 | 292 | $field[] = 'required:true'; |
293 | 293 | } |
294 | - if($rule) |
|
294 | + if ($rule) |
|
295 | 295 | { |
296 | 296 | $field[] = "rule:'{$rule}'"; |
297 | 297 | } |
298 | - $fields[] = "\t\t'{$target}' : {" . implode(',', $field) . "}"; |
|
298 | + $fields[] = "\t\t'{$target}' : {".implode(',', $field)."}"; |
|
299 | 299 | |
300 | - if(!in_array($target, $target_list)) |
|
300 | + if (!in_array($target, $target_list)) |
|
301 | 301 | { |
302 | 302 | $target_list[] = $target; |
303 | 303 | } |
304 | - if(!$target_type_list[$target]) |
|
304 | + if (!$target_type_list[$target]) |
|
305 | 305 | { |
306 | 306 | $target_type_list[$target] = $type; |
307 | 307 | } |
@@ -310,37 +310,37 @@ discard block |
||
310 | 310 | // generates parameter script to create dbata |
311 | 311 | $rename_params = array(); |
312 | 312 | $parameter_count = count($parameter_param); |
313 | - if($parameter_count) |
|
313 | + if ($parameter_count) |
|
314 | 314 | { |
315 | 315 | // contains parameter of the default filter contents |
316 | - foreach($parameter_param as $key => $param) |
|
316 | + foreach ($parameter_param as $key => $param) |
|
317 | 317 | { |
318 | 318 | $attrs = $param->attrs; |
319 | 319 | $name = trim($attrs->name); |
320 | 320 | $target = trim($attrs->target); |
321 | 321 | |
322 | 322 | //if($name && $target && ($name != $target)) $js_doc[] = "\t\tparams['{$name}'] = params['{$target}']; delete params['{$target}'];"; |
323 | - if($name && $target && ($name != $target)) |
|
323 | + if ($name && $target && ($name != $target)) |
|
324 | 324 | { |
325 | 325 | $rename_params[] = "'{$target}':'{$name}'"; |
326 | 326 | } |
327 | - if($name && !in_array($name, $target_list)) |
|
327 | + if ($name && !in_array($name, $target_list)) |
|
328 | 328 | { |
329 | 329 | $target_list[] = $name; |
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
333 | 333 | // Check extend_filter_item |
334 | - for($i = 0; $i < $extend_filter_count; $i++) |
|
334 | + for ($i = 0; $i < $extend_filter_count; $i++) |
|
335 | 335 | { |
336 | 336 | $filter_item = $extend_filter_list[$i]; |
337 | 337 | $target = $name = trim($filter_item->name); |
338 | - if(!$name || !$target) |
|
338 | + if (!$name || !$target) |
|
339 | 339 | { |
340 | 340 | continue; |
341 | 341 | } |
342 | 342 | |
343 | - if(!in_array($name, $target_list)) |
|
343 | + if (!in_array($name, $target_list)) |
|
344 | 344 | { |
345 | 345 | $target_list[] = $name; |
346 | 346 | } |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | // generates the response script |
351 | 351 | $response_count = count($response_tag); |
352 | 352 | $responses = array(); |
353 | - for($i = 0; $i < $response_count; $i++) |
|
353 | + for ($i = 0; $i < $response_count; $i++) |
|
354 | 354 | { |
355 | 355 | $attrs = $response_tag[$i]->attrs; |
356 | 356 | $name = $attrs->name; |
@@ -359,10 +359,10 @@ discard block |
||
359 | 359 | |
360 | 360 | // writes lang values of the form field |
361 | 361 | $target_count = count($target_list); |
362 | - for($i = 0; $i < $target_count; $i++) |
|
362 | + for ($i = 0; $i < $target_count; $i++) |
|
363 | 363 | { |
364 | 364 | $target = $target_list[$i]; |
365 | - if(!$lang->{$target}) |
|
365 | + if (!$lang->{$target}) |
|
366 | 366 | { |
367 | 367 | $lang->{$target} = $target; |
368 | 368 | } |
@@ -381,9 +381,9 @@ discard block |
||
381 | 381 | */ |
382 | 382 | |
383 | 383 | // writes error messages |
384 | - foreach($lang->filter as $key => $val) |
|
384 | + foreach ($lang->filter as $key => $val) |
|
385 | 385 | { |
386 | - if(!$val) |
|
386 | + if (!$val) |
|
387 | 387 | { |
388 | 388 | $val = $key; |
389 | 389 | } |
@@ -392,24 +392,24 @@ discard block |
||
392 | 392 | } |
393 | 393 | |
394 | 394 | $callback_func = $xml_obj->filter->response->attrs->callback_func; |
395 | - if(!$callback_func) |
|
395 | + if (!$callback_func) |
|
396 | 396 | { |
397 | 397 | $callback_func = "filterAlertMessage"; |
398 | 398 | } |
399 | 399 | |
400 | 400 | $confirm_msg = ''; |
401 | - if($confirm_msg_code) |
|
401 | + if ($confirm_msg_code) |
|
402 | 402 | { |
403 | 403 | $confirm_msg = $lang->{$confirm_msg_code}; |
404 | 404 | } |
405 | 405 | |
406 | 406 | $jsdoc = array(); |
407 | - $jsdoc[] = "function {$filter_name}(form){ return legacy_filter('{$filter_name}', form, '{$module}', '{$act}', {$callback_func}, [" . implode(',', $responses) . "], '" . addslashes($confirm_msg) . "', {" . implode(',', $rename_params) . "}) };"; |
|
407 | + $jsdoc[] = "function {$filter_name}(form){ return legacy_filter('{$filter_name}', form, '{$module}', '{$act}', {$callback_func}, [".implode(',', $responses)."], '".addslashes($confirm_msg)."', {".implode(',', $rename_params)."}) };"; |
|
408 | 408 | $jsdoc[] = '(function($){'; |
409 | 409 | $jsdoc[] = "\tvar v=xe.getApp('validator')[0];if(!v)return false;"; |
410 | - $jsdoc[] = "\t" . 'v.cast("ADD_FILTER", ["' . $filter_name . '", {' . implode(',', $fields) . '}]);'; |
|
411 | - $jsdoc[] = "\t" . implode("\n\t", $js_rules); |
|
412 | - $jsdoc[] = "\t" . implode("\n\t", $js_messages); |
|
410 | + $jsdoc[] = "\t".'v.cast("ADD_FILTER", ["'.$filter_name.'", {'.implode(',', $fields).'}]);'; |
|
411 | + $jsdoc[] = "\t".implode("\n\t", $js_rules); |
|
412 | + $jsdoc[] = "\t".implode("\n\t", $js_messages); |
|
413 | 413 | $jsdoc[] = '})(jQuery);'; |
414 | 414 | $jsdoc = implode("\n", $jsdoc); |
415 | 415 | |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | */ |
425 | 425 | function _getCompiledFileName($xml_file) |
426 | 426 | { |
427 | - return sprintf('%s%s.%s.compiled.js', $this->compiled_path, md5($this->version . $xml_file), Context::getLangType()); |
|
427 | + return sprintf('%s%s.%s.compiled.js', $this->compiled_path, md5($this->version.$xml_file), Context::getLangType()); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | } |
@@ -85,8 +85,7 @@ discard block |
||
85 | 85 | if(strpos($name, '.') === FALSE) |
86 | 86 | { |
87 | 87 | $this->column_name = $name; |
88 | - } |
|
89 | - else |
|
88 | + } else |
|
90 | 89 | { |
91 | 90 | list($prefix, $name) = explode('.', $name); |
92 | 91 | $this->column_name = $name; |
@@ -159,8 +158,7 @@ discard block |
||
159 | 158 | , $this->argument_name |
160 | 159 | , $this->argument_name |
161 | 160 | ); |
162 | - } |
|
163 | - else |
|
161 | + } else |
|
164 | 162 | { |
165 | 163 | $arg = sprintf("\n" . '${\'%s_argument\'} = new Argument(\'%s\', %s);' . "\n" |
166 | 164 | , $this->argument_name |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | static $number_of_arguments = 0; |
64 | 64 | |
65 | 65 | $this->argument_name = $tag->attrs->var; |
66 | - if(!$this->argument_name) |
|
66 | + if (!$this->argument_name) |
|
67 | 67 | { |
68 | 68 | $this->argument_name = str_replace('.', '_', $tag->attrs->name); |
69 | 69 | } |
70 | - if(!$this->argument_name) |
|
70 | + if (!$this->argument_name) |
|
71 | 71 | { |
72 | 72 | $this->argument_name = str_replace('.', '_', $tag->attrs->column); |
73 | 73 | } |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | $this->argument_name .= $number_of_arguments; |
79 | 79 | |
80 | 80 | $name = $tag->attrs->name; |
81 | - if(!$name) |
|
81 | + if (!$name) |
|
82 | 82 | { |
83 | 83 | $name = $tag->attrs->column; |
84 | 84 | } |
85 | - if(strpos($name, '.') === FALSE) |
|
85 | + if (strpos($name, '.') === FALSE) |
|
86 | 86 | { |
87 | 87 | $this->column_name = $name; |
88 | 88 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $this->table_name = $prefix; |
94 | 94 | } |
95 | 95 | |
96 | - if($tag->attrs->operation) |
|
96 | + if ($tag->attrs->operation) |
|
97 | 97 | { |
98 | 98 | $this->operation = $tag->attrs->operation; |
99 | 99 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | function isConditionArgument() |
126 | 126 | { |
127 | - if($this->operation) |
|
127 | + if ($this->operation) |
|
128 | 128 | { |
129 | 129 | return TRUE; |
130 | 130 | } |
@@ -137,50 +137,50 @@ discard block |
||
137 | 137 | */ |
138 | 138 | function toString() |
139 | 139 | { |
140 | - if($this->isConditionArgument()) |
|
140 | + if ($this->isConditionArgument()) |
|
141 | 141 | { |
142 | 142 | // Instantiation |
143 | - $arg = sprintf("\n" . '${\'%s_argument\'} = new ConditionArgument(\'%s\', %s, \'%s\');' . "\n" |
|
143 | + $arg = sprintf("\n".'${\'%s_argument\'} = new ConditionArgument(\'%s\', %s, \'%s\');'."\n" |
|
144 | 144 | , $this->argument_name |
145 | 145 | , $this->variable_name |
146 | - , '$args->' . $this->variable_name |
|
146 | + , '$args->'.$this->variable_name |
|
147 | 147 | , $this->operation |
148 | 148 | ); |
149 | 149 | // Call methods to validate argument and ensure default value |
150 | 150 | $arg .= $this->argument_validator->toString(); |
151 | 151 | |
152 | 152 | // Prepare condition string |
153 | - $arg .= sprintf('${\'%s_argument\'}->createConditionValue();' . "\n" |
|
153 | + $arg .= sprintf('${\'%s_argument\'}->createConditionValue();'."\n" |
|
154 | 154 | , $this->argument_name |
155 | 155 | ); |
156 | 156 | |
157 | 157 | // Check that argument passed validation, else return |
158 | - $arg .= sprintf('if(!${\'%s_argument\'}->isValid()) return ${\'%s_argument\'}->getErrorMessage();' . "\n" |
|
158 | + $arg .= sprintf('if(!${\'%s_argument\'}->isValid()) return ${\'%s_argument\'}->getErrorMessage();'."\n" |
|
159 | 159 | , $this->argument_name |
160 | 160 | , $this->argument_name |
161 | 161 | ); |
162 | 162 | } |
163 | 163 | else |
164 | 164 | { |
165 | - $arg = sprintf("\n" . '${\'%s_argument\'} = new Argument(\'%s\', %s);' . "\n" |
|
165 | + $arg = sprintf("\n".'${\'%s_argument\'} = new Argument(\'%s\', %s);'."\n" |
|
166 | 166 | , $this->argument_name |
167 | 167 | , $this->variable_name |
168 | - , $this->ignore_value ? 'NULL' : '$args->{\'' . $this->variable_name . '\'}'); |
|
168 | + , $this->ignore_value ? 'NULL' : '$args->{\''.$this->variable_name.'\'}'); |
|
169 | 169 | |
170 | 170 | $arg .= $this->argument_validator->toString(); |
171 | 171 | |
172 | - $arg .= sprintf('if(!${\'%s_argument\'}->isValid()) return ${\'%s_argument\'}->getErrorMessage();' . "\n" |
|
172 | + $arg .= sprintf('if(!${\'%s_argument\'}->isValid()) return ${\'%s_argument\'}->getErrorMessage();'."\n" |
|
173 | 173 | , $this->argument_name |
174 | 174 | , $this->argument_name |
175 | 175 | ); |
176 | 176 | } |
177 | 177 | |
178 | 178 | // If the argument is null, skip it |
179 | - if($this->argument_validator->isIgnorable()) |
|
179 | + if ($this->argument_validator->isIgnorable()) |
|
180 | 180 | { |
181 | - $arg = sprintf("if(isset(%s)) {", '$args->' . $this->variable_name) |
|
181 | + $arg = sprintf("if(isset(%s)) {", '$args->'.$this->variable_name) |
|
182 | 182 | . $arg |
183 | - . sprintf("} else\n" . '${\'%s_argument\'} = NULL;', $this->argument_name); |
|
183 | + . sprintf("} else\n".'${\'%s_argument\'} = NULL;', $this->argument_name); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | return $arg; |
@@ -107,8 +107,9 @@ |
||
107 | 107 | if(isset($this->default_value)) |
108 | 108 | { |
109 | 109 | $this->default_value = new DefaultValue($this->argument_name, $this->default_value); |
110 | - if($this->default_value->isSequence()) |
|
111 | - $validator .= '$db = DB::getInstance(); $sequence = $db->getNextSequence(); '; |
|
110 | + if($this->default_value->isSequence()) { |
|
111 | + $validator .= '$db = DB::getInstance(); $sequence = $db->getNextSequence(); '; |
|
112 | + } |
|
112 | 113 | if($this->default_value->isOperation()) |
113 | 114 | { |
114 | 115 | $validator .= sprintf('${\'%s_argument\'}->setColumnOperation(\'%s\');' . "\n" |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | function isIgnorable() |
75 | 75 | { |
76 | - if(isset($this->default_value) || isset($this->notnull)) |
|
76 | + if (isset($this->default_value) || isset($this->notnull)) |
|
77 | 77 | { |
78 | 78 | return FALSE; |
79 | 79 | } |
@@ -83,47 +83,47 @@ discard block |
||
83 | 83 | function toString() |
84 | 84 | { |
85 | 85 | $validator = ''; |
86 | - if($this->filter) |
|
86 | + if ($this->filter) |
|
87 | 87 | { |
88 | - $validator .= sprintf('${\'%s_argument\'}->checkFilter(\'%s\');' . "\n" |
|
88 | + $validator .= sprintf('${\'%s_argument\'}->checkFilter(\'%s\');'."\n" |
|
89 | 89 | , $this->argument_name |
90 | 90 | , $this->filter |
91 | 91 | ); |
92 | 92 | } |
93 | - if($this->min_length) |
|
93 | + if ($this->min_length) |
|
94 | 94 | { |
95 | - $validator .= sprintf('${\'%s_argument\'}->checkMinLength(%s);' . "\n" |
|
95 | + $validator .= sprintf('${\'%s_argument\'}->checkMinLength(%s);'."\n" |
|
96 | 96 | , $this->argument_name |
97 | 97 | , $this->min_length |
98 | 98 | ); |
99 | 99 | } |
100 | - if($this->max_length) |
|
100 | + if ($this->max_length) |
|
101 | 101 | { |
102 | - $validator .= sprintf('${\'%s_argument\'}->checkMaxLength(%s);' . "\n" |
|
102 | + $validator .= sprintf('${\'%s_argument\'}->checkMaxLength(%s);'."\n" |
|
103 | 103 | , $this->argument_name |
104 | 104 | , $this->max_length |
105 | 105 | ); |
106 | 106 | } |
107 | - if(isset($this->default_value)) |
|
107 | + if (isset($this->default_value)) |
|
108 | 108 | { |
109 | 109 | $this->default_value = new DefaultValue($this->argument_name, $this->default_value); |
110 | - if($this->default_value->isSequence()) |
|
110 | + if ($this->default_value->isSequence()) |
|
111 | 111 | $validator .= '$db = DB::getInstance(); $sequence = $db->getNextSequence(); '; |
112 | - if($this->default_value->isOperation()) |
|
112 | + if ($this->default_value->isOperation()) |
|
113 | 113 | { |
114 | - $validator .= sprintf('${\'%s_argument\'}->setColumnOperation(\'%s\');' . "\n" |
|
114 | + $validator .= sprintf('${\'%s_argument\'}->setColumnOperation(\'%s\');'."\n" |
|
115 | 115 | , $this->argument_name |
116 | 116 | , $this->default_value->getOperation() |
117 | 117 | ); |
118 | 118 | } |
119 | - $validator .= sprintf('${\'%s_argument\'}->ensureDefaultValue(%s);' . "\n" |
|
119 | + $validator .= sprintf('${\'%s_argument\'}->ensureDefaultValue(%s);'."\n" |
|
120 | 120 | , $this->argument_name |
121 | 121 | , $this->default_value->toString() |
122 | 122 | ); |
123 | 123 | } |
124 | - if($this->notnull) |
|
124 | + if ($this->notnull) |
|
125 | 125 | { |
126 | - $validator .= sprintf('${\'%s_argument\'}->checkNotNull();' . "\n" |
|
126 | + $validator .= sprintf('${\'%s_argument\'}->checkNotNull();'."\n" |
|
127 | 127 | , $this->argument_name |
128 | 128 | ); |
129 | 129 | } |