function fieldgroup_groups in Content Construction Kit (CCK) 5
Same name and namespace in other branches
- 6.3 modules/fieldgroup/fieldgroup.module \fieldgroup_groups()
- 6 modules/fieldgroup/fieldgroup.module \fieldgroup_groups()
- 6.2 modules/fieldgroup/fieldgroup.module \fieldgroup_groups()
16 calls to fieldgroup_groups()
- content_admin_field_overview_form in ./
content_admin.inc - Menu callback; presents a listing of fields for a content type.
- content_copy_groups in ./
content_copy.module - Get all the groups for a content type.
- content_copy_import_form_submit in ./
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
- fieldgroup_display_overview_form in ./
fieldgroup.module - fieldgroup_display_overview_form_submit in ./
fieldgroup.module
File
- ./
fieldgroup.module, line 231 - Create field groups for CCK fields.
Code
function fieldgroup_groups($content_type = '', $sorted = FALSE, $reset = FALSE) {
static $groups, $groups_sorted;
if (!isset($groups) || $reset) {
if ($cached = cache_get('fieldgroup_data', 'cache_content')) {
$data = unserialize($cached->data);
$groups = $data['groups'];
$groups_sorted = $data['groups_sorted'];
}
else {
$result = db_query("SELECT * FROM {node_group} ORDER BY weight, group_name");
$groups = array();
$groups_sorted = array();
while ($group = db_fetch_array($result)) {
$group['settings'] = unserialize($group['settings']);
$group['fields'] = array();
$groups[$group['type_name']][$group['group_name']] = $group;
$groups_sorted[$group['type_name']][] =& $groups[$group['type_name']][$group['group_name']];
}
//load fields
$result = db_query("SELECT nfi.*, ng.group_name FROM {node_group} ng " . "INNER JOIN {node_group_fields} ngf ON ngf.type_name = ng.type_name AND ngf.group_name = ng.group_name " . "INNER JOIN {node_field_instance} nfi ON nfi.field_name = ngf.field_name AND nfi.type_name = ngf.type_name " . "ORDER BY nfi.weight");
while ($field = db_fetch_array($result)) {
$groups[$field['type_name']][$field['group_name']]['fields'][$field['field_name']] = $field;
}
cache_set('fieldgroup_data', 'cache_content', serialize(array(
'groups' => $groups,
'groups_sorted' => $groups_sorted,
)));
}
}
if (empty($content_type)) {
return $groups;
}
elseif (!$groups[$content_type]) {
return array();
}
return $sorted ? $groups_sorted[$content_type] : $groups[$content_type];
}