rfe-1502 : Smart sorting for int keys

Signed-off-by: Chanaka Dharmarathna <pe.chanaka.ck@gmail.com>
This commit is contained in:
Chanaka Dharmarathna 2014-08-26 21:44:05 +05:30
parent 8d95c4ec4f
commit 7969336d04
8 changed files with 56 additions and 1 deletions

View File

@ -2,6 +2,7 @@ phpMyAdmin - ChangeLog
======================
4.3.0.0 (not yet released)
+ rfe #1502 Smart sorting for int keys
+ rfe #1521 Confirmation message when dropping user(s)
+ rfe #1518 Confirm dialog on accidentally leaving a page
+ rfe #1445 Easy access to "SHOW CREATE ..."

View File

@ -2263,6 +2263,15 @@ Design customization
If enabled, remember the sorting of each table when browsing them.
.. config:option:: $cfg['TablePrimaryKeyOrder']
:type: string
:default: ``'NONE'``
This defines the default sort order for the tables, having a primary key,
when there is no sort order defines externally.
Acceptable values : ['NONE', 'ASC', 'DESC']
.. config:option:: $cfg['HeaderFlipType']
:type: string

View File

@ -2587,6 +2587,12 @@ $cfg['LimitChars'] = 50;
*/
$cfg['RowActionLinks'] = 'left';
/**
* Default sort order by primary key.
* @global string $cfg['TablePrimaryKeyOrder']
*/
$cfg['TablePrimaryKeyOrder'] = 'NONE';
/**
* default display direction (horizontal|vertical|horizontalflipped)
*

View File

@ -57,6 +57,11 @@ $cfg_db['RowActionLinks'] = array(
'right' => __('Right'),
'both' => __('Both')
);
$cfg_db['TablePrimaryKeyOrder'] = array(
'NONE' => __('None'),
'ASC' => __('Ascending'),
'DESC' => __('Descending')
);
$cfg_db['ProtectBinary'] = array(false, 'blob', 'noblob', 'all');
$cfg_db['DefaultDisplay'] = array('horizontal', 'vertical', 'horizontalflipped');
$cfg_db['CharEditing'] = array('input', 'textarea');

View File

@ -522,6 +522,8 @@ $strConfigRecodingEngine_name = __('Recoding engine');
$strConfigRememberSorting_desc
= __('When browsing tables, the sorting of each table is remembered.');
$strConfigRememberSorting_name = __('Remember table\'s sorting');
$strConfigTablePrimaryKeyOrder_desc = __('Default sort order for tables with primary key.');
$strConfigTablePrimaryKeyOrder_name = __('The sort order');
$strConfigRepeatCells_desc
= __('Repeat the headers every X cells, [kbd]0[/kbd] deactivates this feature.');
$strConfigRepeatCells_name = __('Repeat headers');

View File

@ -207,6 +207,7 @@ $forms['Main_panel']['Browse'] = array(
'RepeatCells',
'LimitChars',
'RowActionLinks',
'TablePrimaryKeyOrder',
'DefaultDisplay',
'RememberSorting');
$forms['Main_panel']['Edit'] = array(

View File

@ -117,6 +117,7 @@ $forms['Main_panel']['Browse'] = array(
'RepeatCells',
'LimitChars',
'RowActionLinks',
'TablePrimaryKeyOrder',
'DefaultDisplay',
'RememberSorting');
$forms['Main_panel']['Edit'] = array(

View File

@ -1213,7 +1213,37 @@ function PMA_getDefaultSqlQueryForBrowse($db, $table)
);
$sql_query = $book_sql_query;
} else {
$sql_query = 'SELECT * FROM ' . PMA_Util::backquote($table);
$defaultOrderByClause = '';
if (isset($GLOBALS['cfg']['TablePrimaryKeyOrder'])
&& ($GLOBALS['cfg']['TablePrimaryKeyOrder'] !== 'NONE')
) {
$primaryKey = null;
$primary = PMA_Index::getPrimary($table, $db);
if ($primary !== false) {
$primarycols = $primary->getColumns();
foreach ($primarycols as $col) {
$primaryKey = $col->getName();
break;
}
if ($primaryKey != null) {
$defaultOrderByClause = ' ORDER BY ' . PMA_Util::backquote($table) . '.'
. PMA_Util::backquote($primaryKey) . ' '
. $GLOBALS['cfg']['TablePrimaryKeyOrder'];
}
}
}
$sql_query = 'SELECT * FROM ' . PMA_Util::backquote($table) . $defaultOrderByClause;
}
unset($book_sql_query);