Projet

Général

Profil

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

root / drupal7 / sites / all / modules / ctools / plugins / content_types / user_context / user_links.inc @ 6e3ce7c2

1 e4c061ad Assos Assos
<?php
2
3
/**
4 c304a780 Assos Assos
 * @file
5 e4c061ad Assos Assos
 * Plugins are described by creating a $plugin array which will be used
6
 * by the system that includes this file.
7
 */
8 c304a780 Assos Assos
9 e4c061ad Assos Assos
$plugin = array(
10
  'single' => TRUE,
11
  'title' => t('User links'),
12
  'icon' => 'icon_user.png',
13
  'description' => t('User links of the referenced user.'),
14
  'required context' => new ctools_context_required(t('User'), 'user'),
15
  'category' => t('User'),
16
  'defaults' => array(
17
    'override_title' => FALSE,
18
    'override_title_text' => '',
19
    'build_mode' => '',
20
  ),
21
);
22
23
/**
24
 * Output function for the user links.
25
 */
26
function ctools_user_links_content_type_render($subtype, $conf, $panel_args, $context) {
27
  if (!empty($context) && empty($context->data)) {
28
    return;
29
  }
30
31
  $account = clone $context->data;
32
  $block = new stdClass();
33
  $block->module = 'user';
34 c304a780 Assos Assos
  $block->delta = $account->uid;
35 e4c061ad Assos Assos
36
  if (empty($account)) {
37
    $block->delta   = 'placeholder';
38
    $block->subject = t('User name.');
39
    $block->content = t('User links go here.');
40
  }
41
  else {
42
    $block->subject = $account->name;
43
    user_build_content($account, $conf['build_mode']);
44
    if (!empty($account->content['links'])) {
45
      $block->content = $account->content['links'];
46
    }
47
    else {
48
      $block->content = '';
49
    }
50
  }
51
  return $block;
52
}
53
54
/**
55
 * Returns an edit form for the custom type.
56
 */
57
function ctools_user_links_content_type_edit_form($form, &$form_state) {
58
  $conf = $form_state['conf'];
59
60
  $entity = entity_get_info('user');
61
  $build_mode_options = array();
62
  foreach ($entity['view modes'] as $mode => $option) {
63
    $build_mode_options[$mode] = $option['label'];
64
  }
65
66
  $form['build_mode'] = array(
67
    '#title' => t('Build mode'),
68
    '#type' => 'select',
69
    '#description' => t('Select a build mode for this user.'),
70
    '#options' => $build_mode_options,
71
    '#default_value' => $conf['build_mode'],
72
  );
73
74
  return $form;
75
}
76
77
function ctools_user_links_content_type_edit_form_submit($form, &$form_state) {
78
  // Copy everything from our defaults.
79
  foreach (array_keys($form_state['plugin']['defaults']) as $key) {
80
    $form_state['conf'][$key] = $form_state['values'][$key];
81
  }
82
}
83
84
function ctools_user_links_content_type_admin_title($subtype, $conf, $context) {
85
  return t('"@s" links', array('@s' => $context->identifier));
86
}