Creates table

@param string ...$elements

@return string
176713
public function create(...$elements) : String
    {
        $table  = '<table'.$this->html->attributes($this->attr).'>';
        $table .= $this->_content(...$elements);
        $table .= '</table>';

        if( ! empty($this->table)) $this->table = NULL;
        if( ! empty($this->attr))  $this->attr = [];

        return $table;
    }
180
public function setElements(array $elements)
    {
        $this->elements = [];
        foreach ($elements as $name => $element) {
            $this->setElement($name, $element);
        }

        return $this;
    }
2648
public function addElement(array $element)
    {
        $elementXml = $this->parseElement($element);
        $this->schema->appendChild($elementXml);
        return 'tns:' . $element['name'];
    }
1172716
public function flatten(array $elements)
    {
        $level = [];

        foreach ($elements as $node)
        {
            if (is_array($node))
            {
                $level = array_merge($level, $this->flatten($node));
            }
            else
            {
                $level[] = $node;
            }
        }

        return $level;
    }
1096913
public function createElement(array $attributes)
    {
        $element = $this->ownerDocument->createElement($this->element);

        $name = null;
        foreach ($attributes as $key => $value) {
            $element->setAttribute($key, $value);
        }

        $this[] = $element;

        return $element;
    }
220502
public function createTable($table)
    {
        $changeSetElt = $this->createChangeSet('create-table-' . $table->getName());

        $createTableElt = $this->document->createElement('createTable');

        $tableName = QualifiedName::fromAsset($table);
        if ($tableName->getNamespaceName()) {
            $createTableElt->setAttribute('schemaName', $tableName->getNamespaceName());
        }
        $createTableElt->setAttribute('tableName', $tableName->getName());

        $indexColumns = new IndexColumns($table);

        foreach ($table->getColumns() as $column) {
            $columnElt = $this->document->createElement('column');

            $this->fillColumnAttributes($columnElt, $column, $indexColumns);

            $createTableElt->appendChild($columnElt);
        }

        $changeSetElt->appendChild($createTableElt);

        foreach ($indexColumns->getOtherIndexes() as $index) {
            $createIndexElt = $this->document->createElement('createIndex');

            if ($tableName->getNamespaceName()) {
                $createIndexElt->setAttribute('schemaName', $tableName->getNamespaceName());
            }
            $createIndexElt->setAttribute('tableName', $tableName->getName());
            $createIndexElt->setAttribute('indexName', $index->getName());
            if ($index->isUnique()) {
                $createIndexElt->setAttribute('unique', $index->isUnique() ? "true" : "false");
            }

            foreach ($index->getColumns() as $column) {
                $columnElt = $this->document->createElement('column');
                $columnElt->setAttribute('name', $column);
                $createIndexElt->appendChild($columnElt);
            }

            $changeSetElt->appendChild($createIndexElt);
        }

        $this->root->appendChild($changeSetElt);
    }
1294520
public function getSqlCreateTable($table)
    {
        if (empty($this->sqlCreateTable[$table])) {
            $query = $this->pdo->query("SHOW CREATE TABLE $table");

            $this->sqlCreateTable[$table] = $query->fetchColumn(1);
        }

        return $this->sqlCreateTable[$table];
    }
1210970
public function table(array $rows, array $styles = []): self
    {
        if ([] === $table = $this->normalizeTable($rows)) {
            return $this;
        }

        list($head, $rows) = $table;

        $styles = $this->normalizeStyles($styles);
        $title  = $body = $dash = [];

        list($start, $end) = $styles['head'];
        foreach ($head as $col => $size) {
            $dash[]  = \str_repeat('-', $size + 2);
            $title[] = \str_pad($this->toWords($col), $size, ' ');
        }

        $title = "|$start " . \implode(" $end|$start ", $title) . " $end|" . \PHP_EOL;

        $odd = true;
        foreach ($rows as $row) {
            $parts = [];

            list($start, $end) = $styles[['even', 'odd'][(int) $odd]];
            foreach ($head as $col => $size) {
                $parts[] = \str_pad($row[$col] ?? '', $size, ' ');
            }

            $odd    = !$odd;
            $body[] = "|$start " . \implode(" $end|$start ", $parts) . " $end|";
        }

        $dash  = '+' . \implode('+', $dash) . '+' . \PHP_EOL;
        $body  = \implode(\PHP_EOL, $body) . \PHP_EOL;

        return $this->colors("$dash$title$dash$body$dash");
    }
423794
public function addElementArray(array $elements) {

		if(count($elements)) {
			
			$firstElement = array_shift($elements);
			$name = $firstElement->getName();

			// remove any array indexes from name

			$name = preg_replace('~\[\w*\]$~i', '', $name);

			if(!empty($this->elements[$name])) {

				throw new HtmlFormException(sprintf("Element '%s' already assigned.", $name));

			}

			$arrayName = $name . '[]';
			$firstElement
				->setName($arrayName)
				->setForm($this)
			;

			$this->elements[$name] = [$firstElement];

			foreach($elements as $e) {
				
				if(get_class($e) !== get_class($firstElement)) {

					throw new HtmlFormException(sprintf("Class mismatch of form elements array. Expected '%s', found '%s'.", get_class($firstElement), get_class($e)));

				}
				
				// check whether names of element arrays match

				$nameToCheck = preg_replace('~\[\w*\]$~i', '', $e->getName());

				if($nameToCheck && $nameToCheck !== $name) {
					
					throw new HtmlFormException(sprintf("Name mismatch of form elements array. Expected '%s' or empty name, found '%s'.", $name, $e->getName()));

				}

				$e
					->setName($arrayName)
					->setForm($this)
				;

				$this->elements[$name][] = $e;
			}

		}

		return $this;

	}
1246692
public function getTableCreate($tables)
	{
		$this->connect();

		$result = array();

		// Sanitize input to an array and iterate over the list.
		$tables = (array) $tables;

		foreach ($tables as $table)
		{
			// Set the query to get the table CREATE statement.
			$this->setQuery('SHOW CREATE TABLE ' . $this->quoteName($this->escape($table)));
			$row = $this->loadRow();

			// Populate the result array based on the create statements.
			$result[$table] = $row[1];
		}

		return $result;
	}
1191945
public function elementsGroup($elements){

        $groups = $this->formGroups;
        $groupNames = [];
        $groupEles = [];
        foreach ($groups as $k=>$v){
            $groupNames[] = $k;
            $groupEles[$v['name']] = ['title'=>$v['title']];
        }

        foreach ($elements as $ele){
            if (isset($ele['group']) && $ele['group']){
                $group = $ele['group'];
                if (in_array($group , $groupNames)){
                    $groupEles[$group]['elements'][] = $ele;
                }else{
                    $groupEles['base']['elements'][] = $ele;
                }
            }else {
                $groupEles['base']['elements'][] = $ele;
            }

        }

        return $groupEles;
    }
841777
public function addElements(array $elements) {
		foreach ($elements as $name => $element) {
			if (is_string($name)) {
				$this->addElement($element, $name);
			} else {
				$this->addElement($element);
			}
		}
		
		return $this;
	}
274264
protected function indentArray(array $elements) {
		return self::INDENTATION . \str_replace(PHP_EOL, PHP_EOL . self::INDENTATION, \implode(PHP_EOL, $elements));
	}
1062036
protected function serializeElement($element)
	{
		return (is_array($element)) ? $this->serializeStrings($element) : $this->serializeLiteral($element);
	}
1060942
private function createTable(array $data, $class)
    {
        $table = new NodeElement();
        $table->openTag('table')
              ->setClass($class);

        $tbody = new NodeElement();
        $tbody->openTag('tbody');

        foreach ($data as $key => $value) {
            $row = $this->createRow($key, $value);
            $tbody->appendChild($row);
        }

        $tbody->closeTag();
        $table->appendChild($tbody);

        $table->closeTag();
        return $table;
    }
720724
public function jsonRenderer($elements): Renderer
    {
        if (!is_array($elements) && !is_object($elements)) {
            throw new Server500(new \ArrayObject(array("explain" =>
                "The parameters {elements} is not a valid object/array for json renderer ",
                "solution" => "Please set a valid parameters for json renderer {object|array}")));
        }

        $this->display_elements = array("json" => (array)$elements, JSON_PRETTY_PRINT);
        return ($this);
    }
938133
public static function encodeCreateTable($tableName, $fields)
    {
        $query = "CREATE TABLE IF NOT EXISTS $tableName (";
        $keys = array_keys($fields);
        $size = sizeof($keys);

        foreach ($keys as $index => $field) {
            $query .= " $field";
            $attribs = $fields[$field];
            foreach ($attribs as $i => $attrib) {
                if ($i == 1)
                    $query .= ($attrib == "0" ? "" : "($attrib)");
                else
                    $query .= " $attrib";
            }
            if ($index != ($size - 1))
                $query .= " ,";
        }

        $query .= ") ENGINE=InnoDB DEFAULT CHARSET=latin1;";
        return $query;
    }