Exemple #1
0
 /**
  * @param CellMatrix $matrix
  * @param \Donquixote\Cellbrush\Axis\Axis $rows
  * @param \Donquixote\Cellbrush\Axis\Axis $columns
  */
 public function modifyMatrix(CellMatrix $matrix, Axis $rows, Axis $columns)
 {
     // Fill the basic cells.
     foreach ($this->getCells() as $rowName => $rowCells) {
         $rowRange = $rows->subtreeRange($rowName);
         foreach ($rowCells as $colName => $cell) {
             $colRange = $columns->subtreeRange($colName);
             $brush = new RangedBrush($rowRange, $colRange);
             $matrix->addCell($brush, $cell);
         }
     }
 }
 /**
  * @return AttributesInterface[]
  *   Objects representing attributes for each TR element.
  * @see BuildContainer::$IndexedRowAttributes
  */
 protected function get_IndexedRowAttributes()
 {
     /** @var Attributes[] $all */
     $all = [];
     foreach ($this->rows->getLeafMap() as $rowName => $iRow) {
         $all[$iRow] = $this->RowAttributes->nameGetAttributes($rowName);
     }
     foreach ($this->RowStripings as $striping) {
         $n = count($striping);
         foreach ($all as $i => $attr) {
             if (isset($striping[$i % $n])) {
                 $all[$i] = $attr->addClass($striping[$i % $n]);
             }
         }
     }
     return $all;
 }
 /**
  * @param Axis $columns
  *   Either 'thead' or 'tbody' or 'tfoot'.
  * @param StaticAttributesMap $tableColAttributes
  *
  * @return string
  *   Rendered table section html.
  */
 function render(Axis $columns, StaticAttributesMap $tableColAttributes)
 {
     if ($this->rows->isEmpty() || !$columns->getCount()) {
         return '';
     }
     $container = new BuildContainer($this->rows->takeSnapshot(), $columns, $this->cellMap->getCells());
     /** @var BuildContainerBase $container */
     $container->OpenEndCells = $this->openEndMap->getNames();
     $container->RowAttributes = clone $this->rowAttributes->staticCopy();
     $container->RowStripings = $this->rowStripings;
     $container->TableColAttributes = $tableColAttributes;
     $container->SectionColAttributes = $this->colAttributes->staticCopy();
     /** @var BuildContainer $container */
     $innerHtml = $container->InnerHtml;
     return '  ' . $this->renderTag($this->tagName, "\n" . $innerHtml . '  ') . "\n";
 }