Mercurial > hg > rr-repo
comparison sites/all/modules/quicktabs/plugins/QuickBlockContent.inc @ 2:b74b41bb73f0
-- Google analytics module
author | danieleb <danielebarchiesi@me.com> |
---|---|
date | Thu, 22 Aug 2013 17:22:54 +0100 |
parents | |
children | 134d4b2e75f6 |
comparison
equal
deleted
inserted
replaced
1:67ce89da90df | 2:b74b41bb73f0 |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * Class for tab content of type "block" - this is for rendering a block as tab | |
5 * content. | |
6 */ | |
7 class QuickBlockContent extends QuickContent { | |
8 | |
9 public static function getType() { | |
10 return 'block'; | |
11 } | |
12 | |
13 public function optionsForm($delta, $qt) { | |
14 $tab = $this->settings; | |
15 $form = array(); | |
16 $form['block']['bid'] = array( | |
17 '#type' => 'select', | |
18 '#options' => quicktabs_get_blocks(), | |
19 '#default_value' => isset($tab['bid']) ? $tab['bid'] : '', | |
20 '#title' => t('Select a block'), | |
21 ); | |
22 $form['block']['hide_title'] = array( | |
23 '#type' => 'checkbox', | |
24 '#title' => t('Hide the title of this block'), | |
25 '#default_value' => isset($tab['hide_title']) ? $tab['hide_title'] : 1, | |
26 ); | |
27 return $form; | |
28 } | |
29 | |
30 public function render($hide_empty = FALSE, $args = array()) { | |
31 if ($this->rendered_content) { | |
32 return $this->rendered_content; | |
33 } | |
34 $output = array(); | |
35 $item = $this->settings; | |
36 if (!empty($args)) { | |
37 // The args have been passed in from an ajax request. | |
38 $qt_name = array_shift($args); | |
39 list($item['bid'], $item['hide_title']) = $args; | |
40 | |
41 // Ensure the block is assigned to the requested quicktabs block. This test prevents | |
42 // AJAX access to blocks that have not been added to an AJAX-enabled quicktabs block. | |
43 $break = TRUE; | |
44 $quicktabs = quicktabs_load($qt_name); | |
45 // Ensure AJAX is enabled for the quicktabs block. | |
46 if (!empty($quicktabs) && $quicktabs->ajax == 1) { | |
47 // Ensure the requested tab has been added to the quicktabs block. | |
48 foreach ($quicktabs->tabs as $quicktab) { | |
49 if (isset($quicktab['bid']) && ($quicktab['bid'] == $item['bid'])) { | |
50 $break = FALSE; | |
51 break; | |
52 } | |
53 } | |
54 } | |
55 if ($break == TRUE) { | |
56 if (!$hide_empty) { | |
57 $output['#markup'] = theme('quicktabs_tab_access_denied', $item); | |
58 } | |
59 return $output; | |
60 } | |
61 } | |
62 | |
63 if (isset($item['bid'])) { | |
64 if (module_exists('block')) { | |
65 $pos = strpos($item['bid'], '_delta_'); | |
66 $module = drupal_substr($item['bid'], 0, $pos); | |
67 $delta = drupal_substr($item['bid'], $pos + 7); | |
68 | |
69 $block = block_load($module, $delta); | |
70 $block->region = 'quicktabs_tabpage'; | |
71 | |
72 if ($block_arr = _block_render_blocks(array($block))) { | |
73 if ($item['hide_title']) { | |
74 $block_arr["{$block->module}_{$block->delta}"]->subject = FALSE; | |
75 } | |
76 if (!empty($block_arr["{$block->module}_{$block->delta}"]->content)) { | |
77 $build = _block_get_renderable_array($block_arr); | |
78 $output = $build; | |
79 } | |
80 } | |
81 } | |
82 elseif (!$hide_empty) { | |
83 $output['#markup'] = t('Block module is not enabled, cannot display content.'); | |
84 } | |
85 } | |
86 $this->rendered_content = $output; | |
87 return $output; | |
88 } | |
89 | |
90 public function getAjaxKeys() { | |
91 return array('bid', 'hide_title'); | |
92 } | |
93 } |