Ejemplo n.º 1
0
 /**
  * @return array[][]
  */
 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;
 }
Ejemplo n.º 2
0
 /**
  * @param string $groupName
  * @param string[] $colNameSuffixes
  *
  * @return $this
  * @throws Exception
  */
 function addColGroup($groupName, array $colNameSuffixes)
 {
     $this->columns->addColGroup($groupName, $colNameSuffixes);
     return $this;
 }