The branch, master has been updated via e5e340e525f51a318def41e087301b015c661ff1 (commit) via cb6716c4814ba7e8031ea2a0a5f5a8d7ab78068d (commit) via b1cf628bd7809c58af73391f3b9949f89c11a386 (commit) via 38171b9e239d68b4116d08ef46749a554a32e485 (commit) via 7a788a52b9931c317611b3c14b8795a999cc736a (commit) via 906d7bc6325cd9b186db6eb24c4252e27c9aa8fe (commit) via dba7151245ac841a02a6733eef3f05c00d9d3794 (commit) via 2040be9611832190e07c001e19b8755c13399589 (commit) via 9b2aa3c40d65d40a293c433dc581f0aa0c2bc354 (commit) via 715f2f04f6170265d2ea9f9d0b507bc4dae40557 (commit) via 7415caa4e4cbc576b9425cb96a04c0928307e8fb (commit) via 32910a9b285eac3ab7d6d3a52c26757019bf9570 (commit) via b24a566ebaa1b73944c23703cae00b56447ad049 (commit) from 40aaa768dd3529b05563f7c0193c1a70661574fd (commit)
- Log ----------------------------------------------------------------- commit e5e340e525f51a318def41e087301b015c661ff1 Author: Michal Čihař mcihar@novell.com Date: Wed Jul 21 10:16:30 2010 +0200
Proper propagating of overrided values.
commit cb6716c4814ba7e8031ea2a0a5f5a8d7ab78068d Author: Michal Čihař mcihar@novell.com Date: Wed Jul 21 10:11:35 2010 +0200
Documentation in LaTeX format strings.
commit b1cf628bd7809c58af73391f3b9949f89c11a386 Author: Michal Čihař mcihar@novell.com Date: Wed Jul 21 10:10:06 2010 +0200
Support for phpMyAdmin documentation in plugin library.
commit 38171b9e239d68b4116d08ef46749a554a32e485 Author: Michal Čihař mcihar@novell.com Date: Wed Jul 21 10:08:48 2010 +0200
Move documentation link to better place.
commit 7a788a52b9931c317611b3c14b8795a999cc736a Author: Michal Čihař mcihar@novell.com Date: Wed Jul 21 10:07:03 2010 +0200
Document why __VAR__ is there.
commit 906d7bc6325cd9b186db6eb24c4252e27c9aa8fe Author: Michal Čihař mcihar@novell.com Date: Wed Jul 21 10:06:16 2010 +0200
By default use new format strings.
commit dba7151245ac841a02a6733eef3f05c00d9d3794 Author: Michal Čihař mcihar@novell.com Date: Wed Jul 21 10:05:55 2010 +0200
Document new format strings.
commit 2040be9611832190e07c001e19b8755c13399589 Author: Michal Čihař mcihar@novell.com Date: Wed Jul 21 09:56:05 2010 +0200
Documentation.
commit 9b2aa3c40d65d40a293c433dc581f0aa0c2bc354 Author: Michal Čihař mcihar@novell.com Date: Wed Jul 21 09:55:13 2010 +0200
Indentation.
commit 715f2f04f6170265d2ea9f9d0b507bc4dae40557 Author: Michal Čihař mcihar@novell.com Date: Wed Jul 21 09:54:04 2010 +0200
Move messages to place where they are used.
commit 7415caa4e4cbc576b9425cb96a04c0928307e8fb Author: Michal Čihař mcihar@novell.com Date: Wed Jul 21 09:51:24 2010 +0200
LaTeX export uses PMA_expandUserString.
commit 32910a9b285eac3ab7d6d3a52c26757019bf9570 Author: Michal Čihař mcihar@novell.com Date: Wed Jul 21 09:43:38 2010 +0200
Cleanup in PMA_expandUserString.
commit b24a566ebaa1b73944c23703cae00b56447ad049 Author: Michal Čihař mcihar@novell.com Date: Wed Jul 21 09:36:28 2010 +0200
Export uses same expanding as title.
-----------------------------------------------------------------------
Summary of changes: Documentation.html | 47 +++++++++++++++--------- export.php | 4 +-- libraries/common.lib.php | 69 ++++++++++++++++++++++++----------- libraries/config.default.php | 10 +++--- libraries/display_export.lib.php | 7 ++-- libraries/export/latex.php | 47 +++++++++++++----------- libraries/plugin_interface.lib.php | 2 + libraries/select_lang.lib.php | 4 -- 8 files changed, 114 insertions(+), 76 deletions(-)
diff --git a/Documentation.html b/Documentation.html index 67f9ff1..7574c09 100644 --- a/Documentation.html +++ b/Documentation.html @@ -2150,24 +2150,8 @@ setfacl -d -m "g:www-data:rwx" tmp <dt id="cfg_TitleDatabase">$cfg['TitleDatabase'] string</dt> <dt id="cfg_TitleServer">$cfg['TitleServer'] string</dt> <dt id="cfg_TitleDefault">$cfg['TitleDefault'] string</dt> - <dd>Allows you to specify window's title bar. Following magic string can - be used to get special values: - <dl> - <dt><code>@HTTP_HOST@</code></dt> - <dd>HTTP host that runs phpMyAdmin</dd> - <dt><code>@SERVER@</code></dt> - <dd>MySQL server name</dd> - <dt><code>@VERBOSE@</code></dt> - <dd>Verbose MySQL server name as defined in <a href="#cfg_Servers_verbose">server configuration</a></dd> - <dt><code>@VSERVER@</code></dt> - <dd>Verbose MySQL server name if set, otherwise normal</dd> - <dt><code>@DATABASE@</code></dt> - <dd>Currently opened database</dd> - <dt><code>@TABLE@</code></dt> - <dd>Currently opened table</dd> - <dt><code>@PHPMYADMIN@</code></dt> - <dd>phpMyAdmin with version</dd> - </dl> + <dd>Allows you to specify window's title bar. You can use + <a href="#faq6_27">format string expansion</a>. </dd>
<dt id="cfg_ErrorIconic">$cfg['ErrorIconic'] boolean</dt> @@ -4330,6 +4314,33 @@ chmod o+rwx tmp <p> Click the first row of the range, hold the shift key and click the last row of the range. This works everywhere you see rows, for example in Browse mode or on the Structure page.</p>
+<h4 id="faq6_27"> + <a href="#faq6_27">6.27 What format strings can I use?</a></h4> + +<p> + In all places where phpMyAdmin accepts format strings, you can use + <code>@VARIABLE@</code> expansion and + <a href="http://php.net/strftime">strftime</a> format strings. The + expanded variables depend on a context (eg. if you don't have chosen + table, you can not get table name), but following variables can be used: +</p> +<dl> + <dt><code>@HTTP_HOST@</code></dt> + <dd>HTTP host that runs phpMyAdmin</dd> + <dt><code>@SERVER@</code></dt> + <dd>MySQL server name</dd> + <dt><code>@VERBOSE@</code></dt> + <dd>Verbose MySQL server name as defined in <a href="#cfg_Servers_verbose">server configuration</a></dd> + <dt><code>@VSERVER@</code></dt> + <dd>Verbose MySQL server name if set, otherwise normal</dd> + <dt><code>@DATABASE@</code></dt> + <dd>Currently opened database</dd> + <dt><code>@TABLE@</code></dt> + <dd>Currently opened table</dd> + <dt><code>@PHPMYADMIN@</code></dt> + <dd>phpMyAdmin with version</dd> +</dl> + <h3 id="faqproject">phpMyAdmin project</h3>
<h4 id="faq7_1"> diff --git a/export.php b/export.php index 43c37ce..2db992d 100644 --- a/export.php +++ b/export.php @@ -247,18 +247,16 @@ if ($asfile) { if (isset($remember_template)) { $GLOBALS['PMA_Config']->setCookie('pma_server_filename_template', $filename_template); } - $filename = str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template)); } elseif ($export_type == 'database') { if (isset($remember_template)) { $GLOBALS['PMA_Config']->setCookie('pma_db_filename_template', $filename_template); } - $filename = str_replace('__DB__', $db, str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template))); } else { if (isset($remember_template)) { $GLOBALS['PMA_Config']->setCookie('pma_table_filename_template', $filename_template); } - $filename = str_replace('__TABLE__', $table, str_replace('__DB__', $db, str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template)))); } + $filename = PMA_expandUserString($filename_template);
// convert filename to iso-8859-1, it is safer $filename = PMA_convert_string($charset, 'iso-8859-1', $filename); diff --git a/libraries/common.lib.php b/libraries/common.lib.php index e2af6d9..a8c32fc 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -2828,28 +2828,53 @@ $mapping = array( }
/** - * Formats user string, expading @VARIABLES@. + * Formats user string, expading @VARIABLES@, accepting strftime format string. + * + * @param string Text where to do expansion. + * @param function Function to call for escaping variable values. + * @param array Array with overrides for default parameters (obtained from GLOBALS). */ -function PMA_expandUserString($string) { - return str_replace( - array( - '@HTTP_HOST@', - '@SERVER@', - '@VERBOSE@', - '@VSERVER@', - '@DATABASE@', - '@TABLE@', - '@PHPMYADMIN@', - ), - array( - PMA_getenv('HTTP_HOST') ? PMA_getenv('HTTP_HOST') : '', - $GLOBALS['cfg']['Server']['host'], - $GLOBALS['cfg']['Server']['verbose'], - !empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : $GLOBALS['cfg']['Server']['host'], - $GLOBALS['db'], - $GLOBALS['table'], - 'phpMyAdmin ' . PMA_VERSION, - ), - $string); +function PMA_expandUserString($string, $escape = NULL, $updates = array()) { + /* Content */ + $vars['http_host'] = PMA_getenv('HTTP_HOST') ? PMA_getenv('HTTP_HOST') : ''; + $vars['server_name'] = $GLOBALS['cfg']['Server']['host']; + $vars['server_verbose'] = $GLOBALS['cfg']['Server']['verbose']; + $vars['server_verbose_or_name'] = !empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : $GLOBALS['cfg']['Server']['host']; + $vars['database'] = $GLOBALS['db']; + $vars['table'] = $GLOBALS['table']; + $vars['phpmyadmin_version'] = 'phpMyAdmin ' . PMA_VERSION; + + /* Update forced variables */ + foreach($updates as $key => $val) { + $vars[$key] = $val; + } + + /* Replacement mapping */ + /* + * The __VAR__ ones are for backward compatibility, because user + * might still have it in cookies. + */ + $replace = array( + '@HTTP_HOST@' => $vars['http_host'], + '@SERVER@' => $vars['server_name'], + '__SERVER__' => $vars['server_name'], + '@VERBOSE@' => $vars['server_verbose'], + '@VSERVER@' => $vars['server_verbose_or_name'], + '@DATABASE@' => $vars['database'], + '__DB__' => $vars['database'], + '@TABLE@' => $vars['table'], + '__TABLE__' => $vars['table'], + '@PHPMYADMIN@' => $vars['phpmyadmin_version'], + ); + + /* Optional escaping */ + if (!is_null($escape)) { + foreach($replace as $key => $val) { + $replace[$key] = $escape($val); + } + } + + /* 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 4b6bd96..7ec7c5d 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -1116,21 +1116,21 @@ $cfg['Export']['remember_file_template'] = true; * * @global string $cfg['Export']['file_template_table'] */ -$cfg['Export']['file_template_table'] = '__TABLE__'; +$cfg['Export']['file_template_table'] = '@TABLE@';
/** * * * @global string $cfg['Export']['file_template_database'] */ -$cfg['Export']['file_template_database'] = '__DB__'; +$cfg['Export']['file_template_database'] = '@DB@';
/** * * * @global string $cfg['Export']['file_template_server'] */ -$cfg['Export']['file_template_server'] = '__SERVER__'; +$cfg['Export']['file_template_server'] = '@SERVER@';
/** * @@ -1431,14 +1431,14 @@ $cfg['Export']['latex_data_continued_caption'] = 'strLatexContent strLatexContin * * @global string $cfg['Export']['latex_data_label'] */ -$cfg['Export']['latex_data_label'] = 'tab:__TABLE__-data'; +$cfg['Export']['latex_data_label'] = 'tab:@TABLE@-data';
/** * * * @global string $cfg['Export']['latex_structure_label'] */ -$cfg['Export']['latex_structure_label'] = 'tab:__TABLE__-structure'; +$cfg['Export']['latex_structure_label'] = 'tab:@TABLE@-structure';
/** * diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php index ae099e0..afa6435 100644 --- a/libraries/display_export.lib.php +++ b/libraries/display_export.lib.php @@ -147,13 +147,13 @@ echo PMA_pluginGetJavascript($export_list); echo __('File name template');
$trans = new PMA_Message; - $trans->addMessage('__SERVER__/'); + $trans->addMessage('@SERVER@/'); $trans->addString(__('server name')); if ($export_type == 'database' || $export_type == 'table') { - $trans->addMessage('__DB__/'); + $trans->addMessage('@DB@/'); $trans->addString(__('database name')); if ($export_type == 'table') { - $trans->addMessage('__TABLE__/'); + $trans->addMessage('@TABLE@/'); $trans->addString(__('table name')); } } @@ -193,6 +193,7 @@ echo PMA_pluginGetJavascript($export_list); ?> />
+ <?php echo PMA_showDocu('faq6_27'); ?> ( <input type="checkbox" name="remember_template" id="checkbox_remember_template" diff --git a/libraries/export/latex.php b/libraries/export/latex.php index ccf87e9..056b69f 100644 --- a/libraries/export/latex.php +++ b/libraries/export/latex.php @@ -9,6 +9,11 @@ if (! defined('PHPMYADMIN')) { exit; }
+/* Messages used in default captions */ +$GLOBALS['strLatexContent'] = __('Content of table @TABLE@'); +$GLOBALS['strLatexContinued'] = __('(continued)'); +$GLOBALS['strLatexStructure'] = __('Structure of table @TABLE@'); + /** * */ @@ -31,11 +36,11 @@ if (isset($plugin_list)) { $plugin_list['latex']['options'][] = array('type' => 'bgroup', 'name' => 'structure', 'text' => __('Structure'), 'force' => 'data'); $plugin_list['latex']['options'][] = - array('type' => 'text', 'name' => 'structure_caption', 'text' => __('Table caption')); + array('type' => 'text', 'name' => 'structure_caption', 'text' => __('Table caption'), 'doc' => 'faq6_27'); $plugin_list['latex']['options'][] = - array('type' => 'text', 'name' => 'structure_continued_caption', 'text' => __('Continued table caption')); + array('type' => 'text', 'name' => 'structure_continued_caption', 'text' => __('Continued table caption'), 'doc' => 'faq6_27'); $plugin_list['latex']['options'][] = - array('type' => 'text', 'name' => 'structure_label', 'text' => __('Label key')); + array('type' => 'text', 'name' => 'structure_label', 'text' => __('Label key'), 'doc' => 'faq6_27'); if (!empty($GLOBALS['cfgRelation']['relation'])) { $plugin_list['latex']['options'][] = array('type' => 'bool', 'name' => 'relation', 'text' => __('Relations')); @@ -55,11 +60,11 @@ if (isset($plugin_list)) { $plugin_list['latex']['options'][] = array('type' => 'bool', 'name' => 'columns', 'text' => __('Put columns names in the first row')); $plugin_list['latex']['options'][] = - array('type' => 'text', 'name' => 'data_caption', 'text' => __('Table caption')); + array('type' => 'text', 'name' => 'data_caption', 'text' => __('Table caption'), 'doc' => 'faq6_27'); $plugin_list['latex']['options'][] = - array('type' => 'text', 'name' => 'data_continued_caption', 'text' => __('Continued table caption')); + array('type' => 'text', 'name' => 'data_continued_caption', 'text' => __('Continued table caption'), 'doc' => 'faq6_27'); $plugin_list['latex']['options'][] = - array('type' => 'text', 'name' => 'data_label', 'text' => __('Label key')); + array('type' => 'text', 'name' => 'data_label', 'text' => __('Label key'), 'doc' => 'faq6_27'); $plugin_list['latex']['options'][] = array('type' => 'text', 'name' => 'null', 'text' => __('Replace NULL by')); $plugin_list['latex']['options'][] = @@ -76,12 +81,12 @@ if (isset($plugin_list)) { * @access private */ function PMA_texEscape($string) { - $escape = array('$', '%', '{', '}', '&', '#', '_', '^'); - $cnt_escape = count($escape); - for ($k=0; $k < $cnt_escape; $k++) { - $string = str_replace($escape[$k], '\' . $escape[$k], $string); - } - return $string; + $escape = array('$', '%', '{', '}', '&', '#', '_', '^'); + $cnt_escape = count($escape); + for ($k=0; $k < $cnt_escape; $k++) { + $string = str_replace($escape[$k], '\' . $escape[$k], $string); + } + return $string; }
/** @@ -207,8 +212,8 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$buffer .= ' \hline \endhead \hline \endfoot \hline ' . $crlf; if (isset($GLOBALS['latex_caption'])) { - $buffer .= ' \caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_data_caption']) - . '} \label{' . str_replace('__TABLE__', $table, $GLOBALS['latex_data_label']) . '} \\'; + $buffer .= ' \caption{' . PMA_expandUserString($GLOBALS['latex_data_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db)) + . '} \label{' . PMA_expandUserString($GLOBALS['latex_data_label'], NULL, array('table' => $table, 'database' => $db)) . '} \\'; } if (!PMA_exportOutputHandler($buffer)) { return FALSE; @@ -226,7 +231,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { return FALSE; } if (isset($GLOBALS['latex_caption'])) { - if (!PMA_exportOutputHandler('\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_data_continued_caption']) . '} \\ ')) return FALSE; + if (!PMA_exportOutputHandler('\caption{' . PMA_expandUserString($GLOBALS['latex_data_continued_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db)) . '} \\ ')) return FALSE; } if (!PMA_exportOutputHandler($buffer . '\endhead \endfoot' . $crlf)) { return FALSE; @@ -289,7 +294,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { * * @access public */ - // @@@ Table structure + // @@@ Table structure function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $dummy) { global $cfgRelation; @@ -373,14 +378,14 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
// Table caption for first page and label if (isset($GLOBALS['latex_caption'])) { - $buffer .= ' \caption{'. str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_structure_caption']) - . '} \label{' . str_replace('__TABLE__', $table, $GLOBALS['latex_structure_label']) + $buffer .= ' \caption{'. PMA_expandUserString($GLOBALS['latex_structure_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db)) + . '} \label{' . PMA_expandUserString($GLOBALS['latex_structure_label'], NULL, array('table' => $table, 'database' => $db)) . '} \\' . $crlf; } $buffer .= $header . ' \\ \hline \hline' . $crlf . '\endfirsthead' . $crlf; // Table caption on next pages if (isset($GLOBALS['latex_caption'])) { - $buffer .= ' \caption{'. str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_structure_continued_caption']) + $buffer .= ' \caption{'. PMA_expandUserString($GLOBALS['latex_structure_continued_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db)) . '} \\ ' . $crlf; } $buffer .= $header . ' \\ \hline \hline \endhead \endfoot ' . $crlf; @@ -425,8 +430,8 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$field_name = $row['Field'];
- $local_buffer = $field_name . "\000" . $type . "\000" - . (($row['Null'] == '' || $row['Null'] == 'NO') ? __('No') : __('Yes')) + $local_buffer = $field_name . "\000" . $type . "\000" + . (($row['Null'] == '' || $row['Null'] == 'NO') ? __('No') : __('Yes')) . "\000" . (isset($row['Default']) ? $row['Default'] : '');
if ($do_relation && $have_rel) { diff --git a/libraries/plugin_interface.lib.php b/libraries/plugin_interface.lib.php index da52b83..b2c441b 100644 --- a/libraries/plugin_interface.lib.php +++ b/libraries/plugin_interface.lib.php @@ -274,6 +274,8 @@ function PMA_pluginGetOneOption($section, $plugin_name, $id, &$opt) if (isset($opt['doc'])) { if (count($opt['doc']) == 3) { $ret .= PMA_showMySQLDocu($opt['doc'][0], $opt['doc'][1], false, $opt['doc'][2]); + } elseif (count($opt['doc']) == 1) { + $ret .= PMA_showDocu($opt['doc'][0]); } else { $ret .= PMA_showMySQLDocu($opt['doc'][0], $opt['doc'][1]); } diff --git a/libraries/select_lang.lib.php b/libraries/select_lang.lib.php index f750d81..ca8c7cc 100644 --- a/libraries/select_lang.lib.php +++ b/libraries/select_lang.lib.php @@ -480,10 +480,6 @@ $charset = 'utf-8'; /* l10n: Text direction, use either ltr or rtl */ $text_dir = __('ltr');
-$strLatexContent = __('Content of table __TABLE__'); -$strLatexContinued = __('(continued)'); -$strLatexStructure = __('Structure of table __TABLE__'); - // now, that we have loaded the language strings we can send the errors if ($GLOBALS['lang_failed_cfg']) { trigger_error(
hooks/post-receive