1 |
85ad3d82
|
Assos Assos
|
<?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 |
|
|
|
45 |
|
|
function views_content_views_attachments_content_type_edit_form($form, &$form_state) {
|
46 |
|
|
$conf = $form_state['conf'];
|
47 |
|
|
|
48 |
|
|
$form['which'] = array(
|
49 |
|
|
'#type' => 'checkboxes',
|
50 |
|
|
'#options' => array(
|
51 |
|
|
'attachment_before' => t('"Before" attachment'),
|
52 |
|
|
'attachment_after' => t('"After" attachment'),
|
53 |
|
|
),
|
54 |
|
|
'#default_value' => $conf['which'],
|
55 |
|
|
);
|
56 |
|
|
|
57 |
|
|
return $form;
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
function views_content_views_attachments_content_type_edit_form_validate(&$form, &$form_state) {
|
61 |
|
|
if (!array_filter($form_state['values']['which'])) {
|
62 |
|
|
form_error($form['which'], t('You must select at least one attachment to display.'));
|
63 |
|
|
}
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
function views_content_views_attachments_content_type_edit_form_submit(&$form, &$form_state) {
|
67 |
|
|
$form_state['conf']['which'] = array_filter($form_state['values']['which']);
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
/**
|
71 |
|
|
* Returns the administrative title for a type.
|
72 |
|
|
*/
|
73 |
|
|
function views_content_views_attachments_content_type_admin_title($subtype, $conf, $context) {
|
74 |
|
|
return t('"@context" attachment', array('@context' => $context->identifier));
|
75 |
|
|
} |