diff --git a/content_panels.inc b/content_panels.inc index 53f61dfbd52cd757eed25234c2d445db3cb89f54..bcecdc637ef5d96933acf59b5e12bcdbe2f6721e 100644 --- a/content_panels.inc +++ b/content_panels.inc @@ -5,7 +5,7 @@ * Callback function to supply a list of content types. */ function content_panels_content_types() { - $items = array(); + $items = array(); if (module_exists('fieldgroup')) { $items['node_cck_group'] = array( @@ -23,7 +23,7 @@ function content_panels_content_types() { } /** - * 'Render' callback for the 'CCK group' content type. + * 'Render' callback for the 'CCK group' content type. */ function content_content_node_cck_group($conf, $panel_args, $context) { $node = isset($context->data) ? drupal_clone($context->data) : NULL; @@ -32,13 +32,13 @@ function content_content_node_cck_group($conf, $panel_args, $context) { if ($node) { // Assemble the fields into groups $node = node_build_content($node); - + // Get the "machine name" of the group from the options $groupname = $conf['group']; // Set the subject to the nice name of the group $block->subject = $node->content[$groupname]['#title']; - + // Print out the contents of the given group // Note, not using drupal_render($node->content[$groupname]) here to avoid printing the fieldset if (is_array($node->content[$groupname])) { @@ -50,12 +50,12 @@ function content_content_node_cck_group($conf, $panel_args, $context) { } } } - + if (empty($output)) { // Output the given empty text $output = $conf['empty']; } - $block->content = $output; + $block->content = $output; $block->delta = $node->nid; } else { @@ -83,43 +83,35 @@ function content_admin_content_types_node_cck_group() { ); } + /** - * Helper function : build the list of groups for the 'edit' form. + * 'Edit' callback for the 'CCK group' content type. */ -function _content_admin_node_cck_group_options() { - $group_list = array(); - +function content_admin_edit_node_cck_group($id, $parents, $conf = array()) { + // Apply defaults + if (empty($conf)) { + $conf = array('title' => '', 'group' => '', 'empty' => ''); + } + // Retrieve the list of all groups on all content types + $group_list = array(); $types = module_exists('fieldgroup') ? fieldgroup_groups(NULL, FALSE, FALSE) : array(); - // Add each group to the list with the content type it is from in parentheses - foreach ($types as $type) { + foreach ($types as $type) { foreach ($type as $group) { $group_list[$group['group_name']] = $group['label'] . ' (' . $group['type_name'] . ')'; } } - return $group_list; -} - -/** - * 'Edit' callback for the 'CCK group' content type. - */ -function content_admin_edit_node_cck_group($id, $parents, $conf = array()) { - // Apply defaults - if (empty($conf)) { - $conf = array('title' => '', 'group' => '', 'empty' => ''); - } - $form['group'] = array( '#type' => 'select', '#title' => t('Which group'), - '#options' => _content_admin_node_cck_group_options(), + '#options' => $group_list, '#default_value' => $conf['group'], '#prefix' => '
', '#suffix' => '
', ); - + $form['empty'] = array( '#type' => 'textarea', '#title' => 'Empty text', @@ -134,7 +126,7 @@ function content_admin_edit_node_cck_group($id, $parents, $conf = array()) { } /** - * 'Title' callback for the 'CCK group' content type. + * 'Title' callback for the 'CCK group' content type. */ function content_admin_title_node_cck_group($conf, $context) { return t('"@s" node cck group', array('@s' => $context->identifier));