Permalink
Browse files

Addapt getHtmlForTableRow to twig template

Signed-off-by: Leonardo Strozzi <laps15@inf.ufpr.br>
  • Loading branch information...
laps15 committed May 10, 2018
1 parent 1967db6 commit c634200564397759217735d24f24a1a938e2a77b
Showing with 130 additions and 144 deletions.
  1. +70 −144 libraries/classes/CentralColumns.php
  2. +60 −0 templates/database/central_columns/table_row.twig
@@ -843,73 +843,6 @@ public function getHtmlForAddColumn(
*/
public function getHtmlForTableRow(array $row, int $row_num, string $db): string
{
$tableHtml = '<tr data-rownum="' . $row_num . '" id="f_' . $row_num . '">'
. Url::getHiddenInputs(
$db
)
. '<input type="hidden" name="edit_save" value="save">'
. '<td class="nowrap">'
. '<input type="checkbox" class="checkall" name="selected_fld[]" '
. 'value="' . htmlspecialchars($row['col_name']) . '" '
. 'id="checkbox_row_' . $row_num . '"/>'
. '</td>'
. '<td id="edit_' . $row_num . '" class="edit center">'
. '<a href="#">' . Util::getIcon('b_edit', __('Edit')) . '</a></td>'
. '<td class="del_row" data-rownum = "' . $row_num . '">'
. '<a hrf="#">' . Util::getIcon('b_drop', __('Delete')) . '</a>'
. '<input type="submit" data-rownum = "' . $row_num . '"'
. ' class="edit_cancel_form" value="Cancel"></td>'
. '<td id="save_' . $row_num . '" class="hide">'
. '<input type="submit" data-rownum = "' . $row_num . '"'
. ' class="edit_save_form" value="Save"></td>';
$tableHtml .=
'<td name="col_name" class="nowrap">'
. '<span>' . htmlspecialchars($row['col_name']) . '</span>'
. '<input name="orig_col_name" type="hidden" '
. 'value="' . 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,
))
. '</td>';
$tableHtml .=
'<td name = "col_type" class="nowrap"><span>'
. htmlspecialchars($row['col_type']) . '</span>'
. 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()
)
)
. '</td>';
$tableHtml .=
'<td class="nowrap" name="col_length">'
. '<span>' . ($row['col_length']?htmlspecialchars($row['col_length']):"")
. '</span>'
. 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']
)
)
. '</td>';
$meta = array();
if (!isset($row['col_default']) || $row['col_default'] == '') {
$meta['DefaultType'] = 'NONE';
@@ -925,85 +858,78 @@ public function getHtmlForTableRow(array $row, int $row_num, string $db): string
$meta['DefaultValue'] = $row['col_default'];
}
}
$tableHtml .=
'<td class="nowrap" name="col_default"><span>' . (isset($row['col_default'])
? htmlspecialchars($row['col_default']) : 'None')
. '</span>'
. 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,
)
)
. '</td>';
$tableHtml .=
'<td name="collation" class="nowrap">'
. '<span>' . htmlspecialchars($row['col_collation']) . '</span>'
. Charsets::getCollationDropdownBox(
$this->dbi,
$this->disableIs,
'field_collation[' . $row_num . ']',
'field_' . $row_num . '_4', $row['col_collation'], false
)
. '</td>';
$tableHtml .=
'<td class="nowrap" name="col_attribute">'
. '<span>' .
($row['col_attribute']
? htmlspecialchars($row['col_attribute']) : "" )
. '</span>'
. 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(),
)
)
. '</td>';
$tableHtml .=
'<td class="nowrap" name="col_isNull">'
. '<span>' . ($row['col_isNull'] ? __('Yes') : __('No'))
. '</span>'
. Template::get('columns_definitions/column_null')
->render(
array(
'column_number' => $row_num,
'ci' => 6,
'ci_offset' => 0,
'column_meta' => array(
'Null' => $row['col_isNull']
)
)
)
. '</td>';
$tableHtml .=
'<td class="nowrap" name="col_extra"><span>'
. htmlspecialchars($row['col_extra']) . '</span>'
. Template::get('columns_definitions/column_extra')->render(
array(
'column_number' => $row_num,
'ci' => 7,
'ci_offset' => 0,
'column_meta' => array('Extra'=>$row['col_extra'])
)
$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']
)
. '</td>';
$tableHtml .= '</tr>';
));
$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'])
));
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,
));
}
/**
@@ -0,0 +1,60 @@
<tr data-rownum="{{ row_num }}" id="{{ 'f_' ~ row_num }}">
{{ Url_getHiddenInputs(db) }}
<input type="hidden" name="edit_save" value="save">
<td class="nowrap">
<input type="checkbox" class="checkall" name="selected_fld[]"
value="{{ row['col_name']|raw }}" id="{{ 'checkbox_row_' ~ row_num }}"/>
</td>
<td id="{{ 'edit_' ~ row_num }}" class="edit center">
<a href="#"> {{ Util_getIcon('b_edit', 'Edit'|trans) |raw }}</a>
</td>
<td class="del_row" data-rownum = "{{ row_num }}">
<a hrf="#">{{ Util_getIcon('b_drop', 'Delete'|trans) }}</a>
<input type="submit" data-rownum = "{{ row_num }}" class="edit_cancel_form" value="Cancel">
</td>
<td id="{{ 'save_' ~ row_num }}" class="hide">
<input type="submit" data-rownum="{{ row_num }}" class="edit_save_form" value="Save">
</td>
<td name="col_name" class="nowrap">
<span>{{ row['col_name'] |raw }}</span>
<input name="orig_col_name" type="hidden" value="{{ row['col_name'] |raw }}">
{{ column_name |raw }}
</td>
<td name = "col_type" class="nowrap">
<span>{{ row['col_type'] |raw }}</span>
{{ column_type |raw }}
</td>
<td class="nowrap" name="col_length">
<span>{{ (row['col_length']?(row['col_length'] | raw):'') }}</span>
{{ column_length |raw }}
</td>
<td class="nowrap" name="col_default">
{% if row['col_default'] is defined %}
<span>{{ row['col_default'] }}</span>
{% else %}
<span>None</span>
{% endif %}
{{ column_default |raw }}
</td>
<td name="collation" class="nowrap">
<span>{{ row['col_collation'] |raw }}</span>
{{ Charsets_getCollationDropdownBox(
dbi,
disableIs,
'field_collation[' ~ row_num ~ ']',
'field_' ~ row_num ~ '_4', row['col_collation'], false
) |raw }}
</td>
<td class="nowrap" name="col_attribute">
<span>{{ row['col_attribute']?(row['col_attribute'] |raw):"" }}</span>
{{ column_attribute |raw }}
</td>
<td class="nowrap" name="col_isNull">
<span>{{ row['col_isNull'] ? 'Yes' |trans : 'No' |trans }}</span>
{{ column_null |raw }}
</td>
<td class="nowrap" name="col_extra">
<span>{{ row['col_extra'] |raw }}</span>
{{ column_extra |raw }}
</td>
</tr>

0 comments on commit c634200

Please sign in to comment.