You are here

function theme_panels_tabs_style_render_region in Panels Tabs 6

Same name and namespace in other branches
  1. 7.2 plugins/styles/tabs.inc \theme_panels_tabs_style_render_region()
  2. 7 plugins/styles/tabs.inc \theme_panels_tabs_style_render_region()

Render region callback.

File

plugins/styles/tabs.inc, line 26
Definition of the 'tabs' panel style.

Code

function theme_panels_tabs_style_render_region($display, $owner_id, $panes, $settings) {
  $output = '';

  // Generate a unique id based on the CSS ID and the name of the panel in the
  // layout.
  $id = '';

  //If CSS ID is set.
  if ($display->css_id) {
    $id = "{$display->css_id}-";
  }
  $pane_id = reset(array_keys($panes));
  $id .= $display->content[$pane_id]->panel;

  // Add the Javascript to the page, and save the settings for this panel.
  _panels_tabs_add_js($id, $settings['filling_tabs']);
  $tabs = array();
  $tabs[$id] = array(
    '#type' => 'tabset',
    '#tabset_name' => $id,
  );
  $index = 0;
  foreach ($panes as $pane_id => $pane_content) {
    if (!empty($pane_content)) {
      $tabs[$id][$pane_id] = array(
        '#type' => 'tabpage',
        '#title' => $display->content[$pane_id]->tab_title,
        '#content' => $pane_content,
        '#weight' => $index,
      );
      $index++;
    }
  }

  // No content has been rendered
  if (empty($index)) {
    return;
  }

  // See if an optional title was added.
  if (!empty($settings['title'])) {
    $output .= theme('panels_tabs_title', $settings['title']);
  }
  $output .= tabs_render($tabs);
  return $output;
}