You are here

function theme_views_editablefields_view_table in Editable Fields 5.2

Same name and namespace in other branches
  1. 5.3 editablefields.module \theme_views_editablefields_view_table()
  2. 5 editablefields.module \theme_views_editablefields_view_table()

Display the nodes of a view as a table.

File

./editablefields.module, line 298

Code

function theme_views_editablefields_view_table($view, $nodes, $type) {
  $fields = _views_get_fields();
  $editable = _handle_editablefield_form_input($view, $nodes);
  foreach ($nodes as $node) {
    $row = array();
    foreach ($view->field as $field) {
      if ($fields[$field['id']]['visible'] !== FALSE) {
        $cell['data'] = views_theme_field('views_editablefields_handle_field', $field['queryname'], $fields, $field, $node, $view);
        $cell['class'] = "view-field " . views_css_safe('view-field-' . $field['queryname']);
        $row[] = $cell;
      }
    }
    $rows[] = $row;
  }
  $html = theme('table', $view->table_header, $rows);
  if ($editable) {
    $newentry_form = _editablefields_entry_form($view);
    if ($nodes) {
      $form['editablefields']['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Submit'),
      );
      $form['editablefields']['#value'] = $html;
      drupal_process_form('editablefields', $form);
      $eform = drupal_render($form);
      return $eform . $newentry_form;
    }
    else {
      return $newentry_form;
    }
  }
  else {
    return $html;
  }
}