function quicktabs_block in Quick Tabs 5
Same name and namespace in other branches
- 6.3 quicktabs.module \quicktabs_block()
- 6 quicktabs.module \quicktabs_block()
- 6.2 quicktabs.module \quicktabs_block()
Implementation of hook_block
File
- ./
quicktabs.module, line 473
Code
function quicktabs_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$jqueryblocks = array();
$result = db_query('SELECT * FROM {quicktabs}');
while ($row = db_fetch_object($result)) {
$jqueryblocks[$row->qtid] = $row->title;
}
foreach ($jqueryblocks as $key => $val) {
$blocks[$key]['info'] = t($val);
}
return $blocks;
break;
case 'view':
if ($jqueryblock = db_fetch_object(db_query('SELECT qtid, title, tabs FROM {quicktabs} WHERE qtid = %d', $delta))) {
quicktabs_add_css();
drupal_add_js(drupal_get_path('module', 'quicktabs') . '/js/quicktabs.js');
$mainblock['subject'] = $jqueryblock->title;
$tabs = unserialize($jqueryblock->tabs);
if ($tabs[0]['weight']) {
foreach ($tabs as $key => $tab) {
$weight[$key] = $tab['weight'];
}
array_multisort($weight, SORT_ASC, $tabs);
}
$tabtitles = array();
foreach ($tabs as $tab) {
$tabtitles[] = $tab['title'];
}
$output = '<div class="quicktabs_wrapper">';
$output .= theme('quicktabs_tabs', $tabtitles);
$output .= '<div class="quicktabs_main">';
foreach ($tabs as $j => $tab) {
$output .= '<div class="quicktabs qt' . $j . '">';
if ($tab['type'] == 'view') {
if (module_exists('views')) {
if ($tab['args'] != '') {
$args = explode(',', $tab['args']);
}
else {
$args = array();
}
$view = views_get_view($tab['bvid']);
$viewbuild = $tab['build'] ? $tab['build'] : variable_get('quicktabs_viewbuild', 'embed');
$output .= views_build_view($viewbuild, $view, $args, false, $tab['limit']);
}
else {
$output .= 'Views module not enabled, cannot display tab content';
}
}
else {
$pos = strpos($tab['bvid'], '_delta_');
$blockmodule = substr($tab['bvid'], 0, $pos);
$blockdelta = substr($tab['bvid'], $pos + 7);
$block = (object) module_invoke($blockmodule, 'block', 'view', $blockdelta);
$block->module = $blockmodule;
$block->delta = $blockdelta;
if (variable_get('quicktabs_blocktitles', 1) == 1) {
$output .= $block->content ? theme('quicktabs_block', $block, TRUE) : '';
}
else {
$output .= $block->content ? theme('quicktabs_block', $block, FALSE) : '';
}
}
$output .= '</div>';
}
$output .= '</div></div>';
$mainblock['content'] = $output;
}
return $mainblock;
break;
}
}