Creates table header

@param array $rows
@return \Krystal\Form\NodeElement
506379
private function createTopHeadingRow(array $rows)
    {
        $elements = array();

        if ($this->options[self::GRID_PARAM_BATCH] === true) {
            $checkbox = Element::checkbox(null, false, array(), false);
            $elements[] = $this->createColumn(null, $checkbox);
        }

        foreach ($rows as $row) {
            // Ignore if configuration for current column isn't provided
            if (!$this->hasColumnConfiguration($row[self::GRID_PARAM_COLUMN])) {
                continue;
            }

            $column = isset($row[self::GRID_PARAM_COLUMN]) ? $row[self::GRID_PARAM_COLUMN] : null;
            // Use label if provided explicitly, otherwise use normalized column name as a fallback
            $label = isset($row[self::GRID_PARAM_LABEL]) ? $row[self::GRID_PARAM_LABEL] : TextUtils::normalizeColumn($row[self::GRID_PARAM_COLUMN]);

            // If sorting isn't defined, then assume that it's true by default
            if (!isset($row[self::GRID_PARAM_SORTING]) && isset($row[self::GRID_PARAM_FILTER]) && $row[self::GRID_PARAM_FILTER] == true) {
                $row[self::GRID_PARAM_SORTING] = true;
            } else {
                $row[self::GRID_PARAM_SORTING] = false;
            }

            // If translation isn't defined, assume true by default
            if (!isset($row[self::GRID_PARAM_TRANSLATE])) {
                $row[self::GRID_PARAM_TRANSLATE] = true;
            }

            // Translate if required
            if ($row[self::GRID_PARAM_TRANSLATE] == true && $this->hasTranslator()) {
                $label = $this->translator->translate($label);
            }

            // Creating a link or raw text here
            if ($row[self::GRID_PARAM_SORTING] === true) {
                // Use explicit key parameter for sorting if provided
                $inputName = isset($row[self::GRID_PARAM_NAME]) ? $row[self::GRID_PARAM_NAME] : $column;

                $elements[] = $this->createHeader($this->createHeaderLink($inputName, ' ' . $label));
            } else {
                $elements[] = $this->createTextHeader($label);
            }
        }

        if ($this->hasActions()) {
            $actionLabel = 'Actions';
            $actionLabel = $this->hasTranslator() ? $this->translator->translate($actionLabel) : $actionLabel;
            $elements[] = $this->createTextHeader($actionLabel);
        }

        return $this->createTableRow($elements);
    }
1346840
private function makeTableBody($headers, $rows)
    {
        $body = [];
        $tableCellWidth = ($this->option('w')) ? $this->option('w') : 10;
        for ($i = 0; $i < count($rows); $i++) {
            $row = [];
            for ($j = 0; $j < count($headers); $j++) {
                $column = $headers[$j];
                $row[$j] = str_limit($rows[$i]->$column, $tableCellWidth, '');
            }
            $body[$i] = $row;
        }
        return $body;
    }
867144
public function addRow($rows = null) {
        if( ! is_array($rows) ) {
            $rows = func_get_args();
        }
        $row = new TableRow;
        foreach( $rows as $arg ) {
            $cell = new TableCell;
            $cell->addChild( $arg );
            $row->addChild( $cell );
        }
        $this->addChild($row);
        return $row;
    }
305975
public function createRow(array $data = array())
    {
        $cols     = $this->getColumns();
        $defaults = array_combine($cols, array_fill(0, count($cols), null));

        $config = array(
            'table'    => $this,
            'data'     => $defaults,
            'stored'   => false
        );

        $rowClass = $this->_rowClass;
        $row = new $rowClass($config);
        $row->setFromArray($data);
        return $row;
    }
954542
private function createBodyRows($columns, array $data)
    {
        $rows = array();

        foreach ($data as $row) {
            $rows[] = $this->createBodyRow($columns, $row);
        }

        return $rows;
    }
1304452
public static function renderTableHeaderRow(array $arrCells) : string
    {
        $strRow = "";
        foreach ($arrCells as $th) {
            $strRow .= self::th($th);
        }
        return self::tr($strRow);
    }
847860
private function createHeader($children = array(), $text = null)
    {
        return $this->createElement('th', $children, array('class' => $this->options['tableHeaderClass']), $text);
    }
1084749
public function render(array $columnNames, array $rows): string
	{
		if(!$this->isValidInput($columnNames, $rows))
		{
			throw new RuntimeException('The number of cells in each row must match the number of columns.');
		}

		$columnWidths = $this->getColumnWidths($columnNames, $rows);

		// Build table header

		$table = $this->buildRowSeparator($columnWidths);

		$table .= $this->buildTableRow($columnNames, $columnWidths);

		$table .= $this->buildRowSeparator($columnWidths);

		// Add table rows

		foreach($rows as $row)
		{
			$table .= $this->buildTableRow($row, $columnWidths);
		}

		// Add bottom border

		$table .= $this->buildRowSeparator($columnWidths);

		// Return table

		return $table;
	}
667072
protected function fillRows(array $rows)
    {
        $row = [];
        $seriesOptions = $this->seriesOptions();
        foreach ($seriesOptions as $serieId => $serieOpts) {
            $row[$serieId] = '0';
        }

        $starts = clone($this->startDate());
        $ends = $this->endDate();
        while ($starts < $ends) {
            $x = $starts->format($this->dateFormat());
            if (!isset($rows[$x])) {
                $rows[$x] = $row;
            }
            $starts->add($this->dateInterval());
        }
        ksort($rows);
        return $rows;
    }
615251
private function createRow($key, $value)
    {
        $tr = new NodeElement();
        $tr->openTag('tr');

        $first = new NodeElement();
        $first->openTag('td')
              ->finalize()
              ->setText($key)
              ->closeTag();

        $second = new NodeElement();
        $second->openTag('td')
              ->finalize()
              ->setText($value)
              ->closeTag();

        $tr->appendChildren(array($first, $second));
        $tr->closeTag();

        return $tr;
    }
1138389
private function copyRow($rows, $line)
    {
        $row = $rows[$line];
        foreach ($row as $cellKey => $cellValue) {
            $row[$cellKey] = '';
            if ($cellValue instanceof TableCell) {
                $row[$cellKey] = new TableCell('', array('colspan' => $cellValue->getColspan()));
            }
        }

        return $row;
    }
772083
public function export(array &$rows)
    {
        $config     = $this->getConfiguration('export');
        $fieldNames = isset($config['fields']) ? $config['fields'] : null;
        $result     = array();

        if ($fieldNames) {
            foreach ($rows as &$row) {
                $exportRow = array();
                foreach ($fieldNames as $fieldName => $fieldCode) {
                    $exportRow[ $fieldName ] = $this->evaluateField($row, $fieldCode);
                }
                $result[] = $exportRow;
            }
        } else {
            $result = &$rows;
        }

        return $result;
    }
1287411
protected function writeTable(array $headers, array $rows)
    {
        $columnCount = count($headers);
        $rowCount = count($rows) + 1;
        $columns = array_fill(0, $columnCount, 0);
        $tables = [];

        foreach (array_merge([$headers], $rows) as $row) {
            $i = -1;
            $newRow = [];
            foreach ($row as $col) {
                $newRow[++$i] = StringParser::create($col)->getParsed();
                $newRow[$i]['len'] = 0;
                foreach ($newRow[$i] as $part) {
                    $newRow[$i]['len'] += strlen($part['original']);
                }
                $columns[$i] = max($columns[$i], $newRow[$i]['len']);
            }
            $tables[] = $newRow;
        }

        $i = -1;
        $line = str_repeat('-', array_sum($columns) + $columnCount + 2);
        foreach ($tables as $row) {
            if (++$i === 0) {
                echo $line . PHP_EOL;
            }
            $j = -1;
            foreach ($row as $col) {
                ++$j;
                $len = array_pop($col);
                foreach ($col as $part) {
                    echo ' ' . $part['colored'];
                    echo str_repeat(' ', $columns[$j] - $len + 1);
                }
            }

            if ($i === 0) {
                echo PHP_EOL;
                echo $line;
            }

            echo PHP_EOL;
            if ($i === $rowCount - 1) {
                echo $line . PHP_EOL;
            }
        }
    }
161809
public static function create(array $tokens) {
        HashMap::assert($tokens, 'tokens');

        if (empty($tokens['LIMIT'])) return [];

        $headers = [];
        array_push($headers, 'Limit: ' . $tokens['LIMIT']['rowcount']);
        if(empty($tokens['LIMIT']['offset'])) return $headers;
        array_push($headers, 'Offset: ' . $tokens['LIMIT']['offset']);
        return $headers;
    }
258564
public function setRow(TableRow $row = null)
    {
        $this->row = $row;

        if (null !== $row && !in_array($this, $row->getCells())) {
            $row->addCell($this);
        }

        return $this;
    }
272853
public function prepareResults(&$rows)
    {
        foreach ($rows as $key => &$row) {
            $row = $this->create($row);
        }
        return $rows;
    }
1067308
function addRows($rows)
	{
		for($i=0; $i < count($rows); $i++) $this->addRow($rows[$i]);
	}