You are here

function skinr_panels_skinr_ui_element_options in Skinr 8.2

Same name and namespace in other branches
  1. 7.2 skinr_panels/skinr_panels.skinr.inc \skinr_panels_skinr_ui_element_options()

Implements hook_skinr_ui_element_options().

File

skinr_panels/skinr_panels.skinr.inc, line 17
Implements Skinr hooks for panels.module.

Code

function skinr_panels_skinr_ui_element_options($theme_name = NULL) {
  $options = array(
    'panels' => array(),
  );

  // Load displays for pages.
  if (module_exists('page_manager')) {
    module_load_include('inc', 'page_manager', 'page_manager.admin');
    ctools_include('plugins', 'panels');
    $tasks = page_manager_get_tasks_by_type('page');
    $pages = array(
      'operations' => array(),
    );
    page_manager_get_pages($tasks, $pages);
    foreach ($pages['rows'] as $task_name => $page) {

      // Skip disabled pages.
      if ($pages['disabled'][$task_name]) {
        continue;
      }
      list($task_id, $subtask_id) = page_manager_get_task_id($task_name);
      $task = $tasks[$task_id];
      if (empty($task)) {
        continue;
      }
      if ($subtask_id) {
        $subtask = page_manager_get_task_subtask($task, $subtask_id);
        if (empty($subtask)) {
          continue;
        }
      }
      else {
        $subtask = $task;
        $subtask['name'] = '';
      }
      $handlers = page_manager_load_sorted_handlers($task, $subtask_id);
      $dids = array();
      foreach ($handlers as $handler) {
        if ($handler->handler != 'panel_context') {
          continue;
        }
        if (!isset($handler->conf['did'])) {

          // In code.
          $display = $handler->conf['display'];
        }
        else {
          $display = panels_load_display($handler->conf['did']);
        }

        // Output display.

        /*
        // No use in outputting display if we can't add classes to it. It's
        // only possible with a custom template override.
        $name = 'display__' . $display->uuid;
        $title = t('Display');
        $options['panels']['   ' . $display->title][$name] = $title;
        */

        // Output regions.

        /*
        // No use in outputting regions if we can't add classes to them.
        $layout = panels_get_layout($display->layout);
        foreach ($layout['regions'] as $region_id => $title) {
          $name = 'region__' . $display->uuid . '__' . $region_id;
          $title = t('Region: @region', array('@region' => $title));
          $options['panels']['   ' . $display->title][$name] = $title;
        }
        */

        // Output panes.
        foreach ($display->content as $pane) {
          if (!isset($pane->uuid)) {

            // Old version of panels; skip.
            $message = 'Pane @pane_id in display @display is missing a UUID property.';
            drupal_set_message(t($message, array(
              '@pane_id' => $pane->pid,
              '@display' => $display->title,
            )), 'warning');
            watchdog('skinr_panels', $message, array(
              '@pane_id' => $pane->pid,
              '@display' => $display->title,
            ), WATCHDOG_WARNING);
            continue;
          }
          $name = 'pane__' . $pane->uuid;
          $title = t('Pane: @pane_id', array(
            '@pane_id' => $pane->uuid,
          ));
          $options['panels']['   ' . $display->title][$name] = $title;
        }
      }
    }
  }
  ksort($options['panels']);

  // Load displays for panel nodes.
  if (module_exists('panels_node')) {
    $query = new EntityFieldQuery();
    $nids = $query
      ->entityCondition('entity_type', 'node')
      ->entityCondition('bundle', 'panel')
      ->propertyCondition('status', '1')
      ->propertyOrderBy('title', 'ASC')
      ->execute();
    if ($nids) {
      foreach (node_load_multiple(array_keys($nids['node'])) as $node) {
        $display = panels_load_display($node->panels_node['did']);
        $category = t('Panel node: @title', array(
          '@title' => $node->title,
        ));

        // Output display.

        /*
        // No use in outputting display if we can't add classes to it. It's
        // only possible with a custom template override.
        $name = 'display__' . $display->uuid;
        $title = t('Display');
        $options['panels']['   ' . $category][$name] = $title;
        */

        // Output regions.

        /*
        // No use in outputting regions if we can't add classes to them.
        $layout = panels_get_layout($display->layout);
        foreach ($layout['regions'] as $region_id => $title) {
          $name = 'region__' . $display->uuid . '__' . $region_id;
          $title = t('Region: @region', array('@region' => $title));
          $options['panels']['   ' . $category][$name] = $title;
        }
        */

        // Output panes.
        foreach ($display->content as $pane) {
          $name = 'pane__' . $pane->uuid;
          $title = t('Pane: @pane_id', array(
            '@pane_id' => $pane->uuid,
          ));
          $options['panels']['   ' . $category][$name] = $title;
        }
      }
    }
  }

  // Load displays for mini panels.
  if (module_exists('panels_mini')) {
  }
  return $options;
}