Create one single body row element

@param array $columns
@param array $data
@return string
506557
private function createBodyRow($columns, $data)
    {
        $id = null;

        // Columns to be used when creating a row
        $children = array();

        // Handle batch callback and state
        if ($this->options[self::GRID_PARAM_BATCH] === true) {
            // Apply callback if provided
            if (isset($this->options[self::GRID_PARAM_BATCH_CALLBACK]) && is_callable($this->options[self::GRID_PARAM_BATCH_CALLBACK])) {
                // Result of batch callback function call
                $batchRequired = (bool) call_user_func($this->options[self::GRID_PARAM_BATCH_CALLBACK], $data);
            } else {
                // By default, batch is required for all rows
                $batchRequired = true;
            }

            if ($batchRequired) {
                $batchOutput = Element::checkbox($this->createInputName(self::GRID_PARAM_BATCH, $data[$this->getPkColumn()]), false, array(), false);
            } else {
                $batchOutput = null;
            }

            $children[] = $this->createColumn(null, $batchOutput);
        }
        // Done handling batch

        foreach ($columns as $configuration) {
			$column = $configuration[self::GRID_PARAM_COLUMN];
			$value = isset($data[$column]) ? $data[$column] : null;

            // Ignore if configuration for current column isn't provided
            if (!$this->hasColumnConfiguration($column)) {
                continue;
            }

            // Grab the ID
            if ($this->getPkColumn() !== false && $this->isPkColumnName($column)) {
                $id = $value;
            }

            // Grab column attributes if present
            $tdAttributes = isset($configuration[self::GRID_PARAM_TD_ATTRIBUTES]) ? $configuration[self::GRID_PARAM_TD_ATTRIBUTES] : array();

            // Find out whether current row is editable or not
            $editable = $this->findOptionByColumn($column, self::GRIG_PARAM_EDITABLE);
            // Get custom value (which is provided by a callback) if possible
            $callback = $this->findOptionByColumn($column, self::GRID_PARAM_VALUE);

            // If a callback function is provided for custom value, then use its returned value providing current row as argument
            if ($callback instanceof Closure) {
                $value = $callback($data);
            }

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

            // Translate if required
            if ($configuration[self::GRID_PARAM_TRANSLATEABLE] == true && $this->hasTranslator()) {
                $value = $this->translator->translate($value);
            }

            if ($editable == true) {
                $name = $this->createInputName($column, $id);
                $filter = $this->findOptionByColumn($column, self::GRID_PARAM_FILTER);

                if (is_array($filter)) {
                    $column = $this->createInput('createColumn', $column, $name, $value, $filter);
                } else {
                    $column = $this->createInput('createColumn', $column, $name, $value);
                }

            } else {
                $column = $this->createColumn(null, $value, $tdAttributes);
            }

            // Push prepared element
            $children[] = $column;
        }

        // If action columns provided, then create action links
        if ($this->hasActions()) {
            $links = array();

            foreach ($this->options[self::GRID_PARAM_ACTIONS] as $name => $callback) {
                // Append only if callable type provided as a value
                if (is_callable($callback)) {
                    $links[] = $callback($data);
                }
            }

            $children[] = $this->createColumn(null, join(PHP_EOL, $links));
        }

        // Now append row attributes if defined
        $attributes = array();

        if (isset($this->options[self::GRID_PARAM_ROW_ATTRS])) {
            foreach($this->options[self::GRID_PARAM_ROW_ATTRS] as $name => $value) {
                // If closure is provided, then execute it and get returned value
                if (is_callable($value)) {
                    $value = $value($data);
                }

                // Don't append NULL-like attributes
                if ($value != null) {
                    $attributes[$name] = $value;
                }
            }
        }

        return $this->createTableRow($children, $attributes);
    }
1055581
public function select(string $column, string ...$columns)
    {
        $instance = $this->selectQueryInstance();

        $instance->selectQuery()->columns($column, ...$columns);

        return $instance;
    }
759864
public function withColumns(array $columns): self
    {
        $selector = clone $this;
        $selector->loader = $selector->loader->withColumns($columns);

        return $selector;
    }
387625
protected function generateBody(array $params, array $columns): void
  {
    $uniqueColumns = $this->checkUniqueKeys($columns);
    $limit         = ($uniqueColumns==null);

    $this->codeStore->append(sprintf('delete from %s', $this->tableName));
    $this->codeStore->append('where');

    $first = true;
    foreach ($params as $column)
    {
      if ($first)
      {
        $format = sprintf("%%%ds %%s = p_%%s", 1);
        $this->codeStore->appendToLastLine(sprintf($format, '', $column['column_name'], $column['column_name']));
      }
      else
      {
        $format = sprintf("and%%%ds %%s = p_%%s", 3);
        $this->codeStore->append(sprintf($format, '', $column['column_name'], $column['column_name']));
      }

      $first = false;
    }

    if ($limit)
    {
      $this->codeStore->append('limit 0,1');
    }

    $this->codeStore->append(';');
  }
741384
public function select($columns = '*')
    {
        settype($columns, 'array');

        $this->columns = array_unique(array_merge($this->columns, $columns));
        return $this;
    }
326654
public static function createArray( $data )
    {
        $_result = array();
        $_count = func_num_args();

        for ( $_i = 0; $_i < $_count; $_i++ )
        {
            //	Any other columns to touch?
            if ( null !== ( $_arg = func_get_arg( $_i ) ) )
            {
                if ( !is_array( $_arg ) )
                {
                    $_result[] = $_arg;
                }
                else
                {
                    foreach ( $_arg as $_value )
                    {
                        $_result[] = $_value;
                    }
                }
            }
        }

        //	Return the fresh array...
        return $_result;
    }
614575
protected function createRendererColumn($columnData, $postX)
    {
        /** @var Control $element */
        $element = $columnData['renderer'];
        $element->setPosition($postX, 0);
        $element->setHeight(4);

        return $element;
    }
683643
public function getGrid($data, $row = 'tr', $col = 'td', $options = null)
    {
        $rows = '';

        if (!is_array($data)) {
            return $rows;
        }


        foreach ($data as $rowIndex => $rowValue) {

            // Attribute for tr
            $attributes[$row] = '';
            foreach ($options[$row] as $key => $value) {
                if ($key !== 'tag') {

                    $value = is_callable($value) ?
                        $value($rowIndex, $rowValue, $options) : $value;

                    $attributes[$row] .= !empty($value) ? ' ' . $key . '="' . $value . '"' : '';
                }
            }

            $cols = '';
            $skipCols = 0;
            $skipCols = $this->isShowRowIndex() ? $skipCols + 1 : $skipCols;
            $skipCols = $this->isShowRowCheckbox() ? $skipCols + 1 : $skipCols;

            $i = 0;
            foreach ($rowValue as $colIndex => $colValue) {

                // Attribute for td
                $attributes[$col] = '';
                foreach ($options[$col] as $key => $value) {
                    if ($key !== 'tag' && $key !== 'value') {

                        $value = is_callable($value) ?
                            $value($rowIndex, $colIndex, $colValue,
                                $options) : $value;

                        $attributes[$col] .= !empty($value) ? ' ' . $key . '="' . $value . '"' : '';
                    }
                }

                // Value for td
                if (($row == 'thead_tr' && !$this->theadUsesValue) ||
                    ($row == 'tfoot_tr' && !$this->tfootUsesValue)
                ) {
                    if ($rowIndex === 'search') {
                        $colValue = $i >= $skipCols ? $colValue : '';
                    } else {
                        $colValue = $i >= $skipCols ? $colIndex : '';
                    }

                } else {
                    $colValue = isset($options[$col]['value']) && is_callable($options[$col]['value']) ?
                        $options[$col]['value']($rowIndex, $colIndex,
                            $colValue,
                            $options) : $colValue;
                }

                $cols .= sprintf($options[$col]['tag'], $attributes[$col],
                    $colValue);

                $i++;
            }

            $rows .= sprintf($options[$row]['tag'], $attributes[$row], $cols);
        }

        return $rows;
    }
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;
    }
1034122
public static function table($table, $columns, $rows) {
		if (count($rows)) {
			$return = new Table;
			$return->rows($rows);
			foreach ($columns as $column) {
				$return->column($column->name, $column->type, $column->title);
			}
			if (isset($table->fields->deleted_at)) $return->deletable();
			if (array_keys($table->order_by)[0] == $table->name . '.precedence') $return->draggable(action('\LeftRight\Center\Controllers\RowController@reorder', $table->name));
			if (!empty($table->group_by)) $return->groupBy('group');
			return $return->draw($table->name);
		}
	}
623095
public function getHtmlTable(array $rows): string
  {
    $this->prepare();

    $ret = $this->getHtmlPrefix();

    $ret .= Html::generateTag('table', $this->attributes);

    // Generate HTML code for the column classes.
    $ret .= '<colgroup>';
    foreach ($this->columns as $column)
    {
      // If required disable sorting of this column.
      if (!$this->sortable) $column->notSortable();

      // Generate column element.
      $ret .= $column->getHtmlCol();
    }
    $ret .= '</colgroup>';

    // Generate HTML code for the table header.
    $ret .= Html::generateTag('thead', ['class' => static::$class]);
    $ret .= $this->getHtmlHeader();
    $ret .= '</thead>';

    // Generate HTML code for the table body.
    $ret .= Html::generateTag('tbody', ['class' => static::$class]);
    $ret .= $this->getHtmlBody($rows);
    $ret .= '</tbody>';

    $ret .= '</table>';

    $ret .= $this->getHtmlPostfix();

    $this->generateResponsiveCss();

    return $ret;
  }
936826
public static function make(array $data, array $rules)
    {
        self::$validator = new V([]);
        self::$validator->labels($data);

        foreach ($rules as $rule => $columns) {
            if (is_string($columns)) {
                $columns = self::separte($columns);
            } else {
                $columns = $columns;
            }

            $value = self::getValue($rule);

            self::$validator->rule($value['rule'], $columns, $value['value']);
        }

        return new ValidationResult(self::$validator);
    }
220597
public function select($column, ...$columns) {
        $this->params = [];
        if (count($columns)) {
            array_unshift($columns, $column);
            $columnStr = implode('`,`', $columns);
            $this->sql = "SELECT `{$columnStr}` ";
        } else {
            $this->sql = "SELECT {$column} ";
        }
        return $this;
    }
479694
public function make(array $data = null, array $options = null)
    {
        $data = $data ? $data : $this->getData();
        $this->setData($data);

        $options = $options ? $options : $this->getOptions();
        $options = array_replace_recursive($this->getDefaults(), $options);
        $this->setOptions($options);




        if ($this->isShowRowCheckbox()) {
            $this->addRowCheckbox();
        }

        if ($this->isShowRowIndex()) {
            $this->addRowIndex();
        }

        if ($this->isShowColSearch()) {
            $this->addColSearch();
        }

        $options = $this->getOptions();
        $data = $this->getData();

        $attributes = [];

        // Attributes for wrappers
        $attributes['table'] = $this->getAttributes('table', $options);
        $attributes['caption'] = $this->getAttributes('caption', $options);
        $attributes['colgroup'] = $this->getAttributes('colgroup', $options);
        $attributes['thead'] = $this->getAttributes('thead', $options);
        $attributes['tbody'] = $this->getAttributes('tbody', $options);
        $attributes['tfoot'] = $this->getAttributes('tfoot', $options);

        // caption
        $caption = isset($options['caption']['value']) ?
            $options['caption']['value'] : '';

        // colgroup data
        $cols = '';
            if (is_array($options['colgroup']) && $this->isShowColgroup()) {
            $colsData = isset($options['colgroup']['value']) ?
                $options['colgroup']['value'] : array_slice($data, 0, 1);
            $cols = $this->getColgroup($colsData, $options);
        }

        // thead data
        $thead_rows = '';
        if (is_array($options['thead']) && $this->isShowThead()) {
            $theadData = isset($options['thead']['value']) ?
                $options['thead']['value'] : array_slice($data, 0, 1);
            $theadData = is_callable($theadData) ? $theadData($data) : $theadData;
            $thead_rows = $this->getGrid($theadData, 'thead_tr', 'th',
                $options);
        }

        // tfoot data
        $tfoot_rows = '';
        if (is_array($options['tfoot']) && $this->isShowTfoot()) {
            $tfootData = isset($options['tfoot']['value']) ?
                $options['tfoot']['value'] : null;
            $tfootData = is_callable($tfootData) ? $tfootData($data) : $tfootData;
            $tfoot_rows = $this->getGrid($tfootData, 'tfoot_tr', 'tfoot_td',
                $options);
        }

        // tbody data
        $tbody_rows = $this->getGrid($data, 'tr', 'td', $options);

        // Render wrappers
        $caption = empty($caption) ?
            '' : sprintf($options['caption']['tag'], $attributes['caption'],
                $caption);

        $colgroup = empty($cols) ?
            '' : sprintf($options['colgroup']['tag'], $attributes['colgroup'],
                $cols);

        $thead = empty($thead_rows) ?
            '' : sprintf($options['thead']['tag'], $attributes['thead'],
                $thead_rows);

        $tbody = sprintf($options['tbody']['tag'], $attributes['tbody'],
            $tbody_rows);

        $tfoot = empty($tfoot_rows) ?
            '' : sprintf($options['tfoot']['tag'], $attributes['tfoot'],
                $tfoot_rows);

        $table = $caption .$colgroup . $thead . $tbody . $tfoot;

        return sprintf($options['table']['tag'], $attributes['table'], $table);
    }
1060506
protected function getRowSql($data, $columnFields) {
        $args = [];
        foreach ($data as $key => $item) {
            if (is_null($item)) {
                $args[] = 'NULL';
                continue;
            }
            if (array_key_exists($key, $columnFields) && $columnFields[$key]) {
                $args[] = $item;
                continue;
            }
            $args[] = sprintf('\'%s\'',
                str_replace(
                    ["\r\n", "\r", "\n", '\\\'', '\''],
                    ["\n", '\r\n', '\r\n', '\'', '\\\''], $item));
        }
        return implode(',',$args);
    }
875603
public function withColumns(array $columns): self
    {
        $loader = clone $this;
        $loader->columns = array_merge(
            [$loader->schema[Record::SH_PRIMARY_KEY]],
            $columns
        );

        return $loader;
    }
653329
public function columns($columns)
    {
        if (!is_array($columns)) {
            $columns = preg_split('~\s*,\s*~', trim($columns));
        }

        $this->columns = $columns;

        return $this;
    }