You are here

function _content_admin_type_fields in Content Construction Kit (CCK) 6

Same name and namespace in other branches
  1. 5 content_admin.inc \_content_admin_type_fields()

Menu callback; lists all defined fields for quick reference.

1 string reference to '_content_admin_type_fields'
content_menu in ./content.module
Implementation of hook_menu().

File

includes/content.admin.inc, line 11
Administrative interface for content type creation.

Code

function _content_admin_type_fields() {
  $fields = content_fields();
  $header = array(
    t('Field name'),
    t('Field type'),
    t('Used in'),
  );
  $rows = array();
  foreach ($fields as $field) {
    $row = array();
    $row[] = $field['field_name'];
    $row[] = $field['type'];
    $types = array();
    $result = db_query("SELECT nt.name, nt.type FROM {" . content_instance_tablename() . "} nfi " . "LEFT JOIN {node_type} nt ON nt.type = nfi.type_name " . "WHERE nfi.field_name = '%s' " . "AND nfi.widget_active = 1 " . "ORDER BY nt.name ASC", $field['field_name']);
    while ($type = db_fetch_array($result)) {
      $content_type = content_types($type['type']);
      $types[] = l($type['name'], 'admin/content/node-type/' . $content_type['url_str'] . '/fields');
    }
    $row[] = implode(', ', $types);
    $rows[] = $row;
  }
  if (empty($rows)) {
    $output = t('No fields have been defined for any content type yet.');
  }
  else {
    $output = theme('table', $header, $rows);
  }
  return $output;
}