';
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($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 string $db current database
*
* @return string html dropdown for selecting table
*/
public static function getHtmlForTableDropdown($db)
{
$GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']);
$tables = $GLOBALS['dbi']->getTables($db, $GLOBALS['userlink']);
$selectHtml = '';
return $selectHtml;
}
/**
* build dropdown select html to select column in selected table,
* include only columns which are not already in central list
*
* @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($db, $selected_tbl)
{
$existing_cols = self::getFromTable($db, $selected_tbl);
$GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']);
$columns = (array) $GLOBALS['dbi']->getColumnNames(
$db, $selected_tbl, $GLOBALS['userlink']
);
$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 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($total_rows, $pos, $db)
{
$columnAdd = '
';
return $columnAdd;
}
/**
* build html for 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
* @param string $db current database
*
* @return string html of a particular row in the central columns table.
*/
public static function getHtmlForCentralColumnsTableRow($row, $row_num, $db)
{
$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.
*/
public static function getHtmlForCentralColumnsEditTableRow($row, $row_num)
{
$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 static function getListRaw($db, $table)
{
$cfgCentralColumns = self::getParams();
if (empty($cfgCentralColumns)) {
return json_encode(array());
}
$centralTable = $cfgCentralColumns['table'];
if (empty($table) || $table == '') {
$query = 'SELECT * FROM ' . Util::backquote($centralTable) . ' '
. 'WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\';';
} else {
$GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']);
$columns = (array) $GLOBALS['dbi']->getColumnNames(
$db, $table, $GLOBALS['userlink']
);
$cols = '';
foreach ($columns as $col_select) {
$cols .= '\'' . $GLOBALS['dbi']->escapeString($col_select) . '\',';
}
$cols = trim($cols, ',');
$query = 'SELECT * FROM ' . Util::backquote($centralTable) . ' '
. 'WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
if ($cols) {
$query .= ' AND col_name NOT IN (' . $cols . ')';
}
$query .= ';';
}
$GLOBALS['dbi']->selectDb($cfgCentralColumns['db'], $GLOBALS['controllink']);
$columns_list = (array)$GLOBALS['dbi']->fetchResult(
$query, null, null, $GLOBALS['controllink']
);
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(&$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 static function getHtmlForAddNewColumn($db, $total_rows)
{
$addNewColumn = '
';
return $addNewColumn;
}
/**
* Get HTML for editing page central columns
*
* @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($selected_fld,$selected_db)
{
$html = '