You are here

function fieldgroup_groups in Content Construction Kit (CCK) 6.3

Same name and namespace in other branches
  1. 5 fieldgroup.module \fieldgroup_groups()
  2. 6 modules/fieldgroup/fieldgroup.module \fieldgroup_groups()
  3. 6.2 modules/fieldgroup/fieldgroup.module \fieldgroup_groups()

Returns all groups for a content type

36 calls to fieldgroup_groups()
ContentUICrud::testAddFieldUI in tests/content.crud.test
content_copy_export_form in modules/content_copy/content_copy.module
A form to export field definitions.
content_copy_import_form_submit in modules/content_copy/content_copy.module
Submit handler for import form. For each submitted field: 1) add new field to the database 2) execute the imported field macro to update the settings to the imported values
content_display_overview_form in includes/content.admin.inc
Menu callback; presents a listing of fields display settings for a content type.
content_field_overview_form in includes/content.admin.inc
Menu callback; listing of fields for a content type.

... See full list

File

modules/fieldgroup/fieldgroup.module, line 224
Create field groups for CCK fields.

Code

function fieldgroup_groups($content_type = '', $sorted = FALSE, $reset = FALSE) {
  global $language;
  static $groups, $groups_sorted;
  if (!isset($groups) || $reset) {
    if ($cached = cache_get('fieldgroup_data:' . $language->language, content_cache_tablename())) {
      $data = $cached->data;
      $groups = $data['groups'];
      $groups_sorted = $data['groups_sorted'];
    }
    else {
      $result = db_query("SELECT * FROM {" . fieldgroup_tablename() . "} ORDER BY type_name, weight");
      $groups = array();
      $groups_sorted = array();
      while ($group = db_fetch_array($result)) {
        $groups[$group['type_name']] = _fieldgroup_get_tree($group['type_name']);
        $groups_sorted[$group['type_name']][] =& $groups[$group['type_name']][$group['group_name']];
      }
      cache_set('fieldgroup_data:' . $language->language, array(
        'groups' => $groups,
        'groups_sorted' => $groups_sorted,
      ), content_cache_tablename());
    }
  }
  if (empty($content_type)) {
    return $groups;
  }
  elseif (empty($groups) || empty($groups[$content_type])) {
    return array();
  }
  return $sorted ? $groups_sorted[$content_type] : $groups[$content_type];
}