coding standards

This commit is contained in:
Loïc Chapeaux
2002-07-05 12:01:00 +00:00
parent 60985e8bdf
commit a967a579fc
2 changed files with 156 additions and 135 deletions

View File

@@ -10,12 +10,17 @@ require('./libraries/grab_globals.lib.php3');
require('./libraries/common.lib.php3'); require('./libraries/common.lib.php3');
require('./libraries/relation.lib.php3'); require('./libraries/relation.lib.php3');
/**
* Gets the relation settings
*/
$cfgRelation = PMA_getRelationsParam(); $cfgRelation = PMA_getRelationsParam();
/** /**
* A query has been submitted -> execute it, else display the headers * A query has been submitted -> execute it, else display the headers
*/ */
if (isset($submit_sql) && eregi('^SELECT',$encoded_sql_query)) { if (isset($submit_sql) && eregi('^SELECT', $encoded_sql_query)) {
$goto = 'db_details.php3'; $goto = 'db_details.php3';
$zero_rows = htmlspecialchars($strSuccess); $zero_rows = htmlspecialchars($strSuccess);
$sql_query = urldecode($encoded_sql_query); $sql_query = urldecode($encoded_sql_query);
@@ -30,9 +35,11 @@ if (isset($submit_sql) && eregi('^SELECT',$encoded_sql_query)) {
require('./db_details_db_info.php3'); require('./db_details_db_info.php3');
} }
if(isset($submit_sql) && !eregi('^SELECT',$encoded_sql_query)) { if (isset($submit_sql) && !eregi('^SELECT', $encoded_sql_query)) {
echo '<p class="warning">' . $strHaveToShow . '</p>'; echo '<p class="warning">' . $strHaveToShow . '</p>';
} }
/** /**
* Initialize some variables * Initialize some variables
*/ */
@@ -115,8 +122,8 @@ $k = 0;
// The tables list sent by a previously submitted form // The tables list sent by a previously submitted form
if (!empty($TableList)) { if (!empty($TableList)) {
for ($x = 0; $x < sizeof($TableList); $x++) { for ($x = 0; $x < count($TableList); $x++) {
$tbl_names[$TableList[$x]] = ' selected="selected"'; $tbl_names[urldecode($TableList[$x])] = ' selected="selected"';
} }
} // end if } // end if
@@ -261,7 +268,7 @@ for ($x = 0; $x < $col; $x++) {
<?php <?php
echo "\n"; echo "\n";
// if they have chosen all fields using the * selector, // If they have chosen all fields using the * selector,
// then sorting is not available // then sorting is not available
// Robbat2 - Fix for Bug #570698 // Robbat2 - Fix for Bug #570698
if (isset($Sort[$x]) && isset($Field[$x]) && (substr(urldecode($Field[$x]),-2) == '.*')) { if (isset($Sort[$x]) && isset($Field[$x]) && (substr(urldecode($Field[$x]),-2) == '.*')) {
@@ -632,7 +639,7 @@ for ($x = 0; $x < $col; $x++) {
<?php <?php
while (list($key, $val) = each($tbl_names)) { while (list($key, $val) = each($tbl_names)) {
echo ' '; echo ' ';
echo '<option value="' . $key . '"' . $val . '>' . htmlspecialchars($key) . '</option>' . "\n"; echo '<option value="' . urlencode($key) . '"' . $val . '>' . htmlspecialchars($key) . '</option>' . "\n";
} }
?> ?>
</select> </select>
@@ -778,19 +785,19 @@ if (isset($Field) && count($Field) > 0) {
// We will need this a few times: // We will need this a few times:
$incrit = '(\'' . implode('\', \'', $alltabs) . '\')'; $incrit = '(\'' . implode('\', \'', $alltabs) . '\')';
$_rel_query = 'SELECT master_table AS wer, COUNT(foreign_table) AS hits' $rel_query = 'SELECT master_table AS wer, COUNT(foreign_table) AS hits'
. ' FROM ' . PMA_backquote($cfgRelation['relation']) . ' FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . $db . '\' ' . ' WHERE master_db = \'' . $db . '\''
. ' AND foreign_db = \'' . $db . '\' ' . ' AND foreign_db = \'' . $db . '\''
. ' AND master_table IN ' . $incrit . ' AND master_table IN ' . $incrit
. ' AND foreign_table IN ' . $incrit . ' AND foreign_table IN ' . $incrit;
. ' GROUP BY master_table ORDER BY hits DESC'; if (!empty($column)) {
if(!empty($column)){ $rel_query .= ' AND master_field = \'' . $column . '\'';
$_rel_query .= ' AND master_field = \'' . $column . '\'';
} }
$rel_query .= ' GROUP BY master_table ORDER BY hits DESC'
$_relations = PMA_query_as_cu($_rel_query); $relations = PMA_query_as_cu($rel_query);
while ($row = PMA_mysql_fetch_array($_relations)) { while ($row = PMA_mysql_fetch_array($relations)) {
// we want the first one (highest number of hits) or the first one // we want the first one (highest number of hits) or the first one
// that is in the WHERE clause // that is in the WHERE clause
if (!isset($master)) { if (!isset($master)) {
@@ -816,32 +823,33 @@ if (isset($Field) && count($Field) > 0) {
} }
} // end while } // end while
// now we only use everything but the first table // now we only use everything but the first table
$incrit_s = '(\'' . implode('\', \'', $reltabs) . '\')'; $incrit_s = '(\'' . implode('\', \'', $reltabs) . '\')';
$_rel_query = 'SELECT *' $rel_query = 'SELECT *'
. ' FROM ' . PMA_backquote($cfgRelation['relation']) . ' FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . $db . '\' ' . ' WHERE master_db = \'' . $db . '\''
. ' AND foreign_db = \'' . $db . '\' ' . ' AND foreign_db = \'' . $db . '\''
. ' AND master_table IN ' . $incrit . ' AND master_table IN ' . $incrit
. ' AND foreign_table IN ' . $incrit_s . ' AND foreign_table IN ' . $incrit_s;
. ' ORDER BY foreign_table, master_table'; if (!empty($column)) {
if(!empty($column)){ $rel_query .= ' AND master_field = \'' . $column . '\'';
$_rel_query .= ' AND master_field = \'' . $column . '\'';
} }
$rel_query .= ' ORDER BY foreign_table, master_table';
if (isset($dbh)) { if (isset($dbh)) {
PMA_mysql_select_db($cfgRelation['db'],$dbh); PMA_mysql_select_db($cfgRelation['db'], $dbh);
$_relations = @PMA_mysql_query($_rel_query, $GLOBALS['dbh']) or PMA_mysqlDie(mysql_error($GLOBALS['dbh']), $_rel_query, '', $err_url_0); $relations = @PMA_mysql_query($rel_query, $dbh) or PMA_mysqlDie(mysql_error($dbh), $rel_query, '', $err_url_0);
PMA_mysql_select_db($db,$dbh); PMA_mysql_select_db($db, $dbh);
} else { } else {
PMA_mysql_select_db($cfgRelation['db']); PMA_mysql_select_db($cfgRelation['db']);
$_relations = @PMA_mysql_query($_rel_query) or PMA_mysqlDie('', $_rel_query, '', $err_url_0); $relations = @PMA_mysql_query($rel_query) or PMA_mysqlDie('', $rel_query, '', $err_url_0);
PMA_mysql_select_db($db); PMA_mysql_select_db($db);
} }
while ($row = PMA_mysql_fetch_array($_relations)) { while ($row = PMA_mysql_fetch_array($relations)) {
$foreign_table = $row['foreign_table']; $foreign_table = $row['foreign_table'];
if ($rel[$foreign_table]['mcon'] == 0) { if ($rel[$foreign_table]['mcon'] == 0) {
// if we already found a link to the mastertable we don't // if we already found a link to the master table we don't
// want another otherwise we take whatever we get // want another otherwise we take whatever we get
$rel[$foreign_table]['link'] = ' LEFT JOIN ' . PMA_backquote($foreign_table) $rel[$foreign_table]['link'] = ' LEFT JOIN ' . PMA_backquote($foreign_table)
. ' ON ' . PMA_backquote($row['master_table']) . '.' . PMA_backquote($row['master_field']) . ' ON ' . PMA_backquote($row['master_table']) . '.' . PMA_backquote($row['master_field'])
@@ -870,27 +878,27 @@ if (isset($Field) && count($Field) > 0) {
$incrit_d = '(\'' . implode('\', \'', $found) . '\')'; $incrit_d = '(\'' . implode('\', \'', $found) . '\')';
$incrit_s = '(\'' . implode('\', \'', $rest) . '\')'; $incrit_s = '(\'' . implode('\', \'', $rest) . '\')';
$_rel_query = 'SELECT *' $rel_query = 'SELECT *'
. ' FROM ' . PMA_backquote($cfgRelation['relation']) . ' FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . $db . '\' ' . ' WHERE master_db = \'' . $db . '\''
. ' AND foreign_db = \'' . $db . '\' ' . ' AND foreign_db = \'' . $db . '\''
. ' AND master_table IN ' . $incrit_s . ' AND master_table IN ' . $incrit_s
. ' AND foreign_table IN ' . $incrit_d . ' AND foreign_table IN ' . $incrit_d;
. ' ORDER BY master_table, foreign_table'; if (!empty($column)) {
if(!empty($column)){ $rel_query .= ' AND master_field = \'' . $column . '\'';
$_rel_query .= ' AND master_field = \'' . $column . '\'';
} }
$rel_query .= ' ORDER BY master_table, foreign_table';
if (isset($dbh)) { if (isset($dbh)) {
PMA_mysql_select_db($cfgRelation['db'],$dbh); PMA_mysql_select_db($cfgRelation['db'], $dbh);
$_relations = @PMA_mysql_query($_rel_query, $GLOBALS['dbh']) or PMA_mysqlDie(mysql_error($GLOBALS['dbh']), $_rel_query, '', $err_url_0); $relations = @PMA_mysql_query($rel_query, $dbh) or PMA_mysqlDie(mysql_error($dbh), $rel_query, '', $err_url_0);
PMA_mysql_select_db($db,$dbh); PMA_mysql_select_db($db, $dbh);
} else { } else {
PMA_mysql_select_db($cfgRelation['db']); PMA_mysql_select_db($cfgRelation['db']);
$_relations = @PMA_mysql_query($_rel_query) or PMA_mysqlDie('', $_rel_query, '', $err_url_0); $relations = @PMA_mysql_query($rel_query) or PMA_mysqlDie('', $rel_query, '', $err_url_0);
PMA_mysql_select_db($db); PMA_mysql_select_db($db);
} }
while ($row = PMA_mysql_fetch_array($_relations)) { while ($row = PMA_mysql_fetch_array($relations)) {
$found_table = $row['master_table']; $found_table = $row['master_table'];
if ($rel[$found_table]['mcon'] == 0) { if ($rel[$found_table]['mcon'] == 0) {
// if we allready found a link to the mastertable we // if we allready found a link to the mastertable we
@@ -939,16 +947,17 @@ if (isset($Field) && count($Field) > 0) {
$qry_from .= $ljm . $lj; $qry_from .= $ljm . $lj;
} // end if ($master != '') } // end if ($master != '')
} // end rel work and $alltabs > 0 } // end rel work and $alltabs > 0
if (empty($qry_from) && count($alltabs)) { if (empty($qry_from) && count($alltabs)) {
// there might be more than one mentioning of the table in here // there might be more than one mentioning of the table in here
// as array_unique is only PHP4 we have to do this by hand // as array_unique is only PHP4 we have to do this by hand
$_temp = array(); $temp = array();
while (list($k, $v) = each ($alltabs)) { while (list($k, $v) = each($alltabs)) {
$_temp[$v] = 1; $temp[$v] = 1;
} }
unset($alltabs); unset($alltabs);
$alltabs = array(); $alltabs = array();
while (list($k, $v) = each ($_temp)) { while (list($k, $v) = each($temp)) {
$alltabs[] = $k; $alltabs[] = $k;
} }
$qry_from = implode(', ', PMA_backquote($alltabs)); $qry_from = implode(', ', PMA_backquote($alltabs));
@@ -1027,10 +1036,10 @@ for ($x = 0; $x < $col; $x++) {
// if they have chosen all fields using the * selector, // if they have chosen all fields using the * selector,
// then sorting is not available // then sorting is not available
// Robbat2 - Fix for Bug #570698 // Robbat2 - Fix for Bug #570698
if(substr($curField[$x],-2) != '.*') if (substr($curField[$x], -2) != '.*') {
{ $qry_orderby .= $curField[$x] . ' ' . $curSort[$x]; $qry_orderby .= $curField[$x] . ' ' . $curSort[$x];
$last_orderby = 1; $last_orderby = 1;
} }
} }
} // end for } // end for
if (!empty($qry_orderby)) { if (!empty($qry_orderby)) {

View File

@@ -11,50 +11,55 @@ require('./tbl_properties_common.php3');
require('./tbl_properties_table_info.php3'); require('./tbl_properties_table_info.php3');
require('./libraries/relation.lib.php3'); require('./libraries/relation.lib.php3');
/**
* Gets the relation settings
*/
$cfgRelation = PMA_getRelationsParam(); $cfgRelation = PMA_getRelationsParam();
/** /**
* Updates * Updates
*/ */
if ($cfgRelation['relwork']) { if ($cfgRelation['relwork']) {
$existrel = getForeigners($db,$table); $existrel = getForeigners($db, $table);
} }
if ($cfgRelation['displaywork']) { if ($cfgRelation['displaywork']) {
$disp = getDisplayField($db,$table); $disp = getDisplayField($db, $table);
} }
if ($cfgRelation['relwork'] if ($cfgRelation['relwork']
&& isset($submit_rel) && $submit_rel == 'true') { && isset($submit_rel) && $submit_rel == 'true') {
while (list($key, $value) = each($destination)) { while (list($key, $value) = each($destination)) {
if ($value != 'nix') { if ($value != 'nix') {
$for = explode('.', $value); $for = explode('.', $value);
if (!isset($existrel[$key])) { if (!isset($existrel[$key])) {
$upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['relation']) $upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['relation'])
. '(master_db, master_table, master_field, foreign_db, foreign_table, foreign_field)' . '(master_db, master_table, master_field, foreign_db, foreign_table, foreign_field)'
. ' values(' . ' values('
. '\'' . PMA_sqlAddslashes($db) . '\', ' . '\'' . PMA_sqlAddslashes($db) . '\', '
. '\'' . PMA_sqlAddslashes($table) . '\', ' . '\'' . PMA_sqlAddslashes($table) . '\', '
. '\'' . PMA_sqlAddslashes($key) . '\', ' . '\'' . PMA_sqlAddslashes($key) . '\', '
. '\'' . PMA_sqlAddslashes($for[0]) . '\', ' . '\'' . PMA_sqlAddslashes($for[0]) . '\', '
. '\'' . PMA_sqlAddslashes($for[1]) . '\',' . '\'' . PMA_sqlAddslashes($for[1]) . '\','
. '\'' . PMA_sqlAddslashes($for[2]) . '\')'; . '\'' . PMA_sqlAddslashes($for[2]) . '\')';
} else if ($existrel[$key] != $value) { } else if ($existrel[$key] != $value) {
$upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation']) . ' SET' $upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation']) . ' SET'
. ' foreign_db = \'' . PMA_sqlAddslashes($for[0]) .'\', ' . ' foreign_db = \'' . PMA_sqlAddslashes($for[0]) . '\', '
. ' foreign_table = \'' . PMA_sqlAddslashes($for[1]) .'\', ' . ' foreign_table = \'' . PMA_sqlAddslashes($for[1]) . '\', '
. ' foreign_field = \'' . PMA_sqlAddslashes($for[2]) .'\' ' . ' foreign_field = \'' . PMA_sqlAddslashes($for[2]) . '\' '
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'' . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\'' . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND master_field = \'' . PMA_sqlAddslashes($key) . '\''; . ' AND master_field = \'' . PMA_sqlAddslashes($key) . '\'';
} // end if... else.... } // end if... else....
} else if (isset($existrel[$key])) { } else if (isset($existrel[$key])) {
$upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) $upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'' . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\'' . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND master_field = \'' . PMA_sqlAddslashes($key) . '\''; . ' AND master_field = \'' . PMA_sqlAddslashes($key) . '\'';
} // end if... else.... } // end if... else....
if(isset($upd_query)){ if (isset($upd_query)) {
$upd_rs = PMA_query_as_cu($upd_query); $upd_rs = PMA_query_as_cu($upd_query);
unset($upd_query); unset($upd_query);
} }
} // end while } // end while
@@ -64,74 +69,77 @@ if ($cfgRelation['displaywork']
&& isset($submit_show) && $submit_show == 'true') { && isset($submit_show) && $submit_show == 'true') {
if ($disp) { if ($disp) {
$upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_info']) $upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_info'])
. ' SET display_field = \'' . PMA_sqlAddslashes($display_field) . '\'' . ' SET display_field = \'' . PMA_sqlAddslashes($display_field) . '\''
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''; . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
} else { } else {
$upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['table_info']) $upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['table_info'])
. '(db_name,table_name,display_field) ' . '(db_name, table_name, display_field) '
. ' VALUES(' . ' VALUES('
. '\'' . PMA_sqlAddslashes($db) . '\',' . '\'' . PMA_sqlAddslashes($db) . '\','
. '\'' . PMA_sqlAddslashes($table) . '\',' . '\'' . PMA_sqlAddslashes($table) . '\','
. '\'' . PMA_sqlAddslashes($display_field) .'\')'; . '\'' . PMA_sqlAddslashes($display_field) . '\')';
} }
if(isset($upd_query)){ if (isset($upd_query)) {
$upd_rs = PMA_query_as_cu($upd_query); $upd_rs = PMA_query_as_cu($upd_query);
} }
} // end if } // end if
if($cfgRelation['commwork'] if ($cfgRelation['commwork']
&& isset($submit_comm) && $submit_comm == 'true') { && isset($submit_comm) && $submit_comm == 'true') {
while (list($key,$value) = each($comment)) { while (list($key, $value) = each($comment)) {
$test_qry = 'SELECT comment FROM ' . PMA_backquote($cfgRelation['column_comments']) $test_qry = 'SELECT comment FROM ' . PMA_backquote($cfgRelation['column_comments'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\''; . ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\'';
$test_rs = PMA_query_as_cu($test_qry); $test_rs = PMA_query_as_cu($test_qry);
if(mysql_num_rows($test_rs)>0) { if ($test_rs && mysql_num_rows($test_rs) > 0) {
if(strlen($value)>0){ if (strlen($value) > 0) {
$upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_comments']) $upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_comments'])
. ' SET comment = \'' . PMA_sqlAddslashes($value) . '\'' . ' SET comment = \'' . PMA_sqlAddslashes($value) . '\''
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\''; . ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\'';
} else { } else {
$upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_comments']) $upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_comments'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\''; . ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\'';
} }
} else if (strlen($value)>0){ } else if (strlen($value) > 0) {
$upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['column_comments']) $upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['column_comments'])
. ' (db_name,table_name,column_name,comment) ' . ' (db_name, table_name, column_name, comment) '
. ' VALUES(\'' . PMA_sqlAddslashes($db) . '\',' . ' VALUES('
. '\'' . PMA_sqlAddslashes($db) . '\','
. '\'' . PMA_sqlAddslashes($table) . '\',' . '\'' . PMA_sqlAddslashes($table) . '\','
. '\'' . PMA_sqlAddslashes($key) . '\',' . '\'' . PMA_sqlAddslashes($key) . '\','
. '\'' . PMA_sqlAddslashes($value) . '\')'; . '\'' . PMA_sqlAddslashes($value) . '\')';
} }
if(isset($upd_query)){ if (isset($upd_query)){
$upd_rs = PMA_query_as_cu($upd_query); $upd_rs = PMA_query_as_cu($upd_query);
} }
} // end while (transferred data) } // end while (transferred data)
} // end if (commwork) } // end if (commwork)
// now that we might have changed we have to see again // Now that we might have changed we have to see again
if ($cfgRelation['relwork']) { if ($cfgRelation['relwork']) {
$existrel = getForeigners($db,$table); $existrel = getForeigners($db, $table);
} }
if ($cfgRelation['displaywork']) { if ($cfgRelation['displaywork']) {
$disp = getDisplayField($db,$table); $disp = getDisplayField($db, $table);
} }
if ($cfgRelation['commwork']) { if ($cfgRelation['commwork']) {
$comments = getComments($db,$table); $comments = getComments($db, $table);
} }
/** /**
* Dialog * Dialog
*/ */
if ($cfgRelation['relwork']) { if ($cfgRelation['relwork']) {
// to choose Relations we first need all tablenames in current db // To choose relations we first need all tables names in current db
$tab_query = 'SHOW TABLES FROM ' . PMA_backquote($db); $tab_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
$tab_rs = PMA_mysql_query($tab_query) or PMA_mysqlDie('', $tab_query, '', $err_url_0); $tab_rs = PMA_mysql_query($tab_query) or PMA_mysqlDie('', $tab_query, '', $err_url_0);
$selectboxall['nix'] = '--'; $selectboxall['nix'] = '--';
@@ -159,15 +167,20 @@ if ($cfgRelation['relwork']) {
} }
} // end while } // end while
// create Array of Relations (Mike Beck) // Create array of relations (Mike Beck)
$rel_dest = getForeigners($db,$table); $rel_dest = getForeigners($db, $table);
} // end if } // end if
// now find out the columns of our $table // Now find out the columns of our $table
$col_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table); $col_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table);
$col_rs = PMA_mysql_query($col_query) or PMA_mysqlDie('', $col_query, '', $err_url_0); $col_rs = PMA_mysql_query($col_query) or PMA_mysqlDie('', $col_query, '', $err_url_0);
if ($col_rs && mysql_num_rows($col_rs) > 0) { if ($col_rs && mysql_num_rows($col_rs) > 0) {
while ($row = PMA_mysql_fetch_array($col_rs)) {
$save_row[] = $row;
}
$saved_row_cnt = count($save_row);
?> ?>
<form method="post" action="tbl_relation.php3"> <form method="post" action="tbl_relation.php3">
<input type="hidden" name="lang" value="<?php echo $lang; ?>" /> <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
@@ -178,15 +191,11 @@ if ($col_rs && mysql_num_rows($col_rs) > 0) {
<table> <table>
<tr> <tr>
<th colspan=2 align="center"><b><?php echo $strLinksTo; ?></b></th> <th colspan="2" align="center"><b><?php echo $strLinksTo; ?></b></th>
</tr> </tr>
<?php <?php
for ($i = 0; $i < $saved_row_cnt; $i++) {
while ($row = PMA_mysql_fetch_array($col_rs)) { echo "\n";
$save_row[] = $row;
}
for ($i=0;$i<count($save_row);$i++){
echo "\n";
?> ?>
<tr> <tr>
<th><?php echo $save_row[$i]['Field']; ?></th> <th><?php echo $save_row[$i]['Field']; ?></th>
@@ -198,7 +207,7 @@ if ($col_rs && mysql_num_rows($col_rs) > 0) {
reset($selectboxall); reset($selectboxall);
while (list($key, $value) = each($selectboxall)) { while (list($key, $value) = each($selectboxall)) {
$myfield = $save_row[$i]['Field']; $myfield = $save_row[$i]['Field'];
if(isset($existrel[$myfield])){ if (isset($existrel[$myfield])) {
$test = $existrel[$myfield]['foreign_db'] . '.' $test = $existrel[$myfield]['foreign_db'] . '.'
. $existrel[$myfield]['foreign_table'] . '.' . $existrel[$myfield]['foreign_table'] . '.'
. $existrel[$myfield]['foreign_field']; . $existrel[$myfield]['foreign_field'];
@@ -207,7 +216,7 @@ if ($col_rs && mysql_num_rows($col_rs) > 0) {
} }
echo ' ' echo ' '
. '<option value="' . htmlspecialchars($key) . '"'; . '<option value="' . htmlspecialchars($key) . '"';
if ( $test && $key == $test) { if ($test && $key == $test) {
echo ' selected="selected"'; echo ' selected="selected"';
} }
echo '>' . $value . '</option>'. "\n"; echo '>' . $value . '</option>'. "\n";
@@ -232,7 +241,7 @@ if ($col_rs && mysql_num_rows($col_rs) > 0) {
<?php <?php
if ($cfgRelation['displaywork']) { if ($cfgRelation['displaywork']) {
// Get "display_filed" infos // Get "display_filed" infos
$disp = getDisplayField($db,$table); $disp = getDisplayField($db, $table);
echo "\n"; echo "\n";
?> ?>
@@ -261,42 +270,45 @@ if ($col_rs && mysql_num_rows($col_rs) > 0) {
</form> </form>
<?php <?php
} // end if (displayworks) } // end if (displayworks)
if($cfgRelation['commwork']) {
?>
<form method="post" action="tbl_relation.php3">
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="db" value="<?php echo $db; ?>" />
<input type="hidden" name="table" value="<?php echo $table; ?>" />
<input type="hidden" name="submit_comm" value="true" />
<table> if ($cfgRelation['commwork']) {
<tr>
<th colspan=2 align="center"><b><?php echo $strComments; ?></b></th> echo "\n";
</tr> ?>
<form method="post" action="tbl_relation.php3">
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="db" value="<?php echo $db; ?>" />
<input type="hidden" name="table" value="<?php echo $table; ?>" />
<input type="hidden" name="submit_comm" value="true" />
<table>
<tr>
<th colspan="2" align="center"><b><?php echo $strComments; ?></b></th>
</tr>
<?php <?php
for ($i=0;$i<count($save_row);$i++){ for ($i = 0; $i < $saved_row_cnt; $i++) {
$field =$save_row[$i]['Field']; $field = $save_row[$i]['Field'];
echo "\n"; echo "\n";
?> ?>
<tr> <tr>
<th><?php echo $field; ?></th> <th><?php echo $field; ?></th>
<td> <td>
<input type="text" name="comment[<?php echo $field;?>]" value="<?php echo htmlspecialchars($comments[$field]);?>"> <input type="text" name="comment[<?php echo $field;?>]" value="<?php echo htmlspecialchars($comments[$field]); ?>">
</td> </td>
</tr> </tr>
<?php <?php
} // end for } // end for
echo "\n"; echo "\n";
?> ?>
<tr> <tr>
<td colspan="2" align="center"> <td colspan="2" align="center">
<input type="submit" value="<?php echo $strGo; ?>" /> <input type="submit" value="<?php echo $strGo; ?>" />
</td> </td>
</tr> </tr>
</table> </table>
</form> </form>
<?php <?php
} // end if (comments work) } // end if (comments work)
} // end if (we have columns in this table) } // end if (we have columns in this table)