function quicktabs_render_tabpage in Quick Tabs 6.3
Same name and namespace in other branches
- 6.2 quicktabs.module \quicktabs_render_tabpage()
Render quicktabs tabpage.
4 calls to quicktabs_render_tabpage()
- quicktabs_ajax_block in ./
quicktabs.module - Ajax callback for block tabpage.
- quicktabs_ajax_node in ./
quicktabs.module - Ajax callback for node tabpage.
- quicktabs_ajax_qtabs in ./
quicktabs.module - Ajax callback for qtabs tabpage.
- quicktabs_render in ./
quicktabs.module - Render quicktabs.
File
- ./
quicktabs.module, line 573
Code
function quicktabs_render_tabpage($tab, $hide_empty = FALSE) {
static $cache;
$cachekey = md5(serialize($tab));
if (isset($cache[$cachekey])) {
return $cache[$cachekey];
}
$output = '';
switch ($tab['type']) {
case 'qtabs':
if (isset($tab['machine_name'])) {
if ($quicktabs = quicktabs_load($tab['machine_name'])) {
$output = theme('quicktabs', $quicktabs);
}
}
break;
case 'view':
if (isset($tab['vid'])) {
if (module_exists('views')) {
if ($view = views_get_view($tab['vid'])) {
if ($view
->access($tab['display'])) {
$view
->set_display($tab['display']);
$view
->set_arguments($tab['args']);
$view_output = $view
->preview();
if (!empty($view->result) || $view->display_handler
->get_option('empty') || !empty($view->style_plugin->definition['even empty'])) {
$output = $view_output;
}
else {
$output = '';
}
}
elseif (!$hide_empty) {
$output = theme('quicktabs_tab_access_denied', $tab);
}
$view
->destroy();
}
}
elseif (!$hide_empty) {
$output = t('Views module not enabled, cannot display tab content.');
}
}
break;
case 'block':
if (isset($tab['bid'])) {
// Ensure the block is assigned to the requested quicktabs block. This test prevents
// AJAX access to blocks that have not been added to an AJAX-enabled quicktabs block.
// The qt_name key is set only for AJAX requests.
if (isset($tab['qt_name'])) {
$break = TRUE;
$quicktabs = quicktabs_load($tab['qt_name']);
// Ensure AJAX is enabled for the quicktabs block.
if (!empty($quicktabs) && $quicktabs['ajax'] == 1) {
// Ensure the requested tab has been added to the quicktabs block.
foreach ($quicktabs['tabs'] as $quicktab) {
if (isset($quicktab['bid']) && $quicktab['bid'] == $tab['bid']) {
$break = FALSE;
break;
}
}
}
if ($break == TRUE) {
if (!$hide_empty) {
$output = theme('quicktabs_tab_access_denied', $tab);
}
break;
}
}
$pos = strpos($tab['bid'], '_delta_');
$blockmodule = substr($tab['bid'], 0, $pos);
$blockdelta = substr($tab['bid'], $pos + 7);
$access = _quictabs_access_block($blockmodule, $blockdelta);
if ($access) {
$block = (object) module_invoke($blockmodule, 'block', 'view', $blockdelta);
if (isset($block->content)) {
$block->module = $blockmodule;
$block->delta = $blockdelta;
$block->region = 'quicktabs_tabpage';
if ($tab['hide_title'] || !isset($block->subject)) {
$block->subject = FALSE;
}
$output = theme('block', $block);
}
}
else {
$output = theme('quicktabs_tab_access_denied', $tab);
}
}
break;
case 'node':
if (isset($tab['nid'])) {
$node = node_load($tab['nid']);
if (!empty($node)) {
if (node_access('view', $node)) {
$output = node_view($node, $tab['teaser'], $tab['hide_title'], TRUE);
}
elseif (!$hide_empty) {
$output = theme('quicktabs_tab_access_denied', $tab);
}
}
}
break;
case 'freetext':
$output = $tab['text'];
break;
case 'callback':
$output = menu_execute_active_handler($tab['path']);
break;
}
$cache[$cachekey] = $output;
return $output;
}