Projet

Général

Profil

Paste
Télécharger (2,2 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ctools / plugins / content_types / user_form / user_form_component.inc @ 6e3ce7c2

1
<?php
2

    
3
/**
4
 * Plugins are described by creating a $plugin array which will be used
5
 * by the system that includes this file.
6
 */
7
$plugin = array(
8
  'single' => TRUE,
9
  'icon' => 'icon_user_form.png',
10
  'title' => t('User form: add a specific component'),
11
  'description' => t('The user form component by selection.'),
12
  'required context' => new ctools_context_required(t('Form'), 'form'),
13
  'category' => t('Form'),
14
);
15

    
16
/**
17
 * Ctools plugin content type render for the picture form field.
18
 */
19
function ctools_user_form_component_content_type_render($subtype, $conf, $panel_args, &$context) {
20
  $block = new stdClass();
21
  $block->module = t('user-form');
22

    
23
  $block->delta = 'title-options';
24

    
25
  if (isset($context->form)) {
26
    if (!empty($context->form[$conf['field']])) {
27
      $block->content[$conf['field']] = $context->form[$conf['field']];
28
      unset($context->form[$conf['field']]);
29
    }
30
  }
31
  else {
32
    $block->content = t('User form edit components.');
33
  }
34
  return $block;
35
}
36

    
37
/**
38
 * Ctools plugin admin title function for the a selectable form field.
39
 */
40
function ctools_user_form_component_content_type_admin_title($subtype, $conf, $context) {
41
  return t('"@s" user form @field field', array('@s' => $context->identifier, '@field' => $conf['field']));
42
}
43

    
44
/**
45
 * Ctools plugin configuration edit form for the selectable form field.
46
 *
47
 * Provide the list of fields in the user profile edit form to select from the
48
 * plugin configuration.
49
 */
50
function ctools_user_form_component_content_type_edit_form($form, &$form_state) {
51
  $conf = $form_state['conf'];
52
  $user_form = drupal_get_form('user_profile_form');
53

    
54
  $field_keys = element_children($user_form);
55
  $options = array_combine($field_keys, $field_keys);
56

    
57
  $form['field'] = array(
58
    '#type' => 'select',
59
    '#title' => t('User form field'),
60
    '#options' => $options,
61
    '#description' => t('Select a form field from the current user form to display in this pane.'),
62
    '#default_value' => !empty($conf['field']) ? $conf['field'] : '',
63
  );
64
  return $form;
65
}
66

    
67
/**
68
 * Ctools plugin configuration edit form submit handler.
69
 */
70
function ctools_user_form_component_content_type_edit_form_submit($form, &$form_state) {
71
  $form_state['conf']['field'] = $form_state['values']['field'];
72
}