You are here

private function crumbs_UI_TableSection::getMatrix in Crumbs, the Breadcrumbs suite 7.2

Return value

array[][]

2 calls to crumbs_UI_TableSection::getMatrix()
crumbs_UI_TableSection::getDrupalRows in lib/UI/TableSection.php
Returns rows that can be used in Drupal 7's theme('table').
crumbs_UI_TableSection::render in lib/UI/TableSection.php
Renders the table section as a tbody, thead or tfoot.

File

lib/UI/TableSection.php, line 158

Class

crumbs_UI_TableSection

Code

private function getMatrix() {
  $matrix = array();
  $cols = $this->columns
    ->getCols();
  $colNames = array_keys($cols);

  // Fill all 1x1 cells.
  foreach ($this->rows as $rowName => $rTrue) {
    foreach ($cols as $colName => $cTrue) {
      $matrix[$rowName][$colName] = isset($this->cells[$rowName][$colName]) ? $this->cells[$rowName][$colName] : array(
        '',
        'td',
        array(),
      );
    }
  }
  $colGroups = $this->columns
    ->getColGroups();

  // Fill horizontal cell groups (colspan).
  foreach ($this->cells as $rowName => $rowCellGroups) {
    if (!isset($this->rows[$rowName])) {
      continue;
    }
    foreach ($rowCellGroups as $colGroupName => $cell) {
      if (!isset($colGroups[$colGroupName])) {
        continue;
      }
      $colNameSuffixes = $colGroups[$colGroupName];
      $cell[2]['colspan'] = count($colNameSuffixes);
      $matrix[$rowName][$colGroupName . '.' . $colNameSuffixes[0]] = $cell;
      for ($i = 1; $i < count($colNameSuffixes); ++$i) {
        unset($matrix[$rowName][$colGroupName . '.' . $colNameSuffixes[$i]]);
      }
    }
  }

  // Fill full-width cells (colspan).
  foreach ($this->cells as $rowName => $rowCellGroups) {
    if (!isset($this->rows[$rowName])) {
      continue;
    }
    if (!isset($rowCellGroups[''])) {
      continue;
    }
    $cell = $rowCellGroups[''];
    $cell[2]['colspan'] = count($cols);
    $matrix[$rowName][$colNames[0]] = $cell;
    for ($i = 1; $i < count($cols); ++$i) {
      unset($matrix[$rowName][$colNames[$i]]);
    }
  }

  // Fill full-height cells (rowspan).
  if (isset($this->cells[''])) {
    $rowNames = array_keys($this->rows);
    foreach ($this->cells[''] as $colName => $cell) {
      if (!isset($cols[$colName])) {
        continue;
      }
      $cell[2]['rowspan'] = count($rowNames);
      $matrix[$rowNames[0]][$colName] = $cell;
      for ($i = 1; $i < count($rowNames); ++$i) {
        unset($matrix[$rowNames[$i]][$colName]);
      }
    }
  }

  // Vertical cell groups are not implemented yet.
  return $matrix;
}