function conditional_fields_load_data in Conditional Fields 6.2
Same name and namespace in other branches
- 5 conditional_fields.module \conditional_fields_load_data()
- 6 conditional_fields.module \conditional_fields_load_data()
Returns an array of conditional fields settings for a given node type. $structure can be either 'flat' or 'row' . 'row' data is data per row, while 'flat' data is a list of both controlling and controlled fields.
7 calls to conditional_fields_load_data()
- conditional_fields_content_admin_field in ./
conditional_fields.module - Alteration of the field editing form
- conditional_fields_fieldgroup_group_edit_form in ./
conditional_fields.module - Alteration of the fieldgroup editing form
- conditional_fields_field_overview_form in ./
conditional_fields.module - Find conditional fields and mark them.
- conditional_fields_field_overview_form_validate in ./
conditional_fields.module - Conditional fields in some situations can't change group.
- conditional_fields_nodeapi in ./
conditional_fields.module - Implementation of hook_nodeapi().
File
- ./
conditional_fields.module, line 1067 - Content fields and groups visibility based on the values of user defined 'trigger' fields.
Code
function conditional_fields_load_data($type, $structure = 'row', $reset = FALSE) {
static $data;
if ($reset) {
unset($data);
}
if (!isset($data[$structure][$type])) {
$data[$structure][$type] = array();
if ($structure == 'row') {
$query = db_query("SELECT control_field_name, field_name, trigger_values FROM {conditional_fields} WHERE type = '%s'", $type);
while ($result = db_fetch_array($query)) {
$result['trigger_values'] = unserialize($result['trigger_values']);
$data['row'][$type][] = $result;
}
}
elseif ($structure == 'flat') {
$query = db_query("SELECT control_field_name, field_name FROM {conditional_fields} WHERE type = '%s'", $type);
while ($result = db_fetch_array($query)) {
$data['flat'][$type][$result['control_field_name']] = $result['control_field_name'];
$data['flat'][$type][$result['field_name']] = $result['field_name'];
}
$data['flat'][$type] = array_unique($data['flat'][$type]);
}
}
return $data[$structure][$type];
}