Merge branch 'master' of ssh://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin/phpmyadmin

This commit is contained in:
Crack
2010-08-28 12:12:52 +02:00
929 changed files with 5532 additions and 1993 deletions

0
CREDITS Normal file → Executable file
View File

1
ChangeLog Normal file → Executable file
View File

@@ -110,6 +110,7 @@ $Id$
- [relations] Dropped WYSIWYG-PDF configuration variable.
- rfe #806035, #686260 [relations] Export relations to Dia, SVG and others
+ [interface] Added charts to status tab, profiling page and query results
+ [interface] AJAXification on various pages
3.3.7.0 (not yet released)

5
Documentation.html Normal file → Executable file
View File

@@ -4853,6 +4853,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
<li>Simplified interface for export/import</li>
</ul></li>
<li>Ninad Pundalik (Google Summer of Code 2010)
<ul>
<li>AJAXifying the interface</li>
</ul></li>
<li>Barrie Leslie
<ul>
<li>BLOBstreaming support with PBMS PHP extension</li>

0
INSTALL Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

0
README Normal file → Executable file
View File

0
README.VENDOR Normal file → Executable file
View File

0
TODO Normal file → Executable file
View File

0
browse_foreigners.php Normal file → Executable file
View File

0
bs_disp_as_mime_type.php Normal file → Executable file
View File

0
bs_play_media.php Normal file → Executable file
View File

0
changelog.php Normal file → Executable file
View File

0
chk_rel.php Normal file → Executable file
View File

0
config.sample.inc.php Normal file → Executable file
View File

0
contrib/README Normal file → Executable file
View File

0
contrib/htaccess Normal file → Executable file
View File

0
contrib/packaging/Fedora/phpMyAdmin-http.conf Normal file → Executable file
View File

0
contrib/packaging/Fedora/phpMyAdmin.spec Normal file → Executable file
View File

0
contrib/swekey.sample.conf Normal file → Executable file
View File

81
db_create.php Normal file → Executable file
View File

@@ -9,6 +9,9 @@
* Gets some core libraries
*/
require_once './libraries/common.inc.php';
$GLOBALS['js_include'][] = 'functions.js';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
require_once './libraries/mysql_charsets.lib.php';
PMA_checkParameters(array('new_db'));
@@ -38,6 +41,14 @@ if (! $result) {
// avoid displaying the not-created db name in header or navi panel
$GLOBALS['db'] = '';
$GLOBALS['table'] = '';
/**
* If in an Ajax request, just display the message with {@link PMA_ajaxResponse}
*/
if($GLOBALS['is_ajax_request'] == true) {
PMA_ajaxResponse($message, FALSE);
}
require_once './libraries/header.inc.php';
require_once './main.php';
} else {
@@ -45,6 +56,76 @@ if (! $result) {
$message->addParam($new_db);
$GLOBALS['db'] = $new_db;
/**
* If in an Ajax request, build the output and send it
*/
if($GLOBALS['is_ajax_request'] == true) {
/**
* String containing the SQL Query formatted in pretty HTML
* @global array $GLOBALS['extra_data']
* @name $extra_data
*/
$extra_data['sql_query'] = PMA_showMessage(NULL, $sql_query, 'success');
//Construct the html for the new database, so that it can be appended to the list of databases on server_databases.php
/**
* Build the array to be passed to {@link PMA_generate_common_url} to generate the links
* @global array $GLOBALS['db_url_params']
* @name $db_url_params
*/
$db_url_params['db'] = $new_db;
$is_superuser = PMA_isSuperuser();
/**
* String that will contain the output HTML
* @name $new_db_string
*/
$new_db_string = '<tr>';
/**
* Is user allowed to drop the database?
*/
if ($is_superuser || $cfg['AllowUserDropDatabase']) {
$new_db_string .= '<td class="tool">';
$new_db_string .= '<input type="checkbox" title="'. $new_db .'" value="' . $new_db . '" name="selected_dbs[]" />';
$new_db_string .='</td>';
}
/**
* Link to the database's page
*/
$new_db_string .= '<td class="name">';
$new_db_string .= '<a target="_parent" title="Jump to database" href="index.php' . PMA_generate_common_url($db_url_params) . '">';
$new_db_string .= $new_db . '</a>';
$new_db_string .= '</td>';
/**
* If the user has privileges, let him check privileges for the DB
*/
if($is_superuser) {
$db_url_params['checkprivs'] = $new_db;
$new_db_string .= '<td class="tool">';
$new_db_string .= '<a title="Check privileges for database" href="server_privileges.php' . PMA_generate_common_url($db_url_params) . '">';
$new_db_string .= ($cfg['PropertiesIconic']
? '<img class="icon" src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" alt=" ' . __('Check Privileges') . '" /> '
: __('Check Privileges')) . '</a>';
$new_db_string .= '</td>';
}
$new_db_string .= '</tr>';
/** @todo Statistics for newly created DB! */
$extra_data['new_db_string'] = $new_db_string;
PMA_ajaxResponse($message, true, $extra_data);
}
require_once './libraries/header.inc.php';
require_once './' . $cfg['DefaultTabDatabase'];
}

0
db_datadict.php Normal file → Executable file
View File

0
db_export.php Normal file → Executable file
View File

0
db_import.php Normal file → Executable file
View File

26
db_operations.php Normal file → Executable file
View File

@@ -18,6 +18,14 @@
require_once './libraries/common.inc.php';
require_once './libraries/mysql_charsets.lib.php';
// add blobstreaming library functions
require_once "./libraries/blobstreaming.lib.php";
// add a javascript file for jQuery functions to handle Ajax actions
// also add jQueryUI
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
$GLOBALS['js_include'][] = 'db_operations.js';
/**
* Rename/move or copy database
*/
@@ -254,6 +262,16 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
$message = PMA_Message::error();
}
}
/**
* Database has been successfully renamed/moved. If in an Ajax request,
* generate the output with {@link PMA_ajaxResponse} and exit
*/
if( $GLOBALS['is_ajax_request'] == true) {
$extra_data['newname'] = $newname;
$extra_data['sql_query'] = PMA_showMessage(NULL, $sql_query);
PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
};
}
@@ -326,7 +344,7 @@ if (!$is_information_schema) {
* rename database
*/
?>
<form method="post" action="db_operations.php"
<form id="rename_db_form" method="post" action="db_operations.php"
onsubmit="return emptyFormElements(this, 'newname')">
<?php
if (isset($db_collation)) {
@@ -361,7 +379,7 @@ if (!$is_information_schema) {
echo ')'; ?>
</fieldset>
<fieldset class="tblFooters">
<input type="submit" value="<?php echo __('Go'); ?>" onclick="return confirmLink(this, 'CREATE DATABASE ... <?php echo __('and then'); ?> DROP DATABASE <?php echo PMA_jsFormat($db); ?>')" />
<input id="rename_db_input" type="submit" value="<?php echo __('Go'); ?>" />
</fieldset>
</form>
<?php
@@ -404,7 +422,7 @@ echo __('Remove database');
* Copy database
*/
?>
<form method="post" action="db_operations.php"
<form id="copy_db_form" method="post" action="db_operations.php"
onsubmit="return emptyFormElements(this, 'newname')">
<?php
if (isset($db_collation)) {
@@ -474,7 +492,7 @@ echo __('Remove database');
/**
* Change database charset
*/
echo '<form method="post" action="./db_operations.php">' . "\n"
echo '<form id="change_db_charset_form" method="post" action="./db_operations.php">' . "\n"
. PMA_generate_common_hidden_inputs($db, $table)
. '<fieldset>' . "\n"
. ' <legend>';

0
db_printview.php Normal file → Executable file
View File

0
db_qbe.php Normal file → Executable file
View File

21
db_search.php Normal file → Executable file
View File

@@ -37,6 +37,9 @@
*/
require_once './libraries/common.inc.php';
$GLOBALS['js_include'][] = 'jquery/jquery-1.4.2.js';
$GLOBALS['js_include'][] = 'db_search.js';
/**
* Gets some core libraries and send headers
*/
@@ -108,11 +111,14 @@ if (empty($_REQUEST['field_str']) || ! is_string($_REQUEST['field_str'])) {
}
/**
* Displays top links
* Displays top links if we are not in an Ajax request
*/
$sub_part = '';
require './libraries/db_info.inc.php';
if( $GLOBALS['is_ajax_request'] != true) {
require './libraries/db_info.inc.php';
echo '<div id="searchresults">';
}
/**
* 1. Main search form has been submitted
@@ -269,13 +275,22 @@ if (isset($_REQUEST['submit_search'])) {
}
} // end 1.
/**
* If we are in an Ajax request, we need to exit after displaying all the HTML
*/
if($GLOBALS['is_ajax_request'] == true) {
exit;
}
else {
echo '</div>';//end searchresults div
}
/**
* 2. Displays the main search form
*/
?>
<a name="db_search"></a>
<form method="post" action="db_search.php" name="db_search">
<form id="db_search_form" method="post" action="db_search.php" name="db_search">
<?php echo PMA_generate_common_hidden_inputs($GLOBALS['db']); ?>
<fieldset>
<legend><?php echo __('Search in database'); ?></legend>

3
db_sql.php Normal file → Executable file
View File

@@ -13,6 +13,9 @@ require_once './libraries/common.inc.php';
/**
* Runs common work
*/
$GLOBALS['js_include'][] = 'functions.js';
$GLOBALS['js_include'][] = 'sql.js';
require './libraries/db_common.inc.php';
require_once './libraries/sql_query_form.lib.php';

13
db_structure.php Normal file → Executable file
View File

@@ -11,6 +11,7 @@
require_once './libraries/common.inc.php';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
$GLOBALS['js_include'][] = 'db_structure.js';
/**
* Prepares the tables list if the user where not redirected to this script
@@ -294,13 +295,12 @@ foreach ($tables as $keyname => $each_table) {
if (! $db_is_information_schema) {
if (! empty($each_table['TABLE_ROWS'])) {
$empty_table = '<a href="sql.php?' . $tbl_url_query
$empty_table = '<a class="truncate_table_anchor" href="sql.php?' . $tbl_url_query
. '&amp;sql_query=';
$empty_table .= urlencode('TRUNCATE ' . PMA_backquote($each_table['TABLE_NAME']))
. '&amp;zero_rows='
. urlencode(sprintf(__('Table %s has been emptied'), htmlspecialchars($each_table['TABLE_NAME'])))
. '" onclick="return confirmLink(this, \'TRUNCATE ';
$empty_table .= PMA_jsFormat($each_table['TABLE_NAME']) . '\')">' . $titles['Empty'] . '</a>';
.'">' . $titles['Empty'] . '</a>';
} else {
$empty_table = $titles['NoEmpty'];
}
@@ -384,11 +384,10 @@ foreach ($tables as $keyname => $each_table) {
<?php echo $titles['Insert']; ?></a></td>
<td align="center"><?php echo $empty_table; ?></td>
<td align="center">
<a href="sql.php?<?php echo $tbl_url_query;
<a class="drop_table_anchor" href="sql.php?<?php echo $tbl_url_query;
?>&amp;reload=1&amp;purge=1&amp;sql_query=<?php
echo urlencode($drop_query); ?>&amp;zero_rows=<?php
echo urlencode($drop_message); ?>"
onclick="return confirmLink(this, '<?php echo PMA_jsFormat($drop_query, false); ?>')">
echo urlencode($drop_message); ?>" >
<?php echo $titles['Drop']; ?></a></td>
<?php } // end if (! $db_is_information_schema)
@@ -453,7 +452,7 @@ if ($is_show_stats) {
}
?>
</tbody>
<tbody>
<tbody id="tbl_summary_row">
<tr><th></th>
<th align="center" nowrap="nowrap">
<?php

21
db_tracking.php Normal file → Executable file
View File

@@ -9,7 +9,15 @@
*/
require_once './libraries/common.inc.php';
require './libraries/db_common.inc.php';
//Get some js files needed for Ajax requests
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
/**
* If we are not in an Ajax request, then do the common work and show the links etc.
*/
if($GLOBALS['is_ajax_request'] != true) {
require './libraries/db_common.inc.php';
}
$url_query .= '&amp;goto=tbl_tracking.php&amp;back=db_tracking.php';
// Get the database structure
@@ -20,6 +28,15 @@ require './libraries/db_info.inc.php';
// (here, do not use $_REQUEST['db] as it can be crafted)
if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
PMA_Tracker::deleteTracking($GLOBALS['db'], $_REQUEST['table']);
/**
* If in an Ajax request, generate the success message and use
* {@link PMA_ajaxResponse()} to send the output
*/
if($GLOBALS['is_ajax_request'] == true) {
$message = PMA_Message::success();
PMA_ajaxResponse($message, true);
}
}
// Get tracked data about the database
@@ -112,7 +129,7 @@ if (PMA_DBI_num_rows($all_tables_result) > 0) {
<td><?php echo $version_data['date_created'];?></td>
<td><?php echo $version_data['date_updated'];?></td>
<td><?php echo $version_status;?></td>
<td><a href="<?php echo $delete_link;?>" onclick="return confirmLink(this, '<?php echo PMA_jsFormat(__('Delete tracking data for this table'), false); ?>')"><?php echo $drop_image_or_text; ?></a></td>
<td><a class="drop_tracking_anchor" href="<?php echo $delete_link;?>" ><?php echo $drop_image_or_text; ?></a></td>
<td> <a href="<?php echo $tmp_link; ?>"><?php echo __('Versions');?></a>
| <a href="<?php echo $tmp_link; ?>&amp;report=true&amp;version=<?php echo $version_data['version'];?>"><?php echo __('Tracking report');?></a>
| <a href="<?php echo $tmp_link; ?>&amp;snapshot=true&amp;version=<?php echo $version_data['version'];?>"><?php echo __('Structure snapshot');?></a></td>

0
docs.css Normal file → Executable file
View File

0
error.php Normal file → Executable file
View File

0
export.php Normal file → Executable file
View File

0
favicon.ico Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

0
import.php Normal file → Executable file
View File

0
import_status.php Normal file → Executable file
View File

0
index.php Normal file → Executable file
View File

0
js/colorpicker/css/colorpicker.css Normal file → Executable file
View File

0
js/colorpicker/css/layout.css Normal file → Executable file
View File

0
js/colorpicker/images/blank.gif Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 49 B

After

Width:  |  Height:  |  Size: 49 B

0
js/colorpicker/images/colorpicker_background.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

0
js/colorpicker/images/colorpicker_hex.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 532 B

After

Width:  |  Height:  |  Size: 532 B

0
js/colorpicker/images/colorpicker_hsb_b.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 970 B

After

Width:  |  Height:  |  Size: 970 B

0
js/colorpicker/images/colorpicker_hsb_h.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1012 B

After

Width:  |  Height:  |  Size: 1012 B

0
js/colorpicker/images/colorpicker_hsb_s.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

0
js/colorpicker/images/colorpicker_indic.gif Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 86 B

After

Width:  |  Height:  |  Size: 86 B

0
js/colorpicker/images/colorpicker_overlay.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

0
js/colorpicker/images/colorpicker_rgb_b.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 970 B

After

Width:  |  Height:  |  Size: 970 B

0
js/colorpicker/images/colorpicker_rgb_g.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

0
js/colorpicker/images/colorpicker_rgb_r.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

0
js/colorpicker/images/colorpicker_select.gif Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 78 B

After

Width:  |  Height:  |  Size: 78 B

0
js/colorpicker/images/colorpicker_submit.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 984 B

After

Width:  |  Height:  |  Size: 984 B

0
js/colorpicker/images/custom_background.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

0
js/colorpicker/images/custom_hex.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 562 B

After

Width:  |  Height:  |  Size: 562 B

0
js/colorpicker/images/custom_hsb_b.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

0
js/colorpicker/images/custom_hsb_h.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 970 B

After

Width:  |  Height:  |  Size: 970 B

0
js/colorpicker/images/custom_hsb_s.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

0
js/colorpicker/images/custom_indic.gif Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 86 B

After

Width:  |  Height:  |  Size: 86 B

0
js/colorpicker/images/custom_rgb_b.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1008 B

After

Width:  |  Height:  |  Size: 1008 B

0
js/colorpicker/images/custom_rgb_g.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

0
js/colorpicker/images/custom_rgb_r.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1018 B

After

Width:  |  Height:  |  Size: 1018 B

0
js/colorpicker/images/custom_submit.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 997 B

After

Width:  |  Height:  |  Size: 997 B

0
js/colorpicker/images/select.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 506 B

After

Width:  |  Height:  |  Size: 506 B

0
js/colorpicker/images/select2.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 518 B

After

Width:  |  Height:  |  Size: 518 B

0
js/colorpicker/images/slider.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 315 B

After

Width:  |  Height:  |  Size: 315 B

0
js/colorpicker/js/colorpicker.js Normal file → Executable file
View File

6
js/common.js Normal file → Executable file
View File

@@ -205,7 +205,7 @@ function refreshNavigation() {
function addClass(element, classname)
{
if (element != null) {
element.className += ' ' + classname;
$("#"+element).addClass(classname);
//alert('set class: ' + classname + ', now: ' + element.className);
}
}
@@ -216,9 +216,7 @@ function addClass(element, classname)
function removeClass(element, classname)
{
if (element != null) {
element.className = element.className.replace(' ' + classname, '');
// if there is no other class anem there is no leading space
element.className = element.className.replace(classname, '');
$("#"+element).removeClass(classname);
//alert('removed class: ' + classname + ', now: ' + element.className);
}
}

0
js/cross_framing_protection.js Normal file → Executable file
View File

127
js/db_operations.js Normal file
View File

@@ -0,0 +1,127 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* @fileoverview function used in server privilege pages
* @name Database Operations
*
* @requires jQuery
* @requires jQueryUI
* @requires js/functions.js
*
* @version $Id$
*/
/**
* Ajax event handlers here for db_operations.php
*
* Actions Ajaxified here:
* Rename Database
* Copy Database
* Change charset
*/
$(document).ready(function() {
/**
* Ajax event handlers for 'Rename Database'
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowUser()
*/
$("#rename_db_form").live('submit', function(event) {
event.preventDefault();
var question = 'CREATE DATABASE ... and then DROP DATABASE ' + window.parent.db;
$(this).append('<input type="hidden" name="ajax_request" value="true" />');
/**
* @var button_options Object containing options for jQueryUI dialog buttons
*/
var button_options = {};
button_options[PMA_messages['strYes']] = function() {
$(this).dialog("close").remove();
window.parent.refreshMain();
window.parent.refreshNavigation();
};
button_options[PMA_messages['strNo']] = function() { $(this).dialog("close").remove(); }
$(this).PMA_confirm(question, $(this).attr('action'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strRenamingDatabases']);
$.get(url, $("#rename_db_form").serialize() + '&is_js_confirmed=1', function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
window.parent.db = data.newname;
$("#topmenucontainer")
.next('div')
.remove()
.end()
.after(data.sql_query);
//Remove the empty notice div generated due to a NULL query passed to PMA_showMessage()
var notice_class = $("#topmenucontainer").next("div").find('.notice');
if($(notice_class).text() == '') {
$(notice_class).remove();
}
$("<span>" + PMA_messages['strReloadDatabase'] + "?</span>").dialog({
buttons: button_options
}) //end dialog options
}
else {
PMA_ajaxShowMessage(data.error);
}
}) // end $.get()
})
}); // end Rename Database
/**
* Ajax Event Handler for 'Copy Database'
*
* @uses PMA_ajaxShowMessage()
*/
$("#copy_db_form").live('submit', function(event) {
event.preventDefault();
PMA_ajaxShowMessage(PMA_messages['strCopyingDatabase']);
$(this).append('<input type="hidden" name="ajax_request" value="true" />');
$.get($(this).attr('action'), $(this).serialize(), function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
if( $("#checkbox_switch").is(":checked")) {
window.parent.db = data.newname;
window.parent.refreshMain();
}
}
else {
PMA_ajaxShowMessage(data.error);
}
}) // end $.get
}) // end copy database
/**
* Ajax Event handler for 'Change Charset' of the database
*
* @uses PMA_ajaxShowMessage()
*/
$("#change_db_charset_form").live('submit', function(event) {
event.preventDefault();
$(this).append('<input type="hidden" name="ajax_request" value="true" />');
PMA_ajaxShowMessage(PMA_messages['strChangingCharset']);
$.get($(this).attr('action'), $(this).serialize() + "&submitcollation=" + $(this).find("input[name=submitcollation]").attr('value'), function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
}
else {
PMA_ajaxShowMessage(data.error);
}
}) // end $.get()
}) // end change charset
}, 'top.frame_content');

34
js/db_search.js Normal file
View File

@@ -0,0 +1,34 @@
/**
* @fileoverview JavaScript functions used on Database Search page
* @name Database Search
*
* @requires jQuery
* @requires js/functions.js
*/
/**
* AJAX script for the Database Search page.
*
* Actions ajaxified here:
* Retrieve result of SQL query
*/
$(document).ready(function() {
/**
* Ajax Event handler for retrieving the result of an SQL Query
*
* @uses PMA_ajaxShowMessage()
*/
$("#db_search_form").live('submit', function(event) {
event.preventDefault();
PMA_ajaxShowMessage(PMA_messages['strSearching']);
$(this).append('<input type="hidden" name="ajax_request" value="true"');
$.get($(this).attr('action'), $(this).serialize() + "&submit_search=" + $("#buttonGo").val(), function(data) {
$("#searchresults").html(data);
}) // end $.get()
})
}, 'top.frame_content'); // end $(document).ready()

224
js/db_structure.js Normal file
View File

@@ -0,0 +1,224 @@
/**
* @fileoverview functions used on the database structure page
* @name Database Structure
*
* @requires jQuery
* @requires jQueryUI
* @required js/functions.js
*/
/**
* AJAX scripts for db_structure.php
*
* Actions ajaxified here:
* Drop Database
* Truncate Table
* Drop Table
*
*/
$(document).ready(function() {
/**
* Ajax Event handler for 'Truncate Table'
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
*/
$(".truncate_table_anchor").live('click', function(event) {
event.preventDefault();
//extract current table name and build the question string
/**
* @var curr_table_name String containing the name of the table to be truncated
*/
var curr_table_name = $(this).parents('tr').children('th').children('a').text();
/**
* @var question String containing the question to be asked for confirmation
*/
var question = 'TRUNCATE ' + curr_table_name;
/**
* @var this_anchor Object referring to the anchor clicked
*/
var this_anchor = $(this);
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$.get(url, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
//Remove the action's href and class, so as to disable further attempts to truncate the table
// @todo: How to replace the icon with the disabled version?
$(this_anchor)
.removeAttr('href')
.removeClass('.truncate_table_anchor');
}
else {
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
}
}) // end $.get()
}) //end $.PMA_confirm()
}); //end of Truncate Table Ajax action
/**
* Ajax Event handler for 'Drop Table'
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
*/
$(".drop_table_anchor").live('click', function(event) {
event.preventDefault();
//extract current table name and build the question string
/**
* @var curr_row Object containing reference to the current row
*/
var curr_row = $(this).parents('tr');
/**
* @var curr_table_name String containing the name of the table to be truncated
*/
var curr_table_name = $(curr_row).children('th').children('a').text();
/**
* @var question String containing the question to be asked for confirmation
*/
var question = 'DROP TABLE ' + curr_table_name;
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$.get(url, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
//need to find a better solution here. The icon should be replaced
$(curr_row).hide("medium").remove();
}
else {
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
}
}); // end $.get()
}); // end $.PMA_confirm()
}); //end of Drop Table Ajax action
/**
* Ajax Event handler for 'Drop Event'
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
*/
$('.drop_event_anchor').live('click', function(event) {
event.preventDefault();
/**
* @var curr_event_row Object reference to current event's row
*/
var curr_event_row = $(this).parents('tr');
/**
* @var curr_event_name String containing the name of {@link curr_event_row}
*/
var curr_event_name = $(curr_event_row).children('td:first').text();
/**
* @var question String containing the question to be asked for confirmation
*/
var question = 'DROP EVENT ' + curr_event_name;
$(this).PMA_confirm(question, $(this).attr('href') , function(url) {
PMA_ajaxShowMessage(PMA_messages['strDroppingEvent']);
$.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$(curr_event_row).hide("medium").remove();
}
else {
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
}
}) // end $.get()
}) // end $.PMA_confirm()
}) //end Drop Event
/**
* Ajax Event handler for 'Drop Procedure'
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
*/
$('.drop_procedure_anchor').live('click', function(event) {
event.preventDefault();
/**
* @var curr_proc_row Object containing reference to the current procedure's row
*/
var curr_proc_row = $(this).parents('tr');
/**
* @var question String containing the question to be asked for confirmation
*/
var question = $(curr_proc_row).children('.drop_procedure_sql').val();
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strDroppingProcedure']);
$.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$(curr_event_row).hide("medium").remove();
}
else {
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
}
}) // end $.get()
}) // end $.PMA_confirm()
}) //end Drop Procedure
$('.drop_tracking_anchor').live('click', function(event) {
event.preventDefault();
/**
* @var curr_tracking_row Object containing reference to the current tracked table's row
*/
var curr_tracking_row = $(this).parents('tr');
/**
* @var question String containing the question to be asked for confirmation
*/
var question = PMA_messages['strDeleteTrackingData'];
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strDeletingTrackingData']);
$.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$(curr_tracking_row).hide("medium").remove();
}
else {
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
}
}) // end $.get()
}) // end $.PMA_confirm()
}) //end Drop Tracking
//Calculate Real End for InnoDB
/**
* Ajax Event handler for calculatig the real end for a InnoDB table
*
* @uses $.PMA_confirm
*/
$('#real_end_input').live('click', function(event) {
event.preventDefault();
/**
* @var question String containing the question to be asked for confirmation
*/
var question = PMA_messages['strOperationTakesLongTime'];
$(this).PMA_confirm(question, '', function() {
return true;
})
return false;
}) //end Calculate Real End for InnoDB
}, 'top.frame_content'); // end $(document).ready()

0
js/dom-drag.js Normal file → Executable file
View File

657
js/functions.js Normal file → Executable file
View File

@@ -15,6 +15,12 @@ var sql_box_locked = false;
*/
var only_once_elements = new Array();
/**
* @var ajax_message_init boolean boolean that stores status of
* notification for PMA_ajaxShowNotification
*/
var ajax_message_init = false;
/**
* selects the content of a given object, f.e. a textarea
*
@@ -99,6 +105,9 @@ function confirmLink(theLink, theSqlQuery)
* @param object the message to display
*
* @return boolean whether to run the query or not
*
* @todo used only by libraries/display_tbl.lib.php. figure out how it is used
* and replace with a jQuery equivalent
*/
function confirmAction(theMessage)
{
@@ -876,7 +885,7 @@ function PMA_markRowsInit() {
}
if (event.shiftKey == true && table.lastClicked != undefined) {
if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; }
if (event.preventDefault) {event.preventDefault();} else {event.returnValue = false;}
i = table.lastClicked;
if (i < this.rowIndex) {
@@ -926,26 +935,9 @@ $(document).ready(PMA_markRowsInit);
* @param container DOM element
*/
function markAllRows( container_id ) {
var rows = document.getElementById(container_id).getElementsByTagName('tr');
var unique_id;
var checkbox;
for ( var i = 0; i < rows.length; i++ ) {
checkbox = rows[i].getElementsByTagName( 'input' )[0];
if ( checkbox && checkbox.type == 'checkbox' ) {
unique_id = checkbox.name + checkbox.value;
if ( checkbox.disabled == false ) {
checkbox.checked = true;
if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
rows[i].className += ' marked';
marked_row[unique_id] = true;
}
}
}
}
$("#"+container_id).find("input:checkbox:enabled").attr('checked', 'checked')
.parents("tr").addClass("marked");
return true;
}
@@ -956,22 +948,9 @@ function markAllRows( container_id ) {
* @param container DOM element
*/
function unMarkAllRows( container_id ) {
var rows = document.getElementById(container_id).getElementsByTagName('tr');
var unique_id;
var checkbox;
for ( var i = 0; i < rows.length; i++ ) {
checkbox = rows[i].getElementsByTagName( 'input' )[0];
if ( checkbox && checkbox.type == 'checkbox' ) {
unique_id = checkbox.name + checkbox.value;
checkbox.checked = false;
rows[i].className = rows[i].className.replace(' marked', '');
marked_row[unique_id] = false;
}
}
$("#"+container_id).find("input:checkbox:enabled").removeAttr('checked')
.parents("tr").removeClass("marked");
return true;
}
@@ -1231,12 +1210,12 @@ function setVerticalPointer(theRow, theColNum, theAction, theDefaultClass1, theD
* @return boolean always true
*/
function setCheckboxes( container_id, state ) {
var checkboxes = document.getElementById(container_id).getElementsByTagName('input');
for ( var i = 0; i < checkboxes.length; i++ ) {
if ( checkboxes[i].type == 'checkbox' ) {
checkboxes[i].checked = state;
}
if(state) {
$("#"+container_id).find("input:checkbox").attr('checked', 'checked');
}
else {
$("#"+container_id).find("input:checkbox").removeAttr('checked');
}
return true;
@@ -1297,13 +1276,13 @@ function setCheckboxColumn(theCheckbox){
*/
function setSelectOptions(the_form, the_select, do_check)
{
var selectObject = document.forms[the_form].elements[the_select];
var selectCount = selectObject.length;
for (var i = 0; i < selectCount; i++) {
selectObject.options[i].selected = do_check;
} // end for
if( do_check ) {
$("form[name='"+ the_form +"']").find("select[name='"+the_select+"']").find("option").attr('selected', 'selected');
}
else {
$("form[name='"+ the_form +"']").find("select[name="+the_select+"]").find("option").removeAttr('selected');
}
return true;
} // end of the 'setSelectOptions()' function
@@ -1663,6 +1642,46 @@ function popupBSMedia(url_params, bs_ref, m_type, is_cust_type, w_width, w_heigh
var mediaWin = window.open('bs_play_media.php?' + url_params + '&bs_reference=' + bs_ref + '&media_type=' + m_type + '&custom_type=' + is_cust_type, 'viewBSMedia', 'width=' + w_width + ', height=' + w_height + ', resizable=1, scrollbars=1, status=0');
}
/**
* popups a request for changing MIME types for files in the BLOB repository
*
* @param var db database name
* @param var table table name
* @param var reference BLOB repository reference
* @param var current_mime_type current MIME type associated with BLOB repository reference
*/
function requestMIMETypeChange(db, table, reference, current_mime_type)
{
// no mime type specified, set to default (nothing)
if (undefined == current_mime_type)
current_mime_type = "";
// prompt user for new mime type
var new_mime_type = prompt("Enter custom MIME type", current_mime_type);
// if new mime_type is specified and is not the same as the previous type, request for mime type change
if (new_mime_type && new_mime_type != current_mime_type)
changeMIMEType(db, table, reference, new_mime_type);
}
/**
* changes MIME types for files in the BLOB repository
*
* @param var db database name
* @param var table table name
* @param var reference BLOB repository reference
* @param var mime_type new MIME type to be associated with BLOB repository reference
*/
function changeMIMEType(db, table, reference, mime_type)
{
// specify url and parameters for jQuery POST
var mime_chg_url = 'bs_change_mime_type.php';
var params = {bs_db: db, bs_table: table, bs_reference: reference, bs_new_mime_type: mime_type};
// jQuery POST
jQuery.post(mime_chg_url, params);
}
/**
* Jquery Coding for inline editing SQL_QUERY
*/
@@ -1741,6 +1760,103 @@ $(document).ready(function(){
}
});
/**
* Function to process the plain HTML response from an Ajax request. Inserts
* the various HTML divisions from the response at the proper locations. The
* array relates the divisions to be inserted to their placeholders.
*
* @param var divisions_map an associative array of id names
*
* <code>
* PMA_ajaxInsertResponse({'resultsTable':'resultsTable_response',
* 'profilingData':'profilingData_response'});
* </code>
*
*/
function PMA_ajaxInsertResponse(divisions_map) {
$.each(divisions_map, function(key, value) {
var content_div = '#'+value;
var target_div = '#'+key;
var content = $(content_div).html();
//replace content of target_div with that from the response
$(target_div).html(content);
});
};
/**
* Show a message on the top of the page for an Ajax request
*
* @param var message string containing the message to be shown.
* optional, defaults to 'Loading...'
* @param var timeout number of milliseconds for the message to be visible
* optional, defaults to 5000
*/
function PMA_ajaxShowMessage(message, timeout) {
//Handle the case when a empty data.message is passed. We don't want the empty message
if(message == '') {
return true;
}
/**
* @var msg String containing the message that has to be displayed
* @default PMA_messages['strLoading']
*/
if(!message) {
var msg = PMA_messages['strLoading'];
}
else {
var msg = message;
}
/**
* @var timeout Number of milliseconds for which {@link msg} will be visible
* @default 5000 ms
*/
if(!timeout) {
var to = 5000;
}
else {
var to = timeout;
}
if( !ajax_message_init) {
//For the first time this function is called, append a new div
$(function(){
$('<div id="loading_parent"></div>')
.insertBefore("#serverinfo");
$('<span id="loading" class="ajax_notification"></span>')
.appendTo("#loading_parent")
.html(msg)
.slideDown('medium')
.delay(to)
.slideUp('medium', function(){
$(this)
.html("") //Clear the message
.hide();
});
}, 'top.frame_content');
ajax_message_init = true;
}
else {
//Otherwise, just show the div again after inserting the message
$("#loading")
.clearQueue()
.html(msg)
.slideDown('medium')
.delay(to)
.slideUp('medium', function() {
$(this)
.html("")
.hide();
})
}
}
/**
* Hides/shows the "Open in ENUM/SET editor" message, depending on the data type of the column currently selected
*/
@@ -1755,6 +1871,451 @@ function toggle_enum_notice(selectElement) {
}
}
/**
* jQuery function that uses jQueryUI's dialogs to confirm with user. Does not
* return a jQuery object yet and hence cannot be chained
*
* @param string question
* @param string url URL to be passed to the callbackFn to make
* an Ajax call to
* @param function callbackFn callback to execute after user clicks on OK
*/
jQuery.fn.PMA_confirm = function(question, url, callbackFn) {
if (PMA_messages['strDoYouReally'] == '') {
return true;
}
/**
* @var button_options Object that stores the options passed to jQueryUI
* dialog
*/
var button_options = {};
button_options[PMA_messages['strOK']] = function(){
$(this).dialog("close").remove();
if($.isFunction(callbackFn)) {
callbackFn.call(this, url);
}
};
button_options[PMA_messages['strCancel']] = function() {$(this).dialog("close").remove();}
$('<div id="confirm_dialog"></div>')
.prepend(question)
.dialog({buttons: button_options});
};
/**
* jQuery function to sort a table's body after a new row has been appended to it.
* Also fixes the even/odd classes of the table rows at the end.
*
* @param string text_selector string to select the sortKey's text
*
* @return jQuery Object for chaining purposes
*/
jQuery.fn.PMA_sort_table = function(text_selector) {
return this.each(function() {
/**
* @var table_body Object referring to the table's <tbody> element
*/
var table_body = $(this);
/**
* @var rows Object referring to the collection of rows in {@link table_body}
*/
var rows = $(this).find('tr').get();
//get the text of the field that we will sort by
$.each(rows, function(index, row) {
row.sortKey = $.trim($(row).find(text_selector).text().toLowerCase());
})
//get the sorted order
rows.sort(function(a,b) {
if(a.sortKey < b.sortKey) {
return -1;
}
if(a.sortKey > b.sortKey) {
return 1;
}
return 0;
})
//pull out each row from the table and then append it according to it's order
$.each(rows, function(index, row) {
$(table_body).append(row);
row.sortKey = null;
})
//Re-check the classes of each row
$(this).find('tr:odd')
.removeClass('even').addClass('odd')
.end()
.find('tr:even')
.removeClass('odd').addClass('even');
})
}
/**
* jQuery coding for 'Create Table'. Used on db_operations.php,
* db_structure.php and db_tracking.php (i.e., wherever
* libraries/display_create_table.lib.php is used)
*
* Attach Ajax Event handlers for Create Table
*/
$(document).ready(function() {
/**
* Attach event handler to the submit action of the create table minimal form
* and retrieve the full table form and display it in a dialog
*
* @uses PMA_ajaxShowMessage()
*/
$("#create_table_form_minimal").live('submit', function(event) {
event.preventDefault();
/* @todo Validate this form! */
/**
* @var button_options Object that stores the options passed to jQueryUI
* dialog
*/
var button_options = {};
button_options[PMA_messages['strCancel']] = function() {$(this).dialog('close').remove();}
PMA_ajaxShowMessage();
$(this).append('<input type="hidden" name="ajax_request" value="true" />');
$.get($(this).attr('action'), $(this).serialize(), function(data) {
$('<div id="create_table_dialog"></div>')
.append(data)
.dialog({
title: top.frame_content.PMA_messages['strCreateTable'],
width: 900,
buttons : button_options
}); // end dialog options
}) // end $.get()
});
/**
* Attach event handler for submission of create table form
*
* @uses PMA_ajaxShowMessage()
* @uses $.PMA_sort_table()
* @uses window.parent.refreshNavigation()
*/
$("#create_table_form").find("input[name=submit_num_fields], input[name=do_save_data]").live('click', function(event) {
event.preventDefault();
/**
* @var the_form object referring to the create table form
*/
var the_form = $("#create_table_form");
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$(the_form).append('<input type="hidden" name="ajax_request" value="true" />');
if($(this).attr('name') == 'submit_num_fields') {
//User wants to add more fields to the table
$.post($(the_form).attr('action'), $(the_form).serialize() + "&submit_num_fields=" + $(this).val(), function(data) {
$("#create_table_dialog").html(data);
}) //end $.post()
}
else if($(this).attr('name') == 'do_save_data') {
//User wants to submit the form
$.post($(the_form).attr('action'), $(the_form).serialize() + "&do_save_data=" + $(this).val(), function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$("#create_table_dialog").dialog("close").remove();
/**
* @var tables_table Object referring to the <tbody> element that holds the list of tables
*/
var tables_table = $("#tablesForm").find("tbody").not("#tbl_summary_row");
/**
* @var curr_last_row Object referring to the last <tr> element in {@link tables_table}
*/
var curr_last_row = $(tables_table).find('tr:last');
/**
* @var curr_last_row_index_string String containing the index of {@link curr_last_row}
*/
var curr_last_row_index_string = $(curr_last_row).find('input:checkbox').attr('id').match(/\d+/)[0];
/**
* @var curr_last_row_index Index of {@link curr_last_row}
*/
var curr_last_row_index = parseFloat(curr_last_row_index_string);
/**
* @var new_last_row_index Index of the new row to be appended to {@link tables_table}
*/
var new_last_row_index = curr_last_row_index + 1;
/**
* @var new_last_row_id String containing the id of the row to be appended to {@link tables_table}
*/
var new_last_row_id = 'checkbox_tbl_' + new_last_row_index;
//append to table
$(data.new_table_string)
.find('input:checkbox')
.val(new_last_row_id)
.end()
.appendTo(tables_table);
//Sort the table
$(tables_table).PMA_sort_table('th');
//Refresh navigation frame as a new table has been added
window.parent.refreshNavigation();
}
else {
PMA_ajaxShowMessage(data.error);
}
}) // end $.post()
} // end elseif()
}) // end create table form submit button actions
}, 'top.frame_content'); //end $(document).ready for 'Create Table'
/**
* Attach event handlers for Empty Table and Drop Table. Used wherever libraries/
* tbl_links.inc.php is used.
*/
$(document).ready(function() {
/**
* Attach Ajax event handlers for Empty Table
*
* @uses PMA_ajaxShowMessage()
* @uses $.PMA_confirm()
*/
$("#empty_table_anchor").live('click', function(event) {
event.preventDefault();
/**
* @var question String containing the question to be asked for confirmation
*/
var question = 'TRUNCATE TABLE ' + window.parent.table;
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$("#topmenucontainer")
.next('div')
.remove()
.end()
.after(data.sql_query);
}
else {
PMA_ajaxShowMessage(data.error);
}
}) // end $.get
}) // end $.PMA_confirm()
}) // end Empty Table
/**
* Attach Ajax event handler for Drop Table
*
* @uses PMA_ajaxShowMessage()
* @uses $.PMA_confirm()
* @uses window.parent.refreshNavigation()
*/
$("#drop_table_anchor").live('click', function(event) {
event.preventDefault();
/**
* @var question String containing the question to be asked for confirmation
*/
var question = 'DROP TABLE/VIEW ' + window.parent.table;
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$("#topmenucontainer")
.next('div')
.remove()
.end()
.after(data.sql_query);
window.parent.table = '';
window.parent.refreshNavigation();
}
else {
PMA_ajaxShowMessage(data.error);
}
}) // end $.get
}) // end $.PMA_confirm()
}) // end $().live()
}, 'top.frame_content'); //end $(document).ready() for libraries/tbl_links.inc.php
/**
* Attach Ajax event handlers for Drop Trigger. Used on tbl_structure.php
*/
$(document).ready(function() {
$(".drop_trigger_anchor").live('click', function(event) {
event.preventDefault();
/**
* @var curr_row Object reference to the current trigger's <tr>
*/
var curr_row = $(this).parents('tr');
/**
* @var question String containing the question to be asked for confirmation
*/
var question = 'DROP TRIGGER IF EXISTS `' + $(curr_row).children('td:first').text() + '`';
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$("#topmenucontainer")
.next('div')
.remove()
.end()
.after(data.sql_query);
$(curr_row).hide("medium").remove();
}
else {
PMA_ajaxShowMessage(data.error);
}
}) // end $.get()
}) // end $.PMA_confirm()
}) // end $().live()
}, 'top.frame_content'); //end $(document).ready() for Drop Trigger
/**
* Attach Ajax event handlers for Drop Database. Moved here from db_structure.js
* as it was also required on db_create.php
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
* @uses window.parent.refreshNavigation()
* @uses window.parent.refreshMain()
*/
$(document).ready(function() {
$("#drop_db_anchor").live('click', function(event) {
event.preventDefault();
//context is top.frame_content, so we need to use window.parent.db to access the db var
/**
* @var question String containing the question to be asked for confirmation
*/
var question = PMA_messages['strDropDatabaseStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + ' :\n' + 'DROP DATABASE ' + window.parent.db;
$(this).PMA_confirm(question, $(this).attr('href') ,function(url) {
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$.get(url, {'is_js_confirmed': '1', 'ajax_request': true}, function(data) {
//Database deleted successfully, refresh both the frames
window.parent.refreshNavigation();
window.parent.refreshMain();
}) // end $.get()
}); // end $.PMA_confirm()
}); //end of Drop Database Ajax action
}) // end of $(document).ready() for Drop Database
/**
* Attach Ajax event handlers for 'Create Database'. Used wherever libraries/
* display_create_database.lib.php is used, ie main.php and server_databases.php
*
* @uses PMA_ajaxShowMessage()
*/
$(document).ready(function() {
$('#create_database_form').live('submit', function(event) {
event.preventDefault();
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$(this).append('<input type="hidden" name="ajax_request" value="true" />');
$.post($(this).attr('action'), $(this).serialize(), function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
//Append database's row to table
$("#tabledatabases")
.find('tbody')
.append(data.new_db_string)
.PMA_sort_table('.name')
.find('#db_summary_row')
.appendTo('#tabledatabases tbody')
.removeClass('odd even');
}
else {
PMA_ajaxShowMessage(data.error);
}
}) // end $.post()
}) // end $().live()
}) // end $(document).ready() for Create Database
/**
* Attach Ajax event handlers for 'Change Password' on main.php
*/
$(document).ready(function() {
/**
* Attach Ajax event handler on the change password anchor
*/
$('#change_password_anchor').live('click', function(event) {
event.preventDefault();
/**
* @var button_options Object containing options to be passed to jQueryUI's dialog
*/
var button_options = {};
button_options[PMA_messages['strCancel']] = function() {$(this).dialog('close').remove();}
$.get($(this).attr('href'), {'ajax_request': true}, function(data) {
$('<div id="change_password_dialog></div>')
.dialog({
title: top.frame_content.PMA_messages['strChangePassword'],
width: 600,
buttons : button_options
})
.append(data);
}) // end $.get()
}) // end handler for change password anchor
/**
* Attach Ajax event handler for Change Password form submission
*
* @uses PMA_ajaxShowMessage()
*/
$("#change_password_form").find('input[name=change_pw]').live('click', function(event) {
event.preventDefault();
/**
* @var the_form Object referring to the change password form
*/
var the_form = $("#change_password_form");
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$(the_form).append('<input type="hidden" name="ajax_request" value="true" />');
$.post($(the_form).attr('action'), $(the_form).serialize(), function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$("#topmenucontainer").after(data.sql_query);
$("#change_password_dialog").hide().remove();
}
else {
PMA_ajaxShowMessage(data.error);
}
}) // end $.post()
}) // end handler for Change Password form submission
}) // end $(document).ready() for Change Password
/**
* Toggle the hiding/showing of the "Open in ENUM/SET editor" message when
* the page loads and when the selected data type changes

0
js/indexes.js Normal file → Executable file
View File

0
js/jquery/jquery-1.4.2.js vendored Normal file → Executable file
View File

0
js/jquery/jquery-ui-1.8.custom.js vendored Normal file → Executable file
View File

0
js/jquery/jquery.json-2.2.js Normal file → Executable file
View File

0
js/jquery/timepicker.js vendored Normal file → Executable file
View File

0
js/keyhandler.js Normal file → Executable file
View File

0
js/main_custom_color.js Normal file → Executable file
View File

40
js/messages.php Normal file → Executable file
View File

@@ -29,6 +29,12 @@ $js_messages['strNoDropDatabases'] = __('"DROP DATABASE" statements are disabled
/* For confirmations */
$js_messages['strDoYouReally'] = __('Do you really want to ');
$js_messages['strDropDatabaseStrongWarning'] = __('You are about to DESTROY a complete database!');
$js_messages['strDroppingEvent'] = __('Dropping Event');
$js_messages['strDroppingProcedure'] = __('Dropping Procedure');
$js_messages['strDeleteTrackingData'] = __('Delete tracking data for this table');
$js_messages['strDeletingTrackingData'] = __('Deleting tracking data');
$js_messages['strDroppingPrimaryKeyIndex'] = __('Dropping Primary Key/Index');
$js_messages['strOperationTakesLongTime'] = __('This operation could take a long time. Proceed anyway?');
/* For blobstreaming */
$js_messages['strBLOBRepositoryDisableStrongWarning'] = __('You are about to DISABLE a BLOB Repository!');
@@ -43,11 +49,44 @@ $js_messages['strHostEmpty'] = __('The host name is empty!');
$js_messages['strUserEmpty'] = __('The user name is empty!');
$js_messages['strPasswordEmpty'] = __('The password is empty!');
$js_messages['strPasswordNotSame'] = __('The passwords aren\'t the same!');
$js_messages['strAddNewUser'] = __('Add a New User');
$js_messages['strCreateUser'] = __('Create User');
$js_messages['strReloadingPrivileges'] = __('Reloading Privileges');
$js_messages['strRemovingSelectedUsers'] = __('Removing Selected Users');
$js_messages['strClose'] = __('Close');
/* For inline query editing */
$js_messages['strGo'] = __('Go');
$js_messages['strCancel'] = __('Cancel');
/* For Ajax Notifications */
$js_messages['strLoading'] = __('Loading');
$js_messages['strProcessingRequest'] = __('Processing Request');
$js_messages['strErrorProcessingRequest'] = __('Error in Processing Request');
$js_messages['strDroppingColumn'] = __('Dropping Column');
$js_messages['strAddingPrimaryKey'] = __('Adding Primary Key');
$js_messages['strOK'] = __('OK');
/* For db_operations.js */
$js_messages['strRenamingDatabases'] = __('Renaming Databases');
$js_messages['strReloadDatabase'] = __('Reload Database');
$js_messages['strCopyingDatabase'] = __('Copying Database');
$js_messages['strChangingCharset'] = __('Changing Charset');
$js_messages['strTableMustHaveAtleastOneColumn'] = __('Table must have atleast 1 column');
$js_messages['strCreateTable'] = __('Create Table');
$js_messages['strYes'] = __('Yes');
$js_messages['strNo'] = __('No');
/* For db_search.js */
$js_messages['strSearching'] = __('Searching');
/* For sql.js */
$js_messages['strToggleQueryBox'] = __('Toggle Query Box Visibility');
$js_messages['strInlineEdit'] = __('Inline Edit');
/* For tbl_change.js */
$js_messages['strIgnore'] = __('Ignore');
/* Designer */
$js_messages['strModifications'] = __('Modifications have been saved');
$js_messages['strRelationDeleted'] = __('Relation deleted');
@@ -65,6 +104,7 @@ $js_messages['strChangeDisplay'] = __('Choose column to display');
/* password generation */
$js_messages['strGeneratePassword'] = __('Generate password');
$js_messages['strGenerate'] = __('Generate');
$js_messages['strChangePassword'] = __('Change Password');
/* navigation tabs */
$js_messages['strMore'] = __('More');

0
js/navigation.js Normal file → Executable file
View File

0
js/querywindow.js Normal file → Executable file
View File

0
js/replication.js Normal file → Executable file
View File

373
js/server_privileges.js Normal file → Executable file
View File

@@ -1,6 +1,11 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* function used in server privilege pages
* @fileoverview functions used in server privilege pages
* @name Server Privileges
*
* @requires jQuery
* @requires jQueryUI
* @requires js/functions.js
*
* @version $Id$
*/
@@ -8,8 +13,8 @@
/**
* Validates the password field in a form
*
* @uses PMA_messages['strPasswordEmpty']
* @uses PMA_messages['strPasswordNotSame']
* @see PMA_messages['strPasswordEmpty']
* @see PMA_messages['strPasswordNotSame']
* @param object the form
* @return boolean whether the field value is valid or not
*/
@@ -93,3 +98,365 @@ function suggestPassword(passwd_form) {
passwd_form.text_pma_pw2.value = passwd.value;
return true;
}
/**
* When a new user is created and retrieved over Ajax, append the user's row to
* the user's table
*
* @param new_user_string the html for the new user's row
* @param new_user_initial the first alphabet of the user's name
* @param new_user_initial_string html to replace the initial for pagination
*/
function appendNewUser(new_user_string, new_user_initial, new_user_initial_string) {
//Append the newly retrived user to the table now
//Calculate the index for the new row
var curr_last_row = $("#usersForm").find('tbody').find('tr:last');
var curr_last_row_index_string = $(curr_last_row).find('input:checkbox').attr('id').match(/\d+/)[0];
var curr_last_row_index = parseFloat(curr_last_row_index_string);
var new_last_row_index = curr_last_row_index + 1;
var new_last_row_id = 'checkbox_sel_users_' + new_last_row_index;
//Append to the table and set the id/names correctly
$(new_user_string)
.insertAfter($(curr_last_row))
.find('input:checkbox')
.attr('id', new_last_row_id)
.val(function() {
//the insert messes up the &amp;27; part. let's fix it
return $(this).val().replace(/&/,'&amp;');
})
.end()
.find('label')
.attr('for', new_last_row_id)
.end();
//Let us sort the table alphabetically
$("#usersForm").find('tbody').PMA_sort_table('label');
$("#initials_table").find('td:contains('+new_user_initial+')')
.html(new_user_initial_string);
};
/**#@+
* @namespace jQuery
*/
/**
* AJAX scripts for server_privileges page.
*
* Actions ajaxified here:
* Add a new user
* Revoke a user
* Edit privileges
* Export privileges
* Paginate table of users
* Flush privileges
*
* @memberOf jQuery
* @name document.ready
*/
$(document).ready(function() {
/** @lends jQuery */
/**
* AJAX event handler for 'Add a New User'
*
* @see PMA_ajaxShowMessage()
* @see appendNewUser()
* @memberOf jQuery
* @name add_user_click
*
*/
$("#fieldset_add_user a").live("click", function(event) {
/** @lends jQuery */
event.preventDefault();
PMA_ajaxShowMessage();
/**
* @var button_options Object containing options for jQueryUI dialog buttons
*/
var button_options = {};
button_options[PMA_messages['strCreateUser']] = function() {
/**
* @var the_form stores reference to current form
*/
var the_form = $(this).find("#addUsersForm");
if( ! checkAddUser($(the_form).get(0)) ) {
PMA_ajaxShowMessage(PMA_messages['strFormEmpty']);
return false;
}
//We also need to post the value of the submit button in order to get this to work correctly
$.post($(the_form).attr('action'), $(the_form).serialize() + "&adduser_submit=" + $(this).find("input[name=adduser_submit]").attr('value'), function(data) {
if(data.success == true) {
$("#add_user_dialog").dialog("close").remove();
PMA_ajaxShowMessage(data.message);
$("#topmenucontainer")
.next('div')
.remove()
.end()
.after(data.sql_query);
//Remove the empty notice div generated due to a NULL query passed to PMA_showMessage()
var notice_class = $("#topmenucontainer").next("div").find('.notice');
if($(notice_class).text() == '') {
$(notice_class).remove();
}
appendNewUser(data.new_user_string, data.new_user_initial, data.new_user_initial_string);
}
else {
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : "+data.error, "7000");
}
})
};
button_options[PMA_messages['strCancel']] = function() {$(this).dialog("close").remove();}
$.get($(this).attr("href"), {'ajax_request':true}, function(data) {
$('<div id="add_user_dialog"></div>')
.prepend(data)
.find("#fieldset_add_user_footer").hide() //showing the "Go" and "Create User" buttons together will confuse the user
.end()
.find("#addUsersForm").append('<input type="hidden" name="ajax_request" value="true" />')
.end()
.dialog({
title: top.frame_content.PMA_messages['strAddNewUser'],
width: 800,
modal: true,
buttons: button_options
}); //dialog options end
}); // end $.get()
});//end of Add New User AJAX event handler
/**
* Ajax event handler for 'Reload Privileges' anchor
*
* @see PMA_ajaxShowMessage()
* @memberOf jQuery
* @name reload_privileges_click
*/
$("#reload_privileges_anchor").live("click", function(event) {
event.preventDefault();
PMA_ajaxShowMessage(PMA_messages['strReloadingPrivileges']);
$.get($(this).attr("href"), {'ajax_request': true}, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
}
else {
PMA_ajaxShowMessage(data.error);
}
}); //end $.get()
}); //end of Reload Privileges Ajax event handler
/**
* AJAX handler for 'Revoke User'
*
* @see PMA_ajaxShowMessage()
* @memberOf jQuery
* @name revoke_user_click
*/
$("#fieldset_delete_user_footer #buttonGo").live('click', function(event) {
event.preventDefault();
PMA_ajaxShowMessage(PMA_messages['strRemovingSelectedUsers']);
$.post($("#usersForm").attr('action'), $("#usersForm").serialize() + "&delete=" + $(this).attr('value') + "&ajax_request=true", function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
//Remove the revoked user from the users list
$("#usersForm").find("input:checkbox:checked").parents("tr").slideUp("medium", function() {
var this_user_initial = $(this).find('input:checkbox').val().charAt(0).toUpperCase();
$(this).remove();
//If this is the last user with this_user_initial, remove the link from #initials_table
if($("#tableuserrights").find('input:checkbox[value^=' + this_user_initial + ']').length == 0) {
$("#initials_table").find('td > a:contains(' + this_user_initial + ')').parent('td').html(this_user_initial);
}
//Re-check the classes of each row
$("#usersForm")
.find('tbody').find('tr:odd')
.removeClass('even').addClass('odd')
.end()
.find('tr:even')
.removeClass('odd').addClass('even');
})
}
else {
PMA_ajaxShowMessage(data.error);
}
}) // end $.post()
}) // end Revoke User
/**
* AJAX handler for 'Edit User'
*
* @see PMA_ajaxShowMessage()
*
*/
/**
* Step 1: Load Edit User Dialog
* @memberOf jQuery
* @name edit_user_click
*/
$(".edit_user_anchor").live('click', function(event) {
/** @lends jQuery */
event.preventDefault();
PMA_ajaxShowMessage();
$(this).parents('tr').addClass('current_row');
/**
* @var button_options Object containing options for jQueryUI dialog buttons
*/
var button_options = {};
button_options[PMA_messages['strCancel']] = function() {$(this).dialog("close").remove();}
$.get($(this).attr('href'), {'ajax_request':true, 'edit_user_dialog': true}, function(data) {
$('<div id="edit_user_dialog"></div>')
.append(data)
.dialog({
width: 900,
buttons: button_options
})
}) // end $.get()
})
/**
* Step 2: Submit the Edit User Dialog
*
* @see PMA_ajaxShowMessage()
* @memberOf jQuery
* @name edit_user_submit
*/
$("#edit_user_dialog").find("form").live('submit', function(event) {
/** @lends jQuery */
event.preventDefault();
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$(this).append('<input type="hidden" name="ajax_request" value="true" />');
/**
* @var curr_submit_name name of the current button being submitted
*/
var curr_submit_name = $(this).find('.tblFooters').find('input:submit').attr('name');
/**
* @var curr_submit_value value of the current button being submitted
*/
var curr_submit_value = $(this).find('.tblFooters').find('input:submit').val();
$.post($(this).attr('action'), $(this).serialize() + '&' + curr_submit_name + '=' + curr_submit_value, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
//Close the jQueryUI dialog
$("#edit_user_dialog").dialog("close").remove();
if(data.sql_query) {
$("#topmenucontainer")
.next('div')
.remove()
.end()
.after(data.sql_query);
var notice_class = $("#topmenucontainer").next("div").find('.notice');
if($(notice_class).text() == '') {
$(notice_class).remove();
}
} //Show SQL Query that was executed
//Append new user if necessary
if(data.new_user_string) {
appendNewUser(data.new_user_string, data.new_user_initial, data.new_user_initial_string);
}
//Change privileges if they were edited
if(data.new_privileges) {
$("#usersForm")
.find('.current_row')
.find('tt')
.html(data.new_privileges);
}
$("#usersForm")
.find('.current_row')
.removeClass('current_row');
}
else {
PMA_ajaxShowMessage(data.error);
}
});
})
//end Edit user
/**
* AJAX handler for 'Export Privileges'
*
* @see PMA_ajaxShowMessage()
* @memberOf jQuery
* @name export_user_click
*/
$(".export_user_anchor").live('click', function(event) {
/** @lends jQuery */
event.preventDefault();
PMA_ajaxShowMessage();
/**
* @var button_options Object containing options for jQueryUI dialog buttons
*/
var button_options = {};
button_options[PMA_messages['strClose']] = function() {$(this).dialog("close").remove();}
$.get($(this).attr('href'), {'ajax_request': true}, function(data) {
$('<div id="export_dialog"></div>')
.prepend(data)
.dialog({
width : 500,
buttons: button_options
});
}) //end $.get
}) //end export privileges
/**
* AJAX handler to Paginate the Users Table
*
* @see PMA_ajaxShowMessage()
* @name paginate_users_table_click
* @memberOf jQuery
*/
$("#initials_table").find("a").live('click', function(event) {
event.preventDefault();
PMA_ajaxShowMessage();
$.get($(this).attr('href'), {'ajax_request' : true, 'random': Math.random()}, function(data) {
$("#usersForm")
.hide("medium")
.siblings("#initials_table")
.after(data)
.show("medium")
.end()
.remove();
$("#initials_table").siblings("h2").not(":first").remove();
}) // end $.get
})// end of the paginate users table
}, 'top.frame_content'); //end $(document).ready()
/**#@- */

0
js/server_synchronize.js Normal file → Executable file
View File

630
js/sql.js Normal file
View File

@@ -0,0 +1,630 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* @fileoverview functions used wherever an sql query form is used
*
* @requires jQuery
* @requires js/functions.js
*
* @version $Id$
*/
/**
* Get the field name for the current field. Required to construct the query
* for inline editing
*
* @param this_field_obj jQuery object that points to the current field's tr
* @param disp_mode string
*/
function getFieldName(this_field_obj, disp_mode) {
if(disp_mode == 'vertical') {
var field_name = $(this_field_obj).siblings('th').find('a').text();
}
else {
var this_field_index = $(this_field_obj).index();
if(window.parent.text_dir == 'ltr') {
// 4 columns to account for the checkbox, edit, delete and appended inline edit anchors
var field_name = $(this_field_obj).parents('table').find('thead').find('th:nth('+ (this_field_index-4 )+') a').text();
}
else {
var field_name = $(this_field_obj).parents('table').find('thead').find('th:nth('+ this_field_index+') a').text();
}
}
field_name = $.trim(field_name);
return field_name;
}
/**
* The function that iterates over each row in the table_results and appends a
* new inline edit anchor to each table row.
*
* @param disp_mode string
*/
function appendInlineAnchor(disp_mode) {
if(disp_mode == 'vertical') {
var cloned_row = $('.edit_row_anchor').removeClass('edit_row_anchor').parent('tr').clone();
var img_object = $(cloned_row).find('img:first').attr('title', PMA_messages['strInlineEdit']);
$(cloned_row).find('td').addClass('edit_row_anchor')
.find('a').attr('href', '#')
.find('div')
.text(PMA_messages['strInlineEdit'])
.prepend(img_object);
$(cloned_row).insertBefore($('.where_clause').parent('tr'));
$("#table_results").find('tr:first').find('th')
.attr('rowspan', '4');
}
else {
$('.edit_row_anchor').each(function() {
$(this).removeClass('edit_row_anchor');
var cloned_anchor = $(this).clone();
var img_object = $(cloned_anchor).find('img').attr('title', PMA_messages['strInlineEdit']);
$(cloned_anchor).addClass('edit_row_anchor')
.find('a').attr('href', '#')
.find('div')
.text(PMA_messages['strInlineEdit'])
.prepend(img_object);
$(this).siblings('.where_clause')
.before(cloned_anchor);
});
$('#rowsDeleteForm').find('thead').find('th').each(function() {
if($(this).attr('colspan') == 3) {
$(this).attr('colspan', '4')
}
})
}
}
/**#@+
* @namespace jQuery
*/
/**
* @description <p>Ajax scripts for sql and browse pages</p>
*
* Actions ajaxified here:
* <ul>
* <li>Retrieve results of an SQL query</li>
* <li>Paginate the results table</li>
* <li>Sort the results table</li>
* <li>Change table according to display options</li>
* <li>Inline editing of data</li>
* </ul>
*
* @name document.ready
* @memberOf jQuery
*/
$(document).ready(function() {
/**
* current value of the direction in which the table is displayed
* @type String
* @fieldOf jQuery
* @name disp_mode
*/
var disp_mode = $("#top_direction_dropdown").val();
/**
* Update value of {@link jQuery.disp_mode} everytime the direction dropdown changes value
* @memberOf jQuery
* @name direction_dropdown_change
*/
$("#top_direction_dropdown, #bottom_direction_dropdown").live('change', function(event) {
disp_mode = $(this).val();
})
/**
* Attach the {@link appendInlineAnchor} function to a custom event, which
* will be triggered manually everytime the table of results is reloaded
* @memberOf jQuery
* @name sqlqueryresults_live
*/
$("#sqlqueryresults").live('appendAnchor',function() {
appendInlineAnchor(disp_mode);
})
/**
* Trigger the appendAnchor event to prepare the first table for inline edit
*
* @memberOf jQuery
* @name sqlqueryresults_trigger
*/
$("#sqlqueryresults").trigger('appendAnchor');
/**
* Append the Toggle Query Box message to the query input form
*
* @memberOf jQuery
* @name appendToggleSpan
*/
$('<span id="togglequerybox"></span>')
.html(PMA_messages['strToggleQueryBox'])
.appendTo("#sqlqueryform");
// Attach the toggling of the query box visibility to a click
$("#togglequerybox").live('click', function() {
$(this).siblings().slideToggle("medium");
})
/**
* Ajax Event handler for 'SQL Query Submit'
*
* @see PMA_ajaxShowMessage()
* @memberOf jQuery
* @name sqlqueryform_submit
*/
$("#sqlqueryform").live('submit', function(event) {
event.preventDefault();
PMA_ajaxShowMessage();
$(this).append('<input type="hidden" name="ajax_request" value="true" />');
$.post($(this).attr('action'), $(this).serialize() , function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
}
else if (data.success == false ) {
PMA_ajaxShowMessage(data.error);
}
else {
$("#sqlqueryresults").html(data);
$("#sqlqueryresults").trigger('appendAnchor');
if($("#togglequerybox").siblings(":visible").length > 0) {
$("#togglequerybox").trigger('click');
}
}
}) // end $.post()
}) // end SQL Query submit
/**
* Ajax Event handlers for Paginating the results table
*/
/**
* Paginate when we click any of the navigation buttons
* @memberOf jQuery
* @name paginate_nav_button_click
* @uses PMA_ajaxShowMessage()
*/
$("input[name=navig]").live('click', function(event) {
/** @lends jQuery */
event.preventDefault();
PMA_ajaxShowMessage();
/**
* @var the_form Object referring to the form element that paginates the results table
*/
var the_form = $(this).parent("form");
$(the_form).append('<input type="hidden" name="ajax_request" value="true" />');
$.post($(the_form).attr('action'), $(the_form).serialize(), function(data) {
$("#sqlqueryresults").html(data);
$("#sqlqueryresults").trigger('appendAnchor');
}) // end $.post()
})// end Paginate results table
/**
* Paginate results with Page Selector dropdown
* @memberOf jQuery
* @name paginate_dropdown_change
*/
$("#pageselector").live('change', function(event) {
event.preventDefault();
PMA_ajaxShowMessage();
$.get($(this).attr('href'), $(this).serialize() + '&ajax_request=true', function(data) {
$("#sqlqueryresults").html(data);
$("#sqlqueryresults").trigger('appendAnchor');
}) // end $.get()
})// end Paginate results with Page Selector
/**
* Ajax Event handler for sorting the results table
* @memberOf jQuery
* @name table_results_sort_click
*/
$("#table_results").find("a[title=Sort]").live('click', function(event) {
event.preventDefault();
PMA_ajaxShowMessage();
$.get($(this).attr('href'), $(this).serialize() + '&ajax_request=true', function(data) {
$("#sqlqueryresults").html(data);
$("#sqlqueryresults").trigger('appendAnchor');
}) // end $.get()
})//end Sort results table
/**
* Ajax Event handler for the display options
* @memberOf jQuery
* @name displayOptionsForm_submit
*/
$("#displayOptionsForm").live('submit', function(event) {
event.preventDefault();
$.post($(this).attr('action'), $(this).serialize() + '&ajax_request=true' , function(data) {
$("#sqlqueryresults").html(data);
$("#sqlqueryresults").trigger('appendAnchor');
}) // end $.post()
})
//end displayOptionsForm handler
/**
* Ajax Event handlers for Inline Editing
*/
/**
* On click, replace the current field with an input/textarea
* @memberOf jQuery
* @name inline_edit_start
* @see PMA_ajaxShowMessage()
* @see getFieldName()
*/
$(".edit_row_anchor").live('click', function(event) {
/** @lends jQuery */
event.preventDefault();
$(this).removeClass('edit_row_anchor').addClass('edit_row_anchor_active');
// Initialize some variables
if(disp_mode == 'vertical') {
/**
* @var this_row_index Index of the current <td> in the parent <tr>
* Current <td> is the inline edit anchor.
*/
var this_row_index = $(this).index();
/**
* @var input_siblings Object referring to all inline editable events from same row
*/
var input_siblings = $(this).parents('tbody').find('tr').find('.data_inline_edit:nth('+this_row_index+')');
/**
* @var where_clause String containing the WHERE clause to select this row
*/
var where_clause = $(this).parents('tbody').find('tr').find('.where_clause:nth('+this_row_index+')').val();
}
else {
var input_siblings = $(this).parent('tr').find('.data_inline_edit');
var where_clause = $(this).parent('tr').find('.where_clause').val();
}
$(input_siblings).each(function() {
/** @lends jQuery */
/**
* @var data_value Current value of this field
*/
var data_value = $(this).html();
// We need to retrieve the value from the server for truncated/relation fields
// Find the field name
/**
* @var this_field Object referring to this field (<td>)
*/
var this_field = $(this);
/**
* @var field_name String containing the name of this field.
* @see getFieldName()
*/
var field_name = getFieldName($(this), disp_mode);
// In each input sibling, wrap the current value in a textarea
// and store the current value in a hidden span
if($(this).is(':not(.truncated, .transformed, .relation, .enum, .null)')) {
// handle non-truncated, non-transformed, non-relation values
// We don't need to get any more data, just wrap the value
$(this).html('<textarea>'+data_value+'</textarea>')
.append('<span class="original_data">'+data_value+'</span>');
$(".original_data").hide();
}
else if($(this).is('.truncated, .transformed')) {
/** @lends jQuery */
//handle truncated/transformed values values
/**
* @var sql_query String containing the SQL query used to retrieve value of truncated/transformed data
*/
var sql_query = 'SELECT ' + field_name + ' FROM ' + window.parent.table + ' WHERE ' + where_clause;
// Make the Ajax call and get the data, wrap it and insert it
$.post('sql.php', {
'token' : window.parent.token,
'db' : window.parent.db,
'ajax_request' : true,
'sql_query' : sql_query,
'inline_edit' : true
}, function(data) {
if(data.success == true) {
$(this_field).html('<textarea>'+data.value+'</textarea>')
.append('<span class="original_data">'+data_value+'</span>');
$(".original_data").hide();
}
else {
PMA_ajaxShowMessage(data.error);
}
}) // end $.post()
}
else if($(this).is('.relation')) {
/** @lends jQuery */
//handle relations
/**
* @var curr_value String containing the current value of this relational field
*/
var curr_value = $(this).find('a').text();
/**
* @var post_params Object containing parameters for the POST request
*/
var post_params = {
'ajax_request' : true,
'get_relational_values' : true,
'db' : window.parent.db,
'table' : window.parent.table,
'column' : field_name,
'token' : window.parent.token,
'curr_value' : curr_value
}
$.post('sql.php', post_params, function(data) {
$(this_field).html(data.dropdown)
.append('<span class="original_data">'+data_value+'</span>');
$(".original_data").hide();
}) // end $.post()
}
else if($(this).is('.enum')) {
/** @lends jQuery */
//handle enum fields
/**
* @var curr_value String containing the current value of this relational field
*/
var curr_value = $(this).text();
/**
* @var post_params Object containing parameters for the POST request
*/
var post_params = {
'ajax_request' : true,
'get_enum_values' : true,
'db' : window.parent.db,
'table' : window.parent.table,
'column' : field_name,
'token' : window.parent.token,
'curr_value' : curr_value
}
$.post('sql.php', post_params, function(data) {
$(this_field).html(data.dropdown)
.append('<span class="original_data">'+data_value+'</span>');
$(".original_data").hide();
}) // end $.post()
}
else if($(this).is('.null')) {
//handle null fields
$(this_field).html('<textarea></textarea>')
.append('<span class="original_data">NULL</span>');
$(".original_data").hide();
}
})
}) // End On click, replace the current field with an input/textarea
/**
* After editing, clicking again should post data
*
* @memberOf jQuery
* @name inline_edit_save
* @see PMA_ajaxShowMessage()
* @see getFieldName()
*/
$(".edit_row_anchor_active").live('click', function(event) {
/** @lends jQuery */
event.preventDefault();
/**
* @var this_row Object referring to current row that is being edited
*/
var this_row = $(this);
// Initialize variables
if(disp_mode == 'vertical') {
/**
* @var this_row_index Index of the current <td> in the parent <tr>
* Current <td> is the inline edit anchor.
*/
var this_row_index = $(this).index();
/**
* @var input_siblings Object referring to all inline editable events from same row
*/
var input_siblings = $(this).parents('tbody').find('tr').find('.data_inline_edit:nth('+this_row_index+')');
/**
* @var where_clause String containing the WHERE clause to select this row
*/
var where_clause = $(this).parents('tbody').find('tr').find('.where_clause:nth('+this_row_index+')').val();
}
else {
var input_siblings = $(this).parent('tr').find('.data_inline_edit');
var where_clause = $(this).parent('tr').find('.where_clause').val();
}
/**
* @var nonunique Boolean, whether this row is unique or not
*/
if($(this).is('.nonunique')) {
var nonunique = 0;
}
else {
var nonunique = 1;
}
// Collect values of all fields to submit, we don't know which changed
/**
* @var params_to_submit Array containing the name/value pairs of all fields
*/
var params_to_submit = {};
/**
* @var relation_fields Array containing the name/value pairs of relational fields
*/
var relation_fields = {};
/**
* @var transform_fields Array containing the name/value pairs for transformed fields
*/
var transform_fields = {};
/**
* @var transformation_fields Boolean, if there are any transformed fields in this row
*/
var transformation_fields = false;
$(input_siblings).each(function() {
/** @lends jQuery */
/**
* @var this_field Object referring to this field (<td>)
*/
var this_field = $(this);
/**
* @var field_name String containing the name of this field.
* @see getFieldName()
*/
var field_name = getFieldName($(this), disp_mode);
/**
* @var this_field_params Array temporary storage for the name/value of current field
*/
var this_field_params = {};
if($(this).is('.transformed')) {
transformation_fields = true;
}
if($(this).is(":not(.relation, .enum)")) {
this_field_params[field_name] = $(this).find('textarea').val();
if($(this).is('.transformed')) {
$.extend(transform_fields, this_field_params);
}
}
else {
this_field_params[field_name] = $(this).find('select').val();
if($(this).is('.relation')) {
$.extend(relation_fields, this_field_params);
}
}
$.extend(params_to_submit, this_field_params);
})
/**
* @var sql_query String containing the SQL query to update this row
*/
var sql_query = 'UPDATE ' + window.parent.table + ' SET ';
$.each(params_to_submit, function(key, value) {
if(value.length == 0) {
value = 'NULL'
}
sql_query += ' ' + key + "='" + value + "' , ";
})
//Remove the last ',' appended in the above loop
sql_query = sql_query.replace(/,\s$/, '');
sql_query += ' WHERE ' + where_clause;
/**
* @var rel_fields_list String, url encoded representation of {@link relations_fields}
*/
var rel_fields_list = $.param(relation_fields);
/**
* @var transform_fields_list String, url encoded representation of {@link transform_fields}
*/
var transform_fields_list = $.param(transform_fields);
// Make the Ajax post after setting all parameters
/**
* @var post_params Object containing parameters for the POST request
*/
var post_params = {'ajax_request' : true,
'sql_query' : sql_query,
'disp_direction' : disp_mode,
'token' : window.parent.token,
'db' : window.parent.db,
'table' : window.parent.table,
'clause_is_unique' : nonunique,
'where_clause' : where_clause,
'rel_fields_list' : rel_fields_list,
'do_transformations' : transformation_fields,
'transform_fields_list' : transform_fields_list,
'goto' : 'sql.php'
};
$.post('tbl_replace.php', post_params, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$(this_row).removeClass('edit_row_anchor_active').addClass('edit_row_anchor');
$(input_siblings).each(function() {
// Inline edit post has been successful.
if($(this).is(':not(.relation, .enum)')) {
/**
* @var new_html String containing value of the data field after edit
*/
var new_html = $(this).find('textarea').val();
if($(this).is('.transformed')) {
var field_name = getFieldName($(this), disp_mode);
var this_field = $(this);
$.each(data.transformations, function(key, value) {
if(key == field_name) {
if($(this_field).is('.text_plain, .application_octetstream')) {
new_html = value;
return false;
}
else {
var new_value = $(this_field).find('textarea').val();
new_html = $(value).append(new_value);
return false;
}
}
})
}
}
else {
var new_html = $(this).find('select').val();
if($(this).is('.relation')) {
var field_name = getFieldName($(this), disp_mode);
var this_field = $(this);
$.each(data.relations, function(key, value) {
if(key == field_name) {
var new_value = $(this_field).find('select').val();
new_html = $(value).append(new_value);
return false;
}
})
}
}
$(this).html(new_html);
})
}
else {
PMA_ajaxShowMessage(data.error);
};
}) // end $.post()
}) // End After editing, clicking again should post data
}, 'top.frame_content') // end $(document).ready()
/**#@- */

154
js/tbl_change.js Normal file → Executable file
View File

@@ -1,6 +1,10 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* function used in table data manipulation pages
* @fileoverview function used in table data manipulation pages
*
* @requires jQuery
* @requires jQueryUI
* @requires js/functions.js
*
* @version $Id$
*/
@@ -247,3 +251,151 @@ function unNullify(urlField, multi_edit)
return true;
} // end of the 'unNullify()' function
/**
* Ajax handlers for Change Table page
*
* Actions Ajaxified here:
* Submit Data to be inserted into the table
* Restart insertion with 'N' rows.
*/
$(document).ready(function() {
/**
* Submission of data to be inserted into table
*
* @uses PMA_ajaxShowMessage()
*/
$("#insertForm").live('submit', function(event) {
/**
* @var the_form Object referring to the insertion form
*/
var the_form = $(this);
event.preventDefault();
PMA_ajaxShowMessage();
$(the_form).append('<input type="hidden" name="ajax_request" value="true" />');
$.post($(the_form).attr('action'), $(the_form).serialize(), function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$("#topmenucontainer")
.next('div')
.remove()
.end()
.after(data.sql_query);
//Remove the empty notice div generated due to a NULL query passed to PMA_showMessage()
var notice_class = $("#topmenucontainer").next("div").find('.notice');
if($(notice_class).text() == '') {
$(notice_class).remove();
}
//Clear the data in the forms
$(the_form).find('input:reset').trigger('click');
}
else {
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : "+data.error, "7000");
}
})
}) // end submission of data to be inserted into table
/**
* Restart Insertion form
*/
$("#insert_rows").live('change', function(event) {
event.preventDefault();
/**
* @var curr_rows Number of current insert rows already on page
*/
var curr_rows = $(".insertRowTable").length;
/**
* @var target_rows Number of rows the user wants
*/
var target_rows = $("#insert_rows").val();
if(curr_rows < target_rows ) {
while( curr_rows < target_rows ) {
/**
* @var last_row Object referring to the last row
*/
var last_row = $("#insertForm").find(".insertRowTable:last");
//Clone the insert tables
$(last_row)
.clone()
.insertBefore("#insertForm > fieldset")
.find('input[name*=multi_edit],select[name*=multi_edit]')
.each(function() {
/**
* Extract the index from the name attribute for all input/select fields and increment it
* name is of format funcs[multi_edit][10][<long random string of alphanum chars>]
*/
/**
* @var this_name String containing name of the input/select elements
*/
var this_name = $(this).attr('name');
/** split {@link this_name} at [10], so we have the parts that can be concatenated later */
var name_parts = this_name.split(/\[\d+\]/);
/** extract the [10] from {@link name_parts} */
var old_row_index_string = this_name.match(/\[\d+\]/)[0];
/** extract 10 - had to split into two steps to accomodate double digits */
var old_row_index = parseInt(old_row_index_string.match(/\d+/)[0]);
/** calculate next index i.e. 11 */
var new_row_index = old_row_index + 1;
/** generate the new name i.e. funcs[multi_edit][11][foobarbaz] */
var new_name = name_parts[0] + '[' + new_row_index + ']' + name_parts[1];
$(this).attr('name', new_name);
});
//Insert/Clone the ignore checkboxes
if(curr_rows == 1 ) {
$('<input id="insert_ignore_check_1" type="checkbox" name="insert_ignore_check_1" checked="checked" />')
.insertBefore(".insertRowTable:last")
.after('<label for="insert_ignore_check_1">' + PMA_messages['strIgnore'] + '</label>');
}
else {
/**
* @var last_checkbox Object reference to the last checkbox in #insertForm
*/
var last_checkbox = $("#insertForm").children('input:checkbox:last');
/** name of {@link last_checkbox} */
var last_checkbox_name = $(last_checkbox).attr('name');
/** index of {@link last_checkbox} */
var last_checkbox_index = parseInt(last_checkbox_name.match(/\d+/));
/** name of new {@link last_checkbox} */
var new_name = last_checkbox_name.replace(/\d+/,last_checkbox_index+1);
$(last_checkbox)
.clone()
.attr({'id':new_name, 'name': new_name})
.add('label[for^=insert_ignore_check]:last')
.clone()
.attr('for', new_name)
.before('<br />')
.insertBefore(".insertRowTable:last");
}
curr_rows++;
}
}
else if( curr_rows > target_rows) {
while(curr_rows > target_rows) {
$("input[id^=insert_ignore_check]:last")
.nextUntil("fieldset")
.andSelf()
.remove();
curr_rows--;
}
}
})
}, 'top.frame_content'); //end $(document).ready()

21
js/tbl_operations.js Normal file
View File

@@ -0,0 +1,21 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* function used in server privilege pages
*
* @version $Id$
*/
/**
* Add all AJAX scripts for tbl_operations.php page here.
*
* Alter table order - #div_table_order form
* Move Table - #div_table_rename form
* Table Options - #div_table_options form
* Copy Table - #div_table_copy form
* Table Maintenance - #div_table_maintenance (need to id each anchor)
* Check
* Repair
* Analyze
* Flush
* Optimize
*/

0
js/tbl_relation.js Normal file → Executable file
View File

32
js/tbl_select.js Normal file
View File

@@ -0,0 +1,32 @@
/**
* @fileoverview JavaScript functions used on tbl_select.php
*
* @requires jQuery
* @requires js/functions.js
*/
/**
* Ajax event handlers for this page
*
* Actions ajaxified here:
* Table Search
*/
$(document).ready(function() {
/**
* Ajax event handler for Table Search
*
* @uses PMA_ajaxShowMessage()
*/
$("#tbl_search_form").live('submit', function(event) {
event.preventDefault();
PMA_ajaxShowMessage(PMA_messages['strSearching']);
$(this).append('<input type="hidden" name="ajax_request" value="true" />');
$.post($(this).attr('action'), $(this).serialize(), function(data) {
$("#searchresults").html(data);
})
})
}, 'top.frame_content'); // end $(document).ready()

133
js/tbl_structure.js Normal file
View File

@@ -0,0 +1,133 @@
/**
* @fileoverview functions used on the table structure page
* @name Table Structure
*
* @requires jQuery
* @requires jQueryUI
* @required js/functions.js
*/
/**
* AJAX scripts for tbl_structure.php
*
* Actions ajaxified here:
* Drop Column
* Add Primary Key
* Drop Primary Key/Index
*
*/
$(document).ready(function() {
/**
* Attach Event Handler for 'Drop Column'
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
*/
$(".drop_column_anchor").live('click', function(event) {
event.preventDefault();
/**
* @var curr_table_name String containing the name of the current table
*/
var curr_table_name = window.parent.table;
/**
* @var curr_row Object reference to the currently selected row (i.e. field in the table)
*/
var curr_row = $(this).parents('tr');
/**
* @var curr_column_name String containing name of the field referred to by {@link curr_row}
*/
var curr_column_name = $(curr_row).children('th').children('label').text();
/**
* @var question String containing the question to be asked for confirmation
*/
var question = PMA_messages['strDoYouReally'] + ' :\n ALTER TABLE `' + curr_table_name + '` DROP `' + curr_column_name + '`';
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strDroppingColumn']);
$.get(url, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$(curr_row).hide("medium").remove();
}
else {
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
}
}) // end $.get()
}); // end $.PMA_confirm()
}) ; //end of Drop Column Anchor action
/**
* Ajax Event handler for 'Add Primary Key'
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
*/
$(".action_primary a").live('click', function(event) {
event.preventDefault();
/**
* @var curr_table_name String containing the name of the current table
*/
var curr_table_name = window.parent.table;
/**
* @var curr_column_name String containing name of the field referred to by {@link curr_row}
*/
var curr_column_name = $(this).parents('tr').children('th').children('label').text();
/**
* @var question String containing the question to be asked for confirmation
*/
var question = PMA_messages['strDoYouReally'] + ' :\n ALTER TABLE `' + curr_table_name + '` ADD PRIMARY KEY(`' + curr_column_name + '`)';
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strAddingPrimaryKey']);
$.get(url, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$(this).remove();
}
else {
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
}
}) // end $.get()
}) // end $.PMA_confirm()
})//end Add Primary Key
/**
* Ajax Event handler for 'Drop Primary Key/Index'
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
*/
$('.drop_primary_key_index_anchor').live('click', function(event) {
event.preventDefault();
/**
* @var curr_row Object containing reference to the current field's row
*/
var curr_row = $(this).parents('tr');
var question = $(curr_row).children('.drop_primary_key_index_msg').val();
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strDroppingPrimaryKeyIndex']);
$.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$(curr_row).hide("medium").remove();
}
else {
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
}
}) // end $.get()
}) // end $.PMA_confirm()
}) //end Drop Primary Key/Index
}) // end $(document).ready()

0
js/update-location.js Normal file → Executable file
View File

0
libraries/.htaccess Normal file → Executable file
View File

0
libraries/Config.class.php Normal file → Executable file
View File

0
libraries/Error.class.php Normal file → Executable file
View File

0
libraries/Error_Handler.class.php Normal file → Executable file
View File

0
libraries/File.class.php Normal file → Executable file
View File

6
libraries/Index.class.php Normal file → Executable file
View File

@@ -477,10 +477,12 @@ class PMA_Index
}
$r .= '<td ' . $row_span . '>'
. ' <a href="sql.php' . PMA_generate_common_url($this_params)
. '" onclick="return confirmLink(this, \'' . $js_msg . '\')">'
. ' <a class="drop_primary_key_index_anchor" href="sql.php' . PMA_generate_common_url($this_params)
. '" >'
. PMA_getIcon('b_drop.png', __('Drop')) . '</a>'
. '</td>' . "\n";
$r .= '<input type="hidden" class="drop_primary_key_index_msg" value="' . $js_msg . '" />';
}
$r .= '<th ' . $row_span . '>' . htmlspecialchars($index->getName()) . '</th>';

0
libraries/List.class.php Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More