You are here

function _quicktabs_build_content_block in Quick Tabs 7.2

File

./quicktabs.module, line 393

Code

function _quicktabs_build_content_block($tab, $hide_empty = FALSE) {
  $output = array();
  if (isset($tab['bid'])) {
    if (module_exists('block')) {

      // 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['#markup'] = theme('quicktabs_tab_access_denied', $tab);
          }
          return $output;
        }
      }
      $pos = strpos($tab['bid'], '_delta_');
      $module = drupal_substr($tab['bid'], 0, $pos);
      $delta = drupal_substr($tab['bid'], $pos + 7);
      $block = block_load($module, $delta);
      $block->region = 'quicktabs_tabpage';
      if ($block_arr = _block_render_blocks(array(
        $block,
      ))) {
        if ($tab['hide_title']) {
          $block_arr["{$block->module}_{$block->delta}"]->subject = FALSE;
        }
        if (!empty($block_arr["{$block->module}_{$block->delta}"]->content)) {
          $build = _block_get_renderable_array($block_arr);
          $output = $build;
        }
      }
    }
    elseif (!$hide_empty) {
      $output['#markup'] = t('Block module is not enabled, cannot display tab content.');
    }
  }
  return $output;
}