'
. 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';
} else {
if ($row['col_default'] == 'CURRENT_TIMESTAMP'
|| $row['col_default'] == 'current_timestamp()'
) {
$meta['DefaultType'] = 'CURRENT_TIMESTAMP';
} elseif ($row['col_default'] == 'NULL') {
$meta['DefaultType'] = $row['col_default'];
} else {
$meta['DefaultType'] = 'USER_DEFINED';
$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
)
. ' | ';
$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']
)
)
)
. ' | ';
$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;
}
/**
* build html for editing a row in central columns table
*
* @param array $row array contains complete information of a
* particular row of central list table
* @param int $row_num position the row in the table
*
* @return string html of a particular row in the central columns table.
*/
private function getHtmlForEditTableRow(array $row, $row_num)
{
$tableHtml = ''
. ''
. '| '
. 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 .=
''
. 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 .=
''
. 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';
} else {
if ($row['col_default'] == 'CURRENT_TIMESTAMP'
|| $row['col_default'] == 'current_timestamp()'
) {
$meta['DefaultType'] = 'CURRENT_TIMESTAMP';
} elseif ($row['col_default'] == 'NULL') {
$meta['DefaultType'] = $row['col_default'];
} else {
$meta['DefaultType'] = 'USER_DEFINED';
$meta['DefaultValue'] = $row['col_default'];
}
}
$tableHtml .=
''
. Template::get('columns_definitions/column_default')
->render(
array(
'column_number' => $row_num,
'ci' => 3,
'ci_offset' => 0,
'type_upper' => mb_strtoupper($row['col_default']),
'column_meta' => $meta,
'char_editing' => $this->charEditing,
)
)
. ' | ';
$tableHtml .=
''
. Charsets::getCollationDropdownBox(
$this->dbi,
$this->disableIs,
'field_collation[' . $row_num . ']',
'field_' . $row_num . '_4', $row['col_collation'], false
)
. ' | ';
$tableHtml .=
''
. Template::get('columns_definitions/column_attribute')
->render(
array(
'column_number' => $row_num,
'ci' => 5,
'ci_offset' => 0,
'extracted_columnspec' => array(
'attribute' => $row['col_attribute']
),
'column_meta' => array(),
'submit_attribute' => false,
'attribute_types' => $this->dbi->types->getAttributes(),
)
)
. ' | ';
$tableHtml .=
''
. 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 .=
''
. 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;
}
/**
* get the list of columns in given database excluding
* the columns present in current table
*
* @param string $db selected database
* @param string $table current table name
*
* @return string encoded list of columns present in central list for the given
* database
*/
public function getListRaw($db, $table)
{
$cfgCentralColumns = $this->getParams();
if (empty($cfgCentralColumns)) {
return json_encode(array());
}
$centralTable = $cfgCentralColumns['table'];
if (empty($table) || $table == '') {
$query = 'SELECT * FROM ' . Util::backquote($centralTable) . ' '
. 'WHERE db_name = \'' . $this->dbi->escapeString($db) . '\';';
} else {
$this->dbi->selectDb($db);
$columns = (array) $this->dbi->getColumnNames(
$db, $table
);
$cols = '';
foreach ($columns as $col_select) {
$cols .= '\'' . $this->dbi->escapeString($col_select) . '\',';
}
$cols = trim($cols, ',');
$query = 'SELECT * FROM ' . Util::backquote($centralTable) . ' '
. 'WHERE db_name = \'' . $this->dbi->escapeString($db) . '\'';
if ($cols) {
$query .= ' AND col_name NOT IN (' . $cols . ')';
}
$query .= ';';
}
$this->dbi->selectDb($cfgCentralColumns['db'], DatabaseInterface::CONNECT_CONTROL);
$columns_list = (array)$this->dbi->fetchResult(
$query, null, null, DatabaseInterface::CONNECT_CONTROL
);
$this->handleColumnExtra($columns_list);
return json_encode($columns_list);
}
/**
* Get HTML for "check all" check box with "with selected" dropdown
*
* @param string $pmaThemeImage pma theme image url
* @param string $text_dir url for text directory
*
* @return string $html_output
*/
public function getTableFooter($pmaThemeImage, $text_dir)
{
$html_output = Template::get('select_all')
->render(
array(
'pma_theme_image' => $pmaThemeImage,
'text_dir' => $text_dir,
'form_name' => 'tableslistcontainer',
)
);
$html_output .= Util::getButtonOrImage(
'edit_central_columns', 'mult_submit change_central_columns',
__('Edit'), 'b_edit', 'edit central columns'
);
$html_output .= Util::getButtonOrImage(
'delete_central_columns', 'mult_submit',
__('Delete'), 'b_drop',
'remove_from_central_columns'
);
return $html_output;
}
/**
* function generate and return the table footer for
* multiple edit central columns page
*
* @return string html for table footer in central columns multi edit page
*/
private function getEditTableFooter()
{
$html_output = '';
return $html_output;
}
/**
* Column `col_extra` is used to store both extra and attributes for a column.
* This method separates them.
*
* @param array &$columns_list columns list
*
* @return void
*/
private function handleColumnExtra(array &$columns_list)
{
foreach ($columns_list as &$row) {
$vals = explode(',', $row['col_extra']);
if (in_array('BINARY', $vals)) {
$row['col_attribute'] = 'BINARY';
} elseif (in_array('UNSIGNED', $vals)) {
$row['col_attribute'] = 'UNSIGNED';
} elseif (in_array('UNSIGNED ZEROFILL', $vals)) {
$row['col_attribute'] = 'UNSIGNED ZEROFILL';
} elseif (in_array('on update CURRENT_TIMESTAMP', $vals)) {
$row['col_attribute'] = 'on update CURRENT_TIMESTAMP';
} else {
$row['col_attribute'] = '';
}
if (in_array('auto_increment', $vals)) {
$row['col_extra'] = 'auto_increment';
} else {
$row['col_extra'] = '';
}
}
}
/**
* build html for adding a new user defined column to central list
*
* @param string $db current database
* @param integer $total_rows number of rows in central columns
*
* @return string html of the form to let user add a new user defined column to the
* list
*/
public function getHtmlForAddNewColumn($db, $total_rows)
{
$addNewColumn = '