1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Contains the panelizer node view row style plugin.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
/**
|
8 |
|
|
* Plugin which renders a panelizer node.
|
9 |
|
|
*/
|
10 |
|
|
class panelizer_plugin_row_panelizer_node_view extends views_plugin_row_node_view {
|
11 |
|
|
// Basic properties that let the row style follow relationships.
|
12 |
|
|
var $base_table = 'node';
|
13 |
|
|
var $base_field = 'nid';
|
14 |
|
|
|
15 |
|
|
function init(&$view, &$display, $options = NULL) {
|
16 |
|
|
parent::init($view, $display, $options);
|
17 |
|
|
// We need to define this here, not in hook_views_plugins() due to a bug
|
18 |
|
|
// in Views itself. See http://drupal.org/node/1205376 for more info.
|
19 |
|
|
$this->definition['theme'] = 'views_view_row_node';
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
function option_definition() {
|
23 |
|
|
$options = parent::option_definition();
|
24 |
|
|
$options['render_anything'] = array('default' => FALSE);
|
25 |
|
|
return $options;
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
function options_form(&$form, &$form_state) {
|
29 |
|
|
parent::options_form($form, $form_state);
|
30 |
|
|
$form['render_anything'] = array(
|
31 |
|
|
'#type' => 'checkbox',
|
32 |
|
|
'#title' => t('Also display content that is not handled by panelizer'),
|
33 |
|
|
'#description' => t('If any content is not panelized, it will be hidden unless this is checked.'),
|
34 |
|
|
'#default_value' => $this->options['render_anything'],
|
35 |
|
|
'#weight' => -1,
|
36 |
|
|
);
|
37 |
|
|
|
38 |
|
|
// Force the row options from the parent plugin to depend on this checkbox.
|
39 |
|
|
foreach (array('view_mode', 'links', 'comments') as $element_name) {
|
40 |
|
|
$form[$element_name]['#dependency'] = array(
|
41 |
|
|
'edit-row-options-render-anything' => array(1),
|
42 |
|
|
);
|
43 |
|
|
}
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
function render($row) {
|
47 |
|
|
$node = node_load($row->nid);
|
48 |
|
|
if (empty($node)) {
|
49 |
|
|
return;
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
$handler = panelizer_entity_plugin_get_handler('node');
|
53 |
|
|
$info = $handler->render_entity($node, 'page_manager');
|
54 |
|
|
|
55 |
|
|
if (empty($info)) {
|
56 |
|
|
if (!empty($this->options['render_anything'])) {
|
57 |
|
|
return parent::render($row);
|
58 |
|
|
}
|
59 |
|
|
}
|
60 |
|
|
else {
|
61 |
|
|
return $info['content'];
|
62 |
|
|
}
|
63 |
|
|
}
|
64 |
|
|
} |