<?php

/**
 * @file
 */

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

  foreach ($ideas as $idea) {
    $rows[] = array(
      '<span class="idea-title">' . $idea->title . theme('mark', node_mark($idea->nid, $idea->changed)) . '</span>',
      format_date($idea->changed, 'small'),
      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) {
  drupal_add_css(drupal_get_path('module', 'storm') . '/storm-node.css', 'module');

  $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_date($node->created, 'small')),
    '#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_date($node->changed, 'small')),
      '#weight' => 13,
    );
  }

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

  return $node;
}
