The branch, master has been updated via 39aa4355a90055611412d7f5c75458427545aef3 (commit) via 01ded03e89e9e92e70c4c29750c34a64e4c2339d (commit) from 442294fa6070649f920f7c841cf4062a1f7189cc (commit)
- Log ----------------------------------------------------------------- commit 39aa4355a90055611412d7f5c75458427545aef3 Author: Michal Čihař mcihar@novell.com Date: Tue Jul 27 10:01:58 2010 +0200
Convert default queries to unified expansion.
commit 01ded03e89e9e92e70c4c29750c34a64e4c2339d Author: Michal Čihař mcihar@novell.com Date: Tue Jul 27 09:51:34 2010 +0200
Remove duplicate info.
-----------------------------------------------------------------------
Summary of changes: ChangeLog | 5 +++-- Documentation.html | 8 +++++--- libraries/common.lib.php | 18 ++++++++++++++++++ libraries/config.default.php | 14 +++----------- libraries/sql_query_form.lib.php | 19 +++---------------- 5 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/ChangeLog b/ChangeLog index e9f6419..2acdf45 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 d5c5d45..bf9a05a 100644 --- a/Documentation.html +++ b/Documentation.html @@ -2182,9 +2182,9 @@ setfacl -d -m "g:www-data:rwx" tmp <span id="cfg_DefaultQueryDatabase">$cfg['DefaultQueryDatabase']</span> string </dt> <dd>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 <tt>$cfg['DefaultQueryTable']</tt>.</dd> + specify any. You can use standard + <a href="#faq6_27">format string expansion</a>. + </dd>
<dt id="cfg_SQP_fmtType">$cfg['SQP']['fmtType'] string [<tt>html</tt>|<tt>none</tt>]</dt> <dd> @@ -4353,6 +4353,8 @@ chmod o+rwx tmp <dd>Currently opened database</dd> <dt><code>@TABLE@</code></dt> <dd>Currently opened table</dd> + <dt><code>@FIELDS@</code></dt> + <dd>Fields of currently opened table</dd> <dt><code>@PHPMYADMIN@</code></dt> <dd>phpMyAdmin with version</dd> </dl> diff --git a/libraries/common.lib.php b/libraries/common.lib.php index c9a0f11..9c575c9 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 4f71e56..19b0cf0 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 faa563a..728c12c 100644 --- a/libraries/sql_query_form.lib.php +++ b/libraries/sql_query_form.lib.php @@ -40,8 +40,6 @@ require_once './libraries/bookmark.lib.php'; // used for file listing * @uses $GLOBALS['cfg']['DefaultQueryDatabase'] * @uses $GLOBALS['cfg']['Servers'] * @uses $GLOBALS['cfg']['DefaultTabDatabase'] - * @uses $GLOBALS['cfg']['DefaultQueryDatabase'] - * @uses $GLOBALS['cfg']['DefaultQueryTable'] * @uses $GLOBALS['cfg']['Bookmark'] * @uses PMA_generate_common_url() * @uses PMA_backquote() @@ -235,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']; @@ -259,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');
hooks/post-receive