Merge branch 'master' of https://github.com/phpmyadmin/phpmyadmin into UT_plu_parse

This commit is contained in:
adamgsoc2013 2013-07-14 22:16:18 +08:00
commit 9092a26489
20 changed files with 593 additions and 142 deletions

View File

@ -24,6 +24,7 @@ phpMyAdmin - ChangeLog
+ rfe #175 Allow cross-database relations
- [core] Dropped support for PHP 5.2.
+ rfe #487 and rfe #1405 Find and Replacing column wise
+ rfe #1373 Use same create view dialog for editing a view
4.0.5.0 (not yet released)
- bug #3977 Not detected configuration storage

View File

@ -3675,7 +3675,7 @@ function printPage()
*/
AJAX.registerTeardown('functions.js', function () {
$('input#print').unbind('click');
$('span a.create_view.ajax').die('click');
$('a.create_view.ajax').die('click');
$('#createViewDialog').find('input, select').die('keydown');
});
@ -3684,7 +3684,7 @@ AJAX.registerOnload('functions.js', function () {
/**
* Ajaxification for the "Create View" action
*/
$('span a.create_view.ajax').live('click', function (e) {
$('a.create_view.ajax').live('click', function (e) {
e.preventDefault();
PMA_createViewDialog($(this));
});
@ -3698,13 +3698,29 @@ AJAX.registerOnload('functions.js', function () {
$(this).closest('.ui-dialog').find('.ui-button:first').click();
}
}); // end $.live()
var $elm = $('textarea[name="view[as]"]');
if ($elm.length > 0) {
if (typeof CodeMirror != 'undefined') {
syntaxHighlighter = CodeMirror.fromTextArea(
$elm[0],
{
lineNumbers: true,
matchBrackets: true,
indentUnit: 4,
mode: "text/x-mysql",
lineWrapping: true
}
);
}
}
});
function PMA_createViewDialog($this)
{
var $msg = PMA_ajaxShowMessage();
var syntaxHighlighter = null;
$.get($this.attr('href') + '&ajax_request=1', function (data) {
$.get($this.attr('href') + '&ajax_request=1&ajax_dialog=1', function (data) {
if (data.success === true) {
PMA_ajaxRemoveMessage($msg);
var buttonOptions = {};
@ -3728,21 +3744,19 @@ function PMA_createViewDialog($this)
$(this).dialog("close");
};
var $dialog = $('<div/>').attr('id', 'createViewDialog').append(data.message).dialog({
width: 500,
minWidth: 300,
maxWidth: 620,
width: 600,
minWidth: 400,
modal: true,
buttons: buttonOptions,
title: $('legend', $(data.message)).html(),
title: PMA_messages.strCreateView,
close: function () {
$(this).remove();
}
});
$dialog.find('legend').remove();
// Attach syntax highlited editor
if (typeof CodeMirror !== 'undefined') {
var $elm = $dialog.find('textarea');
var opts = {lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql"};
var opts = {lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql", lineWrapping: true};
syntaxHighlighter = CodeMirror.fromTextArea($elm[0], opts);
}
$('input:visible[type=text]', $dialog).first().focus();

View File

@ -376,6 +376,7 @@ $js_messages['strNewerVersion'] = __('A newer version of phpMyAdmin is available
$js_messages['strLatestAvailable'] = __(', latest stable version:');
$js_messages['strUpToDate'] = __('up to date');
$js_messages['strCreateView'] = __('Create view');
echo "var PMA_messages = new Array();\n";
foreach ($js_messages as $name => $js_message) {

View File

@ -1438,7 +1438,7 @@ class PMA_DatabaseInterface
/**
* Function called just after a connection to the MySQL database server has
* been established. It sets the connection collation, and determins the
* been established. It sets the connection collation, and determines the
* version of MySQL which is running.
*
* @param mixed $link mysql link resource|object

View File

@ -192,11 +192,11 @@ class PMA_TableSearch
}
/**
* Returns an array with necessary configrations to create
* sub-tabs(Table Search and Zoom Search) in the table_select page.
* Returns an array with necessary configurations to create
* sub-tabs in the table_select page.
*
* @return array Array containing configuration (icon, text, link, id, args)
* of sub-tabs for Table Search and Zoom search
* of sub-tabs
*/
private function _getSubTabs()
{

View File

@ -301,6 +301,61 @@ $GLOBALS['dummy_queries'] = array(
" AND table_name = 'pma_test_table2'" .
" ORDER BY version DESC",
'result' => array()
),
array(
'query' => "SHOW SLAVE STATUS",
'result' => array(
array(
'Slave_IO_State' => 'running',
'Master_Host' => 'locahost',
'Master_User' => 'Master_User',
'Master_Port' => '1002',
'Connect_Retry' => 'Connect_Retry',
'Master_Log_File' => 'Master_Log_File',
'Read_Master_Log_Pos' => 'Read_Master_Log_Pos',
'Relay_Log_File' => 'Relay_Log_File',
'Relay_Log_Pos' => 'Relay_Log_Pos',
'Relay_Master_Log_File' => 'Relay_Master_Log_File',
'Slave_IO_Running' => 'NO',
'Slave_SQL_Running' => 'NO',
'Replicate_Do_DB' => 'Replicate_Do_DB',
'Replicate_Ignore_DB' => 'Replicate_Ignore_DB',
'Replicate_Do_Table' => 'Replicate_Do_Table',
'Replicate_Ignore_Table' => 'Replicate_Ignore_Table',
'Replicate_Wild_Do_Table' => 'Replicate_Wild_Do_Table',
'Replicate_Wild_Ignore_Table' => 'Replicate_Wild_Ignore_Table',
'Last_Errno' => 'Last_Errno',
'Last_Error' => 'Last_Error',
'Skip_Counter' => 'Skip_Counter',
'Exec_Master_Log_Pos' => 'Exec_Master_Log_Pos',
'Relay_Log_Space' => 'Relay_Log_Space',
'Until_Condition' => 'Until_Condition',
'Until_Log_File' => 'Until_Log_File',
'Until_Log_Pos' => 'Until_Log_Pos',
'Master_SSL_Allowed' => 'Master_SSL_Allowed',
'Master_SSL_CA_File' => 'Master_SSL_CA_File',
'Master_SSL_CA_Path' => 'Master_SSL_CA_Path',
'Master_SSL_Cert' => 'Master_SSL_Cert',
'Master_SSL_Cipher' => 'Master_SSL_Cipher',
'Master_SSL_Key' => 'Master_SSL_Key',
'Seconds_Behind_Master' => 'Seconds_Behind_Master',
)
)
),
array(
'query' => "SHOW MASTER STATUS",
'result' => array(
array(
"File" => "master-bin.000030",
"Position" => "107",
"Binlog_Do_DB" => "Binlog_Do_DB",
"Binlog_Ignore_DB" => "Binlog_Ignore_DB",
)
)
),
array(
'query' => "SHOW GRANTS",
'result' => array()
)
);
/**

View File

@ -396,6 +396,7 @@ $PMA_SQPdata_reserved_word = array (
'BINLOG',
'BOTH',
'BY',
'CALL',
'CASCADE',
'CASE',
'CHANGE',

View File

@ -1445,18 +1445,34 @@ function PMA_getHtmlDivForMoveColumnsDialog()
*/
function PMA_getHtmlForEditView($url_params)
{
$create_view = $GLOBALS['dbi']->getDefinition(
$GLOBALS['db'], 'VIEW', $GLOBALS['table']
$retval = array();
$query = "SELECT `VIEW_DEFINITION`, `CHECK_OPTION`, `DEFINER`, `SECURITY_TYPE`"
. " FROM `INFORMATION_SCHEMA`.`VIEWS`"
. " WHERE TABLE_SCHEMA='" . PMA_Util::sqlAddSlashes($GLOBALS['db']) . "'"
. " AND TABLE_NAME='" . PMA_Util::sqlAddSlashes($GLOBALS['table']) . "';";
$item = $GLOBALS['dbi']->fetchSingleRow($query);
$view = array(
'operation' => 'alter',
'definer' => $item['DEFINER'],
'sql_security' => $item['SECURITY_TYPE'],
'name' => $GLOBALS['table'],
'as' => $item['VIEW_DEFINITION'],
'with' => $item['CHECK_OPTION'],
);
$url = 'view_create.php' . PMA_generate_common_url($url_params) . '&amp;';
$url .= implode(
'&amp;',
array_map(
function($key, $val) {
return 'view[' . urlencode($key) . ']=' . urlencode($val);
},
array_keys($view),
$view
)
);
$create_view = preg_replace('@^CREATE@', 'ALTER', $create_view);
$html_output = PMA_Util::linkOrButton(
'tbl_sql.php' . PMA_generate_common_url(
$url_params +
array(
'sql_query' => $create_view,
'show_query' => '1',
)
),
$url,
PMA_Util::getIcon('b_edit.png', __('Edit view'), true)
);
return $html_output;

View File

@ -4,10 +4,10 @@ msgstr ""
"Project-Id-Version: phpMyAdmin 4.1-dev\n"
"Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n"
"POT-Creation-Date: 2013-07-12 16:06+0200\n"
"PO-Revision-Date: 2013-07-09 15:28+0200\n"
"PO-Revision-Date: 2013-07-12 21:25+0200\n"
"Last-Translator: Matías Bellone <matiasbellone+weblate@gmail.com>\n"
"Language-Team: Spanish <http://l10n.cihar.com/projects/phpmyadmin/master/es/"
">\n"
"Language-Team: Spanish "
"<http://l10n.cihar.com/projects/phpmyadmin/master/es/>\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -1679,7 +1679,7 @@ msgstr "Agregar %d valor(es)"
msgid ""
"Note: If the file contains multiple tables, they will be combined into one."
msgstr ""
"Nota: si la fila contiene múltiples tablas, van a ser combinadas en una"
"Nota: si la fila contiene múltiples tablas, van a ser combinadas en una."
#: js/messages.php:262
msgid "Hide query box"
@ -2862,7 +2862,7 @@ msgstr "La clave primaria ha sido eliminada"
#: libraries/Index.class.php:608
#, php-format
msgid "Index %s has been dropped."
msgstr "El índice %s ha sido eliminado"
msgstr "El índice %s ha sido eliminado."
#: libraries/Index.class.php:731
#, php-format
@ -3848,7 +3848,7 @@ msgstr ""
#: libraries/sql_query_form.lib.php:483
msgid "The directory you set for upload work cannot be reached."
msgstr ""
"No se puede acceder al directorio que seleccionó para subir los archivos"
"No se puede acceder al directorio que seleccionó para subir los archivos."
#: libraries/Util.class.php:3452
msgid "There are no files to upload"
@ -8054,7 +8054,8 @@ msgstr ""
#, php-format
msgid "No activity within %s seconds; please log in again."
msgstr ""
"No ha habido actividad desde hace %s o más segundos; inicie sesión nuevamente"
"No ha habido actividad desde hace %s o más segundos; inicie sesión "
"nuevamente."
#: libraries/plugins/auth/AuthenticationCookie.class.php:667
#: libraries/plugins/auth/AuthenticationCookie.class.php:669
@ -8079,7 +8080,7 @@ msgstr "El archivo %s no contiene ningún id de clave"
#: libraries/plugins/auth/swekey/swekey.auth.lib.php:176
#: libraries/plugins/auth/swekey/swekey.auth.lib.php:196
msgid "Hardware authentication failed!"
msgstr "La autenticación de hardware fracasó"
msgstr "¡Fracasó la autenticación de hardware!"
#: libraries/plugins/auth/swekey/swekey.auth.lib.php:183
msgid "No valid authentication key plugged"
@ -11316,7 +11317,7 @@ msgid ""
msgstr ""
"Parece haber un error en su consulta de SQL. La salida generada por el "
"servidor de MySQL, de existir, aparece abajo, en cuyo caso puede ayudar a "
"diagnosticar el problema"
"diagnosticar el problema."
#: libraries/sqlparser.lib.php:178
msgid ""

View File

@ -4,10 +4,9 @@ msgstr ""
"Project-Id-Version: phpMyAdmin-docs 4.0.0-dev\n"
"Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n"
"POT-Creation-Date: 2013-07-12 16:06+0200\n"
"PO-Revision-Date: 2013-07-12 15:29+0200\n"
"PO-Revision-Date: 2013-07-14 01:43+0200\n"
"Last-Translator: Marc Delisle <marc@infomarc.info>\n"
"Language-Team: French <http://l10n.cihar.com/projects/phpmyadmin/master/fr/"
">\n"
"Language-Team: French <http://l10n.cihar.com/projects/phpmyadmin/master/fr/>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -1668,7 +1667,7 @@ msgstr "Ajouter %d valeur(s)"
#: js/messages.php:259
msgid ""
"Note: If the file contains multiple tables, they will be combined into one."
msgstr "Note : si le fichier contient plusieurs tables, elles seront combinées"
msgstr "Note : si le fichier contient plusieurs tables, elles seront combinées."
#: js/messages.php:262
msgid "Hide query box"
@ -2848,7 +2847,7 @@ msgstr "La clé primaire a été effacée"
#: libraries/Index.class.php:608
#, php-format
msgid "Index %s has been dropped."
msgstr "L'index %s a été effacé"
msgstr "L'index %s a été effacé."
#: libraries/Index.class.php:731
#, php-format
@ -3829,7 +3828,7 @@ msgstr ""
#: libraries/Util.class.php:3441 libraries/insert_edit.lib.php:1183
#: libraries/sql_query_form.lib.php:483
msgid "The directory you set for upload work cannot be reached."
msgstr "Le répertoire de transfert est inaccessible"
msgstr "Le répertoire de transfert est inaccessible."
#: libraries/Util.class.php:3452
msgid "There are no files to upload"
@ -8015,7 +8014,7 @@ msgstr "Le fichier %s ne contient pas d'identifiant de clé"
#: libraries/plugins/auth/swekey/swekey.auth.lib.php:176
#: libraries/plugins/auth/swekey/swekey.auth.lib.php:196
msgid "Hardware authentication failed!"
msgstr "L'authentification matérielle a échoué"
msgstr "L'authentification matérielle a échoué !"
#: libraries/plugins/auth/swekey/swekey.auth.lib.php:183
msgid "No valid authentication key plugged"

View File

@ -4,10 +4,10 @@ msgstr ""
"Project-Id-Version: phpMyAdmin 4.1-dev\n"
"Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n"
"POT-Creation-Date: 2013-07-12 16:06+0200\n"
"PO-Revision-Date: 2013-07-09 12:21+0200\n"
"PO-Revision-Date: 2013-07-14 12:36+0200\n"
"Last-Translator: Burak Yavuz <hitowerdigit@hotmail.com>\n"
"Language-Team: Turkish <http://l10n.cihar.com/projects/phpmyadmin/master/tr/"
">\n"
"Language-Team: Turkish "
"<http://l10n.cihar.com/projects/phpmyadmin/master/tr/>\n"
"Language: tr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -1663,7 +1663,7 @@ msgid ""
"Note: If the file contains multiple tables, they will be combined into one."
msgstr ""
"Not: Eğer dosya çoklu tablolar içeriyorsa, bunlar bir tane içinde "
"birleştirilecektir"
"birleştirilecektir."
#: js/messages.php:262
msgid "Hide query box"
@ -2832,7 +2832,7 @@ msgstr "Birincil anahtar kaldırıldı"
#: libraries/Index.class.php:608
#, php-format
msgid "Index %s has been dropped."
msgstr "%s indeksi kaldırıldı"
msgstr "%s indeksi kaldırıldı."
#: libraries/Index.class.php:731
#, php-format
@ -3797,7 +3797,7 @@ msgstr "Web sunucusu gönderme dizininden <b>%s</b> seçin:"
#: libraries/Util.class.php:3441 libraries/insert_edit.lib.php:1183
#: libraries/sql_query_form.lib.php:483
msgid "The directory you set for upload work cannot be reached."
msgstr "Gönderme işi için ayarladığınız dizine ulaşılamıyor"
msgstr "Gönderme işi için ayarladığınız dizine ulaşılamıyor."
#: libraries/Util.class.php:3452
msgid "There are no files to upload"
@ -3932,7 +3932,7 @@ msgstr "%s %s veya sonrasına yükseltmelisiniz."
#: libraries/common.inc.php:1075
msgid "Error: Token mismatch"
msgstr "Hata: Belirti uyuşmazlığı"
msgstr "Hata: Belirt uyuşmazlığı"
#: libraries/common.inc.php:1119
msgid "GLOBALS overwrite attempt"
@ -7954,7 +7954,7 @@ msgstr ""
#: libraries/plugins/auth/AuthenticationSignon.class.php:254
#, php-format
msgid "No activity within %s seconds; please log in again."
msgstr "%s saniye içinde hiçbir işlem yapılmadı, lütfen yeniden oturum açın"
msgstr "%s saniye içinde hiçbir işlem yapılmadı; lütfen tekrar oturum açın."
#: libraries/plugins/auth/AuthenticationCookie.class.php:667
#: libraries/plugins/auth/AuthenticationCookie.class.php:669
@ -7978,7 +7978,7 @@ msgstr "%s dosyası herhangi bir anahtar kimliği içermiyor"
#: libraries/plugins/auth/swekey/swekey.auth.lib.php:176
#: libraries/plugins/auth/swekey/swekey.auth.lib.php:196
msgid "Hardware authentication failed!"
msgstr "Donanım kimlik doğrulaması başarısız"
msgstr "Donanım kimlik doğrulaması başarısız oldu!"
#: libraries/plugins/auth/swekey/swekey.auth.lib.php:183
msgid "No valid authentication key plugged"
@ -11148,7 +11148,8 @@ msgid ""
"below, if there is any, may also help you in diagnosing the problem."
msgstr ""
"SQL sorgunuzda bir hata olduğu görünüyor. MySQL sunucusu hata çıktısı "
"aşağıdadır, eğer varsa, sorunu teşhis etmenizde ayrıca size yardımcı olabilir"
"aşağıdadır, eğer varsa, sorunu teşhis etmenizde ayrıca size yardımcı "
"olabilir."
#: libraries/sqlparser.lib.php:178
msgid ""

View File

@ -4,10 +4,10 @@ msgstr ""
"Project-Id-Version: phpMyAdmin 4.1-dev\n"
"Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n"
"POT-Creation-Date: 2013-07-12 16:06+0200\n"
"PO-Revision-Date: 2013-07-05 16:35+0200\n"
"PO-Revision-Date: 2013-07-13 20:32+0200\n"
"Last-Translator: Tony Chen <tonychen@finenet.com.tw>\n"
"Language-Team: Traditional Chinese <http://l10n.cihar.com/projects/"
"phpmyadmin/master/zh_TW/>\n"
"Language-Team: Traditional Chinese "
"<http://l10n.cihar.com/projects/phpmyadmin/master/zh_TW/>\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -1680,10 +1680,9 @@ msgid "Show search criteria"
msgstr "顯示搜尋條件"
#: js/messages.php:278
#, fuzzy
#| msgid "Hide search criteria"
msgid "Hide find and replace criteria"
msgstr "隱藏搜尋條件"
msgstr "隱藏搜尋和替換條件"
#: js/messages.php:279
msgid "Show find and replace criteria"
@ -2774,7 +2773,7 @@ msgstr "已刪除主鍵"
#: libraries/Index.class.php:608
#, php-format
msgid "Index %s has been dropped."
msgstr "已刪除索引 %s"
msgstr "已刪除索引 %s"
#: libraries/Index.class.php:731
#, php-format
@ -3161,7 +3160,7 @@ msgstr "資料表搜尋"
#: libraries/TableSearch.class.php:217 libraries/TableSearch.class.php:1172
msgid "Find and Replace"
msgstr ""
msgstr "搜尋和替換"
#: libraries/TableSearch.class.php:239 libraries/insert_edit.lib.php:1352
msgid "Edit/Insert"
@ -3226,20 +3225,18 @@ msgid "Reset zoom"
msgstr "重設縮放大小"
#: libraries/TableSearch.class.php:1281
#, fuzzy
#| msgid "Replace with"
msgid "Replace with:"
msgstr "替換爲"
msgstr "替換爲"
#: libraries/TableSearch.class.php:1341
msgid "Find and replace - preview"
msgstr "尋找和替換-預覽"
#: libraries/TableSearch.class.php:1345
#, fuzzy
#| msgid "Column"
msgid "Count"
msgstr "欄位"
msgstr "次數"
#: libraries/TableSearch.class.php:1346
msgid "Original string"
@ -3722,7 +3719,7 @@ msgstr "選擇 Web 伺服器上傳目錄 <b>%s</b>"
#: libraries/Util.class.php:3441 libraries/insert_edit.lib.php:1183
#: libraries/sql_query_form.lib.php:483
msgid "The directory you set for upload work cannot be reached."
msgstr "設定之上傳目錄錯誤,無法使用"
msgstr "設定之上傳目錄錯誤,無法使用"
#: libraries/Util.class.php:3452
msgid "There are no files to upload"
@ -7666,7 +7663,7 @@ msgstr "空密碼登錄被禁止 (參見 允許空密碼)"
#: libraries/plugins/auth/AuthenticationSignon.class.php:254
#, php-format
msgid "No activity within %s seconds; please log in again."
msgstr "登錄超時 (%s 秒未操作),請重新登錄"
msgstr "登錄超時 (%s 秒未操作),請重新登錄"
#: libraries/plugins/auth/AuthenticationCookie.class.php:667
#: libraries/plugins/auth/AuthenticationCookie.class.php:669
@ -7690,7 +7687,7 @@ msgstr "檔案 %s 未包含任何密鑰"
#: libraries/plugins/auth/swekey/swekey.auth.lib.php:176
#: libraries/plugins/auth/swekey/swekey.auth.lib.php:196
msgid "Hardware authentication failed!"
msgstr "硬件認證失敗"
msgstr "硬體身份驗證失敗!"
#: libraries/plugins/auth/swekey/swekey.auth.lib.php:183
msgid "No valid authentication key plugged"
@ -9180,7 +9177,7 @@ msgstr "顯示資料表格大小"
#: libraries/schema/User_Schema.class.php:461
msgid "Same width for all tables"
msgstr ""
msgstr "所有資料表使用相同的寬度"
#: libraries/schema/User_Schema.class.php:464 libraries/structure.lib.php:379
msgid "Data Dictionary"
@ -10710,9 +10707,7 @@ msgstr "僅查看"
msgid ""
"There seems to be an error in your SQL query. The MySQL server error output "
"below, if there is any, may also help you in diagnosing the problem."
msgstr ""
"您的 SQL 查詢可能有錯。如果可能的話,以下會列出 MySQL 伺服器的錯誤輸出,這可"
"能對您解決問題有一定的幫助"
msgstr "您的 SQL 查詢可能有錯。如果可能的話,以下會列出 MySQL 伺服器的錯誤輸出,這可能對您解決問題有一定的幫助。"
#: libraries/sqlparser.lib.php:178
msgid ""

View File

@ -18,6 +18,7 @@ require_once 'libraries/Util.class.php';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/Table.class.php';
require_once 'libraries/Tracker.class.php';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/import.lib.php';
require_once 'libraries/sanitizing.lib.php';

View File

@ -19,6 +19,7 @@ require_once 'libraries/Util.class.php';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/Table.class.php';
require_once 'libraries/Tracker.class.php';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/import.lib.php';
/* Each PluginObserver instance contains a PluginManager instance */

View File

@ -17,6 +17,7 @@ require_once 'libraries/Util.class.php';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/Table.class.php';
require_once 'libraries/Tracker.class.php';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/import.lib.php';

View File

@ -18,6 +18,7 @@ require_once 'libraries/Util.class.php';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/Table.class.php';
require_once 'libraries/Tracker.class.php';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/import.lib.php';
require_once 'libraries/sanitizing.lib.php';

View File

@ -18,6 +18,7 @@ require_once 'libraries/Util.class.php';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/Table.class.php';
require_once 'libraries/Tracker.class.php';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/import.lib.php';

View File

@ -18,6 +18,7 @@ require_once 'libraries/Util.class.php';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/Table.class.php';
require_once 'libraries/Tracker.class.php';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/import.lib.php';
/* Each PluginObserver instance contains a PluginManager instance */

View File

@ -0,0 +1,310 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* tests for replication_gui.lib.php
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
require_once 'libraries/Util.class.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/Tracker.class.php';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/replication.inc.php';
require_once 'libraries/replication_gui.lib.php';
require_once 'libraries/Theme.class.php';
require_once 'libraries/Message.class.php';
require_once 'libraries/sanitizing.lib.php';
require_once 'libraries/sqlparser.lib.php';
require_once 'libraries/js_escape.lib.php';
/**
* PMA_Serverreplication_Test class
*
* this class is for testing replication_gui.lib.php functions
*
* @package PhpMyAdmin-test
*/
class PMA_ServerReplication_Test extends PHPUnit_Framework_TestCase
{
/**
* Prepares environment for the test.
*
* @return void
*/
public function setUp()
{
//$_REQUEST
$_REQUEST['log'] = "index1";
$_REQUEST['pos'] = 3;
$_REQUEST['mr_adduser'] = "mr_adduser";
//$GLOBALS
$GLOBALS['cfg']['MaxRows'] = 10;
$GLOBALS['cfg']['ServerDefault'] = "server";
$GLOBALS['cfg']['RememberSorting'] = true;
$GLOBALS['cfg']['SQP'] = array();
$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000;
$GLOBALS['cfg']['ShowSQL'] = true;
$GLOBALS['cfg']['SQP']['fmtType'] = 'none';
$GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons';
$GLOBALS['cfg']['LimitChars'] = 100;
$GLOBALS['cfg']['DBG']['sql'] = false;
$GLOBALS['cfg']['ShowHint'] = true;
$GLOBALS['table'] = "table";
$GLOBALS['url_params'] = array();
$GLOBALS['pmaThemeImage'] = 'image';
//$_SESSION
$_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme');
$_SESSION['PMA_Theme'] = new PMA_Theme();
//Mock DBI
$slave_host = array(
array('Server_id'=>'Server_id1', 'Host'=>'Host1'),
array('Server_id'=>'Server_id2', 'Host'=>'Host2'),
);
$fetchResult = array(
array(
"SHOW SLAVE HOSTS",
null,
null,
null,
0,
$slave_host
),
);
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
->disableOriginalConstructor()
->getMock();
$dbi->expects($this->any())->method('fetchResult')
->will($this->returnValueMap($fetchResult));
$fields_info = array(
"Host" => array(
"Field" => "host",
"Type" => "char(60)",
"Null" => "NO",
)
);
$dbi->expects($this->any())->method('getColumns')
->will($this->returnValue($fields_info));
$GLOBALS['dbi'] = $dbi;
}
/**
* Test for PMA_getHtmlForMasterReplication
*
* @return void
*/
public function testPMAGetHtmlForMasterReplication()
{
global $master_variables;
global $master_variables_alerts;
global $master_variables_oks;
global $server_master_replication;
global $strReplicationStatus_master;
$master_variables_alerts = null;
$master_variables_oks = null;
$strReplicationStatus_master = null;
//Call the test function
$html = PMA_getHtmlForMasterReplication();
//validate 1: Master replication
$this->assertContains(
'<legend>Master replication</legend>',
$html
);
$this->assertContains(
'This server is configured as master in a replication process.',
$html
);
//validate 2: PMA_getHtmlForReplicationStatusTable
$this->assertContains(
'<div id="replication_master_section"',
$html
);
//$master_variables
$this->assertContains(
"Binlog_Do_DB",
$html
);
$this->assertContains(
"Binlog_Ignore_DB",
$html
);
//$server_master_replication
$this->assertContains(
"master-bin.000030",
$html
);
//validate 3: PMA_getHtmlForReplicationSlavesTable
$this->assertContains(
'replication_slaves_section',
$html
);
$this->assertContains(
'<th>Server ID</th>',
$html
);
$this->assertContains(
'<th>Host</th>',
$html
);
//slave host
$this->assertContains(
'<td class="value">Server_id1</td>',
$html
);
$this->assertContains(
'<td class="value">Server_id2</td>',
$html
);
$this->assertContains(
'<td class="value">Host1</td>',
$html
);
$this->assertContains(
'<td class="value">Host2</td>',
$html
);
//Notice
$this->assertContains(
'Only slaves started with the',
$html
);
//validate 4: navigation URL
$this->assertContains(
'<a href="server_replication.php',
$html
);
$this->assertContains(
'Add slave replication user',
$html
);
//validate 5: 'Add replication slave user' form
$this->assertContains(
'<div id="master_addslaveuser_gui">',
$html
);
}
/**
* Test for PMA_getHtmlForNotServerReplication
*
* @return void
*/
public function testPMAGetHtmlForNotServerReplication()
{
//Call the test function
$html = PMA_getHtmlForNotServerReplication();
$this->assertContains(
'<legend>Master replication</legend>',
$html
);
$this->assertContains(
'This server is not configured as master in a replication process.',
$html
);
}
/**
* Test for PMA_getHtmlForSlaveConfiguration
*
* @return void
*/
public function testPMAGetHtmlForSlaveConfiguration()
{
global $server_slave_replication;
//Call the test function
$html = PMA_getHtmlForSlaveConfiguration(
true,
$server_slave_replication
);
//legend
$this->assertContains(
'<legend>Slave replication</legend>',
$html
);
$this->assertContains(
'<div id="slave_configuration_gui">',
$html
);
//notice
$this->assertContains(
'Server is configured as slave in a replication process.',
$html
);
//slave session
$this->assertContains(
'<div id="replication_slave_section"',
$html
);
//variable
$this->assertContains(
'Master_SSL_CA_Path',
$html
);
$this->assertContains(
'Master_SSL_Cert',
$html
);
$this->assertContains(
'Master_SSL_Cipher',
$html
);
$this->assertContains(
'Seconds_Behind_Master',
$html
);
}
/**
* Test for PMA_getHtmlForReplicationChangeMaster
*
* @return void
*/
public function testPMAGetHtmlForReplicationChangeMaster()
{
//Call the test function
$html = PMA_getHtmlForReplicationChangeMaster("slave_changemaster");
$this->assertContains(
'<form method="post" action="server_replication.php">',
$html
);
$this->assertContains(
'Slave configuration',
$html
);
$this->assertContains(
'Change or reconfigure master server',
$html
);
$notice = 'Make sure, you have unique server-id '
. 'in your configuration file (my.cnf)';
$this->assertContains(
$notice,
$html
);
}
}

View File

@ -17,7 +17,7 @@ require_once './libraries/common.inc.php';
* Runs common work
*/
require './libraries/db_common.inc.php';
$url_params['goto'] = $cfg['DefaultTabDatabase'];
$url_params['goto'] = 'tbl_structure.php';
$url_params['back'] = 'view_create.php';
$view_algorithm_options = array(
@ -27,26 +27,45 @@ $view_algorithm_options = array(
);
$view_with_options = array(
'CASCADED CHECK OPTION',
'LOCAL CHECK OPTION'
'CASCADED',
'LOCAL'
);
if (isset($_REQUEST['createview'])) {
$view_sql_security_options = array(
'DEFINER',
'INVOKER'
);
if (isset($_REQUEST['createview']) || isset($_REQUEST['alterview'])) {
/**
* Creates the view
*/
$sep = "\r\n";
$sql_query = 'CREATE';
if (isset($_REQUEST['view']['or_replace'])) {
$sql_query .= ' OR REPLACE';
if (isset($_REQUEST['createview'])) {
$sql_query = 'CREATE';
if (isset($_REQUEST['view']['or_replace'])) {
$sql_query .= ' OR REPLACE';
}
} else {
$sql_query = 'ALTER';
}
if (PMA_isValid($_REQUEST['view']['algorithm'], $view_algorithm_options)) {
$sql_query .= $sep . ' ALGORITHM = ' . $_REQUEST['view']['algorithm'];
}
if (! empty($_REQUEST['view']['definer'])) {
$sql_query .= $sep . ' DEFINER = ' . $_REQUEST['view']['definer'];
}
if (isset($_REQUEST['view']['sql_security'])) {
if (in_array($_REQUEST['view']['sql_security'], $view_sql_security_options)) {
$sql_query .= $sep . ' SQL SECURITY '
. $_REQUEST['view']['sql_security'];
}
}
$sql_query .= $sep . ' VIEW ' . PMA_Util::backquote($_REQUEST['view']['name']);
if (! empty($_REQUEST['view']['column_names'])) {
@ -56,44 +75,44 @@ if (isset($_REQUEST['createview'])) {
$sql_query .= $sep . ' AS ' . $_REQUEST['view']['as'];
if (isset($_REQUEST['view']['with'])) {
$options = array_intersect($_REQUEST['view']['with'], $view_with_options);
if (count($options)) {
$sql_query .= $sep . ' WITH ' . implode(' ', $options);
if (in_array($_REQUEST['view']['with'], $view_with_options)) {
$sql_query .= $sep . ' WITH ' . $_REQUEST['view']['with']
. ' CHECK OPTION';
}
}
if ($GLOBALS['dbi']->tryQuery($sql_query)) {
include_once './libraries/tbl_views.lib.php';
// If different column names defined for VIEW
$view_columns = array();
if (isset($_REQUEST['view']['column_names'])) {
$view_columns = explode(',', $_REQUEST['view']['column_names']);
}
$column_map = PMA_getColumnMap($_REQUEST['view']['as'], $view_columns);
$pma_tranformation_data = PMA_getExistingTranformationData($GLOBALS['db']);
if ($pma_tranformation_data !== false) {
// SQL for store new transformation details of VIEW
$new_transformations_sql = PMA_getNewTransformationDataSql(
$pma_tranformation_data, $column_map, $_REQUEST['view']['name'],
$GLOBALS['db']
);
);
// Store new transformations
if ($new_transformations_sql != '') {
$GLOBALS['dbi']->tryQuery($new_transformations_sql);
}
}
unset($pma_tranformation_data);
if ($GLOBALS['is_ajax_request'] != true) {
if (! isset($_REQUEST['ajax_dialog'])) {
$message = PMA_Message::success();
include './' . $cfg['DefaultTabDatabase'];
include 'tbl_structure.php';
} else {
$response = PMA_Response::getInstance();
$response->addJSON(
@ -102,12 +121,13 @@ if (isset($_REQUEST['createview'])) {
PMA_Message::success(), $sql_query
)
);
$response->isSuccess(true);
}
exit;
} else {
if ($GLOBALS['is_ajax_request'] != true) {
if (! isset($_REQUEST['ajax_dialog'])) {
$message = PMA_Message::rawError($GLOBALS['dbi']->getError());
} else {
$response = PMA_Response::getInstance();
@ -126,12 +146,15 @@ if (isset($_REQUEST['createview'])) {
// prefill values if not already filled from former submission
$view = array(
'operation' => 'create',
'or_replace' => '',
'algorithm' => '',
'definer' => '',
'sql_security' => '',
'name' => '',
'column_names' => '',
'as' => $sql_query,
'with' => array(),
'with' => '',
);
if (PMA_isValid($_REQUEST['view'], 'array')) {
@ -149,21 +172,27 @@ $htmlString = '<!-- CREATE VIEW options -->'
. '<form method="post" action="view_create.php">'
. PMA_generate_common_hidden_inputs($url_params)
. '<fieldset>'
. '<legend>' . __('Create view')
. PMA_Util::showMySQLDocu('SQL-Syntax', 'CREATE_VIEW') . '</legend>'
. '<table class="rte_table">'
. '<tr><td><label for="or_replace">OR REPLACE</label></td>'
. '<td><input type="checkbox" name="view[or_replace]" id="or_replace"';
if ($view['or_replace']) {
$htmlString .= ' checked="checked"';
}
$htmlString .= ' value="1" />'
. '</td>'
. '</tr>'
. '<tr>'
. '<td><label for="algorithm">ALGORITHM</label></td>'
. '<td><select name="view[algorithm]" id="algorithm">';
. '<legend>'
. (isset($_REQUEST['ajax_dialog']) ?
__('Details') :
($view['operation'] == 'create' ? __('Create view') : __('Edit view'))
)
. '</legend>'
. '<table class="rte_table">';
if ($view['operation'] == 'create') {
$htmlString .= '<tr>'
. '<td class="nowrap"><label for="or_replace">OR REPLACE</label></td>'
. '<td><input type="checkbox" name="view[or_replace]" id="or_replace"';
if ($view['or_replace']) {
$htmlString .= ' checked="checked"';
}
$htmlString .= ' value="1" /></td></tr>';
}
$htmlString .= '<tr>'
. '<td class="nowrap"><label for="algorithm">ALGORITHM</label></td>'
. '<td><select name="view[algorithm]" id="algorithm">';
foreach ($view_algorithm_options as $option) {
$htmlString .= '<option value="' . htmlspecialchars($option) . '"';
if ($view['algorithm'] === $option) {
@ -171,61 +200,83 @@ foreach ($view_algorithm_options as $option) {
}
$htmlString .= '>' . htmlspecialchars($option) . '</option>';
}
$htmlString .= '</select>'
. '</td>'
. '</tr>'
. '<tr><td>' . __('VIEW name') . '</td>'
. '<td><input type="text" size="20" name="view[name]" onfocus="this.select()"'
. ' value="' . htmlspecialchars($view['name']) . '" />'
. '</td>'
. '</tr>'
. '<tr><td>' . __('Column names') . '</td>'
. '</td></tr>';
$htmlString .= '<tr><td class="nowrap">' . __('Definer') . '</td>'
. '<td><input type="text" maxlength="100" size="50" name="view[definer]"'
. ' value="' . htmlspecialchars($view['definer']) . '" />'
. '</td></tr>';
$htmlString .= '<tr><td class="nowrap">SQL SECURITY</td>'
. '<td><select name="view[sql_security]">'
. '<option value=""></option>';
foreach ($view_sql_security_options as $option) {
$htmlString .= '<option value="' . htmlspecialchars($option) . '"';
if ($option == $view['sql_security']) {
$htmlString .= ' selected="selected"';
}
$htmlString .= '>' . htmlspecialchars($option) . '</option>';
}
$htmlString .= '<select>'
. '</td></tr>';
if ($view['operation'] == 'create') {
$htmlString .= '<tr><td class="nowrap">' . __('VIEW name') . '</td>'
. '<td><input type="text" size="20" name="view[name]"'
. ' onfocus="this.select()"'
. ' value="' . htmlspecialchars($view['name']) . '" />'
. '</td></tr>';
} else {
$htmlString .= '<tr><td><input type="hidden" name="view[name]"'
. ' value="' . htmlspecialchars($view['name']) . '" />'
. '</td></tr>';
}
$htmlString .= '<tr><td class="nowrap">' . __('Column names') . '</td>'
. '<td><input type="text" maxlength="100" size="50" name="view[column_names]"'
. ' onfocus="this.select()"'
. ' value="' . htmlspecialchars($view['column_names']) . '" />'
. '</td>'
. '</tr>'
. '<tr><td>AS</td>'
. '</td></tr>';
$htmlString .= '<tr><td class="nowrap">AS</td>'
. '<td>'
. '<textarea name="view[as]" rows="' . $cfg['TextareaRows'] . '"'
. ' cols="' . $cfg['TextareaCols'] . '"'
. ' dir="' . $text_dir . '"';
. ' cols="' . $cfg['TextareaCols'] . '" dir="' . $text_dir . '"';
if ($GLOBALS['cfg']['TextareaAutoSelect'] || true) {
$htmlString .= ' onclick="selectContent(this, sql_box_locked, true)"';
}
$htmlString .= '>' . htmlspecialchars($view['as']) . '</textarea>'
. '</td>'
. '</tr>'
. '<tr><td>WITH</td>'
. '<td>';
. '</td></tr>';
$htmlString .= '<tr><td class="nowrap">WITH CHECK OPTION</td>'
. '<td><select name="view[with]">'
. '<option value=""></option>';
foreach ($view_with_options as $option) {
$htmlString .= '<input type="checkbox" name="view[with][]"';
if (in_array($option, $view['with'])) {
$htmlString .= ' checked="checked"';
$htmlString .= '<option value="' . htmlspecialchars($option) . '"';
if ($option == $view['with']) {
$htmlString .= ' selected="selected"';
}
$htmlString .= ' id="view_with_'
. str_replace(' ', '_', htmlspecialchars($option)) . '"'
. ' value="' . htmlspecialchars($option) . '" />'
. '<label for="view_with_' . str_replace(' ', '_', htmlspecialchars($option))
. '">&nbsp;'
. htmlspecialchars($option) . '</label><br />';
$htmlString .= '>' . htmlspecialchars($option) . '</option>';
}
$htmlString .= '<select>'
. '</td></tr>';
$htmlString .= '</td>'
. '</tr>'
. '</table>'
$htmlString .= '</table>'
. '</fieldset>';
if ($GLOBALS['is_ajax_request'] != true) {
if (! isset($_REQUEST['ajax_dialog'])) {
$htmlString .= '<fieldset class="tblFooters">'
. '<input type="submit" name="createview" value="' . __('Go') . '" />'
. '<input type="hidden" name="'
. ($view['operation'] == 'create' ? 'createview' : 'alterview' )
. '" value="1" />'
. '<input type="submit" name="" value="' . __('Go') . '" />'
. '</fieldset>';
} else {
$htmlString .= '<input type="hidden" name="createview" value="1" />'
$htmlString .= '<input type="hidden" name="'
. ($view['operation'] == 'create' ? 'createview' : 'alterview' )
. '" value="1" />'
. '<input type="hidden" name="ajax_dialog" value="1" />'
. '<input type="hidden" name="ajax_request" value="1" />';
}