<?php

/**
 * @file
 */

function theme_stormidea_list($header, $ideas) {
  $rows = array();

  foreach ($ideas as $idea) {
    $rows[] = array(
      '<span class="idea-title">' . $idea->title . '</span>',
      _format_small_date($idea->changed),
      array(
        'data' => storm_icon_edit_node($idea, $_GET) . storm_icon_delete_node($idea, $_GET),
        'class' => 'storm_list_operations',
      ),
    );
  }
  $o = theme('table', $header, $rows, array('id' => 'stormideas'));
  return $o;
}

function theme_stormidea_view($node, $teaser = FALSE, $page = FALSE) {
  $node = node_prepare($node, $teaser);
  $l_pos = 1; // Used to increase the link position number (see issue 814820)

  $node->content['links'] = array(
    '#prefix' => '<div class="stormlinks"><dl>',
    '#suffix' => '</dl></div>',
    '#weight' => $l_pos++,
  );
  $node->content['group1'] = array(
    '#prefix' => '<div class="stormfields">',
    '#suffix' => '</div>',
    '#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
  );
  $node->content['group1']['created'] = array(
    '#prefix' => '<div class="created">',
    '#suffix' => '</div>',
    '#value' => theme('storm_view_item', t('Idea recorded'), _format_small_date($node->created)),
    '#weight' => 12,
  );
  if ($node->changed != $node->created) {
    $node->content['group1']['modified'] = array(
      '#prefix' => '<div class="created">',
      '#suffix' => '</div>',
      '#value' => theme('storm_view_item', t('Note updated'), _format_small_date($node->changed)),
      '#weight' => 13,
    );
  }

  unset($node->content['body']);

  return $node;
}
