';
return $table_navigation_html;
}
/**
* function generate and return the table header for central columns page
*
* @param string $class styling class of 'th' elements
* @param string $title title of the 'th' elements
* @param integer $actionCount number of actions
*
* @return string html for table header in central columns view/edit page
*/
public static function getTableHeader($class='', $title='', $actionCount=0)
{
$action = '';
if ($actionCount > 0) {
$action .= '
'
. __('Action') . '
';
}
$tableheader = '';
$tableheader .= '
'
. '
'
. '
'
. $action
. '
'
. __('Name') . '
'
. '
'
. __('Type') . '
'
. '
'
. __('Length/Values') . '
'
. '
'
. __('Default') . '
'
. '
' . __('Collation') . '
'
. '
'
. __('Attribute') . '
'
. '
'
. __('Null') . '
'
. '
'
. __('A_I') . '
'
. '
';
$tableheader .= '';
return $tableheader;
}
/**
* Function generate and return the table header for
* multiple edit central columns page
*
* @param array $header_cells headers list
*
* @return string html for table header in central columns multi edit page
*/
public static function getEditTableHeader(array $header_cells)
{
$html = '
';
$html .= '
' . __('Structure');
$html .= '
';
foreach ($header_cells as $header_val) {
$html .= '
' . $header_val . '
';
}
$html .= '
';
return $html;
}
/**
* build the dropdown select html for tables of given database
*
* @param DatabaseInterface $dbi DatabaseInterface instance
* @param string $db current database
*
* @return string html dropdown for selecting table
*/
public static function getHtmlForTableDropdown(DatabaseInterface $dbi, $db)
{
$dbi->selectDb($db);
$tables = $dbi->getTables($db);
$selectHtml = '';
return $selectHtml;
}
/**
* build dropdown select html to select column in selected table,
* include only columns which are not already in central list
*
* @param DatabaseInterface $dbi DatabaseInterface instance
* @param string $user current user
* @param string $db current database to which selected table belongs
* @param string $selected_tbl selected table
*
* @return string html to select column
*/
public static function getHtmlForColumnDropdown(
DatabaseInterface $dbi,
$user,
$db,
$selected_tbl
) {
$existing_cols = self::getFromTable($dbi, $user, $db, $selected_tbl);
$dbi->selectDb($db);
$columns = (array) $dbi->getColumnNames(
$db, $selected_tbl
);
$selectColHtml = "";
foreach ($columns as $column) {
if (!in_array($column, $existing_cols)) {
$selectColHtml .= '';
}
}
return $selectColHtml;
}
/**
* HTML to display the form that let user to add a column on Central columns page
*
* @param DatabaseInterface $dbi DatabaseInterface instance
* @param int $total_rows total number of rows in complete result set
* @param int $pos offset of first result with complete result set
* @param string $db current database
*
* @return string html to add a column in the central list
*/
public static function getHtmlForAddCentralColumn(
DatabaseInterface $dbi,
$total_rows,
$pos,
$db
) {
$columnAdd = '
';
return $columnAdd;
}
/**
* build html for a row in central columns table
*
* @param DatabaseInterface $dbi DatabaseInterface instance
* @param string $maxRows number of rows displayed when browsing a result set
* @param string $charEditing which editor should be used for CHAR/VARCHAR fields
* @param boolean $disableIs Disable use of INFORMATION_SCHEMA
* @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
* @param string $db current database
*
* @return string html of a particular row in the central columns table.
*/
public static function getHtmlForCentralColumnsTableRow(
DatabaseInterface $dbi,
$maxRows,
$charEditing,
$disableIs,
array $row,
$row_num,
$db
) {
$tableHtml = '
';
return $tableHtml;
}
/**
* build html for editing a row in central columns table
*
* @param DatabaseInterface $dbi DatabaseInterface instance
* @param string $maxRows number of rows displayed when browsing a result set
* @param string $charEditing which editor should be used for CHAR/VARCHAR fields
* @param boolean $disableIs Disable use of INFORMATION_SCHEMA
* @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.
*/
public static function getHtmlForCentralColumnsEditTableRow(
DatabaseInterface $dbi,
$maxRows,
$charEditing,
$disableIs,
array $row,
$row_num
) {
$tableHtml = '
';
return $tableHtml;
}
/**
* get the list of columns in given database excluding
* the columns present in current table
*
* @param DatabaseInterface $dbi DatabaseInterface instance
* @param string $user current user
* @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 static function getListRaw(
DatabaseInterface $dbi,
$user,
$db,
$table
) {
$cfgCentralColumns = self::getParams($user);
if (empty($cfgCentralColumns)) {
return json_encode(array());
}
$centralTable = $cfgCentralColumns['table'];
if (empty($table) || $table == '') {
$query = 'SELECT * FROM ' . Util::backquote($centralTable) . ' '
. 'WHERE db_name = \'' . $dbi->escapeString($db) . '\';';
} else {
$dbi->selectDb($db);
$columns = (array) $dbi->getColumnNames(
$db, $table
);
$cols = '';
foreach ($columns as $col_select) {
$cols .= '\'' . $dbi->escapeString($col_select) . '\',';
}
$cols = trim($cols, ',');
$query = 'SELECT * FROM ' . Util::backquote($centralTable) . ' '
. 'WHERE db_name = \'' . $dbi->escapeString($db) . '\'';
if ($cols) {
$query .= ' AND col_name NOT IN (' . $cols . ')';
}
$query .= ';';
}
$dbi->selectDb($cfgCentralColumns['db'], DatabaseInterface::CONNECT_CONTROL);
$columns_list = (array)$dbi->fetchResult(
$query, null, null, DatabaseInterface::CONNECT_CONTROL
);
self::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 static 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.png', 'edit central columns'
);
$html_output .= Util::getButtonOrImage(
'delete_central_columns', 'mult_submit',
__('Delete'), 'b_drop.png',
'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
*/
public static 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
*/
public static 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 DatabaseInterface $dbi DatabaseInterface instance
* @param string $maxRows number of rows displayed when browsing a result set
* @param string $charEditing which editor should be used for CHAR/VARCHAR fields
* @param boolean $disableIs Disable use of INFORMATION_SCHEMA
* @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 static function getHtmlForAddNewColumn(
DatabaseInterface $dbi,
$maxRows,
$charEditing,
$disableIs,
$db,
$total_rows
) {
$addNewColumn = '
';
return $addNewColumn;
}
/**
* Get HTML for editing page central columns
*
* @param DatabaseInterface $dbi DatabaseInterface instance
* @param string $user current user
* @param string $maxRows number of rows displayed when browsing a result set
* @param string $charEditing which editor should be used for CHAR/VARCHAR fields
* @param boolean $disableIs Disable use of INFORMATION_SCHEMA
* @param array $selected_fld Array containing the selected fields
* @param string $selected_db String containing the name of database
*
* @return string HTML for complete editing page for central columns
*/
public static function getHtmlForEditingPage(
DatabaseInterface $dbi,
$user,
$maxRows,
$charEditing,
$disableIs,
array $selected_fld,
$selected_db
) {
$html = '