Render $table into html.

This method is generally called via double-dispatch, as provided by Visitor\VisitableTrait.

@param TableInterface $table
@return string
18234
public function visitTable(TableInterface $table)
    {
        $template = 'table/base.twig';

        $filters = [];
        for ($thisFilter = $table->getFilter(); $thisFilter !== null; $thisFilter = $thisFilter->getNextFilter()) {
            $filters[] = $thisFilter;
        }

        return $this
            ->loadTemplate($template)
            ->render(
                [
                    "id" => $table->getId(),
                    "classes" => $table->getClasses(),
                    "data" => $table->getData(),
                    "rows" => $table->getRows(),
                    "filters" => $filters,
                ]
            );
    }
211548
protected function renderTable($table, $returnOnlyDataTableXml = false, $prefixLines = '')
    {
        $array = $this->getArrayFromDataTable($table);
        if ($table instanceof Map) {
            $out = $this->renderDataTableMap($table, $array, $prefixLines);

            if ($returnOnlyDataTableXml) {
                return $out;
            }
            $out = "<results>\n$out</results>";
            return $out;
        }

        // integer value of ZERO is a value we want to display
        if ($array != 0 && empty($array)) {
            if ($returnOnlyDataTableXml) {
                throw new Exception("Illegal state, what xml shall we return?");
            }
            $out = "<result />";
            return $out;
        }
        if ($table instanceof Simple) {
            if (is_array($array)) {
                $out = $this->renderDataTableSimple($array);
            } else {
                $out = $array;
            }
            if ($returnOnlyDataTableXml) {
                return $out;
            }

            if (is_array($array)) {
                $out = "<result>\n" . $out . "</result>";
            } else {
                $value = self::formatValueXml($out);
                if ($value === '') {
                    $out = "<result />";
                } else {
                    $out = "<result>" . $value . "</result>";
                }
            }
            return $out;
        }

        if ($table instanceof DataTable) {
            $out = $this->renderDataTable($array);
            if ($returnOnlyDataTableXml) {
                return $out;
            }
            $out = "<result>\n$out</result>";
            return $out;
        }

        if (is_array($array)) {
            $out = $this->renderArray($array, $prefixLines . "\t");
            if ($returnOnlyDataTableXml) {
                return $out;
            }
            return "<result>\n$out</result>";
        }
    }
270632
public function renderTable(): string
    {
        $output = '';

        if ($this->tableOptionsInit !== null) {
            $output .= "        {$this->tableOptionsInit}\n\n";
        }

        $output .= "        \$this->createTable('" . $this->renderName() . "', [";

        foreach ($this->columns as $column) {
            $output .= "\n" . $column->render($this);
        }

        $output .= "\n        ]" . ($this->tableOptions !== null ? ", {$this->tableOptions}" : '') . ");\n";

        return $output;
    }
97971
public function render(ElementInterface $element): string
    {
        if (! $element instanceof ErrorAwareInterface) {
            throw new InvalidClassException(
                sprintf(
                    'The given element "%s" does not implement "%s"',
                    $element->name(),
                    ErrorAwareInterface::class
                )
            );
        }

        $errors = $element->errors();
        if (count($errors) < 1) {
            return '';
        }

        $html = array_reduce(
            $errors,
            function ($html, $error): string {
                $html .= sprintf(
                    $this->options['error'],
                    $error
                );

                return $html;
            },
            ''
        );

        return sprintf(
            $this->options['wrapper'],
            $html
        );
    }
682458
public function renderAsTable() {
    $html = '';
    foreach ($this->cells as $iRow => $rowCells) {
      $rowHtml = '';
      foreach ($rowCells as $iCol => $cell) {
        $rowHtml .= $cell->render();
      }
      $html .= '    <tr>' . $rowHtml . '</tr>' . "\n";
    }
    return "<table>\n  <tbody>\n" . $html . "  </tbody>\n</table>\n";
  }
1064907
public function escapeTable(string $table): string
	{
		$segments = [];

		foreach(explode('.', $table) as $segment)
		{
			$segments[] = $this->escapeIdentifier($segment);
		}

		return implode('.', $segments);
	}
1101
protected function renderDataTableMap($table, &$allColumns = array())
    {
        $str = '';
        foreach ($table->getDataTables() as $currentLinePrefix => $dataTable) {
            $returned = explode("\n", $this->renderTable($dataTable, $allColumns));

            // get rid of the columns names
            $returned = array_slice($returned, 1);

            // case empty datatable we don't print anything in the CSV export
            // when in xml we would output <result date="2008-01-15" />
            if (!empty($returned)) {
                foreach ($returned as &$row) {
                    $row = $currentLinePrefix . $this->separator . $row;
                }
                $str .= "\n" . implode("\n", $returned);
            }
        }

        // prepend table key to column list
        $allColumns = array_merge(array($table->getKeyName() => true), $allColumns);

        // add header to output string
        $str = $this->getHeaderLine(array_keys($allColumns)) . $str;

        return $str;
    }
188544
protected function renderHead(TableAbstract $table, DataRequest $dataRequest)
    {
        $head = new Head();

        // Add the name row
        $row = new Row($head);
        foreach ($table->getColumns() as $column) {
            $cell = new Cell($column, $row, $column->getName());
            
            $row->addCell($cell);
        }
        
        $head->addRow($row);
        
        return $head;
    }
673309
protected function getTable(OutputInterface $output)
    {
        if (!\class_exists('Symfony\Component\Console\Helper\Table')) {
            return $this->getTableHelper();
        }

        $style = new TableStyle();
        $style
            ->setVerticalBorderChar(' ')
            ->setHorizontalBorderChar('')
            ->setCrossingChar('');

        $table = new Table($output);

        return $table
            ->setRows([])
            ->setStyle($style);
    }
737674
public function displayTable($table)
    {
        $headers = $this->makeHeaders($table[0]);

        $rows = [];

        foreach ($table as $row) {
            $rows[] = (array) $row;
        }

        $this->table = $this->getHelperSet()->get('table');

        $this->table->setHeaders($headers)->setRows($rows);

        $this->table->render($this->getOutput());
    }
41663
public function wrapTable($table)
    {
        if ($table instanceof Blueprint) $table = $table->getTable();

        return parent::wrapTable($table);
    }
853891
public function render(ElementInterface $element): string
    {
        if (! $element instanceof ChoiceElementInterface) {
            throw new InvalidClassException(
                sprintf(
                    'The given element "%s" has to implement "%s"',
                    $element->name(),
                    ChoiceElementInterface::class
                )
            );
        }

        $attributes = $element->attributes();
        unset($attributes['type'], $attributes['value']);

        return sprintf(
            '<select %s>%s</select>',
            $this->attributesToString($attributes),
            $this->renderChoices($element->choices(), $element->value())
        );
    }
244225
public function compileTableDeclaration(AbstractTable $table)
    {
        $declaration = '';

        if ($table->isJoin()) {
            $declaration .= $this->compileJoinName($table->getJoinMetadata()) . ' ';
        }

        $declaration .= $table->getTableName();

        if ($alias = $table->getAlias()) {
            $declaration .= ' AS ' . $alias;
        }

        if ($table->isJoin() && $joinOn = $table->getJoinMetadata()->getJoinOn()) {
            $declaration .= ' ON ' . $joinOn;
        }

        return $declaration;
    }
953201
protected function table( $table )
	{
		return $this->db->connection( $this->connection )->table( $table )->useWritePdo();
	}
851000
public function render()
    {
        
        // Render the table container
        $output = "<table {$this->renderAttributes()} >\n\t<tbody>\n";
        
        // Render the heading
        $output .= "\t\t<th>\n";
        
        foreach ($this->_head as $heading) {
            
            $output .= "\t\t\t<td>{$heading}</td>\n";
            
        }
        
        $output .= "\t\t</th>\n";
        
        // Render the rows
        foreach($this->_rows as $row) {
            
            $output .= "\t\t<tr>\n";
            
            foreach($this->_head as $columnName) {
                
                $column = $row[$columnName];
                
                switch(gettype($column)) {
                    
                    case 'array':
                        $column = print_r($column, true);
                        break;
                    
                    case 'object':
                        $column = (method_exists($column, 'render')) ? $column->render() : 'Object';
                        break;
                    
                    case 'boolean':
                        $column = $column ? 'True' : 'False';
                        break;
                    
                    case 'unknown type':
                    case 'resource':
                    case 'NULL':
                        $column = 'NULL';
                    
                    default:
                        break;
                    
                }
                
                $output .= "\t\t\t<td>{$column}</td>\n";
                
            }
            
            $output .= "\t\t</tr>\n";
            
        }
        
        $output .= "\t</tbody>\n</table>";
        
        return $output;
        
    }
516993
protected function renderDataTable($table)
    {
        if ($table->getRowsCount() == 0) {
            return "<strong><em>Empty table</em></strong><br />\n";
        }

        $i = 1;
        $tableStructure = array();

        /*
         * table = array
         * ROW1 = col1 | col2 | col3 | metadata | idSubTable
         * ROW2 = col1 | col2 (no value but appears) | col3 | metadata | idSubTable
         * 		subtable here
         */
        $allColumns = array();
        foreach ($table->getRows() as $row) {
            foreach ($row->getColumns() as $column => $value) {
                // for example, goals data is array: not supported in export RSS
                // in the future we shall reuse ViewDataTable for html exports in RSS anyway
                if (is_array($value)) {
                    continue;
                }
                $allColumns[$column] = true;
                $tableStructure[$i][$column] = $value;
            }
            $i++;
        }
        $html = "\n";
        $html .= "<table border=1 width=70%>";
        $html .= "\n<tr>";
        foreach ($allColumns as $name => $toDisplay) {
            if ($toDisplay !== false) {
                if ($this->translateColumnNames) {
                    $name = $this->translateColumnName($name);
                }
                $html .= "\n\t<td><strong>$name</strong></td>";
            }
        }
        $html .= "\n</tr>";

        foreach ($tableStructure as $row) {
            $html .= "\n\n<tr>";
            foreach ($allColumns as $columnName => $toDisplay) {
                if ($toDisplay !== false) {
                    $value = "-";
                    if (isset($row[$columnName])) {
                        $value = urldecode($row[$columnName]);
                    }

                    $html .= "\n\t<td>$value</td>";
                }
            }
            $html .= "</tr>";
        }
        $html .= "\n\n</table>";
        return $html;
    }
790690
protected function renderElementIcon(ElementInterface $element)
    {
        $render = '';
        $icon   = $element->getOption('icon');
        if ($icon) {
            $iconHelper = $this->getIconHelper();
            $render     = $iconHelper($icon);
        }
        return $render;
    }