Merge remote-tracking branch 'origin/master' into tyronm

This commit is contained in:
Tyron Madlener 2011-07-05 18:09:55 +02:00
parent b8fbb9d1af
commit 2ee9f03cbb
372 changed files with 157876 additions and 106885 deletions

View File

@ -1,4 +1,4 @@
phpMyAdmin - ChangeLog
phpMyAdmin - ChangeLog
======================
3.5.0.0 (not yet released)
@ -16,8 +16,40 @@
+ Patch #3271804 for rfe #3177495, new DisableMultiTableMaintenance directive
+ [interface] Reorganised server status page.
+ [interface] Changed way of generating charts.
+ rfe #939233 [interface] Flexible column width
+ [interface] Mouse-based column reordering in query results
+ AJAX for Insert to a table from database Structure page
- Patch #3316969 PMA_ajaxShowMessage() does not respect timeout
+ AJAX for Change on multiple rows in table Browse
+ [interface] Improved support for stored routines
+ [display] More options for browsing GIS data
+ [interface] Support for spatial indexes
+ [display] GIS data visualization
+ AJAX for table structure multiple-column change
+ AJAX for table structure index edit
+ Show/hide indexes in table Structure
+ More compact navigation bar
+ Display direction (horizontal/vertical) no longer displayed by default
+ Shift/click support in database Structure
+ Show/hide column in table Browse
- bug #3353856 [AJAX] AJAX dialogs use wrong font-size
3.4.3.0 (not yet released)
3.4.4.0 (not yet released)
- bug #3323060 [parser] SQL parser breaks AJAX requests if query has unclosed quotes
- bug #3323101 [parser] Invalid escape sequence in SQL parser
- bug #3348995 [config] $cfg['Export']['asfile'] set to false does not select asText option
- bug #3340151 [export] Working SQL query exports error page
- bug #3353649 [interface] "Create an index on X columns" form not validated
- bug #3350790 [interface] JS error in Table->Structure->Index->Edit
- bug #3353811 [interface] Info message has "error" class
3.4.3.1 (2011-07-02)
- [security] Fixed possible session manipulation in swekey authentication, see PMASA-2011-5
- [security] Fixed possible code injection incase session variables are compromised, see PMASA-2011-6
- [security] Fixed regexp quoting issue in Synchronize code, see PMASA-2011-7
- [security] Fixed filtering of a file path, which allowed for directory traversal, see PMASA-2011-8
3.4.3.0 (2011-06-27)
- bug #3311170 [sync] Missing helper icons in Synchronize
- patch #3304473 [setup] Redefine a lable that was wrong
- bug #3304544 [parser] master is not a reserved word
@ -26,6 +58,11 @@
- bug #3313210 [interface] Columns class sometimes changed for nothing
- patch #3313326 [interface] Some tooltips do not disappear
- bug #3315720 [search] Fix search in non unicode tables
- bug #3315741 [display] Inline query edit broken
- patch #3317206 [privileges] Generate password option missing on new accounts
- bug #3317293 [edit] Inline edit places HTML line breaks in edit area
- bug #3319466 [interface] Inline query edit does not escape special characters
- minor XSS (require a valid token)
3.4.2.0 (2011-06-07)
- bug #3301249 [interface] Iconic table operations does not remove inline edit label
@ -100,7 +137,7 @@
+ patch #2974341 [structure] Clicking on table name in db Structure should
Browse the table if possible, thanks to bhdouglass - dougboybhd
+ patch #2975533 [search] New search operators, thanks to
Martynas Mickevičius
Martynas Mickevičius
+ patch #2967320 [designer] Colored relations based on the primary key,
thanks to GreenRover - greenrover
- [core] Provide way for vendors to easily change paths to config files.
@ -254,7 +291,7 @@
3.3.7.0 (2010-09-07)
- patch #3050492 [PDF scratchboard] Cannot drag table box to the edge after
a page size increase, thanks to Martin Schönberger - mad05
a page size increase, thanks to Martin Schönberger - mad05
3.3.6.0 (2010-08-28)
- bug #3033063 [core] Navi gets wrong db name
@ -275,7 +312,7 @@
3.3.5.0 (2010-07-26)
- patch #2932113 [information_schema] Slow export when having lots of
databases, thanks to Stéphane Pontier - shadow_walker
databases, thanks to Stéphane Pontier - shadow_walker
- bug #3022705 [import] Import button does not work in Catalan when there
is no progress bar possible
- bug [replication] Do not offer information_schema in the list of databases
@ -315,9 +352,9 @@
- patch #2984893 [engines] InnoDB storage page emits a warning,
thanks to Madhura Jayaratne - madhuracj
- bug #2974687, bug #2974692 [compatibility] PHPExcel : IBM AIX iconv() does not work,
thanks to Björn Wiberg - bwiberg
thanks to Björn Wiberg - bwiberg
- bug #2983066 [interface] Flush table on table operations shows the query twice,
thanks to Martynas Mickevičius - BlinK_
thanks to Martynas Mickevičius - BlinK_
- bug #2983060, patch #2987900 [interface] Fix initial state of tables in
designer, thanks to Sutharshan Balachandren.
- bug #2983062, patch #2989408 [engines] Fix warnings when changing table
@ -396,7 +433,7 @@
+ rfe #2839504 [engines] Support InnoDB plugin's new row formats
+ [core] Added ability for synchronizing databases among servers.
+ [lang] #2843101 Dutch update, thanks to scavenger2008
+ [lang] Galician update, thanks to Xosé Calvo - xosecalvo
+ [lang] Galician update, thanks to Xosé Calvo - xosecalvo
+ [export] Added MediaWiki export module,
thanks to Derek Schaefer - drummingds1
+ [lang] Turkish update, thanks to Burak Yavuz

View File

@ -137,6 +137,8 @@ vim: expandtab ts=4 sw=4 sts=4 tw=78
<abbr title="Frequently Asked Questions">FAQ</abbr> 3.6)</a></li>
<li>support mysqli, the improved MySQL extension <a href="#faq1_17">
(see <abbr title="Frequently Asked Questions">FAQ</abbr> 1.17)</a></li>
<li>create, edit, call, export and drop stored procedures and functions</li>
<li>create, edit, export and drop events and triggers</li>
<li>communicate in <a href="http://www.phpmyadmin.net/home_page/translations.php">62 different languages</a>
</li>
<li>synchronize two databases residing on the same as well as remote servers
@ -1073,7 +1075,7 @@ ALTER TABLE `pma_column_comments`
Without configuring the storage, you can still access the recently used tables,
but it will disappear after you logout.<br/><br/>
To allow the usage of this functionality:
To allow the usage of this functionality persistently:
<ul>
<li>set up <a href="#pmadb">pmadb</a> and the phpMyAdmin configuration storage</li>
@ -2141,6 +2143,12 @@ setfacl -d -m "g:www-data:rwx" tmp
identify what they mean.
</dd>
<dt id="cfg_ShowDisplayDir">$cfg['ShowDisplayDir'] boolean</dt>
<dd>
Defines whether or not type display direction option is shown
when browsing a table.
</dd>
<dt id="cfg_RepeatCells">$cfg['RepeatCells'] integer</dt>
<dd>
Repeat the headers every X cells, or 0 to deactivate.
@ -5152,6 +5160,8 @@ Jakub Wilk, Thomas Michael Winningham, Vilius Zigmantas, &quot;Manuzhai&quot;.
<li><a href="http://www.wikipedia.org/wiki/Secure_Sockets_Layer">SSL (Secure
Sockets Layer)</a>
- a cryptographic protocol which provides secure communication on the Internet.</li>
<li><a href="http://en.wikipedia.org/wiki/Stored_procedure">Stored procedure</a>
- a subroutine available to applications accessing a relational database system</li>
<li><a href="http://www.wikipedia.org/wiki/SQL">SQL</a>
- Structured Query Language</li>
<li><a href="http://www.wikipedia.org/wiki/Table_%28database%29">table</a>
@ -5163,6 +5173,9 @@ Jakub Wilk, Thomas Michael Winningham, Vilius Zigmantas, &quot;Manuzhai&quot;.
- a type of archive file format: the Tape ARchive format.</li>
<li><a href="http://www.wikipedia.org/wiki/TCP">TCP (Transmission Control Protocol)</a>
- one of the core protocols of the Internet protocol suite.</li>
<li><a href="http://en.wikipedia.org/wiki/Database_trigger">trigger</a>
- a procedural code that is automatically executed in response to
certain events on a particular table or view in a database</li>
<li><a href="http://www.acko.net/node/56">UFPDF</a>
- Unicode/UTF-8 extension for FPDF</li>
<li><a href="http://www.wikipedia.org/wiki/URL">URL (Uniform Resource Locator)</a>

View File

@ -58,9 +58,8 @@ PMA_DBI_select_db($db);
$rowset = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
$count = 0;
while ($row = PMA_DBI_fetch_assoc($rowset)) {
$myfieldname = 'Tables_in_' . htmlspecialchars($db);
$table = $row[$myfieldname];
while ($row = PMA_DBI_fetch_row($rowset)) {
$table = $row[0];
$comments = PMA_getComments($db, $table);
echo '<div>' . "\n";

40
db_events.php Normal file
View File

@ -0,0 +1,40 @@
<?php
/**
* Events management.
*
* @package phpMyAdmin
*/
require_once './libraries/common.inc.php';
require_once './libraries/common.lib.php';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
$GLOBALS['js_include'][] = 'db_events.js';
/**
* Create labels for the list
*/
$titles = PMA_buildActionTitles();
/**
* Displays the header
*/
require_once './libraries/db_common.inc.php';
/**
* Displays the tabs
*/
require_once './libraries/db_info.inc.php';
/**
* Displays the list of events
*/
require_once './libraries/db_events.inc.php';
/**
* Displays the footer
*/
require './libraries/footer.inc.php';
?>

View File

@ -3,10 +3,6 @@
/**
* dumps a database
*
* @uses libraries/db_common.inc.php
* @uses libraries/db_info.inc.php
* @uses libraries/display_export.lib.php
* @uses $tables from libraries/db_info.inc.php
* @package phpMyAdmin
*/

View File

@ -47,7 +47,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
// lower_case_table_names=1 `DB` becomes `db`
$lower_case_table_names = PMA_DBI_fetch_value('SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1);
if ($lower_case_table_names === '1') {
$newname = strtolower($newname);
$newname = PMA_strtolower($newname);
}
$local_query = 'CREATE DATABASE ' . PMA_backquote($newname);
@ -69,37 +69,36 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
$GLOBALS['pma']->databases->build();
}
if (PMA_MYSQL_INT_VERSION >= 50000) {
// here I don't use DELIMITER because it's not part of the
// language; I have to send each statement one by one
// here I don't use DELIMITER because it's not part of the
// language; I have to send each statement one by one
// to avoid selecting alternatively the current and new db
// we would need to modify the CREATE definitions to qualify
// the db name
$procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
if ($procedure_names) {
foreach($procedure_names as $procedure_name) {
PMA_DBI_select_db($db);
$tmp_query = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name);
// collect for later display
$GLOBALS['sql_query'] .= "\n" . $tmp_query;
PMA_DBI_select_db($newname);
PMA_DBI_query($tmp_query);
}
}
$function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
if ($function_names) {
foreach($function_names as $function_name) {
PMA_DBI_select_db($db);
$tmp_query = PMA_DBI_get_definition($db, 'FUNCTION', $function_name);
// collect for later display
$GLOBALS['sql_query'] .= "\n" . $tmp_query;
PMA_DBI_select_db($newname);
PMA_DBI_query($tmp_query);
}
// to avoid selecting alternatively the current and new db
// we would need to modify the CREATE definitions to qualify
// the db name
$procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
if ($procedure_names) {
foreach($procedure_names as $procedure_name) {
PMA_DBI_select_db($db);
$tmp_query = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name);
// collect for later display
$GLOBALS['sql_query'] .= "\n" . $tmp_query;
PMA_DBI_select_db($newname);
PMA_DBI_query($tmp_query);
}
}
$function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
if ($function_names) {
foreach($function_names as $function_name) {
PMA_DBI_select_db($db);
$tmp_query = PMA_DBI_get_definition($db, 'FUNCTION', $function_name);
// collect for later display
$GLOBALS['sql_query'] .= "\n" . $tmp_query;
PMA_DBI_select_db($newname);
PMA_DBI_query($tmp_query);
}
}
// go back to current db, just in case
PMA_DBI_select_db($db);
@ -233,7 +232,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
// to avoid selecting alternatively the current and new db
// we would need to modify the CREATE definitions to qualify
// the db name
$event_names = PMA_DBI_fetch_result('SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \'' . PMA_sqlAddslashes($db,true) . '\';');
$event_names = PMA_DBI_fetch_result('SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \'' . PMA_sqlAddSlashes($db,true) . '\';');
if ($event_names) {
foreach($event_names as $event_name) {
PMA_DBI_select_db($db);
@ -244,9 +243,10 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
PMA_DBI_query($tmp_query);
}
}
}
// go back to current db, just in case
PMA_DBI_select_db($db);
}
// go back to current db, just in case
PMA_DBI_select_db($db);
// Duplicate the bookmarks for this db (done once for each db)
if (! $_error && $db != $newname) {
@ -586,7 +586,7 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?>
$test_query = '
SELECT *
FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . '
WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
$test_rs = PMA_query_as_controluser($test_query, null, PMA_DBI_QUERY_STORE);
/*

View File

@ -53,7 +53,7 @@ if ($cfg['SkipLockedTables'] == true) {
if ($result != false && PMA_DBI_num_rows($result) > 0) {
while ($tmp = PMA_DBI_fetch_row($result)) {
if (! isset($sot_cache[$tmp[0]])) {
$sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
$sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddSlashes($tmp[0], true) . '\';');
$sts_tmp = PMA_DBI_fetch_assoc($sts_result);
$tables[] = $sts_tmp;
} else { // table in use

View File

@ -759,7 +759,7 @@ if (isset($Field) && count($Field) > 0) {
while ($ind = PMA_DBI_fetch_assoc($ind_rs)) {
$col1 = $tab . '.' . $ind['Column_name'];
if (isset($col_all[$col1])) {
if ($ind['non_unique'] == 0) {
if ($ind['Non_unique'] == 0) {
if (isset($col_where[$col1])) {
$col_unique[$col1] = 'Y';
} else {

450
db_routines.php Normal file
View File

@ -0,0 +1,450 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Routines management.
*
* @package phpMyAdmin
*/
/**
* Include required files
*/
require_once './libraries/common.inc.php';
require_once './libraries/common.lib.php';
require_once './libraries/db_routines.lib.php';
require_once './libraries/mysql_charsets.lib.php';
/**
* Include JavaScript libraries
*/
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
$GLOBALS['js_include'][] = 'db_routines.js';
/**
* Create labels for the list
*/
$titles = PMA_buildActionTitles();
if ($GLOBALS['is_ajax_request'] != true) {
/**
* Displays the header
*/
require_once './libraries/db_common.inc.php';
/**
* Displays the tabs
*/
require_once './libraries/db_info.inc.php';
} else {
if (strlen($db)) {
PMA_DBI_select_db($db);
if (! isset($url_query)) {
$url_query = PMA_generate_common_url($db);
}
}
}
/**
* Process all requests
*/
// Some definitions
$param_directions = array('IN',
'OUT',
'INOUT');
$param_opts_num = array('UNSIGNED',
'ZEROFILL',
'UNSIGNED ZEROFILL');
$param_sqldataaccess = array('NO SQL',
'CONTAINS SQL',
'READS SQL DATA',
'MODIFIES SQL DATA');
/**
* Generate the conditional classes that will be used to attach jQuery events to links.
*/
$ajax_class = array(
'add' => '',
'edit' => '',
'exec' => '',
'drop' => '',
'export' => ''
);
if ($GLOBALS['cfg']['AjaxEnable']) {
$ajax_class['add'] = 'class="add_routine_anchor"';
$ajax_class['edit'] = 'class="edit_routine_anchor"';
$ajax_class['exec'] = 'class="exec_routine_anchor"';
$ajax_class['drop'] = 'class="drop_routine_anchor"';
$ajax_class['export'] = 'class="export_routine_anchor"';
}
/**
* Keep a list of errors that occured while processing an 'Add' or 'Edit' operation.
*/
$routine_errors = array();
/**
* Handle all user requests other than the default of listing routines
*/
if (! empty($_REQUEST['execute_routine']) && ! empty($_REQUEST['routine_name'])) {
// Build the queries
$routine = PMA_RTN_getRoutineDataFromName($db, $_REQUEST['routine_name'], false);
if ($routine !== false) {
$queries = array();
$end_query = array();
$args = array();
for ($i=0; $i<$routine['num_params']; $i++) {
if (isset($_REQUEST['params'][$routine['param_name'][$i]])) {
$value = $_REQUEST['params'][$routine['param_name'][$i]];
if (is_array($value)) { // is SET type
$value = implode(',', $value);
}
$value = PMA_sqlAddSlashes($value);
if (! empty($_REQUEST['funcs'][$routine['param_name'][$i]])
&& in_array($_REQUEST['funcs'][$routine['param_name'][$i]], $cfg['Functions'])) {
$queries[] = "SET @p$i={$_REQUEST['funcs'][$routine['param_name'][$i]]}('$value');\n";
} else {
$queries[] = "SET @p$i='$value';\n";
}
$args[] = "@p$i";
} else {
$args[] = "@p$i";
}
if ($routine['type'] == 'PROCEDURE') {
if ($routine['param_dir'][$i] == 'OUT' || $routine['param_dir'][$i] == 'INOUT') {
$end_query[] = "@p$i AS " . PMA_backquote($routine['param_name'][$i]);
}
}
}
if ($routine['type'] == 'PROCEDURE') {
$queries[] = "CALL " . PMA_backquote($routine['name'])
. "(" . implode(', ', $args) . ");\n";
if (count($end_query)) {
$queries[] = "SELECT " . implode(', ', $end_query) . ";\n";
}
} else {
$queries[] = "SELECT " . PMA_backquote($routine['name'])
. "(" . implode(', ', $args) . ") "
. "AS " . PMA_backquote($routine['name']) . ";\n";
}
// Execute the queries
$affected = 0;
$result = null;
$outcome = true;
foreach ($queries as $num => $query) {
$resource = PMA_DBI_try_query($query);
if ($resource === false) {
$outcome = false;
break;
}
while (true) {
if(! PMA_DBI_more_results()) {
break;
}
PMA_DBI_next_result();
}
if (substr($query, 0, 6) == 'SELECT') {
$result = $resource;
} else if (substr($query, 0, 4) == 'CALL') {
$affected = PMA_DBI_affected_rows() - PMA_DBI_num_rows($resource);
}
}
// Generate output
if ($outcome) {
$message = __('Your SQL query has been executed successfully');
if ($routine['type'] == 'PROCEDURE') {
$message .= '<br />';
$message .= sprintf(_ngettext('%d row affected by the last statement inside the procedure', '%d rows affected by the last statement inside the procedure', $affected), $affected);
}
$message = PMA_message::success($message);
// Pass the SQL queries through the "pretty printer"
$output = '<code class="sql" style="margin-bottom: 1em;">';
$output .= PMA_SQP_formatHtml(PMA_SQP_parse(implode($queries)));
$output .= '</code>';
// Display results
if ($result) {
$output .= "<fieldset><legend>";
$output .= sprintf(__('Execution results of routine %s'),
PMA_backquote(htmlspecialchars($routine['name'])));
$output .= "</legend>";
$output .= "<table><tr>";
foreach (PMA_DBI_get_fields_meta($result) as $key => $field) {
$output .= "<th>" . htmlspecialchars($field->name) . "</th>";
}
$output .= "</tr>";
// Stored routines can only ever return ONE ROW.
$data = PMA_DBI_fetch_single_row($result);
foreach ($data as $key => $value) {
if ($value === null) {
$value = '<i>NULL</i>';
} else {
$value = htmlspecialchars($value);
}
$output .= "<td class='odd'>" . $value . "</td>";
}
$output .= "</table></fieldset>";
} else {
$notice = __('MySQL returned an empty result set (i.e. zero rows).');
$output .= PMA_message::notice($notice)->getDisplay();
}
} else {
$output = '';
$message = PMA_message::error(sprintf(__('The following query has failed: "%s"'), $query) . '<br /><br />'
. __('MySQL said: ') . PMA_DBI_getError(null));
}
// Print/send output
if ($GLOBALS['is_ajax_request']) {
$extra_data = array('dialog' => false);
PMA_ajaxResponse($message->getDisplay() . $output, $message->isSuccess(), $extra_data);
} else {
echo $message->getDisplay() . $output;
if ($message->isError()) {
// At least one query has failed, so shouldn't
// execute any more queries, so we quit.
exit;
}
unset($_POST);
// Now deliberately fall through to displaying the routines list
}
} else {
$message = __('Error in processing request') . ' : '
. sprintf(__('No routine with name %1$s found in database %2$s'),
htmlspecialchars(PMA_backquote($_REQUEST['routine_name'])),
htmlspecialchars(PMA_backquote($db)));
$message = PMA_message::error($message);
if ($GLOBALS['is_ajax_request']) {
PMA_ajaxResponse($message, $message->isSuccess());
} else {
echo $message->getDisplay();
unset($_POST);
}
}
} else if (! empty($_GET['execute_dialog']) && ! empty($_GET['routine_name'])) {
/**
* Display the execute form for a routine.
*/
$routine = PMA_RTN_getRoutineDataFromName($db, $_GET['routine_name'], false);
if ($routine !== false) {
$form = PMA_RTN_getExecuteForm($routine, $GLOBALS['is_ajax_request']);
if ($GLOBALS['is_ajax_request'] == true) {
$extra_data = array();
$extra_data['dialog'] = true;
$extra_data['title'] = __("Execute routine") . " ";
$extra_data['title'] .= PMA_backquote(htmlentities($_GET['routine_name'], ENT_QUOTES));
PMA_ajaxResponse($form, true, $extra_data);
} else {
echo "\n\n<h2>" . __("Execute routine") . "</h2>\n\n";
echo $form;
require './libraries/footer.inc.php';
// exit;
}
} else if (($GLOBALS['is_ajax_request'] == true)) {
$message = __('Error in processing request') . ' : '
. sprintf(__('No routine with name %1$s found in database %2$s'),
htmlspecialchars(PMA_backquote($_REQUEST['routine_name'])),
htmlspecialchars(PMA_backquote($db)));
$message = PMA_message::error($message);
PMA_ajaxResponse($message, false);
}
} else if (! empty($_GET['exportroutine']) && ! empty($_GET['routine_name'])) {
/**
* Display the export for a routine.
*/
$routine_name = htmlspecialchars(PMA_backquote($_GET['routine_name']));
$routine_type = PMA_DBI_fetch_value("SELECT ROUTINE_TYPE "
. "FROM INFORMATION_SCHEMA.ROUTINES "
. "WHERE ROUTINE_SCHEMA='" . PMA_sqlAddSlashes($db) . "' "
. "AND SPECIFIC_NAME='" . PMA_sqlAddSlashes($_GET['routine_name']) . "';");
if (! empty($routine_type) && $create_proc = PMA_DBI_get_definition($db, $routine_type, $_GET['routine_name'])) {
$create_proc = '<textarea cols="40" rows="15" style="width: 100%;">' . htmlspecialchars($create_proc) . '</textarea>';
if ($GLOBALS['is_ajax_request']) {
$extra_data = array('title' => sprintf(__('Export of routine %s'), $routine_name));
PMA_ajaxResponse($create_proc, true, $extra_data);
} else {
echo '<fieldset>' . "\n"
. ' <legend>' . sprintf(__('Export of routine %s'), $routine_name) . '</legend>' . "\n"
. $create_proc . "\n"
. '</fieldset>';
}
} else {
$response = __('Error in processing request') . ' : '
. sprintf(__('No routine with name %1$s found in database %2$s'),
$routine_name, htmlspecialchars(PMA_backquote($db)));
$response = PMA_message::error($response);
if ($GLOBALS['is_ajax_request']) {
PMA_ajaxResponse($response, false);
} else {
$response->display();
}
}
} else if (! empty($_REQUEST['routine_process_addroutine']) || ! empty($_REQUEST['routine_process_editroutine'])) {
/**
* Handle a request to create/edit a routine
*/
$sql_query = '';
$routine_query = PMA_RTN_getQueryFromRequest();
if (! count($routine_errors)) { // set by PMA_RTN_getQueryFromRequest()
// Execute the created query
if (! empty($_REQUEST['routine_process_editroutine'])) {
if (! in_array($_REQUEST['routine_original_type'], array('PROCEDURE', 'FUNCTION'))) {
$routine_errors[] = sprintf(__('Invalid routine type: "%s"'), htmlspecialchars($_REQUEST['routine_original_type']));
} else {
// Backup the old routine, in case something goes wrong
$create_routine = PMA_DBI_get_definition($db, $_REQUEST['routine_original_type'], $_REQUEST['routine_original_name']);
$drop_routine = "DROP {$_REQUEST['routine_original_type']} " . PMA_backquote($_REQUEST['routine_original_name']) . ";\n";
$result = PMA_DBI_try_query($drop_routine);
if (! $result) {
$routine_errors[] = sprintf(__('The following query has failed: "%s"'), $drop_routine) . '<br />'
. __('MySQL said: ') . PMA_DBI_getError(null);
} else {
$result = PMA_DBI_try_query($routine_query);
if (! $result) {
$routine_errors[] = sprintf(__('The following query has failed: "%s"'), $routine_query) . '<br />'
. __('MySQL said: ') . PMA_DBI_getError(null);
// We dropped the old routine, but were unable to create the new one
// Try to restore the backup query
$result = PMA_DBI_try_query($create_routine);
if (! $result) {
// OMG, this is really bad! We dropped the query, failed to create a new one
// and now even the backup query does not execute!
// This should not happen, but we better handle this just in case.
$routine_errors[] = __('Sorry, we failed to restore the dropped routine.') . '<br />'
. __('The backed up query was:') . "\"$create_routine\"" . '<br />'
. __('MySQL said: ') . PMA_DBI_getError(null);
}
} else {
$message = PMA_Message::success(__('Routine %1$s has been modified.'));
$message->addParam(PMA_backquote($_REQUEST['routine_name']));
$sql_query = $drop_routine . $routine_query;
}
}
}
} else {
// 'Add a new routine' mode
$result = PMA_DBI_try_query($routine_query);
if (! $result) {
$routine_errors[] = sprintf(__('The following query has failed: "%s"'), $routine_query) . '<br /><br />'
. __('MySQL said: ') . PMA_DBI_getError(null);
} else {
$message = PMA_Message::success(__('Routine %1$s has been created.'));
$message->addParam(PMA_backquote($_REQUEST['routine_name']));
$sql_query = $routine_query;
}
}
}
if (count($routine_errors)) {
$message = PMA_Message::error(__('<b>One or more errors have occured while processing your request:</b>'));
$message->addString('<ul>');
foreach ($routine_errors as $num => $string) {
$message->addString('<li>' . $string . '</li>');
}
$message->addString('</ul>');
}
$output = PMA_showMessage($message, $sql_query);
if ($GLOBALS['is_ajax_request']) {
$extra_data = array();
if ($message->isSuccess()) {
$columns = "`SPECIFIC_NAME`, `ROUTINE_NAME`, `ROUTINE_TYPE`, `DTD_IDENTIFIER`, `ROUTINE_DEFINITION`";
$where = "ROUTINE_SCHEMA='" . PMA_sqlAddSlashes($db) . "' AND ROUTINE_NAME='" . PMA_sqlAddSlashes($_REQUEST['routine_name']) . "'";
$routine = PMA_DBI_fetch_single_row("SELECT $columns FROM `INFORMATION_SCHEMA`.`ROUTINES` WHERE $where;");
$extra_data['name'] = htmlspecialchars(strtoupper($_REQUEST['routine_name']));
$extra_data['new_row'] = PMA_RTN_getRowForRoutinesList($routine, 0, true);
$response = $output;
} else {
$response = $message;
}
PMA_ajaxResponse($response, $message->isSuccess(), $extra_data);
}
}
/**
* Display a form used to add/edit a routine, if necessary
*/
if (count($routine_errors) || ( empty($_REQUEST['routine_process_addroutine']) && empty($_REQUEST['routine_process_editroutine']) &&
(! empty($_REQUEST['addroutine']) || ! empty($_REQUEST['editroutine'])
|| ! empty($_REQUEST['routine_addparameter']) || ! empty($_REQUEST['routine_removeparameter'])
|| ! empty($_REQUEST['routine_changetype'])))) { // FIXME: this must be simpler than that
// Handle requests to add/remove parameters and changing routine type
// This is necessary when JS is disabled
$operation = '';
if (! empty($_REQUEST['routine_addparameter'])) {
$operation = 'add';
} else if (! empty($_REQUEST['routine_removeparameter'])) {
$operation = 'remove';
} else if (! empty($_REQUEST['routine_changetype'])) {
$operation = 'change';
}
// Get the data for the form (if any)
if (! empty($_REQUEST['addroutine'])) {
$title = __("Create routine");
$routine = PMA_RTN_getRoutineDataFromRequest();
$mode = 'add';
} else if (! empty($_REQUEST['editroutine'])) {
$title = __("Edit routine");
if (! $operation && ! empty($_REQUEST['routine_name']) && empty($_REQUEST['routine_process_editroutine'])) {
$routine = PMA_RTN_getRoutineDataFromName($db, $_REQUEST['routine_name']);
if ($routine !== false) {
$routine['original_name'] = $routine['name'];
$routine['original_type'] = $routine['type'];
}
} else {
$routine = PMA_RTN_getRoutineDataFromRequest();
}
$mode = 'edit';
}
if ($routine !== false) {
// Show form
$editor = PMA_RTN_getEditorForm($mode, $operation, $routine, $routine_errors, $GLOBALS['is_ajax_request']);
if ($GLOBALS['is_ajax_request']) {
$template = PMA_RTN_getParameterRow();
$extra_data = array('title' => $title, 'param_template' => $template, 'type' => $routine['type']);
PMA_ajaxResponse($editor, true, $extra_data);
}
echo "\n\n<h2>$title</h2>\n\n$editor";
require './libraries/footer.inc.php';
// exit;
} else {
$message = __('Error in processing request') . ' : '
. sprintf(__('No routine with name %1$s found in database %2$s'),
htmlspecialchars(PMA_backquote($_REQUEST['routine_name'])),
htmlspecialchars(PMA_backquote($db)));
$message = PMA_message::error($message);
if ($GLOBALS['is_ajax_request']) {
PMA_ajaxResponse($message, false);
} else {
$message->display();
}
}
}
/**
* Display a list of available routines
*/
echo PMA_RTN_getRoutinesList();
/**
* Display the form for adding a new routine, if the user has the privileges.
*/
echo PMA_RTN_getAddRoutineLink();
/**
* Display a warning for users with PHP's old "mysql" extension.
*/
if ($GLOBALS['cfg']['Server']['extension'] === 'mysql') {
trigger_error(__('You are using PHP\'s deprecated \'mysql\' extension, '
. 'which is not capable of handling multi queries. '
. '<b>The execution of some stored routines may fail!</b> '
. 'Please use the improved \'mysqli\' extension to '
. 'avoid any problems.'), E_USER_WARNING);
}
if ($GLOBALS['is_ajax_request'] != true) {
/**
* Displays the footer
*/
require './libraries/footer.inc.php';
}
?>

View File

@ -5,30 +5,6 @@
*
* @todo make use of UNION when searching multiple tables
* @todo display executed query, optional?
* @uses $cfg['UseDbSearch']
* @uses $GLOBALS['db']
* @uses PMA_DBI_get_tables()
* @uses PMA_sqlAddslashes()
* @uses PMA_getSearchSqls()
* @uses PMA_DBI_fetch_value()
* @uses PMA_linkOrButton()
* @uses PMA_generate_common_url()
* @uses PMA_generate_common_hidden_inputs()
* @uses PMA_showMySQLDocu()
* @uses $_REQUEST['search_str']
* @uses $_REQUEST['submit_search']
* @uses $_REQUEST['search_option']
* @uses $_REQUEST['table_select']
* @uses $_REQUEST['unselectall']
* @uses $_REQUEST['selectall']
* @uses $_REQUEST['field_str']
* @uses is_string()
* @uses htmlspecialchars()
* @uses array_key_exists()
* @uses is_array()
* @uses array_intersect()
* @uses sprintf()
* @uses in_array()
* @package phpMyAdmin
*/
@ -38,6 +14,8 @@
require_once './libraries/common.inc.php';
$GLOBALS['js_include'][] = 'db_search.js';
$GLOBALS['js_include'][] = 'sql.js';
$GLOBALS['js_include'][] = 'makegrid.js';
/**
* Gets some core libraries and send headers
@ -83,11 +61,11 @@ if (empty($_REQUEST['search_str']) || ! is_string($_REQUEST['search_str'])) {
$searched = htmlspecialchars($_REQUEST['search_str']);
// For "as regular expression" (search option 4), we should not treat
// this as an expression that contains a LIKE (second parameter of
// PMA_sqlAddslashes()).
// PMA_sqlAddSlashes()).
//
// Usage example: If user is seaching for a literal $ in a regexp search,
// he should enter \$ as the value.
$search_str = PMA_sqlAddslashes($_REQUEST['search_str'], ($search_option == 4 ? false : true));
$search_str = PMA_sqlAddSlashes($_REQUEST['search_str'], ($search_option == 4 ? false : true));
}
$tables_selected = array();
@ -106,7 +84,7 @@ if (isset($_REQUEST['selectall'])) {
if (empty($_REQUEST['field_str']) || ! is_string($_REQUEST['field_str'])) {
unset($field_str);
} else {
$field_str = PMA_sqlAddslashes($_REQUEST['field_str'], true);
$field_str = PMA_sqlAddSlashes($_REQUEST['field_str'], true);
}
/**
@ -128,7 +106,6 @@ if (isset($_REQUEST['submit_search'])) {
* Builds the SQL search query
*
* @todo can we make use of fulltextsearch IN BOOLEAN MODE for this?
* @uses PMA_DBI_query
* PMA_backquote
* PMA_DBI_free_result
* PMA_DBI_fetch_assoc
@ -295,7 +272,7 @@ else {
<legend><?php echo __('Search in database'); ?></legend>
<table class="formlayout">
<tr><td><?php echo __('Word(s) or value(s) to search for (wildcard: "%"):'); ?></td>
<tr><td><?php echo __('Words or values to search for (wildcard: "%"):'); ?></td>
<td><input type="text" name="search_str" size="60"
value="<?php echo $searched; ?>" /></td>
</tr>
@ -318,7 +295,7 @@ unset($choices);
</td>
</tr>
<tr><td align="right" valign="top">
<?php echo __('Inside table(s):'); ?></td>
<?php echo __('Inside tables:'); ?></td>
<td rowspan="2">
<?php
echo ' <select name="table_select[]" size="6" multiple="multiple">' . "\n";

View File

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

View File

@ -12,6 +12,7 @@ require_once './libraries/common.inc.php';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
$GLOBALS['js_include'][] = 'db_structure.js';
$GLOBALS['js_include'][] = 'tbl_change.js';
/**
* Prepares the tables list if the user where not redirected to this script
@ -58,14 +59,6 @@ $titles = PMA_buildActionTitles();
if ($num_tables == 0) {
echo '<p>' . __('No tables found in database') . '</p>' . "\n";
// Routines
require './libraries/db_routines.inc.php';
// Events
if (PMA_MYSQL_INT_VERSION > 50100) {
require './libraries/db_events.inc.php';
}
if (empty($db_is_information_schema)) {
require './libraries/display_create_table.lib.php';
} // end if (Create Table dialog)
@ -354,8 +347,8 @@ foreach ($tables as $keyname => $each_table) {
<?php echo $titles['Structure']; ?></a></td>
<td align="center"><?php echo $search_table; ?></td>
<?php if (! $db_is_information_schema) { ?>
<td align="center">
<a href="tbl_change.php?<?php echo $tbl_url_query; ?>">
<td align="center" class="insert_table">
<a <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'class="ajax"' : ''); ?> href="tbl_change.php?<?php echo $tbl_url_query; ?>">
<?php echo $titles['Insert']; ?></a></td>
<td align="center"><?php echo $empty_table; ?></td>
<td align="center">
@ -545,13 +538,6 @@ PMA_listNavigator($total_num_tables, $pos, $_url_params, 'db_structure.php', 'fr
<hr />
<?php
// Routines
require './libraries/db_routines.inc.php';
// Events
if (PMA_MYSQL_INT_VERSION > 50100) {
require './libraries/db_events.inc.php';
}
/**
* Work on the database

View File

@ -67,7 +67,7 @@ require_once './libraries/db_links.inc.php';
$all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
' WHERE ' . PMA_backquote('db_name') . ' = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' ' .
' WHERE ' . PMA_backquote('db_name') . ' = \'' . PMA_sqlAddSlashes($_REQUEST['db']) . '\' ' .
' GROUP BY '. PMA_backquote('table_name') .
' ORDER BY '. PMA_backquote('table_name') .' ASC';
@ -110,7 +110,7 @@ if (PMA_DBI_num_rows($all_tables_result) > 0) {
$table_query = ' SELECT * FROM ' .
PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
' WHERE `db_name` = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' AND `table_name` = \'' . PMA_sqlAddslashes($table_name) . '\' AND `version` = \'' . $version_number . '\'';
' WHERE `db_name` = \'' . PMA_sqlAddSlashes($_REQUEST['db']) . '\' AND `table_name` = \'' . PMA_sqlAddSlashes($table_name) . '\' AND `version` = \'' . $version_number . '\'';
$table_result = PMA_query_as_controluser($table_query);
$version_data = PMA_DBI_fetch_array($table_result);

38
db_triggers.php Normal file
View File

@ -0,0 +1,38 @@
<?php
/**
*
*/
require_once './libraries/common.inc.php';
require_once './libraries/common.lib.php';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
$GLOBALS['js_include'][] = 'display_triggers.js';
/**
* Create labels for the list
*/
$titles = PMA_buildActionTitles();
/**
* Displays the header
*/
require_once './libraries/db_common.inc.php';
/**
* Displays the tabs
*/
require_once './libraries/db_info.inc.php';
/**
* Displays the list of triggers
*/
require_once './libraries/display_triggers.inc.php';
/**
* Displays the footer
*/
require './libraries/footer.inc.php';
?>

View File

@ -53,12 +53,12 @@ require_once './libraries/header_meta_style.inc.php';
?>
</div>
<p>
<a href="enum_editor.php?token=<?php echo urlencode($_GET['token']); ?>&field=<?php echo urlencode($_GET['field']); ?>&extra_fields=<?php echo $_GET['extra_fields'] + 1; ?>&values=<?php echo urlencode(join(",", $values)); ?>">
<a href="enum_editor.php<?php echo PMA_generate_common_url(array('field' => $_GET['field'], 'extra_fields' => $_GET['extra_fields'] + 1, 'values' => join(',', $values))); ?>">
<?php echo __('+ Restart insertion and add a new value'); ?>
</a>
</p>
<input type="hidden" name="token" value="<?php echo $_GET['token']; ?>" />
<input type="hidden" name="field" value="<?php echo $_GET['field']; ?>" />
<?php echo PMA_generate_common_hidden_inputs(); ?>
<input type="hidden" name="field" value="<?php echo htmlspecialchars($_GET['field']); ?>" />
<input type="hidden" name="num_fields" value="<?php echo $total_fields; ?>" />
<input type="submit" value="<?php echo __('Go'); ?>" />
</form>
@ -66,7 +66,7 @@ require_once './libraries/header_meta_style.inc.php';
<div id="enum_editor_output">
<h3><?php echo __('Output'); ?></h3>
<p><?php echo __('Copy and paste the joined values into the "Length/Values" field'); ?></p>
<textarea id="joined_values" cols="95" rows="5"><?php echo join(",", $values); ?></textarea>
<textarea id="joined_values" cols="95" rows="5"><?php echo htmlspecialchars(join(",", $values)); ?></textarea>
</div>
</div>
</body>

View File

@ -3,7 +3,6 @@
/**
* Core script for import, this is just the glue around all other stuff
*
* @uses PMA_Bookmark_getList()
* @package phpMyAdmin
*/
@ -108,7 +107,7 @@ if ($import_type == 'table') {
}
$err_url = $goto
. '?' . $common
. (preg_match('@^tbl_[a-z]*\.php$@', $goto) ? '&amp;table=' . urlencode($table) : '');
. (preg_match('@^tbl_[a-z]*\.php$@', $goto) ? '&amp;table=' . htmlspecialchars($table) : '');
$_SESSION['Import_message']['go_back_url'] = $err_url;
}
@ -154,7 +153,7 @@ if (!empty($id_bookmark)) {
case 0: // bookmarked query that have to be run
$import_text = PMA_Bookmark_get($db, $id_bookmark, 'id', isset($action_bookmark_all));
if (isset($bookmark_variable) && !empty($bookmark_variable)) {
$import_text = preg_replace('|/\*(.*)\[VARIABLE\](.*)\*/|imsU', '${1}' . PMA_sqlAddslashes($bookmark_variable) . '${2}', $import_text);
$import_text = preg_replace('|/\*(.*)\[VARIABLE\](.*)\*/|imsU', '${1}' . PMA_sqlAddSlashes($bookmark_variable) . '${2}', $import_text);
}
// refresh left frame on changes in table or db structure

View File

@ -3,26 +3,7 @@
/**
* forms frameset
*
* @uses $GLOBALS['cfg']['QueryHistoryDB']
* @uses $GLOBALS['cfg']['Server']['user']
* @uses $GLOBALS['cfg']['DefaultTabServer'] as src for the mainframe
* @uses $GLOBALS['cfg']['DefaultTabDatabase'] as src for the mainframe
* @uses $GLOBALS['cfg']['NaviWidth'] for navi frame width
* @uses $GLOBALS['collation_connection'] from $_REQUEST (grab_globals.lib.php)
* or common.inc.php
* @uses $GLOBALS['available_languages'] from common.inc.php (select_lang.lib.php)
* @uses $GLOBALS['db']
* @uses $GLOBALS['lang']
* @uses $GLOBALS['text_dir']
* @uses $_ENV['HTTP_HOST']
* @uses PMA_getRelationsParam()
* @uses PMA_purgeHistory()
* @uses PMA_generate_common_url()
* @uses PMA_VERSION
* @uses session_write_close()
* @uses time()
* @uses PMA_getenv()
* @uses header() to send charset
* @package phpMyAdmin
*/
@ -73,7 +54,7 @@ if (! strlen($GLOBALS['db'])) {
} else {
$_GET['db'] = $GLOBALS['db'];
$_GET['table'] = $GLOBALS['table'];
$main_target = $GLOBALS['cfg']['DefaultTabTable'];
$main_target = isset($GLOBALS['goto']) ? $GLOBALS['goto'] : $GLOBALS['cfg']['DefaultTabTable'];
}
$url_query = PMA_generate_common_url($_GET);

View File

@ -50,7 +50,7 @@ function setFieldValue(field, field_type, value) {
field.attr('checked', (value != undefined ? value : field.attr('defaultChecked')));
break;
case 'select':
var options = field.attr('options');
var options = field.prop('options');
var i, imax = options.length;
if (value == undefined) {
for (i = 0; i < imax; i++) {

2
js/db_events.js Normal file
View File

@ -0,0 +1,2 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */

568
js/db_routines.js Normal file
View File

@ -0,0 +1,568 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Validate routine editor form fields.
*
* @param syntaxHiglighter an object containing the reference to the
* codemirror editor. This will be used to
* focus the form on the codemirror editor
* if it contains invalid data.
*/
function validateRoutineEditor(syntaxHiglighter) {
/**
* @var inputname Will contain the value of the name
* attribute of input fields being checked.
*/
var inputname = '';
/**
* @var $elm a jQuery object containing the reference
* to an element that is being validated.
*/
var $elm = null;
/**
* @var isError Stores the outcome of the validation.
*/
var isError = false;
$elm = $('.rte_table').last().find('input[name=routine_name]');
if ($elm.val() == '') {
$elm.focus();
isError = true;
} else if ($elm.val().length > 64) {
alert(PMA_messages['strValueTooLong']);
$elm.focus().select();
return false;
}
if (! isError) {
$elm = $('.rte_table').find('textarea[name=routine_definition]');
if ($elm.val() == '') {
syntaxHiglighter.focus();
isError = true;
}
}
if (! isError) {
$('.routine_params_table').last().find('tr').each(function() {
if (! isError) {
$(this).find(':input').each(function() {
inputname = $(this).attr('name');
if (inputname.substr(0, 17) == 'routine_param_dir' ||
inputname.substr(0, 18) == 'routine_param_name' ||
inputname.substr(0, 18) == 'routine_param_type') {
if ($(this).val() == '') {
$(this).focus();
isError = true;
return false;
}
}
});
}
});
}
if (! isError) {
// SET, ENUM, VARCHAR and VARBINARY fields must have length/values
$('.routine_params_table').last().find('tr').each(function() {
var $inputtyp = $(this).find('select[name^=routine_param_type]');
var $inputlen = $(this).find('input[name^=routine_param_length]');
if ($inputtyp.length && $inputlen.length) {
if (($inputtyp.val() == 'ENUM' || $inputtyp.val() == 'SET' || $inputtyp.val().substr(0,3) == 'VAR')
&& $inputlen.val() == '') {
$inputlen.focus();
isError = true;
return false;
}
}
});
}
if (! isError && $('select[name=routine_type]').find(':selected').val() == 'FUNCTION') {
// The length/values of return variable for functions must
// be set, if the type is SET, ENUM, VARCHAR or VARBINARY.
var $returntyp = $('select[name=routine_returntype]');
var $returnlen = $('input[name=routine_returnlength]');
if (($returntyp.val() == 'ENUM' || $returntyp.val() == 'SET' || $returntyp.val().substr(0,3) == 'VAR')
&& $returnlen.val() == '') {
$returnlen.focus();
isError = true;
}
}
if (! isError && $('select[name=routine_type]').find(':selected').val() == 'FUNCTION') {
if ($('.rte_table').find('textarea[name=routine_definition]').val().toLowerCase().indexOf('return') < 0) {
syntaxHiglighter.focus();
alert(PMA_messages['MissingReturn']);
return false;
}
}
if (! isError) {
$elm = $('.rte_table').last().find('input[name=routine_comment]');
if ($elm.val().length > 64) {
alert(PMA_messages['strValueTooLong']);
$elm.focus().select();
return false;
}
}
if (! isError) {
return true;
} else {
alert(PMA_messages['strFormEmpty']);
return false;
}
} // end validateRoutineEditor()
/**
* Enable/disable the "options" dropdown and "length" input for
* parameters and the return variable in the routine editor
* as necessary.
*
* @param $type a jQuery object containing the reference
* to the "Type" dropdown box
* @param $len a jQuery object containing the reference
* to the "Length" input box
* @param $text a jQuery object containing the reference
* to the dropdown box with options for
* parameters of text type
* @param $num a jQuery object containing the reference
* to the dropdown box with options for
* parameters of numeric type
*/
function setOptionsForParameter($type, $len, $text, $num) {
// Process for parameter options
switch ($type.val()) {
case 'TINYINT':
case 'SMALLINT':
case 'MEDIUMINT':
case 'INT':
case 'BIGINT':
case 'DECIMAL':
case 'FLOAT':
case 'DOUBLE':
case 'REAL':
$text.parent().hide();
$num.parent().show();
break;
case 'TINYTEXT':
case 'TEXT':
case 'MEDIUMTEXT':
case 'LONGTEXT':
case 'CHAR':
case 'VARCHAR':
case 'SET':
case 'ENUM':
$text.parent().show();
$text.show();
$num.parent().hide();
break;
default:
$text.parent().show();
$text.hide();
$num.parent().hide();
break;
}
// Process for parameter length
switch ($type.val()) {
case 'DATE':
case 'DATETIME':
case 'TIME':
case 'TINYBLOB':
case 'TINYTEXT':
case 'BLOB':
case 'TEXT':
case 'MEDIUMBLOB':
case 'MEDIUMTEXT':
case 'LONGBLOB':
case 'LONGTEXT':
$len.hide();
break;
default:
$len.show();
break;
}
}
/**
* Attach Ajax event handlers for the Routines functionalities.
*
* @see $cfg['AjaxEnable']
*/
$(document).ready(function() {
/**
* @var $ajaxDialog jQuery object containing the reference to the
* dialog that contains the routine editor.
*/
var $ajaxDialog = null;
/**
* @var param_template This variable contains the template for one row
* of the parameters table that is attached to the
* dialog when a new parameter is added.
*/
var param_template = '';
/**
* @var syntaxHiglighter Reference to the codemirror editor.
*/
var syntaxHiglighter = null;
/**
* @var button_options Object containing options for jQueryUI dialog buttons
*/
var button_options = {};
/**
* Attach Ajax event handlers for the Add/Edit routine functionality.
*
* @uses PMA_ajaxShowMessage()
* @uses PMA_ajaxRemoveMessage()
*
* @see $cfg['AjaxEnable']
*/
$('.add_routine_anchor, .edit_routine_anchor').live('click', function(event) {
event.preventDefault();
/**
* @var $edit_row jQuery object containing the reference to
* the row of the the routine being edited
* from the list of routines .
*/
var $edit_row = null;
if ($(this).hasClass('edit_routine_anchor')) {
// Remeber the row of the routine being edited for later,
// so that if the edit is successful, we can replace the
// row with info about the modified routine.
$edit_row = $(this).parents('tr');
}
/**
* @var $msg jQuery object containing the reference to
* the AJAX message shown to the user.
*/
var $msg = PMA_ajaxShowMessage(PMA_messages['strLoading']);
$.get($(this).attr('href'), {'ajax_request': true}, function(data) {
if(data.success == true) {
PMA_ajaxRemoveMessage($msg);
button_options[PMA_messages['strGo']] = function() {
syntaxHiglighter.save();
// Validate editor and submit request, if passed.
if (validateRoutineEditor(syntaxHiglighter)) {
/**
* @var data Form data to be sent in the AJAX request.
*/
var data = $('.rte_form').last().serialize();
$msg = PMA_ajaxShowMessage(PMA_messages['strLoading']);
$.post('db_routines.php', data, function (data) {
if(data.success == true) {
// Routine created successfully
PMA_ajaxRemoveMessage($msg);
PMA_slidingMessage(data.message);
$ajaxDialog.dialog('close');
// If we are in 'edit' mode, we must remove the reference to the old row.
if (mode == 'edit') {
$edit_row.remove();
}
// Insert the new row at the correct location in the list of routines
/**
* @var text Contains the name of a routine from the list
* that is used in comparisons to find the correct
* location where to insert a new row.
*/
var text = '';
/**
* @var inserted Whether a new has been inserted
* in the list of routines or not.
*/
var inserted = false;
$('table.data').find('tr').each(function() {
text = $(this).children('td').eq(0).find('strong').text().toUpperCase();
if (text != '' && text > data.name) {
$(this).before(data.new_row);
inserted = true;
return false;
}
});
if (! inserted) {
$('table.data').append(data.new_row);
}
// Fade-in the new row
$('.ajaxInsert').show('slow').removeClass('ajaxInsert');
// Now we have inserted the row at the correct position, but surely
// at least some row classes are wrong now. So we will itirate
// throught all rows and assign correct classes to them.
/**
* @var ct Count of processed rows.
*/
var ct = 0;
$('table.data').find('tr').has('td').each(function() {
rowclass = (ct % 2 == 0) ? 'even' : 'odd';
$(this).removeClass().addClass(rowclass);
ct++;
});
// If this is the first routine being added, remove the
// "No routines" message and show the list of routines.
if ($('table.data').find('tr').has('td').length > 0 && $('#nothing2display').is(':visible')) {
$('#nothing2display').hide("slow", function () {
$('table.data').show("slow");
});
}
} else {
PMA_ajaxShowMessage(data.error);
}
});
}
} // end of function that handles the submission of the Editor
button_options[PMA_messages['strClose']] = function() {
$(this).dialog("close");
}
/**
* Display the dialog to the user
*/
$ajaxDialog = $('<div>'+data.message+'</div>').dialog({
width: 700, // TODO: make a better decision about the size
height: 550, // of the dialog based on the size of the viewport
buttons: button_options,
title: data.title,
modal: true,
close: function () {
$(this).remove();
}
});
$ajaxDialog.find('input[name=routine_name]').focus();
/**
* @var mode Used to remeber whether the editor is in
* "Edit Routine" or "Add Routine" mode.
*/
var mode = 'add';
if ($('input[name=routine_process_editroutine]').length > 0) {
mode = 'edit';
}
// Cache the template for a parameter table row
param_template = data.param_template;
// Make adjustments in the dialog to make it AJAX compatible
$('.routine_param_remove').show();
$('input[name=routine_removeparameter]').remove();
$('input[name=routine_addparameter]').css('width', '100%');
// Enable/disable the 'options' dropdowns for parameters as necessary
$('.routine_params_table').last().find('th[colspan=2]').attr('colspan', '1');
$('.routine_params_table').last().find('tr').has('td').each(function() {
setOptionsForParameter(
$(this).find('select[name^=routine_param_type]'),
$(this).find('input[name^=routine_param_length]'),
$(this).find('select[name^=routine_param_opts_text]'),
$(this).find('select[name^=routine_param_opts_num]')
);
});
// Enable/disable the 'options' dropdowns for function return value as necessary
setOptionsForParameter(
$('.rte_table').last().find('select[name=routine_returntype]'),
$('.rte_table').last().find('input[name=routine_returnlength]'),
$('.rte_table').last().find('select[name=routine_returnopts_text]'),
$('.rte_table').last().find('select[name=routine_returnopts_num]')
);
// Attach syntax highlited editor to routine definition
/**
* @var $elm jQuery object containing the reference to
* the "Routine Definition" textarea.
*/
var $elm = $('textarea[name=routine_definition]').last();
/**
* @var opts Options to pass to the codemirror editor.
*/
var opts = {lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql"};
syntaxHiglighter = CodeMirror.fromTextArea($elm[0], opts);
// Hack to prevent the syntax highlighter from expanding beyond dialog boundries
$('.CodeMirror-scroll').find('div').first().css('width', '1px');
} else {
PMA_ajaxShowMessage(data.error);
}
}) // end $.get()
}); // end $.live()
/**
* Attach Ajax event handlers for the "Add parameter to routine" functionality.
*
* @see $cfg['AjaxEnable']
*/
$('input[name=routine_addparameter]').live('click', function(event) {
event.preventDefault();
/**
* @var $routine_params_table jQuery object containing the reference
* to the routine parameters table.
*/
var $routine_params_table = $('.routine_params_table').last();
/**
* @var $new_param_row A string containing the HTML code for the
* new row for the routine paramaters table.
*/
var new_param_row = param_template.replace(/%s/g, $routine_params_table.find('tr').length-1);
$routine_params_table.append(new_param_row);
if ($('.rte_table').find('select[name=routine_type]').val() == 'FUNCTION') {
$('.routine_return_row').show();
$('.routine_direction_cell').hide();
}
/**
* @var $newrow jQuery object containing the reference to the newly
* inserted row in the routine parameters table.
*/
var $newrow = $('.routine_params_table').last().find('tr').has('td').last();
setOptionsForParameter(
$newrow.find('select[name^=routine_param_type]'),
$newrow.find('input[name^=routine_param_length]'),
$newrow.find('select[name^=routine_param_opts_text]'),
$newrow.find('select[name^=routine_param_opts_num]')
);
}); // end $.live()
/**
* Attach Ajax event handlers for the "Remove parameter from routine" functionality.
*
* @see $cfg['AjaxEnable']
*/
$('.routine_param_remove_anchor').live('click', function (event) {
event.preventDefault();
$(this).parent().parent().remove();
// After removing a parameter, the indices of the name attributes in
// the input fields lose the correct order and need to be reordered.
/**
* @var index Counter used for reindexing the input
* fields in the routine parameters table.
*/
var index = 0;
$('.routine_params_table').last().find('tr').has('td').each(function() {
$(this).find(':input').each(function() {
/**
* @var inputname The value of the name attribute of
* the input field being reindexed.
*/
var inputname = $(this).attr('name');
if (inputname.substr(0, 17) == 'routine_param_dir') {
$(this).attr('name', inputname.substr(0, 17) + '[' + index + ']');
} else if (inputname.substr(0, 18) == 'routine_param_name') {
$(this).attr('name', inputname.substr(0, 18) + '[' + index + ']');
} else if (inputname.substr(0, 18) == 'routine_param_type') {
$(this).attr('name', inputname.substr(0, 18) + '[' + index + ']');
} else if (inputname.substr(0, 20) == 'routine_param_length') {
$(this).attr('name', inputname.substr(0, 20) + '[' + index + ']');
} else if (inputname.substr(0, 23) == 'routine_param_opts_text') {
$(this).attr('name', inputname.substr(0, 23) + '[' + index + ']');
} else if (inputname.substr(0, 22) == 'routine_param_opts_num') {
$(this).attr('name', inputname.substr(0, 22) + '[' + index + ']');
}
});
index++;
});
}); // end $.live()
/**
* Attach Ajax event handlers for the "Change routine type" functionality.
*
* @see $cfg['AjaxEnable']
*/
$('select[name=routine_type]').live('change', function() {
$('.routine_return_row, .routine_direction_cell').toggle();
}); // end $.live()
/**
* Attach Ajax event handlers for the "Change parameter type" functionality.
*
* @see $cfg['AjaxEnable']
*/
$('select[name^=routine_param_type]').live('change', function() {
/**
* @var $row jQuery object containing the reference to
* a row in the routine parameters table.
*/
var $row = $(this).parents('tr').first();
setOptionsForParameter(
$row.find('select[name^=routine_param_type]'),
$row.find('input[name^=routine_param_length]'),
$row.find('select[name^=routine_param_opts_text]'),
$row.find('select[name^=routine_param_opts_num]')
);
});
/**
* Attach Ajax event handlers for the "Change the type of return
* variable of function" functionality.
*
* @see $cfg['AjaxEnable']
*/
$('select[name=routine_returntype]').live('change', function() {
setOptionsForParameter(
$('.rte_table').find('select[name=routine_returntype]'),
$('.rte_table').find('input[name=routine_returnlength]'),
$('.rte_table').find('select[name=routine_returnopts_text]'),
$('.rte_table').find('select[name=routine_returnopts_num]')
);
});
/**
* Attach Ajax event handlers for the Execute routine functionality.
*
* @uses PMA_ajaxShowMessage()
* @uses PMA_ajaxRemoveMessage()
*
* @see $cfg['AjaxEnable']
*/
$('.exec_routine_anchor').live('click', function(event) {
event.preventDefault();
/**
* @var $msg jQuery object containing the reference to
* the AJAX message shown to the user.
*/
var $msg = PMA_ajaxShowMessage(PMA_messages['strLoading']);
$.get($(this).attr('href'), {'ajax_request': true}, function(data) {
if(data.success == true) {
PMA_ajaxRemoveMessage($msg);
if (data.dialog) {
button_options[PMA_messages['strGo']] = function() {
/**
* @var data Form data to be sent in the AJAX request.
*/
var data = $('.rte_form').last().serialize();
$msg = PMA_ajaxShowMessage(PMA_messages['strLoading']);
$.post('db_routines.php', data, function (data) {
if(data.success == true) {
// Routine executed successfully
PMA_ajaxRemoveMessage($msg);
PMA_slidingMessage(data.message);
$ajaxDialog.dialog('close');
} else {
PMA_ajaxShowMessage(data.error);
}
});
}
button_options[PMA_messages['strClose']] = function() {
$(this).dialog("close");
}
/**
* Display the dialog to the user
*/
$ajaxDialog = $('<div>'+data.message+'</div>').dialog({
width: 650, // TODO: make a better decision about the size
// of the dialog based on the size of the viewport
buttons: button_options,
title: data.title,
modal: true,
close: function () {
$(this).remove();
}
});
$ajaxDialog.find('input[name^=params]').first().focus();
} else {
// Routine executed successfully
PMA_slidingMessage(data.message);
}
} else {
PMA_ajaxShowMessage(data.error);
}
});
});
/**
* Attach Ajax event handlers for input fields in the routines editor
* and the routine execution dialog used to submit the Ajax request
* when the ENTER key is pressed.
*
* @see $cfg['AjaxEnable']
*/
$('input[name^=routine], input[name^=params]').live('keydown', function(e) {
if (e.which == 13) {
e.preventDefault();
if (typeof button_options[PMA_messages['strGo']] == 'function') {
button_options[PMA_messages['strGo']].call();
}
}
});
}); // end of $(document).ready() for the Routine Functionalities

View File

@ -26,7 +26,14 @@ function loadResult(result_path , table_name , link , ajaxEnable){
/** Load the browse results to the page */
$("#table-info").show();
$('#table-link').attr({"href" : 'sql.php?'+link }).text(table_name);
$('#browse-results').load(result_path + " '"+'#sqlqueryresults' + "'").show();
$('#browse-results').load(result_path + " '"+'#sqlqueryresults' + "'", null, function() {
// because under db_search, window.parent.table is not defined yet,
// we assign it manually from #table-link
window.parent.table = $('#table-link').text().trim();
appendInlineAnchor();
$('#table_results').makegrid();
}).show();
}
else
{
@ -173,7 +180,6 @@ $(document).ready(function() {
if (typeof response == 'string') {
// found results
$("#searchresults").html(response);
$("#sqlqueryresults").trigger('appendAnchor');
$('#togglesearchresultlink')
// always start with the Show message

View File

@ -10,7 +10,7 @@
/**
* AJAX scripts for db_structure.php
*
*
* Actions ajaxified here:
* Drop Database
* Truncate Table
@ -33,7 +33,7 @@ function PMA_adjustTotals($this_anchor) {
// (not really needed in case we are dropping the table)
$rows_td.text('0');
// set size to unknown (not sure how to get the exact
// value here, as an empty InnoDB table would have a size)
// value here, as an empty InnoDB table would have a size)
$size_td.text('-');
// try to compute a new total row number
@ -51,6 +51,128 @@ function PMA_adjustTotals($this_anchor) {
}
$(document).ready(function() {
/**
* Ajax Event handler for 'Insert Table'
*
* @uses PMA_ajaxShowMessage()
* @see $cfg['AjaxEnable']
*/
var currrent_insert_table;
$("td.insert_table a.ajax").live('click', function(event){
event.preventDefault();
currrent_insert_table = $(this);
var url = $(this).attr("href");
if (url.substring(0, 15) == "tbl_change.php?") {
url = url.substring(15);
}
var div = $('<div id="insert_table_dialog"></div>');
var target = "tbl_change.php";
/**
* @var button_options Object that stores the options passed to jQueryUI
* dialog
*/
var button_options = {};
// in the following function we need to use $(this)
button_options[PMA_messages['strCancel']] = function() {$(this).parent().dialog('close').remove();}
var button_options_error = {};
button_options_error[PMA_messages['strOK']] = function() {$(this).parent().dialog('close').remove();}
var $msgbox = PMA_ajaxShowMessage();
$.get( target , url+"&ajax_request=true" , function(data) {
//in the case of an error, show the error message returned.
if (data.success != undefined && data.success == false) {
div
.append(data.error)
.dialog({
title: PMA_messages['strInsertTable'],
height: 230,
width: 900,
open: PMA_verifyTypeOfAllColumns,
buttons : button_options_error
})// end dialog options
} else {
div
.append(data)
.dialog({
title: PMA_messages['strInsertTable'],
height: 600,
width: 900,
open: PMA_verifyTypeOfAllColumns,
buttons : button_options
})
//Remove the top menu container from the dialog
.find("#topmenucontainer").hide()
; // end dialog options
$(".insertRowTable").addClass("ajax");
$("#buttonYes").addClass("ajax");
}
PMA_ajaxRemoveMessage($msgbox);
}) // end $.get()
});
$("#insertForm .insertRowTable.ajax input[value=Go]").live('click', function(event) {
event.preventDefault();
/**
* @var the_form object referring to the insert form
*/
var $form = $("#insertForm");
$("#result_query").remove();
PMA_prepareForAjaxRequest($form);
//User wants to submit the form
$.post($form.attr('action'), $form.serialize() , function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
} else {
PMA_ajaxShowMessage(data.error);
}
if ($("#insert_table_dialog").length > 0) {
$("#insert_table_dialog").dialog("close").remove();
}
/**Update the row count at the tableForm*/
currrent_insert_table.closest('tr').find('.value.tbl_rows').html(data.row_count);
}) // end $.post()
}) // end insert table button "Go"
$("#buttonYes.ajax").live('click', function(event){
event.preventDefault();
/**
* @var the_form object referring to the insert form
*/
var $form = $("#insertForm");
/**Get the submit type and the after insert type in the form*/
var selected_submit_type = $("#insertForm").find("#actions_panel .control_at_footer option:selected").attr('value');
var selected_after_insert = $("#insertForm").find("#actions_panel select[name=after_insert] option:selected").attr('value');
$("#result_query").remove();
PMA_prepareForAjaxRequest($form);
//User wants to submit the form
$.post($form.attr('action'), $form.serialize() , function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
if (selected_submit_type == "showinsert") {
$(data.sql_query).insertAfter("#topmenucontainer");
$("#result_query .notice").remove();
$("#result_query").prepend((data.message));
}
if (selected_after_insert == "new_insert") {
/**Trigger the insert dialog for new_insert option*/
currrent_insert_table.trigger('click');
}
} else {
PMA_ajaxShowMessage(data.error);
}
if ($("#insert_table_dialog").length > 0) {
$("#insert_table_dialog").dialog("close").remove();
}
/**Update the row count at the tableForm*/
currrent_insert_table.closest('tr').find('.value.tbl_rows').html(data.row_count);
}) // end $.post()
});
/**
* Ajax Event handler for 'Truncate Table'
@ -147,83 +269,9 @@ $(document).ready(function() {
}); // end $.PMA_confirm()
}); //end of Drop Table Ajax action
/**
* Ajax Event handler for 'Drop Event'
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
* @see $cfg['AjaxEnable']
*/
$('.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()
* @see $cfg['AjaxEnable']
*/
$('.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('td').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
/**
* Ajax Event handler for 'Drop tracking'
*
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
* @see $cfg['AjaxEnable']
@ -261,7 +309,7 @@ $(document).ready(function() {
//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) {

2
js/display_triggers.js Normal file
View File

@ -0,0 +1,2 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */

View File

@ -89,18 +89,23 @@ $(document).ready(function() {
/**
* Toggles the disabling of the "save to file" options
*/
function toggle_save_to_file() {
if($("#radio_dump_asfile:checked").length == 0) {
$("#ul_save_asfile > li").fadeTo('fast', 0.4);
$("#ul_save_asfile > li > input").attr('disabled', 'disabled');
$("#ul_save_asfile > li> select").attr('disabled', 'disabled');
} else {
$("#ul_save_asfile > li").fadeTo('fast', 1);
$("#ul_save_asfile > li > input").removeAttr('disabled');
$("#ul_save_asfile > li> select").removeAttr('disabled');
}
}
$(document).ready(function() {
toggle_save_to_file();
$("input[type='radio'][name='output_format']").change(function() {
if($("#radio_dump_asfile:checked").length == 0) {
$("#ul_save_asfile > li").fadeTo('fast', 0.4);
$("#ul_save_asfile > li > input").attr('disabled', 'disabled');
$("#ul_save_asfile > li> select").attr('disabled', 'disabled');
} else {
$("#ul_save_asfile > li").fadeTo('fast', 1);
$("#ul_save_asfile > li > input").removeAttr('disabled');
$("#ul_save_asfile > li> select").removeAttr('disabled');
}
});
toggle_save_to_file();
});
});
/**

View File

@ -15,10 +15,9 @@ 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 int ajax_message_count Number of AJAX messages shown since page load
*/
var ajax_message_init = false;
var ajax_message_count = 0;
/**
* @var codemirror_editor object containing CodeMirror editor
@ -624,24 +623,75 @@ $(document).ready(function() {
if ($(e.target).is('a, img, a *')) {
return;
}
// XXX: FF fires two click events for <label> (label and checkbox), so we need to handle this differently
var $tr = $(this);
var $checkbox = $tr.find(':checkbox');
if ($checkbox.length) {
// checkbox in a row, add or remove class depending on checkbox state
var checked = $checkbox.attr('checked');
if (!$(e.target).is(':checkbox, label')) {
checked = !checked;
$checkbox.attr('checked', checked);
}
if (checked) {
$tr.addClass('marked');
// make the table unselectable (to prevent default highlighting when shift+click)
$tr.parents('table').noSelect();
if (!e.shiftKey || last_clicked_row == -1) {
// usual click
// XXX: FF fires two click events for <label> (label and checkbox), so we need to handle this differently
var $checkbox = $tr.find(':checkbox');
if ($checkbox.length) {
// checkbox in a row, add or remove class depending on checkbox state
var checked = $checkbox.attr('checked');
if (!$(e.target).is(':checkbox, label')) {
checked = !checked;
$checkbox.attr('checked', checked);
}
if (checked) {
$tr.addClass('marked');
} else {
$tr.removeClass('marked');
}
last_click_checked = checked;
} else {
$tr.removeClass('marked');
// normaln data table, just toggle class
$tr.toggleClass('marked');
last_click_checked = false;
}
// remember the last clicked row
last_clicked_row = last_click_checked ? $('tr.odd:not(.noclick), tr.even:not(.noclick)').index(this) : -1;
last_shift_clicked_row = -1;
} else {
// normal data table, just toggle class
$tr.toggleClass('marked');
// handle the shift click
var start, end;
// clear last shift click result
if (last_shift_clicked_row >= 0) {
if (last_shift_clicked_row >= last_clicked_row) {
start = last_clicked_row;
end = last_shift_clicked_row;
} else {
start = last_shift_clicked_row;
end = last_clicked_row;
}
$tr.parent().find('tr.odd:not(.noclick), tr.even:not(.noclick)')
.slice(start, end + 1)
.removeClass('marked')
.find(':checkbox')
.attr('checked', false);
}
// handle new shift click
var curr_row = $('tr.odd:not(.noclick), tr.even:not(.noclick)').index(this);
if (curr_row >= last_clicked_row) {
start = last_clicked_row;
end = curr_row;
} else {
start = curr_row;
end = last_clicked_row;
}
$tr.parent().find('tr.odd:not(.noclick), tr.even:not(.noclick)')
.slice(start, end + 1)
.addClass('marked')
.find(':checkbox')
.attr('checked', true);
// remember the last shift clicked row
last_shift_clicked_row = curr_row;
}
});
@ -653,6 +703,22 @@ $(document).ready(function() {
});
})
/**
* True if last click is to check a row.
*/
var last_click_checked = false;
/**
* Zero-based index of last clicked row.
* Used to handle the shift + click event in the code above.
*/
var last_clicked_row = -1;
/**
* Zero-based index of last shift clicked row.
*/
var last_shift_clicked_row = -1;
/**
* Row highlighting in horizontal mode (use "live"
* so that it works also for pages reached via AJAX)
@ -1150,7 +1216,7 @@ function changeMIMEType(db, table, reference, mime_type)
* Jquery Coding for inline editing SQL_QUERY
*/
$(document).ready(function(){
$(".inline_edit_sql").click( function(){
$(".inline_edit_sql").live('click', function(){
var db = $(this).prev().find("input[name='db']").val();
var table = $(this).prev().find("input[name='table']").val();
var token = $(this).prev().find("input[name='token']").val();
@ -1165,7 +1231,12 @@ $(document).ready(function(){
$(".btnSave").each(function(){
$(this).click(function(){
sql_query = $(this).prev().val();
window.location.replace("import.php?db=" + db +"&table=" + table + "&sql_query=" + sql_query + "&show_query=1&token=" + token);
window.location.replace("import.php"
+ "?db=" + encodeURIComponent(db)
+ "&table=" + encodeURIComponent(table)
+ "&sql_query=" + encodeURIComponent(sql_query)
+ "&show_query=1"
+ "&token=" + token);
});
});
$(".btnDiscard").each(function(){
@ -1243,83 +1314,64 @@ $(document).ready(function(){
* optional, defaults to 'Loading...'
* @param var timeout number of milliseconds for the message to be visible
* optional, defaults to 5000
* @return jQuery object jQuery Element that holds the message div
* @return jQuery object jQuery Element that holds the message div
*/
function PMA_ajaxShowMessage(message, timeout) {
//Handle the case when a empty data.message is passed. We don't want the empty message
if(message == '') {
//Handle the case when a empty data.message is passed. We don't want the empty message
if (message == '') {
return true;
} else if (! message) {
// If the message is undefined, show the default
message = PMA_messages['strLoading'];
}
/**
* @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
* @var timeout Number of milliseconds for which the message will be visible
* @default 5000 ms
*/
if(!timeout) {
var to = 5000;
}
else {
var to = timeout;
if (! timeout) {
timeout = 5000;
}
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)
.fadeIn('medium')
.delay(to)
.fadeOut('medium', function(){
$(this)
.html("") //Clear the message
.hide();
});
}, 'top.frame_content');
ajax_message_init = true;
// Create a parent element for the AJAX messages, if necessary
if ($('#loading_parent').length == 0) {
$('<div id="loading_parent"></div>')
.insertBefore("#serverinfo");
}
else {
//Otherwise, just show the div again after inserting the message
$("#loading")
.stop(true, true)
.html(msg)
// Update message count to create distinct message elements every time
ajax_message_count++;
// Remove all old messages, if any
$(".ajax_notification[id^=ajax_message_num]").remove();
/**
* @var $retval a jQuery object containing the reference
* to the created AJAX message
*/
var $retval = $('<span class="ajax_notification" id="ajax_message_num_' + ajax_message_count + '"></span>')
.hide()
.appendTo("#loading_parent")
.html(message)
.fadeIn('medium')
.delay(to)
.delay(timeout)
.fadeOut('medium', function() {
$(this)
.html("")
.hide();
})
}
$(this).remove();
});
return $("#loading");
return $retval;
}
/**
* Removes the message shown for an Ajax operation when it's completed
*/
function PMA_ajaxRemoveMessage($this_msgbox) {
$this_msgbox
.stop(true, true)
.fadeOut('medium', function() {
$this_msgbox.hide();
});
if ($this_msgbox != undefined && $this_msgbox instanceof jQuery) {
$this_msgbox
.stop(true, true)
.fadeOut('medium');
}
}
/**
@ -1469,7 +1521,7 @@ function PMA_createChart(passedSettings) {
enabled:false
},
xAxis: {
type: 'datetime',
type: 'datetime'
},
yAxis: {
min: 0,
@ -1775,46 +1827,6 @@ $(document).ready(function() {
}, 'top.frame_content'); //end $(document).ready for 'Create Table'
/**
* Attach Ajax event handlers for Drop Trigger. Used on tbl_structure.php
* @see $cfg['AjaxEnable']
*/
$(document).ready(function() {
$(".drop_trigger_anchor").live('click', function(event) {
event.preventDefault();
$anchor = $(this);
/**
* @var curr_row Object reference to the current trigger's <tr>
*/
var $curr_row = $anchor.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() + '`';
$anchor.PMA_confirm(question, $anchor.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
@ -2079,6 +2091,10 @@ $(document).ready(function() {
* Hides certain table structure actions, replacing them with the word "More". They are displayed
* in a dropdown menu when the user hovers over the word "More."
*/
displayMoreTableOpts();
});
function displayMoreTableOpts() {
// Remove the actions from the table cells (they are available by default for JavaScript-disabled browsers)
// if the table is not a view or information_schema (otherwise there is only one action to hide and there's no point)
if($("input[type='hidden'][name='table_type']").val() == "table") {
@ -2088,6 +2104,7 @@ $(document).ready(function() {
$table.find("td[class='unique']").remove();
$table.find("td[class='index']").remove();
$table.find("td[class='fulltext']").remove();
$table.find("td[class='spatial']").remove();
$table.find("th[class='action']").attr("colspan", 3);
// Display the "more" text
@ -2098,9 +2115,9 @@ $(document).ready(function() {
// Optimize DOM querying
var $this_dropdown = $(this);
// The top offset must be set for IE even if it didn't change
var cell_right_edge_offset = $this_dropdown.parent().offset().left + $this_dropdown.parent().innerWidth();
var cell_right_edge_offset = $this_dropdown.parent().position().left + $this_dropdown.parent().innerWidth();
var left_offset = cell_right_edge_offset - $this_dropdown.innerWidth();
var top_offset = $this_dropdown.parent().offset().top + $this_dropdown.parent().innerHeight();
var top_offset = $this_dropdown.parent().position().top + $this_dropdown.parent().innerHeight();
$this_dropdown.offset({ top: top_offset, left: left_offset });
});
@ -2146,8 +2163,7 @@ $(document).ready(function() {
}
});
}
});
}
$(document).ready(initTooltips);
/* Displays tooltips */
@ -2274,62 +2290,6 @@ $(function() {
menuResize();
});
/**
* For the checkboxes in browse mode, handles the shift/click (only works
* in horizontal mode) and propagates the click to the "companion" checkbox
* (in both horizontal and vertical). Works also for pages reached via AJAX.
*/
$(document).ready(function() {
$('.multi_checkbox').live('click',function(e) {
var current_checkbox_id = this.id;
var left_checkbox_id = current_checkbox_id.replace('_right', '_left');
var right_checkbox_id = current_checkbox_id.replace('_left', '_right');
var other_checkbox_id = '';
if (current_checkbox_id == left_checkbox_id) {
other_checkbox_id = right_checkbox_id;
} else {
other_checkbox_id = left_checkbox_id;
}
var $current_checkbox = $('#' + current_checkbox_id);
var $other_checkbox = $('#' + other_checkbox_id);
if (e.shiftKey) {
var index_of_current_checkbox = $('.multi_checkbox').index($current_checkbox);
var $last_checkbox = $('.multi_checkbox').filter('.last_clicked');
var index_of_last_click = $('.multi_checkbox').index($last_checkbox);
$('.multi_checkbox')
.filter(function(index) {
// the first clicked row can be on a row above or below the
// shift-clicked row
return (index_of_current_checkbox > index_of_last_click && index > index_of_last_click && index < index_of_current_checkbox)
|| (index_of_last_click > index_of_current_checkbox && index < index_of_last_click && index > index_of_current_checkbox);
})
.each(function(index) {
var $intermediate_checkbox = $(this);
if ($current_checkbox.is(':checked')) {
$intermediate_checkbox.attr('checked', true);
} else {
$intermediate_checkbox.attr('checked', false);
}
});
}
$('.multi_checkbox').removeClass('last_clicked');
$current_checkbox.addClass('last_clicked');
// When there is a checkbox on both ends of the row, propagate the
// click on one of them to the other one.
// (the default action has not been prevented so if we have
// just clicked, this "if" is true)
if ($current_checkbox.is(':checked')) {
$other_checkbox.attr('checked', true);
} else {
$other_checkbox.attr('checked', false);
}
});
}) // end of $(document).ready() for multi checkbox
/**
* Get the row number from the classlist (for example, row_1)
*/
@ -2497,6 +2457,184 @@ $(document).ready(function() {
}) // end of $(document).ready()
/**
* Attach Ajax event handlers for Export of Routines, Triggers and Events.
*
* @uses PMA_ajaxShowMessage()
* @uses PMA_ajaxRemoveMessage()
*
* @see $cfg['AjaxEnable']
*/
$(document).ready(function() {
$('.export_routine_anchor, .export_trigger_anchor, .export_event_anchor').live('click', function(event) {
event.preventDefault();
var $msg = PMA_ajaxShowMessage(PMA_messages['strLoading']);
$.get($(this).attr('href'), {'ajax_request': true}, function(data) {
if(data.success == true) {
PMA_ajaxRemoveMessage($msg);
/**
* @var button_options Object containing options for jQueryUI dialog buttons
*/
var button_options = {};
button_options[PMA_messages['strClose']] = function() {$(this).dialog("close").remove();}
/**
* Display the dialog to the user
*/
var $ajaxDialog = $('<div>'+data.message+'</div>').dialog({
width: 500,
buttons: button_options,
title: data.title
});
// Attach syntax highlited editor to export dialog
var elm = $ajaxDialog.find('textarea');
CodeMirror.fromTextArea(elm[0], {lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql"});
} else {
PMA_ajaxShowMessage(data.error);
}
}) // end $.get()
}); // end $.live()
}); // end of $(document).ready() for Export of Routines, Triggers and Events.
/**
* Creates a message inside an object with a sliding effect
*
* @param msg A string containing the text to display
* @param $obj a jQuery object containing the reference
* to the element where to put the message
* This is optional, if no element is
* provided, one will be created below the
* navigation links at the top of the page
*
* @return bool True on success, false on failure
*/
function PMA_slidingMessage(msg, $obj) {
if (msg == undefined || msg.length == 0) {
// Don't show an empty message
return false;
}
if ($obj == undefined || ! $obj instanceof jQuery || $obj.length == 0) {
// If the second argument was not supplied,
// we might have to create a new DOM node.
if ($('#PMA_slidingMessage').length == 0) {
$('#topmenucontainer')
.after('<span id="PMA_slidingMessage" '
+ 'style="display: inline-block;"></span>');
}
$obj = $('#PMA_slidingMessage');
}
if ($obj.has('div').length > 0) {
// If there already is a message inside the
// target object, we must get rid of it
$obj
.find('div')
.first()
.fadeOut(function () {
$obj
.children()
.remove();
$obj
.append('<div style="display: none;">' + msg + '</div>')
.animate({
height: $obj.find('div').first().height()
})
.find('div')
.first()
.fadeIn();
});
} else {
// Object does not already have a message
// inside it, so we simply slide it down
var h = $obj
.width('100%')
.html('<div style="display: none;">' + msg + '</div>')
.find('div')
.first()
.height();
$obj
.find('div')
.first()
.css('height', 0)
.show()
.animate({
height: h
}, function() {
// Set the height of the parent
// to the height of the child
$obj
.height(
$obj
.find('div')
.first()
.height()
);
});
}
return true;
} // end PMA_slidingMessage()
/**
* Attach Ajax event handlers for Drop functionality of Routines, Triggers and Events.
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
* @see $cfg['AjaxEnable']
*/
$(document).ready(function() {
$('.drop_routine_anchor, .drop_trigger_anchor, .drop_event_anchor').live('click', function(event) {
event.preventDefault();
/**
* @var $curr_row Object containing reference to the current row
*/
var $curr_row = $(this).parents('tr');
/**
* @var question String containing the question to be asked for confirmation
*/
var question = $('<div></div>').text($curr_row.children('td').children('.drop_sql').html());
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
/**
* @var $msg jQuery object containing the reference to
* the AJAX message shown to the user.
*/
var $msg = PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) {
if(data.success == true) {
/**
* @var $table Object containing reference to the main list of elements.
*/
var $table = $curr_row.parent();
if ($table.find('tr').length == 2) {
$table.hide("slow", function () {
$(this).find('tr.even, tr.odd').remove();
$('#nothing2display').show("slow");
});
} else {
$curr_row.hide("slow", function () {
$(this).remove();
// Now we have removed the row from the list, but maybe
// some row classes are wrong now. So we will itirate
// throught all rows and assign correct classes to them.
/**
* @var ct Count of processed rows.
*/
var ct = 0;
$table.find('tr').has('td').each(function() {
rowclass = (ct % 2 == 0) ? 'even' : 'odd';
$(this).removeClass().addClass(rowclass);
ct++;
});
});
}
// Show the query that we just executed
PMA_ajaxRemoveMessage($msg);
PMA_slidingMessage(data.sql_query);
} else {
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
}
}) // end $.get()
}) // end $.PMA_confirm()
}); // end $.live()
}); //end $(document).ready() for Drop functionality of Routines, Triggers and Events.
/**
* Attach Ajax event handlers for Drop Table.
*
@ -2567,4 +2705,35 @@ $(document).ready(function() {
if (elm.length > 0) {
codemirror_editor = CodeMirror.fromTextArea(elm[0], {lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql"});
}
})
});
/**
* jQuery plugin to cancel selection in HTML code.
*/
(function ($) {
$.fn.noSelect = function (p) { //no select plugin by Paulo P.Marinas
var prevent = (p == null) ? true : p;
if (prevent) {
return this.each(function () {
if ($.browser.msie || $.browser.safari) $(this).bind('selectstart', function () {
return false;
});
else if ($.browser.mozilla) {
$(this).css('MozUserSelect', 'none');
$('body').trigger('focus');
} else if ($.browser.opera) $(this).bind('mousedown', function () {
return false;
});
else $(this).attr('unselectable', 'on');
});
} else {
return this.each(function () {
if ($.browser.msie || $.browser.safari) $(this).unbind('selectstart');
else if ($.browser.mozilla) $(this).css('MozUserSelect', 'inherit');
else if ($.browser.opera) $(this).unbind('mousedown');
else $(this).removeAttr('unselectable', 'on');
});
}
}; //end noSelect
})(jQuery);

View File

@ -17,29 +17,122 @@ function checkIndexName()
}
// Gets the elements pointers
var the_idx_name = document.forms['index_frm'].elements['index'];
var the_idx_type = document.forms['index_frm'].elements['index_type'];
var the_idx_name = document.forms['index_frm'].elements['index[Key_name]'];
var the_idx_type = document.forms['index_frm'].elements['index[Index_type]'];
// Index is a primary key
if (the_idx_type.options[0].value == 'PRIMARY' && the_idx_type.options[0].selected) {
document.forms['index_frm'].elements['index'].value = 'PRIMARY';
document.forms['index_frm'].elements['index[Key_name]'].value = 'PRIMARY';
if (typeof(the_idx_name.disabled) != 'undefined') {
document.forms['index_frm'].elements['index'].disabled = true;
document.forms['index_frm'].elements['index[Key_name]'].disabled = true;
}
}
// Other cases
else {
if (the_idx_name.value == 'PRIMARY') {
document.forms['index_frm'].elements['index'].value = '';
document.forms['index_frm'].elements['index[Key_name]'].value = '';
}
if (typeof(the_idx_name.disabled) != 'undefined') {
document.forms['index_frm'].elements['index'].disabled = false;
document.forms['index_frm'].elements['index[Key_name]'].disabled = false;
}
}
return true;
} // end of the 'checkIndexName()' function
onload = checkIndexName;
/**
* Hides/shows the inputs and submits appropriately depending
* on whether the index type chosen is 'SPATIAL' or not.
*/
function checkIndexType()
{
/**
* @var Object Dropdown to select the index type.
*/
$select_index_type = $('#select_index_type');
/**
* @var Object Table header for the size column.
*/
$size_header = $('thead tr th:nth-child(2)');
/**
* @var Object Inputs to specify the columns for the index.
*/
$column_inputs = $('select[name="index[columns][names][]"]');
/**
* @var Object Inputs to specify sizes for columns of the index.
*/
$size_inputs = $('input[name="index[columns][sub_parts][]"]');
/**
* @var Object Span containg the controllers to add more columns
*/
$add_more = $('#addMoreColumns');
if ($select_index_type.val() == 'SPATIAL') {
// Disable and hide the size column
$size_header.hide();
$size_inputs.each(function(){
$(this)
.attr('disabled', true)
.parent('td').hide();
});
// Disable and hide the columns of the index other than the first one
var initial = true;
$column_inputs.each(function() {
$column_input = $(this);
if (! initial) {
$column_input
.attr('disabled', true)
.parent('td').hide();
} else {
initial = false;
}
});
// Hide controllers to add more columns
$add_more.hide();
} else {
// Enable and show the size column
$size_header.show();
$size_inputs.each(function() {
$(this)
.attr('disabled', false)
.parent('td').show();
});
// Enable and show the columns of the index
$column_inputs.each(function() {
$(this)
.attr('disabled', false)
.parent('td').show();
});
// Show controllers to add more columns
$add_more.show();
}
}
/**#@+
* @namespace jQuery
*/
/**
* @description <p>Ajax scripts for table index page</p>
*
* Actions ajaxified here:
* <ul>
* <li>Showing/hiding inputs depending on the index type chosen</li>
* </ul>
*
* @name document.ready
* @memberOf jQuery
*/
$(document).ready(function() {
checkIndexType();
$('#select_index_type').bind('change', checkIndexType);
});
/**#@- */

View File

@ -0,0 +1,5 @@
/*!
* jquery.event.drag - v 2.0.0 * Copyright (c) 2010 Three Dub Media - http://threedubmedia.com
* Open Source MIT License - http://threedubmedia.com/code/license
*/
;(function(f){f.fn.drag=function(b,a,d){var e=typeof b=="string"?b:"",k=f.isFunction(b)?b:f.isFunction(a)?a:null;if(e.indexOf("drag")!==0)e="drag"+e;d=(b==k?a:d)||{};return k?this.bind(e,d,k):this.trigger(e)};var i=f.event,h=i.special,c=h.drag={defaults:{which:1,distance:0,not:":input",handle:null,relative:false,drop:true,click:false},datakey:"dragdata",livekey:"livedrag",add:function(b){var a=f.data(this,c.datakey),d=b.data||{};a.related+=1;if(!a.live&&b.selector){a.live=true;i.add(this,"draginit."+ c.livekey,c.delegate)}f.each(c.defaults,function(e){if(d[e]!==undefined)a[e]=d[e]})},remove:function(){f.data(this,c.datakey).related-=1},setup:function(){if(!f.data(this,c.datakey)){var b=f.extend({related:0},c.defaults);f.data(this,c.datakey,b);i.add(this,"mousedown",c.init,b);this.attachEvent&&this.attachEvent("ondragstart",c.dontstart)}},teardown:function(){if(!f.data(this,c.datakey).related){f.removeData(this,c.datakey);i.remove(this,"mousedown",c.init);i.remove(this,"draginit",c.delegate);c.textselect(true); this.detachEvent&&this.detachEvent("ondragstart",c.dontstart)}},init:function(b){var a=b.data,d;if(!(a.which>0&&b.which!=a.which))if(!f(b.target).is(a.not))if(!(a.handle&&!f(b.target).closest(a.handle,b.currentTarget).length)){a.propagates=1;a.interactions=[c.interaction(this,a)];a.target=b.target;a.pageX=b.pageX;a.pageY=b.pageY;a.dragging=null;d=c.hijack(b,"draginit",a);if(a.propagates){if((d=c.flatten(d))&&d.length){a.interactions=[];f.each(d,function(){a.interactions.push(c.interaction(this,a))})}a.propagates= a.interactions.length;a.drop!==false&&h.drop&&h.drop.handler(b,a);c.textselect(false);i.add(document,"mousemove mouseup",c.handler,a);return false}}},interaction:function(b,a){return{drag:b,callback:new c.callback,droppable:[],offset:f(b)[a.relative?"position":"offset"]()||{top:0,left:0}}},handler:function(b){var a=b.data;switch(b.type){case !a.dragging&&"mousemove":if(Math.pow(b.pageX-a.pageX,2)+Math.pow(b.pageY-a.pageY,2)<Math.pow(a.distance,2))break;b.target=a.target;c.hijack(b,"dragstart",a); if(a.propagates)a.dragging=true;case "mousemove":if(a.dragging){c.hijack(b,"drag",a);if(a.propagates){a.drop!==false&&h.drop&&h.drop.handler(b,a);break}b.type="mouseup"}case "mouseup":i.remove(document,"mousemove mouseup",c.handler);if(a.dragging){a.drop!==false&&h.drop&&h.drop.handler(b,a);c.hijack(b,"dragend",a)}c.textselect(true);if(a.click===false&&a.dragging){jQuery.event.triggered=true;setTimeout(function(){jQuery.event.triggered=false},20);a.dragging=false}break}},delegate:function(b){var a= [],d,e=f.data(this,"events")||{};f.each(e.live||[],function(k,j){if(j.preType.indexOf("drag")===0)if(d=f(b.target).closest(j.selector,b.currentTarget)[0]){i.add(d,j.origType+"."+c.livekey,j.origHandler,j.data);f.inArray(d,a)<0&&a.push(d)}});if(!a.length)return false;return f(a).bind("dragend."+c.livekey,function(){i.remove(this,"."+c.livekey)})},hijack:function(b,a,d,e,k){if(d){var j={event:b.originalEvent,type:b.type},n=a.indexOf("drop")?"drag":"drop",l,o=e||0,g,m;e=!isNaN(e)?e:d.interactions.length; b.type=a;b.originalEvent=null;d.results=[];do if(g=d.interactions[o])if(!(a!=="dragend"&&g.cancelled)){m=c.properties(b,d,g);g.results=[];f(k||g[n]||d.droppable).each(function(q,p){l=(m.target=p)?i.handle.call(p,b,m):null;if(l===false){if(n=="drag"){g.cancelled=true;d.propagates-=1}if(a=="drop")g[n][q]=null}else if(a=="dropinit")g.droppable.push(c.element(l)||p);if(a=="dragstart")g.proxy=f(c.element(l)||g.drag)[0];g.results.push(l);delete b.result;if(a!=="dropinit")return l});d.results[o]=c.flatten(g.results); if(a=="dropinit")g.droppable=c.flatten(g.droppable);a=="dragstart"&&!g.cancelled&&m.update()}while(++o<e);b.type=j.type;b.originalEvent=j.event;return c.flatten(d.results)}},properties:function(b,a,d){var e=d.callback;e.drag=d.drag;e.proxy=d.proxy||d.drag;e.startX=a.pageX;e.startY=a.pageY;e.deltaX=b.pageX-a.pageX;e.deltaY=b.pageY-a.pageY;e.originalX=d.offset.left;e.originalY=d.offset.top;e.offsetX=b.pageX-(a.pageX-e.originalX);e.offsetY=b.pageY-(a.pageY-e.originalY);e.drop=c.flatten((d.drop||[]).slice()); e.available=c.flatten((d.droppable||[]).slice());return e},element:function(b){if(b&&(b.jquery||b.nodeType==1))return b},flatten:function(b){return f.map(b,function(a){return a&&a.jquery?f.makeArray(a):a&&a.length?c.flatten(a):a})},textselect:function(b){f(document)[b?"unbind":"bind"]("selectstart",c.dontstart).attr("unselectable",b?"off":"on").css("MozUserSelect",b?"":"none")},dontstart:function(){return false},callback:function(){}};c.callback.prototype={update:function(){h.drop&&this.available.length&& f.each(this.available,function(b){h.drop.locate(this,b)})}};h.draginit=h.dragstart=h.dragend=c})(jQuery);

View File

@ -0,0 +1,78 @@
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.4
*
* Requires: 1.2.2+
*/
(function($) {
var types = ['DOMMouseScroll', 'mousewheel'];
$.event.special.mousewheel = {
setup: function() {
if ( this.addEventListener ) {
for ( var i=types.length; i; ) {
this.addEventListener( types[--i], handler, false );
}
} else {
this.onmousewheel = handler;
}
},
teardown: function() {
if ( this.removeEventListener ) {
for ( var i=types.length; i; ) {
this.removeEventListener( types[--i], handler, false );
}
} else {
this.onmousewheel = null;
}
}
};
$.fn.extend({
mousewheel: function(fn) {
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
},
unmousewheel: function(fn) {
return this.unbind("mousewheel", fn);
}
});
function handler(event) {
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
event = $.event.fix(orgEvent);
event.type = "mousewheel";
// Old school scrollwheel delta
if ( event.wheelDelta ) { delta = event.wheelDelta/120; }
if ( event.detail ) { delta = -event.detail/3; }
// New school multidimensional scroll (touchpads) deltas
deltaY = delta;
// Gecko
if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
deltaY = 0;
deltaX = -1*delta;
}
// Webkit
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
// Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY);
return $.event.handle.apply(this, args);
}
})(jQuery);

1339
js/jquery/jquery.svg.js Normal file

File diff suppressed because it is too large Load Diff

864
js/makegrid.js Normal file
View File

@ -0,0 +1,864 @@
(function ($) {
$.grid = function(t) {
// prepare the grid
var g = {
// constant
minColWidth: 15,
// variables, assigned with default value, changed later
alignment: 'horizontal', // 3 possibilities: vertical, horizontal, horizontalflipped
actionSpan: 5,
colOrder: new Array(), // array of column order
colVisib: new Array(), // array of column visibility
tableCreateTime: null, // table creation time, only available in "Browse tab"
hintShown: false, // true if hint balloon is shown, used by updateHint() method
reorderHint: '', // string, hint for column reordering
sortHint: '', // string, hint for column sorting
markHint: '', // string, hint for column marking
colVisibHint: '', // string, hint for column visibility drop-down
showAllColText: '', // string, text for "show all" button under column visibility list
showReorderHint: false,
showSortHint: false,
showMarkHint: false,
showColVisibHint: false,
hintIsHiding: false, // true when hint is still shown, but hideHint() already called
visibleHeadersCount: 0, // number of visible data headers
// functions
dragStartRsz: function(e, obj) { // start column resize
var n = $(this.cRsz).find('div').index(obj);
this.colRsz = {
x0: e.pageX,
n: n,
obj: obj,
objLeft: $(obj).position().left,
objWidth: this.alignment != 'vertical' ?
$(this.t).find('th.draggable:visible:eq(' + n + ') span').outerWidth() :
$(this.t).find('tr:first td:eq(' + n + ') span').outerWidth()
};
$('body').css('cursor', 'col-resize');
$('body').noSelect();
},
dragStartMove: function(e, obj) { // start column move
// prepare the cCpy and cPointer from the dragged column
$(this.cCpy).text($(obj).text());
var objPos = $(obj).position();
if (this.alignment != 'vertical') {
$(this.cCpy).css({
top: objPos.top + 20,
left: objPos.left,
height: $(obj).height(),
width: $(obj).width()
});
$(this.cPointer).css({
top: objPos.top
});
} else { // vertical alignment
$(this.cCpy).css({
top: objPos.top,
left: objPos.left + 30,
height: $(obj).height(),
width: $(obj).width()
});
$(this.cPointer).css({
top: objPos.top
});
}
// get the column index, zero-based
var n = this.getHeaderIdx(obj);
this.colMov = {
x0: e.pageX,
y0: e.pageY,
n: n,
newn: n,
obj: obj,
objTop: objPos.top,
objLeft: objPos.left
};
$('body').css('cursor', 'move');
this.hideHint();
$('body').noSelect();
},
dragMove: function(e) {
if (this.colRsz) {
var dx = e.pageX - this.colRsz.x0;
if (this.colRsz.objWidth + dx > this.minColWidth)
$(this.colRsz.obj).css('left', this.colRsz.objLeft + dx + 'px');
} else if (this.colMov) {
// dragged column animation
if (this.alignment != 'vertical') {
var dx = e.pageX - this.colMov.x0;
$(this.cCpy)
.css('left', this.colMov.objLeft + dx)
.show();
} else { // vertical alignment
var dy = e.pageY - this.colMov.y0;
$(this.cCpy)
.css('top', this.colMov.objTop + dy)
.show();
}
// pointer animation
var hoveredCol = this.getHoveredCol(e);
if (hoveredCol) {
var newn = this.getHeaderIdx(hoveredCol);
this.colMov.newn = newn;
if (newn != this.colMov.n) {
// show the column pointer in the right place
var colPos = $(hoveredCol).position();
if (this.alignment != 'vertical') {
var newleft = newn < this.colMov.n ?
colPos.left :
colPos.left + $(hoveredCol).outerWidth();
$(this.cPointer)
.css({
left: newleft,
visibility: 'visible'
});
} else { // vertical alignment
var newtop = newn < this.colMov.n ?
colPos.top :
colPos.top + $(hoveredCol).outerHeight();
$(this.cPointer)
.css({
top: newtop,
visibility: 'visible'
});
}
} else {
// no movement to other column, hide the column pointer
$(this.cPointer).css('visibility', 'hidden');
}
}
}
},
dragEnd: function(e) {
if (this.colRsz) {
var dx = e.pageX - this.colRsz.x0;
var nw = this.colRsz.objWidth + dx;
if (nw < this.minColWidth) {
nw = this.minColWidth;
}
var n = this.colRsz.n;
// do the resizing
this.resize(n, nw);
$('body').css('cursor', 'default');
this.reposRsz();
this.reposDrop();
this.colRsz = false;
} else if (this.colMov) {
// shift columns
if (this.colMov.newn != this.colMov.n) {
this.shiftCol(this.colMov.n, this.colMov.newn);
// assign new position
var objPos = $(this.colMov.obj).position();
this.colMov.objTop = objPos.top;
this.colMov.objLeft = objPos.left;
this.colMov.n = this.colMov.newn;
// send request to server to remember the column order
if (this.tableCreateTime) {
this.sendColPrefs();
}
this.refreshRestoreButton();
}
// animate new column position
$(this.cCpy).stop(true, true)
.animate({
top: g.colMov.objTop,
left: g.colMov.objLeft
}, 'fast')
.fadeOut();
$(this.cPointer).css('visibility', 'hidden');
this.colMov = false;
}
$('body').css('cursor', 'default');
$('body').noSelect(false);
},
/**
* Resize column n to new width "nw"
*/
resize: function(n, nw) {
if (this.alignment != 'vertical') {
$(this.t).find('tr').each(function() {
$(this).find('th.draggable:visible:eq(' + n + ') span,' +
'td:visible:eq(' + (g.actionSpan + n) + ') span')
.css('width', nw);
});
} else { // vertical alignment
$(this.t).find('tr').each(function() {
$(this).find('td:eq(' + n + ') span')
.css('width', nw);
});
}
},
/**
* Reposition column resize bars.
*/
reposRsz: function() {
$(this.cRsz).find('div').hide();
$firstRowCols = this.alignment != 'vertical' ?
$(this.t).find('tr:first th.draggable:visible') :
$(this.t).find('tr:first td');
for (var n = 0; n < $firstRowCols.length; n++) {
$this = $($firstRowCols[n]);
$cb = $(g.cRsz).find('div:eq(' + n + ')'); // column border
$cb.css('left', $this.position().left + $this.outerWidth(true))
.show();
}
},
/**
* Shift column from index oldn to newn.
*/
shiftCol: function(oldn, newn) {
if (this.alignment != 'vertical') {
$(this.t).find('tr').each(function() {
if (newn < oldn) {
$(this).find('th.draggable:eq(' + newn + '),' +
'td:eq(' + (g.actionSpan + newn) + ')')
.before($(this).find('th.draggable:eq(' + oldn + '),' +
'td:eq(' + (g.actionSpan + oldn) + ')'));
} else {
$(this).find('th.draggable:eq(' + newn + '),' +
'td:eq(' + (g.actionSpan + newn) + ')')
.after($(this).find('th.draggable:eq(' + oldn + '),' +
'td:eq(' + (g.actionSpan + oldn) + ')'));
}
});
// reposition the column resize bars
this.reposRsz();
} else { // vertical alignment
// shift rows
if (newn < oldn) {
$(this.t).find('tr:eq(' + (g.actionSpan + newn) + ')')
.before($(this.t).find('tr:eq(' + (g.actionSpan + oldn) + ')'));
} else {
$(this.t).find('tr:eq(' + (g.actionSpan + newn) + ')')
.after($(this.t).find('tr:eq(' + (g.actionSpan + oldn) + ')'));
}
}
// adjust the column visibility list
if (newn < oldn) {
$(g.cList).find('tr:eq(' + newn + ')')
.before($(g.cList).find('tr:eq(' + oldn + ')'));
} else {
$(g.cList).find('tr:eq(' + newn + ')')
.after($(g.cList).find('tr:eq(' + oldn + ')'));
}
// adjust the colOrder
var tmp = this.colOrder[oldn];
this.colOrder.splice(oldn, 1);
this.colOrder.splice(newn, 0, tmp);
// adjust the colVisib
var tmp = this.colVisib[oldn];
this.colVisib.splice(oldn, 1);
this.colVisib.splice(newn, 0, tmp);
},
/**
* Find currently hovered table column's header (excluding actions column).
* @return the hovered column's th object or undefined if no hovered column found.
*/
getHoveredCol: function(e) {
var hoveredCol;
$headers = $(this.t).find('th.draggable:visible');
if (this.alignment != 'vertical') {
$headers.each(function() {
var left = $(this).offset().left;
var right = left + $(this).outerWidth();
if (left <= e.pageX && e.pageX <= right) {
hoveredCol = this;
}
});
} else { // vertical alignment
$headers.each(function() {
var top = $(this).offset().top;
var bottom = top + $(this).height();
if (top <= e.pageY && e.pageY <= bottom) {
hoveredCol = this;
}
});
}
return hoveredCol;
},
/**
* Get a zero-based index from a <th class="draggable"> tag in a table.
*/
getHeaderIdx: function(obj) {
var n;
if (this.alignment != 'vertical') {
n = $(obj).parents('tr').find('th.draggable').index(obj);
} else {
var column_idx = $(obj).index();
var $th_in_same_column = $(this.t).find('th.draggable:nth-child(' + (column_idx + 1) + ')');
n = $th_in_same_column.index(obj);
}
return n;
},
/**
* Reposition the table back to normal order.
*/
restoreColOrder: function() {
// use insertion sort, since we already have shiftCol function
for (var i = 1; i < this.colOrder.length; i++) {
var x = this.colOrder[i];
var j = i - 1;
while (j >= 0 && x < this.colOrder[j]) {
j--;
}
if (j != i - 1) {
this.shiftCol(i, j + 1);
}
}
if (this.tableCreateTime) {
// send request to server to remember the column order
this.sendColPrefs();
}
this.refreshRestoreButton();
},
/**
* Send column preferences (column order and visibility) to the server.
*/
sendColPrefs: function() {
$.post('sql.php', {
ajax_request: true,
db: window.parent.db,
table: window.parent.table,
token: window.parent.token,
server: window.parent.server,
set_col_prefs: true,
col_order: this.colOrder.toString(),
col_visib: this.colVisib.toString(),
table_create_time: this.tableCreateTime
});
},
/**
* Refresh restore button state.
* Make restore button disabled if the table is similar with initial state.
*/
refreshRestoreButton: function() {
// check if table state is as initial state
var isInitial = true;
for (var i = 0; i < this.colOrder.length; i++) {
if (this.colOrder[i] != i) {
isInitial = false;
break;
}
}
// check if only one visible column left
var isOneColumn = this.visibleHeadersCount == 1;
// enable or disable restore button
if (isInitial || isOneColumn) {
$('.restore_column').hide();
} else {
$('.restore_column').show();
}
},
/**
* Show hint with the text supplied.
*/
showHint: function(e) {
if (!this.colRsz && !this.colMov) { // if not resizing or dragging
var text = '';
if (this.showReorderHint && this.reorderHint) {
text += this.reorderHint;
}
if (this.showSortHint && this.sortHint) {
text += text.length > 0 ? '<br />' : '';
text += this.sortHint;
}
if (this.showMarkHint && this.markHint &&
!this.showSortHint // we do not show mark hint, when sort hint is shown
) {
text += text.length > 0 ? '<br />' : '';
text += this.markHint;
}
if (this.showColVisibHint && this.colVisibHint) {
text += text.length > 0 ? '<br />' : '';
text += this.colVisibHint;
}
// hide the hint if no text
if (!text) {
this.hideHint();
return;
}
$(this.dHint).html(text);
if (!this.hintShown || this.hintIsHiding) {
$(this.dHint)
.stop(true, true)
.css({
top: e.clientY,
left: e.clientX + 15
})
.show('fast');
this.hintShown = true;
this.hintIsHiding = false;
}
}
},
/**
* Hide the hint.
*/
hideHint: function() {
if (this.hintShown) {
$(this.dHint)
.stop(true, true)
.hide(300, function() {
g.hintShown = false;
g.hintIsHiding = false;
});
this.hintIsHiding = true;
}
},
/**
* Update hint position.
*/
updateHint: function(e) {
if (this.hintShown) {
$(this.dHint).css({
top: e.clientY,
left: e.clientX + 15
});
}
},
/**
* Toggle column's visibility.
* After calling this function and it returns true, afterToggleCol() must be called.
*
* @return boolean True if the column is toggled successfully.
*/
toggleCol: function(n) {
if (this.colVisib[n]) {
// can hide if more than one column is visible
if (this.visibleHeadersCount > 1) {
if (this.alignment != 'vertical') {
$(this.t).find('tr').each(function() {
$(this).find('th.draggable:eq(' + n + '),' +
'td:eq(' + (g.actionSpan + n) + ')')
.hide();
});
} else { // vertical alignment
$(this.t).find('tr:eq(' + (g.actionSpan + n) + ')')
.hide();
}
this.colVisib[n] = 0;
$(this.cList).find('tr:eq(' + n + ') input').removeAttr('checked');
} else {
// cannot hide, force the checkbox to stay checked
$(this.cList).find('tr:eq(' + n + ') input').attr('checked', 'checked');
return false;
}
} else { // column n is not visible
if (this.alignment != 'vertical') {
$(this.t).find('tr').each(function() {
$(this).find('th.draggable:eq(' + n + '),' +
'td:eq(' + (g.actionSpan + n) + ')')
.show();
});
} else { // vertical alignment
$(this.t).find('tr:eq(' + (g.actionSpan + n) + ')')
.show();
}
this.colVisib[n] = 1;
$(this.cList).find('tr:eq(' + n + ') input').attr('checked', 'checked');
}
return true;
},
/**
* This must be called after calling toggleCol() and the return value is true.
*
* This function is separated from toggleCol because, sometimes, we want to toggle
* some columns together at one time and do one adjustment after it, e.g. in showAllColumns().
*/
afterToggleCol: function() {
// some adjustments after hiding column
this.reposRsz();
this.reposDrop();
this.sendColPrefs();
// check visible first row headers count
this.visibleHeadersCount = this.alignment != 'vertical' ?
$(this.t).find('tr:first th.draggable:visible').length :
$(this.t).find('th.draggable:nth-child(1):visible').length;
this.refreshRestoreButton();
},
/**
* Show columns' visibility list.
*/
showColList: function(obj) {
// only show when not resizing or reordering
if (!this.colRsz && !this.colMov) {
var pos = $(obj).position();
// check if the list position is too right
if (pos.left + $(this.cList).outerWidth(true) > $(document).width()) {
pos.left = $(document).width() - $(this.cList).outerWidth(true);
}
$(this.cList).css({
left: pos.left,
top: pos.top + $(obj).outerHeight(true)
})
.show();
$(obj).addClass('coldrop-hover');
}
},
/**
* Hide columns' visibility list.
*/
hideColList: function() {
$(this.cList).hide();
$(g.cDrop).find('.coldrop-hover').removeClass('coldrop-hover');
},
/**
* Reposition the column visibility drop-down arrow.
*/
reposDrop: function() {
$th = $(t).find('th:not(.draggable)');
for (var i = 0; i < $th.length; i++) {
var $cd = $(this.cDrop).find('div:eq(' + i + ')'); // column drop-down arrow
var pos = $($th[i]).position();
$cd.css({
left: pos.left + $($th[i]).width() - $cd.width(),
top: pos.top
});
}
},
/**
* Show all hidden columns.
*/
showAllColumns: function() {
for (var i = 0; i < this.colVisib.length; i++) {
if (!this.colVisib[i]) {
this.toggleCol(i);
}
}
this.afterToggleCol();
}
}
// wrap all data cells, except actions cell, with span
$(t).find('th, td:not(:has(span))')
.wrapInner('<span />');
g.gDiv = document.createElement('div'); // create global div
g.cRsz = document.createElement('div'); // column resizer
g.cCpy = document.createElement('div'); // column copy, to store copy of dragged column header
g.cPointer = document.createElement('div'); // column pointer, used when reordering column
g.dHint = document.createElement('div'); // draggable hint
g.cDrop = document.createElement('div'); // column drop-down arrows
g.cList = document.createElement('div'); // column visibility list
// assign the table alignment
g.alignment = $("#top_direction_dropdown").val();
// adjust g.cCpy
g.cCpy.className = 'cCpy';
$(g.cCpy).hide();
// adjust g.cPoint
g.cPointer.className = g.alignment != 'vertical' ? 'cPointer' : 'cPointerVer';
$(g.cPointer).css('visibility', 'hidden');
// adjust g.dHint
g.dHint.className = 'dHint';
$(g.dHint).hide();
// adjust g.cDrop
g.cDrop.className = 'cDrop';
// adjust g.cList
g.cList.className = 'cList';
$(g.cList).hide();
// chain table and grid together
t.grid = g;
g.t = t;
// get first row data columns
var $firstRowCols = g.alignment != 'vertical' ?
$(t).find('tr:first th.draggable') :
$(t).find('tr:first td');
// get first row of data headers (first column of data headers, in vertical mode)
var $firstRowHeaders = g.alignment != 'vertical' ?
$(t).find('tr:first th.draggable') :
$(t).find('th.draggable:nth-child(1)');
// initialize g.visibleHeadersCount
g.visibleHeadersCount = $firstRowHeaders.filter(':visible').length;
// assign first column (actions) span
if (! $(t).find('tr:first th:first').hasClass('draggable')) { // action header exist
g.actionSpan = g.alignment != 'vertical' ?
$(t).find('tr:first th:first').prop('colspan') :
$(t).find('tr:first th:first').prop('rowspan');
} else {
g.actionSpan = 0;
}
// assign table create time
// #table_create_time will only available if we are in "Browse" tab
g.tableCreateTime = $('#table_create_time').val();
// assign column reorder & column sort hint
g.reorderHint = $('#col_order_hint').val();
g.sortHint = $('#sort_hint').val();
g.markHint = $('#col_mark_hint').val();
g.colVisibHint = $('#col_visib_hint').val();
g.showAllColText = $('#show_all_col_text').val();
// initialize column order
$col_order = $('#col_order');
if ($col_order.length > 0) {
g.colOrder = $col_order.val().split(',');
for (var i = 0; i < g.colOrder.length; i++) {
g.colOrder[i] = parseInt(g.colOrder[i]);
}
} else {
g.colOrder = new Array();
for (var i = 0; i < $firstRowHeaders.length; i++) {
g.colOrder.push(i);
}
}
// initialize column visibility
$col_visib = $('#col_visib');
if ($col_visib.length > 0) {
g.colVisib = $col_visib.val().split(',');
for (var i = 0; i < g.colVisib.length; i++) {
g.colVisib[i] = parseInt(g.colVisib[i]);
}
} else {
g.colVisib = new Array();
for (var i = 0; i < $firstRowHeaders.length; i++) {
g.colVisib.push(1);
}
}
if ($firstRowHeaders.length > 1) {
// create column drop-down arrow(s)
$(t).find('th:not(.draggable)').each(function() {
var cd = document.createElement('div'); // column drop-down arrow
var pos = $(this).position();
$(cd).addClass('coldrop')
.css({
left: pos.left + $(this).width() - $(cd).width(),
top: pos.top
})
.click(function() {
if (g.cList.style.display == 'none') {
g.showColList(this);
} else {
g.hideColList();
}
});
$(g.cDrop).append(cd);
});
// add column visibility control
g.cList.innerHTML = '<table cellpadding="0" cellspacing="0"><tbody></tbody></table>';
var $tbody = $(g.cList).find('tbody');
for (var i = 0; i < $firstRowHeaders.length; i++) {
var currHeader = $firstRowHeaders[i];
var tr = document.createElement('tr');
$(tr).html('<td><input type="checkbox" ' + (g.colVisib[i] ? 'checked="checked" ' : '') + '/></td>' +
'<td>' + $(currHeader).text() + '</td>');
$tbody.append(tr);
// add event on click
$(tr).click(function() {
if ( g.toggleCol($(this).index()) ) {
g.afterToggleCol();
}
});
}
// add "show all column" button
var showAll = document.createElement('div');
$(showAll).addClass('showAllColBtn')
.text(g.showAllColText);
$(g.cList).append(showAll);
$(showAll).click(function() {
g.showAllColumns();
});
// prepend "show all column" button at top if the list is too long
if ($firstRowHeaders.length > 10) {
var clone = showAll.cloneNode(true);
$(g.cList).prepend(clone);
$(clone).click(function() {
g.showAllColumns();
});
}
}
// create column borders
$firstRowCols.each(function() {
$this = $(this);
var cb = document.createElement('div'); // column border
$(cb).addClass('colborder')
.mousedown(function(e) {
g.dragStartRsz(e, this);
});
$(g.cRsz).append(cb);
});
g.reposRsz();
// register events
if (g.reorderHint) { // make sure columns is reorderable
$(t).find('th.draggable')
.mousedown(function(e) {
if (g.visibleHeadersCount > 1) {
g.dragStartMove(e, this);
}
})
.mouseenter(function(e) {
if (g.visibleHeadersCount > 1) {
g.showReorderHint = true;
$(this).css('cursor', 'move');
} else {
$(this).css('cursor', 'inherit');
}
g.showHint(e);
})
.mouseleave(function(e) {
g.showReorderHint = false;
g.showHint(e);
});
}
$(t).find('th:not(.draggable)')
.mouseenter(function(e) {
g.showColVisibHint = true;
g.showHint(e);
})
.mouseleave(function(e) {
g.showColVisibHint = false;
g.showHint(e);
});
$(t).find('th.draggable a')
.attr('title', '') // hide default tooltip for sorting
.mouseenter(function(e) {
g.showSortHint = true;
g.showHint(e);
})
.mouseleave(function(e) {
g.showSortHint = false;
g.showHint(e);
});
$(t).find('th.marker')
.mouseenter(function(e) {
g.showMarkHint = true;
g.showHint(e);
})
.mouseleave(function(e) {
g.showMarkHint = false;
g.showHint(e);
});
$(document).mousemove(function(e) {
g.dragMove(e);
g.updateHint(e);
});
$(document).mouseup(function(e) {
g.dragEnd(e);
});
$('.restore_column').click(function() {
g.restoreColOrder();
});
$(t).find('td, th.draggable').mouseenter(function() {
g.hideColList();
});
// add table class
$(t).addClass('pma_table');
// link all divs
$(t).before(g.gDiv);
$(g.gDiv).append(t);
$(g.gDiv).prepend(g.cRsz);
$(g.gDiv).append(g.cPointer);
$(g.gDiv).append(g.cDrop);
$(g.gDiv).append(g.cList);
$(g.gDiv).append(g.dHint);
$(g.gDiv).append(g.cCpy);
// some adjustment
g.refreshRestoreButton();
g.cRsz.className = 'cRsz';
$(t).removeClass('data');
$(g.gDiv).addClass('data');
$(g.cRsz).css('height', $(t).height());
$(t).find('th a').bind('dragstart', function() {
return false;
});
};
// document ready checking
var docready = false;
$(document).ready(function() {
docready = true;
});
// Additional jQuery functions
/**
* Make resizable, reorderable grid.
*/
$.fn.makegrid = function() {
return this.each(function() {
if (!docready) {
var t = this;
$(document).ready(function() {
$.grid(t);
t.grid.reposDrop();
});
} else {
$.grid(this);
this.grid.reposDrop();
}
});
};
/**
* Refresh grid. This must be called after changing the grid's content.
*/
$.fn.refreshgrid = function() {
return this.each(function() {
if (!docready) {
var t = this;
$(document).ready(function() {
if (t.grid) {
t.grid.reposRsz();
t.grid.reposDrop();
}
});
} else {
if (this.grid) {
this.grid.reposRsz();
this.grid.reposDrop();
}
}
});
}
})(jQuery);

View File

@ -24,15 +24,13 @@ require_once './libraries/js_escape.lib.php';
$js_messages['strClickToSelect'] = __('Click to select');
$js_messages['strClickToUnselect'] = __('Click to unselect');
$js_messages['strNoDropDatabases'] = __('"DROP DATABASE" statements are disabled.');
$js_messages['strNoDropDatabases'] = $cfg['AllowUserDropDatabase'] ? '' : __('"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['strDropTableStrongWarning'] = __('You are about to DESTROY a complete table!');
$js_messages['strTruncateTableStrongWarning'] = __('You are about to TRUNCATE a complete table!');
$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');
@ -77,9 +75,9 @@ $js_messages['strThousandsSeperator'] = __(',');
/* l10n: Decimal separator */
$js_messages['strDecimalSeperator'] = __('.');
$js_messages['strChartKBSent'] = __('kB sent since last refresh');
$js_messages['strChartKBReceived'] = __('kB received since last refresh');
$js_messages['strChartServerTraffic'] = __('Server traffic (in kB)');
$js_messages['strChartKBSent'] = __('KiB sent since last refresh');
$js_messages['strChartKBReceived'] = __('KiB received since last refresh');
$js_messages['strChartServerTraffic'] = __('Server traffic (in KiB)');
$js_messages['strChartConnections'] = __('Connections since last refresh');
$js_messages['strChartProcesses'] = __('Processes');
$js_messages['strChartConnectionsTitle'] = __('Connections / Processes');
@ -114,6 +112,8 @@ $js_messages['strNo'] = __('No');
/* For db_stucture.js */
$js_messages['strInsertTable'] = __('Insert Table');
$js_messages['strHideIndexes'] = __('Hide indexes');
$js_messages['strShowIndexes'] = __('Show indexes');
/* For db_search.js */
$js_messages['strSearching'] = __('Searching');
@ -122,6 +122,10 @@ $js_messages['strShowSearchResults'] = __('Show search results');
$js_messages['strBrowsing'] = __('Browsing');
$js_messages['strDeleting'] = __('Deleting');
/* For db_routines.js */
$js_messages['MissingReturn'] = __('The definition of a stored function must contain a RETURN statement!');
$js_messages['strValueTooLong'] = __('Value too long in the form!');
/* For import.js */
$js_messages['strImportCSV'] = __('Note: If the file contains multiple tables, they will be combined into one');
@ -132,6 +136,8 @@ $js_messages['strInlineEdit'] = __('Inline Edit');
$js_messages['strEdit'] = __('Edit');
$js_messages['strSave'] = __('Save');
$js_messages['strHide'] = __('Hide');
$js_messages['strNoRowSelected'] = __('No rows selected');
$js_messages['strChangeTbl'] = __('Change');
/* For tbl_select.js */
$js_messages['strHideSearchCriteria'] = __('Hide search criteria');

2553
js/openlayers/OpenLayers.js Normal file

File diff suppressed because one or more lines are too long

BIN
js/openlayers/img/blank.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 992 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 967 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

View File

@ -0,0 +1,10 @@
.olLayerGoogleCopyright {
right: 3px;
bottom: 2px;
left: auto;
}
.olLayerGooglePoweredBy {
left: 2px;
bottom: 2px;
}

View File

@ -0,0 +1,7 @@
.olControlZoomPanel div {
background-image: url(img/zoom-panel-NOALPHA.png);
}
.olControlPanPanel div {
background-image: url(img/pan-panel-NOALPHA.png);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,397 @@
div.olMap {
z-index: 0;
padding: 0px!important;
margin: 0px!important;
cursor: default;
}
div.olMapViewport {
text-align: left;
}
div.olLayerDiv {
-moz-user-select: none;
}
.olLayerGoogleCopyright {
left: 2px;
bottom: 2px;
}
.olLayerGooglePoweredBy {
left: 2px;
bottom: 15px;
}
.olControlAttribution {
font-size: smaller;
right: 3px;
bottom: 4.5em;
position: absolute;
display: block;
}
.olControlScale {
right: 3px;
bottom: 3em;
display: block;
position: absolute;
font-size: smaller;
}
.olControlScaleLine {
display: block;
position: absolute;
left: 10px;
bottom: 15px;
font-size: xx-small;
}
.olControlScaleLineBottom {
border: solid 2px black;
border-bottom: none;
margin-top:-2px;
text-align: center;
}
.olControlScaleLineTop {
border: solid 2px black;
border-top: none;
text-align: center;
}
.olControlPermalink {
right: 3px;
bottom: 1.5em;
display: block;
position: absolute;
font-size: smaller;
}
div.olControlMousePosition {
bottom: 0em;
right: 3px;
display: block;
position: absolute;
font-family: Arial;
font-size: smaller;
}
.olControlOverviewMapContainer {
position: absolute;
bottom: 0px;
right: 0px;
}
.olControlOverviewMapElement {
padding: 10px 18px 10px 10px;
background-color: #00008B;
-moz-border-radius: 1em 0 0 0;
}
.olControlOverviewMapMinimizeButton {
right: 0px;
bottom: 80px;
}
.olControlOverviewMapMaximizeButton {
right: 0px;
bottom: 80px;
}
.olControlOverviewMapExtentRectangle {
overflow: hidden;
background-image: url("img/blank.gif");
cursor: move;
border: 2px dotted red;
}
.olControlOverviewMapRectReplacement {
overflow: hidden;
cursor: move;
background-image: url("img/overview_replacement.gif");
background-repeat: no-repeat;
background-position: center;
}
.olLayerGeoRSSDescription {
float:left;
width:100%;
overflow:auto;
font-size:1.0em;
}
.olLayerGeoRSSClose {
float:right;
color:gray;
font-size:1.2em;
margin-right:6px;
font-family:sans-serif;
}
.olLayerGeoRSSTitle {
float:left;font-size:1.2em;
}
.olPopupContent {
padding:5px;
overflow: auto;
}
.olControlNavToolbar {
width:0px;
height:0px;
}
.olControlNavToolbar div {
display:block;
width: 28px;
height: 28px;
top: 300px;
left: 6px;
position: relative;
}
.olControlNavigationHistory {
background-image: url("img/navigation_history.png");
background-repeat: no-repeat;
width: 24px;
height: 24px;
}
.olControlNavigationHistoryPreviousItemActive {
background-position: 0px 0px;
}
.olControlNavigationHistoryPreviousItemInactive {
background-position: 0px -24px;
}
.olControlNavigationHistoryNextItemActive {
background-position: -24px 0px;
}
.olControlNavigationHistoryNextItemInactive {
background-position: -24px -24px;
}
.olControlNavToolbar .olControlNavigationItemActive {
background-image: url("img/panning-hand-on.png");
background-repeat: no-repeat;
}
.olControlNavToolbar .olControlNavigationItemInactive {
background-image: url("img/panning-hand-off.png");
background-repeat: no-repeat;
}
.olControlNavToolbar .olControlZoomBoxItemActive {
background-image: url("img/drag-rectangle-on.png");
background-color: orange;
background-repeat: no-repeat;
}
.olControlNavToolbar .olControlZoomBoxItemInactive {
background-image: url("img/drag-rectangle-off.png");
background-repeat: no-repeat;
}
.olControlEditingToolbar {
float:right;
right: 0px;
height: 30px;
width: 200px;
}
.olControlEditingToolbar div {
background-image: url("img/editing_tool_bar.png");
background-repeat: no-repeat;
float:right;
width: 24px;
height: 24px;
margin: 5px;
}
.olControlEditingToolbar .olControlNavigationItemActive {
background-position: -103px -23px;
}
.olControlEditingToolbar .olControlNavigationItemInactive {
background-position: -103px -0px;
}
.olControlEditingToolbar .olControlDrawFeaturePointItemActive {
background-position: -77px -23px;
}
.olControlEditingToolbar .olControlDrawFeaturePointItemInactive {
background-position: -77px -0px;
}
.olControlEditingToolbar .olControlDrawFeaturePathItemInactive {
background-position: -51px 0px;
}
.olControlEditingToolbar .olControlDrawFeaturePathItemActive {
background-position: -51px -23px;
}
.olControlEditingToolbar .olControlDrawFeaturePolygonItemInactive {
background-position: -26px 0px;
}
.olControlEditingToolbar .olControlDrawFeaturePolygonItemActive {
background-position: -26px -23px ;
}
div.olControlSaveFeaturesItemActive {
background-image: url(img/save_features_on.png);
background-repeat: no-repeat;
background-position: 0px 1px;
}
div.olControlSaveFeaturesItemInactive {
background-image: url(img/save_features_off.png);
background-repeat: no-repeat;
background-position: 0px 1px;
}
.olHandlerBoxZoomBox {
border: 2px solid red;
position: absolute;
background-color: white;
opacity: 0.50;
font-size: 1px;
filter: alpha(opacity=50);
}
.olHandlerBoxSelectFeature {
border: 2px solid blue;
position: absolute;
background-color: white;
opacity: 0.50;
font-size: 1px;
filter: alpha(opacity=50);
}
.olControlPanPanel {
top: 10px;
left: 5px;
}
.olControlPanPanel div {
background-image: url(img/pan-panel.png);
height: 18px;
width: 18px;
cursor: pointer;
position: absolute;
}
.olControlPanPanel .olControlPanNorthItemInactive {
top: 0px;
left: 9px;
background-position: 0px 0px;
}
.olControlPanPanel .olControlPanSouthItemInactive {
top: 36px;
left: 9px;
background-position: 18px 0px;
}
.olControlPanPanel .olControlPanWestItemInactive {
position: absolute;
top: 18px;
left: 0px;
background-position: 0px 18px;
}
.olControlPanPanel .olControlPanEastItemInactive {
top: 18px;
left: 18px;
background-position: 18px 18px;
}
.olControlZoomPanel {
top: 71px;
left: 14px;
}
.olControlZoomPanel div {
background-image: url(img/zoom-panel.png);
position: absolute;
height: 18px;
width: 18px;
cursor: pointer;
}
.olControlZoomPanel .olControlZoomInItemInactive {
top: 0px;
left: 0px;
background-position: 0px 0px;
}
.olControlZoomPanel .olControlZoomToMaxExtentItemInactive {
top: 18px;
left: 0px;
background-position: 0px -18px;
}
.olControlZoomPanel .olControlZoomOutItemInactive {
top: 36px;
left: 0px;
background-position: 0px 18px;
}
.olPopupCloseBox {
background: url("img/close.gif") no-repeat;
cursor: pointer;
}
.olFramedCloudPopupContent {
padding: 5px;
overflow: auto;
}
.olControlNoSelect {
-moz-user-select: none;
}
.olImageLoadError {
background-color: pink;
opacity: 0.5;
filter: alpha(opacity=50); /* IE */
}
/**
* Cursor styles
*/
.olCursorWait {
cursor: wait;
}
.olDragDown {
cursor: move;
}
.olDrawBox {
cursor: crosshair;
}
.olControlDragFeatureOver {
cursor: move;
}
.olControlDragFeatureActive.olControlDragFeatureOver.olDragDown {
cursor: -moz-grabbing;
}
/**
* Layer switcher
*/
.olControlLayerSwitcher {
position: absolute;
top: 25px;
right: 0px;
width: 20em;
font-family: sans-serif;
font-weight: bold;
margin-top: 3px;
margin-left: 3px;
margin-bottom: 3px;
font-size: smaller;
color: white;
background-color: transparent;
}
.olControlLayerSwitcher .layersDiv {
padding-top: 5px;
padding-left: 10px;
padding-bottom: 5px;
padding-right: 75px;
background-color: darkblue;
width: 100%;
height: 100%;
}
.olControlLayerSwitcher .layersDiv .baseLbl,
.olControlLayerSwitcher .layersDiv .dataLbl {
margin-top: 3px;
margin-left: 3px;
margin-bottom: 3px;
}
.olControlLayerSwitcher .layersDiv .baseLayersDiv,
.olControlLayerSwitcher .layersDiv .dataLayersDiv {
padding-left: 10px;
}
.olControlLayerSwitcher .maximizeDiv,
.olControlLayerSwitcher .minimizeDiv {
top: 5px;
right: 0px;
}

288
js/sql.js
View File

@ -42,12 +42,13 @@ function getFieldName($this_field, disp_mode) {
else {
var this_field_index = $this_field.index();
// ltr or rtl direction does not impact how the DOM was generated
//
// check if the action column in the left exist
var leftActionExist = !$('#table_results').find('th:first').hasClass('draggable');
// 5 columns to account for the checkbox, edit, appended inline edit, copy and delete anchors but index is zero-based so substract 4
var field_name = $('#table_results').find('thead').find('th:nth('+ (this_field_index-4 )+') a').text();
var field_name = $('#table_results').find('thead').find('th:nth('+ (this_field_index - (leftActionExist ? 4 : 0)) + ') a').text();
// happens when just one row (headings contain no a)
if ("" == field_name) {
field_name = $('#table_results').find('thead').find('th:nth('+ (this_field_index-4 )+')').text();
field_name = $('#table_results').find('thead').find('th:nth('+ (this_field_index - (leftActionExist ? 4 : 0)) + ')').text();
}
}
@ -96,7 +97,7 @@ function appendInlineAnchor() {
$cloned_tr.insertAfter($this_tr);
});
$('#rowsDeleteForm').find('tbody').find('th').each(function() {
$('#resultsForm').find('tbody').find('th').each(function() {
var $this_th = $(this);
if ($this_th.attr('rowspan') == 4) {
$this_th.attr('rowspan', '5');
@ -148,7 +149,7 @@ function appendInlineAnchor() {
$this_td.after($cloned_anchor);
});
$('#rowsDeleteForm').find('thead, tbody').find('th').each(function() {
$('#resultsForm').find('thead, tbody').find('th').each(function() {
var $this_th = $(this);
if ($this_th.attr('colspan') == 4) {
$this_th.attr('colspan', '5');
@ -218,6 +219,24 @@ $(document).ready(function() {
$("#sqlqueryresults").live('appendAnchor',function() {
appendInlineAnchor();
})
/**
* Attach the {@link makegrid} function to a custom event, which will be
* triggered manually everytime the table of results is reloaded
* @memberOf jQuery
*/
$("#sqlqueryresults").live('makegrid', function() {
$('#table_results').makegrid();
})
/**
* Attach the {@link refreshgrid} function to a custom event, which will be
* triggered manually everytime the table of results is manipulated (e.g., by inline edit)
* @memberOf jQuery
*/
$("#sqlqueryresults").live('refreshgrid', function() {
$('#table_results').refreshgrid();
})
/**
* Trigger the appendAnchor event to prepare the first table for inline edit
@ -331,6 +350,7 @@ $(document).ready(function() {
$('#sqlqueryresults').show();
$("#sqlqueryresults").html(data);
$("#sqlqueryresults").trigger('appendAnchor');
$("#sqlqueryresults").trigger('makegrid');
$('#togglequerybox').show();
if($("#togglequerybox").siblings(":visible").length > 0) {
$("#togglequerybox").trigger('click');
@ -371,6 +391,7 @@ $(document).ready(function() {
$.post($the_form.attr('action'), $the_form.serialize(), function(data) {
$("#sqlqueryresults").html(data);
$("#sqlqueryresults").trigger('appendAnchor');
$("#sqlqueryresults").trigger('makegrid');
PMA_init_slider();
PMA_ajaxRemoveMessage($msgbox);
@ -394,6 +415,7 @@ $(document).ready(function() {
$.post($the_form.attr('action'), $the_form.serialize() + '&ajax_request=true', function(data) {
$("#sqlqueryresults").html(data);
$("#sqlqueryresults").trigger('appendAnchor');
$("#sqlqueryresults").trigger('makegrid');
PMA_init_slider();
PMA_ajaxRemoveMessage($msgbox);
}) // end $.post()
@ -419,7 +441,8 @@ $(document).ready(function() {
$.get($anchor.attr('href'), $anchor.serialize() + '&ajax_request=true', function(data) {
$("#sqlqueryresults")
.html(data)
.trigger('appendAnchor');
.trigger('appendAnchor')
.trigger('makegrid');
PMA_ajaxRemoveMessage($msgbox);
}) // end $.get()
})//end Sort results table
@ -438,7 +461,8 @@ $(document).ready(function() {
$.post($form.attr('action'), $form.serialize() + '&ajax_request=true' , function(data) {
$("#sqlqueryresults")
.html(data)
.trigger('appendAnchor');
.trigger('appendAnchor')
.trigger('makegrid');
PMA_init_slider();
}) // end $.post()
})
@ -524,21 +548,22 @@ $(document).ready(function() {
$this_hide.parent().removeClass("hover noclick");
$this_hide.siblings().removeClass("hover");
var last_column = $this_hide.siblings().length;
var $input_siblings = $this_hide.parent('tr').find('.inline_edit');
var txt = '';
for(var i = 4; i < last_column; i++) {
if($this_hide.siblings("td:eq(" + i + ")").hasClass("inline_edit") == false) {
continue;
$input_siblings.each(function() {
var $this_hide_siblings = $(this);
txt = $this_hide_siblings.data('original_data');
if($this_hide_siblings.children('span').children().length != 0) {
$this_hide_siblings.children('span').empty();
$this_hide_siblings.children('span').append(txt);
}
txt = $this_hide.siblings("td:eq(" + i + ")").data('original_data');
if($this_hide.siblings("td:eq(" + i + ")").children().length != 0) {
$this_hide.siblings("td:eq(" + i + ")").empty();
$this_hide.siblings("td:eq(" + i + ")").append(txt);
}
}
});
$(this).prev().prev().remove();
$(this).prev().remove();
$(this).remove();
// refresh the grid
$("#sqlqueryresults").trigger('refreshgrid');
});
} else {
var txt = '';
@ -546,7 +571,8 @@ $(document).ready(function() {
$('#table_results tbody tr td span a#hide').click(function() {
var $hide_a = $(this);
var pos = $hide_a.parents('td').index();
var $this_hide = $(this).parents('td');
var pos = $this_hide.index();
var $this_span = $hide_a.parent();
$this_span.find('a, br').remove();
@ -554,22 +580,26 @@ $(document).ready(function() {
var $this_row = $this_span.parents('tr');
// changing inline_edit_active to inline_edit_anchor
$this_row.siblings("tr:eq(3) td:eq(" + pos + ")").removeClass("inline_edit_active").addClass("inline_edit_anchor");
$this_hide.removeClass("inline_edit_active").addClass("inline_edit_anchor");
// removing marked and hover classes.
$this_row.parent('tbody').find('tr').find("td:eq(" + pos + ")").removeClass("marked hover");
for( var i = 6; i <= rows + 2; i++){
for( var i = 0; i <= rows + 2; i++){
if( $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").hasClass("inline_edit") == false) {
continue;
}
txt = $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").data('original_data');
$this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").empty();
$this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").append(txt);
$this_row_siblings = $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")");
txt = $this_row_siblings.data('original_data');
$this_row_siblings.children('span').empty();
$this_row_siblings.children('span').append(txt);
}
$(this).prev().remove();
$(this).prev().remove();
$(this).remove();
// refresh the grid
$("#sqlqueryresults").trigger('refreshgrid');
});
}
@ -601,7 +631,7 @@ $(document).ready(function() {
/**
* @var data_value Current value of this field
*/
var data_value = $(this).html();
var data_value = $(this).children('span').html();
// We need to retrieve the value from the server for truncated/relation fields
// Find the field name
@ -610,6 +640,10 @@ $(document).ready(function() {
* @var this_field Object referring to this field (<td>)
*/
var $this_field = $(this);
/**
* @var this_field_span Object referring to this field's child (<span>)
*/
var $this_field_span = $(this).children('span');
/**
* @var field_name String containing the name of this field.
* @see getFieldName()
@ -627,11 +661,11 @@ $(document).ready(function() {
/**
* @var curr_value String current value of the field (for fields that are of type enum or set).
*/
var curr_value = $this_field.text();
var curr_value = $this_field_span.text();
if($this_field.is(':not(.not_null)')){
// add a checkbox to mark null for all the field that are nullable.
$this_field.html('<div class="null_div">Null :<input type="checkbox" class="checkbox_null_'+ field_name + '_' + this_row_index +'"></div>');
$this_field_span.html('<div class="null_div">Null :<input type="checkbox" class="checkbox_null_'+ field_name + '_' + this_row_index +'"></div>');
// check the 'checkbox_null_<field_name>_<row_index>' if the corresponding value is null
if($this_field.is('.null')) {
$('.checkbox_null_' + field_name + '_' + this_row_index).attr('checked', true);
@ -678,15 +712,17 @@ $(document).ready(function() {
})
} else {
$this_field.html('<div class="null_div"></div>');
$this_field_span.html('<div class="null_div"></div>');
}
// In each input sibling, wrap the current value in a textarea
// and store the current value in a hidden span
if($this_field.is(':not(.truncated, .transformed, .relation, .enum, .set, .null)')) {
// handle non-truncated, non-transformed, non-relation values
value = data_value.replace("<br>", "\n");
// We don't need to get any more data, just wrap the value
$this_field.append('<textarea>'+data_value+'</textarea>');
$this_field_span.append('<textarea>' + value + '</textarea>');
$this_field.data('original_data', data_value);
}
else if($this_field.is('.truncated, .transformed')) {
@ -707,8 +743,9 @@ $(document).ready(function() {
'inline_edit' : true
}, function(data) {
if(data.success == true) {
$this_field.append('<textarea>'+data.value+'</textarea>');
$this_field_span.append('<textarea>'+data.value+'</textarea>');
$this_field.data('original_data', data_value);
$("#sqlqueryresults").trigger('refreshgrid');
}
else {
PMA_ajaxShowMessage(data.error);
@ -734,8 +771,9 @@ $(document).ready(function() {
}
$.post('sql.php', post_params, function(data) {
$this_field.append(data.dropdown);
$this_field_span.append(data.dropdown);
$this_field.data('original_data', data_value);
$("#sqlqueryresults").trigger('refreshgrid');
}) // end $.post()
}
else if($this_field.is('.enum')) {
@ -755,8 +793,9 @@ $(document).ready(function() {
'curr_value' : curr_value
}
$.post('sql.php', post_params, function(data) {
$this_field.append(data.dropdown);
$this_field_span.append(data.dropdown);
$this_field.data('original_data', data_value);
$("#sqlqueryresults").trigger('refreshgrid');
}) // end $.post()
}
else if($this_field.is('.set')) {
@ -777,16 +816,21 @@ $(document).ready(function() {
}
$.post('sql.php', post_params, function(data) {
$this_field.append(data.select);
$this_field_span.append(data.select);
$this_field.data('original_data', data_value);
$("#sqlqueryresults").trigger('refreshgrid');
}) // end $.post()
}
else if($this_field.is('.null')) {
//handle null fields
$this_field.append('<textarea></textarea>');
$this_field_span.append('<textarea></textarea>');
$this_field.data('original_data', 'NULL');
}
})
});
// refresh the grid
$("#sqlqueryresults").trigger('refreshgrid');
}) // End On click, replace the current field with an input/textarea
/**
@ -808,7 +852,7 @@ $(document).ready(function() {
* being edited
*
*/
var $this_td = $(this).parent().parent();
var $this_td = $(this).parents('td');
var $test_element = ''; // to test the presence of a element
// Initialize variables
@ -1020,6 +1064,159 @@ $(document).ready(function() {
PMA_unInlineEditRow($del_hide, $chg_submit, $this_td, $input_siblings, '', disp_mode);
}
}) // End After editing, clicking again should post data
/**
* Ajax Event for table row change
* */
$("#resultsForm.ajax .mult_submit[value=edit]").live('click', function(event){
event.preventDefault();
/*Check whether atleast one row is selected for change*/
if ($("#table_results tbody tr, #table_results tbody tr td").hasClass("marked")) {
var div = $('<div id="change_row_dialog"></div>');
/**
* @var button_options Object that stores the options passed to jQueryUI
* dialog
*/
var button_options = {};
// in the following function we need to use $(this)
button_options[PMA_messages['strCancel']] = function() {$(this).parent().dialog('close').remove();}
var button_options_error = {};
button_options_error[PMA_messages['strOK']] = function() {$(this).parent().dialog('close').remove();}
var $form = $("#resultsForm");
var $msgbox = PMA_ajaxShowMessage();
$.get( $form.attr('action'), $form.serialize()+"&ajax_request=true&submit_mult=row_edit", function(data) {
//in the case of an error, show the error message returned.
if (data.success != undefined && data.success == false) {
div
.append(data.error)
.dialog({
title: PMA_messages['strChangeTbl'],
height: 230,
width: 900,
open: PMA_verifyTypeOfAllColumns,
buttons : button_options_error
})// end dialog options
} else {
div
.append(data)
.dialog({
title: PMA_messages['strChangeTbl'],
height: 600,
width: 900,
open: PMA_verifyTypeOfAllColumns,
buttons : button_options
})
//Remove the top menu container from the dialog
.find("#topmenucontainer").hide()
; // end dialog options
$(".insertRowTable").addClass("ajax");
$("#buttonYes").addClass("ajax");
}
PMA_ajaxRemoveMessage($msgbox);
}) // end $.get()
} else {
PMA_ajaxShowMessage(PMA_messages['strNoRowSelected']);
}
});
/**
* Click action for "Go" button in ajax dialog insertForm -> insertRowTable
*/
$("#insertForm .insertRowTable.ajax input[value=Go]").live('click', function(event) {
event.preventDefault();
/**
* @var the_form object referring to the insert form
*/
var $form = $("#insertForm");
PMA_prepareForAjaxRequest($form);
//User wants to submit the form
$.post($form.attr('action'), $form.serialize(), function(data) {
if (data.success == true) {
PMA_ajaxShowMessage(data.message);
if ($("#pageselector").length != 0) {
$("#pageselector").trigger('change');
} else {
$("input[name=navig].ajax").trigger('click');
}
} else {
PMA_ajaxShowMessage(data.error);
$("#table_results tbody tr.marked .multi_checkbox " +
", #table_results tbody tr td.marked .multi_checkbox").prop("checked", false);
$("#table_results tbody tr.marked .multi_checkbox " +
", #table_results tbody tr td.marked .multi_checkbox").removeClass("last_clicked");
$("#table_results tbody tr" +
", #table_results tbody tr td").removeClass("marked");
}
if ($("#change_row_dialog").length > 0) {
$("#change_row_dialog").dialog("close").remove();
}
/**Update the row count at the tableForm*/
$("#result_query").remove();
$("#sqlqueryresults").prepend(data.sql_query);
$("#result_query .notice").remove();
$("#result_query").prepend((data.message));
}) // end $.post()
}) // end insert table button "Go"
/**$("#buttonYes.ajax").live('click'
* Click action for #buttonYes button in ajax dialog insertForm
*/
$("#buttonYes.ajax").live('click', function(event){
event.preventDefault();
/**
* @var the_form object referring to the insert form
*/
var $form = $("#insertForm");
/**Get the submit type and the after insert type in the form*/
var selected_submit_type = $("#insertForm").find("#actions_panel .control_at_footer option:selected").attr('value');
var selected_after_insert = $("#insertForm").find("#actions_panel select[name=after_insert] option:selected").attr('value');
$("#result_query").remove();
PMA_prepareForAjaxRequest($form);
//User wants to submit the form
$.post($form.attr('action'), $form.serialize() , function(data) {
if (data.success == true) {
PMA_ajaxShowMessage(data.message);
if (selected_submit_type == "showinsert") {
$("#sqlqueryresults").prepend(data.sql_query);
$("#result_query .notice").remove();
$("#result_query").prepend(data.message);
$("#table_results tbody tr.marked .multi_checkbox " +
", #table_results tbody tr td.marked .multi_checkbox").prop("checked", false);
$("#table_results tbody tr.marked .multi_checkbox " +
", #table_results tbody tr td.marked .multi_checkbox").removeClass("last_clicked");
$("#table_results tbody tr" +
", #table_results tbody tr td").removeClass("marked");
} else {
if ($("#pageselector").length != 0) {
$("#pageselector").trigger('change');
} else {
$("input[name=navig].ajax").trigger('click');
}
$("#result_query").remove();
$("#sqlqueryresults").prepend(data.sql_query);
$("#result_query .notice").remove();
$("#result_query").prepend((data.message));
}
} else {
PMA_ajaxShowMessage(data.error);
$("#table_results tbody tr.marked .multi_checkbox " +
", #table_results tbody tr td.marked .multi_checkbox").prop("checked", false);
$("#table_results tbody tr.marked .multi_checkbox " +
", #table_results tbody tr td.marked .multi_checkbox").removeClass("last_clicked");
$("#table_results tbody tr" +
", #table_results tbody tr td").removeClass("marked");
}
if ($("#change_row_dialog").length > 0) {
$("#change_row_dialog").dialog("close").remove();
}
}) // end $.post()
});
}, 'top.frame_content') // end $(document).ready()
@ -1050,10 +1247,11 @@ function PMA_unInlineEditRow($del_hide, $chg_submit, $this_td, $input_siblings,
$input_siblings.each(function() {
// Inline edit post has been successful.
$this_sibling = $(this);
$this_sibling_span = $(this).children('span');
var is_null = $this_sibling.find('input:checkbox').is(':checked');
if (is_null) {
$this_sibling.html('NULL');
$this_sibling_span.html('NULL');
$this_sibling.addClass('null');
} else {
$this_sibling.removeClass('null');
@ -1113,9 +1311,12 @@ function PMA_unInlineEditRow($del_hide, $chg_submit, $this_td, $input_siblings,
}
}
}
$this_sibling.html(new_html);
$this_sibling_span.html(new_html);
}
})
// refresh the grid
$("#sqlqueryresults").trigger('refreshgrid');
}
/**
@ -1162,24 +1363,29 @@ $(document).ready(function() {
$('.column_heading.marker').live('click', function() {
PMA_changeClassForColumn($(this), 'marked');
});
/**
* create resizable table
*/
$("#sqlqueryresults").trigger('makegrid');
});
/*
/*
* Profiling Chart
*/
function createProfilingChart() {
if($('#profilingchart').length==0) return;
var cdata = new Array();
$.each(jQuery.parseJSON($('#profilingchart').html()),function(key,value) {
cdata.push([key,parseFloat(value)]);
});
// Prevent the user from seeing the JSON code
$('div#profilingchart').html('').show();
PMA_createChart({
chart: {
chart: {
renderTo: 'profilingchart',
backgroundColor: $('#sqlqueryresults fieldset').css('background-color')
},

250
js/tbl_gis_visualization.js Normal file
View File

@ -0,0 +1,250 @@
/**
* @fileoverview functions used for visualizing GIS data
*
* @requires jquery
* @requires jquery/jquery.svg.js
* @requires jquery/jquery.mousewheel.js
* @requires jquery/jquery.event.drag-2.0.min.js
*/
var x = 0;
var y = 0;
var scale = 1;
var svg;
/**
* Zooms and pans the visualization.
*/
function zoomAndPan() {
var g = svg.getElementById('groupPanel');
g.setAttribute('transform', 'translate(' + x + ', ' + y + ') scale(' + scale + ')');
var id;
var circle;
$('circle.vector').each(function() {
id = $(this).attr('id');
circle = svg.getElementById(id);
svg.change(circle, {
r : (3 / scale),
"stroke-width" : (2 / scale)
});
});
var line;
$('polyline.vector').each(function() {
id = $(this).attr('id');
line = svg.getElementById(id);
svg.change(line, {
"stroke-width" : (2 / scale)
});
});
var polygon;
$('path.vector').each(function() {
id = $(this).attr('id');
polygon = svg.getElementById(id);
svg.change(polygon, {
"stroke-width" : (0.5 / scale)
});
});
}
/**
* Ajax handlers for GIS visualization page
*
* Actions Ajaxified here:
*
* Zooming in and zooming out on mousewheel movement.
* Panning the visualization on dragging.
* Zooming in on double clicking.
* Zooming out on clicking the zoom out button.
* Panning on clicking the arrow buttons.
* Displaying tooltips for GIS objects.
*/
$(document).ready(function() {
var $placeholder = $('#placeholder');
var $openlayersmap = $('#openlayersmap');
if ($('#choice').prop('checked') != true) {
$openlayersmap.hide();
} else {
$placeholder.hide();
}
var cssObj = {
'border' : '1px solid #aaa',
'width' : $placeholder.width(),
'height' : $placeholder.height(),
'float' : 'right'
};
$openlayersmap.css(cssObj);
drawOpenLayers();
$('.choice').show();
$('#choice').bind('click', function() {
if ($(this).prop('checked') == false) {
$placeholder.show();
$openlayersmap.hide();
} else {
$placeholder.hide();
$openlayersmap.show();
}
});
$('#placeholder').svg({
onLoad: function(svg_ref) {
svg = svg_ref;
}
});
// Removes the second SVG element unnecessarily added due to the above command.
$('#placeholder').find('svg:nth-child(2)').remove();
if ($("#placeholder svg").length > 0) {
var pmaThemeImage = $('#pmaThemeImage').attr('value');
// add panning arrows
$('<img class="button" id="left_arrow" src="' + pmaThemeImage + 'west-mini.png">').appendTo($placeholder);
$('<img class="button" id="right_arrow" src="' + pmaThemeImage + 'east-mini.png">').appendTo($placeholder);
$('<img class="button" id="up_arrow" src="' + pmaThemeImage + 'north-mini.png">').appendTo($placeholder);
$('<img class="button" id="down_arrow" src="' + pmaThemeImage + 'south-mini.png">').appendTo($placeholder);
// add zooming controls
$('<img class="button" id="zoom_in" src="' + pmaThemeImage + 'zoom-plus-mini.png">').appendTo($placeholder);
$('<img class="button" id="zoom_world" src="' + pmaThemeImage + 'zoom-world-mini.png">').appendTo($placeholder);
$('<img class="button" id="zoom_out" src="' + pmaThemeImage + 'zoom-minus-mini.png">').appendTo($placeholder);
}
$('#placeholder').live('mousewheel', function(event, delta) {
if (delta > 0) {
//zoom in
scale *= 1.5;
// zooming in keeping the position under mouse pointer unmoved.
x = event.layerX - (event.layerX - x) * 1.5;
y = event.layerY - (event.layerY - y) * 1.5;
zoomAndPan();
} else {
//zoom out
scale /= 1.5;
// zooming out keeping the position under mouse pointer unmoved.
x = event.layerX - (event.layerX - x) / 1.5;
y = event.layerY - (event.layerY - y) / 1.5;
zoomAndPan();
}
return true;
});
var dragX = 0; var dragY = 0;
$('svg').live('dragstart', function(event, dd) {
$placeholder.addClass('placeholderDrag');
dragX = Math.round(dd.offsetX);
dragY = Math.round(dd.offsetY);
});
$('svg').live('mouseup', function(event) {
$placeholder.removeClass('placeholderDrag');
});
$('svg').live('drag', function(event, dd) {
newX = Math.round(dd.offsetX);
x += newX - dragX;
dragX = newX;
newY = Math.round(dd.offsetY);
y += newY - dragY;
dragY = newY;
zoomAndPan();
});
$('#placeholder').live('dblclick', function(event) {
scale *= 1.5;
// zooming in keeping the position under mouse pointer unmoved.
x = event.layerX - (event.layerX - x) * 1.5;
y = event.layerY - (event.layerY - y) * 1.5;
zoomAndPan();
});
$('#zoom_in').live('click', function(e) {
e.preventDefault();
//zoom in
scale *= 1.5;
width = $('#placeholder svg').attr('width');
height = $('#placeholder svg').attr('height');
// zooming in keeping the center unmoved.
x = width / 2 - (width / 2 - x) * 1.5;
y = height / 2 - (height / 2 - y) * 1.5;
zoomAndPan();
});
$('#zoom_world').live('click', function(e) {
e.preventDefault();
scale = 1;
x = 0;
y = 0;
zoomAndPan();
});
$('#zoom_out').live('click', function(e) {
e.preventDefault();
//zoom out
scale /= 1.5;
width = $('#placeholder svg').attr('width');
height = $('#placeholder svg').attr('height');
// zooming out keeping the center unmoved.
x = width / 2 - (width / 2 - x) / 1.5;
y = height / 2 - (height / 2 - y) / 1.5;
zoomAndPan();
});
$('#left_arrow').live('click', function(e) {
e.preventDefault();
x += 100;
zoomAndPan();
});
$('#right_arrow').live('click', function(e) {
e.preventDefault();
x -= 100;
zoomAndPan();
});
$('#up_arrow').live('click', function(e) {
e.preventDefault();
y += 100;
zoomAndPan();
});
$('#down_arrow').live('click', function(e) {
e.preventDefault();
y -= 100;
zoomAndPan();
});
/**
* Detect the mousemove event and show tooltips.
*/
$('.polygon, .multipolygon, .point, .multipoint, .linestring, .multilinestring, '
+ '.geometrycollection').live('mousemove', function(event) {
contents = $(this).attr('name');
$("#tooltip").remove();
if (contents != '') {
$('<div id="tooltip">' + contents + '</div>').css({
position : 'absolute',
display : 'none',
top : event.pageY + 10,
left : event.pageX + 10,
border : '1px solid #fdd',
padding : '2px',
'background-color' : '#fee',
opacity : 0.80
}).appendTo("body").fadeIn(200);
}
});
/**
* Detect the mouseout event and hide tooltips.
*/
$('.polygon, .multipolygon, .point, .multipoint, .linestring, .multilinestring, '
+ '.geometrycollection').live('mouseout', function(event) {
$("#tooltip").remove();
});
});

View File

@ -67,6 +67,7 @@ $(document).ready(function() {
// found results
$("#sqlqueryresults").html(response);
$("#sqlqueryresults").trigger('appendAnchor');
$("#sqlqueryresults").trigger('makegrid');
$('#tbl_search_form')
// work around for bug #3168569 - Issue on toggling the "Hide search criteria" in chrome.
.slideToggle()

View File

@ -145,5 +145,251 @@ $(document).ready(function() {
}) // end $.get()
}) // end $.PMA_confirm()
}) //end Drop Primary Key/Index
/**
*Ajax event handler for muti column change
**/
$("#fieldsForm.ajax .mult_submit[value=change]").live('click', function(event){
event.preventDefault();
/*Check whether atleast one row is selected for change*/
if($("#tablestructure tbody tr").hasClass("marked")){
var div = $('<div id="change_column_dialog"></div>');
/**
* @var button_options Object that stores the options passed to jQueryUI
* dialog
*/
var button_options = {};
// in the following function we need to use $(this)
button_options[PMA_messages['strCancel']] = function() {$(this).parent().dialog('close').remove();}
var button_options_error = {};
button_options_error[PMA_messages['strOK']] = function() {$(this).parent().dialog('close').remove();}
var $form = $("#fieldsForm");
var $msgbox = PMA_ajaxShowMessage();
$.get( $form.attr('action') , $form.serialize()+"&ajax_request=true&submit_mult=change" , function(data) {
//in the case of an error, show the error message returned.
if (data.success != undefined && data.success == false) {
div
.append(data.error)
.dialog({
title: PMA_messages['strChangeTbl'],
height: 230,
width: 900,
open: PMA_verifyTypeOfAllColumns,
buttons : button_options_error
})// end dialog options
} else {
div
.append(data)
.dialog({
title: PMA_messages['strChangeTbl'],
height: 600,
width: 900,
open: PMA_verifyTypeOfAllColumns,
buttons : button_options
})
//Remove the top menu container from the dialog
.find("#topmenucontainer").hide()
; // end dialog options
$("#append_fields_form input[name=do_save_data]").addClass("ajax");
}
PMA_ajaxRemoveMessage($msgbox);
}) // end $.get()
} else {
PMA_ajaxShowMessage(PMA_messages['strNoRowSelected']);
}
});
/**
*Ajax action for submitting the column change form
**/
$("#append_fields_form input[name=do_save_data].ajax").live('click', function(event) {
event.preventDefault();
/**
* @var the_form object referring to the export form
*/
var $form = $("#append_fields_form");
PMA_prepareForAjaxRequest($form);
//User wants to submit the form
$.post($form.attr('action'), $form.serialize()+"&do_save_data=Save", function(data) {
if ($("#sqlqueryresults").length != 0) {
$("#sqlqueryresults").remove();
} else if ($(".error").length != 0) {
$(".error").remove();
}
if (data.success == true) {
PMA_ajaxShowMessage(data.message);
$("<div id='sqlqueryresults'></div>").insertAfter("#topmenucontainer");
$("#sqlqueryresults").html(data.sql_query);
$("#result_query .notice").remove();
$("#result_query").prepend((data.message));
if ($("#change_column_dialog").length > 0) {
$("#change_column_dialog").dialog("close").remove();
}
/*Reload the field form*/
$.post($("#fieldsForm").attr('action'), $("#fieldsForm").serialize()+"&ajax_request=true", function(form_data) {
$("#fieldsForm").remove();
var $temp_div = $("<div id='temp_div'><div>").append(form_data);
if ($("#sqlqueryresults").length != 0) {
$temp_div.find("#fieldsForm").insertAfter("#sqlqueryresults");
} else {
$temp_div.find("#fieldsForm").insertAfter(".error");
}
/*Call the function to display the more options in table*/
displayMoreTableOpts();
});
} else {
var $temp_div = $("<div id='temp_div'><div>").append(data);
var $error = $temp_div.find(".error code").addClass("error");
PMA_ajaxShowMessage($error);
}
}) // end $.post()
}) // end insert table button "do_save_data"
/**
*Ajax event handler for index edit
**/
$("#table_index tbody tr td.edit_index.ajax").live('click', function(event){
event.preventDefault();
var url = $(this).find("a").attr("href");
if (url.substring(0, 16) == "tbl_indexes.php?") {
url = url.substring(16, url.length );
}
url = url + "&ajax_request=true";
var div = $('<div id="edit_index_dialog"></div>');
/**
* @var button_options Object that stores the options passed to jQueryUI
* dialog
*/
var button_options = {};
// in the following function we need to use $(this)
button_options[PMA_messages['strCancel']] = function() {$(this).parent().dialog('close').remove();}
var button_options_error = {};
button_options_error[PMA_messages['strOK']] = function() {$(this).parent().dialog('close').remove();}
var $msgbox = PMA_ajaxShowMessage();
$.get( "tbl_indexes.php" , url , function(data) {
//in the case of an error, show the error message returned.
if (data.success != undefined && data.success == false) {
div
.append(data.error)
.dialog({
title: PMA_messages['strEdit'],
height: 230,
width: 900,
open: PMA_verifyTypeOfAllColumns,
buttons : button_options_error
})// end dialog options
} else {
div
.append(data)
.dialog({
title: PMA_messages['strEdit'],
height: 600,
width: 900,
open: PMA_verifyTypeOfAllColumns,
buttons : button_options
})
//Remove the top menu container from the dialog
.find("#topmenucontainer").hide()
; // end dialog options
}
PMA_ajaxRemoveMessage($msgbox);
}) // end $.get()
});
/**
*Ajax action for submiting the index form
**/
$("#index_frm.ajax input[name=do_save_data]").live('click', function(event) {
event.preventDefault();
/**
* @var the_form object referring to the export form
*/
var $form = $("#index_frm");
PMA_prepareForAjaxRequest($form);
//User wants to submit the form
$.post($form.attr('action'), $form.serialize()+"&do_save_data=Save", function(data) {
if ($("#sqlqueryresults").length != 0) {
$("#sqlqueryresults").remove();
}
if (data.success == true) {
PMA_ajaxShowMessage(data.message);
$("<div id='sqlqueryresults'></div>").insertAfter("#topmenucontainer");
$("#sqlqueryresults").html(data.sql_query);
$("#result_query .notice").remove();
$("#result_query").prepend((data.message));
/*Reload the field form*/
$("#table_index").remove();
var temp_div = $("<div id='temp_div'><div>").append(data.index_table);
$(temp_div).find("#table_index").insertAfter("#index_header");
if ($("#edit_index_dialog").length > 0) {
$("#edit_index_dialog").dialog("close").remove();
}
} else {
var temp_div = $("<div id='temp_div'><div>").append(data.error);
var error = $(temp_div).find(".error code").addClass("error");
PMA_ajaxShowMessage(error);
}
}) // end $.post()
}) // end insert table button "do_save_data"
/**
*Ajax action for submiting the index form for add more columns
**/
$("#index_frm.ajax input[name=add_fields]").live('click', function(event) {
event.preventDefault();
/**
* @var the_form object referring to the export form
*/
var $form = $("#index_frm");
PMA_prepareForAjaxRequest($form);
//User wants to submit the form
$.post($form.attr('action'), $form.serialize()+"&add_fields=Go", function(data) {
$("#index_columns").remove();
var temp_div = $("<div id='temp_div'><div>").append(data);
$(temp_div).find("#index_columns").insertAfter("#index_frm fieldset .error");
}) // end $.post()
}) // end insert table button "Go"
/**Add the show/hide index table option if the index is available*/
if ($("#index_div.ajax").find("#table_index").length != 0) {
/**
*Prepare a div containing a link for toggle the index table
*/
$('<div id="toggletableindexdiv"><a id="toggletableindexlink"></a></div>')
.insertAfter('#index_div')
/** don't show it until we have index table on-screen */
.show();
/** Changing the displayed text according to the hide/show criteria in table index*/
$('#toggletableindexlink')
.html(PMA_messages['strHideIndexes'])
.bind('click', function() {
var $link = $(this);
$('#index_div').slideToggle();
if ($link.text() == PMA_messages['strHideIndexes']) {
$link.text(PMA_messages['strShowIndexes']);
} else {
$link.text(PMA_messages['strHideIndexes']);
}
/** avoid default click action */
return false;
});
} //end show/hide table index
}) // end $(document).ready()

View File

@ -305,10 +305,6 @@ class PMA_Config
/**
* loads default values from default source
*
* @uses file_exists()
* @uses $this->default_source
* @uses $this->error_config_default_file
* @uses $this->settings
* @return boolean success
*/
function loadDefaults()
@ -418,16 +414,6 @@ class PMA_Config
* Loads user preferences and merges them with current config
* must be called after control connection has been estabilished
*
* @uses $GLOBALS['cfg']
* @uses $GLOBALS['collation_connection']
* @uses $GLOBALS['lang']
* @uses $_SESSION['cache']['server_$server']['config_mtime']
* @uses $_SESSION['cache']['server_$server']['userprefs']
* @uses $_SESSION['cache']['server_$server']['userprefs_mtime']
* @uses $_SESSION['PMA_Theme_Manager']
* @uses PMA_apply_userprefs()
* @uses PMA_array_merge_recursive()
* @uses PMA_load_userprefs()
* @return boolean
*/
function loadUserPreferences()
@ -530,10 +516,6 @@ class PMA_Config
* If user preferences are not yet initialized, option is applied to global config and
* added to a update queue, which is processed by {@link loadUserPreferences()}
*
* @uses $GLOBALS['cfg']
* @uses PMA_array_read()
* @uses PMA_array_write()
* @uses PMA_persist_option()
* @param string $cookie_name can be null
* @param string $cfg_path
* @param mixed $new_cfg_value
@ -672,7 +654,6 @@ class PMA_Config
/**
* sets configuration variable
*
* @uses $this->settings
* @param string $setting configuration option
* @param string $value new value for configuration option
*/
@ -890,14 +871,6 @@ class PMA_Config
/**
* checks for font size configuration, and sets font size as requested by user
*
* @uses $_GET
* @uses $_POST
* @uses $_COOKIE
* @uses preg_match()
* @uses function_exists()
* @uses PMA_Config::set()
* @uses PMA_Config::get()
* @uses PMA_Config::setCookie()
*/
function checkFontsize()
{
@ -1105,8 +1078,6 @@ class PMA_Config
/**
* returns options for font size selection
*
* @uses preg_replace()
* @uses ksort()
* @static
* @param string $current_size current selected font size with unit
* @return array selectable font sizes
@ -1167,9 +1138,6 @@ class PMA_Config
/**
* returns html selectbox for font sizes
*
* @uses $GLOBALS['PMA_Config']
* @uses PMA_Config::get()
* @uses PMA_Config::_getFontsizeOptions()
* @static
* @param string $current_size currently slected font size with unit
* @return string html selectbox
@ -1204,8 +1172,6 @@ class PMA_Config
/**
* return complete font size selection form
*
* @uses PMA_generate_common_hidden_inputs()
* @uses PMA_Config::_getFontsizeSelection()
* @static
* @param string $current_size currently slected font size with unit
* @return string html selectbox
@ -1225,10 +1191,6 @@ class PMA_Config
/**
* removes cookie
*
* @uses PMA_Config::isHttps()
* @uses PMA_Config::getCookiePath()
* @uses setcookie()
* @uses time()
* @param string $cookie name of cookie to remove
* @return boolean result of setcookie()
*/
@ -1242,12 +1204,6 @@ class PMA_Config
* sets cookie if value is different from current cokkie value,
* or removes if value is equal to default
*
* @uses PMA_Config::isHttps()
* @uses PMA_Config::getCookiePath()
* @uses $_COOKIE
* @uses PMA_Config::removeCookie()
* @uses setcookie()
* @uses time()
* @param string $cookie name of cookie to remove
* @param mixed $value new cookie value
* @param string $default default value

View File

@ -93,12 +93,6 @@ class PMA_Error extends PMA_Message
/**
* Constructor
*
* @uses debug_backtrace()
* @uses PMA_Error::setNumber()
* @uses PMA_Error::setMessage()
* @uses PMA_Error::setFile()
* @uses PMA_Error::setLine()
* @uses PMA_Error::setBacktrace()
* @param integer $errno
* @param string $errstr
* @param string $errfile
@ -122,7 +116,6 @@ class PMA_Error extends PMA_Message
/**
* sets PMA_Error::$_backtrace
*
* @uses PMA_Error::$_backtrace to set it
* @param array $backtrace
*/
public function setBacktrace($backtrace)
@ -133,7 +126,6 @@ class PMA_Error extends PMA_Message
/**
* sets PMA_Error::$_line
*
* @uses PMA_Error::$_line to set it
* @param integer $line
*/
public function setLine($line)
@ -144,8 +136,6 @@ class PMA_Error extends PMA_Message
/**
* sets PMA_Error::$_file
*
* @uses PMA_Error::$_file to set it
* @uses PMA_Error::relPath()
* @param string $file
*/
public function setFile($file)
@ -157,13 +147,6 @@ class PMA_Error extends PMA_Message
/**
* returns unique PMA_Error::$_hash, if not exists it will be created
*
* @uses PMA_Error::$_hash as return value and to set it if required
* @uses PMA_Error::getNumber()
* @uses PMA_Error::getMessage()
* @uses PMA_Error::getFile()
* @uses PMA_Error::getLine()
* @uses PMA_Error::getBacktrace()
* @uses md5()
* @param string $file
* @return string PMA_Error::$_hash
*/
@ -185,7 +168,6 @@ class PMA_Error extends PMA_Message
/**
* returns PMA_Error::$_backtrace
*
* @uses PMA_Error::$_backtrace as return value
* @return array PMA_Error::$_backtrace
*/
public function getBacktrace()
@ -196,7 +178,6 @@ class PMA_Error extends PMA_Message
/**
* returns PMA_Error::$_file
*
* @uses PMA_Error::$_file as return value
* @return string PMA_Error::$_file
*/
public function getFile()
@ -207,7 +188,6 @@ class PMA_Error extends PMA_Message
/**
* returns PMA_Error::$_line
*
* @uses PMA_Error::$_line as return value
* @return integer PMA_Error::$_line
*/
public function getLine()
@ -218,8 +198,6 @@ class PMA_Error extends PMA_Message
/**
* returns type of error
*
* @uses PMA_Error::$errortype
* @uses PMA_Error::getNumber()
* @return string type of error
*/
public function getType()
@ -230,8 +208,6 @@ class PMA_Error extends PMA_Message
/**
* returns level of error
*
* @uses PMA_Error::$$errorlevel
* @uses PMA_Error::getNumber()
* @return string level of error
*/
public function getLevel()
@ -242,9 +218,6 @@ class PMA_Error extends PMA_Message
/**
* returns title prepared for HTML Title-Tag
*
* @uses PMA_Error::getTitle()
* @uses htmlspecialchars()
* @uses substr()
* @return string HTML escaped and truncated title
*/
public function getHtmlTitle()
@ -255,8 +228,6 @@ class PMA_Error extends PMA_Message
/**
* returns title for error
*
* @uses PMA_Error::getType()
* @uses PMA_Error::getMessage()
* @return string
*/
public function getTitle()
@ -267,10 +238,6 @@ class PMA_Error extends PMA_Message
/**
* Display HTML backtrace
*
* @uses PMA_Error::getBacktrace()
* @uses PMA_Error::relPath()
* @uses PMA_Error::displayArg()
* @uses count()
*/
public function displayBacktrace()
{
@ -300,9 +267,6 @@ class PMA_Error extends PMA_Message
* Display a single function argument
* if $function is one of include/require the $arg is converted te relative path
*
* @uses PMA_Error::relPath()
* @uses in_array()
* @uses gettype()
* @param string $arg
* @param string $function
*/
@ -327,11 +291,6 @@ class PMA_Error extends PMA_Message
/**
* Displays the error in HTML
*
* @uses PMA_Error::getLevel()
* @uses PMA_Error::getType()
* @uses PMA_Error::getMessage()
* @uses PMA_Error::displayBacktrace()
* @uses PMA_Error::isDisplayed()
*/
public function display()
{
@ -356,10 +315,6 @@ class PMA_Error extends PMA_Message
/**
* whether this error is a user error
*
* @uses E_USER_WARNING
* @uses E_USER_ERROR
* @uses E_USER_NOTICE
* @uses PMA_Error::getNumber()
* @return boolean
*/
public function isUserError()
@ -374,16 +329,6 @@ class PMA_Error extends PMA_Message
* and make users feel save to submit error reports
*
* @static
* @uses PHP_OS()
* @uses __FILE__()
* @uses realpath()
* @uses substr()
* @uses explode()
* @uses dirname()
* @uses implode()
* @uses count()
* @uses array_pop()
* @uses str_replace()
* @param string $dest path to be shorten
* @return string shortened path
*/

View File

@ -28,7 +28,6 @@ class PMA_Error_Handler
/**
* Constructor - set PHP error handler
*
* @uses set_error_handler()
*/
public function __construct()
{
@ -40,10 +39,6 @@ class PMA_Error_Handler
*
* stores errors in session
*
* @uses $_SESSION['errors']
* @uses array_merge()
* @uses PMA_Error_Handler::$_errors
* @uses PMA_Error::isDisplayed()
*/
public function __destruct()
{
@ -69,8 +64,6 @@ class PMA_Error_Handler
/**
* returns array with all errors
*
* @uses PMA_Error_Handler::$_errors as return value
* @uses PMA_Error_Handler::_checkSavedErrors()
* @return array PMA_Error_Handler::$_errors
*/
protected function getErrors()
@ -90,24 +83,6 @@ class PMA_Error_Handler
* Do not use the context parameter as we want to avoid storing the
* complete $GLOBALS inside $_SESSION['errors']
*
* @uses E_USER_NOTICE
* @uses E_USER_WARNING
* @uses E_STRICT
* @uses E_NOTICE
* @uses E_WARNING
* @uses E_CORE_WARNING
* @uses E_COMPILE_WARNING
* @uses E_USER_ERROR
* @uses E_ERROR
* @uses E_PARSE
* @uses E_CORE_ERROR
* @uses E_COMPILE_ERROR
* @uses E_RECOVERABLE_ERROR
* @uses PMA_Error
* @uses PMA_Error_Handler::$_errors
* @uses PMA_Error_Handler::_dispFatalError()
* @uses PMA_Error::getHash()
* @uses PMA_Error::getNumber()
* @param integer $errno
* @param string $errstr
* @param string $errfile
@ -151,8 +126,6 @@ class PMA_Error_Handler
* log error to configured log facility
*
* @todo finish!
* @uses PMA_Error::getMessage()
* @uses error_log()
* @param PMA_Error $error
*/
protected function _logError($error)
@ -163,7 +136,6 @@ class PMA_Error_Handler
/**
* trigger a custom error
*
* @uses trigger_error()
* @param string $errorInfo
* @param integer $errorNumber
* @param string $file
@ -178,10 +150,6 @@ class PMA_Error_Handler
/**
* display fatal error and exit
*
* @uses headers_sent()
* @uses PMA_Error::display()
* @uses PMA_Error_Handler::_dispPageStart()
* @uses PMA_Error_Handler::_dispPageEnd()
* @param PMA_Error $error
*/
protected function _dispFatalError($error)
@ -197,10 +165,6 @@ class PMA_Error_Handler
/**
* display the whole error page with all errors
*
* @uses headers_sent()
* @uses PMA_Error_Handler::dispAllErrors()
* @uses PMA_Error_Handler::_dispPageStart()
* @uses PMA_Error_Handler::_dispPageEnd()
*/
public function dispErrorPage()
{
@ -214,10 +178,6 @@ class PMA_Error_Handler
/**
* display user errors not displayed
*
* @uses PMA_Error_Handler::getErrors()
* @uses PMA_Error::isDisplayed()
* @uses PMA_Error::isUserError()
* @uses PMA_Error::display()
*/
public function dispUserErrors()
{
@ -231,7 +191,6 @@ class PMA_Error_Handler
/**
* display HTML header
*
* @uses PMA_Error::getTitle()
* @param PMA_error $error
*/
protected function _dispPageStart($error = null)
@ -257,8 +216,6 @@ class PMA_Error_Handler
/**
* display all errors regardless already displayed or user errors
*
* @uses PMA_Error_Handler::getErrors()
* @uses PMA_Error::display()
*/
public function dispAllErrors()
{
@ -270,11 +227,6 @@ class PMA_Error_Handler
/**
* display errors not displayed
*
* @uses $cfg['Error_Handler']['display']
* @uses PMA_Error_Handler::getErrors()
* @uses PMA_Error_Handler::dispUserErrors()
* @uses PMA_Error::isDisplayed()
* @uses PMA_Error::display()
*/
public function dispErrors()
{
@ -296,9 +248,6 @@ class PMA_Error_Handler
/**
* look in session for saved errors
*
* @uses $_SESSION['errors']
* @uses PMA_Error_Handler::$_errors
* @uses array_merge()
*/
protected function _checkSavedErrors()
{
@ -321,8 +270,6 @@ class PMA_Error_Handler
/**
* return count of errors
*
* @uses PMA_Error_Handler::getErrors()
* @uses count()
* @return integer number of errors occoured
*/
public function countErrors()
@ -333,9 +280,6 @@ class PMA_Error_Handler
/**
* return count of user errors
*
* @uses PMA_Error_Handler::countErrors()
* @uses PMA_Error_Handler::getErrors()
* @uses PMA_Error::isUserError()
* @return integer number of user errors occoured
*/
public function countUserErrors()
@ -355,7 +299,6 @@ class PMA_Error_Handler
/**
* whether use errors occured or not
*
* @uses PMA_Error_Handler::countUserErrors()
* @return boolean
*/
public function hasUserErrors()
@ -366,7 +309,6 @@ class PMA_Error_Handler
/**
* whether errors occured or not
*
* @uses PMA_Error_Handler::countErrors()
* @return boolean
*/
public function hasErrors()
@ -377,9 +319,6 @@ class PMA_Error_Handler
/**
* number of errors to be displayed
*
* @uses $cfg['Error_Handler']['display']
* @uses PMA_Error_Handler::countErrors()
* @uses PMA_Error_Handler::countUserErrors()
* @return integer number of errors to be displayed
*/
public function countDisplayErrors()
@ -394,7 +333,6 @@ class PMA_Error_Handler
/**
* whether there are errors to display or not
*
* @uses PMA_Error_Handler::countDisplayErrors()
* @return boolean
*/
public function hasDisplayErrors()

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