diff --git a/ChangeLog b/ChangeLog
index e9f641925..2acdf45b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -91,8 +91,9 @@ $Id$
+ [core] Dropped AllowAnywhereRecoding configuration variable.
- rfe #3016457 [interface] Define tab order in SQL form to allow easier tab
navigation.
-+ [code] Centralized format string expansion, @VARIABLES@ are recommended way
- now.
++ [core] Centralized format string expansion, @VARIABLES@ are recommended way
+ now, used by file name templates, default queries, export and title
+ generating.
+ [validator] SQL validator works also with SOAP PHP extension.
- [interface] Better formatting for SQL validator results.
- [doc] The linked-tables infrastructure is now called phpMyAdmin
diff --git a/Documentation.html b/Documentation.html
index d5c5d4516..bf9a05a81 100644
--- a/Documentation.html
+++ b/Documentation.html
@@ -2182,9 +2182,9 @@ setfacl -d -m "g:www-data:rwx" tmp
$cfg['DefaultQueryDatabase'] string
Default queries that will be displayed in query boxes when user didn't
- specify any. Use %d for database name, %t for table name and %f for a
- comma separated list of column names. Note that %t and %f are only
- applicable to $cfg['DefaultQueryTable'].
+ specify any. You can use standard
+ format string expansion.
+
$cfg['SQP']['fmtType'] string [html|none]
@@ -4353,6 +4353,8 @@ chmod o+rwx tmp
Currently opened database
@TABLE@
Currently opened table
+ @FIELDS@
+ Fields of currently opened table
@PHPMYADMIN@
phpMyAdmin with version
diff --git a/libraries/common.lib.php b/libraries/common.lib.php
index c9a0f1153..9c575c988 100644
--- a/libraries/common.lib.php
+++ b/libraries/common.lib.php
@@ -2891,6 +2891,24 @@ function PMA_expandUserString($string, $escape = NULL, $updates = array()) {
}
}
+ /* Fetch fields list if required */
+ if (strpos($string, '@FIELDS@') !== FALSE) {
+ $fields_list = PMA_DBI_fetch_result(
+ 'SHOW FULL COLUMNS FROM ' . PMA_backquote($GLOBALS['db'])
+ . '.' . PMA_backquote($GLOBALS['table']));
+
+ $field_names = array();
+ foreach ($fields_list as $field) {
+ if (!is_null($escape)) {
+ $field_names[] = $escape($field['Field']);
+ } else {
+ $field_names[] = $field['Field'];
+ }
+ }
+
+ $replace['@FIELDS@'] = implode(',', $field_names);
+ }
+
/* Do the replacement */
return str_replace(array_keys($replace), array_values($replace), strftime($string));
}
diff --git a/libraries/config.default.php b/libraries/config.default.php
index 4f71e5610..19b0cf033 100644
--- a/libraries/config.default.php
+++ b/libraries/config.default.php
@@ -2344,22 +2344,14 @@ $cfg['ThemePerServer'] = false;
*/
/**
- * Default queries
- * %d will be replaced by the database name.
- * %t will be replaced by the table name.
- * %f will be replaced by a list of field names.
- * (%t and %f only applies to DefaultQueryTable)
+ * Default query for table
*
* @global string $cfg['DefaultQueryTable']
*/
-$cfg['DefaultQueryTable'] = 'SELECT * FROM %t WHERE 1';
+$cfg['DefaultQueryTable'] = 'SELECT * FROM @TABLE@ WHERE 1';
/**
- * Default queries
- * %d will be replaced by the database name.
- * %t will be replaced by the table name.
- * %f will be replaced by a list of field names.
- * (%t and %f only applies to DefaultQueryTable)
+ * Default query for database
*
* @global string $cfg['DefaultQueryDatabase']
*/
diff --git a/libraries/sql_query_form.lib.php b/libraries/sql_query_form.lib.php
index e46da3a48..728c12c48 100644
--- a/libraries/sql_query_form.lib.php
+++ b/libraries/sql_query_form.lib.php
@@ -233,8 +233,7 @@ function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, $delimiter
// $tmp_db_link = htmlspecialchars($db);
$legend = sprintf(__('Run SQL query/queries on database %s'), $tmp_db_link);
if (empty($query)) {
- $query = str_replace('%d',
- PMA_backquote($db), $GLOBALS['cfg']['DefaultQueryDatabase']);
+ $query = PMA_expandUserString($GLOBALS['cfg']['DefaultQueryDatabase'], 'PMA_backquote');
}
} else {
$table = $GLOBALS['table'];
@@ -257,18 +256,8 @@ function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, $delimiter
// else use
// $tmp_db_link = htmlspecialchars($db);
$legend = sprintf(__('Run SQL query/queries on database %s'), $tmp_db_link);
- if (empty($query) && count($fields_list)) {
- $field_names = array();
- foreach ($fields_list as $field) {
- $field_names[] = PMA_backquote($field['Field']);
- }
- $query =
- str_replace('%d', PMA_backquote($db),
- str_replace('%t', PMA_backquote($table),
- str_replace('%f',
- implode(', ', $field_names),
- $GLOBALS['cfg']['DefaultQueryTable'])));
- unset($field_names);
+ if (empty($query)) {
+ $query = PMA_expandUserString($GLOBALS['cfg']['DefaultQueryTable'], 'PMA_backquote');
}
}
$legend .= ': ' . PMA_showMySQLDocu('SQL-Syntax', 'SELECT');