Conditional Ajax for db Structure and Tracking

This commit is contained in:
Marc Delisle
2011-01-29 11:15:35 -05:00
parent 3c573fc82e
commit dea96e2e5a
5 changed files with 37 additions and 7 deletions

View File

@@ -266,7 +266,11 @@ foreach ($tables as $keyname => $each_table) {
if (! $db_is_information_schema) {
if (! empty($each_table['TABLE_ROWS'])) {
$empty_table = '<a class="truncate_table_anchor" href="sql.php?' . $tbl_url_query
$empty_table = '<a ';
if ($GLOBALS['cfg']['AjaxEnable']) {
$empty_table .= 'class="truncate_table_anchor"';
}
$empty_table .= ' href="sql.php?' . $tbl_url_query
. '&amp;sql_query=';
$empty_table .= urlencode('TRUNCATE ' . PMA_backquote($each_table['TABLE_NAME']))
. '&amp;message_to_show='
@@ -355,7 +359,7 @@ foreach ($tables as $keyname => $each_table) {
<?php echo $titles['Insert']; ?></a></td>
<td align="center"><?php echo $empty_table; ?></td>
<td align="center">
<a class="drop_table_anchor" href="sql.php?<?php echo $tbl_url_query;
<a <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'class="drop_table_anchor"' : ''); ?> href="sql.php?<?php echo $tbl_url_query;
?>&amp;reload=1&amp;purge=1&amp;sql_query=<?php
echo urlencode($drop_query); ?>&amp;message_to_show=<?php
echo urlencode($drop_message); ?>" >

View File

@@ -11,6 +11,7 @@ require_once './libraries/common.inc.php';
//Get some js files needed for Ajax requests
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
$GLOBALS['js_include'][] = 'db_structure.js';
/**
* If we are not in an Ajax request, then do the common work and show the links etc.
@@ -129,7 +130,7 @@ if (PMA_DBI_num_rows($all_tables_result) > 0) {
<td><?php echo $version_data['date_created'];?></td>
<td><?php echo $version_data['date_updated'];?></td>
<td><?php echo $version_status;?></td>
<td><a class="drop_tracking_anchor" href="<?php echo $delete_link;?>" ><?php echo $drop_image_or_text; ?></a></td>
<td><a <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'class="drop_tracking_anchor"' : ''); ?> href="<?php echo $delete_link;?>" ><?php echo $drop_image_or_text; ?></a></td>
<td> <a href="<?php echo $tmp_link; ?>"><?php echo __('Versions');?></a>
| <a href="<?php echo $tmp_link; ?>&amp;report=true&amp;version=<?php echo $version_data['version'];?>"><?php echo __('Tracking report');?></a>
| <a href="<?php echo $tmp_link; ?>&amp;snapshot=true&amp;version=<?php echo $version_data['version'];?>"><?php echo __('Structure snapshot');?></a></td>

View File

@@ -57,6 +57,7 @@ $(document).ready(function() {
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
* @see $cfg['AjaxEnable']
*/
$(".truncate_table_anchor").live('click', function(event) {
event.preventDefault();
@@ -105,6 +106,7 @@ $(document).ready(function() {
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
* @see $cfg['AjaxEnable']
*/
$(".drop_table_anchor").live('click', function(event) {
event.preventDefault();
@@ -150,6 +152,7 @@ $(document).ready(function() {
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
* @see $cfg['AjaxEnable']
*/
$('.drop_event_anchor').live('click', function(event) {
event.preventDefault();
@@ -188,6 +191,7 @@ $(document).ready(function() {
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
* @see $cfg['AjaxEnable']
*/
$('.drop_procedure_anchor').live('click', function(event) {
event.preventDefault();
@@ -217,19 +221,28 @@ $(document).ready(function() {
}) // end $.PMA_confirm()
}) //end Drop Procedure
/**
* Ajax Event handler for 'Drop tracking'
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowMessage()
* @see $cfg['AjaxEnable']
*/
$('.drop_tracking_anchor').live('click', function(event) {
event.preventDefault();
var $anchor = $(this);
/**
* @var curr_tracking_row Object containing reference to the current tracked table's row
*/
var curr_tracking_row = $(this).parents('tr');
var curr_tracking_row = $anchor.parents('tr');
/**
* @var question String containing the question to be asked for confirmation
*/
var question = PMA_messages['strDeleteTrackingData'];
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
$anchor.PMA_confirm(question, $anchor.attr('href'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strDeletingTrackingData']);

View File

@@ -25,6 +25,11 @@ if ($events) {
__('Type'));
$ct=0;
$delimiter = '//';
if ($GLOBALS['cfg']['AjaxEnable']) {
$conditional_class = 'class="drop_event_anchor"';
} else {
$conditional_class = '';
}
foreach ($events as $event) {
// information_schema (at least in MySQL 5.1.22) does not return
@@ -45,7 +50,7 @@ if ($events) {
($ct%2 == 0) ? 'even' : 'odd',
$event['EVENT_NAME'],
! empty($definition) ? PMA_linkOrButton('db_sql.php?' . $url_query . '&amp;sql_query=' . urlencode($definition) . '&amp;show_query=1&amp;db_query_force=1&amp;delimiter=' . urlencode($delimiter), $titles['Structure']) : '&nbsp;',
'<a class="drop_event_anchor" href="sql.php?' . $url_query . '&amp;sql_query=' . urlencode($sqlDrop) . '" >' . $titles['Drop'] . '</a>',
'<a ' . $conditional_class . ' href="sql.php?' . $url_query . '&amp;sql_query=' . urlencode($sqlDrop) . '" >' . $titles['Drop'] . '</a>',
$event['EVENT_TYPE']);
$ct++;
}

View File

@@ -37,6 +37,12 @@ if ($routines) {
__('Return type'));
$ct=0;
$delimiter = '//';
if ($GLOBALS['cfg']['AjaxEnable']) {
$conditional_class = 'class="drop_procedure_anchor"';
} else {
$conditional_class = '';
}
foreach ($routines as $routine) {
// information_schema (at least in MySQL 5.0.45)
@@ -64,6 +70,7 @@ if ($routines) {
} else {
$sqlDropProc = 'DROP FUNCTION ' . PMA_backquote($routine['SPECIFIC_NAME']);
}
echo sprintf('<tr class="%s">
<td><input type="hidden" class="drop_procedure_sql" value="%s" /><strong>%s</strong></td>
<td>%s</td>
@@ -75,7 +82,7 @@ if ($routines) {
$sqlDropProc,
$routine['ROUTINE_NAME'],
! empty($definition) ? PMA_linkOrButton('db_sql.php?' . $url_query . '&amp;sql_query=' . urlencode($definition) . '&amp;show_query=1&amp;db_query_force=1&amp;delimiter=' . urlencode($delimiter), $titles['Structure']) : '&nbsp;',
'<a class="drop_procedure_anchor" href="sql.php?' . $url_query . '&amp;sql_query=' . urlencode($sqlDropProc) . '" >' . $titles['Drop'] . '</a>',
'<a ' . $conditional_class . ' href="sql.php?' . $url_query . '&amp;sql_query=' . urlencode($sqlDropProc) . '" >' . $titles['Drop'] . '</a>',
$routine['ROUTINE_TYPE'],
$routine['DTD_IDENTIFIER']);
$ct++;