| 352 | | // Sanity check for b0rken schemas, missing type/widget will cause PHP to barf later on... |
|---|
| 353 | | if (! array_key_exists('type', $config)) |
|---|
| 354 | | { |
|---|
| 355 | | // TODO: trigger *informative* error |
|---|
| 356 | | $config['type'] = 'text'; |
|---|
| 357 | | $config['readonly'] = true; |
|---|
| 358 | | } |
|---|
| 359 | | if (! array_key_exists('widget', $config)) |
|---|
| 360 | | { |
|---|
| 361 | | // TODO: trigger *informative* error |
|---|
| 362 | | $config['widget'] = 'text'; |
|---|
| 363 | | $config['readonly'] = true; |
|---|
| 364 | | } |
|---|
| 365 | | if (! array_key_exists('description', $config)) |
|---|
| 366 | | { |
|---|
| 367 | | $config['description'] = null; |
|---|
| 368 | | } |
|---|
| 369 | | if (! array_key_exists('helptext', $config)) |
|---|
| 370 | | { |
|---|
| 371 | | $config['helptext'] = null; |
|---|
| 372 | | } |
|---|
| 373 | | if (! array_key_exists('static_prepend', $config)) |
|---|
| 374 | | { |
|---|
| 375 | | $config['static_prepend'] = null; |
|---|
| 376 | | } |
|---|
| 377 | | if (! array_key_exists('static_append', $config)) |
|---|
| 378 | | { |
|---|
| 379 | | $config['static_append'] = null; |
|---|
| 380 | | } |
|---|
| 381 | | |
|---|
| 382 | | if (! array_key_exists('readonly', $config)) |
|---|
| 383 | | { |
|---|
| 384 | | $config['readonly'] = false; |
|---|
| 385 | | } |
|---|
| 386 | | if (! array_key_exists('hidden', $config)) |
|---|
| 387 | | { |
|---|
| 388 | | $config['hidden'] = false; |
|---|
| 389 | | } |
|---|
| 390 | | if (! array_key_exists('aisonly', $config)) |
|---|
| 391 | | { |
|---|
| 392 | | $config['aisonly'] = false; |
|---|
| 393 | | } |
|---|
| 394 | | if (! array_key_exists('read_privilege', $config)) |
|---|
| 395 | | { |
|---|
| 396 | | $config['read_privilege'] = null; |
|---|
| 397 | | } |
|---|
| 398 | | if (! array_key_exists('write_privilege', $config)) |
|---|
| 399 | | { |
|---|
| 400 | | $config['write_privilege'] = null; |
|---|
| 401 | | } |
|---|
| 402 | | |
|---|
| 403 | | if (! array_key_exists('required', $config)) |
|---|
| 404 | | { |
|---|
| 405 | | $config['required'] = false; |
|---|
| 406 | | } |
|---|
| 407 | | |
|---|
| 408 | | if (! array_key_exists('default', $config)) |
|---|
| 409 | | { |
|---|
| 410 | | $config['default'] = null; |
|---|
| 411 | | } |
|---|
| 412 | | |
|---|
| | 352 | // Sanity check for b0rken schemas, missing type/widget would cause DM & PHP to barf later on... |
|---|
| | 353 | if ( !array_key_exists('type', $config) |
|---|
| | 354 | || empty($config['type'])) |
|---|
| | 355 | { |
|---|
| | 356 | $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Field '{$config['name']}' in schema '{$this->name}' loaded from {$this->_schemadb_path} is missing *type* definition"); |
|---|
| | 357 | // this will exit |
|---|
| | 358 | } |
|---|
| | 359 | if ( !array_key_exists('widget', $config) |
|---|
| | 360 | || empty($config['widget'])) |
|---|
| | 361 | { |
|---|
| | 362 | $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Field '{$config['name']}' in schema '{$this->name}' loaded from {$this->_schemadb_path} is missing *widget* definition"); |
|---|
| | 363 | // this will exit |
|---|
| | 364 | } |
|---|
| | 365 | /* Rest of the defaults */ |
|---|
| | 366 | // Simple ones |
|---|
| | 367 | $simple_defaults = array |
|---|
| | 368 | ( |
|---|
| | 369 | 'description' => null, |
|---|
| | 370 | 'helptext' => null, |
|---|
| | 371 | 'static_prepend' => null, |
|---|
| | 372 | 'static_append' => null, |
|---|
| | 373 | 'read_privilege' => null, |
|---|
| | 374 | 'write_privilege' => null, |
|---|
| | 375 | 'default' => null, |
|---|
| | 376 | 'readonly' => false, |
|---|
| | 377 | 'hidden' => false, |
|---|
| | 378 | 'aisonly' => false, |
|---|
| | 379 | 'required' => false, |
|---|
| | 380 | ); |
|---|
| | 381 | foreach ($simple_defaults as $property => $value) |
|---|
| | 382 | { |
|---|
| | 383 | if (! array_key_exists( $property, $config)) |
|---|
| | 384 | { |
|---|
| | 385 | $config[ $property] = $value; |
|---|
| | 386 | } |
|---|
| | 387 | } |
|---|
| | 388 | unset($property, $value); |
|---|
| | 389 | |
|---|
| | 390 | // And complex ones |
|---|