You are here

function theme_matrix_table_view in Matrix field 5

1 theme call to theme_matrix_table_view()
matrix_field_formatter in ./matrix.module
Implemenation of hook_field_formatter

File

./matrix.module, line 241

Code

function theme_matrix_table_view($node_field, $field) {
  $rows = trim($field['rows']);
  $cols = trim($field['cols']);
  $rows = explode("\n", $rows);
  $cols = explode("\n", $cols);
  $header = array_merge(array(
    '',
  ), $cols);
  $i = 0;
  foreach ($rows as $row) {
    if ($row) {
      $j = 0;
      $outputs = array(
        $row,
      );
      foreach ($cols as $col) {
        if ($col) {
          if (!empty($node_field[$i][$j])) {
            $outputs[] = $node_field[$i][$j];
          }
          else {
            $outputs[] = '-';
          }
          $j++;
        }
      }
      $i++;
    }
    if ($outputs) {
      $output[] = $outputs;
    }
  }
  return theme('table', $header, $output, array());
}