diff --git a/libraries/classes/CentralColumns.php b/libraries/classes/CentralColumns.php index f092da0341..14eefe784b 100644 --- a/libraries/classes/CentralColumns.php +++ b/libraries/classes/CentralColumns.php @@ -823,13 +823,8 @@ class CentralColumns int $pos, string $db ): string { - $icon = Util::getIcon( - 'centralColumns_add', - __('Add column') - ); $table_drop_down = $this->getHtmlForTableDropdown($db); return Template::get('database/central_columns/add_column')->render(array( - 'icon' => $icon, 'pos' => $pos, 'db' => $db, 'total_rows' => $total_rows, @@ -848,73 +843,6 @@ class CentralColumns */ public function getHtmlForTableRow(array $row, int $row_num, string $db): string { - $tableHtml = '' - . Url::getHiddenInputs( - $db - ) - . '' - . '' - . '' - . '' - . '' - . '' . Util::getIcon('b_edit', __('Edit')) . '' - . '' - . '' . Util::getIcon('b_drop', __('Delete')) . '' - . '' - . '' - . ''; - - $tableHtml .= - '' - . '' . htmlspecialchars($row['col_name']) . '' - . '' - . Template::get('columns_definitions/column_name')->render(array( - 'column_number' => $row_num, - 'ci' => 0, - 'ci_offset' => 0, - 'column_meta' => array( - 'Field'=>$row['col_name'] - ), - 'cfg_relation' => array( - 'centralcolumnswork' => false - ), - 'max_rows' => $this->maxRows, - )) - . ''; - $tableHtml .= - '' - . htmlspecialchars($row['col_type']) . '' - . Template::get('columns_definitions/column_type') - ->render( - array( - 'column_number' => $row_num, - 'ci' => 1, - 'ci_offset' => 0, - 'type_upper' => mb_strtoupper($row['col_type']), - 'column_meta' => array() - ) - ) - . ''; - $tableHtml .= - '' - . '' . ($row['col_length']?htmlspecialchars($row['col_length']):"") - . '' - . Template::get('columns_definitions/column_length')->render( - array( - 'column_number' => $row_num, - 'ci' => 2, - 'ci_offset' => 0, - 'length_values_input_size' => 8, - 'length_to_display' => $row['col_length'] - ) - ) - . ''; - $meta = array(); if (!isset($row['col_default']) || $row['col_default'] == '') { $meta['DefaultType'] = 'NONE'; @@ -930,85 +858,78 @@ class CentralColumns $meta['DefaultValue'] = $row['col_default']; } } - $tableHtml .= - '' . (isset($row['col_default']) - ? htmlspecialchars($row['col_default']) : 'None') - . '' - . Template::get('columns_definitions/column_default') - ->render( - array( - 'column_number' => $row_num, - 'ci' => 3, - 'ci_offset' => 0, - 'type_upper' => mb_strtoupper($row['col_type']), - 'column_meta' => $meta, - 'char_editing' => $this->charEditing, - ) - ) - . ''; - - $tableHtml .= - '' - . '' . htmlspecialchars($row['col_collation']) . '' - . Charsets::getCollationDropdownBox( - $this->dbi, - $this->disableIs, - 'field_collation[' . $row_num . ']', - 'field_' . $row_num . '_4', $row['col_collation'], false + $column_name = Template::get('columns_definitions/column_name')->render(array( + 'column_number' => $row_num, + 'ci' => 0, + 'ci_offset' => 0, + 'column_meta' => array( + 'Field'=>$row['col_name'] + ), + 'cfg_relation' => array( + 'centralcolumnswork' => false + ), + 'max_rows' => $this->maxRows, + )); + $column_type = Template::get('columns_definitions/column_type')->render(array( + 'column_number' => $row_num, + 'ci' => 1, + 'ci_offset' => 0, + 'type_upper' => mb_strtoupper($row['col_type']), + 'column_meta' => array() + )); + $column_length = Template::get('columns_definitions/column_length')->render(array( + 'column_number' => $row_num, + 'ci' => 2, + 'ci_offset' => 0, + 'length_values_input_size' => 8, + 'length_to_display' => $row['col_length'] + )); + $column_default = Template::get('columns_definitions/column_default')->render(array( + 'column_number' => $row_num, + 'ci' => 3, + 'ci_offset' => 0, + 'type_upper' => mb_strtoupper($row['col_type']), + 'column_meta' => $meta, + 'char_editing' => $this->charEditing, + )); + $column_attribute = Template::get('columns_definitions/column_attribute')->render(array( + 'column_number' => $row_num, + 'ci' => 5, + 'ci_offset' => 0, + 'extracted_columnspec' => array(), + 'column_meta' => $row['col_attribute'], + 'submit_attribute' => false, + 'attribute_types' => $this->dbi->types->getAttributes(), + )); + $column_null = Template::get('columns_definitions/column_null')->render(array( + 'column_number' => $row_num, + 'ci' => 6, + 'ci_offset' => 0, + 'column_meta' => array( + 'Null' => $row['col_isNull'] ) - . ''; - $tableHtml .= - '' - . '' . - ($row['col_attribute'] - ? htmlspecialchars($row['col_attribute']) : "" ) - . '' - . Template::get('columns_definitions/column_attribute') - ->render( - array( - 'column_number' => $row_num, - 'ci' => 5, - 'ci_offset' => 0, - 'extracted_columnspec' => array(), - 'column_meta' => $row['col_attribute'], - 'submit_attribute' => false, - 'attribute_types' => $this->dbi->types->getAttributes(), - ) - ) - . ''; - $tableHtml .= - '' - . '' . ($row['col_isNull'] ? __('Yes') : __('No')) - . '' - . Template::get('columns_definitions/column_null') - ->render( - array( - 'column_number' => $row_num, - 'ci' => 6, - 'ci_offset' => 0, - 'column_meta' => array( - 'Null' => $row['col_isNull'] - ) - ) - ) - . ''; + )); + $column_extra = Template::get('columns_definitions/column_extra')->render(array( + 'column_number' => $row_num, + 'ci' => 7, + 'ci_offset' => 0, + 'column_meta' => array('Extra'=>$row['col_extra']) + )); - $tableHtml .= - '' - . htmlspecialchars($row['col_extra']) . '' - . Template::get('columns_definitions/column_extra')->render( - array( - 'column_number' => $row_num, - 'ci' => 7, - 'ci_offset' => 0, - 'column_meta' => array('Extra'=>$row['col_extra']) - ) - ) - . ''; - - $tableHtml .= ''; - - return $tableHtml; + return Template::get('database/central_columns/table_row')->render(array( + 'column_name' => $column_name, + 'column_type' => $column_type, + 'column_length' => $column_length, + 'column_default' => $column_default, + 'column_attribute' => $column_attribute, + 'column_null' => $column_null, + 'column_extra' => $column_extra, + 'row_num' => $row_num, + 'row' => $row, + 'db' => $db, + 'dbi' => $this->dbi, + 'disableIs' => $this->disableIs, + )); } /** diff --git a/templates/database/central_columns/add_column.twig b/templates/database/central_columns/add_column.twig index 68eba31a9e..1a3a0672e0 100644 --- a/templates/database/central_columns/add_column.twig +++ b/templates/database/central_columns/add_column.twig @@ -2,9 +2,9 @@ - {{ icon|raw }} + {{ Util_getIcon('centralColumns_add', 'Add column'|trans)|raw }}
- {{ Url_getHiddenInputs(db)}} + {{ Url_getHiddenInputs(db) |raw }} diff --git a/templates/database/central_columns/table_row.twig b/templates/database/central_columns/table_row.twig new file mode 100644 index 0000000000..0514d2c935 --- /dev/null +++ b/templates/database/central_columns/table_row.twig @@ -0,0 +1,60 @@ + + {{ Url_getHiddenInputs(db) }} + + + + + + {{ Util_getIcon('b_edit', 'Edit'|trans) |raw }} + + + {{ Util_getIcon('b_drop', 'Delete'|trans) }} + + + + + + + {{ row['col_name'] |raw }} + + {{ column_name |raw }} + + + {{ row['col_type'] |raw }} + {{ column_type |raw }} + + + {{ (row['col_length']?(row['col_length'] | raw):'') }} + {{ column_length |raw }} + + + {% if row['col_default'] is defined %} + {{ row['col_default'] }} + {% else %} + None + {% endif %} + {{ column_default |raw }} + + + {{ row['col_collation'] |raw }} + {{ Charsets_getCollationDropdownBox( + dbi, + disableIs, + 'field_collation[' ~ row_num ~ ']', + 'field_' ~ row_num ~ '_4', row['col_collation'], false + ) |raw }} + + + {{ row['col_attribute']?(row['col_attribute'] |raw):"" }} + {{ column_attribute |raw }} + + + {{ row['col_isNull'] ? 'Yes' |trans : 'No' |trans }} + {{ column_null |raw }} + + + {{ row['col_extra'] |raw }} + {{ column_extra |raw }} + +