comparison sites/all/modules/quicktabs/plugins/QuickQuicktabs.inc @ 6:a75ead649730

added biblio, admin_menu and reference modules
author danieleb <danielebarchiesi@me.com>
date Fri, 20 Sep 2013 11:18:21 +0100
parents b74b41bb73f0
children 134d4b2e75f6
comparison
equal deleted inserted replaced
5:d72257b2ddc2 6:a75ead649730
3 /** 3 /**
4 * Renders the content using the original Quicktabs mechanism of previous versions. 4 * Renders the content using the original Quicktabs mechanism of previous versions.
5 * Includes support for ajax rendered content. 5 * Includes support for ajax rendered content.
6 */ 6 */
7 class QuickQuicktabs extends QuickRenderer { 7 class QuickQuicktabs extends QuickRenderer {
8 8
9 public function render() { 9 public function render() {
10 $quickset = $this->quickset; 10 $quickset = $this->quickset;
11 11
12 $render_array = array(); 12 $render_array = array();
13 13
14 $active_tab = $quickset->getActiveTab(); 14 $active_tab = $quickset->getActiveTab();
15 if ($tabs = $this->build_tablinks($active_tab)) { 15 if ($tabs = $this->build_tablinks($active_tab)) {
16 $render_array['#attached'] = $this->add_attached(); 16 $render_array['#attached'] = $this->add_attached();
21 21
22 $render_array['content'] = array( 22 $render_array['content'] = array(
23 '#theme' => 'qt_quicktabs', 23 '#theme' => 'qt_quicktabs',
24 '#options' => array('attributes' => array( 24 '#options' => array('attributes' => array(
25 'id' => 'quicktabs-' . $qt_name, 25 'id' => 'quicktabs-' . $qt_name,
26 'class' => 'quicktabs-wrapper quicktabs-style-' . drupal_strtolower($settings['style']), 26 'class' => 'quicktabs-wrapper quicktabs-style-' . drupal_html_class($settings['style']),
27 )), 27 )),
28 'tabs' => array('#theme' => 'qt_quicktabs_tabset', '#options' => array('active' => $active_tab, 'style' => drupal_strtolower($settings['style'])), 'tablinks' => $tabs), 28 'tabs' => array('#theme' => 'qt_quicktabs_tabset', '#options' => array('active' => $active_tab, 'style' => drupal_html_class($settings['style'])), 'tablinks' => $tabs),
29 // The main content area, each quicktab container needs a unique id. 29 // The main content area, each quicktab container needs a unique id.
30 'container' => array( 30 'container' => array(
31 '#prefix' => '<div id="quicktabs-container-' . $qt_name .'" class="quicktabs_main quicktabs-style-' . drupal_strtolower($settings['style']) .'">', 31 '#prefix' => '<div id="quicktabs-container-' . $qt_name .'" class="quicktabs_main quicktabs-style-' . drupal_html_class($settings['style']) .'">',
32 '#suffix' => '</div>', 32 '#suffix' => '</div>',
33 'divs' => array(), 33 'divs' => array(),
34 ), 34 ),
35 ); 35 );
36 36
53 return $render_array; 53 return $render_array;
54 } 54 }
55 55
56 /** 56 /**
57 * Build the actual tab links, with appropriate href, title and attributes. 57 * Build the actual tab links, with appropriate href, title and attributes.
58 * 58 *
59 * @param $active_tab The index of the active tab. 59 * @param $active_tab The index of the active tab.
60 */ 60 */
61 protected function build_tablinks($active_tab) { 61 protected function build_tablinks($active_tab) {
62 $quickset = $this->quickset; 62 $quickset = $this->quickset;
63 $settings = $quickset->getSettings(); 63 $settings = $quickset->getSettings();
130 $quicktabs_array = array_merge(array('name' => $name, 'tabs' => $tab_settings), $settings); 130 $quicktabs_array = array_merge(array('name' => $name, 'tabs' => $tab_settings), $settings);
131 $attached['js'][] = array('data' => array('quicktabs' => array('qt_' . $name => $quicktabs_array)), 'type' => 'setting'); 131 $attached['js'][] = array('data' => array('quicktabs' => array('qt_' . $name => $quicktabs_array)), 'type' => 'setting');
132 } 132 }
133 return $attached; 133 return $attached;
134 } 134 }
135 135
136 /** 136 /**
137 * Helper function to construct link options for tab links. 137 * Helper function to construct link options for tab links.
138 */ 138 */
139 protected function construct_link_options($tabkey) { 139 protected function construct_link_options($tabkey) {
140 $qt_name = $this->quickset->getName(); 140 $qt_name = $this->quickset->getName();
141 $settings = $this->quickset->getSettings();
142
141 $id = 'quicktabs-tab-' . implode('-', array($qt_name, $tabkey)); 143 $id = 'quicktabs-tab-' . implode('-', array($qt_name, $tabkey));
142 144
143 // Need to construct the correct querystring for the tab links. 145 // Need to construct the correct querystring for the tab links.
144 $query = drupal_get_query_parameters(NULL, array("qt-$qt_name", 'q', 'page')); 146 $query = drupal_get_query_parameters(NULL, array("qt-$qt_name", 'q', 'page'));
145 $query["qt-{$qt_name}"] = $tabkey; 147 $query["qt-{$qt_name}"] = $tabkey;
146 148
147 $link_options = array( 149 $link_options = array(
148 'attributes' => array( 150 'attributes' => array(
149 'id' => $id, 151 'id' => $id,
150 ), 152 ),
151 'query' => $query, 153 'query' => $query,
152 'fragment' => 'qt-' . $qt_name, 154 'fragment' => 'qt-' . $qt_name,
155 'html' => isset($settings['html']) ? $settings['html'] : FALSE,
153 ); 156 );
154 return $link_options; 157 return $link_options;
155 } 158 }
156 } 159 }