? cck-content_type_field_form.patch Index: includes/panels/content_types/content_field_form.inc =================================================================== RCS file: includes/panels/content_types/content_field_form.inc diff -N includes/panels/content_types/content_field_form.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ includes/panels/content_types/content_field_form.inc 8 Aug 2010 20:39:19 -0000 @@ -0,0 +1,126 @@ + 'content_content_field_form_content_type_content_type', +); + +/** + * Return all field content types available. + */ +function content_content_field_form_content_type_content_types() { + // This will hold all the individual field content types. + $types = array(); + + // Get all fields on the site. + $field_types = _content_field_types(); + + foreach (content_types() as $type_name => $type) { + foreach ($type['fields'] as $field_name => $field) { + if (!isset($types[$field_name])) { + $types[$field_name] = array( + 'category' => t('Form'), + 'icon' => 'icon_node_form.png', + 'title' => t('Field: @widget_label (@field_name) - @field_type', array( + '@widget_label' => t($field['widget']['label']), + '@field_name' => $field_name, + '@field_type' => t($field_types[$field['type']]['label']), + )), + 'description' => t('Field on the referenced node.'), + 'types' => array(), + ); + if (isset($field_types[$field['type']]['content_icon'])) { + $types[$field_name]['icon'] = $field_types[$field['type']]['content_icon']; + } + } + $types[$field_name]['types'][$type_name] = $type['name']; + } + } + + // Create the required context for each field related to the content types. + foreach ($types as $field_name => $field_content_type) { + $types[$field_name]['required context'] = new ctools_context_required(t('Form'), 'node_form', array( + 'type' => array_keys($types[$field_name]['types']), + )); + unset($types[$field_name]['types']); + } + + return $types; +} + +/** + * Just one subtype. + * + * Ordinarily this function is meant to get just one subtype. However, we are + * using it to deal with the fact that we have changed the subtype names. This + * lets us translate the name properly. + */ +function content_content_field_form_content_type_content_type($subtype) { + $types = content_content_field_form_content_type_content_types(); + if (isset($types[$subtype])) { + return $types[$subtype]; + } +} + +/** + * Output function for the 'field' content type. + */ +function content_content_field_form_content_type_render($subtype, $conf, $panel_args, $context) { + $node = $context->data; + + // Extract the node type from the node in context, the field name from the + // panels content type subtype, and get the content field structure. + $field_name = $subtype; + $field = content_fields($field_name, $node->type); + + // Check view access to the field. + if (!content_access('edit', $field, NULL, $node)) { + return; + } + + $block = new stdClass(); + $block->module = 'content'; + $block->delta = $field_name; + + if (isset($context->form)) { + if (!empty($context->form['form_id']) && !empty($context->form[$field_name]['#access'])) { + $block->content = drupal_render($context->form[$field_name]); + } + } + else { + $block->content = t('Content field form.'); + } + return $block; +} + +/** + * Returns a settings form for the custom type. + */ +function content_content_field_form_content_type_edit_form(&$form, &$form_state) { +} + +function content_content_field_form_content_type_edit_form_submit(&$form, &$form_state) { +} + +/** + * Admin title for field content type. + */ +function content_content_field_form_content_type_admin_title($subtype, $conf, $context) { + // Get all fields on the site. + $field_types = _content_field_types(); + + // Get all the information about our field. + $field = content_fields($subtype); + + return t('"@s" field: @widget_label (@field_name) - @field_type', array( + '@s' => $context->identifier, + '@widget_label' => t($field['widget']['label']), + '@field_name' => $subtype, + '@field_type' => t($field_types[$field['type']]['label']), + )); +}