Git
Threads by month
- ----- 2025 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
July 2011
- 6 participants
- 320 discussions

[Phpmyadmin-git] [SCM] phpMyAdmin branch, QA_3_4, updated. RELEASE_3_4_3_1-20-g39cb4d4
by Rouslan Placella 04 Jul '11
by Rouslan Placella 04 Jul '11
04 Jul '11
The branch, QA_3_4 has been updated
via 39cb4d4798f495db25bf65dda95fc8c4e9893367 (commit)
from 2ec0de3a9f8d77c750f02c27ba8d83b407a87ea5 (commit)
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 1 +
tbl_indexes.php | 10 ++++------
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 377449c..00f3ba4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@ phpMyAdmin - ChangeLog
- 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
diff --git a/tbl_indexes.php b/tbl_indexes.php
index e2ef288..54923a0 100644
--- a/tbl_indexes.php
+++ b/tbl_indexes.php
@@ -161,7 +161,9 @@ if (isset($_REQUEST['create_index'])) {
}
?>
</legend>
-
+<?php
+PMA_Message::notice(__('("PRIMARY" <b>must</b> be the name of and <b>only of</b> a primary key!)'))->display();
+?>
<div class="formelement">
<label for="input_index_name"><?php echo __('Index name:'); ?></label>
<input type="text" name="index[Key_name]" id="input_index_name" size="25"
@@ -176,11 +178,7 @@ if (isset($_REQUEST['create_index'])) {
<?php echo PMA_showMySQLDocu('SQL-Syntax', 'ALTER_TABLE'); ?>
</div>
-
-<br class="clearfloat" />
-<?php
-PMA_Message::error(__('("PRIMARY" <b>must</b> be the name of and <b>only of</b> a primary key!)'))->display();
-?>
+<br class="clearfloat" /><br />
<table>
<thead>
hooks/post-receive
--
phpMyAdmin
1
0

[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-6541-g064d399
by Rouslan Placella 04 Jul '11
by Rouslan Placella 04 Jul '11
04 Jul '11
The branch, master has been updated
via 064d399d878f36a0a26f6db890b947bccb3ef8ab (commit)
via 2ec0de3a9f8d77c750f02c27ba8d83b407a87ea5 (commit)
from 9e8e70f0a1d21eaab1b3256c2249721150a93c7e (commit)
- Log -----------------------------------------------------------------
commit 064d399d878f36a0a26f6db890b947bccb3ef8ab
Merge: 9e8e70f0a1d21eaab1b3256c2249721150a93c7e 2ec0de3a9f8d77c750f02c27ba8d83b407a87ea5
Author: Rouslan Placella <rouslan(a)placella.com>
Date: Mon Jul 4 13:03:14 2011 +0100
Merge branch 'QA_3_4'
Conflicts:
tbl_indexes.php
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 1 +
js/indexes.js | 12 ++++++------
tbl_indexes.php | 4 ++--
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 312e148..3842abc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -39,6 +39,7 @@ phpMyAdmin - ChangeLog
- 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
3.4.3.1 (2011-07-02)
- [security] Fixed possible session manipulation in swekey authentication, see PMASA-2011-5
diff --git a/js/indexes.js b/js/indexes.js
index 9b64d92..ef6f877 100644
--- a/js/indexes.js
+++ b/js/indexes.js
@@ -17,24 +17,24 @@ 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;
}
}
diff --git a/tbl_indexes.php b/tbl_indexes.php
index 995ee24..6491c10 100644
--- a/tbl_indexes.php
+++ b/tbl_indexes.php
@@ -140,8 +140,8 @@ if (isset($_REQUEST['index']) && is_array($_REQUEST['index'])) {
?>
<form action="./tbl_indexes.php" method="post" name="index_frm" id="index_frm" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : ''); ?>
- onsubmit="if (typeof(this.elements['index'].disabled) != 'undefined') {
- this.elements['index'].disabled = false}">
+ onsubmit="if (typeof(this.elements['index[Key_name]'].disabled) != 'undefined') {
+ this.elements['index[Key_name]'].disabled = false}">
<?php
$form_params = array(
'db' => $db,
hooks/post-receive
--
phpMyAdmin
1
0

[Phpmyadmin-git] [SCM] phpMyAdmin branch, QA_3_4, updated. RELEASE_3_4_3_1-19-g2ec0de3
by Rouslan Placella 04 Jul '11
by Rouslan Placella 04 Jul '11
04 Jul '11
The branch, QA_3_4 has been updated
via 2ec0de3a9f8d77c750f02c27ba8d83b407a87ea5 (commit)
from c4ecddb5a2df58f26675f0162d8f2335b71bfbd5 (commit)
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 1 +
js/indexes.js | 12 ++++++------
tbl_indexes.php | 4 ++--
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 459bd1f..377449c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@ phpMyAdmin - ChangeLog
- 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
3.4.3.1 (2011-07-02)
- [security] Fixed possible session manipulation in swekey authentication, see PMASA-2011-5
diff --git a/js/indexes.js b/js/indexes.js
index a15b249..c7bed94 100644
--- a/js/indexes.js
+++ b/js/indexes.js
@@ -17,24 +17,24 @@ 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;
}
}
diff --git a/tbl_indexes.php b/tbl_indexes.php
index 46e5e1c..e2ef288 100644
--- a/tbl_indexes.php
+++ b/tbl_indexes.php
@@ -133,8 +133,8 @@ if (isset($_REQUEST['index']) && is_array($_REQUEST['index'])) {
?>
<form action="./tbl_indexes.php" method="post" name="index_frm"
- onsubmit="if (typeof(this.elements['index'].disabled) != 'undefined') {
- this.elements['index'].disabled = false}">
+ onsubmit="if (typeof(this.elements['index[Key_name]'].disabled) != 'undefined') {
+ this.elements['index[Key_name]'].disabled = false}">
<?php
$form_params = array(
'db' => $db,
hooks/post-receive
--
phpMyAdmin
1
0

[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-6539-g9e8e70f
by Rouslan Placella 04 Jul '11
by Rouslan Placella 04 Jul '11
04 Jul '11
The branch, master has been updated
via 9e8e70f0a1d21eaab1b3256c2249721150a93c7e (commit)
via c4ecddb5a2df58f26675f0162d8f2335b71bfbd5 (commit)
from bc828427c771ccf1197b2e0295dbd4f968e5752c (commit)
- Log -----------------------------------------------------------------
commit 9e8e70f0a1d21eaab1b3256c2249721150a93c7e
Merge: bc828427c771ccf1197b2e0295dbd4f968e5752c c4ecddb5a2df58f26675f0162d8f2335b71bfbd5
Author: Rouslan Placella <rouslan(a)placella.com>
Date: Mon Jul 4 12:32:23 2011 +0100
Merge branch 'QA_3_4'
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 1 +
tbl_structure.php | 8 ++------
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 25516fe..312e148 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,6 +38,7 @@ phpMyAdmin - ChangeLog
- 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
3.4.3.1 (2011-07-02)
- [security] Fixed possible session manipulation in swekey authentication, see PMASA-2011-5
diff --git a/tbl_structure.php b/tbl_structure.php
index 10cc8d3..afca2ea 100644
--- a/tbl_structure.php
+++ b/tbl_structure.php
@@ -723,7 +723,7 @@ if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
?>
</div>
<form action="./tbl_indexes.php" method="post"
- onsubmit="return checkFormElementInRange(this, 'idx_num_fields',
+ onsubmit="return checkFormElementInRange(this, 'added_fields',
'<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
1)">
<fieldset>
@@ -732,11 +732,7 @@ if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
echo sprintf(__('Create an index on %s columns'),
'<input type="text" size="2" name="added_fields" value="1" />');
?>
- <input type="submit" name="create_index" value="<?php echo __('Go'); ?>"
- onclick="return checkFormElementInRange(this.form,
- 'idx_num_fields',
- '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
- 1)" />
+ <input type="submit" name="create_index" value="<?php echo __('Go'); ?>" />
</fieldset>
</form>
<br />
hooks/post-receive
--
phpMyAdmin
1
0

[Phpmyadmin-git] [SCM] phpMyAdmin branch, QA_3_4, updated. RELEASE_3_4_3_1-18-gc4ecddb
by Rouslan Placella 04 Jul '11
by Rouslan Placella 04 Jul '11
04 Jul '11
The branch, QA_3_4 has been updated
via c4ecddb5a2df58f26675f0162d8f2335b71bfbd5 (commit)
from 041cd7e7d2dfa95dd055da6fd2eb5308902fda95 (commit)
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 1 +
tbl_structure.php | 8 ++------
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6bdeb8c..459bd1f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@ phpMyAdmin - ChangeLog
- 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
3.4.3.1 (2011-07-02)
- [security] Fixed possible session manipulation in swekey authentication, see PMASA-2011-5
diff --git a/tbl_structure.php b/tbl_structure.php
index 7d380b4..4c0b185 100644
--- a/tbl_structure.php
+++ b/tbl_structure.php
@@ -680,7 +680,7 @@ if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
?>
<br />
<form action="./tbl_indexes.php" method="post"
- onsubmit="return checkFormElementInRange(this, 'idx_num_fields',
+ onsubmit="return checkFormElementInRange(this, 'added_fields',
'<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
1)">
<fieldset>
@@ -689,11 +689,7 @@ if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
echo sprintf(__('Create an index on %s columns'),
'<input type="text" size="2" name="added_fields" value="1" />');
?>
- <input type="submit" name="create_index" value="<?php echo __('Go'); ?>"
- onclick="return checkFormElementInRange(this.form,
- 'idx_num_fields',
- '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
- 1)" />
+ <input type="submit" name="create_index" value="<?php echo __('Go'); ?>" />
</fieldset>
</form>
<br />
hooks/post-receive
--
phpMyAdmin
1
0

[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-6537-gbc82842
by Marc Delisle 04 Jul '11
by Marc Delisle 04 Jul '11
04 Jul '11
The branch, master has been updated
via bc828427c771ccf1197b2e0295dbd4f968e5752c (commit)
from 64e4f9fe0ed661e16172cc354e5dfd0b9111342e (commit)
- Log -----------------------------------------------------------------
commit bc828427c771ccf1197b2e0295dbd4f968e5752c
Author: Marc Delisle <marc(a)infomarc.info>
Date: Mon Jul 4 07:28:36 2011 -0400
Missing ChangeLog entry
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 587922f..25516fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,10 +27,11 @@ phpMyAdmin - ChangeLog
+ [display] GIS data visualization
+ AJAX for table structure multiple-column change
+ AJAX for table structure index edit
-+ Show/hide indexes in table structure
++ 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
3.4.4.0 (not yet released)
- bug #3323060 [parser] SQL parser breaks AJAX requests if query has unclosed quotes
hooks/post-receive
--
phpMyAdmin
1
0

[Phpmyadmin-git] [SCM] phpMyAdmin website branch, master, updated. 4058bd0bd23780d16eb957812f6296c512bf3762
by Marc Delisle 04 Jul '11
by Marc Delisle 04 Jul '11
04 Jul '11
The branch, master has been updated
via 4058bd0bd23780d16eb957812f6296c512bf3762 (commit)
from 93b17ee20ed413d79e41250f1cc55ae9961f3123 (commit)
- Log -----------------------------------------------------------------
commit 4058bd0bd23780d16eb957812f6296c512bf3762
Author: Marc Delisle <marc(a)infomarc.info>
Date: Mon Jul 4 07:18:01 2011 -0400
Clarification about need for token
-----------------------------------------------------------------------
Summary of changes:
templates/security/PMASA-2011-7 | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/templates/security/PMASA-2011-7 b/templates/security/PMASA-2011-7
index 294d7d7..a33048c 100644
--- a/templates/security/PMASA-2011-7
+++ b/templates/security/PMASA-2011-7
@@ -11,7 +11,7 @@ PMASA-2011-7
</py:def>
<py:def function="announcement_updated">
-2011-07-03
+2011-07-04
</py:def>
<py:def function="announcement_summary">
@@ -30,6 +30,8 @@ We consider this vulnerability to be serious.
All PHP versions that were current at the time of the advisory (5.3.6,
5.2.17) on all OS are vulnerable, unless the Suhosin patch has been
installed.
+
+An attacker must be logged in via phpMyAdmin to exploit this problem.
</py:def>
<py:def function="announcement_affected">
hooks/post-receive
--
phpMyAdmin website
1
0

[Phpmyadmin-git] [SCM] phpMyAdmin website branch, master, updated. 93b17ee20ed413d79e41250f1cc55ae9961f3123
by Marc Delisle 03 Jul '11
by Marc Delisle 03 Jul '11
03 Jul '11
The branch, master has been updated
via 93b17ee20ed413d79e41250f1cc55ae9961f3123 (commit)
from b5731f4ca159230c34db6ce111617ca27b1b2867 (commit)
- Log -----------------------------------------------------------------
commit 93b17ee20ed413d79e41250f1cc55ae9961f3123
Author: Marc Delisle <marc(a)infomarc.info>
Date: Sun Jul 3 09:58:15 2011 -0400
Clarify vulnerable PHP versions; new CWE ids
-----------------------------------------------------------------------
Summary of changes:
templates/security/PMASA-2011-5 | 6 +++++-
templates/security/PMASA-2011-7 | 10 ++++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/templates/security/PMASA-2011-5 b/templates/security/PMASA-2011-5
index 0661593..b21c291 100644
--- a/templates/security/PMASA-2011-5
+++ b/templates/security/PMASA-2011-5
@@ -10,6 +10,10 @@ PMASA-2011-5
2011-07-02
</py:def>
+<py:def function="announcement_updated">
+2011-07-03
+</py:def>
+
<py:def function="announcement_summary">
Possible session manipulation in Swekey authentication.
</py:def>
@@ -43,7 +47,7 @@ This issue was found by Frans Pehrson from <a href="http://www.xxor.se">Xxor AB<
<!--! CVE ID of the report, this is automatically added to references -->
<py:def function="announcement_cve">CVE-2011-2505</py:def>
-<py:def function="announcement_cwe">661</py:def>
+<py:def function="announcement_cwe">473 661</py:def>
<py:def function="announcement_commits">
7ebd958b2bf59f96fecd5b3322bdbd0b244a7967
diff --git a/templates/security/PMASA-2011-7 b/templates/security/PMASA-2011-7
index 6a1aeb6..294d7d7 100644
--- a/templates/security/PMASA-2011-7
+++ b/templates/security/PMASA-2011-7
@@ -10,12 +10,16 @@ PMASA-2011-7
2011-07-02
</py:def>
+<py:def function="announcement_updated">
+2011-07-03
+</py:def>
+
<py:def function="announcement_summary">
Regular expression quoting issue in Synchronize code.
</py:def>
<py:def function="announcement_description">
-Through a possible bug in PHP running on Windows systems a null byte can truncate the pattern string allowing an attacker to inject the /e modifier causing the preg_replace function to execute its second argument as PHP code.
+Through a possible bug in PHP, a null byte can truncate the pattern string allowing an attacker to inject the /e modifier causing the preg_replace function to execute its second argument as PHP code.
</py:def>
<py:def function="announcement_severity">
@@ -23,7 +27,9 @@ We consider this vulnerability to be serious.
</py:def>
<py:def function="announcement_mitigation">
-Only PHP running on Windows has been found to be vulnerable, Linux and OpenBSD are not affected.
+All PHP versions that were current at the time of the advisory (5.3.6,
+5.2.17) on all OS are vulnerable, unless the Suhosin patch has been
+installed.
</py:def>
<py:def function="announcement_affected">
hooks/post-receive
--
phpMyAdmin website
1
0

[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-6534-g3c0853d
by Marc Delisle 03 Jul '11
by Marc Delisle 03 Jul '11
03 Jul '11
The branch, master has been updated
via 3c0853dc681a7e4bdb463ab27009137d63325790 (commit)
via 61ea5e765db6c9382ef8fba9ab27737664b2d6cc (commit)
via c4ee218fb5c1eafce1cbe47168cb920f8bf5c902 (commit)
via 2a5fee1aed801560bd1498e6270f5de19e7c7e55 (commit)
via f0c322cbdd168d251a47ae7ed3200e4abde7cd8d (commit)
via 9ae693eb066194304c632fc4be83dc45f2e6a122 (commit)
via 24150ce3a929f64f5c2cd267372f6811de7e0296 (commit)
via d6fce49ca0b9d0e8ebe7f4f061f1b16c67005d58 (commit)
via b140a6091cb61230c7c13ac65b9fd287f47a458b (commit)
via 6665c1a88918f210dbbe0cee9fab9c22c95574bd (commit)
via 5184256f10fac2b3eb11ccb6a6e3c25133c10bfb (commit)
via 5304f19396dccd12b000c1366eca06b6edb4b518 (commit)
via b97aeef6b6a71519af3cf39b2866629a472ea283 (commit)
via 14ffb9ae84c5f749d480a7d7e71e47345eca050d (commit)
via 60a0334661c25b36ccbe7caa0248dec6d641dfb5 (commit)
via c7892cf5bbb7790ea725196f4a01dd2c40f43013 (commit)
via 216b4e80b28110d4150c486ff8690d737f5ce442 (commit)
via 22ff715452ccd849a790f9ac4d429bf226777ff7 (commit)
via ba4515212a24c1d81a7251e85a82d7c8649b7604 (commit)
via 4932550801b853892f98bbcaa0dcb7607da2bbe5 (commit)
via 8686c60c8b9c81b6b269d833c90e4d8d990315c5 (commit)
via d7857edc285872ba0f4bc0e6197464e422261d80 (commit)
via 96d7a3230f52c91b768c058102c9be55b0eb0107 (commit)
via 6e7d46bd285bc1201e82a706054a58b8acd2781d (commit)
via cab875f3df38bdbd6db959a7916dbd087be7307f (commit)
via 66cb04ead51b1d88a3e95f7439b4b8687dde8398 (commit)
from cfdf3aa7c346ca90768874bfb7dd5a44920d215f (commit)
- Log -----------------------------------------------------------------
commit 3c0853dc681a7e4bdb463ab27009137d63325790
Merge: cfdf3aa7c346ca90768874bfb7dd5a44920d215f 61ea5e765db6c9382ef8fba9ab27737664b2d6cc
Author: Marc Delisle <marc(a)infomarc.info>
Date: Sun Jul 3 07:29:03 2011 -0400
Merge commit '61ea5e765db6c9382ef8fba9ab27737664b2d6cc'
commit 61ea5e765db6c9382ef8fba9ab27737664b2d6cc
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Fri Jul 1 16:19:58 2011 +0800
Shift+click: fix bug 'shift+click not working after pressing next, end, etc.'
commit c4ee218fb5c1eafce1cbe47168cb920f8bf5c902
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Fri Jul 1 11:31:30 2011 +0800
Navigation bar: more compact, display horizontal/vertical mode only when configured
commit 2a5fee1aed801560bd1498e6270f5de19e7c7e55
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Thu Jun 30 17:04:42 2011 +0800
Navigation bar: better support for IE
commit f0c322cbdd168d251a47ae7ed3200e4abde7cd8d
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Thu Jun 30 13:15:13 2011 +0800
Modify the navigation bar to provide more intuitive UI
commit 9ae693eb066194304c632fc4be83dc45f2e6a122
Merge: 24150ce3a929f64f5c2cd267372f6811de7e0296 d6fce49ca0b9d0e8ebe7f4f061f1b16c67005d58
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Wed Jun 29 10:29:17 2011 +0800
Merge branch 'hidecol' into aris
commit 24150ce3a929f64f5c2cd267372f6811de7e0296
Merge: b140a6091cb61230c7c13ac65b9fd287f47a458b eb8caa4b7742cda1816598f4b5cf18f4b0616fce
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Wed Jun 29 10:28:00 2011 +0800
Merge remote-tracking branch 'origin/master' into aris
commit d6fce49ca0b9d0e8ebe7f4f061f1b16c67005d58
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Wed Jun 29 10:27:34 2011 +0800
Show/hide column: fix bug in IE8, checkbox in column visibility list not shown
commit b140a6091cb61230c7c13ac65b9fd287f47a458b
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Wed Jun 29 00:13:54 2011 +0800
Disable text selection only for shift-click enabled table
commit 6665c1a88918f210dbbe0cee9fab9c22c95574bd
Merge: 5184256f10fac2b3eb11ccb6a6e3c25133c10bfb 5304f19396dccd12b000c1366eca06b6edb4b518
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Tue Jun 28 17:52:31 2011 +0800
Merge branch 'hidecol' into aris
commit 5184256f10fac2b3eb11ccb6a6e3c25133c10bfb
Merge: b97aeef6b6a71519af3cf39b2866629a472ea283 500daacd24292fdf2524eb2a99bf86ccaf1d9e2e
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Tue Jun 28 17:52:27 2011 +0800
Merge remote-tracking branch 'origin/master' into aris
commit 5304f19396dccd12b000c1366eca06b6edb4b518
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Tue Jun 28 17:51:59 2011 +0800
Fix bug when hovering 'More' under 'Structure' tab
commit b97aeef6b6a71519af3cf39b2866629a472ea283
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Tue Jun 28 10:25:11 2011 +0800
Fix bug in shift+click
commit 14ffb9ae84c5f749d480a7d7e71e47345eca050d
Merge: 60a0334661c25b36ccbe7caa0248dec6d641dfb5 c7892cf5bbb7790ea725196f4a01dd2c40f43013
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Tue Jun 28 09:57:25 2011 +0800
Merge branch 'hidecol' into aris
commit 60a0334661c25b36ccbe7caa0248dec6d641dfb5
Merge: 216b4e80b28110d4150c486ff8690d737f5ce442 49a39787c3d44817c4c9056e0488d420a0e000ab
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Tue Jun 28 09:50:54 2011 +0800
Fix merge conflict with origin/master
commit c7892cf5bbb7790ea725196f4a01dd2c40f43013
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Tue Jun 28 09:42:26 2011 +0800
Change to and some code fix
commit 216b4e80b28110d4150c486ff8690d737f5ce442
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Tue Jun 28 09:33:09 2011 +0800
Better shift+click handling
commit 22ff715452ccd849a790f9ac4d429bf226777ff7
Merge: 8686c60c8b9c81b6b269d833c90e4d8d990315c5 ba4515212a24c1d81a7251e85a82d7c8649b7604
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Mon Jun 27 12:10:51 2011 +0800
Merge branch 'hidecol' into aris
commit ba4515212a24c1d81a7251e85a82d7c8649b7604
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Mon Jun 27 12:10:04 2011 +0800
Remove 'too many' <th> when browsing table with vertical mode and repeat headers = small value
commit 4932550801b853892f98bbcaa0dcb7607da2bbe5
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Mon Jun 27 11:53:57 2011 +0800
Show/hide column: remove hide button, add column visibility hint, and some prettification
commit 8686c60c8b9c81b6b269d833c90e4d8d990315c5
Merge: 96d7a3230f52c91b768c058102c9be55b0eb0107 d7857edc285872ba0f4bc0e6197464e422261d80
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Sat Jun 25 00:58:03 2011 +0800
Merge branch 'hidecol' into aris
commit d7857edc285872ba0f4bc0e6197464e422261d80
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Sat Jun 25 00:57:31 2011 +0800
Show/hide column: optimize background image prefetching
commit 96d7a3230f52c91b768c058102c9be55b0eb0107
Merge: cab875f3df38bdbd6db959a7916dbd087be7307f 6e7d46bd285bc1201e82a706054a58b8acd2781d
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Fri Jun 24 23:57:00 2011 +0800
Merge branch 'hidecol' into aris
commit 6e7d46bd285bc1201e82a706054a58b8acd2781d
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Fri Jun 24 23:56:46 2011 +0800
Add image file for show/hide column
commit cab875f3df38bdbd6db959a7916dbd087be7307f
Merge: 0a6f2823bd46fc3f486c0b1ef557c1e1284626ba 66cb04ead51b1d88a3e95f7439b4b8687dde8398
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Fri Jun 24 18:20:31 2011 +0800
Merge branch 'hidecol' into aris
commit 66cb04ead51b1d88a3e95f7439b4b8687dde8398
Author: Aris Feryanto <aris_feryanto(a)yahoo.com>
Date: Fri Jun 24 18:18:43 2011 +0800
Add new feature: show/hide column(s) while browsing a table
-----------------------------------------------------------------------
Summary of changes:
Documentation.html | 6 +
js/functions.js | 188 ++++++----
js/makegrid.js | 398 ++++++++++++++++----
libraries/Table.class.php | 14 +-
libraries/config.default.php | 5 +
libraries/config/messages.inc.php | 2 +
libraries/config/setup.forms.php | 1 +
libraries/config/user_preferences.forms.php | 1 +
libraries/display_tbl.lib.php | 191 +++++-----
sql.php | 9 +-
themes/original/css/theme_right.css.php | 119 ++++++-
.../img/b_more.png => original/img/col_drop.png} | Bin 1002 -> 1002 bytes
themes/pmahomme/css/theme_right.css.php | 143 +++++++-
themes/pmahomme/img/{b_more.png => col_drop.png} | Bin 1002 -> 1002 bytes
14 files changed, 822 insertions(+), 255 deletions(-)
copy themes/{pmahomme/img/b_more.png => original/img/col_drop.png} (100%)
copy themes/pmahomme/img/{b_more.png => col_drop.png} (100%)
diff --git a/Documentation.html b/Documentation.html
index eb840d2..29054a2 100644
--- a/Documentation.html
+++ b/Documentation.html
@@ -2143,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.
diff --git a/js/functions.js b/js/functions.js
index 397f248..e25ec98 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -623,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 {
- // normaln 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 +704,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)
*/
@@ -2037,9 +2104,9 @@ function displayMoreTableOpts() {
// 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 });
});
@@ -2213,62 +2280,6 @@ $(function() {
});
/**
- * 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)
*/
function PMA_getRowNumber(classlist) {
@@ -2659,4 +2670,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);
+
diff --git a/js/makegrid.js b/js/makegrid.js
index 6e16db9..8b1bd7c 100644
--- a/js/makegrid.js
+++ b/js/makegrid.js
@@ -3,21 +3,26 @@
// prepare the grid
var g = {
// constant
- minColWidth: 5,
+ 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
- showReorderHint: false, // boolean, used by showHint() method
- showSortHint: false, // boolean, used by showHint() method
+ 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,
- hintIsHiding: false, // true when hint is still shown, but hide() already called
+ 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
@@ -28,7 +33,7 @@
obj: obj,
objLeft: $(obj).position().left,
objWidth: this.alignment != 'vertical' ?
- $(this.t).find('th.draggable:eq(' + n + ') span').outerWidth() :
+ $(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');
@@ -141,20 +146,11 @@
}
var n = this.colRsz.n;
// do the resizing
- if (this.alignment != 'vertical') {
- $(this.t).find('tr').each(function() {
- $(this).find('th.draggable:eq(' + n + ') span,' +
- 'td: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);
- });
- }
+ this.resize(n, nw);
+
$('body').css('cursor', 'default');
this.reposRsz();
+ this.reposDrop();
this.colRsz = false;
} else if (this.colMov) {
// shift columns
@@ -167,7 +163,7 @@
this.colMov.n = this.colMov.newn;
// send request to server to remember the column order
if (this.tableCreateTime) {
- this.sendColOrder();
+ this.sendColPrefs();
}
this.refreshRestoreButton();
}
@@ -188,18 +184,35 @@
},
/**
+ * 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') :
+ $(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
- var pad = parseInt($this.css('padding-right'));
- $cb.css('left', Math.floor($this.position().left + $this.width() + pad))
+ $cb.css('left', $this.position().left + $this.outerWidth(true))
.show();
}
},
@@ -229,16 +242,28 @@
// shift rows
if (newn < oldn) {
$(this.t).find('tr:eq(' + (g.actionSpan + newn) + ')')
- .before($(this.t).find('tr:eq(' + (g.actionSpan + oldn) + ')'));
+ .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) + ')'));
+ .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);
},
/**
@@ -247,10 +272,10 @@
*/
getHoveredCol: function(e) {
var hoveredCol;
- $headers = $(this.t).find('th.draggable');
+ $headers = $(this.t).find('th.draggable:visible');
if (this.alignment != 'vertical') {
$headers.each(function() {
- var left = $(this).position().left;
+ var left = $(this).offset().left;
var right = left + $(this).outerWidth();
if (left <= e.pageX && e.pageX <= right) {
hoveredCol = this;
@@ -258,7 +283,7 @@
});
} else { // vertical alignment
$headers.each(function() {
- var top = $(this).position().top;
+ var top = $(this).offset().top;
var bottom = top + $(this).height();
if (top <= e.pageY && e.pageY <= bottom) {
hoveredCol = this;
@@ -286,7 +311,7 @@
/**
* Reposition the table back to normal order.
*/
- restore: function() {
+ 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];
@@ -300,23 +325,24 @@
}
if (this.tableCreateTime) {
// send request to server to remember the column order
- this.sendColOrder();
+ this.sendColPrefs();
}
this.refreshRestoreButton();
},
/**
- * Send column order to the server.
+ * Send column preferences (column order and visibility) to the server.
*/
- sendColOrder: function() {
+ 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_order: true,
+ set_col_prefs: true,
col_order: this.colOrder.toString(),
+ col_visib: this.colVisib.toString(),
table_create_time: this.tableCreateTime
});
},
@@ -334,8 +360,10 @@
break;
}
}
+ // check if only one visible column left
+ var isOneColumn = this.visibleHeadersCount == 1;
// enable or disable restore button
- if (isInitial) {
+ if (isInitial || isOneColumn) {
$('.restore_column').hide();
} else {
$('.restore_column').show();
@@ -361,6 +389,10 @@
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) {
@@ -373,8 +405,8 @@
$(this.dHint)
.stop(true, true)
.css({
- top: e.pageY,
- left: e.pageX + 15
+ top: e.clientY,
+ left: e.clientX + 15
})
.show('fast');
this.hintShown = true;
@@ -404,18 +436,142 @@
updateHint: function(e) {
if (this.hintShown) {
$(this.dHint).css({
- top: e.pageY,
- left: e.pageX + 15
+ 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();
@@ -432,6 +588,13 @@
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;
@@ -441,6 +604,14 @@
$(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' ?
@@ -458,6 +629,8 @@
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');
@@ -468,37 +641,106 @@
}
} else {
g.colOrder = new Array();
- for (var i = 0; i < $firstRowCols.length; i++) {
+ 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
- var pad = parseInt($this.css('padding-right'));
- $(cb).css('left', Math.floor($this.position().left + $this.width() + pad));
- $(cb).addClass('colborder');
- $(cb).mousedown(function(e) {
- g.dragStartRsz(e, this);
- });
+ $(cb).addClass('colborder')
+ .mousedown(function(e) {
+ g.dragStartRsz(e, this);
+ });
$(g.cRsz).append(cb);
});
-
- // wrap all data cells, except actions cell, with span
- $(t).find('th, td:not(:has(span))')
- .wrapInner('<span />');
+ g.reposRsz();
// register events
- if ($firstRowCols.length > 1 && g.reorderHint) { // make sure columns is reorderable
+ if (g.reorderHint) { // make sure columns is reorderable
$(t).find('th.draggable')
- .css('cursor', 'move')
.mousedown(function(e) {
- g.dragStartMove(e, this);
+ if (g.visibleHeadersCount > 1) {
+ g.dragStartMove(e, this);
+ }
})
.mouseenter(function(e) {
- g.showReorderHint = true;
+ if (g.visibleHeadersCount > 1) {
+ g.showReorderHint = true;
+ $(this).css('cursor', 'move');
+ } else {
+ $(this).css('cursor', 'inherit');
+ }
g.showHint(e);
})
.mouseleave(function(e) {
@@ -506,6 +748,15 @@
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) {
@@ -533,7 +784,10 @@
g.dragEnd(e);
});
$('.restore_column').click(function() {
- g.restore();
+ g.restoreColOrder();
+ });
+ $(t).find('td, th.draggable').mouseenter(function() {
+ g.hideColList();
});
// add table class
@@ -543,9 +797,11 @@
$(t).before(g.gDiv);
$(g.gDiv).append(t);
$(g.gDiv).prepend(g.cRsz);
- $(g.gDiv).append(g.cCpy);
$(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();
@@ -574,9 +830,11 @@
var t = this;
$(document).ready(function() {
$.grid(t);
+ t.grid.reposDrop();
});
} else {
$.grid(this);
+ this.grid.reposDrop();
}
});
};
@@ -588,37 +846,19 @@
if (!docready) {
var t = this;
$(document).ready(function() {
- if (t.grid) t.grid.reposRsz();
+ if (t.grid) {
+ t.grid.reposRsz();
+ t.grid.reposDrop();
+ }
});
} else {
- if (this.grid) this.grid.reposRsz();
+ if (this.grid) {
+ this.grid.reposRsz();
+ this.grid.reposDrop();
+ }
}
});
}
- $.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);
diff --git a/libraries/Table.class.php b/libraries/Table.class.php
index 8e8a8d7..37df829 100644
--- a/libraries/Table.class.php
+++ b/libraries/Table.class.php
@@ -16,6 +16,7 @@ class PMA_Table
*/
const PROP_SORTED_COLUMN = 'sorted_col';
const PROP_COLUMN_ORDER = 'col_order';
+ const PROP_COLUMN_VISIB = 'col_visib';
static $cache = array();
@@ -1305,6 +1306,7 @@ class PMA_Table
* Available property:
* - PROP_SORTED_COLUMN
* - PROP_COLUMN_ORDER
+ * - PROP_COLUMN_VISIB
*
*
* @param string $property
@@ -1335,7 +1337,8 @@ class PMA_Table
} else {
return false;
}
- } else if ($property == self::PROP_COLUMN_ORDER) {
+ } else if ($property == self::PROP_COLUMN_ORDER ||
+ $property == self::PROP_COLUMN_VISIB) {
if (isset($this->uiprefs[$property])) {
// check if the table has not been modified
if (self::sGetStatusInfo($this->db_name, $this->name, 'Create_time') ==
@@ -1361,10 +1364,11 @@ class PMA_Table
* Available property:
* - PROP_SORTED_COLUMN
* - PROP_COLUMN_ORDER
+ * - PROP_COLUMN_VISIB
*
* @param string $property
* @param mixed $value
- * @param string $table_create_time Needed for PROP_COLUMN_ORDER
+ * @param string $table_create_time Needed for PROP_COLUMN_ORDER and PROP_COLUMN_VISIB
* @return boolean|PMA_Message
*/
public function setUiProp($property, $value, $table_create_time = NULL)
@@ -1373,8 +1377,10 @@ class PMA_Table
$this->loadUiPrefs();
}
// we want to save the create time if the property is PROP_COLUMN_ORDER
- if ($property == self::PROP_COLUMN_ORDER) {
- $curr_create_time = self::sGetStatusInfo($this->db_name, $this->name, 'Create_time');
+ if ($property == self::PROP_COLUMN_ORDER ||
+ $property == self::PROP_COLUMN_VISIB) {
+
+ $curr_create_time = self::sGetStatusInfo($this->db_name, $this->name, 'CREATE_TIME');
if (isset($table_create_time) &&
$table_create_time == $curr_create_time) {
$this->uiprefs['CREATE_TIME'] = $curr_create_time;
diff --git a/libraries/config.default.php b/libraries/config.default.php
index b355c02..809a48d 100644
--- a/libraries/config.default.php
+++ b/libraries/config.default.php
@@ -2313,6 +2313,11 @@ $cfg['ShowBrowseComments'] = true;
$cfg['ShowPropertyComments']= true;
/**
+ * shows table display direction.
+ */
+$cfg['ShowDisplayDir'] = false;
+
+/**
* repeat header names every X cells? (0 = deactivate)
*
* @global integer $cfg['RepeatCells']
diff --git a/libraries/config/messages.inc.php b/libraries/config/messages.inc.php
index 5b144e1..0602cae 100644
--- a/libraries/config/messages.inc.php
+++ b/libraries/config/messages.inc.php
@@ -450,6 +450,8 @@ $strConfigShowAll_name = __('Allow to display all the rows');
$strConfigShowChgPassword_desc = __('Please note that enabling this has no effect with [kbd]config[/kbd] authentication mode because the password is hard coded in the configuration file; this does not limit the ability to execute the same command directly');
$strConfigShowChgPassword_name = __('Show password change form');
$strConfigShowCreateDb_name = __('Show create database form');
+$strConfigShowDisplayDir_desc = __('Defines whether or not type display direction option is shown when browsing a table');
+$strConfigShowDisplayDir_name = __('Show display direction');
$strConfigShowFieldTypesInDataEditView_desc = __('Defines whether or not type fields should be initially displayed in edit/insert mode');
$strConfigShowFieldTypesInDataEditView_name = __('Show field types');
$strConfigShowFunctionFields_desc = __('Display the function fields in edit/insert mode');
diff --git a/libraries/config/setup.forms.php b/libraries/config/setup.forms.php
index 8cb473d..e1865fa 100644
--- a/libraries/config/setup.forms.php
+++ b/libraries/config/setup.forms.php
@@ -198,6 +198,7 @@ $forms['Main_frame']['Browse'] = array(
'Order',
'BrowsePointerEnable',
'BrowseMarkerEnable',
+ 'ShowDisplayDir',
'RepeatCells',
'LimitChars',
'RowActionLinks',
diff --git a/libraries/config/user_preferences.forms.php b/libraries/config/user_preferences.forms.php
index 38137ae..f1363b4 100644
--- a/libraries/config/user_preferences.forms.php
+++ b/libraries/config/user_preferences.forms.php
@@ -108,6 +108,7 @@ $forms['Main_frame']['Browse'] = array(
'DisplayBinaryAsHex',
'BrowsePointerEnable',
'BrowseMarkerEnable',
+ 'ShowDisplayDir',
'RepeatCells',
'LimitChars',
'RowActionLinks',
diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php
index 0280d8b..988da42 100644
--- a/libraries/display_tbl.lib.php
+++ b/libraries/display_tbl.lib.php
@@ -293,8 +293,9 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di
?>
<!-- Navigation bar -->
-<table border="0" cellpadding="2" cellspacing="0" class="navigation">
+<table border="0" cellpadding="0" cellspacing="0" class="navigation">
<tr>
+ <td class="navigation_separator"></td>
<?php
// Move to the beginning or to the previous page
if ($_SESSION['tmp_user_values']['pos'] && $_SESSION['tmp_user_values']['max_rows'] != 'all') {
@@ -330,8 +331,7 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di
5,
5,
20,
- 10,
- __('Page number:')
+ 10
);
?>
</form>
@@ -344,16 +344,16 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di
if ($GLOBALS['cfg']['ShowAll'] && ($num_rows < $unlim_num_rows)) {
echo "\n";
?>
-<td>
- <form action="sql.php" method="post">
- <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
- <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
- <input type="hidden" name="pos" value="0" />
- <input type="hidden" name="session_max_rows" value="all" />
- <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
- <input type="submit" name="navig" value="<?php echo __('Show all'); ?>" />
- </form>
-</td>
+ <td>
+ <form action="sql.php" method="post">
+ <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
+ <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
+ <input type="hidden" name="pos" value="0" />
+ <input type="hidden" name="session_max_rows" value="all" />
+ <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
+ <input type="submit" name="navig" value="<?php echo __('Show all'); ?>" />
+ </form>
+ </td>
<?php
} // end show all
@@ -386,9 +386,17 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di
$onclick
);
} // end move toward
+
+ // show separator if pagination happen
+ if ($nbTotalPage > 1){
+ echo '<td><div class="navigation_separator">|</div></td>';
+ }
?>
<td>
- <input class="restore_column hide" type="submit" value="<?php echo __('Restore column order'); ?>" />
+ <div class="restore_column hide">
+ <input type="submit" value="<?php echo __('Restore column order'); ?>" />
+ <div class="navigation_separator">|</div>
+ </div>
<?php
if (PMA_isSelect()) {
// generate the column order, if it is set
@@ -397,6 +405,10 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di
if ($col_order) {
echo '<input id="col_order" type="hidden" value="' . implode(',', $col_order) . '" />';
}
+ $col_visib = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_VISIB);
+ if ($col_visib) {
+ echo '<input id="col_visib" type="hidden" value="' . implode(',', $col_visib) . '" />';
+ }
// generate table create time
echo '<input id="table_create_time" type="hidden" value="' .
PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Create_time') . '" />';
@@ -405,40 +417,48 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di
echo '<input id="col_order_hint" type="hidden" value="' . __('Drag to reorder') . '" />';
echo '<input id="sort_hint" type="hidden" value="' . __('Click to sort') . '" />';
echo '<input id="col_mark_hint" type="hidden" value="' . __('Click to mark/unmark') . '" />';
+ echo '<input id="col_visib_hint" type="hidden" value="' . __('Click the drop-down arrow<br />to toggle column\'s visibility') . '" />';
+ echo '<input id="show_all_col_text" type="hidden" value="' . __('Show all') . '" />';
?>
</td>
-</tr>
-</table>
<?php // if displaying a VIEW, $unlim_num_rows could be zero because
// of $cfg['MaxExactCountViews']; in this case, avoid passing
// the 5th parameter to checkFormElementInRange()
// (this means we can't validate the upper limit ?>
-<div>
- <form action="sql.php" method="post"
-onsubmit="return (checkFormElementInRange(this, 'session_max_rows', '<?php echo str_replace('\'', '\\\'', __('%d is not valid row number.')); ?>', 1) && checkFormElementInRange(this, 'pos', '<?php echo str_replace('\'', '\\\'', __('%d is not valid row number.')); ?>', 0<?php echo $unlim_num_rows > 0 ? ',' . $unlim_num_rows - 1 : ''; ?>))">
- <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
- <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
- <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
- <input type="submit" name="navig" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : ''); ?> value="<?php echo __('Show'); ?> :" />
- <input type="text" name="session_max_rows" size="3" value="<?php echo (($_SESSION['tmp_user_values']['max_rows'] != 'all') ? $_SESSION['tmp_user_values']['max_rows'] : $GLOBALS['cfg']['MaxRows']); ?>" class="textfield" onfocus="this.select()" />
- <?php echo __('row(s) starting from row #') . "\n"; ?>
- <input type="text" name="pos" size="6" value="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" class="textfield" onfocus="this.select()" />
- <?php
- // Display mode (horizontal/vertical and repeat headers)
- $choices = array(
- 'horizontal' => __('horizontal'),
- 'horizontalflipped' => __('horizontal (rotated headers)'),
- 'vertical' => __('vertical'));
- $param1 = PMA_generate_html_dropdown('disp_direction', $choices, $_SESSION['tmp_user_values']['disp_direction'], $id_for_direction_dropdown);
- unset($choices);
-
- $param2 = ' <input type="text" size="3" name="repeat_cells" value="' . $_SESSION['tmp_user_values']['repeat_cells'] . '" class="textfield" />' . "\n"
- . ' ';
- echo ' ' . sprintf(__('in %s mode and repeat headers after %s cells'), "\n" . $param1, "\n" . $param2) . "\n";
- ?>
- </form>
-</div>
+ <td class="navigation_goto">
+ <form action="sql.php" method="post"
+ onsubmit="return (checkFormElementInRange(this, 'session_max_rows', '<?php echo str_replace('\'', '\\\'', __('%d is not valid row number.')); ?>', 1) && checkFormElementInRange(this, 'pos', '<?php echo str_replace('\'', '\\\'', __('%d is not valid row number.')); ?>', 0<?php echo $unlim_num_rows > 0 ? ',' . $unlim_num_rows - 1 : ''; ?>))">
+ <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
+ <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
+ <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
+ <input type="submit" name="navig" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : ''); ?> value="<?php echo __('Show'); ?> :" />
+ <?php echo __('Start row') . ': ' . "\n"; ?>
+ <input type="text" name="pos" size="3" value="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" class="textfield" onfocus="this.select()" />
+ <?php echo __('Number of rows') . ': ' . "\n"; ?>
+ <input type="text" name="session_max_rows" size="3" value="<?php echo (($_SESSION['tmp_user_values']['max_rows'] != 'all') ? $_SESSION['tmp_user_values']['max_rows'] : $GLOBALS['cfg']['MaxRows']); ?>" class="textfield" onfocus="this.select()" />
+ <?php
+ if ($GLOBALS['cfg']['ShowDisplayDir']) {
+ // Display mode (horizontal/vertical and repeat headers)
+ echo __('Mode') . ': ' . "\n";
+ $choices = array(
+ 'horizontal' => __('horizontal'),
+ 'horizontalflipped' => __('horizontal (rotated headers)'),
+ 'vertical' => __('vertical'));
+ echo PMA_generate_html_dropdown('disp_direction', $choices, $_SESSION['tmp_user_values']['disp_direction'], $id_for_direction_dropdown);
+ unset($choices);
+ }
+
+ echo __('Headers every') . ': ' . "\n";
+ echo '<input type="text" size="3" name="repeat_cells" value="' . $_SESSION['tmp_user_values']['repeat_cells'] . '" class="textfield" />' . "\n";
+ echo __('rows'). "\n";
+ ?>
+ </form>
+ </td>
+ <td class="navigation_separator"></td>
+</tr>
+</table>
+
<?php
} // end of the 'PMA_displayTableNavigation()' function
@@ -779,8 +799,10 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// prepare to get the column order, if available
$pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
$col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER);
+ $col_visib = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_VISIB);
} else {
$col_order = false;
+ $col_visib = false;
}
for ($j = 0; $j < $fields_cnt; $j++) {
@@ -921,6 +943,9 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
echo '<th';
$th_class = array();
$th_class[] = 'draggable';
+ if ($col_visib && !$col_visib[$j]) {
+ $th_class[] = 'hide';
+ }
if ($condition_field) {
$th_class[] = 'condition';
}
@@ -939,7 +964,9 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
echo '>' . $order_link . $comments . '</th>';
}
$vertical_display['desc'][] = ' <th '
- . 'class="draggable' . ($condition_field ? ' condition' : '') . '">' . "\n"
+ . 'class="draggable'
+ . ($condition_field ? ' condition' : '')
+ . '">' . "\n"
. $order_link . $comments . ' </th>' . "\n";
} // end if (2.1)
@@ -950,6 +977,9 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
echo '<th';
$th_class = array();
$th_class[] = 'draggable';
+ if ($col_visib && !$col_visib[$j]) {
+ $th_class[] = 'hide';
+ }
if ($condition_field) {
$th_class[] = 'condition';
}
@@ -971,7 +1001,9 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
echo "\n" . $comments . '</th>';
}
$vertical_display['desc'][] = ' <th '
- . 'class="draggable' . ($condition_field ? ' condition"' : '') . '">' . "\n"
+ . 'class="draggable'
+ . ($condition_field ? ' condition"' : '')
+ . '">' . "\n"
. ' ' . htmlspecialchars($fields_meta[$i]->name) . "\n"
. $comments . ' </th>';
} // end else (2.2)
@@ -1178,8 +1210,10 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
if (PMA_isSelect()) {
$pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
$col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER);
+ $col_visib = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_VISIB);
} else {
$col_order = false;
+ $col_visib = false;
}
// Correction University of Virginia 19991216 in the while below
@@ -1350,11 +1384,14 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$meta = $fields_meta[$i];
$not_null_class = $meta->not_null ? 'not_null' : '';
$relation_class = isset($map[$meta->name]) ? 'relation' : '';
+ $hide_class = ($col_visib && !$col_visib[$j] &&
+ // hide per <td> only if the display direction is not vertical
+ $_SESSION['tmp_user_values']['disp_direction'] != 'vertical') ? 'hide' : '';
$pointer = $i;
$is_field_truncated = false;
//If the previous column had blob data, we need to reset the class
// to $inline_edit_class
- $class = 'data ' . $inline_edit_class . ' ' . $not_null_class . ' ' . $alternating_color_class . ' ' . $relation_class;
+ $class = 'data ' . $inline_edit_class . ' ' . $not_null_class . ' ' . $alternating_color_class . ' ' . $relation_class . ' ' . $hide_class;
// See if this column should get highlight because it's used in the
// where-query.
@@ -1702,13 +1739,15 @@ function PMA_displayVerticalTable()
echo '<th></th>' . "\n";
}
echo $vertical_display['textbtn'];
- $foo_counter = 0;
+ $cell_displayed = 0;
foreach ($vertical_display['row_delete'] as $val) {
- if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
- echo '<th></th>' . "\n";
+ if (($cell_displayed != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($cell_displayed % $_SESSION['tmp_user_values']['repeat_cells'])) {
+ echo '<th' .
+ (($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? ' rowspan="4"' : '') .
+ '></th>' . "\n";
}
echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '_left', $val);
- $foo_counter++;
+ $cell_displayed++;
} // end while
echo '</tr>' . "\n";
} // end if
@@ -1720,14 +1759,8 @@ function PMA_displayVerticalTable()
if (! is_array($vertical_display['row_delete'])) {
echo $vertical_display['textbtn'];
}
- $foo_counter = 0;
foreach ($vertical_display['edit'] as $val) {
- if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
- echo ' <th></th>' . "\n";
- }
-
echo $val;
- $foo_counter++;
} // end while
echo '</tr>' . "\n";
} // end if
@@ -1739,14 +1772,8 @@ function PMA_displayVerticalTable()
if (! is_array($vertical_display['row_delete'])) {
echo $vertical_display['textbtn'];
}
- $foo_counter = 0;
foreach ($vertical_display['copy'] as $val) {
- if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
- echo ' <th></th>' . "\n";
- }
-
echo $val;
- $foo_counter++;
} // end while
echo '</tr>' . "\n";
} // end if
@@ -1758,14 +1785,8 @@ function PMA_displayVerticalTable()
if (! is_array($vertical_display['edit']) && ! is_array($vertical_display['row_delete'])) {
echo $vertical_display['textbtn'];
}
- $foo_counter = 0;
foreach ($vertical_display['delete'] as $val) {
- if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
- echo '<th></th>' . "\n";
- }
-
echo $val;
- $foo_counter++;
} // end while
echo '</tr>' . "\n";
} // end if
@@ -1774,8 +1795,10 @@ function PMA_displayVerticalTable()
// prepare to get the column order, if available
$pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
$col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER);
+ $col_visib = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_VISIB);
} else {
$col_order = false;
+ $col_visib = false;
}
// Displays data
@@ -1783,17 +1806,17 @@ function PMA_displayVerticalTable()
// assign appropriate key with current column order
$key = $col_order ? $col_order[$j] : $j;
- echo '<tr>' . "\n";
+ echo '<tr' . (($col_visib && !$col_visib[$j]) ? ' class="hide"' : '') . '>' . "\n";
echo $val;
- $foo_counter = 0;
+ $cell_displayed = 0;
foreach ($vertical_display['rowdata'][$key] as $subval) {
- if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) and !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
+ if (($cell_displayed != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) and !($cell_displayed % $_SESSION['tmp_user_values']['repeat_cells'])) {
echo $val;
}
echo $subval;
- $foo_counter++;
+ $cell_displayed++;
} // end while
echo '</tr>' . "\n";
@@ -1804,14 +1827,16 @@ function PMA_displayVerticalTable()
&& is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn']))) {
echo '<tr>' . "\n";
echo $vertical_display['textbtn'];
- $foo_counter = 0;
+ $cell_displayed = 0;
foreach ($vertical_display['row_delete'] as $val) {
- if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
- echo '<th></th>' . "\n";
+ if (($cell_displayed != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($cell_displayed % $_SESSION['tmp_user_values']['repeat_cells'])) {
+ echo '<th' .
+ (($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? ' rowspan="4"' : '') .
+ '></th>' . "\n";
}
echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '_right', $val);
- $foo_counter++;
+ $cell_displayed++;
} // end while
echo '</tr>' . "\n";
} // end if
@@ -1823,14 +1848,8 @@ function PMA_displayVerticalTable()
if (! is_array($vertical_display['row_delete'])) {
echo $vertical_display['textbtn'];
}
- $foo_counter = 0;
foreach ($vertical_display['edit'] as $val) {
- if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
- echo '<th></th>' . "\n";
- }
-
echo $val;
- $foo_counter++;
} // end while
echo '</tr>' . "\n";
} // end if
@@ -1842,14 +1861,8 @@ function PMA_displayVerticalTable()
if (! is_array($vertical_display['row_delete'])) {
echo $vertical_display['textbtn'];
}
- $foo_counter = 0;
foreach ($vertical_display['copy'] as $val) {
- if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
- echo '<th></th>' . "\n";
- }
-
echo $val;
- $foo_counter++;
} // end while
echo '</tr>' . "\n";
} // end if
@@ -1861,14 +1874,8 @@ function PMA_displayVerticalTable()
if (! is_array($vertical_display['edit']) && ! is_array($vertical_display['row_delete'])) {
echo $vertical_display['textbtn'];
}
- $foo_counter = 0;
foreach ($vertical_display['delete'] as $val) {
- if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
- echo '<th></th>' . "\n";
- }
-
echo $val;
- $foo_counter++;
} // end while
echo '</tr>' . "\n";
}
diff --git a/sql.php b/sql.php
index 10985b6..543c115 100644
--- a/sql.php
+++ b/sql.php
@@ -164,10 +164,17 @@ if(isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) {
/**
* Check ajax request to set the column order
*/
-if(isset($_REQUEST['set_col_order']) && $_REQUEST['set_col_order'] == true) {
+if(isset($_REQUEST['set_col_prefs']) && $_REQUEST['set_col_prefs'] == true) {
$pmatable = new PMA_Table($table, $db);
+
+ // set column order
$col_order = explode(',', $_REQUEST['col_order']);
$retval = $pmatable->setUiProp(PMA_Table::PROP_COLUMN_ORDER, $col_order, $_REQUEST['table_create_time']);
+
+ // set column visibility
+ $col_visib = explode(',', $_REQUEST['col_visib']);
+ $retval &= $pmatable->setUiProp(PMA_Table::PROP_COLUMN_VISIB, $col_visib, $_REQUEST['table_create_time']);
+
PMA_ajaxResponse(NULL, ($retval == true));
}
diff --git a/themes/original/css/theme_right.css.php b/themes/original/css/theme_right.css.php
index 932f6b8..5b92cd5 100644
--- a/themes/original/css/theme_right.css.php
+++ b/themes/original/css/theme_right.css.php
@@ -2067,11 +2067,15 @@ span.mysql-number {
border-right: solid 1px #FFFFFF;
cursor: col-resize;
height: 100%;
- margin-left: -3px;
+ margin-left: -6px;
position: absolute;
width: 5px;
}
+.pma_table td {
+ position: static;
+}
+
.pma_table th.draggable span, .pma_table tbody td span {
display: block;
overflow: hidden;
@@ -2121,9 +2125,120 @@ span.mysql-number {
margin-top: -1em;
opacity: 0.8;
padding: 0.5em 1em;
- position: absolute;
+ position: fixed;
text-shadow: -1px -1px #000;
-moz-border-radius: 0.3em;
-webkit-border-radius: 0.3em;
border-radius: 0.3em;
}
+
+.data {
+ position: relative;
+}
+
+.cHide {
+ background: #D3DCE3 url(<?php echo $_SESSION['PMA_Theme']->getImgPath(); ?>col_hide.png);
+ color: #CCC;
+ cursor: pointer;
+ height: 16px;
+ margin-left: -5px;
+ margin-top: 0.3em;
+ position: absolute;
+ width: 16px;
+}
+
+.cHide:hover {
+ background-color: #AAA;
+}
+
+.cDrop {
+ left: 0;
+ position: absolute;
+ top: 0;
+}
+
+.coldrop {
+ background: url(<?php echo $_SESSION['PMA_Theme']->getImgPath(); ?>col_drop.png);
+ cursor: pointer;
+ height: 16px;
+ margin-left: 0.5em;
+ margin-top: 0.3em;
+ position: absolute;
+ width: 16px;
+}
+
+.coldrop:hover, .coldrop-hover {
+ background-color: #999;
+}
+
+.cList {
+ background: #EEE;
+ border: solid 1px #999;
+ position: absolute;
+}
+
+.cList table {
+}
+
+.cList table tr:hover {
+ background: #DDD;
+ cursor: pointer;
+}
+
+.cList table td input {
+ cursor: pointer;
+}
+
+.showAllColBtn {
+ border-bottom: solid 1px #999;
+ border-top: solid 1px #999;
+ cursor: pointer;
+ font-size: 0.9em;
+ font-weight: bold;
+ padding: 0.35em 1em;
+ text-align: center;
+}
+
+.showAllColBtn:hover {
+ background: #DDD;
+}
+
+.navigation {
+ background: #E5E5E5;
+ border: 1px solid black;
+ margin: 0.8em 0;
+}
+
+.navigation td {
+ margin: 0;
+ padding: 0;
+ vertical-align: middle;
+ white-space: nowrap;
+}
+
+.navigation_separator {
+ color: #555;
+ display: inline-block;
+ text-align: center;
+ width: 1.2em;
+ text-shadow: 1px 0 #FFF;
+}
+
+.navigation input[type=submit] {
+ background: none;
+ border: 0;
+ margin: 0;
+ padding: 0.3em 0.5em;
+ min-width: 1.5em;
+ font-weight: bold;
+}
+
+.navigation input[type=submit]:hover {
+ background: #333;
+ color: white;
+ cursor: pointer;
+}
+
+.navigation select {
+ margin: 0 0.8em;
+}
diff --git a/themes/pmahomme/css/theme_right.css.php b/themes/pmahomme/css/theme_right.css.php
index 272c17b..f2250a9 100644
--- a/themes/pmahomme/css/theme_right.css.php
+++ b/themes/pmahomme/css/theme_right.css.php
@@ -65,7 +65,7 @@ h2 a img{display:inline;}
.data{
margin: 0 0 12px 0;
-
+position: relative;
}
h3 {
@@ -2422,14 +2422,18 @@ span.mysql-number {
}
.colborder {
- border-left: 1px solid #FFF;
+ border-right: 1px solid #FFF;
cursor: col-resize;
height: 100%;
- margin-left: -1px;
+ margin-left: -6px;
position: absolute;
width: 5px;
}
+.pma_table td {
+ position: static;
+}
+
.pma_table th.draggable span, .pma_table tbody td span {
display: block;
overflow: hidden;
@@ -2483,9 +2487,140 @@ span.mysql-number {
margin-top: -1em;
opacity: 0.8;
padding: 0.5em 1em;
- position: absolute;
+ position: fixed;
text-shadow: -1px -1px #000;
-moz-border-radius: 0.3em;
-webkit-border-radius: 0.3em;
border-radius: 0.3em;
}
+
+.cHide {
+ background: #EEE url(./themes/pmahomme/img/col_hide.png);
+ color: #CCC;
+ cursor: pointer;
+ height: 16px;
+ margin-left: -10px;
+ margin-top: 0.3em;
+ position: absolute;
+ width: 16px;
+}
+
+.cHide:hover {
+ background-color: #AAA;
+}
+
+.cDrop {
+ left: 0;
+ position: absolute;
+ top: 0;
+}
+
+.coldrop {
+ background: url(./themes/pmahomme/img/col_drop.png);
+ cursor: pointer;
+ height: 16px;
+ margin-left: 0.3em;
+ margin-top: 0.3em;
+ position: absolute;
+ width: 16px;
+}
+
+.coldrop:hover, .coldrop-hover {
+ background-color: #999;
+}
+
+.cList {
+ background: #EEE;
+ border: solid 1px #999;
+ position: absolute;
+ -moz-box-shadow: 0 0.2em 0.5em #333;
+ -webkit-box-shadow: 0 0.2em 0.5em #333;
+ box-shadow: 0 0.2em 0.5em #333;
+}
+
+.cList table {
+}
+
+.cList table tr:hover {
+ background: #DDD;
+ cursor: pointer;
+}
+
+.cList table td input {
+ cursor: pointer;
+}
+
+.showAllColBtn {
+ border-bottom: solid 1px #999;
+ border-top: solid 1px #999;
+ cursor: pointer;
+ font-size: 0.9em;
+ font-weight: bold;
+ padding: 0.35em 1em;
+ text-align: center;
+}
+
+.showAllColBtn:hover {
+ background: #DDD;
+}
+
+.navigation {
+ margin: 0.8em 0;
+
+ border-radius: 5px;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+
+ background-image: url(./themes/svg_gradient.php?from=eeeeee&to=cccccc);
+ background-size: 100% 100%;
+ background: -webkit-gradient(linear, left top, left bottom, from(#eeeeee), to(#cccccc));
+ background: -moz-linear-gradient(top, #eeeeee, #cccccc);
+ background: -o-linear-gradient(top, #eeeeee, #cccccc);
+ <?php echo PMA_ieFilter('#eeeeee', '#cccccc'); ?>
+}
+
+.navigation td {
+ margin: 0;
+ padding: 0;
+ vertical-align: middle;
+ white-space: nowrap;
+}
+
+.navigation_separator {
+ color: #999;
+ display: inline-block;
+ font-size: 1.5em;
+ text-align: center;
+ height: 1.4em;
+ width: 1.2em;
+ text-shadow: 1px 0 #FFF;
+}
+
+.navigation input[type=submit] {
+ background: none;
+ border: 0;
+ filter: none;
+ margin: 0;
+ padding: 0.8em 0.5em;
+
+ border-radius: 0;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+}
+
+.navigation input[type=submit]:hover {
+ color: white;
+ cursor: pointer;
+ text-shadow: none;
+
+ background-image: url(./themes/svg_gradient.php?from=333333&to=555555);
+ background-size: 100% 100%;
+ background: -webkit-gradient(linear, left top, left bottom, from(#333333), to(#555555));
+ background: -moz-linear-gradient(top, #333333, #555555);
+ background: -o-linear-gradient(top, #333333, #555555);
+ <?php echo PMA_ieFilter('#333333', '#555555'); ?>
+}
+
+.navigation select {
+ margin: 0 0.8em;
+}
hooks/post-receive
--
phpMyAdmin
1
0

[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-6508-gcfdf3aa
by Piotr Przybylski 03 Jul '11
by Piotr Przybylski 03 Jul '11
03 Jul '11
The branch, master has been updated
via cfdf3aa7c346ca90768874bfb7dd5a44920d215f (commit)
from 5560ad53e07d56e6686964de288d487df02a6153 (commit)
- Log -----------------------------------------------------------------
commit cfdf3aa7c346ca90768874bfb7dd5a44920d215f
Author: Piotr Przybylski <piotrprz(a)gmail.com>
Date: Sun Jul 3 13:21:13 2011 +0200
Whitespace cleanup
Removed @uses and fixed broken PHPDoc comments
-----------------------------------------------------------------------
Summary of changes:
libraries/server_synchronize.lib.php | 569 +++++++++++++++++-----------------
1 files changed, 278 insertions(+), 291 deletions(-)
diff --git a/libraries/server_synchronize.lib.php b/libraries/server_synchronize.lib.php
index a2ea20b..54f15bd 100644
--- a/libraries/server_synchronize.lib.php
+++ b/libraries/server_synchronize.lib.php
@@ -2,26 +2,25 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
-* PMA_getMatchingTables places matching tables in source
+* PMA_getMatchingTables places matching tables in source
* and target databases in $matching_tables array whereas
* $uncommon_source_tables array gets the tables present in
* source database but are absent from target database.
* Criterion for matching tables is just comparing their names.
-*
-* @param $trg_tables array of target database table names,
-* @param $src_tables array of source database table names,
-*
-* @param &$matching_tables empty array passed by reference to save names of matching tables,
-* @param &$uncommon_source_tables empty array passed by reference to save names of tables present in
+*
+* @param $trg_tables array of target database table names,
+* @param $src_tables array of source database table names,
+*
+* @param &$matching_tables empty array passed by reference to save names of matching tables,
+* @param &$uncommon_source_tables empty array passed by reference to save names of tables present in
* source database but absent from target database
*/
-
function PMA_getMatchingTables($trg_tables, $src_tables, &$matching_tables, &$uncommon_source_tables)
{
- for($k=0; $k< sizeof($src_tables); $k++) {
- $present_in_target = false;
- for($l=0; $l < sizeof($trg_tables); $l++) {
- if ($src_tables[$k] === $trg_tables[$l]) {
+ for($k=0; $k< sizeof($src_tables); $k++) {
+ $present_in_target = false;
+ for($l=0; $l < sizeof($trg_tables); $l++) {
+ if ($src_tables[$k] === $trg_tables[$l]) {
$present_in_target = true;
$matching_tables[] = $src_tables[$k];
}
@@ -36,30 +35,29 @@ function PMA_getMatchingTables($trg_tables, $src_tables, &$matching_tables, &$un
* PMA_getNonMatchingTargetTables() places tables present
* in target database but are absent from source database
*
-* @param $trg_tables array of target database table names,
-*
-* @param $matching_tables $matching tables array containing names of matching tables,
-* @param &$uncommon_target_tables empty array passed by reference to save names of tables presnet in
+* @param $trg_tables array of target database table names,
+*
+* @param $matching_tables $matching tables array containing names of matching tables,
+* @param &$uncommon_target_tables empty array passed by reference to save names of tables presnet in
* target database but absent from source database
*/
-
function PMA_getNonMatchingTargetTables($trg_tables, $matching_tables, &$uncommon_target_tables)
{
for($c=0; $c<sizeof($trg_tables) ;$c++) {
- $match = false;
+ $match = false;
for($d=0; $d < sizeof($matching_tables); $d++)
{
if ($trg_tables[$c] === $matching_tables[$d]) {
$match=true;
- }
+ }
}
if ($match === false) {
$uncommon_target_tables[] = $trg_tables[$c];
- }
+ }
}
}
-
- /**
+
+/**
* PMA_dataDiffInTables() finds the difference in source and target matching tables by
* first comparing source table's primary key entries with target table enteries.
* It gets the field names for the matching table also for comparisons.
@@ -67,29 +65,27 @@ function PMA_getNonMatchingTargetTables($trg_tables, $matching_tables, &$uncommo
* field values also, in order to check whether update is required or not.
* If update is required, it is placed in $update_array
* Otherwise that entry is placed in the $insert_array.
- *
- *
+ *
+ *
* @param $src_db name of source database
* @param $trg_db name of target database
* @param $src_link connection established with source server
* @param $trg_link connection established with target server
- * @param $index Index of a table from $matching_table array
- *
- * @param $update_array A three dimensional array passed by reference to
+ * @param $matching_table array containing matching table names
+ * @param $matching_tables_fields A two dimensional array passed by reference to contain names of fields for each matching table
+ * @param $update_array A three dimensional array passed by reference to
* contain updates required for each matching table
- * @param $insert_array A three dimensional array passed by reference to
+ * @param $insert_array A three dimensional array passed by reference to
* contain inserts required for each matching table
- * @param $fields_num A two dimensional array passed by reference to
+ * @param $delete_array Unused
+ * @param $fields_num A two dimensional array passed by reference to
* contain number of fields for each matching table
- * @param $matching_table array containing matching table names
- *
- * @param $matching_tables_fields A two dimensional array passed by reference to contain names of fields for each matching table
- *
+ * @param $matching_table_index Index of a table from $matching_table array
* @param $matching_tables_keys A two dimensional array passed by reference to contain names of keys for each matching table
- */
+ */
function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, &$matching_table, &$matching_tables_fields,
&$update_array, &$insert_array, &$delete_array, &$fields_num, $matching_table_index, &$matching_tables_keys)
-{
+{
if (isset($matching_table[$matching_table_index])) {
$fld = array();
$fld_results = PMA_DBI_get_columns($src_db, $matching_table[$matching_table_index], true, $src_link);
@@ -101,80 +97,80 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, &$matching
$is_key[] = $field_name;
}
$fld[] = $field_name;
- }
+ }
}
$matching_tables_fields[$matching_table_index] = $fld;
$fields_num[$matching_table_index] = sizeof($fld);
$matching_tables_keys[$matching_table_index] = $is_key;
-
- $source_result_set = PMA_get_column_values($src_db, $matching_table[$matching_table_index], $is_key, $src_link);
+
+ $source_result_set = PMA_get_column_values($src_db, $matching_table[$matching_table_index], $is_key, $src_link);
$source_size = sizeof($source_result_set);
-
+
$trg_fld_results = PMA_DBI_get_columns($trg_db, $matching_table[$matching_table_index], true, $trg_link);
$all_keys_match = true;
$trg_keys = array();
-
+
if (isset($trg_fld_results)) {
foreach ($trg_fld_results as $each_field) {
if ($each_field['Key'] == 'PRI') {
- $trg_keys[] = $each_field['Field'];
+ $trg_keys[] = $each_field['Field'];
if (! (in_array($each_field['Field'], $is_key))) {
$all_keys_match = false;
- }
- }
- }
+ }
+ }
+ }
}
$update_row = 0;
$insert_row = 0;
$update_field = 0;
$insert_field = 0;
- $starting_index = 0;
-
- for ($j = 0; $j < $source_size; $j++) {
+ $starting_index = 0;
+
+ for ($j = 0; $j < $source_size; $j++) {
$starting_index = 0;
- $update_field = 0;
+ $update_field = 0;
if (isset($source_result_set[$j]) && ($all_keys_match)) {
// Query the target server to see which rows already exist
- $trg_select_query = "SELECT * FROM " . PMA_backquote($trg_db) . "."
+ $trg_select_query = "SELECT * FROM " . PMA_backquote($trg_db) . "."
. PMA_backquote($matching_table[$matching_table_index]) . " WHERE ";
-
+
if (sizeof($is_key) == 1) {
$trg_select_query .= $is_key[0]. "='" . $source_result_set[$j] . "'";
} elseif (sizeof($is_key) > 1){
for ($k=0; $k < sizeof($is_key); $k++) {
$trg_select_query .= $is_key[$k] . "='" . $source_result_set[$j][$is_key[$k]] . "'";
if ($k < (sizeof($is_key)-1)){
- $trg_select_query .= " AND ";
+ $trg_select_query .= " AND ";
}
- }
+ }
}
-
+
$target_result_set = PMA_DBI_fetch_result($trg_select_query, null, null, $trg_link);
if ($target_result_set) {
// Fetch the row from the source server to do a comparison
- $src_select_query = "SELECT * FROM " . PMA_backquote($src_db) . "."
+ $src_select_query = "SELECT * FROM " . PMA_backquote($src_db) . "."
. PMA_backquote($matching_table[$matching_table_index]) . " WHERE ";
-
+
if (sizeof($is_key) == 1) {
$src_select_query .= $is_key[0] . "='" . $source_result_set[$j] . "'";
} else if(sizeof($is_key) > 1){
for ($k=0; $k< sizeof($is_key); $k++) {
$src_select_query .= $is_key[$k] . "='" . $source_result_set[$j][$is_key[$k]] . "'";
if ($k < (sizeof($is_key) - 1)){
- $src_select_query .= " AND ";
+ $src_select_query .= " AND ";
}
}
- }
-
+ }
+
$src_result_set = PMA_DBI_fetch_result($src_select_query, null, null, $src_link);
-
+
/**
* Comparing each corresponding field of the source and target matching rows.
- * Placing the primary key, value of primary key, field to be updated, and the
- * new value of field to be updated in each row of the update array.
+ * Placing the primary key, value of primary key, field to be updated, and the
+ * new value of field to be updated in each row of the update array.
*/
for ($m = 0; ($m < $fields_num[$matching_table_index]) && ($starting_index == 0) ; $m++) {
if (isset($src_result_set[0][$fld[$m]])) {
@@ -191,12 +187,12 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, &$matching
}
}
}
-
+
$update_array[$matching_table_index][$update_row][$update_field] = $fld[$m];
-
+
$update_field++;
if (isset($src_result_set[0][$fld[$m]])) {
- $update_array[$matching_table_index][$update_row][$update_field] = $src_result_set[0][$fld[$m]];
+ $update_array[$matching_table_index][$update_row][$update_field] = $src_result_set[0][$fld[$m]];
$update_field++;
}
$starting_index = $m;
@@ -206,7 +202,7 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, &$matching
if (sizeof($is_key) == 1) {
if ($source_result_set[$j]) {
$update_array[$matching_table_index][$update_row][$is_key[0]] = $source_result_set[$j];
-
+
}
} elseif (sizeof($is_key) > 1) {
for ($n = 0; $n < sizeof($is_key); $n++) {
@@ -215,12 +211,12 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, &$matching
}
}
}
-
+
$update_array[$matching_table_index][$update_row][$update_field] = $fld[$m];
-
+
$update_field++;
if (isset($src_result_set[0][$fld[$m]])) {
- $update_array[$matching_table_index][$update_row][$update_field] = $src_result_set[0][$fld[$m]];
+ $update_array[$matching_table_index][$update_row][$update_field] = $src_result_set[0][$fld[$m]];
$update_field++;
}
$starting_index = $m;
@@ -229,28 +225,28 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, &$matching
}
}
for ($m = $starting_index + 1; $m < $fields_num[$matching_table_index] ; $m++)
- {
+ {
if (isset($src_result_set[0][$fld[$m]])) {
- if (isset($target_result_set[0][$fld[$m]])) {
+ if (isset($target_result_set[0][$fld[$m]])) {
if (($src_result_set[0][$fld[$m]] != $target_result_set[0][$fld[$m]]) && (!(in_array($fld[$m], $is_key)))) {
- $update_row--;
+ $update_row--;
$update_array[$matching_table_index][$update_row][$update_field] = $fld[$m];
$update_field++;
if ($src_result_set[0][$fld[$m]]) {
$update_array[$matching_table_index][$update_row][$update_field] = $src_result_set[0][$fld[$m]];
$update_field++;
}
- $update_row++;
+ $update_row++;
}
} else {
- $update_row--;
+ $update_row--;
$update_array[$matching_table_index][$update_row][$update_field] = $fld[$m];
$update_field++;
if ($src_result_set[0][$fld[$m]]) {
$update_array[$matching_table_index][$update_row][$update_field] = $src_result_set[0][$fld[$m]];
$update_field++;
}
- $update_row++;
+ $update_row++;
}
}
}
@@ -262,7 +258,7 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, &$matching
if (isset($source_result_set[$j])) {
$insert_array[$matching_table_index][$insert_row][$is_key[0]] = $source_result_set[$j];
}
- } elseif (sizeof($is_key) > 1) {
+ } elseif (sizeof($is_key) > 1) {
for($l = 0; $l < sizeof($is_key); $l++) {
if (isset($source_result_set[$j][$matching_tables_fields[$matching_table_index][$l]])) {
$insert_array[$matching_table_index][$insert_row][$is_key[$l]] = $source_result_set[$j][$matching_tables_fields[$matching_table_index][$l]];
@@ -274,13 +270,13 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, &$matching
} else {
/**
* Placing the primary key, and the value of primary key of the row that is to be inserted in the target table
- * This condition is met when there is an additional column in the source table
+ * This condition is met when there is an additional column in the source table
*/
if (sizeof($is_key) == 1) {
if (isset($source_result_set[$j])) {
$insert_array[$matching_table_index][$insert_row][$is_key[0]] = $source_result_set[$j];
}
- } elseif (sizeof($is_key) > 1) {
+ } elseif (sizeof($is_key) > 1) {
for ($l = 0; $l < sizeof($is_key); $l++) {
if (isset($source_result_set[$j][$matching_tables_fields[$matching_table_index][$l]])) {
$insert_array[$matching_table_index][$insert_row][$is_key[$l]] = $source_result_set[$j][$matching_tables_fields[$matching_table_index][$l]];
@@ -290,31 +286,31 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, &$matching
$insert_row++;
}
} // for loop ends
- }
-}
+ }
+}
+
/**
* PMA_findDeleteRowsFromTargetTables finds the rows which are to be deleted from target table.
-*
-* @param $delete_array array containing rows that are to be deleted
+*
+* @param $delete_array array containing rows that are to be deleted
* @param $matching_table array containing matching table names
* @param $matching_table_index index of a table from $matching_table array
* @param $trg_keys array of target table keys
* @param $src_keys array of source table keys
* @param $trg_db name of target database
* @param $trg_link connection established with target server
-* @param $src_db name of source database
+* @param $src_db name of source database
* @param $src_link connection established with source server
-*
*/
function PMA_findDeleteRowsFromTargetTables(&$delete_array, $matching_table, $matching_table_index, $trg_keys, $src_keys, $trg_db, $trg_link,$src_db, $src_link)
{
if (isset($trg_keys[$matching_table_index])) {
$target_key_values = PMA_get_column_values($trg_db, $matching_table[$matching_table_index], $trg_keys[$matching_table_index], $trg_link);
- $target_row_size = sizeof($target_key_values);
+ $target_row_size = sizeof($target_key_values);
}
if (isset($src_keys[$matching_table_index])) {
$source_key_values = PMA_get_column_values($src_db, $matching_table[$matching_table_index], $src_keys[$matching_table_index], $src_link);
- $source_size = sizeof($source_key_values);
+ $source_size = sizeof($source_key_values);
}
$all_keys_match = 1;
for ($a = 0; $a < sizeof($trg_keys[$matching_table_index]); $a++) {
@@ -322,7 +318,7 @@ function PMA_findDeleteRowsFromTargetTables(&$delete_array, $matching_table, $ma
if (! (in_array($trg_keys[$matching_table_index][$a], $src_keys[$matching_table_index]))) {
$all_keys_match = 0;
}
- }
+ }
}
if (! ($all_keys_match)) {
if (isset($target_key_values)) {
@@ -331,17 +327,17 @@ function PMA_findDeleteRowsFromTargetTables(&$delete_array, $matching_table, $ma
}
if (isset($trg_keys[$matching_table_index])) {
if ((sizeof($trg_keys[$matching_table_index]) == 1) && $all_keys_match) {
- $row = 0;
+ $row = 0;
if (isset($target_key_values)) {
for ($i = 0; $i < sizeof($target_key_values); $i++) {
if (! (in_array($target_key_values[$i], $source_key_values))) {
$delete_array[$matching_table_index][$row] = $target_key_values[$i];
- $row++;
+ $row++;
}
- }
+ }
}
} elseif ((sizeof($trg_keys[$matching_table_index]) > 1) && $all_keys_match) {
- $row = 0;
+ $row = 0;
if (isset($target_key_values)) {
for ($i = 0; $i < sizeof($target_key_values); $i++) {
$is_present = false;
@@ -350,7 +346,7 @@ function PMA_findDeleteRowsFromTargetTables(&$delete_array, $matching_table, $ma
for ($k = 0; $k < sizeof($trg_keys[$matching_table_index]); $k++) {
if ($target_key_values[$i][$trg_keys[$matching_table_index][$k]] != $source_key_values[$j][$trg_keys[$matching_table_index][$k]]) {
$check = false;
- }
+ }
}
if ($check) {
$is_present = true;
@@ -362,61 +358,60 @@ function PMA_findDeleteRowsFromTargetTables(&$delete_array, $matching_table, $ma
}
$row++;
}
- }
- }
+ }
+ }
}
- }
+ }
}
/**
* PMA_dataDiffInUncommonTables() finds the data difference in $source_tables_uncommon
-*
+*
* @param $source_tables_uncommon array of table names; containing table names that are in source db and not in target db
* @param $src_db name of source database
* @param $src_link connection established with source server
* @param $index index of a table from $matching_table array
* @param $row_count number of rows
*/
-
function PMA_dataDiffInUncommonTables($source_tables_uncommon, $src_db, $src_link, $index, &$row_count)
{
- $query = "SELECT COUNT(*) FROM " . PMA_backquote($src_db) . "." . PMA_backquote($source_tables_uncommon[$index]);
- $rows = PMA_DBI_fetch_result($query, null, null, $src_link);
- $row_count[$index] = $rows[0];
+ $query = "SELECT COUNT(*) FROM " . PMA_backquote($src_db) . "." . PMA_backquote($source_tables_uncommon[$index]);
+ $rows = PMA_DBI_fetch_result($query, null, null, $src_link);
+ $row_count[$index] = $rows[0];
}
/**
* PMA_updateTargetTables() sets the updated field values to target table rows using $update_array[$matching_table_index]
*
-*
-* @param $table Array containing matching tables' names
+*
+* @param $table Array containing matching tables' names
* @param $update_array A three dimensional array containing field
* value updates required for each matching table
-* @param $src_db Name of source database
+* @param $src_db Name of source database
* @param $trg_db Name of target database
* @param $trg_link Connection established with target server
-* @param $matching_table_index index of matching table in matching_table_array
+* @param $matching_table_index index of matching table in matching_table_array
+* @param $matching_table_keys
* @param $display true/false value
-*/
-
+*/
function PMA_updateTargetTables($table, $update_array, $src_db, $trg_db, $trg_link, $matching_table_index, $matching_table_keys, $display)
-{
+{
if (isset($update_array[$matching_table_index])) {
if (sizeof($update_array[$matching_table_index])) {
-
+
for ($update_row = 0; $update_row < sizeof($update_array[$matching_table_index]); $update_row++) {
-
- if (isset($update_array[$matching_table_index][$update_row])) {
+
+ if (isset($update_array[$matching_table_index][$update_row])) {
$update_fields_num = sizeof($update_array[$matching_table_index][$update_row])-sizeof($matching_table_keys[$matching_table_index]);
if ($update_fields_num > 0) {
- $query = "UPDATE " . PMA_backquote($trg_db) . "." .PMA_backquote($table[$matching_table_index]) . " SET ";
-
+ $query = "UPDATE " . PMA_backquote($trg_db) . "." .PMA_backquote($table[$matching_table_index]) . " SET ";
+
for ($update_field = 0; $update_field < $update_fields_num; $update_field = $update_field+2) {
if (isset($update_array[$matching_table_index][$update_row][$update_field]) && isset($update_array[$matching_table_index][$update_row][$update_field+1])) {
$query .= $update_array[$matching_table_index][$update_row][$update_field] . "='" . $update_array[$matching_table_index][$update_row][$update_field+1] . "'";
}
if ($update_field < ($update_fields_num - 2)) {
- $query .= ", ";
+ $query .= ", ";
}
}
$query .= " WHERE ";
@@ -424,7 +419,6 @@ function PMA_updateTargetTables($table, $update_array, $src_db, $trg_db, $trg_li
for ($key = 0; $key < sizeof($matching_table_keys[$matching_table_index]); $key++)
{
if (isset($matching_table_keys[$matching_table_index][$key])) {
-
$query .= $matching_table_keys[$matching_table_index][$key] . "='" . $update_array[$matching_table_index][$update_row][$matching_table_keys[$matching_table_index][$key]] . "'";
}
if ($key < (sizeof($matching_table_keys[$matching_table_index]) - 1)) {
@@ -434,27 +428,26 @@ function PMA_updateTargetTables($table, $update_array, $src_db, $trg_db, $trg_li
}
if ($display == true) {
echo "<p>" . $query . "</p>";
- }
+ }
PMA_DBI_try_query($query, $trg_link, 0);
}
- }
+ }
}
}
}
}
+
/**
* PMA_insertIntoTargetTable() inserts missing rows in the target table using $array_insert[$matching_table_index]
-*
-*
-*
+*
* @param $matching_table array containing matching table names
* @param $src_db name of source database
* @param $trg_db name of target database
* @param $src_link connection established with source server
* @param $trg_link connection established with target server
* @param $table_fields array containing field names of a table
-* @param $array_insert
-* @param $matching_table_index index of matching table in matching_table_array
+* @param $array_insert
+* @param $matching_table_index index of matching table in matching_table_array
* @param $matching_tables_keys array containing field names that are keys in the matching table
* @param $source_columns array containing source column information
* @param $add_column_array array containing column names that are to be added in target table
@@ -463,30 +456,29 @@ function PMA_updateTargetTables($table, $update_array, $src_db, $trg_db, $trg_li
* @param $uncommon_tables array containing table names that are present in source db but not in targt db
* @param $uncommon_tables_fields array containing field names of the uncommon tables
* @param $uncommon_cols column names that are present in target table and not in source table
-* @param $alter_str_array array containing column names that are to be altered
-* @param $source_indexes column names on which indexes are made in source table
-* @param $target_indexes column names on which indexes are made in target table
+* @param $alter_str_array array containing column names that are to be altered
+* @param $source_indexes column names on which indexes are made in source table
+* @param $target_indexes column names on which indexes are made in target table
* @param $add_indexes_array array containing column names on which index is to be added in target table
-* @param $alter_indexes_array array containing column names whose indexes are to be altered. Only index name and uniqueness of an index can be changed
+* @param $alter_indexes_array array containing column names whose indexes are to be altered. Only index name and uniqueness of an index can be changed
* @param $delete_array array containing rows that are to be deleted
* @param $update_array array containing rows that are to be updated in target
* @param $display true/false value
-*
*/
function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link, $trg_link, $table_fields, &$array_insert, $matching_table_index,
- $matching_tables_keys, $source_columns, &$add_column_array, $criteria, $target_tables_keys, $uncommon_tables, &$uncommon_tables_fields,$uncommon_cols,
+ $matching_tables_keys, $source_columns, &$add_column_array, $criteria, $target_tables_keys, $uncommon_tables, &$uncommon_tables_fields,$uncommon_cols,
&$alter_str_array,&$source_indexes, &$target_indexes, &$add_indexes_array, &$alter_indexes_array, &$delete_array, &$update_array, $display)
-{
+{
if(isset($array_insert[$matching_table_index])) {
if (sizeof($array_insert[$matching_table_index])) {
for ($insert_row = 0; $insert_row< sizeof($array_insert[$matching_table_index]); $insert_row++) {
if (isset($array_insert[$matching_table_index][$insert_row][$matching_tables_keys[$matching_table_index][0]])) {
-
+
$select_query = "SELECT * FROM " . PMA_backquote($src_db) . "." . PMA_backquote($matching_table[$matching_table_index]) . " WHERE ";
for ($i = 0; $i < sizeof($matching_tables_keys[$matching_table_index]); $i++) {
$select_query .= $matching_tables_keys[$matching_table_index][$i] . "='";
$select_query .= $array_insert[$matching_table_index][$insert_row][$matching_tables_keys[$matching_table_index][$i]] . "'" ;
-
+
if ($i < (sizeof($matching_tables_keys[$matching_table_index]) - 1)) {
$select_query.= " AND ";
}
@@ -494,38 +486,38 @@ function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link,
$select_query .= "; ";
$result = PMA_DBI_fetch_result ($select_query, null, null, $src_link);
$insert_query = "INSERT INTO " . PMA_backquote($trg_db) . "." . PMA_backquote($matching_table[$matching_table_index]) ." (";
-
- for ($field_index = 0; $field_index < sizeof($table_fields[$matching_table_index]); $field_index++)
+
+ for ($field_index = 0; $field_index < sizeof($table_fields[$matching_table_index]); $field_index++)
{
$insert_query .= $table_fields[$matching_table_index][$field_index];
-
- $is_fk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . $trg_db ."'
+
+ $is_fk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . $trg_db ."'
AND TABLE_NAME = '" . $matching_table[$matching_table_index]. "'AND COLUMN_NAME = '" .
$table_fields[$matching_table_index][$field_index] . "' AND TABLE_NAME <> REFERENCED_TABLE_NAME;" ;
-
+
$is_fk_result = PMA_DBI_fetch_result($is_fk_query, null, null, $trg_link);
if (sizeof($is_fk_result) > 0) {
for ($j = 0; $j < sizeof($is_fk_result); $j++)
{
$table_index = array_keys($matching_table, $is_fk_result[$j]['REFERENCED_TABLE_NAME']);
-
+
if (isset($alter_str_array[$table_index[0]])) {
PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, $source_columns, $alter_str_array, $matching_tables_fields,
$criteria, $matching_tables_keys, $target_tables_keys, $table_index[0], $display);
- unset($alter_str_array[$table_index[0]]);
- }
+ unset($alter_str_array[$table_index[0]]);
+ }
if (isset($uncommon_columns[$table_index[0]])) {
PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables, $uncommon_columns, $table_index[0], $display);
- unset($uncommon_columns[$table_index[0]]);
- }
+ unset($uncommon_columns[$table_index[0]]);
+ }
if (isset($add_column_array[$table_index[0]])) {
PMA_findDeleteRowsFromTargetTables($delete_array, $matching_tables, $table_index[0], $target_tables_keys, $matching_tables_keys,
$trg_db, $trg_link, $src_db, $src_link);
-
+
if (isset($delete_array[$table_index[0]])) {
PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $table_index[0], $target_tables_keys, $delete_array, $display);
- unset($delete_array[$table_index[0]]);
- }
+ unset($delete_array[$table_index[0]]);
+ }
PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link, $matching_tables, $source_columns, $add_column_array,
$matching_tables_fields, $criteria, $matching_tables_keys, $target_tables_keys, $uncommon_tables,$uncommon_tables_fields,
$table_index[0], $uncommon_cols, $display);
@@ -535,7 +527,7 @@ function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link,
|| isset($alter_indexes_array[$table_index[0]])) {
PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables, $source_indexes, $target_indexes, $add_indexes_array, $alter_indexes_array,
$remove_indexes_array, $table_index[0], $display);
-
+
unset($add_indexes_array[$table_index[0]]);
unset($alter_indexes_array[$table_index[0]]);
unset($remove_indexes_array[$table_index[0]]);
@@ -548,16 +540,16 @@ function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link,
if (isset($array_insert[$table_index[0]])) {
PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link, $trg_link, $table_fields, $array_insert,
$table_index[0], $matching_tables_keys, $source_columns, $add_column_array, $criteria, $target_tables_keys, $uncommon_tables,
- $uncommon_tables_fields, $uncommon_cols, $alter_str_array, $source_indexes, $target_indexes, $add_indexes_array,
- $alter_indexes_array, $delete_array, $update_array, $display);
+ $uncommon_tables_fields, $uncommon_cols, $alter_str_array, $source_indexes, $target_indexes, $add_indexes_array,
+ $alter_indexes_array, $delete_array, $update_array, $display);
unset($array_insert[$table_index[0]]);
- }
+ }
}
}
if ($field_index < sizeof($table_fields[$matching_table_index])-1) {
$insert_query .= ", ";
}
- }
+ }
$insert_query .= ") VALUES(";
if (sizeof($table_fields[$matching_table_index]) == 1) {
$insert_query .= "'" . PMA_sqlAddSlashes($result[0]) . "'";
@@ -570,32 +562,32 @@ function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link,
}
if ($field_index < (sizeof($table_fields[$matching_table_index])) - 1) {
$insert_query .= " ," ;
- }
+ }
}
- }
+ }
$insert_query .= ");";
if ($display == true) {
PMA_displayQuery($insert_query);
}
PMA_DBI_try_query($insert_query, $trg_link, 0);
- }
+ }
}
}
}
-}
+}
+
/**
-* PMA_createTargetTables() Create the missing table $uncommon_table in target database
-*
-*
-* @param $src_db name of source database
+* PMA_createTargetTables() Create the missing table $uncommon_table in target database
+*
+* @param $src_db name of source database
* @param $trg_db name of target database
-* @param $trg_link connection established with target server
* @param $src_link connection established with source server
-* @param $uncommon_table name of table present in source but not in target
-* @param $table_index index of table in matching_table_array
+* @param $trg_link connection established with target server
+* @param $uncommon_tables names of tables present in source but not in target
+* @param $table_index index of table in $uncommon_tables array
* @param $uncommon_tables_fields field names of the uncommon table
-* @param $display true/false value
-*/
+* @param $display true/false value
+*/
function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, &$uncommon_tables, $table_index, &$uncommon_tables_fields, $display)
{
if (isset($uncommon_tables[$table_index])) {
@@ -605,20 +597,20 @@ function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, &$uncomm
$field_name = $each_field['Field'];
$fields[] = $field_name;
}
- $uncommon_tables_fields[$table_index] = $fields;
-
+ $uncommon_tables_fields[$table_index] = $fields;
+
$Create_Query = PMA_DBI_fetch_value("SHOW CREATE TABLE " . PMA_backquote($src_db) . '.' . PMA_backquote($uncommon_tables[$table_index]), 0, 1, $src_link);
// Replace the src table name with a `dbname`.`tablename`
- $Create_Table_Query = preg_replace('/' . preg_quote(PMA_backquote($uncommon_tables[$table_index]), '/') . '/',
+ $Create_Table_Query = preg_replace('/' . preg_quote(PMA_backquote($uncommon_tables[$table_index]), '/') . '/',
PMA_backquote($trg_db) . '.' .PMA_backquote($uncommon_tables[$table_index]),
$Create_Query,
$limit = 1
);
- $is_fk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . $src_db . "'
+ $is_fk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . $src_db . "'
AND TABLE_NAME = '" . $uncommon_tables[$table_index] . "' AND TABLE_NAME <> REFERENCED_TABLE_NAME;" ;
-
+
$is_fk_result = PMA_DBI_fetch_result($is_fk_query, null, null, $src_link);
if (sizeof($is_fk_result) > 0) {
for ($j = 0; $j < sizeof($is_fk_result); $j++)
@@ -627,35 +619,35 @@ function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, &$uncomm
$table_index = array_keys($uncommon_tables, $is_fk_result[$j]['REFERENCED_TABLE_NAME']);
PMA_createTargetTables($src_db, $trg_db, $trg_link, $src_link, $uncommon_tables, $table_index[0], $uncommon_tables_fields, $display);
unset($uncommon_tables[$table_index[0]]);
- }
+ }
}
}
if ($display == true) {
echo '<p>' . $Create_Table_Query . '</p>';
}
PMA_DBI_try_query($Create_Table_Query, $trg_link, 0);
- }
+ }
}
/**
* PMA_populateTargetTables() inserts data into uncommon tables after they have been created
-*
+*
* @param $src_db name of source database
* @param $trg_db name of target database
* @param $src_link connection established with source server
* @param $trg_link connection established with target server
-* @param $uncommon_tables array containing uncommon table names (table names that are present in source but not in target db)
-* @param $table_index index of table in matching_table_array
+* @param $uncommon_tables array containing uncommon table names (table names that are present in source but not in target db)
+* @param $table_index index of table in matching_table_array
* @param $uncommon_tables_fields field names of the uncommon table
* @param $display true/false value
*
* FIXME: This turns NULL values into '' (empty string)
*/
-function PMA_populateTargetTables($src_db, $trg_db, $src_link, $trg_link, $uncommon_tables, $table_index, $uncommon_tables_fields, $display)
-{
+function PMA_populateTargetTables($src_db, $trg_db, $src_link, $trg_link, $uncommon_tables, $table_index, $uncommon_tables_fields, $display)
+{
$display = false; // todo: maybe display some of the queries if they are not too numerous
$unbuffered_result = PMA_DBI_try_query('SELECT * FROM ' . PMA_backquote($src_db) . '.' . PMA_backquote($uncommon_tables[$table_index]), $src_link, PMA_DBI_QUERY_UNBUFFERED);
if (false !== $unbuffered_result) {
- $insert_query = 'INSERT INTO ' . PMA_backquote($trg_db) . '.' .PMA_backquote($uncommon_tables[$table_index]) . ' VALUES';
+ $insert_query = 'INSERT INTO ' . PMA_backquote($trg_db) . '.' .PMA_backquote($uncommon_tables[$table_index]) . ' VALUES';
while ($one_row = PMA_DBI_fetch_row($unbuffered_result)) {
$insert_query .= '(';
$key_of_last_value = count($one_row) - 1;
@@ -675,55 +667,56 @@ function PMA_populateTargetTables($src_db, $trg_db, $src_link, $trg_link, $uncom
PMA_DBI_try_query($insert_query, $trg_link, 0);
}
}
+
/**
* PMA_deleteFromTargetTable() delete rows from target table
-*
-*
+*
* @param $trg_db name of target database
* @param $trg_link connection established with target server
* @param $matching_tables array containing matching table names
* @param $table_index index of table in matching_table_array
-* @param $target_table_keys primary key names of the target tables
-* @param $delete array array containing the key values of rows that are to be deleted
+* @param $target_tables_keys primary key names of the target tables
+* @param $delete_array array containing the key values of rows that are to be deleted
* @param $display true/false value
*/
-function PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $table_index, $target_tables_keys, $delete_array, $display)
+function PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $table_index, $target_tables_keys, $delete_array, $display)
{
for($i = 0; $i < sizeof($delete_array[$table_index]); $i++) {
if (isset($target_tables_keys[$table_index])) {
- $delete_query = 'DELETE FROM ' . PMA_backquote($trg_db) . '.' .PMA_backquote($matching_tables[$table_index]) . ' WHERE ';
+ $delete_query = 'DELETE FROM ' . PMA_backquote($trg_db) . '.' .PMA_backquote($matching_tables[$table_index]) . ' WHERE ';
for($y = 0; $y < sizeof($target_tables_keys[$table_index]); $y++) {
$delete_query .= $target_tables_keys[$table_index][$y] . " = '";
-
+
if (sizeof($target_tables_keys[$table_index]) == 1) {
- $delete_query .= $delete_array[$table_index][$i] . "'";
+ $delete_query .= $delete_array[$table_index][$i] . "'";
} elseif (sizeof($target_tables_keys[$table_index]) > 1) {
$delete_query .= $delete_array[$table_index][$i][$target_tables_keys[$table_index][$y]] . "'";
}
if ($y < (sizeof($target_tables_keys[$table_index]) - 1)) {
$delete_query .= ' AND ';
}
- $pk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '" . $trg_db . "'
+ $pk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '" . $trg_db . "'
AND REFERENCED_TABLE_NAME = '" . $matching_tables[$table_index]."' AND REFERENCED_COLUMN_NAME = '"
. $target_tables_keys[$table_index][$y] . "' AND TABLE_NAME <> REFERENCED_TABLE_NAME;";
-
+
$pk_query_result = PMA_DBI_fetch_result($pk_query, null, null, $trg_link);
$result_size = sizeof($pk_query_result);
-
+
if ($result_size > 0) {
for ($b = 0; $b < $result_size; $b++) {
$drop_pk_query = "DELETE FROM " . PMA_backquote($pk_query_result[$b]['TABLE_SCHEMA']) . "." . PMA_backquote($pk_query_result[$b]['TABLE_NAME']) . " WHERE " . $pk_query_result[$b]['COLUMN_NAME'] . " = " . $target_tables_keys[$table_index][$y] . ";";
PMA_DBI_try_query($drop_pk_query, $trg_link, 0);
- }
- }
- }
+ }
+ }
+ }
}
if ($display == true) {
- echo '<p>' . $delete_query . '</p>';
+ echo '<p>' . $delete_query . '</p>';
}
PMA_DBI_try_query($delete_query, $trg_link, 0);
}
}
+
/**
* PMA_structureDiffInTables() Gets all the column information for source and target table.
* Compare columns on their names.
@@ -732,10 +725,9 @@ function PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $table_
* If column exists in target table but criteria is different then it is palced in $alter_str_array.
* If column does not exist in source table but is present in target table then it is placed in $uncommon_columns.
* Keys for all the source tables that have a corresponding target table are placed in $matching_tables_keys.
-* Keys for all the target tables that have a corresponding source table are placed in $target_tables_keys.
-*
-*
-* @param $src_db name of source database
+* Keys for all the target tables that have a corresponding source table are placed in $target_tables_keys.
+*
+* @param $src_db name of source database
* @param $trg_db name of target database
* @param $src_link connection established with source server
* @param $trg_link connection established with target server
@@ -749,26 +741,25 @@ function PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $table_
* @param $uncommon_columns array containing the columns that are present in the target table but not in the source table
* @param $criteria array containing the criterias which are to be checked for field that is present in source table and target table
* @param $target_tables_keys array containing the field names which is key in the target table
-* @param $matching_table_index integer number of the matching table
-*
+* @param $matching_table_index integer number of the matching table
*/
function PMA_structureDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matching_tables, &$source_columns, &$target_columns, &$alter_str_array,
- &$add_column_array, &$uncommon_columns, $criteria, &$target_tables_keys, $matching_table_index)
+ &$add_column_array, &$uncommon_columns, $criteria, &$target_tables_keys, $matching_table_index)
{
//Gets column information for source and target table
$source_columns[$matching_table_index] = PMA_DBI_get_columns_full($src_db, $matching_tables[$matching_table_index], null, $src_link);
$target_columns[$matching_table_index] = PMA_DBI_get_columns_full($trg_db, $matching_tables[$matching_table_index], null, $trg_link);
foreach ($source_columns[$matching_table_index] as $column_name => $each_column) {
if (isset($target_columns[$matching_table_index][$column_name]['Field'])) {
- //If column exists in target table then matches criterias like type, null, collation, key, default, comment of the column
+ //If column exists in target table then matches criterias like type, null, collation, key, default, comment of the column
for ($i = 0; $i < sizeof($criteria); $i++) {
if ($source_columns[$matching_table_index][$column_name][$criteria[$i]] != $target_columns[$matching_table_index][$column_name][$criteria[$i]]) {
if (($criteria[$i] == 'Default') && ($source_columns[$matching_table_index][$column_name][$criteria[$i]] == '' )) {
- $alter_str_array[$matching_table_index][$column_name][$criteria[$i]] = 'None';
+ $alter_str_array[$matching_table_index][$column_name][$criteria[$i]] = 'None';
} else {
if (! (($criteria[$i] == 'Key') && (($source_columns[$matching_table_index][$column_name][$criteria[$i]] == 'MUL')
- || ($target_columns[$matching_table_index][$column_name][$criteria[$i]] == 'MUL')
- || ($source_columns[$matching_table_index][$column_name][$criteria[$i]] == 'UNI')
+ || ($target_columns[$matching_table_index][$column_name][$criteria[$i]] == 'MUL')
+ || ($source_columns[$matching_table_index][$column_name][$criteria[$i]] == 'UNI')
|| ($target_columns[$matching_table_index][$column_name][$criteria[$i]] == 'UNI')))) {
$alter_str_array[$matching_table_index][$column_name][$criteria[$i]] = $source_columns[$matching_table_index][$column_name][$criteria[$i]];
}
@@ -782,23 +773,23 @@ function PMA_structureDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matc
//Finds column names that are present in target table but not in source table
foreach ($target_columns[$matching_table_index] as $fld_name => $each_column) {
if (! (isset($source_columns[$matching_table_index][$fld_name]['Field']))) {
- $fields_uncommon[] = $fld_name;
+ $fields_uncommon[] = $fld_name;
}
if ($target_columns[$matching_table_index][$fld_name]['Key'] == 'PRI') {
$keys[] = $fld_name;
}
}
if (isset($fields_uncommon)) {
- $uncommon_columns[$matching_table_index] = $fields_uncommon;
+ $uncommon_columns[$matching_table_index] = $fields_uncommon;
}
if (isset($keys)) {
- $target_tables_keys[$matching_table_index] = $keys;
+ $target_tables_keys[$matching_table_index] = $keys;
}
}
/**
* PMA_addColumnsInTargetTable() adds column that are present in source table but not in target table
*
-* @param $src_db name of source database
+* @param $src_db name of source database
* @param $trg_db name of target database
* @param $src_link connection established with source server
* @param $trg_link connection established with target server
@@ -806,7 +797,7 @@ function PMA_structureDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matc
* @param $source_columns array containing columns information of the source tables
* @param $add_column_array array containing the names of the column(field) that are to be added in the target
* @param $matching_tables_fields
-* @param $criteria array containing the criterias
+* @param $criteria array containing the criterias
* @param $matching_tables_keys array containing the field names which is key in the source table
* @param $target_tables_keys array containing the field names which is key in the target table
* @param $uncommon_tables array containing the table names that are present in source db and not in target db
@@ -826,7 +817,7 @@ function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link, $ma
if($source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Null'] == 'NO') {
$query .= ' Not Null ';
} elseif ($source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Null'] == 'YES') {
- $query .= ' Null ';
+ $query .= ' Null ';
}
if ($source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Collation'] != '') {
$query .= ' COLLATE ' . $source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Collation'];
@@ -835,21 +826,21 @@ function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link, $ma
$query .= " DEFAULT " . $source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Default'];
}
if ($source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Comment'] != '') {
- $query .= " COMMENT " . $source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Comment'];
- }
- if ($source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Key'] == 'PRI' ) {
+ $query .= " COMMENT " . $source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Comment'];
+ }
+ if ($source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Key'] == 'PRI' ) {
$trg_key_size = sizeof($target_tables_keys[$table_counter]);
if ($trg_key_size) {
$check = true;
- for ($a = 0; ($a < $trg_key_size) && ($check); $a++) {
+ for ($a = 0; ($a < $trg_key_size) && ($check); $a++) {
if (! (in_array($target_tables_keys[$table_counter], $uncommon_cols))) {
$check = false;
- }
+ }
}
if (! $check) {
- $query .= " ,DROP PRIMARY KEY " ;
+ $query .= " ,DROP PRIMARY KEY " ;
}
- }
+ }
$query .= " , ADD PRIMARY KEY (";
for ($t = 0; $t < sizeof($matching_tables_keys[$table_counter]); $t++) {
$query .= $matching_tables_keys[$table_counter][$t];
@@ -859,20 +850,20 @@ function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link, $ma
}
$query .= ")";
}
-
+
$query .= ";";
if ($display == true) {
echo '<p>' . $query . '</p>';
}
PMA_DBI_try_query($query, $trg_link, 0);
-
+
//Checks if column to be added is a foreign key or not
$is_fk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . $trg_db . "' AND TABLE_NAME = '"
. $matching_tables[$table_counter] . "' AND COLUMN_NAME ='" . $add_column_array[$table_counter][$matching_tables_fields[$table_counter][$i]] .
"' AND TABLE_NAME <> REFERENCED_TABLE_NAME;";
-
+
$is_fk_result = PMA_DBI_fetch_result($is_fk_query, null, null, $src_link);
-
+
//If column is a foreign key then it is checked that referenced table exist in target db. If referenced table does not exist in target db then
//it is created first.
if (isset($is_fk_result)) {
@@ -886,8 +877,8 @@ function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link, $ma
"ADD CONSTRAINT FOREIGN KEY " . $add_column_array[$table_counter][$matching_tables_fields[$table_counter][$i]] . "
(" . $add_column_array[$table_counter][$matching_tables_fields[$table_counter][$i]] . ") REFERENCES " . PMA_backquote($trg_db) .
'.' . PMA_backquote($is_fk_result[0]['REFERENCED_TABLE_NAME']) . " (" . $is_fk_result[0]['REFERENCED_COLUMN_NAME'] . ");";
-
- PMA_DBI_try_query($fk_query, $trg_link, null);
+
+ PMA_DBI_try_query($fk_query, $trg_link, null);
}
}
}
@@ -895,44 +886,43 @@ function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link, $ma
/**
* PMA_checkForeignKeys() checks if the referenced table have foreign keys.
* uses PMA_createTargetTables()
-*
+*
* @param $src_db name of source database
* @param $src_link connection established with source server
* @param $trg_db name of target database
* @param $trg_link connection established with target server
* @param $referenced_table table whose column is a foreign key in another table
-* @param $uncommon_tables array containing names that are uncommon
+* @param $uncommon_tables array containing names that are uncommon
* @param $uncommon_tables_fields field names of the uncommon table
* @param $display true/false value
*/
function PMA_checkForeignKeys($src_db, $src_link, $trg_db, $trg_link ,$referenced_table, &$uncommon_tables, &$uncommon_tables_fields, $display)
{
- $is_fk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . $src_db . "'
+ $is_fk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . $src_db . "'
AND TABLE_NAME = '" . $referenced_table . "' AND TABLE_NAME <> REFERENCED_TABLE_NAME;";
-
+
$is_fk_result = PMA_DBI_fetch_result($is_fk_query, null, null, $src_link);
if (sizeof($is_fk_result) > 0) {
for ($j = 0; $j < sizeof($is_fk_result); $j++) {
if (in_array($is_fk_result[$j]['REFERENCED_TABLE_NAME'], $uncommon_tables)) {
$table_index = array_keys($uncommon_tables, $is_fk_result[$j]['REFERENCED_TABLE_NAME']);
- PMA_checkForeignKeys($src_db, $src_link, $trg_db, $trg_link, $is_fk_result[$j]['REFERENCED_TABLE_NAME'], $uncommon_tables,
- $uncommon_tables_fields, $display);
+ PMA_checkForeignKeys($src_db, $src_link, $trg_db, $trg_link, $is_fk_result[$j]['REFERENCED_TABLE_NAME'], $uncommon_tables,
+ $uncommon_tables_fields, $display);
PMA_createTargetTables($src_db, $trg_db, $trg_link, $src_link, $uncommon_tables, $table_index[0], $uncommon_tables_fields, $display);
unset($uncommon_tables[$table_index[0]]);
- }
+ }
}
}
}
/**
* PMA_alterTargetTableStructure() alters structure of the target table using $alter_str_array
-*
-*
+*
* @param $trg_db name of target database
* @param $trg_link connection established with target server
* @param $matching_tables array containing names of matching tables
* @param $source_columns array containing columns information of the source table
* @param $alter_str_array array containing the column name and criteria which is to be altered for the targert table
-* @param $matching_tables_fields array containing the name of the fields for the matching table
+* @param $matching_tables_fields array containing the name of the fields for the matching table
* @param $criteria array containing the criterias
* @param $matching_tables_keys array containing the field names which is key in the source table
* @param $target_tables_keys array containing the field names which is key in the target table
@@ -940,7 +930,7 @@ function PMA_checkForeignKeys($src_db, $src_link, $trg_db, $trg_link ,$reference
* @param $display true/false value
*/
function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, &$source_columns, &$alter_str_array, $matching_tables_fields, $criteria,
- &$matching_tables_keys, &$target_tables_keys, $matching_table_index, $display)
+ &$matching_tables_keys, &$target_tables_keys, $matching_table_index, $display)
{
$check = true;
$sql_query = '';
@@ -969,22 +959,22 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, &$s
}
$pri_query .= ");";
}
-
+
if (isset($pri_query)) {
if ($display == true) {
echo '<p>' . $pri_query . '</p>';
}
- PMA_DBI_try_query($pri_query, $trg_link, 0);
+ PMA_DBI_try_query($pri_query, $trg_link, 0);
}
for ($t = 0; $t < sizeof($matching_tables_fields[$matching_table_index]); $t++) {
if ((isset($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]])) && (sizeof($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]]) > 0)) {
- $sql_query = 'ALTER TABLE ' . PMA_backquote($trg_db) . '.' . PMA_backquote($matching_tables[$matching_table_index]) . ' MODIFY ' .
- $matching_tables_fields[$matching_table_index][$t] . ' ' . $source_columns[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]]['Type'];
+ $sql_query = 'ALTER TABLE ' . PMA_backquote($trg_db) . '.' . PMA_backquote($matching_tables[$matching_table_index]) . ' MODIFY ' .
+ $matching_tables_fields[$matching_table_index][$t] . ' ' . $source_columns[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]]['Type'];
$found = false;
for ($i = 0; $i < sizeof($criteria); $i++)
{
if (isset($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]][$criteria[$i]]) && $criteria[$i] != 'Key') {
- $found = true;
+ $found = true;
if (($criteria[$i] == 'Type') && (! isset($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]][$criteria[$i+1]]))) {
if ($source_columns[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]][$criteria[$i + 1]] == 'NO') {
$sql_query .= " Not Null" ;
@@ -1015,7 +1005,7 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, &$s
if ($source_columns[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]]['Type'] != 'timestamp') {
$sql_query .= " DEFAULT '" . $alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]][$criteria[$i]] . "'";
} elseif($source_columns[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]]['Type'] == 'timestamp') {
- $sql_query .= " DEFAULT " . $alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]][$criteria[$i]];
+ $sql_query .= " DEFAULT " . $alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]][$criteria[$i]];
}
} elseif (is_numeric($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]][$criteria[$i]])) {
$sql_query .= " DEFAULT " . $alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]][$criteria[$i]];
@@ -1053,19 +1043,19 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, &$s
if ($check) {
if ($display == true) {
echo '<p>' . $query . '</p>';
- }
+ }
PMA_DBI_try_query($query, $trg_link, 0);
}
}
/**
* PMA_removeColumnsFromTargetTable() removes the columns which are present in target table but not in source table.
-*
+*
* @param $trg_db name of target database
* @param $trg_link connection established with target server
* @param $matching_tables array containing names of matching tables
* @param $uncommon_columns array containing the names of the column which are to be dropped from the target table
-* @param $table_counter index of the matching table as in $matchiing_tables array
+* @param $table_counter index of the matching table as in $matchiing_tables array
* @param $display true/false value
*/
function PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables, $uncommon_columns, $table_counter, $display)
@@ -1074,21 +1064,21 @@ function PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables,
$drop_query = "ALTER TABLE " . PMA_backquote($trg_db) . "." . PMA_backquote($matching_tables[$table_counter]);
for ($a = 0; $a < sizeof($uncommon_columns[$table_counter]); $a++) {
//Checks if column to be removed is a foreign key in any table
- $pk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '" . $trg_db . "'
+ $pk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '" . $trg_db . "'
AND REFERENCED_TABLE_NAME = '" . $matching_tables[$table_counter]."' AND REFERENCED_COLUMN_NAME = '"
. $uncommon_columns[$table_counter][$a] . "' AND TABLE_NAME <> REFERENCED_TABLE_NAME;";
-
+
$pk_query_result = PMA_DBI_fetch_result($pk_query, null, null, $trg_link);
$result_size = sizeof($pk_query_result);
-
+
if ($result_size > 0) {
for ($b = 0; $b < $result_size; $b++) {
$drop_pk_query = "ALTER TABLE " . PMA_backquote($pk_query_result[$b]['TABLE_SCHEMA']) . "." . PMA_backquote($pk_query_result[$b]['TABLE_NAME']) . "
DROP FOREIGN KEY " . $pk_query_result[$b]['CONSTRAINT_NAME'] . ", DROP COLUMN " . $pk_query_result[$b]['COLUMN_NAME'] . ";";
- PMA_DBI_try_query($drop_pk_query, $trg_link, 0);
- }
- }
- $query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . $trg_db . "' AND TABLE_NAME = '"
+ PMA_DBI_try_query($drop_pk_query, $trg_link, 0);
+ }
+ }
+ $query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . $trg_db . "' AND TABLE_NAME = '"
. $matching_tables[$table_counter]. "' AND COLUMN_NAME = '" . $uncommon_columns[$table_counter][$a] . "'
AND TABLE_NAME <> REFERENCED_TABLE_NAME;";
@@ -1100,41 +1090,40 @@ function PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables,
$drop_query .= " DROP COLUMN " . $uncommon_columns[$table_counter][$a];
if ($a < (sizeof($uncommon_columns[$table_counter]) - 1)) {
$drop_query .= " , " ;
- }
+ }
}
$drop_query .= ";" ;
-
+
if ($display == true) {
echo '<p>' . $drop_query . '</p>';
}
- PMA_DBI_try_query($drop_query, $trg_link, 0);
- }
-}
+ PMA_DBI_try_query($drop_query, $trg_link, 0);
+ }
+}
+
/**
-* PMA_indexesDiffInTables() compares the source table indexes with target table indexes and keep the indexes to be added in target table in $add_indexes_array
-* indexes to be altered in $alter_indexes_array and indexes to be removed from target table in $remove_indexes_array.
-* Only keyname and uniqueness characteristic of the indexes are altered.
-* @uses sizeof()
-* @uses PMA_get_table_indexes()
-*
-* @param $src_db name of source database
+* PMA_indexesDiffInTables() compares the source table indexes with target table indexes and keep the indexes to be added in target table in $add_indexes_array
+* indexes to be altered in $alter_indexes_array and indexes to be removed from target table in $remove_indexes_array.
+* Only keyname and uniqueness characteristic of the indexes are altered.
+*
+* @param $src_db name of source database
* @param $trg_db name of target database
* @param $src_link connection established with source server
* @param $trg_link connection established with target server
* @param $matching_tables array containing the matching tables name
-* @param $source_indexes array containing the indexes of the source table
+* @param $source_indexes array containing the indexes of the source table
* @param $target_indexes array containing the indexes of the target table
* @param $add_indexes_array array containing the name of the column on which the index is to be added in the target table
* @param $alter_indexes_array array containing the key name which needs to be altered
* @param $remove_indexes_array array containing the key name of the index which is to be removed from the target table
-* @param $table_counter number of the matching table
+* @param $table_counter number of the matching table
*/
function PMA_indexesDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matching_tables, &$source_indexes, &$target_indexes, &$add_indexes_array,
&$alter_indexes_array, &$remove_indexes_array, $table_counter)
{
//Gets indexes information for source and target table
$source_indexes[$table_counter] = PMA_get_table_indexes($src_db, $matching_tables[$table_counter],$src_link);
- $target_indexes[$table_counter] = PMA_get_table_indexes($trg_db, $matching_tables[$table_counter],$trg_link);
+ $target_indexes[$table_counter] = PMA_get_table_indexes($trg_db, $matching_tables[$table_counter],$trg_link);
for ($a = 0; $a < sizeof($source_indexes[$table_counter]); $a++) {
$found = false;
$z = 0;
@@ -1152,15 +1141,15 @@ function PMA_indexesDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matchi
}
}
}
- $z++;
+ $z++;
}
if ($found === false) {
if(! ($source_indexes[$table_counter][$a]['Key_name'] == 'PRIMARY')) {
- $add_indexes_array [$table_counter][] = $source_indexes[$table_counter][$a]['Column_name'];
+ $add_indexes_array [$table_counter][] = $source_indexes[$table_counter][$a]['Column_name'];
}
}
}
-
+
//Finds indexes that exist on target table but not on source table
for ($b = 0; $b < sizeof($target_indexes[$table_counter]); $b++) {
$found = false;
@@ -1170,29 +1159,29 @@ function PMA_indexesDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matchi
if ($target_indexes[$table_counter][$b]['Column_name'] == $source_indexes[$table_counter][$c]['Column_name']) {
$found = true;
}
- $c++;
+ $c++;
}
if ($found === false) {
- $remove_indexes_array[$table_counter][] = $target_indexes[$table_counter][$b]['Key_name'];
+ $remove_indexes_array[$table_counter][] = $target_indexes[$table_counter][$b]['Key_name'];
}
}
}
/**
-* PMA_applyIndexesDiff() create indexes, alters indexes and remove indexes.
-*
+* PMA_applyIndexesDiff() create indexes, alters indexes and remove indexes.
+*
* @param $trg_db name of target database
* @param $trg_link connection established with target server
* @param $matching_tables array containing the matching tables name
-* @param $source_indexes array containing the indexes of the source table
+* @param $source_indexes array containing the indexes of the source table
* @param $target_indexes array containing the indexes of the target table
* @param $add_indexes_array array containing the column names on which indexes are to be created in target table
* @param $alter_indexes_array array containing the column names for which indexes are to be altered
* @param $remove_indexes_array array containing the key name of the indexes which are to be removed from the target table
-* @param $table_counter number of the matching table
+* @param $table_counter number of the matching table
* @param $display true/false value
*/
-function PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables, $source_indexes, $target_indexes, $add_indexes_array, $alter_indexes_array,
+function PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables, $source_indexes, $target_indexes, $add_indexes_array, $alter_indexes_array,
$remove_indexes_array, $table_counter, $display)
{
//Adds indexes on target table
@@ -1200,7 +1189,7 @@ function PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables, $source_ind
$sql = "ALTER TABLE " . PMA_backquote($trg_db) . "." . PMA_backquote($matching_tables[$table_counter]) . " ADD" ;
for ($a = 0; $a < sizeof($source_indexes[$table_counter]); $a++) {
if (isset($add_indexes_array[$table_counter][$a])) {
- for ($b = 0; $b < sizeof($source_indexes[$table_counter]); $b++) {
+ for ($b = 0; $b < sizeof($source_indexes[$table_counter]); $b++) {
if ($source_indexes[$table_counter][$b]['Column_name'] == $add_indexes_array[$table_counter][$a]) {
if ($source_indexes[$table_counter][$b]['Non_unique'] == '0') {
$sql .= " UNIQUE ";
@@ -1221,9 +1210,9 @@ function PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables, $source_ind
$query = "ALTER TABLE " . PMA_backquote($trg_db) . "." . PMA_backquote($matching_tables[$table_counter]);
for ($a = 0; $a < sizeof($alter_indexes_array[$table_counter]); $a++) {
if (isset($alter_indexes_array[$table_counter][$a])) {
- $query .= ' DROP INDEX ' . PMA_backquote($alter_indexes_array[$table_counter][$a]) . " , ADD ";
+ $query .= ' DROP INDEX ' . PMA_backquote($alter_indexes_array[$table_counter][$a]) . " , ADD ";
$got_first_index_column = false;
- for ($z = 0; $z < sizeof($source_indexes[$table_counter]); $z++) {
+ for ($z = 0; $z < sizeof($source_indexes[$table_counter]); $z++) {
if ($source_indexes[$table_counter][$z]['Key_name'] == $alter_indexes_array[$table_counter][$a]) {
if (! $got_first_index_column) {
if ($source_indexes[$table_counter][$z]['Non_unique'] == '0') {
@@ -1250,25 +1239,25 @@ function PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables, $source_ind
$drop_index_query = "ALTER TABLE " . PMA_backquote($trg_db) . "." . PMA_backquote($matching_tables[$table_counter]);
for ($a = 0; $a < sizeof($target_indexes[$table_counter]); $a++) {
if (isset($remove_indexes_array[$table_counter][$a])) {
- $drop_index_query .= " DROP INDEX " . $remove_indexes_array[$table_counter][$a];
+ $drop_index_query .= " DROP INDEX " . $remove_indexes_array[$table_counter][$a];
}
if ($a < (sizeof($remove_indexes_array[$table_counter]) - 1)) {
$drop_index_query .= " , " ;
}
}
- $drop_index_query .= " ; " ;
+ $drop_index_query .= " ; " ;
if ($display == true) {
echo '<p>' . $drop_index_query . '</p>';
}
- PMA_DBI_try_query($drop_index_query, $trg_link, 0);
+ PMA_DBI_try_query($drop_index_query, $trg_link, 0);
}
}
/**
* PMA_displayQuery() displays a query, taking the maximum display size
- * into account
- *
- * @param $query the query to display
+ * into account
+ *
+ * @param $query the query to display
*/
function PMA_displayQuery($query) {
if (strlen($query) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
@@ -1278,12 +1267,12 @@ function PMA_displayQuery($query) {
}
/**
- * PMA_syncDisplayHeaderSource() shows the header for source database
+ * PMA_syncDisplayHeaderSource() shows the header for source database
*
- * @param string $src_db source db name
+ * @param string $src_db source db name
*/
function PMA_syncDisplayHeaderSource($src_db) {
- echo '<div id="serverstatus" style = "overflow: auto; width: 1020px; height: 220px; border-left: 1px gray solid; border-bottom: 1px gray solid; padding:0px; margin-bottom: 1em "> ';
+ echo '<div id="serverstatus" style = "overflow: auto; width: 1020px; height: 220px; border-left: 1px gray solid; border-bottom: 1px gray solid; padding:0; margin-bottom: 1em "> ';
echo '<table id="serverstatusconnections" class="data" width="55%">';
echo '<tr>';
@@ -1300,10 +1289,10 @@ function PMA_syncDisplayHeaderSource($src_db) {
/**
* PMA_syncDisplayHeaderTargetAndMatchingTables() shows the header for target database and the matching tables
- *
- * @param string $trg_db target db name
+ *
+ * @param string $trg_db target db name
* @param array $matching_tables
- * @return boolean $odd_row current value of this toggle
+ * @return boolean $odd_row current value of this toggle
*/
function PMA_syncDisplayHeaderTargetAndMatchingTables($trg_db, $matching_tables) {
echo '<table id="serverstatusconnections" class="data" width="43%">';
@@ -1326,10 +1315,10 @@ function PMA_syncDisplayHeaderTargetAndMatchingTables($trg_db, $matching_tables)
}
/**
- * PMA_syncDisplayBeginTableRow() displays the TR tag for alternating colors
- *
- * @param boolean $odd_row current status of the toggle
- * @return boolean $odd_row final status of the toggle
+ * PMA_syncDisplayBeginTableRow() displays the TR tag for alternating colors
+ *
+ * @param boolean $odd_row current status of the toggle
+ * @return boolean $odd_row final status of the toggle
*/
function PMA_syncDisplayBeginTableRow($odd_row) {
$odd_row = ! $odd_row;
@@ -1348,7 +1337,6 @@ function PMA_syncDisplayBeginTableRow($odd_row) {
* @param mixed $link mysql link resource
* @return array $field_values
*/
-
function PMA_get_column_values($database, $table, $column, $link = null)
{
$query = 'SELECT ';
@@ -1377,7 +1365,6 @@ function PMA_get_column_values($database, $table, $column, $link = null)
* @param mixed $link mysql link resource
* @return array $indexes
*/
-
function PMA_get_table_indexes($database, $table, $link = null)
{
hooks/post-receive
--
phpMyAdmin
1
0