You are here

function PanelizerEntityDefault::make_fake_tabs in Panelizer 7.3

Create some fake tabs that are attached to a page output.

2 calls to PanelizerEntityDefault::make_fake_tabs()
PanelizerEntityDefault::wrap_default_panelizer_pages in plugins/entity/PanelizerEntityDefault.class.php
Provides a wrapper for the panelizer page output.
PanelizerEntityDefault::wrap_entity_panelizer_pages in plugins/entity/PanelizerEntityDefault.class.php
Provides a wrapper for the panelizer page output.

File

plugins/entity/PanelizerEntityDefault.class.php, line 2334
Base class for the Panelizer Entity plugin.

Class

PanelizerEntityDefault
Base class for the Panelizer Entity plugin.

Code

function make_fake_tabs($base_url, $bundle, $view_mode, $output) {

  // Integration with Workbench Moderation: these local tabs will be
  // automatically added via the menu system.
  if (module_exists('workbench_moderation') && isset($bundle->workbench_moderation) && $bundle->workbench_moderation['my_revision']->vid == $bundle->workbench_moderation['current']->vid) {
    return $output;
  }
  $links_array = array();
  foreach (panelizer_operations() as $path => $operation) {
    if ($this
      ->panelizer_access($path, $bundle, $view_mode)) {
      $links_array[$path] = array(
        'title' => t($operation['menu title']),
        'href' => $base_url . '/' . $path,
      );
    }
  }

  // Allow applications to add additional panelizer tabs.
  drupal_alter('panelizer_tab_links', $links_array, $this->entity_type, $bundle, $view_mode);

  // Only render if > 1 link, just like core.
  if (count($links_array) <= 1) {
    return $output;
  }

  // These fake tabs are pretty despicable, but they'll do.
  $links = '<div class="clearfix">' . theme('links', array(
    'links' => $links_array,
    'attributes' => array(
      'class' => array(
        'tabs',
        'secondary',
      ),
    ),
  )) . '</div>';
  if (is_array($output)) {

    // Use array addition because forms will already be sorted so
    // #weight may not be effective.
    $output = array(
      'panelizer_links' => array(
        '#markup' => $links,
        '#weight' => -10000,
      ),
    ) + $output;
  }
  else {
    $output = $links . $output;
  }
  return $output;
}