You are here

function conditional_fields_load_data in Conditional Fields 5

Same name and namespace in other branches
  1. 6.2 conditional_fields.module \conditional_fields_load_data()
  2. 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.

4 calls to conditional_fields_load_data()
conditional_fields_content_admin_field in ./conditional_fields.module
Alteration of the field editing form
conditional_fields_field_overview_form in ./conditional_fields.module
Find conditional fields, mark them, and disable groups select for them.
conditional_fields_nodeapi in ./conditional_fields.module
Implementation of hook_nodeapi()
conditional_fields_node_editing_form in ./conditional_fields.module
Alteration of the node editing form

File

./conditional_fields.module, line 653

Code

function conditional_fields_load_data($type, $structure = 'row', $reset = FALSE) {
  static $data;
  if ($reset) {
    unset($data);
  }
  if (!$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;
      }
    }
    else {
      if ($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];
}