@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | function __construct($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 | } |
@@ -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; |
@@ -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 |
@@ -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 | } |
@@ -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" |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | return $this->_is_string; |
72 | 72 | $str_pos = strpos($this->value, '('); |
73 | - if($str_pos === false) |
|
73 | + if ($str_pos === false) |
|
74 | 74 | { |
75 | 75 | return TRUE; |
76 | 76 | } |
@@ -99,31 +99,31 @@ discard block |
||
99 | 99 | |
100 | 100 | function _setValue() |
101 | 101 | { |
102 | - if(!isset($this->value)) |
|
102 | + if (!isset($this->value)) |
|
103 | 103 | { |
104 | 104 | return; |
105 | 105 | } |
106 | 106 | |
107 | 107 | // If value contains comma separated values and does not contain paranthesis |
108 | 108 | // -> default value is an array |
109 | - if(strpos($this->value, ',') !== FALSE && strpos($this->value, '(') === FALSE) |
|
109 | + if (strpos($this->value, ',') !== FALSE && strpos($this->value, '(') === FALSE) |
|
110 | 110 | { |
111 | 111 | return sprintf('array(%s)', $this->value); |
112 | 112 | } |
113 | 113 | |
114 | 114 | $str_pos = strpos($this->value, '('); |
115 | 115 | // // TODO Replace this with parseExpression |
116 | - if($str_pos === FALSE) |
|
116 | + if ($str_pos === FALSE) |
|
117 | 117 | { |
118 | 118 | $this->_is_string = TRUE; |
119 | - return '\'' . $this->value . '\''; |
|
119 | + return '\''.$this->value.'\''; |
|
120 | 120 | } |
121 | 121 | //if($str_pos===false) return $this->value; |
122 | 122 | |
123 | 123 | $func_name = substr($this->value, 0, $str_pos); |
124 | 124 | $args = substr($this->value, $str_pos + 1, -1); |
125 | 125 | |
126 | - switch($func_name) |
|
126 | + switch ($func_name) |
|
127 | 127 | { |
128 | 128 | case 'ipaddress' : |
129 | 129 | $val = '$_SERVER[\'REMOTE_ADDR\']'; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $val = sprintf('%d', $args); |
160 | 160 | break; |
161 | 161 | default : |
162 | - $val = '\'' . $this->value . '\''; |
|
162 | + $val = '\''.$this->value.'\''; |
|
163 | 163 | //$val = $this->value; |
164 | 164 | } |
165 | 165 |
@@ -26,19 +26,19 @@ discard block |
||
26 | 26 | { |
27 | 27 | $this->groups = array(); |
28 | 28 | |
29 | - if($xml_groups) |
|
29 | + if ($xml_groups) |
|
30 | 30 | { |
31 | - if(!is_array($xml_groups)) |
|
31 | + if (!is_array($xml_groups)) |
|
32 | 32 | { |
33 | 33 | $xml_groups = array($xml_groups); |
34 | 34 | } |
35 | 35 | |
36 | 36 | $dbParser = &DB::getParser(); |
37 | - for($i = 0; $i < count($xml_groups); $i++) |
|
37 | + for ($i = 0; $i < count($xml_groups); $i++) |
|
38 | 38 | { |
39 | 39 | $group = $xml_groups[$i]; |
40 | 40 | $column = trim($group->attrs->column); |
41 | - if(!$column) |
|
41 | + if (!$column) |
|
42 | 42 | { |
43 | 43 | continue; |
44 | 44 | } |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | |
52 | 52 | function toString() |
53 | 53 | { |
54 | - $output = 'array(' . PHP_EOL; |
|
55 | - foreach($this->groups as $group) |
|
54 | + $output = 'array('.PHP_EOL; |
|
55 | + foreach ($this->groups as $group) |
|
56 | 56 | { |
57 | - $output .= "'" . $group . "' ,"; |
|
57 | + $output .= "'".$group."' ,"; |
|
58 | 58 | } |
59 | 59 | $output = substr($output, 0, -1); |
60 | 60 | $output .= ')'; |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | { |
34 | 34 | $this->pipe = $pipe; |
35 | 35 | |
36 | - if(!is_array($conditions)) |
|
36 | + if (!is_array($conditions)) |
|
37 | 37 | { |
38 | 38 | $conditions = array($conditions); |
39 | 39 | } |
40 | 40 | |
41 | - foreach($conditions as $condition) |
|
41 | + foreach ($conditions as $condition) |
|
42 | 42 | { |
43 | 43 | //if($condition->node_name === 'query') $this->conditions[] = new QueryTag($condition, true); |
44 | 44 | $this->conditions[] = new ConditionTag($condition); |
@@ -56,21 +56,21 @@ discard block |
||
56 | 56 | */ |
57 | 57 | function getConditionGroupString() |
58 | 58 | { |
59 | - $conditions_string = 'array(' . PHP_EOL; |
|
60 | - foreach($this->conditions as $condition) |
|
59 | + $conditions_string = 'array('.PHP_EOL; |
|
60 | + foreach ($this->conditions as $condition) |
|
61 | 61 | { |
62 | - $conditions_string .= $condition->getConditionString() . PHP_EOL . ','; |
|
62 | + $conditions_string .= $condition->getConditionString().PHP_EOL.','; |
|
63 | 63 | } |
64 | 64 | $conditions_string = substr($conditions_string, 0, -2); //remove ',' |
65 | 65 | $conditions_string .= ')'; |
66 | 66 | |
67 | - return sprintf("new ConditionGroup(%s%s)", $conditions_string, $this->pipe ? ',\'' . $this->pipe . '\'' : ''); |
|
67 | + return sprintf("new ConditionGroup(%s%s)", $conditions_string, $this->pipe ? ',\''.$this->pipe.'\'' : ''); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | function getArguments() |
71 | 71 | { |
72 | 72 | $arguments = array(); |
73 | - foreach($this->conditions as $condition) |
|
73 | + foreach ($this->conditions as $condition) |
|
74 | 74 | { |
75 | 75 | $arguments = array_merge($arguments, $condition->getArguments()); |
76 | 76 | } |
@@ -67,38 +67,38 @@ discard block |
||
67 | 67 | $this->column_name = $dbParser->parseExpression($condition->attrs->column); |
68 | 68 | |
69 | 69 | // If default value is column name, it should be escaped |
70 | - if($isColumnName = (strpos($condition->attrs->default, '.') !== FALSE |
|
70 | + if ($isColumnName = (strpos($condition->attrs->default, '.') !== FALSE |
|
71 | 71 | && strpos($condition->attrs->default, '.') !== 0 |
72 | - && strpos($condition->attrs->default, '%') === FALSE )) |
|
72 | + && strpos($condition->attrs->default, '%') === FALSE)) |
|
73 | 73 | { |
74 | 74 | $condition->attrs->default = $dbParser->parseExpression($condition->attrs->default); |
75 | 75 | } |
76 | 76 | |
77 | - if($condition->node_name == 'query') |
|
77 | + if ($condition->node_name == 'query') |
|
78 | 78 | { |
79 | 79 | $this->query = new QueryTag($condition, TRUE); |
80 | 80 | $this->default_column = $this->query->toString(); |
81 | 81 | } |
82 | - else if($condition->attrs->var && !strpos($condition->attrs->var, '.')) |
|
82 | + else if ($condition->attrs->var && !strpos($condition->attrs->var, '.')) |
|
83 | 83 | { |
84 | 84 | $this->argument = new QueryArgument($condition); |
85 | 85 | $this->argument_name = $this->argument->getArgumentName(); |
86 | 86 | } |
87 | 87 | else |
88 | 88 | { |
89 | - if(isset($condition->attrs->default)) |
|
89 | + if (isset($condition->attrs->default)) |
|
90 | 90 | { |
91 | 91 | $operationList = array('in' => 1, 'between' => 1, 'notin' => 1, 'not_in' => 1); |
92 | - if(isset($operationList[$this->operation])) |
|
92 | + if (isset($operationList[$this->operation])) |
|
93 | 93 | { |
94 | 94 | $default_value = $condition->attrs->default; |
95 | - if(strpos($default_value, "'") !== FALSE) |
|
95 | + if (strpos($default_value, "'") !== FALSE) |
|
96 | 96 | { |
97 | - $default_value = "\"" . $default_value . "\""; |
|
97 | + $default_value = "\"".$default_value."\""; |
|
98 | 98 | } |
99 | 99 | else |
100 | 100 | { |
101 | - $default_value = "'" . $default_value . "'"; |
|
101 | + $default_value = "'".$default_value."'"; |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | else |
@@ -106,20 +106,20 @@ discard block |
||
106 | 106 | $default_value_object = new DefaultValue($this->column_name, $condition->attrs->default); |
107 | 107 | $default_value = $default_value_object->toString(); |
108 | 108 | |
109 | - if($default_value_object->isStringFromFunction()) |
|
109 | + if ($default_value_object->isStringFromFunction()) |
|
110 | 110 | { |
111 | - $default_value = '"\'".' . $default_value . '."\'"'; |
|
111 | + $default_value = '"\'".'.$default_value.'."\'"'; |
|
112 | 112 | } |
113 | 113 | |
114 | - if($default_value_object->isString() && !$isColumnName && !is_numeric($condition->attrs->default)) |
|
114 | + if ($default_value_object->isString() && !$isColumnName && !is_numeric($condition->attrs->default)) |
|
115 | 115 | { |
116 | - if(strpos($default_value, "'") !== FALSE) |
|
116 | + if (strpos($default_value, "'") !== FALSE) |
|
117 | 117 | { |
118 | - $default_value = "\"" . $default_value . "\""; |
|
118 | + $default_value = "\"".$default_value."\""; |
|
119 | 119 | } |
120 | 120 | else |
121 | 121 | { |
122 | - $default_value = "'" . $default_value . "'"; |
|
122 | + $default_value = "'".$default_value."'"; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | else |
129 | 129 | { |
130 | - $this->default_column = "'" . $dbParser->parseColumnName($condition->attrs->var) . "'"; |
|
130 | + $this->default_column = "'".$dbParser->parseColumnName($condition->attrs->var)."'"; |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | } |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | function getArguments() |
141 | 141 | { |
142 | 142 | $arguments = array(); |
143 | - if($this->query) |
|
143 | + if ($this->query) |
|
144 | 144 | { |
145 | 145 | $arguments = array_merge($arguments, $this->query->getArguments()); |
146 | 146 | } |
147 | - if($this->argument) |
|
147 | + if ($this->argument) |
|
148 | 148 | { |
149 | 149 | $arguments[] = $this->argument; |
150 | 150 | } |
@@ -153,31 +153,31 @@ discard block |
||
153 | 153 | |
154 | 154 | function getConditionString() |
155 | 155 | { |
156 | - if($this->query) |
|
156 | + if ($this->query) |
|
157 | 157 | { |
158 | 158 | return sprintf("new ConditionSubquery('%s',%s,%s%s)" |
159 | 159 | , $this->column_name |
160 | 160 | , $this->default_column |
161 | - , '"' . $this->operation . '"' |
|
162 | - , $this->pipe ? ", '" . $this->pipe . "'" : '' |
|
161 | + , '"'.$this->operation.'"' |
|
162 | + , $this->pipe ? ", '".$this->pipe."'" : '' |
|
163 | 163 | ); |
164 | 164 | } |
165 | - else if(isset($this->default_column)) |
|
165 | + else if (isset($this->default_column)) |
|
166 | 166 | { |
167 | 167 | return sprintf("new ConditionWithoutArgument('%s',%s,%s%s)" |
168 | 168 | , $this->column_name |
169 | 169 | , $this->default_column |
170 | - , '"' . $this->operation . '"' |
|
171 | - , $this->pipe ? ", '" . $this->pipe . "'" : '' |
|
170 | + , '"'.$this->operation.'"' |
|
171 | + , $this->pipe ? ", '".$this->pipe."'" : '' |
|
172 | 172 | ); |
173 | 173 | } |
174 | 174 | else |
175 | 175 | { |
176 | 176 | return sprintf("new ConditionWithArgument('%s',%s,%s%s)" |
177 | 177 | , $this->column_name |
178 | - , '$' . $this->argument_name . '_argument' |
|
179 | - , '"' . $this->operation . '"' |
|
180 | - , $this->pipe ? ", '" . $this->pipe . "'" : '' |
|
178 | + , '$'.$this->argument_name.'_argument' |
|
179 | + , '"'.$this->operation.'"' |
|
180 | + , $this->pipe ? ", '".$this->pipe."'" : '' |
|
181 | 181 | ); |
182 | 182 | } |
183 | 183 | } |
@@ -78,13 +78,11 @@ discard block |
||
78 | 78 | { |
79 | 79 | $this->query = new QueryTag($condition, TRUE); |
80 | 80 | $this->default_column = $this->query->toString(); |
81 | - } |
|
82 | - else if($condition->attrs->var && !strpos($condition->attrs->var, '.')) |
|
81 | + } else if($condition->attrs->var && !strpos($condition->attrs->var, '.')) |
|
83 | 82 | { |
84 | 83 | $this->argument = new QueryArgument($condition); |
85 | 84 | $this->argument_name = $this->argument->getArgumentName(); |
86 | - } |
|
87 | - else |
|
85 | + } else |
|
88 | 86 | { |
89 | 87 | if(isset($condition->attrs->default)) |
90 | 88 | { |
@@ -95,13 +93,11 @@ discard block |
||
95 | 93 | if(strpos($default_value, "'") !== FALSE) |
96 | 94 | { |
97 | 95 | $default_value = "\"" . $default_value . "\""; |
98 | - } |
|
99 | - else |
|
96 | + } else |
|
100 | 97 | { |
101 | 98 | $default_value = "'" . $default_value . "'"; |
102 | 99 | } |
103 | - } |
|
104 | - else |
|
100 | + } else |
|
105 | 101 | { |
106 | 102 | $default_value_object = new DefaultValue($this->column_name, $condition->attrs->default); |
107 | 103 | $default_value = $default_value_object->toString(); |
@@ -116,16 +112,14 @@ discard block |
||
116 | 112 | if(strpos($default_value, "'") !== FALSE) |
117 | 113 | { |
118 | 114 | $default_value = "\"" . $default_value . "\""; |
119 | - } |
|
120 | - else |
|
115 | + } else |
|
121 | 116 | { |
122 | 117 | $default_value = "'" . $default_value . "'"; |
123 | 118 | } |
124 | 119 | } |
125 | 120 | } |
126 | 121 | $this->default_column = $default_value; |
127 | - } |
|
128 | - else |
|
122 | + } else |
|
129 | 123 | { |
130 | 124 | $this->default_column = "'" . $dbParser->parseColumnName($condition->attrs->var) . "'"; |
131 | 125 | } |
@@ -161,8 +155,7 @@ discard block |
||
161 | 155 | , '"' . $this->operation . '"' |
162 | 156 | , $this->pipe ? ", '" . $this->pipe . "'" : '' |
163 | 157 | ); |
164 | - } |
|
165 | - else if(isset($this->default_column)) |
|
158 | + } else if(isset($this->default_column)) |
|
166 | 159 | { |
167 | 160 | return sprintf("new ConditionWithoutArgument('%s',%s,%s%s)" |
168 | 161 | , $this->column_name |
@@ -170,8 +163,7 @@ discard block |
||
170 | 163 | , '"' . $this->operation . '"' |
171 | 164 | , $this->pipe ? ", '" . $this->pipe . "'" : '' |
172 | 165 | ); |
173 | - } |
|
174 | - else |
|
166 | + } else |
|
175 | 167 | { |
176 | 168 | return sprintf("new ConditionWithArgument('%s',%s,%s%s)" |
177 | 169 | , $this->column_name |
@@ -25,42 +25,42 @@ discard block |
||
25 | 25 | function __construct($xml_conditions) |
26 | 26 | { |
27 | 27 | $this->condition_groups = array(); |
28 | - if(!$xml_conditions) |
|
28 | + if (!$xml_conditions) |
|
29 | 29 | { |
30 | 30 | return; |
31 | 31 | } |
32 | 32 | |
33 | 33 | $xml_condition_list = array(); |
34 | - if($xml_conditions->condition) |
|
34 | + if ($xml_conditions->condition) |
|
35 | 35 | { |
36 | 36 | $xml_condition_list = $xml_conditions->condition; |
37 | 37 | } |
38 | 38 | |
39 | - if($xml_conditions->query) |
|
39 | + if ($xml_conditions->query) |
|
40 | 40 | { |
41 | - if(!is_array($xml_condition_list)) |
|
41 | + if (!is_array($xml_condition_list)) |
|
42 | 42 | { |
43 | 43 | $xml_condition_list = array($xml_condition_list); |
44 | 44 | } |
45 | - if(!is_array($xml_conditions->query)) |
|
45 | + if (!is_array($xml_conditions->query)) |
|
46 | 46 | { |
47 | 47 | $xml_conditions->query = array($xml_conditions->query); |
48 | 48 | } |
49 | 49 | $xml_condition_list = array_merge($xml_condition_list, $xml_conditions->query); |
50 | 50 | } |
51 | - if($xml_condition_list) |
|
51 | + if ($xml_condition_list) |
|
52 | 52 | { |
53 | 53 | $this->condition_groups[] = new ConditionGroupTag($xml_condition_list); |
54 | 54 | } |
55 | 55 | |
56 | 56 | $xml_groups = $xml_conditions->group; |
57 | - if($xml_groups) |
|
57 | + if ($xml_groups) |
|
58 | 58 | { |
59 | - if(!is_array($xml_groups)) |
|
59 | + if (!is_array($xml_groups)) |
|
60 | 60 | { |
61 | 61 | $xml_groups = array($xml_groups); |
62 | 62 | } |
63 | - foreach($xml_groups as $group) |
|
63 | + foreach ($xml_groups as $group) |
|
64 | 64 | { |
65 | 65 | $this->condition_groups[] = new ConditionGroupTag($group->condition, $group->attrs->pipe); |
66 | 66 | } |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | */ |
74 | 74 | function toString() |
75 | 75 | { |
76 | - $output_conditions = 'array(' . PHP_EOL; |
|
77 | - foreach($this->condition_groups as $condition) |
|
76 | + $output_conditions = 'array('.PHP_EOL; |
|
77 | + foreach ($this->condition_groups as $condition) |
|
78 | 78 | { |
79 | - $output_conditions .= $condition->getConditionGroupString() . PHP_EOL . ','; |
|
79 | + $output_conditions .= $condition->getConditionGroupString().PHP_EOL.','; |
|
80 | 80 | } |
81 | 81 | $output_conditions = substr($output_conditions, 0, -1); |
82 | 82 | $output_conditions .= ')'; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | function getArguments() |
87 | 87 | { |
88 | 88 | $arguments = array(); |
89 | - foreach($this->condition_groups as $condition) |
|
89 | + foreach ($this->condition_groups as $condition) |
|
90 | 90 | { |
91 | 91 | $arguments = array_merge($arguments, $condition->getArguments()); |
92 | 92 | } |
@@ -59,18 +59,18 @@ discard block |
||
59 | 59 | // Sort order - asc / desc |
60 | 60 | $this->sort_order = $index->attrs->order; |
61 | 61 | $sortList = array('asc' => 1, 'desc' => 1); |
62 | - if(!isset($sortList[$this->sort_order])) |
|
62 | + if (!isset($sortList[$this->sort_order])) |
|
63 | 63 | { |
64 | 64 | $arg = new Xml_Node_(); |
65 | 65 | $arg->attrs = new Xml_Node_(); |
66 | 66 | $arg->attrs->var = $this->sort_order; |
67 | 67 | $arg->attrs->default = 'asc'; |
68 | 68 | $this->sort_order_argument = new SortQueryArgument($arg); |
69 | - $this->sort_order = '$' . $this->sort_order_argument->getArgumentName() . '_argument'; |
|
69 | + $this->sort_order = '$'.$this->sort_order_argument->getArgumentName().'_argument'; |
|
70 | 70 | } |
71 | 71 | else |
72 | 72 | { |
73 | - $this->sort_order = '"' . $this->sort_order . '"'; |
|
73 | + $this->sort_order = '"'.$this->sort_order.'"'; |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | { |
84 | 84 | $arguments = array(); |
85 | 85 | $arguments[] = $this->argument; |
86 | - if($this->sort_order_argument) |
|
86 | + if ($this->sort_order_argument) |
|
87 | 87 | { |
88 | 88 | $arguments[] = $this->sort_order_argument; |
89 | 89 | } |
@@ -67,8 +67,7 @@ |
||
67 | 67 | $arg->attrs->default = 'asc'; |
68 | 68 | $this->sort_order_argument = new SortQueryArgument($arg); |
69 | 69 | $this->sort_order = '$' . $this->sort_order_argument->getArgumentName() . '_argument'; |
70 | - } |
|
71 | - else |
|
70 | + } else |
|
72 | 71 | { |
73 | 72 | $this->sort_order = '"' . $this->sort_order . '"'; |
74 | 73 | } |