comparison sites/all/modules/quicktabs/plugins/QuickNodeContent.inc @ 2:b74b41bb73f0

-- Google analytics module
author danieleb <danielebarchiesi@me.com>
date Thu, 22 Aug 2013 17:22:54 +0100
parents
children a75ead649730
comparison
equal deleted inserted replaced
1:67ce89da90df 2:b74b41bb73f0
1 <?php
2
3 /**
4 * Class for tab content of type "node" - this is for rendering a node as tab
5 * content.
6 */
7 class QuickNodeContent extends QuickContent {
8
9 public static function getType() {
10 return 'node';
11 }
12
13 public function optionsForm($delta, $qt) {
14 $tab = $this->settings;
15 $form = array();
16 $form['node']['nid'] = array(
17 '#type' => 'textfield',
18 '#title' => t('Node'),
19 '#description' => t('The node ID of the node.'),
20 '#maxlength' => 10,
21 '#size' => 20,
22 '#default_value' => isset($tab['nid']) ? $tab['nid'] : '',
23 );
24 $form['node']['teaser'] = array(
25 '#type' => 'checkbox',
26 '#title' => t('Teaser view'),
27 '#default_value' => isset($tab['teaser']) ? $tab['teaser'] : 0,
28 );
29 $form['node']['hide_title'] = array(
30 '#type' => 'checkbox',
31 '#title' => t('Hide the title of this node'),
32 '#default_value' => isset($tab['hide_title']) ? $tab['hide_title'] : 1,
33 );
34 return $form;
35 }
36
37 public function render($hide_empty = FALSE, $args = array()) {
38 if ($this->rendered_content) {
39 return $this->rendered_content;
40 }
41 $item = $this->settings;
42 if (!empty($args)) {
43 // The args have been passed in from an ajax request.
44 // The first element of the args array is the qt_name, which we don't need
45 // for this content type.
46 array_shift($args);
47 list($item['nid'], $item['teaser'], $item['hide_title']) = $args;
48 }
49 $output = array();
50 if (isset($item['nid'])) {
51 $node = node_load($item['nid']);
52 if (!empty($node)) {
53 if (node_access('view', $node)) {
54 $buildmode = $item['teaser'] ? 'teaser' : 'full';
55 $nstruct = node_view($node, $buildmode);
56 if ($item['hide_title']) {
57 $nstruct['#node']->title = NULL;
58 }
59 $output = $nstruct;
60 }
61 elseif (!$hide_empty) {
62 $output = array('#markup' => theme('quicktabs_tab_access_denied', array('tab' => $item)));
63 }
64 }
65 }
66 return $output;
67 }
68
69 public function getAjaxKeys() {
70 return array('nid', 'teaser', 'hide_title');
71 }
72 }