You are here

function theme_revisioning_revisions_summary in Revisioning 6.4

Same name and namespace in other branches
  1. 8 revisioning_theme.inc \theme_revisioning_revisions_summary()
  2. 6.3 revisioning_theme.inc \theme_revisioning_revisions_summary()
  3. 7 revisioning_theme.inc \theme_revisioning_revisions_summary()

Theme the supplied form.

Uses the following subthemes: o 'table_revisions', falling back to theme.inc/theme_table() if not defined o 'placeholder' (to display current revision status) o 'username' Uses the following style-classes (see revisioning.css) o 'table-revisions' o 'revision-current' and 'published' o 'revision-pending'

Parameters

$form:

Return value

unknown_type

File

./revisioning_theme.inc, line 156
Include file for revisioning.module; deals with all theming aspects.

Code

function theme_revisioning_revisions_summary($form) {

  // Need node info, fortunately node_load() employs a cache so is efficient
  $node = node_load($form['nid']['#value']);
  $css_path = drupal_get_path('module', 'revisioning') . '/revisioning.css';
  drupal_add_css($css_path, 'module', 'all', FALSE);

  // Set up the table rows
  $rows = array();
  $revision_ids = element_children($form['info']);
  $show_diff = count($revision_ids) >= 2 && module_exists('diff');
  $show_taxonomy_terms = module_exists('taxonomy') && count(taxonomy_get_vocabularies()) > 0 && variable_get("show_taxonomy_terms", TRUE);

  // Set up the table header
  $header = array(
    t('Revision'),
  );
  if ($show_diff) {
    $header[] = array(
      'data' => drupal_render($form['submit']),
      'class' => 'form-submit',
    );
  }
  if ($show_taxonomy_terms) {
    $header[] = t('Term');
  }
  $header[] = t('Status');
  $is_initial_unpublished_draft = !$node->status && count($revision_ids) == 1;
  foreach ($revision_ids as $vid) {
    $row = array();

    // Revision info
    $row[] = drupal_render($form['info'][$vid]);

    // Compare checkbox
    if ($show_diff) {
      $row[] = array(
        'data' => drupal_render($form['tickbox'][$vid]),
      );
    }

    // Term
    if ($show_taxonomy_terms) {
      $row[] = drupal_render($form['term'][$vid]);
    }

    // Publication status
    $is_current = $vid == $node->vid;
    $is_pending = $vid > $node->vid || $is_initial_unpublished_draft;
    if ($is_pending) {
      $row[] = array(
        'data' => t('in draft/pending publication'),
      );
    }
    else {
      $row[] = array(
        'data' => $is_current && $node->status ? theme('placeholder', t('current revision (published)')) : t('archived'),
      );
    }

    // Apply css
    $row_style = $is_current ? 'revision-current' : ($is_pending ? 'revision-pending' : NULL);
    if ($is_current && $node->status) {
      $row_style .= ' published';
    }
    $rows[] = array(
      'data' => $row,
      'class' => $row_style,
    );
  }
  $attributes = array(
    'class' => 'table-revisions',
  );
  $content = theme(array(
    'table_revisions',
    'table',
  ), $header, $rows, $attributes, $caption = NULL);
  $submenu_links = _revisioning_generate_node_links_according_to_permissions($node);
  return theme(array(
    'revisions_summary',
  ), $submenu_links, $content) . drupal_render($form);
}