@@ -89,7 +89,10 @@ discard block |
||
| 89 | 89 | public function beforeSendToClient($cname, array $expand=null) |
| 90 | 90 | { |
| 91 | 91 | // No name, no way to get parameters client-side. |
| 92 | - if(!$this->id) $this->id = self::GLOBAL_ID; |
|
| 92 | + if(!$this->id) |
|
| 93 | + { |
|
| 94 | + $this->id = self::GLOBAL_ID; |
|
| 95 | + } |
|
| 93 | 96 | |
| 94 | 97 | $form_name = self::form_name($cname, $this->id, $expand); |
| 95 | 98 | |
@@ -188,7 +191,10 @@ discard block |
||
| 188 | 191 | $form_name = self::$prefix.$name; |
| 189 | 192 | } |
| 190 | 193 | |
| 191 | - if(!is_array($fields)) $fields = array(); |
|
| 194 | + if(!is_array($fields)) |
|
| 195 | + { |
|
| 196 | + $fields = array(); |
|
| 197 | + } |
|
| 192 | 198 | switch($type = $this->type) |
| 193 | 199 | { |
| 194 | 200 | case 'customfields-types': |
@@ -213,11 +219,18 @@ discard block |
||
| 213 | 219 | foreach(array_reverse($fields) as $lname => $field) |
| 214 | 220 | { |
| 215 | 221 | if (!empty($this->attrs['sub-type']) && !empty($field['type2']) && |
| 216 | - strpos(','.$field['type2'].',',','.$field['type2'].',') === false) continue; // not for our content type// |
|
| 217 | - if (isset($value[self::$prefix.$lname]) && $value[self::$prefix.$lname] !== '') //break; |
|
| 222 | + strpos(','.$field['type2'].',',','.$field['type2'].',') === false) |
|
| 223 | + { |
|
| 224 | + continue; |
|
| 225 | + } |
|
| 226 | + // not for our content type// |
|
| 227 | + if (isset($value[self::$prefix.$lname]) && $value[self::$prefix.$lname] !== '') |
|
| 228 | + { |
|
| 229 | + //break; |
|
| 218 | 230 | { |
| 219 | 231 | $fields_with_vals[]=$lname; |
| 220 | 232 | } |
| 233 | + } |
|
| 221 | 234 | //$stop_at_field = $name; |
| 222 | 235 | } |
| 223 | 236 | break; |
@@ -248,7 +261,10 @@ discard block |
||
| 248 | 261 | |
| 249 | 262 | // Re-format date custom fields from Y-m-d |
| 250 | 263 | $field_settings =& self::get_array(self::$request->modifications, "{$this->id}[customfields]",true); |
| 251 | - if (true) $field_settings = array(); |
|
| 264 | + if (true) |
|
| 265 | + { |
|
| 266 | + $field_settings = array(); |
|
| 267 | + } |
|
| 252 | 268 | $link_types = Api\Link::app_list(); |
| 253 | 269 | foreach($fields as $fname => $field) |
| 254 | 270 | { |
@@ -271,7 +287,10 @@ discard block |
||
| 271 | 287 | protected function _widget($fname, array $field) |
| 272 | 288 | { |
| 273 | 289 | static $link_types = null; |
| 274 | - if (!isset($link_types)) $link_types = Api\Link::app_list (); |
|
| 290 | + if (!isset($link_types)) |
|
| 291 | + { |
|
| 292 | + $link_types = Api\Link::app_list (); |
|
| 293 | + } |
|
| 275 | 294 | |
| 276 | 295 | $type = $field['type']; |
| 277 | 296 | // Link-tos needs to change from appname to link-to |
@@ -298,8 +317,14 @@ discard block |
||
| 298 | 317 | case 'date': |
| 299 | 318 | case 'date-time': |
| 300 | 319 | $widget->attrs['dataformat'] = $type == 'date' ? 'Y-m-d' : 'Y-m-d H:i:s'; |
| 301 | - if($field['values']['min']) $widget->attrs['min'] = $field['values']['min']; |
|
| 302 | - if($field['values']['max']) $widget->attrs['min'] = $field['values']['max']; |
|
| 320 | + if($field['values']['min']) |
|
| 321 | + { |
|
| 322 | + $widget->attrs['min'] = $field['values']['min']; |
|
| 323 | + } |
|
| 324 | + if($field['values']['max']) |
|
| 325 | + { |
|
| 326 | + $widget->attrs['min'] = $field['values']['max']; |
|
| 327 | + } |
|
| 303 | 328 | break; |
| 304 | 329 | |
| 305 | 330 | case 'vfs-upload': |
@@ -316,7 +341,10 @@ discard block |
||
| 316 | 341 | break; |
| 317 | 342 | |
| 318 | 343 | default: |
| 319 | - if (substr($type, 0, 7) !== 'select-' && $type != 'ajax_select') break; |
|
| 344 | + if (substr($type, 0, 7) !== 'select-' && $type != 'ajax_select') |
|
| 345 | + { |
|
| 346 | + break; |
|
| 347 | + } |
|
| 320 | 348 | // fall-through for all select-* widgets |
| 321 | 349 | case 'select': |
| 322 | 350 | $widget->attrs['multiple'] = $field['rows'] > 1; |
@@ -377,7 +405,10 @@ discard block |
||
| 377 | 405 | $all_readonly = $this->is_readonly($cname, $form_name); |
| 378 | 406 | $value_in = self::get_array($content, $form_name); |
| 379 | 407 | // if we have no id / use self::GLOBAL_ID, we have to set $value_in in global namespace for regular widgets validation to find |
| 380 | - if (!$this->id) $content = array_merge($content, $value_in); |
|
| 408 | + if (!$this->id) |
|
| 409 | + { |
|
| 410 | + $content = array_merge($content, $value_in); |
|
| 411 | + } |
|
| 381 | 412 | //error_log(__METHOD__."($cname, ...) form_name=$form_name, use-private={$this->attrs['use-private']}, value_in=".array2string($value_in)); |
| 382 | 413 | $customfields =& $this->getElementAttribute(self::GLOBAL_VALS, 'customfields'); |
| 383 | 414 | if(is_array($value_in)) |
@@ -402,15 +433,24 @@ discard block |
||
| 402 | 433 | // run validation method of widget implementing this custom field |
| 403 | 434 | $widget = $this->_widget($fname, $field_settings); |
| 404 | 435 | // widget has no validate method, eg. is only displaying stuff --> nothing to validate |
| 405 | - if (!method_exists($widget, 'validate')) continue; |
|
| 436 | + if (!method_exists($widget, 'validate')) |
|
| 437 | + { |
|
| 438 | + continue; |
|
| 439 | + } |
|
| 406 | 440 | $widget->validate($form_name != self::GLOBAL_ID ? $form_name : $cname, $expand, $content, $validated); |
| 407 | 441 | $field_name = $this->id[0] == self::$prefix && $customfields[substr($this->id,1)] ? $this->id : self::form_name($form_name != self::GLOBAL_ID ? $form_name : $cname, $field); |
| 408 | 442 | $valid =& self::get_array($validated, $field_name, true); |
| 409 | 443 | |
| 410 | - if (is_array($valid)) $valid = implode(',', $valid); |
|
| 444 | + if (is_array($valid)) |
|
| 445 | + { |
|
| 446 | + $valid = implode(',', $valid); |
|
| 447 | + } |
|
| 411 | 448 | // NULL is valid for most fields, but not custom fields due to backend handling |
| 412 | 449 | // See so_sql_cf->save() |
| 413 | - if (is_null($valid)) $valid = false; |
|
| 450 | + if (is_null($valid)) |
|
| 451 | + { |
|
| 452 | + $valid = false; |
|
| 453 | + } |
|
| 414 | 454 | //error_log(__METHOD__."() $field_name: ".array2string($value).' --> '.array2string($valid)); |
| 415 | 455 | } |
| 416 | 456 | } |
@@ -418,7 +458,10 @@ discard block |
||
| 418 | 458 | { |
| 419 | 459 | // Transformation doesn't handle validation |
| 420 | 460 | $valid =& self::get_array($validated, $this->id ? $form_name : $field, true); |
| 421 | - if (true) $valid = $value_in; |
|
| 461 | + if (true) |
|
| 462 | + { |
|
| 463 | + $valid = $value_in; |
|
| 464 | + } |
|
| 422 | 465 | //error_log(__METHOD__."() $form_name $field: ".array2string($value).' --> '.array2string($value)); |
| 423 | 466 | } |
| 424 | 467 | } |