[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_0-136-g9210f44

Michal Čihař nijel at users.sourceforge.net
Wed May 11 13:45:21 CEST 2011


The branch, master has been updated
       via  9210f44a612511a92790c92ed4204e7098fc3488 (commit)
       via  d8ae01cdcf9159a4daa4d3ba397b315a935ef634 (commit)
       via  b37d10c3f1fee524a296da6f9202774acf57ce6e (commit)
       via  3222d3a43d5510b2d45f613fcc6f30b52a09e538 (commit)
       via  0d39b5f71a8a237b0ff179538cf5fff5e4dbf18e (commit)
      from  d5f4903d208e6810ab8986b1b65bd891040c79a9 (commit)


- Log -----------------------------------------------------------------
commit 9210f44a612511a92790c92ed4204e7098fc3488
Author: Atul Pratap Singh <atulpratapsingh05 at gmail.com>
Date:   Fri Mar 25 15:54:59 2011 +0530

    When leaving the designer page without saving layout, it now asks for user confirmation

commit d8ae01cdcf9159a4daa4d3ba397b315a935ef634
Merge: 3222d3a43d5510b2d45f613fcc6f30b52a09e538 b37d10c3f1fee524a296da6f9202774acf57ce6e
Author: Michal Čihař <mcihar at novell.com>
Date:   Wed May 11 13:40:39 2011 +0200

    Merge branch 'integration'
    
    Conflicts:
    	js/tbl_operations.js

commit b37d10c3f1fee524a296da6f9202774acf57ce6e
Author: Benoit Dumesnil <best-ben at hotmail.fr>
Date:   Sun Mar 27 05:06:48 2011 +0200

    Feature Request #3187076
    
    This patch transforms the old-style pop-up of truncate and drop table
    to a ajax style pop-up

commit 3222d3a43d5510b2d45f613fcc6f30b52a09e538
Author: ayax88 <ayax88 at users.sourceforge.net>
Date:   Wed May 11 13:31:25 2011 +0200

    Add support for mass prefix change (rfe#2021981).

commit 0d39b5f71a8a237b0ff179538cf5fff5e4dbf18e
Author: Miłosz Lewandowski <milosz.lewandowski at gmail.com>
Date:   Thu Apr 7 18:41:05 2011 +0200

    Show message to move config in setup (bug #3277503).

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                      |    1 +
 db_structure.php               |    6 +++
 js/functions.js                |   71 ++++++++++++++++++++++++++++++++++---
 js/messages.php                |    3 ++
 libraries/mult_submits.inc.php |   76 +++++++++++++++++++++++++++++++++++-----
 pmd/scripts/move.js            |   50 ++++++++++++++++++++++++++
 setup/config.php               |    2 +-
 setup/frames/index.inc.php     |   12 ++++++
 setup/index.php                |    4 ++
 tbl_operations.php             |    9 ++++-
 10 files changed, 217 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8621526..23f11a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 ======================
 
 3.5.0.0 (not yet released)
++ rfe #2021981 [interface] Add support for mass prefix change.
 
 3.4.1.0 (not yet released)
 
diff --git a/db_structure.php b/db_structure.php
index d81af5d..ebc6915 100644
--- a/db_structure.php
+++ b/db_structure.php
@@ -517,6 +517,12 @@ if (!$db_is_information_schema) {
          . __('Repair table') . '</option>' . "\n";
     echo '    <option value="analyze_tbl" >'
          . __('Analyze table') . '</option>' . "\n";
+    echo '    <option value="add_prefix_tbl" >'
+         . __('Add prefix to table') . '</option>' . "\n";
+    echo '    <option value="replace_prefix_tbl" >'
+         . __('Replace table prefix') . '</option>' . "\n";
+    echo '    <option value="copy_tbl_change_prefix" >'
+         . __('Copy table with prefix') . '</option>' . "\n";
 }
 ?>
 </select>
diff --git a/js/functions.js b/js/functions.js
index 572c857..6cae921 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -1269,7 +1269,7 @@ function PMA_ajaxShowMessage(message, timeout) {
             .hide();
         })
     }
-	
+
 	return $("#loading");
 }
 
@@ -1442,7 +1442,7 @@ $(document).ready(function() {
                     open: PMA_verifyTypeOfAllColumns,
                     buttons : button_options
                 }); // end dialog options
-            }            
+            }
             PMA_ajaxRemoveMessage($msgbox);
         }) // end $.get()
 
@@ -1583,7 +1583,7 @@ $(document).ready(function() {
                 $("#create_table_div").html(data);
             }
             PMA_verifyTypeOfAllColumns();
-            PMA_ajaxRemoveMessage($msgbox);    
+            PMA_ajaxRemoveMessage($msgbox);
         }) //end $.post()
 
     }) // end create table form (add fields)
@@ -1733,7 +1733,7 @@ $(document).ready(function() {
             .dialog({
                 title: PMA_messages['strChangePassword'],
                 width: 600,
-                close: function(ev,ui) {$(this).remove();}, 
+                close: function(ev,ui) {$(this).remove();},
                 buttons : button_options,
                 beforeClose: function(ev,ui){ $('#change_password_anchor.dialog_active').removeClass('dialog_active').addClass('ajax')}
             })
@@ -1772,7 +1772,7 @@ $(document).ready(function() {
                 $("#change_password_dialog").hide().remove();
                 $("#edit_user_dialog").dialog("close").remove();
                 $('#change_password_anchor.dialog_active').removeClass('dialog_active').addClass('ajax');
-                PMA_ajaxRemoveMessage($msgbox); 
+                PMA_ajaxRemoveMessage($msgbox);
             }
             else {
                 PMA_ajaxShowMessage(data.error);
@@ -2278,3 +2278,64 @@ $(document).ready(function() {
 
 }) // end of $(document).ready()
 
+/**
+ * Attach Ajax event handlers for Drop Table.
+ *
+ * @uses    $.PMA_confirm()
+ * @uses    PMA_ajaxShowMessage()
+ * @uses    window.parent.refreshNavigation()
+ * @uses    window.parent.refreshMain()
+ * @see $cfg['AjaxEnable']
+ */
+$(document).ready(function() {
+    $("#drop_tbl_anchor").live('click', function(event) {
+        event.preventDefault();
+
+        //context is top.frame_content, so we need to use window.parent.db to access the db var
+        /**
+         * @var question    String containing the question to be asked for confirmation
+         */
+        var question = PMA_messages['strDropTableStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + ' :\n' + 'DROP TABLE ' + window.parent.table;
+
+        $(this).PMA_confirm(question, $(this).attr('href') ,function(url) {
+
+            PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
+            $.get(url, {'is_js_confirmed': '1', 'ajax_request': true}, function(data) {
+                //Database deleted successfully, refresh both the frames
+                window.parent.refreshNavigation();
+                window.parent.refreshMain();
+            }) // end $.get()
+        }); // end $.PMA_confirm()
+    }); //end of Drop Table Ajax action
+}) // end of $(document).ready() for Drop Table
+
+/**
+ * Attach Ajax event handlers for Truncate Table.
+ *
+ * @uses    $.PMA_confirm()
+ * @uses    PMA_ajaxShowMessage()
+ * @uses    window.parent.refreshNavigation()
+ * @uses    window.parent.refreshMain()
+ * @see $cfg['AjaxEnable']
+ */
+$(document).ready(function() {
+    $("#truncate_tbl_anchor").live('click', function(event) {
+        event.preventDefault();
+
+        //context is top.frame_content, so we need to use window.parent.db to access the db var
+        /**
+         * @var question    String containing the question to be asked for confirmation
+         */
+        var question = PMA_messages['strTruncateTableStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + ' :\n' + 'TRUNCATE TABLE ' + window.parent.table;
+
+        $(this).PMA_confirm(question, $(this).attr('href') ,function(url) {
+
+            PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
+            $.get(url, {'is_js_confirmed': '1', 'ajax_request': true}, function(data) {
+                //Database deleted successfully, refresh both the frames
+                window.parent.refreshNavigation();
+                window.parent.refreshMain();
+            }) // end $.get()
+        }); // end $.PMA_confirm()
+    }); //end of Drop Table Ajax action
+}) // end of $(document).ready() for Drop Table
diff --git a/js/messages.php b/js/messages.php
index 0f7c8c7..d6d35db 100644
--- a/js/messages.php
+++ b/js/messages.php
@@ -29,6 +29,8 @@ $js_messages['strNoDropDatabases'] = __('"DROP DATABASE" statements are disabled
 /* For confirmations */
 $js_messages['strDoYouReally'] = __('Do you really want to ');
 $js_messages['strDropDatabaseStrongWarning'] = __('You are about to DESTROY a complete database!');
+$js_messages['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');
@@ -101,6 +103,7 @@ $js_messages['strSelectReferencedKey'] = __('Select referenced key');
 $js_messages['strSelectForeignKey'] = __('Select Foreign Key');
 $js_messages['strPleaseSelectPrimaryOrUniqueKey'] = __('Please select the primary key or a unique key');
 $js_messages['strChangeDisplay'] = __('Choose column to display');
+$js_messages['strLeavingDesigner'] = __('You haven\'t saved the changes in the layout. They will be lost if you don\'t save them.Do you want to continue?');
 
 /* Visual query builder (pmd/scripts/move.js) */
 $js_messages['strAddOption'] = __('Add an option for column ');
diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php
index 270ab71..7c8f27c 100644
--- a/libraries/mult_submits.inc.php
+++ b/libraries/mult_submits.inc.php
@@ -29,6 +29,9 @@ if (! empty($submit_mult)
         } else {
            $selected = $selected_tbl;
            switch ($submit_mult) {
+               case 'add_prefix_tbl': 
+               case 'replace_prefix_tbl':
+               case 'copy_tbl_change_prefix':
                case 'drop_db':
                case 'drop_tbl':
                case 'empty_tbl':
@@ -238,16 +241,50 @@ if (!empty($submit_mult) && !empty($what)) {
     <?php
     echo PMA_generate_common_hidden_inputs($_url_params);
     ?>
-<fieldset class="confirmation">
-    <legend><?php echo ($what == 'drop_db' ? __('You are about to DESTROY a complete database!') . ' ' : '') . __('Do you really want to '); ?>:</legend>
-    <tt><?php echo $full_query; ?></tt>
-</fieldset>
-<fieldset class="tblFooters">
-    <input type="submit" name="mult_btn" value="<?php echo __('Yes'); ?>" id="buttonYes" />
-    <input type="submit" name="mult_btn" value="<?php echo __('No'); ?>" id="buttonNo" />
-</fieldset>
+<?php if ($what == 'replace_prefix_tbl' || $what == 'copy_tbl_change_prefix'){ ?>
+        <fieldset class = "input">
+                <legend><?php echo ($what == 'replace_prefix_tbl' ? __('Replace table prefix') : __('Copy table with prefix')) ?>:</legend>
+                <table>
+                <tr>
+                <td><?php echo __('From'); ?></td><td><input type="text" name="from_prefix" id="initialPrefix"</td>
+                </tr>
+                <tr>
+                <td><?php echo __('To'); ?> </td><td><input type="text" name="to_prefix" id="newPrefix"</td>
+                </tr>
+                </table>
+        </fieldset>
+        <fieldset class="tblFooters">
+                <button type="submit" name="mult_btn" value="<?php echo __('Yes'); ?>" id="buttonYes"><? echo __('Submit'); ?></button>
+        </fieldset>
     <?php
-    require './libraries/footer.inc.php';
+        }
+        elseif($what == 'add_prefix_tbl'){ ?>
+        <fieldset class = "input">
+                <legend><?php echo __('Add table prefix') ?>:</legend>
+                <table>
+                <tr>
+                <td><?php echo __('Add prefix'); ?></td>     <td><input type="text" name="add_prefix" id="txtPrefix"</td>
+                </tr>
+                </table>
+        </fieldset>
+        <fieldset class="tblFooters">
+                <button type="submit" name="mult_btn" value="<?php echo __('Yes'); ?>" id="buttonYes"><? echo __('Submit'); ?></button>
+        </fieldset>
+    <?php
+        }
+        else { ?>
+	<fieldset class="confirmation">
+	    <legend><?php echo ($what == 'drop_db' ? __('You are about to DESTROY a complete database!') . ' ' : '') . __('Do you really want to '); ?>:</legend>
+	    <tt><?php echo $full_query; ?></tt>
+	</fieldset>
+	<fieldset class="tblFooters">
+	    <input type="submit" name="mult_btn" value="<?php echo __('Yes'); ?>" id="buttonYes" />
+	    <input type="submit" name="mult_btn" value="<?php echo __('No'); ?>" id="buttonNo" />
+	</fieldset>
+    <?php
+	}
+	require './libraries/footer.inc.php';
+
 } // end if
 
 
@@ -373,6 +410,27 @@ elseif ($mult_btn == __('Yes')) {
                            . PMA_backquote($selected[$i])
                            . (($i == $selected_cnt-1) ? ');' : '');
                 break;
+	    
+	    case 'add_prefix_tbl':
+                $newtablename = $add_prefix . $selected[$i];
+                $a_query = 'ALTER TABLE ' . PMA_backquote($selected[$i]) . ' RENAME ' . PMA_backquote($newtablename) ; // ADD PREFIX TO TABLE NAME
+                $run_parts = true;
+                break;
+
+            case 'replace_prefix_tbl':
+                $current = $selected[$i];
+                $newtablename = preg_replace("/^" . $from_prefix . "/" , $to_prefix , $current);
+                $a_query = 'ALTER TABLE ' . PMA_backquote($selected[$i]) . ' RENAME ' . PMA_backquote($newtablename) ; // CHANGE PREFIX PATTERN
+                $run_parts = true;
+                break;
+
+            case 'copy_tbl_change_prefix':
+                $current = $selected[$i];
+                $newtablename = preg_replace("/^" . $from_prefix . "/" , $to_prefix , $current);
+                $a_query = 'CREATE TABLE ' . PMA_backquote($newtablename) . ' SELECT * FROM ' . PMA_backquote($selected[$i]) ; // COPY TABLE AND CHANGE PREFIX PATTERN
+                $run_parts = true;
+                break;
+
         } // end switch
 
         // All "DROP TABLE", "DROP FIELD", "OPTIMIZE TABLE" and "REPAIR TABLE"
diff --git a/pmd/scripts/move.js b/pmd/scripts/move.js
index b2f99ee..1ce18a1 100644
--- a/pmd/scripts/move.js
+++ b/pmd/scripts/move.js
@@ -6,6 +6,54 @@
 /**
  * init
  */
+
+
+ var _change = 0; // variable to track any change in designer layout.
+ var _staying = 0; //  variable to check if the user stayed after seeing the confirmation prompt.
+
+//   Below is the function to change the href attributes to '#' while the href script is called using
+//   the onclick event. It fixes the Internet Explorer issue with href.
+
+ $(document).ready(function(){
+    $('a').filter(function(){
+        return ( /^javascript\:/i).test($(this).attr('href'));
+    }).each(function(){
+        var hrefscript = $(this).attr('href');
+        hrefscript = hrefscript.substr(11);
+        $(this).data('hrefscript', hrefscript);
+    }).click(function(){
+        var hrefscript = $(this).data('hrefscript');
+        eval (hrefscript);
+        return false;
+    }).attr('href', '#');
+}); 
+
+// Below is the function to bind onbeforeunload events with the content_frame as well as the top window.
+
+ $(document).ready(function(){
+    $(window).bind('beforeunload', function(){        // onbeforeunload for the frame window.
+        if (_change == 1 && _staying == 0) 
+            return PMA_messages['strLeavingDesigner'];
+        else if (_change == 1 && _staying == 1) 
+            _staying = 0;
+    });
+    $(window).unload(function(){
+        _change = 0;
+    });    
+    window.top.onbeforeunload = function(){     // onbeforeunload for the browser main window.
+        if (_change == 1 && _staying == 0){
+            _staying = 1;                                                   //  Helps if the user stays on the page  as there
+            setTimeout('make_zero();', 100);                    //   is no other way of knowing whether the user stayed or not.
+            return PMA_messages['strLeavingDesigner'];
+        }
+    };
+});
+ 
+ function make_zero(){   // Function called if the user stays after seeing the confirmation prompt.
+      _staying = 0;
+}
+
+
 var dx, dy, dy2;
 var cur_click;
 // update in Main()
@@ -95,6 +143,7 @@ function MouseMove(e)
     //window.status = "X = "+ Glob_X + " Y = "+ Glob_Y;
 
     if (cur_click != null) {
+        _change = 1;
         var mGx = Glob_X - dx;
         var mGy = Glob_Y - dy;
         mGx = mGx > 0 ? mGx : 0;
@@ -448,6 +497,7 @@ function Get_url_pos()
 
 function Save2()
 {
+    _change = 0;
     var poststr = 'IS_AJAX=1&server='+server+'&db=' + db + '&token=' + token + '&die_save_pos=1';
     poststr += Get_url_pos();
     makeRequest('pmd_save_pos.php', poststr);
diff --git a/setup/config.php b/setup/config.php
index fa18106..193b57f 100644
--- a/setup/config.php
+++ b/setup/config.php
@@ -48,7 +48,7 @@ if (PMA_ifSetOr($_POST['submit_clear'], '')) {
 	//
     file_put_contents($config_file_path, ConfigGenerator::getConfigFile());
     header('HTTP/1.1 303 See Other');
-    header('Location: index.php');
+    header('Location: index.php?action_done=config_saved');
     exit;
 } elseif (PMA_ifSetOr($_POST['submit_load'], '')) {
 	//
diff --git a/setup/frames/index.inc.php b/setup/frames/index.inc.php
index 9103606..ea88aa7 100644
--- a/setup/frames/index.inc.php
+++ b/setup/frames/index.inc.php
@@ -85,6 +85,18 @@ if (!$is_https) {
     </select>
 </form>
 
+<?php
+// Check for done action info and set notice message if present
+switch ($action_done) {
+	case 'config_saved':
+		messages_set('notice', 'config_saved', __('Configuration saved.'),
+	        PMA_lang(__('Configuration saved to file config/config.inc.php in phpMyAdmin top level directory, copy it to top level one and delete directory config to use it.')));
+		break;
+	default:
+		break;
+}
+?>
+
 <h2><?php echo __('Overview') ?></h2>
 
 <?php
diff --git a/setup/index.php b/setup/index.php
index 0d4ae4f..736587f 100644
--- a/setup/index.php
+++ b/setup/index.php
@@ -22,6 +22,10 @@ if (!file_exists("./setup/frames/$page.inc.php")) {
     die('Wrong GET file attribute value');
 }
 
+// Handle done action info
+$action_done = filter_input(INPUT_GET, 'action_done');
+$action_done = preg_replace('/[^a-z_]/', '', $action_done);
+
 // send no-cache headers
 require './libraries/header_http.inc.php';
 ?>
diff --git a/tbl_operations.php b/tbl_operations.php
index 28530da..5ba5aab 100644
--- a/tbl_operations.php
+++ b/tbl_operations.php
@@ -30,6 +30,11 @@ $cfgRelation = PMA_getRelationsParam();
 require_once './libraries/mysql_charsets.lib.php';
 require_once './libraries/StorageEngine.class.php';
 
+// add a javascript file for jQuery functions to handle Ajax actions
+// also add jQueryUI
+$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
+$GLOBALS['js_include'][] = 'tbl_operations.js';
+
 /**
  * Class for partition management
  */
@@ -684,7 +689,7 @@ if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_
             'message_to_show' => sprintf(__('Table %s has been emptied'), htmlspecialchars($table)),
         ));
     ?>
-    <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" onclick="return confirmLink(this, '<?php echo PMA_jsFormat($this_sql_query); ?>')">
+    <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'id="truncate_tbl_anchor"' : ''); ?>>
             <?php echo __('Empty the table (TRUNCATE)'); ?></a>
         <?php echo PMA_showMySQLDocu('SQL-Syntax', 'TRUNCATE_TABLE'); ?>
     </li>
@@ -704,7 +709,7 @@ if (! (isset($db_is_information_schema) && $db_is_information_schema)) {
             'table' => $GLOBALS['table'],
         ));
     ?>
-    <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" onclick="return confirmLink(this, '<?php echo PMA_jsFormat($this_sql_query); ?>')">
+    <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'id="drop_tbl_anchor"' : ''); ?>>
             <?php echo __('Delete the table (DROP)'); ?></a>
         <?php echo PMA_showMySQLDocu('SQL-Syntax', 'DROP_TABLE'); ?>
     </li>


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list