You are here

function theme_panels_common_context_list in Panels 5.2

Same name and namespace in other branches
  1. 6.2 includes/common.inc \theme_panels_common_context_list()

Create a visible list of all the contexts available on an object. Assumes arguments, relationships and context objects.

Contexts must be preloaded.

2 theme calls to theme_panels_common_context_list()
panels_mini_edit_form in panels_mini/panels_mini.module
Form to edit the settings of a mini panel.
panels_page_edit_form in panels_page/panels_page.admin.inc
The form to edit the page portion of a panel.

File

includes/common.inc, line 1533
Functions used by more than one panels client module.

Code

function theme_panels_common_context_list($object) {
  $titles = array();
  $output = '';
  $count = 1;

  // First, make a list of arguments. Arguments are pretty simple.
  if (!empty($object->arguments)) {
    foreach ($object->arguments as $argument) {
      $output .= '<tr>';
      $output .= '<td><em>' . t('Argument @count', array(
        '@count' => $count,
      )) . '</em></td>';
      $output .= '<td>' . check_plain($argument['identifier']) . '</td>';
      $output .= '</tr>';
      $titles[panels_argument_context_id($argument)] = $argument['identifier'];
      $count++;
    }
  }
  $count = 1;

  // Then, make a nice list of contexts.
  if (!empty($object->contexts)) {
    foreach ($object->contexts as $context) {
      $output .= '<tr>';
      $output .= '<td><em>' . t('Context @count', array(
        '@count' => $count,
      )) . '</em></td>';
      $output .= '<td>' . check_plain($context['identifier']) . '</td>';
      $output .= '</tr>';
      $titles[panels_context_context_id($context)] = $context['identifier'];
      $count++;
    }
  }

  // And relationships
  if (!empty($object->relationships)) {
    foreach ($object->relationships as $relationship) {
      $output .= '<tr>';
      $output .= '<td><em>' . t('From @title', array(
        '@title' => $titles[$relationship['context']],
      )) . '</em></td>';
      $output .= '<td>' . check_plain($relationship['identifier']) . '</td>';
      $output .= '</tr>';
      $titles[panels_relationship_context_id($relationship)] = $relationship['identifier'];
      $count++;
    }
  }
  if ($output) {
    return "<table><tbody>{$output}</tbody></table>\n";
  }
}