Projet

Général

Profil

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

root / drupal7 / sites / all / modules / ctools / plugins / content_types / comment / comment_links.inc @ e4c061ad

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
  'title' => t('Comment links'),
10
  'icon' => 'icon_comment.png',
11
  'description' => t('Comment links of the referenced comment.'),
12
  'required context' => new ctools_context_required(t('Comment'), 'entity:comment'),
13
  'category' => t('Comment'),
14
  'defaults' => array(
15
    'override_title' => FALSE,
16
    'override_title_text' => '',
17
    'build_mode' => '',
18
  ),
19
);
20

    
21
/**
22
 * Output function for the comment links.
23
 */
24
function ctools_comment_links_content_type_render($subtype, $conf, $panel_args, $context) {
25
  if (!empty($context) && empty($context->data)) {
26
    return;
27
  }
28

    
29
  $comment = isset($context->data) ? clone($context->data) : NULL;
30
  $block = new stdClass();
31
  $block->module = 'comment';
32
  $block->delta  = $comment->cid;
33

    
34
  if (empty($comment)) {
35
    $block->delta   = 'placeholder';
36
    $block->subject = t('Comment subject.');
37
    $block->content = t('Comment links go here.');
38
  }
39
  else {
40
    $node = node_load($comment->nid);
41
    $block->subject = $comment->subject;
42
    comment_build_content($comment, $node, $conf['build_mode']);
43
    $block->content = $comment->content['links'];
44
  }
45
  return $block;
46
}
47

    
48
/**
49
 * Returns an edit form for the custom type.
50
 */
51
function ctools_comment_links_content_type_edit_form($form, &$form_state) {
52
  $conf = $form_state['conf'];
53

    
54
  $entity = entity_get_info('comment');
55
  $build_mode_options = array();
56
  foreach ($entity['view modes'] as $mode => $option) {
57
    $build_mode_options[$mode] = $option['label'];
58
  }
59

    
60
  $form['build_mode'] = array(
61
    '#title' => t('Build mode'),
62
    '#type' => 'select',
63
    '#description' => t('Select a build mode for this comment.'),
64
    '#options' => $build_mode_options,
65
    '#default_value' => $conf['build_mode'],
66
  );
67

    
68
  return $form;
69
}
70

    
71
function ctools_comment_links_content_type_edit_form_submit($form, &$form_state) {
72
  // Copy everything from our defaults.
73
  foreach (array_keys($form_state['plugin']['defaults']) as $key) {
74
    $form_state['conf'][$key] = $form_state['values'][$key];
75
  }
76
}
77

    
78
function ctools_comment_links_content_type_admin_title($subtype, $conf, $context) {
79
  return t('"@s" links', array('@s' => $context->identifier));
80
}