You are here

function panels_theme in Panels 6.3

Same name and namespace in other branches
  1. 6.2 panels.module \panels_theme()
  2. 7.3 panels.module \panels_theme()

Implementation of hook_theme()

File

./panels.module, line 30
panels.module

Code

function panels_theme() {

  // Safety: go away if CTools is not at an appropriate version.
  if (!module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) {
    return array();
  }
  $theme = array();
  $theme['panels_layout_link'] = array(
    'arguments' => array(
      'title',
      'id',
      'image',
      'link',
    ),
  );
  $theme['panels_layout_icon'] = array(
    'arguments' => array(
      'id',
      'image',
      'title' => NULL,
    ),
  );
  $theme['panels_pane'] = array(
    'arguments' => array(
      'output' => array(),
      'pane' => array(),
      'display' => array(),
    ),
    'path' => drupal_get_path('module', 'panels') . '/templates',
    'template' => 'panels-pane',
  );
  $theme['panels_common_content_list'] = array(
    'arguments' => array(
      'display',
    ),
    'file' => 'includes/common.inc',
  );
  $theme['panels_render_display_form'] = array(
    'arguments' => array(
      'form' => NULL,
    ),
  );
  $theme['panels_dashboard'] = array(
    'arguments' => array(),
    'path' => drupal_get_path('module', 'panels') . '/templates',
    'file' => '../includes/callbacks.inc',
    'template' => 'panels-dashboard',
  );
  $theme['panels_dashboard_link'] = array(
    'arguments' => array(
      'link' => array(),
    ),
    'path' => drupal_get_path('module', 'panels') . '/templates',
    'file' => '../includes/callbacks.inc',
    'template' => 'panels-dashboard-link',
  );
  $theme['panels_dashboard_block'] = array(
    'arguments' => array(
      'block' => array(),
    ),
    'path' => drupal_get_path('module', 'panels') . '/templates',
    'file' => '../includes/callbacks.inc',
    'template' => 'panels-dashboard-block',
  );

  // We don't need layout and style themes in maintenance mode.
  // Disabling this: See http://drupal.org/node/979912 for information.
  //  if (defined('MAINTENANCE_MODE')) {
  //    return $theme;
  //  }
  // Register layout and style themes on behalf of all of these items.
  ctools_include('plugins', 'panels');

  // No need to worry about files; the plugin has to already be loaded for us
  // to even know what the theme function is, so files will be auto included.
  $layouts = panels_get_layouts();
  foreach ($layouts as $name => $data) {
    foreach (array(
      'theme',
      'admin theme',
    ) as $callback) {
      if (!empty($data[$callback])) {
        $theme[$data[$callback]] = array(
          'arguments' => array(
            'css_id' => NULL,
            'content' => NULL,
            'settings' => NULL,
            'display' => NULL,
            'layout' => NULL,
            'renderer' => NULL,
          ),
          'path' => $data['path'],
          'file' => $data['file'],
        );

        // if no theme function exists, assume template.
        if (!function_exists("theme_{$data['theme']}")) {
          $theme[$data[$callback]]['template'] = str_replace('_', '-', $data[$callback]);
          $theme[$data[$callback]]['file'] = $data['file'];

          // for preprocess.
        }
      }
    }
  }
  $styles = panels_get_styles();
  foreach ($styles as $name => $data) {
    if (!empty($data['render pane'])) {
      $theme[$data['render pane']] = array(
        'arguments' => array(
          'output' => NULL,
          'pane' => NULL,
          'display' => NULL,
          'style' => NULL,
        ),
        'path' => $data['path'],
        'file' => $data['file'],
      );
    }

    // If we're in legacy mode, include the old callback key for legacy styles.
    if (variable_get('panels_legacy_rendering_mode', TRUE)) {
      if (!empty($data['render panel'])) {
        $theme[$data['render panel']] = array(
          'arguments' => array(
            'display' => NULL,
            'panel_id' => NULL,
            'panes' => NULL,
            'settings' => NULL,
            'style' => NULL,
          ),
          'path' => $data['path'],
          'file' => $data['file'],
        );
      }
    }
    if (!empty($data['render region'])) {
      $theme[$data['render region']] = array(
        'arguments' => array(
          'display' => NULL,
          'region_id' => NULL,
          'panes' => NULL,
          'settings' => NULL,
          'style' => NULL,
        ),
        'path' => $data['path'],
        'file' => $data['file'],
      );
    }
    if (!empty($data['hook theme'])) {
      if (is_array($data['hook theme'])) {
        $theme += $data['hook theme'];
      }
      else {
        if (function_exists($data['hook theme'])) {
          $data['hook theme']($theme, $data);
        }
      }
    }
  }
  return $theme;
}