You are here

function fasttoggle_field_fasttoggle_available_links in Fasttoggle 7

Implements hook_fasttoggle_available_links().

File

module/fasttoggle_field/fasttoggle_field.module, line 109

Code

function fasttoggle_field_fasttoggle_available_links($type = NULL, $obj = NULL) {
  $result = array();
  foreach (field_info_instances() as $entity_type => $instance_array) {

    // Skip entity types that we aren't interested in.
    if (!is_null($type) && $type != $entity_type) {
      continue;
    }
    foreach ($instance_array as $group => $instances) {

      // If a node is given, filter out groups that don't match the node type.
      if (isset($obj) && $type == "node" && $obj->type != $group) {
        continue;
      }
      foreach ($instances as $fieldname => $field_settings) {
        fasttoggle_field_merge_field_labels($entity_type, $group, $fieldname, $field_settings, $result);
      }
      if (!empty($result[$entity_type]['fields'][$group]['instances'])) {
        $result[$entity_type]['fields'][$group]['value_fn'] = 'fasttoggle_field_get_field_value';
        $result[$entity_type]['fields'][$group]['save_fn'] = 'fasttoggle_field_save';
      }
    }
  }
  if (module_exists("profile2") && isset($result["profile2"])) {
    $result = array_merge_recursive($result, array(
      "profile2" => array(
        'id_field' => 'pid',
        'title_field' => 'title',
        'save_fn' => 'fasttoggle_field_save',
        'object_type' => "profile2",
      ),
    ));
  }
  return $result;
}