<?php
// Cell index: If certain fields get left out, the counter shouldn't change.
$ci = 0;

// Every time a cell shall be left out the STRG-jumping feature, $ci_offset
// has to be incremented ($ci_offset++)
$ci_offset = -1;
?>

<td class="center">
    <!-- column name -->
    <?php echo PMA\Template::get('columns_definitions/column_name')
        ->render(array(
            'columnNumber' => $columnNumber,
            'ci' => $ci++,
            'ci_offset' => $ci_offset,
            'columnMeta' => isset($columnMeta) ? $columnMeta : null,
            'cfgRelation' => $cfgRelation
        )); ?>
</td>
<td class="center">
    <!-- column type -->
    <?php echo PMA\Template::get('columns_definitions/column_type')
        ->render(array(
            'columnNumber' => $columnNumber,
            'ci' => $ci++,
            'ci_offset' => $ci_offset,
            'type_upper' => $type_upper,
            'columnMeta' => isset($columnMeta) ? $columnMeta : null
        )); ?>
</td>
<td class="center">
    <!-- column length -->
    <?php echo PMA\Template::get('columns_definitions/column_length')
        ->render(array(
            'columnNumber' => $columnNumber,
            'ci' => $ci++,
            'ci_offset' => $ci_offset,
            'length_values_input_size' => $length_values_input_size,
            'length_to_display' => $length
        )); ?>
</td>
<td class="center">
    <!-- column default -->
    <?php echo PMA\Template::get('columns_definitions/column_default')
        ->render(array(
            'columnNumber' => $columnNumber,
            'ci' => $ci++,
            'ci_offset' => $ci_offset,
            'type_upper' => isset($type_upper) ? $type_upper : null,
            'columnMeta' => isset($columnMeta) ? $columnMeta : null
        )); ?>
</td>
<td class="center">
    <!-- column collation -->
    <?php $tmp_collation = empty($columnMeta['Collation']) ? null : $columnMeta['Collation']; ?>
    <?php echo PMA_generateCharsetDropdownBox(
        PMA_CSDROPDOWN_COLLATION,
        'field_collation[' . $columnNumber . ']',
        'field_' . $columnNumber . '_' . ($ci - $ci_offset),
        $tmp_collation,
        false
    ); ?>
</td>
<td class="center">
    <!-- column attribute -->
    <?php echo PMA\Template::get('columns_definitions/column_attribute')
        ->render(array(
            'columnNumber' => $columnNumber,
            'ci' => $ci++,
            'ci_offset' => $ci_offset,
            'extracted_columnspec' => isset($extracted_columnspec) ? $extracted_columnspec : null,
            'columnMeta' => isset($columnMeta) ? $columnMeta : null,
            'submit_attribute' => isset($submit_attribute) ? $submit_attribute : null,
        )); ?>
</td>
<td class="center">
    <!-- column NULL -->
    <?php echo PMA\Template::get('columns_definitions/column_null')
        ->render(array(
            'columnNumber' => $columnNumber,
            'ci' => $ci++,
            'ci_offset' => $ci_offset,
            'columnMeta' => isset($columnMeta) ? $columnMeta : null
        )); ?>
</td>
<?php if (isset($_REQUEST['change_column']) && !empty($_REQUEST['change_column']) && ! PMA_DRIZZLE): ?>
    <!-- column Adjust privileges, Only for 'Edit' Column(s) -->
    <td class="center">
        <?php $privs_available = isset($GLOBALS['col_priv']) && $GLOBALS['col_priv']
            && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']; ?>
        <?php echo PMA\Template::get('columns_definitions/column_adjust_privileges')
            ->render(array(
                'columnNumber' => $columnNumber,
                'ci' => $ci++,
                'ci_offset' => $ci_offset,
                'privs_available' => $privs_available
            )); ?>
    </td>
<?php endif; ?>
<?php if (!$is_backup): ?>
    <!-- column indexes, See my other comment about  this 'if'. -->
    <td class="center">
        <?php echo PMA\Template::get('columns_definitions/column_indexes')
            ->render(array(
                'columnNumber' => $columnNumber,
                'ci' => $ci++,
                'ci_offset' => $ci_offset,
                'columnMeta' => $columnMeta
            )); ?>
    </td>
<?php endif; ?>
<td class="center">
    <!-- column auto_increment -->
    <?php echo PMA\Template::get('columns_definitions/column_auto_increment')
        ->render(array(
            'columnNumber' => $columnNumber,
            'ci' => $ci++,
            'ci_offset' => $ci_offset,
            'columnMeta' => $columnMeta
        )); ?>
</td>
<td class="center">
    <!-- column comments -->
    <?php echo PMA\Template::get('columns_definitions/column_comment')
        ->render(array(
            'columnNumber' => $columnNumber,
            'ci' => $ci++,
            'ci_offset' => $ci_offset,
            'columnMeta' => isset($columnMeta) ? $columnMeta : null,
            'comments_map' => $comments_map
        )); ?>
</td>
 <!-- column virtuality -->
<?php if (PMA_Util::isVirtualColumnsSupported()): ?>
    <td class="center">
        <?php echo PMA\Template::get('columns_definitions/column_virtuality')
            ->render(array(
                'columnNumber' => $columnNumber,
                'ci' => $ci++,
                'ci_offset' => $ci_offset,
                'columnMeta' => isset($columnMeta) ? $columnMeta : null
            )); ?>
    </td>
<?php endif; ?>
<!-- move column -->
<?php if (isset($fields_meta)): ?>
    <?php $current_index = 0;
    for ($mi = 0, $cols = count($move_columns); $mi < $cols; $mi++) {
        if ($move_columns[$mi]->name == $columnMeta['Field']) {
            $current_index = $mi;
            break;
        }
    } ?>

    <td class="center">
        <?php echo PMA\Template::get('columns_definitions/move_column')
            ->render(array(
                'columnNumber' => $columnNumber,
                'ci' => $ci++,
                'ci_offset' => $ci_offset,
                'columnMeta' => $columnMeta,
                'move_columns' => $move_columns,
                'current_index' => $current_index
            )); ?>
    </td>
<?php endif; ?>

<?php if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME'] && $cfgRelation['commwork']): ?>
    <td class="center">
        <!-- Column Mime-type -->
        <?php echo PMA\Template::get('columns_definitions/mime_type')
            ->render(array(
                'columnNumber' => $columnNumber,
                'ci' => $ci++,
                'ci_offset' => $ci_offset,
                'available_mime' => $available_mime,
                'columnMeta' => $columnMeta,
                'mime_map' => $mime_map
            )); ?>
    </td>
    <td class="center">
        <!-- Column Browser transformation -->
        <?php echo PMA\Template::get('columns_definitions/transformation')
            ->render(array(
                'columnNumber' => $columnNumber,
                'ci' => $ci++,
                'ci_offset' => $ci_offset,
                'available_mime' => $available_mime,
                'columnMeta' => $columnMeta,
                'mime_map' => $mime_map,
                'type' => 'transformation'
            )); ?>
    </td>
    <td class="center">
        <!-- column Transformation options -->
        <?php echo PMA\Template::get('columns_definitions/transformation_option')
            ->render(array(
                'columnNumber' => $columnNumber,
                'ci' => $ci++,
                'ci_offset' => $ci_offset,
                'columnMeta' => $columnMeta,
                'mime_map' => $mime_map,
                'type_prefix' => '',
            )); ?>
    </td>
    <td class="center">
        <!-- Column Input transformation -->
        <?php echo PMA\Template::get('columns_definitions/transformation')
            ->render(array(
                'columnNumber' => $columnNumber,
                'ci' => $ci++,
                'ci_offset' => $ci_offset,
                'available_mime' => $available_mime,
                'columnMeta' => $columnMeta,
                'mime_map' => $mime_map,
                'type' => 'input_transformation'
            )); ?>
    </td>
    <td class="center">
        <!-- column Input transformation options -->
        <?php echo PMA\Template::get('columns_definitions/transformation_option')
            ->render(array(
                'columnNumber' => $columnNumber,
                'ci' => $ci++,
                'ci_offset' => $ci_offset,
                'columnMeta' => $columnMeta,
                'mime_map' => $mime_map,
                'type_prefix' => 'input_',
            )); ?>
    </td>
<?php endif; ?>