Projet

Général

Profil

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

root / drupal7 / sites / all / modules / ctools / views_content / plugins / content_types / views_attachments.inc @ c304a780

1
<?php
2

    
3
/**
4
 * @file
5
 * Allow a view context to display its attachment(s).
6
 */
7

    
8
$plugin = array(
9
  'title' => t('View attachment'),
10
  'category' => t('View context'),
11
  'icon' => 'icon_views_page.png',
12
  'description' => t('Display the attachments on a view context.'),
13
  'required context' => new ctools_context_required(t('View'), 'view'),
14
  'defaults' => array(
15
    'which' => array(),
16
  ),
17
);
18

    
19
/**
20
 * Render the node_terms content type.
21
 */
22
function views_content_views_attachments_content_type_render($subtype, $conf, $panel_args, $context) {
23
  if (empty($context) || empty($context->data)) {
24
    return;
25
  }
26

    
27
  // Build the content type block.
28
  $block          = new stdClass();
29
  $block->module  = 'views_attachments';
30
  $block->delta   = $context->argument;
31
  $block->title   = '';
32
  $block->content = '';
33

    
34
  $output = views_content_context_get_output($context);
35
  foreach ($conf['which'] as $attachment) {
36
    if (isset($output[$attachment])) {
37
      $block->content .= $output[$attachment];
38
    }
39
  }
40

    
41
  return $block;
42
}
43

    
44
function views_content_views_attachments_content_type_edit_form($form, &$form_state) {
45
  $conf = $form_state['conf'];
46

    
47
  $form['which'] = array(
48
    '#type' => 'checkboxes',
49
    '#options' => array(
50
      'attachment_before' => t('"Before" attachment'),
51
      'attachment_after' => t('"After" attachment'),
52
    ),
53
    '#default_value' => $conf['which'],
54
  );
55

    
56
  return $form;
57
}
58

    
59
function views_content_views_attachments_content_type_edit_form_validate(&$form, &$form_state) {
60
  if (!array_filter($form_state['values']['which'])) {
61
    form_error($form['which'], t('You must select at least one attachment to display.'));
62
  }
63
}
64

    
65
function views_content_views_attachments_content_type_edit_form_submit(&$form, &$form_state) {
66
  $form_state['conf']['which'] = array_filter($form_state['values']['which']);
67
}
68

    
69
/**
70
 * Returns the administrative title for a type.
71
 */
72
function views_content_views_attachments_content_type_admin_title($subtype, $conf, $context) {
73
  return t('"@context" attachment', array('@context' => $context->identifier));
74
}