[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_4-17327-ge79ffb9
Madhura Jayaratne
madhuracj at users.sourceforge.net
Sat Aug 27 19:38:35 CEST 2011
The branch, master has been updated
via e79ffb99cd05913fdd67da74f24dcbec690efaf5 (commit)
via 08ec08059a2428358f1d6112a2200788db2153e2 (commit)
from 85037b0d6a434beed2a7d56eef5563067b64adfd (commit)
- Log -----------------------------------------------------------------
commit e79ffb99cd05913fdd67da74f24dcbec690efaf5
Merge: 08ec080 85037b0
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date: Sat Aug 27 23:04:20 2011 +0530
Merge branch 'master' of ssh://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin/phpmyadmin
commit 08ec08059a2428358f1d6112a2200788db2153e2
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date: Sat Aug 27 22:57:08 2011 +0530
Coding style improvements
-----------------------------------------------------------------------
Summary of changes:
libraries/schema/User_Schema.class.php | 404 ++++++++++++----------
libraries/schema/Visio_Relation_Schema.class.php | 180 +++++++----
2 files changed, 343 insertions(+), 241 deletions(-)
diff --git a/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php
index 538ceed..ae0a629 100644
--- a/libraries/schema/User_Schema.class.php
+++ b/libraries/schema/User_Schema.class.php
@@ -31,11 +31,12 @@ class PMA_User_Schema
* you can set the table positions on the paper via scratchboard
* for table positions, put the x,y co-ordinates
*
- * @param string $this->action It tells what the Schema is supposed to do
- * create and select a page, generate schema etc
+ * $this->action tells what the Schema is supposed to do
+ * create and select a page, generate schema etc
+ *
* @access public
+ * @return void
*/
-
public function processUserChoice()
{
global $action_choose, $db, $cfgRelation;
@@ -64,13 +65,17 @@ class PMA_User_Schema
$cfgRelation,
$db
);
- $this->autoLayoutForeign = isset($_POST['auto_layout_foreign']) ? "1":NULL;
- $this->autoLayoutInternal = isset($_POST['auto_layout_internal']) ? "1":NULL;
+ $this->autoLayoutForeign = isset($_POST['auto_layout_foreign'])
+ ? "1"
+ : null;
+ $this->autoLayoutInternal = isset($_POST['auto_layout_internal'])
+ ? "1"
+ : null;
$this->processRelations(
$db,
$this->pageNumber,
$cfgRelation
- );
+ );
break;
case 'edcoord':
$this->chosenPage = $_POST['chpage'];
@@ -97,7 +102,8 @@ class PMA_User_Schema
/**
* shows/displays the HTML FORM to create the page
*
- * @param string db name of the selected database
+ * @param string $db name of the selected database
+ *
* @return void
* @access public
*/
@@ -154,8 +160,10 @@ class PMA_User_Schema
public function selectPage()
{
global $db,$table,$cfgRelation;
- $page_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
+ $page_query = 'SELECT * FROM '
+ . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . PMA_backquote($cfgRelation['pdf_pages'])
+ . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
$page_rs = PMA_query_as_controluser($page_query, false, PMA_DBI_QUERY_STORE);
if ($page_rs && PMA_DBI_num_rows($page_rs) > 0) {
?>
@@ -170,12 +178,15 @@ class PMA_User_Schema
<option value="0"><?php echo __('Select page'); ?></option>
<?php
while ($curr_page = PMA_DBI_fetch_assoc($page_rs)) {
- echo "\n" . ' '
- . '<option value="' . $curr_page['page_nr'] . '"';
- if (isset($this->chosenPage) && $this->chosenPage == $curr_page['page_nr']) {
- echo ' selected="selected"';
- }
- echo '>' . $curr_page['page_nr'] . ': ' . htmlspecialchars($curr_page['page_descr']) . '</option>';
+ echo "\n" . ' '
+ . '<option value="' . $curr_page['page_nr'] . '"';
+ if (isset($this->chosenPage)
+ && $this->chosenPage == $curr_page['page_nr']
+ ) {
+ echo ' selected="selected"';
+ }
+ echo '>' . $curr_page['page_nr'] . ': '
+ . htmlspecialchars($curr_page['page_descr']) . '</option>';
} // end while
echo "\n";
?>
@@ -212,7 +223,11 @@ class PMA_User_Schema
* We will need an array of all tables in this db
*/
$selectboxall = array('--');
- $alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
+ $alltab_rs = PMA_DBI_query(
+ 'SHOW TABLES FROM ' . PMA_backquote($db) . ';',
+ null,
+ PMA_DBI_QUERY_STORE
+ );
while ($val = @PMA_DBI_fetch_row($alltab_rs)) {
$selectboxall[] = $val[0];
}
@@ -225,11 +240,13 @@ class PMA_User_Schema
if (isset($this->chosenPage) && $this->chosenPage > 0) {
echo "\n";
?>
- <h2><?php echo __('Select Tables') ;?></h2>
+ <h2><?php echo __('Select Tables'); ?></h2>
<?php
- $page_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
+ $page_query = 'SELECT * FROM '
+ . PMA_backquote($GLOBALS['cfgRelation']['db'])
+ . '.' . PMA_backquote($cfgRelation['table_coords'])
+ . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
+ . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
$page_rs = PMA_query_as_controluser($page_query, false);
$array_sh_page = array();
while ($temp_sh_page = @PMA_DBI_fetch_assoc($page_rs)) {
@@ -264,55 +281,25 @@ class PMA_User_Schema
$i = 0;
$odd_row = true;
foreach ($array_sh_page as $dummy_sh_page => $sh_page) {
- $_mtab = $sh_page['table_name'];
- $tabExist[$_mtab] = false;
- echo "\n" . ' <tr class="noclick ';
- if ($odd_row) {
- echo 'odd';
- } else {
- echo 'even';
- }
- echo '">';
- $odd_row != $odd_row;
- echo "\n" . ' <td>'
- . "\n" . ' <select name="c_table_' . $i . '[name]">';
- foreach ($selectboxall as $key => $value) {
- echo "\n" . ' <option value="' . htmlspecialchars($value) . '"';
- if ($value == $sh_page['table_name']) {
- echo ' selected="selected"';
- $tabExist[$_mtab] = true;
- }
- echo '>' . htmlspecialchars($value) . '</option>';
- }
- echo "\n" . ' </select>'
- . "\n" . ' </td>';
- echo "\n" . ' <td>'
- . "\n" . ' <input type="checkbox" id="id_c_table_' . $i .'" name="c_table_' . $i . '[delete]" value="y" /><label for="id_c_table_' . $i .'">' . __('Delete') . '</label>';
- echo "\n" . ' </td>';
- echo "\n" . ' <td>'
- . "\n" . ' <input type="text" onchange="dragPlace(' . $i . ', \'x\', this.value)" name="c_table_' . $i . '[x]" value="' . $sh_page['x'] . '" />';
- echo "\n" . ' </td>';
- echo "\n" . ' <td>'
- . "\n" . ' <input type="text" onchange="dragPlace(' . $i . ', \'y\', this.value)" name="c_table_' . $i . '[y]" value="' . $sh_page['y'] . '" />';
- echo "\n" . ' </td>';
- echo "\n" . ' </tr>';
- $i++;
- }
- /*
- * Add one more empty row
- */
+ $_mtab = $sh_page['table_name'];
+ $tabExist[$_mtab] = false;
echo "\n" . ' <tr class="noclick ';
if ($odd_row) {
echo 'odd';
} else {
echo 'even';
}
- $odd_row != $odd_row;
echo '">';
+ $odd_row != $odd_row;
echo "\n" . ' <td>'
. "\n" . ' <select name="c_table_' . $i . '[name]">';
foreach ($selectboxall as $key => $value) {
- echo "\n" . ' <option value="' . htmlspecialchars($value) . '">' . htmlspecialchars($value) . '</option>';
+ echo "\n" . ' <option value="' . htmlspecialchars($value) . '"';
+ if ($value == $sh_page['table_name']) {
+ echo ' selected="selected"';
+ $tabExist[$_mtab] = true;
+ }
+ echo '>' . htmlspecialchars($value) . '</option>';
}
echo "\n" . ' </select>'
. "\n" . ' </td>';
@@ -320,19 +307,49 @@ class PMA_User_Schema
. "\n" . ' <input type="checkbox" id="id_c_table_' . $i .'" name="c_table_' . $i . '[delete]" value="y" /><label for="id_c_table_' . $i .'">' . __('Delete') . '</label>';
echo "\n" . ' </td>';
echo "\n" . ' <td>'
- . "\n" . ' <input type="text" name="c_table_' . $i . '[x]" value="' . (isset($sh_page['x'])?$sh_page['x']:'') . '" />';
+ . "\n" . ' <input type="text" onchange="dragPlace(' . $i . ', \'x\', this.value)" name="c_table_' . $i . '[x]" value="' . $sh_page['x'] . '" />';
echo "\n" . ' </td>';
echo "\n" . ' <td>'
- . "\n" . ' <input type="text" name="c_table_' . $i . '[y]" value="' . (isset($sh_page['y'])?$sh_page['y']:'') . '" />';
+ . "\n" . ' <input type="text" onchange="dragPlace(' . $i . ', \'y\', this.value)" name="c_table_' . $i . '[y]" value="' . $sh_page['y'] . '" />';
echo "\n" . ' </td>';
echo "\n" . ' </tr>';
- echo "\n" . ' </table>' . "\n";
-
- echo "\n" . ' <input type="hidden" name="c_table_rows" value="' . ($i + 1) . '" />';
- echo "\n" . ' <input type="hidden" id="showwysiwyg" name="showwysiwyg" value="' . ((isset($showwysiwyg) && $showwysiwyg == '1') ? '1' : '0') . '" />';
- echo "\n" . ' <input type="checkbox" name="with_field_names" ' . (isset($with_field_names) ? 'checked="checked"' : ''). ' />' . __('Column names') . '<br />';
- echo "\n" . ' <input type="submit" value="' . __('Save') . '" />';
- echo "\n" . '</form>' . "\n\n";
+ $i++;
+ }
+ /*
+ * Add one more empty row
+ */
+ echo "\n" . ' <tr class="noclick ';
+ if ($odd_row) {
+ echo 'odd';
+ } else {
+ echo 'even';
+ }
+ $odd_row != $odd_row;
+ echo '">';
+ echo "\n" . ' <td>'
+ . "\n" . ' <select name="c_table_' . $i . '[name]">';
+ foreach ($selectboxall as $key => $value) {
+ echo "\n" . ' <option value="' . htmlspecialchars($value) . '">' . htmlspecialchars($value) . '</option>';
+ }
+ echo "\n" . ' </select>'
+ . "\n" . ' </td>';
+ echo "\n" . ' <td>'
+ . "\n" . ' <input type="checkbox" id="id_c_table_' . $i .'" name="c_table_' . $i . '[delete]" value="y" /><label for="id_c_table_' . $i .'">' . __('Delete') . '</label>';
+ echo "\n" . ' </td>';
+ echo "\n" . ' <td>'
+ . "\n" . ' <input type="text" name="c_table_' . $i . '[x]" value="' . (isset($sh_page['x'])?$sh_page['x']:'') . '" />';
+ echo "\n" . ' </td>';
+ echo "\n" . ' <td>'
+ . "\n" . ' <input type="text" name="c_table_' . $i . '[y]" value="' . (isset($sh_page['y'])?$sh_page['y']:'') . '" />';
+ echo "\n" . ' </td>';
+ echo "\n" . ' </tr>';
+ echo "\n" . ' </table>' . "\n";
+
+ echo "\n" . ' <input type="hidden" name="c_table_rows" value="' . ($i + 1) . '" />';
+ echo "\n" . ' <input type="hidden" id="showwysiwyg" name="showwysiwyg" value="' . ((isset($showwysiwyg) && $showwysiwyg == '1') ? '1' : '0') . '" />';
+ echo "\n" . ' <input type="checkbox" name="with_field_names" ' . (isset($with_field_names) ? 'checked="checked"' : ''). ' />' . __('Column names') . '<br />';
+ echo "\n" . ' <input type="submit" value="' . __('Save') . '" />';
+ echo "\n" . '</form>' . "\n\n";
} // end if
$this->_deleteTables($db, $this->chosenPage, isset($tabExist));
@@ -375,14 +392,14 @@ class PMA_User_Schema
?>
<label for="pdf_page_number_opt"><?php echo __('Page number:'); ?></label>
<select name="pdf_page_number" id="pdf_page_number_opt">
- <?php
- while ($pages = @PMA_DBI_fetch_assoc($test_rs)) {
- echo ' <option value="' . $pages['page_nr'] . '">'
- . $pages['page_nr'] . ': ' . htmlspecialchars($pages['page_descr']) . '</option>' . "\n";
- } // end while
- PMA_DBI_free_result($test_rs);
- unset($test_rs);
- ?>
+ <?php
+ while ($pages = @PMA_DBI_fetch_assoc($test_rs)) {
+ echo ' <option value="' . $pages['page_nr'] . '">'
+ . $pages['page_nr'] . ': ' . htmlspecialchars($pages['page_descr']) . '</option>' . "\n";
+ } // end while
+ PMA_DBI_free_result($test_rs);
+ unset($test_rs);
+ ?>
</select><br />
<?php } else { ?>
<input type="hidden" name="pdf_page_number" value="<?php echo htmlspecialchars($this->chosenPage); ?>" />
@@ -433,9 +450,10 @@ class PMA_User_Schema
* Check if there are tables that need to be deleted in dashboard,
* if there are, ask the user for allowance
*
- * @param string db name of database selected
- * @param integer chpage selected page
- * @param array tabExist
+ * @param string $db name of database selected
+ * @param integer $chpage selected page
+ * @param array $tabExist
+ *
* @return void
* @access private
*/
@@ -445,13 +463,13 @@ class PMA_User_Schema
$_strtrans = '';
$_strname = '';
$shoot = false;
- if (!empty($tabExist) && is_array($tabExist)) {
+ if (! empty($tabExist) && is_array($tabExist)) {
foreach ($tabExist as $key => $value) {
- if (!$value) {
- $_strtrans .= '<input type="hidden" name="delrow[]" value="' . htmlspecialchars($key) . '" />' . "\n";
- $_strname .= '<li>' . htmlspecialchars($key) . '</li>' . "\n";
- $shoot = true;
- }
+ if (! $value) {
+ $_strtrans .= '<input type="hidden" name="delrow[]" value="' . htmlspecialchars($key) . '" />' . "\n";
+ $_strname .= '<li>' . htmlspecialchars($key) . '</li>' . "\n";
+ $shoot = true;
+ }
}
if ($shoot) {
echo '<form action="schema_edit.php" method="post">' . "\n"
@@ -493,27 +511,27 @@ class PMA_User_Schema
$reset_draginit = '';
$i = 0;
foreach ($array_sh_page as $key => $temp_sh_page) {
- $drag_x = $temp_sh_page['x'];
- $drag_y = $temp_sh_page['y'];
-
- $draginit2 .= ' Drag.init($("#table_' . $i . '")[0], null, 0, parseInt(myid.style.width)-2, 0, parseInt(myid.style.height)-5);' . "\n";
- $draginit2 .= ' $("#table_' . $i . '")[0].onDrag = function (x, y) { document.edcoord.elements["c_table_' . $i . '[x]"].value = parseInt(x); document.edcoord.elements["c_table_' . $i . '[y]"].value = parseInt(y) }' . "\n";
- $draginit .= ' $("#table_' . $i . '")[0].style.left = "' . $drag_x . 'px";' . "\n";
- $draginit .= ' $("#table_' . $i . '")[0].style.top = "' . $drag_y . 'px";' . "\n";
- $reset_draginit .= ' $("#table_' . $i . '")[0].style.left = "2px";' . "\n";
- $reset_draginit .= ' $("#table_' . $i . '")[0].style.top = "' . (15 * $i) . 'px";' . "\n";
- $reset_draginit .= ' document.edcoord.elements["c_table_' . $i . '[x]"].value = "2"' . "\n";
- $reset_draginit .= ' document.edcoord.elements["c_table_' . $i . '[y]"].value = "' . (15 * $i) . '"' . "\n";
-
- echo '<div id="table_' . $i . '" class="pdflayout_table"><u>' . $temp_sh_page['table_name'] . '</u>';
- if (isset($with_field_names)) {
- $fields = PMA_DBI_get_columns($db, $temp_sh_page['table_name']);
- foreach ($fields as $row) {
- echo '<br />' . htmlspecialchars($row['Field']) . "\n";
- }
+ $drag_x = $temp_sh_page['x'];
+ $drag_y = $temp_sh_page['y'];
+
+ $draginit2 .= ' Drag.init($("#table_' . $i . '")[0], null, 0, parseInt(myid.style.width)-2, 0, parseInt(myid.style.height)-5);' . "\n";
+ $draginit2 .= ' $("#table_' . $i . '")[0].onDrag = function (x, y) { document.edcoord.elements["c_table_' . $i . '[x]"].value = parseInt(x); document.edcoord.elements["c_table_' . $i . '[y]"].value = parseInt(y) }' . "\n";
+ $draginit .= ' $("#table_' . $i . '")[0].style.left = "' . $drag_x . 'px";' . "\n";
+ $draginit .= ' $("#table_' . $i . '")[0].style.top = "' . $drag_y . 'px";' . "\n";
+ $reset_draginit .= ' $("#table_' . $i . '")[0].style.left = "2px";' . "\n";
+ $reset_draginit .= ' $("#table_' . $i . '")[0].style.top = "' . (15 * $i) . 'px";' . "\n";
+ $reset_draginit .= ' document.edcoord.elements["c_table_' . $i . '[x]"].value = "2"' . "\n";
+ $reset_draginit .= ' document.edcoord.elements["c_table_' . $i . '[y]"].value = "' . (15 * $i) . '"' . "\n";
+
+ echo '<div id="table_' . $i . '" class="pdflayout_table"><u>' . $temp_sh_page['table_name'] . '</u>';
+ if (isset($with_field_names)) {
+ $fields = PMA_DBI_get_columns($db, $temp_sh_page['table_name']);
+ foreach ($fields as $row) {
+ echo '<br />' . htmlspecialchars($row['Field']) . "\n";
}
- echo '</div>' . "\n";
- $i++;
+ }
+ echo '</div>' . "\n";
+ $i++;
}
?>
</div>
@@ -542,22 +560,25 @@ class PMA_User_Schema
/**
* delete the table rows with table co-ordinates
*
- * @param int delrow delete selected table from list of tables
- * @param array cfgRelation relation settings
- * @param string db database name
- * @param integer chpage selected page for adding relations etc
+ * @param int $delrow delete selected table from list of tables
+ * @param array $cfgRelation relation settings
+ * @param string $db database name
+ * @param integer $chpage selected page for adding relations etc
+ *
* @return void
* @access private
*/
private function _deleteTableRows($delrow,$cfgRelation,$db,$chpage)
{
foreach ($delrow as $current_row) {
- $del_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' ' . "\n"
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' . "\n"
- . ' AND table_name = \'' . PMA_sqlAddSlashes($current_row) . '\'' . "\n"
- . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($chpage) . '\'';
- echo $del_query;
- PMA_query_as_controluser($del_query, false);
+ $del_query = 'DELETE FROM '
+ . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . PMA_backquote($cfgRelation['table_coords']) . ' ' . "\n"
+ . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' . "\n"
+ . ' AND table_name = \'' . PMA_sqlAddSlashes($current_row) . '\'' . "\n"
+ . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($chpage) . '\'';
+ echo $del_query;
+ PMA_query_as_controluser($del_query, false);
}
}
@@ -573,8 +594,8 @@ class PMA_User_Schema
/**
* Settings for relation stuff
*/
- require_once './libraries/transformations.lib.php';
- require_once './libraries/Index.class.php';
+ include_once './libraries/transformations.lib.php';
+ include_once './libraries/Index.class.php';
/**
* default is PDF, otherwise validate it's only letters a-z
*/
@@ -585,50 +606,55 @@ class PMA_User_Schema
PMA_DBI_select_db($db);
- include "./libraries/schema/".ucfirst($export_type)."_Relation_Schema.class.php";
- $obj_schema = eval("new PMA_".ucfirst($export_type)."_Relation_Schema();");
+ include "./libraries/schema/" . ucfirst($export_type) . "_Relation_Schema.class.php";
+ $obj_schema = eval("new PMA_" . ucfirst($export_type) . "_Relation_Schema();");
}
/**
* delete X and Y coordinates
*
- * @param string db The database name
- * @param array cfgRelation relation settings
- * @param integer choosePage selected page for adding relations etc
+ * @param string $db The database name
+ * @param array $cfgRelation relation settings
+ * @param integer $choosePage selected page for adding relations etc
+ *
* @return void
* @access private
*/
public function deleteCoordinates($db, $cfgRelation, $choosePage)
{
- $query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($choosePage) . '\'';
+ $query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . PMA_backquote($cfgRelation['table_coords'])
+ . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
+ . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($choosePage) . '\'';
PMA_query_as_controluser($query, false);
}
/**
* delete pages
*
- * @param string db The database name
- * @param array cfgRelation relation settings
- * @param integer choosePage selected page for adding relations etc
+ * @param string $db The database name
+ * @param array $cfgRelation relation settings
+ * @param integer $choosePage selected page for adding relations etc
+ *
* @return void
* @access private
*/
public function deletePages($db, $cfgRelation, $choosePage)
{
- $query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND page_nr = \'' . PMA_sqlAddSlashes($choosePage) . '\'';
+ $query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . PMA_backquote($cfgRelation['pdf_pages'])
+ . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
+ . ' AND page_nr = \'' . PMA_sqlAddSlashes($choosePage) . '\'';
PMA_query_as_controluser($query, false);
}
/**
* process internal and foreign key relations
*
- * @param string db The database name
- * @param array cfgRelation relation settings
- * @param integer pageNumber document number/Id
+ * @param string $db The database name
+ * @param integer $pageNumber document number/Id
+ * @param array $cfgRelation relation settings
+ *
* @return void
* @access private
*/
@@ -655,9 +681,9 @@ class PMA_User_Schema
$tables = PMA_DBI_get_tables_full($db);
$foreignkey_tables = array();
foreach ($tables as $table_name => $table_properties) {
- if (PMA_foreignkey_supported($table_properties['ENGINE'])) {
- $foreignkey_tables[] = $table_name;
- }
+ if (PMA_foreignkey_supported($table_properties['ENGINE'])) {
+ $foreignkey_tables[] = $table_name;
+ }
}
$all_tables = $foreignkey_tables;
/*
@@ -675,11 +701,14 @@ class PMA_User_Schema
* you setup the PMA tables correctly
*/
$master_tables = 'SELECT COUNT(master_table), master_table'
- . ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
- . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' GROUP BY master_table'
- . ' ORDER BY COUNT(master_table) DESC';
- $master_tables_rs = PMA_query_as_controluser($master_tables, false, PMA_DBI_QUERY_STORE);
+ . ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . PMA_backquote($cfgRelation['relation'])
+ . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\''
+ . ' GROUP BY master_table'
+ . ' ORDER BY COUNT(master_table) DESC';
+ $master_tables_rs = PMA_query_as_controluser(
+ $master_tables, false, PMA_DBI_QUERY_STORE
+ );
if ($master_tables_rs && PMA_DBI_num_rows($master_tables_rs) > 0) {
/* first put all the master tables at beginning
* of the list, so they are near the center of
@@ -697,27 +726,29 @@ class PMA_User_Schema
$foreign_tables = array();
foreach ($all_tables as $master_table) {
- $foreigners = PMA_getForeigners($db, $master_table);
- foreach ($foreigners as $foreigner) {
- if (!in_array($foreigner['foreign_table'], $foreign_tables)) {
- $foreign_tables[] = $foreigner['foreign_table'];
- }
+ $foreigners = PMA_getForeigners($db, $master_table);
+ foreach ($foreigners as $foreigner) {
+ if (! in_array($foreigner['foreign_table'], $foreign_tables)) {
+ $foreign_tables[] = $foreigner['foreign_table'];
}
+ }
}
/*
* Now merge the master and foreign arrays/tables
*/
foreach ($foreign_tables as $foreign_table) {
- if (!in_array($foreign_table, $all_tables)) {
- $all_tables[] = $foreign_table;
- }
+ if (! in_array($foreign_table, $all_tables)) {
+ $all_tables[] = $foreign_table;
+ }
}
}
}
if (isset($this->autoLayoutInternal) || isset($this->autoLayoutForeign)) {
- $this->addRelationCoordinates($all_tables,$pageNumber,$db, $cfgRelation);
+ $this->addRelationCoordinates(
+ $all_tables, $pageNumber, $db, $cfgRelation
+ );
}
$this->chosenPage = $pageNumber;
@@ -726,14 +757,15 @@ class PMA_User_Schema
/**
* Add X and Y coordinates for a table
*
- * @param string db The database name
- * @param array cfgRelation relation settings
- * @param integer pageNumber document number/Id
- * @param array all_tables A list of all tables involved
+ * @param array $all_tables A list of all tables involved
+ * @param integer $pageNumber document number/Id
+ * @param string $db The database name
+ * @param array $cfgRelation relation settings
+ *
* @return void
* @access private
*/
- public function addRelationCoordinates($all_tables,$pageNumber,$db, $cfgRelation)
+ public function addRelationCoordinates($all_tables, $pageNumber, $db, $cfgRelation)
{
/*
* Now generate the coordinates for the schema
@@ -748,9 +780,13 @@ class PMA_User_Schema
/*
* save current table's coordinates
*/
- $insert_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
- . '(db_name, table_name, pdf_page_number, x, y) '
- . 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \'' . PMA_sqlAddSlashes($current_table) . '\',' . $pageNumber . ',' . $pos_x . ',' . $pos_y . ')';
+ $insert_query = 'INSERT INTO '
+ . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . PMA_backquote($cfgRelation['table_coords']) . ' '
+ . '(db_name, table_name, pdf_page_number, x, y) '
+ . 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \''
+ . PMA_sqlAddSlashes($current_table) . '\',' . $pageNumber
+ . ',' . $pos_x . ',' . $pos_y . ')';
PMA_query_as_controluser($insert_query, false);
/*
@@ -776,7 +812,7 @@ class PMA_User_Schema
$pos_y -= $delta;
$direction = "right";
$delta *= $delta_mult;
- break;
+ break;
}
}
}
@@ -784,8 +820,9 @@ class PMA_User_Schema
/**
* update X and Y coordinates for a table
*
- * @param string db The database name
- * @param array cfgRelation relation settings
+ * @param string $db The database name
+ * @param array $cfgRelation relation settings
+ *
* @return void
* @access private
*/
@@ -802,29 +839,38 @@ class PMA_User_Schema
$arrvalue['y'] = 0;
}
if (isset($arrvalue['name']) && $arrvalue['name'] != '--') {
- $test_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
- . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
- $test_rs = PMA_query_as_controluser($test_query, false, PMA_DBI_QUERY_STORE);
+ $test_query = 'SELECT * FROM '
+ . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . PMA_backquote($cfgRelation['table_coords'])
+ . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
+ . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
+ . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
+ $test_rs = PMA_query_as_controluser($test_query, false, PMA_DBI_QUERY_STORE);
//echo $test_query;
if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
if (isset($arrvalue['delete']) && $arrvalue['delete'] == 'y') {
- $ch_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
- . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
+ $ch_query = 'DELETE FROM '
+ . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . PMA_backquote($cfgRelation['table_coords'])
+ . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
+ . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
+ . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
} else {
- $ch_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
- . 'SET x = ' . $arrvalue['x'] . ', y= ' . $arrvalue['y']
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
- . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
+ $ch_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db'])
+ . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
+ . 'SET x = ' . $arrvalue['x'] . ', y= ' . $arrvalue['y']
+ . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
+ . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
+ . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
}
} else {
- $ch_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
- . '(db_name, table_name, pdf_page_number, x, y) '
- . 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\', \'' . PMA_sqlAddSlashes($this->chosenPage) . '\',' . $arrvalue['x'] . ',' . $arrvalue['y'] . ')';
+ $ch_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db'])
+ . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
+ . '(db_name, table_name, pdf_page_number, x, y) '
+ . 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \''
+ . PMA_sqlAddSlashes($arrvalue['name']) . '\', \''
+ . PMA_sqlAddSlashes($this->chosenPage) . '\','
+ . $arrvalue['x'] . ',' . $arrvalue['y'] . ')';
}
//echo $ch_query;
PMA_query_as_controluser($ch_query, false);
diff --git a/libraries/schema/Visio_Relation_Schema.class.php b/libraries/schema/Visio_Relation_Schema.class.php
index be5028d..959d7f1 100644
--- a/libraries/schema/Visio_Relation_Schema.class.php
+++ b/libraries/schema/Visio_Relation_Schema.class.php
@@ -5,7 +5,7 @@
* @package phpMyAdmin
*/
-include_once "Export_Relation_Schema.class.php";
+require_once 'Export_Relation_Schema.class.php';
/**
* This Class inherits the XMLwriter class and
@@ -14,7 +14,6 @@ include_once "Export_Relation_Schema.class.php";
* @access public
* @see http://php.net/manual/en/book.xmlwriter.php
*/
-
class PMA_VISIO extends XMLWriter
{
public $title;
@@ -44,7 +43,7 @@ class PMA_VISIO extends XMLWriter
* Create the XML document
*/
- $this->startDocument('1.0','UTF-8');
+ $this->startDocument('1.0', 'UTF-8');
}
/**
@@ -57,7 +56,8 @@ class PMA_VISIO extends XMLWriter
*
* @return void
* @access public
- * @see XMLWriter::startElement(),XMLWriter::writeAttribute(),_documentProperties,_documentSettings
+ * @see XMLWriter::startElement(), XMLWriter::writeAttribute(),
+ * _documentProperties, _documentSettings
*/
function startVisioDoc()
{
@@ -72,7 +72,8 @@ class PMA_VISIO extends XMLWriter
/**
* Set document title
*
- * @param string value sets the title text
+ * @param string $value title text
+ *
* @return void
* @access public
*/
@@ -84,7 +85,8 @@ class PMA_VISIO extends XMLWriter
/**
* Set document author
*
- * @param string value sets the author
+ * @param string $value the author
+ *
* @return void
* @access public
*/
@@ -145,7 +147,8 @@ class PMA_VISIO extends XMLWriter
/**
* Output Visio XML .VDX Document for download
*
- * @param string fileName name of the Visio XML document
+ * @param string $fileName name of the Visio XML document
+ *
* @return void
* @access public
* @see XMLWriter::flush()
@@ -185,18 +188,22 @@ class Table_Stats
/**
* The "Table_Stats" constructor
*
- * @param string tableName The table name
- * @param integer same_wide_width The max. with among tables
- * @param boolean showKeys Whether to display keys or not
- * @param boolean showInfo Whether to display table position or not
+ * @param string $tableName The table name
+ * @param integer $pageNumber Page number
+ * @param integer &$same_wide_width The max. with among tables
+ * @param boolean $showKeys Whether to display keys or not
+ * @param boolean $showInfo Whether to display table position or not
+ *
* @global object The current Visio XML document
* @global integer The current page number (from the
* $cfg['Servers'][$i]['table_coords'] table)
* @global array The relations settings
* @global string The current db name
+ *
+ * @return void
* @access private
* @see PMA_VISIO, Table_Stats::Table_Stats_setWidth,
- Table_Stats::Table_Stats_setHeight
+ * Table_Stats::Table_Stats_setHeight
*/
function __construct($tableName, $pageNumber, &$same_wide_width, $showKeys = false, $showInfo = false)
{
@@ -206,7 +213,11 @@ class Table_Stats
$sql = 'DESCRIBE ' . PMA_backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) {
- $visio->dieSchema($pageNumber,"VISIO",sprintf(__('The %s table doesn\'t exist!'), $tableName));
+ $visio->dieSchema(
+ $pageNumber,
+ "VISIO",
+ sprintf(__('The %s table doesn\'t exist!'), $tableName)
+ );
}
/*
@@ -218,7 +229,10 @@ class Table_Stats
$indexes = PMA_Index::getFromTable($this->_tableName, $db);
$all_columns = array();
foreach ($indexes as $index) {
- $all_columns = array_merge($all_columns, array_flip(array_keys($index->getColumns())));
+ $all_columns = array_merge(
+ $all_columns,
+ array_flip(array_keys($index->getColumns()))
+ );
}
$this->fields = array_keys($all_columns);
} else {
@@ -234,21 +248,29 @@ class Table_Stats
// setWidth must me after setHeight, because title
// can include table height which changes table width
- $this->_setWidthTable($font,$fontSize);
+ $this->_setWidthTable($font, $fontSize);
if ($same_wide_width < $this->width) {
$same_wide_width = $this->width;
}
// x and y
$sql = 'SELECT x, y FROM '
- . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
+ . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
. ' AND pdf_page_number = ' . $pageNumber;
$result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) {
- $visio->dieSchema($pageNumber,"VISIO",sprintf(__('Please configure the coordinates for table %s'), $tableName));
+ $visio->dieSchema(
+ $pageNumber,
+ "VISIO",
+ sprintf(
+ __('Please configure the coordinates for table %s'),
+ $tableName
+ )
+ );
}
list($this->x, $this->y) = PMA_DBI_fetch_row($result);
$this->x = (double) $this->x;
@@ -270,11 +292,14 @@ class Table_Stats
* Returns title of the current table,
* title can have the dimensions/co-ordinates of the table
*
+ * @return the title
* @access private
*/
private function _getTitle()
{
- return ($this->_showInfo ? sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->heightCell) : '') . ' ' . $this->_tableName;
+ return ($this->_showInfo
+ ? sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->heightCell)
+ : '') . ' ' . $this->_tableName;
}
/**
@@ -282,18 +307,23 @@ class Table_Stats
*
* @param string $font font name
* @param integer $fontSize font size
- * @global object The current Visio XML document
+ *
+ * @global object The current Visio XML document
+ *
+ * @return void
* @see PMA_VISIO
*/
private function _setWidthTable($font,$fontSize)
{
global $visio;
-
}
/**
* Sets the height of the table
*
+ * @param integer $fontSize font size
+ *
+ * @return void
* @access private
*/
function _setHeightTable($fontSize)
@@ -305,8 +335,11 @@ class Table_Stats
/**
* draw the table
*
- * @param boolean showColor Whether to display color
+ * @param boolean $showColor Whether to display color
+ *
* @global object The current Visio XML document
+ *
+ * @return void
* @access public
* @see PMA_VISIO
*/
@@ -316,17 +349,17 @@ class Table_Stats
//echo $this->_tableName.'<br />';
foreach ($this->fields as $field) {
- $this->currentCell += $this->heightCell;
- $showColor = 'none';
- if ($showColor) {
- if (in_array($field, $this->primary)) {
- $showColor = '#0c0';
- }
- if ($field == $this->displayfield) {
- $showColor = 'none';
- }
+ $this->currentCell += $this->heightCell;
+ $showColor = 'none';
+ if ($showColor) {
+ if (in_array($field, $this->primary)) {
+ $showColor = '#0c0';
+ }
+ if ($field == $this->displayfield) {
+ $showColor = 'none';
}
- // code here for drawing table diagrams
+ }
+ // code here for drawing table diagrams
}
}
}
@@ -351,10 +384,12 @@ class Relation_Stats
/**
* The "Relation_Stats" constructor
*
- * @param string master_table The master table name
- * @param string master_field The relation field in the master table
- * @param string foreign_table The foreign table name
- * @param string foreigh_field The relation field in the foreign table
+ * @param string $master_table The master table name
+ * @param string $master_field The relation field in the master table
+ * @param string $foreign_table The foreign table name
+ * @param string $foreign_field The relation field in the foreign table
+ *
+ * @return void
* @see Relation_Stats::_getXy
*/
function __construct($master_table, $master_field, $foreign_table, $foreign_field)
@@ -405,8 +440,9 @@ class Relation_Stats
/**
* Gets arrows coordinates
*
- * @param string table The current table name
- * @param string column The relation column name
+ * @param string $table The current table name
+ * @param string $column The relation column name
+ *
* @return array Arrows coordinates
* @access private
*/
@@ -414,15 +450,21 @@ class Relation_Stats
{
$pos = array_search($column, $table->fields);
// x_left, x_right, y
- return array($table->x, $table->x + $table->width, $table->y + ($pos + 1.5) * $table->heightCell);
+ return array(
+ $table->x,
+ $table->x + $table->width,
+ $table->y + ($pos + 1.5) * $table->heightCell
+ );
}
/**
- * draws relation links and arrows
- * shows foreign key relations
+ * draws relation links and arrows shows foreign key relations
*
- * @param boolean changeColor Whether to use one color per relation or not
- * @global object The current Visio XML document
+ * @param boolean $changeColor Whether to use one color per relation or not
+ *
+ * @global object The current Visio XML document
+ *
+ * @return void
* @access public
* @see PMA_VISIO
*/
@@ -438,7 +480,7 @@ class Relation_Stats
'yellow',
'green',
'cyan',
- ' orange'
+ 'orange'
);
shuffle($listOfColors);
$color = $listOfColors[0];
@@ -447,7 +489,6 @@ class Relation_Stats
}
// code here for making connections b/w relation objects
-
}
}
/*
@@ -457,10 +498,11 @@ class Relation_Stats
/**
* Visio Relation Schema Class
*
- * Purpose of this class is to generate the Visio XML .VDX Document
- * which is used for representing the database diagrams in any version of MS Visio IDE.
- * This class uses Software and Database Template and Database model diagram of Visio
- * and with the combination of these objects actually helps in preparing Visio XML .VDX document.
+ * Purpose of this class is to generate the Visio XML .VDX Document which is used
+ * for representing the database diagrams in any version of MS Visio IDE.
+ * This class uses Software and Database Template and Database model diagram of
+ * Visio and with the combination of these objects actually helps in preparing
+ * Visio XML .VDX document.
*
* Visio XML is generated by using XMLWriter php extension and this class
* inherits Export_Relation_Schema class has common functionality added
@@ -495,7 +537,7 @@ class PMA_Visio_Relation_Schema extends PMA_Export_Relation_Schema
$visio->setTitle(sprintf(__('Schema of the %s database - Page %s'), $db, $this->pageNumber));
$visio->SetAuthor('phpMyAdmin ' . PMA_VERSION);
$visio->startVisioDoc();
- $alltables = $this->getAllTables($db,$this->pageNumber);
+ $alltables = $this->getAllTables($db, $this->pageNumber);
foreach ($alltables as $table) {
if (! isset($this->tables[$table])) {
@@ -515,7 +557,13 @@ class PMA_Visio_Relation_Schema extends PMA_Export_Relation_Schema
* to do a === false and this is not PHP3 compatible)
*/
if (in_array($rel['foreign_table'], $alltables)) {
- $this->_addRelation($one_table, $master_field, $rel['foreign_table'], $rel['foreign_field'],$this->showKeys);
+ $this->_addRelation(
+ $one_table,
+ $master_field,
+ $rel['foreign_table'],
+ $rel['foreign_field'],
+ $this->showKeys
+ );
}
}
}
@@ -533,32 +581,40 @@ class PMA_Visio_Relation_Schema extends PMA_Export_Relation_Schema
/**
* Defines relation objects
*
- * @param string masterTable The master table name
- * @param string masterField The relation field in the master table
- * @param string foreignTable The foreign table name
- * @param string foreignField The relation field in the foreign table
+ * @param string $masterTable The master table name
+ * @param string $masterField The relation field in the master table
+ * @param string $foreignTable The foreign table name
+ * @param string $foreignField The relation field in the foreign table
+ * @param boolean $showKeys Whether to display keys or not
+ *
* @return void
* @access private
- * @see Table_Stats::__construct(),Relation_Stats::__construct()
+ * @see Table_Stats::__construct(), Relation_Stats::__construct()
*/
private function _addRelation($masterTable, $masterField, $foreignTable, $foreignField, $showKeys)
{
if (! isset($this->tables[$masterTable])) {
- $this->tables[$masterTable] = new Table_Stats($masterTable, $this->pageNumber, $showKeys);
+ $this->tables[$masterTable] = new Table_Stats(
+ $masterTable, $this->pageNumber, $showKeys
+ );
}
if (! isset($this->tables[$foreignTable])) {
- $this->tables[$foreignTable] = new Table_Stats($foreignTable, $this->pageNumber, $showKeys);
+ $this->tables[$foreignTable] = new Table_Stats(
+ $foreignTable, $this->pageNumber, $showKeys
+ );
}
- $this->_relations[] = new Relation_Stats($this->tables[$masterTable], $masterField, $this->tables[$foreignTable], $foreignField);
+ $this->_relations[] = new Relation_Stats(
+ $this->tables[$masterTable], $masterField,
+ $this->tables[$foreignTable], $foreignField
+ );
}
/**
* Draws relation references
+ * connects master table's master field to foreign table's forein field.
*
- * connects master table's master field to
- * foreign table's forein field.
+ * @param boolean $changeColor Whether to use one color per relation or not
*
- * @param boolean changeColor Whether to use one color per relation or not
* @return void
* @access private
* @see Relation_Stats::relationDraw()
@@ -573,8 +629,8 @@ class PMA_Visio_Relation_Schema extends PMA_Export_Relation_Schema
/**
* Draws tables
*
+ * @param boolean $changeColor Whether to show color for tables text or not
*
- * @param boolean changeColor Whether to show color for tables text or not
* @return void
* @access private
* @see Table_Stats::tableDraw()
hooks/post-receive
--
phpMyAdmin
More information about the Git
mailing list