You are here

function theme_spaces_datetitle_view_style in Spaces 5

Same name and namespace in other branches
  1. 5.2 spaces_views.inc \theme_spaces_datetitle_view_style()

File

./spaces_views.inc, line 105

Code

function theme_spaces_datetitle_view_style($view, $nodes, $type) {
  $fields = _views_get_fields();
  $taken = array();

  // Set up the fields in nicely named chunks.
  foreach ($view->field as $id => $field) {
    $field_name = $field['field'];
    if (isset($taken[$field_name])) {
      $field_name = $field['queryname'];
    }
    $taken[$field_name] = true;
    $field_names[$id] = $field_name;
  }

  // Set up some variables that won't change.
  $base_vars = array(
    'view' => $view,
    'view_type' => $type,
  );

  // CCK fields can be named anything, so we use
  // a custom function to ransack the view for fields we might want
  $custom_fields = array();
  if (_spaces_views_get_field('cck_date', $view) !== false) {
    $custom_fields[_spaces_views_get_field('cck_date', $view)] = 'cck_date';
  }
  foreach ($nodes as $i => $node) {
    $vars = $base_vars;
    $vars['node'] = $node;
    $vars['count'] = $i;
    $vars['stripe'] = $i % 2 ? 'even' : 'odd';
    foreach ($view->field as $id => $field) {
      if (isset($custom_fields[$id])) {
        $name = $custom_fields[$id];
      }
      else {
        $name = $field_names[$id];
      }
      $vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
      if (isset($field['label'])) {
        $vars[$name . '_label'] = $field['label'];
      }
    }
    $items[] = theme('datetime_view_style_item', $vars);
  }
  if ($items) {
    return theme('item_list', $items);
  }
}