Mercurial > hg > rr-repo
comparison sites/all/modules/quicktabs/plugins/QuickQtabsContent.inc @ 2:b74b41bb73f0
-- Google analytics module
author | danieleb <danielebarchiesi@me.com> |
---|---|
date | Thu, 22 Aug 2013 17:22:54 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:67ce89da90df | 2:b74b41bb73f0 |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * Class for tab content of type "qtabs" - this is for rendering a QuickSet instance | |
5 * as the tab content of another QuickSet instance. | |
6 */ | |
7 class QuickQtabsContent extends QuickContent { | |
8 | |
9 public static function getType() { | |
10 return 'qtabs'; | |
11 } | |
12 | |
13 public function optionsForm($delta, $qt) { | |
14 $tab = $this->settings; | |
15 $form = array(); | |
16 $tab_options = array(); | |
17 foreach (quicktabs_load_multiple() as $machine_name => $info) { | |
18 // Do not offer the option to put a tab inside itself. | |
19 if (!isset($qt->machine_name) || $machine_name != $qt->machine_name) { | |
20 $tab_options[$machine_name] = $info->title; | |
21 } | |
22 } | |
23 $form['qtabs']['machine_name'] = array( | |
24 '#type' => 'select', | |
25 '#title' => t('Quicktabs instance'), | |
26 '#description' => t('The Quicktabs instance to put inside this tab.'), | |
27 '#options' => $tab_options, | |
28 '#default_value' => isset($tab['machine_name']) ? $tab['machine_name'] : '', | |
29 ); | |
30 return $form; | |
31 } | |
32 | |
33 public function render($hide_empty = FALSE, $args = array()) { | |
34 if ($this->rendered_content) { | |
35 return $this->rendered_content; | |
36 } | |
37 $item = $this->settings; | |
38 if (!empty($args)) { | |
39 // The args have been passed in from an ajax request. | |
40 // The first element of the args array is the qt_name, which we don't need | |
41 // for this content type. | |
42 array_shift($args); | |
43 $item['machine_name'] = $args[0]; | |
44 } | |
45 | |
46 $output = array(); | |
47 if (isset($item['machine_name'])) { | |
48 if ($quicktabs = quicktabs_load($item['machine_name'])) { | |
49 $contents = $quicktabs->tabs; | |
50 $name = $quicktabs->machine_name; | |
51 unset($quicktabs->tabs, $quicktabs->machine_name); | |
52 $options = (array) $quicktabs; | |
53 if ($qt = QuickSet::QuickSetRendererFactory($name, $contents, $quicktabs->renderer, $options)) { | |
54 $output = $qt->render(); | |
55 } | |
56 } | |
57 } | |
58 $this->rendered_content = $output; | |
59 return $output; | |
60 } | |
61 | |
62 public function getAjaxKeys() { | |
63 return array('machine_name'); | |
64 } | |
65 } |