function fieldgroup_groups in Content Construction Kit (CCK) 6
Same name and namespace in other branches
- 5 fieldgroup.module \fieldgroup_groups()
- 6.3 modules/fieldgroup/fieldgroup.module \fieldgroup_groups()
- 6.2 modules/fieldgroup/fieldgroup.module \fieldgroup_groups()
13 calls to fieldgroup_groups()
- content_admin_display_overview_form in includes/
content.admin.inc - Menu callback; presents a listing of fields display settings for a content type.
- content_admin_field_overview_form in includes/
content.admin.inc - Menu callback; listing of fields for a content type.
- content_copy_groups in modules/
content_copy/ content_copy.module - Get all the groups for a content type.
- 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
- fieldgroup_display_overview_form_submit in modules/
fieldgroup/ fieldgroup.module
File
- modules/
fieldgroup/ fieldgroup.module, line 246 - 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', content_cache_tablename())) {
$data = $cached->data;
$groups = $data['groups'];
$groups_sorted = $data['groups_sorted'];
}
else {
$result = db_query("SELECT * FROM {" . fieldgroup_tablename() . "} 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 {" . fieldgroup_tablename() . "} ng " . "INNER JOIN {" . fieldgroup_fields_tablename() . "} ngf ON ngf.type_name = ng.type_name AND ngf.group_name = ng.group_name " . "INNER JOIN {" . content_instance_tablename() . "} nfi ON nfi.field_name = ngf.field_name AND nfi.type_name = ngf.type_name " . "WHERE nfi.widget_active = 1 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', 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];
}