Use template for getHtmlForColumns method
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
parent
d5fedaf4c7
commit
925c2e0863
@ -863,33 +863,9 @@ class Tracking
|
||||
*/
|
||||
public static function getHtmlForColumns(array $columns)
|
||||
{
|
||||
$html = '<h3>' . __('Structure') . '</h3>';
|
||||
$html .= '<table id="tablestructure" class="data">';
|
||||
$html .= '<thead>';
|
||||
$html .= '<tr>';
|
||||
$html .= '<th>' . __('#') . '</th>';
|
||||
$html .= '<th>' . __('Column') . '</th>';
|
||||
$html .= '<th>' . __('Type') . '</th>';
|
||||
$html .= '<th>' . __('Collation') . '</th>';
|
||||
$html .= '<th>' . __('Null') . '</th>';
|
||||
$html .= '<th>' . __('Default') . '</th>';
|
||||
$html .= '<th>' . __('Extra') . '</th>';
|
||||
$html .= '<th>' . __('Comment') . '</th>';
|
||||
$html .= '</tr>';
|
||||
$html .= '</thead>';
|
||||
$html .= '<tbody>';
|
||||
$index = 1;
|
||||
foreach ($columns as $field) {
|
||||
$html .= Template::get('table/tracking/structure_snapshot_field')->render([
|
||||
'index' => $index++,
|
||||
'field' => $field,
|
||||
]);;
|
||||
}
|
||||
|
||||
$html .= '</tbody>';
|
||||
$html .= '</table>';
|
||||
|
||||
return $html;
|
||||
return Template::get('table/tracking/structure_snapshot_columns')->render([
|
||||
'columns' => $columns,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
56
templates/table/tracking/structure_snapshot_columns.twig
Normal file
56
templates/table/tracking/structure_snapshot_columns.twig
Normal file
@ -0,0 +1,56 @@
|
||||
<h3>{% trans 'Structure' %}</h3>
|
||||
<table id="tablestructure" class="data">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans %}#{% context %}Number{% endtrans %}</th>
|
||||
<th>{% trans 'Column' %}</th>
|
||||
<th>{% trans 'Type' %}</th>
|
||||
<th>{% trans 'Collation' %}</th>
|
||||
<th>{% trans 'Null' %}</th>
|
||||
<th>{% trans 'Default' %}</th>
|
||||
<th>{% trans 'Extra' %}</th>
|
||||
<th>{% trans 'Comment' %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% set index = 1 %}
|
||||
{% for field in columns %}
|
||||
<tr class="noclick">
|
||||
<td>{{ index }}</td>
|
||||
{% set index = index + 1 %}
|
||||
<td>
|
||||
<strong>
|
||||
{{ field['Field'] }}
|
||||
{% if field['Key'] == 'PRI' %}
|
||||
{{ Util_getImage('b_primary', 'Primary'|trans) }}
|
||||
{% elseif field['Key'] is not empty %}
|
||||
{{ Util_getImage('bd_primary', 'Index'|trans) }}
|
||||
{% endif %}
|
||||
</strong>
|
||||
</td>
|
||||
<td>{{ field['Type'] }}</td>
|
||||
<td>{{ field['Collation'] }}</td>
|
||||
<td>{{ field['Null'] == 'YES' ? 'Yes'|trans : 'No'|trans }}</td>
|
||||
<td>
|
||||
{% if field['Default'] is defined %}
|
||||
{% set extracted_columnspec = Util_extractColumnSpec(field['Type']) %}
|
||||
{% if extracted_columnspec['type'] == 'bit' %}
|
||||
{# here, $field['Default'] contains something like b'010' #}
|
||||
{{ Util_convertBitDefaultValue(field['Default']) }}
|
||||
{% else %}
|
||||
{{ field['Default'] }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if field['Null'] == 'YES' %}
|
||||
<em>NULL</em>
|
||||
{% else %}
|
||||
<em>{% trans %}None{% context %}None for default{% endtrans %}</em>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ field['Extra'] }}</td>
|
||||
<td>{{ field['Comment'] }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
@ -1,35 +0,0 @@
|
||||
<tr class="noclick">
|
||||
<td>{{ index }}</td>
|
||||
<td>
|
||||
<strong>
|
||||
{{ field['Field'] }}
|
||||
{% if field['Key'] == 'PRI' %}
|
||||
{{ Util_getImage('b_primary', 'Primary'|trans) }}
|
||||
{% elseif field['Key'] is not empty %}
|
||||
{{ Util_getImage('bd_primary', 'Index'|trans) }}
|
||||
{% endif %}
|
||||
</strong>
|
||||
</td>
|
||||
<td>{{ field['Type'] }}</td>
|
||||
<td>{{ field['Collation'] }}</td>
|
||||
<td>{{ field['Null'] == 'YES' ? 'Yes'|trans : 'No'|trans }}</td>
|
||||
<td>
|
||||
{% if field['Default'] is defined %}
|
||||
{% set extracted_columnspec = Util_extractColumnSpec(field['Type']) %}
|
||||
{% if extracted_columnspec['type'] == 'bit' %}
|
||||
{# here, $field['Default'] contains something like b'010' #}
|
||||
{{ Util_convertBitDefaultValue(field['Default']) }}
|
||||
{% else %}
|
||||
{{ field['Default'] }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if field['Null'] == 'YES' %}
|
||||
<em>NULL</em>
|
||||
{% else %}
|
||||
<em>{% trans %}None{% context %}None for default{% endtrans %}</em>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ field['Extra'] }}</td>
|
||||
<td>{{ field['Comment'] }}</td>
|
||||
</tr>
|
||||
Loading…
Reference in New Issue
Block a user