remove some duplicate code

This commit is contained in:
Marc Delisle
2009-10-25 12:01:18 +00:00
parent d2233aac88
commit 3d2225d3fc
2 changed files with 45 additions and 79 deletions

View File

@@ -1416,13 +1416,24 @@ function PMA_syncDisplayHeaderTargetAndMatchingTables($trg_db, $matching_tables)
echo '</tr>'; echo '</tr>';
$odd_row = false; $odd_row = false;
foreach ($matching_tables as $tbl_name) { foreach ($matching_tables as $tbl_name) {
$odd_row = ! $odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td> ' .$tbl_name . '</td>';
echo $odd_row ? 'odd' : 'even';
echo '">
<td> ' .$tbl_name . '</td>';
echo '</tr>'; echo '</tr>';
} }
return $odd_row; return $odd_row;
} }
/**
* 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;
echo '<tr height="32" class=" ';
echo $odd_row ? 'odd' : 'even';
echo '">';
return $odd_row;
}
?> ?>

View File

@@ -316,11 +316,8 @@ if ((isset($_REQUEST['submit_connect']))) {
/** /**
* Displays the name of the matching table * Displays the name of the matching table
*/ */
$odd_row = ! $odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td>' . $matching_tables[$i]. "\n" . '</td>
echo $odd_row ? 'odd' : 'even';
echo '">
<td>' . $matching_tables[$i]. "\n" . '</td>
<td align="center">'; <td align="center">';
/** /**
* Calculating the number of alter columns, number of columns to be added, number of columns to be removed, * Calculating the number of alter columns, number of columns to be added, number of columns to be removed,
@@ -378,11 +375,8 @@ if ((isset($_REQUEST['submit_connect']))) {
* Displays the tables' names present in source but missing from target * Displays the tables' names present in source but missing from target
*/ */
for ($j = 0; $j < count($source_tables_uncommon); $j++) { for ($j = 0; $j < count($source_tables_uncommon); $j++) {
$odd_row = !$odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td> + ' .$source_tables_uncommon[$j]. "\n" . '</td> ';
echo $odd_row ? 'odd' : 'even';
echo '">
<td> + ' .$source_tables_uncommon[$j]. "\n" . '</td> ';
echo '<td align="center"><img class="icon" src="' . $pmaThemeImage . 'new_struct.jpg" width="29" height="29" echo '<td align="center"><img class="icon" src="' . $pmaThemeImage . 'new_struct.jpg" width="29" height="29"
alt="Click to Select" onmouseover="change_Image(this);" onmouseout="change_Image(this);" alt="Click to Select" onmouseover="change_Image(this);" onmouseout="change_Image(this);"
@@ -400,11 +394,8 @@ if ((isset($_REQUEST['submit_connect']))) {
</tr>'; </tr>';
} }
foreach ($target_tables_uncommon as $tbl_nc_name) { foreach ($target_tables_uncommon as $tbl_nc_name) {
$odd_row = ! $odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td><td></td>';
echo $odd_row ? 'odd' : 'even';
echo '">
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td><td></td>';
echo '</tr>'; echo '</tr>';
} }
/** /**
@@ -414,19 +405,13 @@ if ((isset($_REQUEST['submit_connect']))) {
$odd_row = PMA_syncDisplayHeaderTargetAndMatchingTables($trg_db, $matching_tables); $odd_row = PMA_syncDisplayHeaderTargetAndMatchingTables($trg_db, $matching_tables);
foreach ($source_tables_uncommon as $tbl_nc_name) { foreach ($source_tables_uncommon as $tbl_nc_name) {
$odd_row = ! $odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td>' .$tbl_nc_name . "\n" . ' (' . $GLOBALS['strNotPresent'] . ')</td>
echo $odd_row ? 'odd' : 'even';
echo '">
<td>' .$tbl_nc_name . "\n" . ' (' . $GLOBALS['strNotPresent'] . ')</td>
</tr>'; </tr>';
} }
foreach ($target_tables_uncommon as $tbl_nc_name) { foreach ($target_tables_uncommon as $tbl_nc_name) {
$odd_row = ! $odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td> - ' .$tbl_nc_name . '</td>';
echo $odd_row ? 'odd' : 'even';
echo '">
<td> - ' .$tbl_nc_name . '</td>';
echo '</tr>'; echo '</tr>';
} }
echo '</table>'; echo '</table>';
@@ -732,11 +717,8 @@ if (isset($_REQUEST['Table_ids'])) {
PMA_syncDisplayHeaderSource($src_db); PMA_syncDisplayHeaderSource($src_db);
$odd_row = false; $odd_row = false;
for($i = 0; $i < count($matching_tables); $i++) { for($i = 0; $i < count($matching_tables); $i++) {
$odd_row = !$odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td align="center">' . $matching_tables[$i]. "\n" . '</td>
echo $odd_row ? 'odd' : 'even';
echo '">
<td align="center">' . $matching_tables[$i]. "\n" . '</td>
<td align="center">'; <td align="center">';
$num_alter_cols = 0; $num_alter_cols = 0;
@@ -811,11 +793,8 @@ if (isset($_REQUEST['Table_ids'])) {
$_SESSION['insert_array'] = $insert_array; $_SESSION['insert_array'] = $insert_array;
for ($j = 0; $j < count($source_tables_uncommon); $j++) { for ($j = 0; $j < count($source_tables_uncommon); $j++) {
$odd_row = ! $odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td align="center"> + ' .$source_tables_uncommon[$j]. "\n" . '</td>
echo $odd_row ? 'odd' : 'even';
echo '">
<td align="center"> + ' .$source_tables_uncommon[$j]. "\n" . '</td>
<td align="center">'; <td align="center">';
/** /**
* Display the difference only when it has not been applied * Display the difference only when it has not been applied
@@ -859,20 +838,14 @@ if (isset($_REQUEST['Table_ids'])) {
* Displaying the target database tables * Displaying the target database tables
*/ */
foreach ($target_tables_uncommon as $tbl_nc_name) { foreach ($target_tables_uncommon as $tbl_nc_name) {
$odd_row = ! $odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td><td></td>';
echo $odd_row ? 'odd' : 'even';
echo '">
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td><td></td>';
echo '</tr>'; echo '</tr>';
} }
echo '</table>'; echo '</table>';
$odd_row = PMA_syncDisplayHeaderTargetAndMatchingTables($trg_db, $matching_tables); $odd_row = PMA_syncDisplayHeaderTargetAndMatchingTables($trg_db, $matching_tables);
foreach ($source_tables_uncommon as $tbl_nc_name) { foreach ($source_tables_uncommon as $tbl_nc_name) {
$odd_row = ! $odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" ';
echo $odd_row ? 'odd' : 'even';
echo '">';
if (in_array($tbl_nc_name, $uncommon_tables)) { if (in_array($tbl_nc_name, $uncommon_tables)) {
echo '<td>' .$tbl_nc_name . "\n" . ' (' . $GLOBALS['strNotPresent'] . ')</td>'; echo '<td>' .$tbl_nc_name . "\n" . ' (' . $GLOBALS['strNotPresent'] . ')</td>';
} else { } else {
@@ -882,11 +855,8 @@ if (isset($_REQUEST['Table_ids'])) {
</tr>'; </tr>';
} }
foreach ($target_tables_uncommon as $tbl_nc_name) { foreach ($target_tables_uncommon as $tbl_nc_name) {
$odd_row = ! $odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td> - ' .$tbl_nc_name . '</td>';
echo $odd_row ? 'odd' : 'even';
echo '">
<td> - ' .$tbl_nc_name . '</td>';
echo '</tr>'; echo '</tr>';
} }
echo '</table> echo '</table>
@@ -989,47 +959,32 @@ if (isset($_REQUEST['synchronize_db'])) {
$odd_row = false; $odd_row = false;
for($i = 0; $i < count($matching_tables); $i++) for($i = 0; $i < count($matching_tables); $i++)
{ {
$odd_row = !$odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td>' . $matching_tables[$i]. "\n" . '</td>
echo $odd_row ? 'odd' : 'even';
echo '">
<td>' . $matching_tables[$i]. "\n" . '</td>
<td></td> <td></td>
</tr>'; </tr>';
} }
for ($j = 0; $j < count($source_tables_uncommon); $j++) { for ($j = 0; $j < count($source_tables_uncommon); $j++) {
$odd_row = ! $odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td> + ' .$source_tables_uncommon[$j]. "\n" . '</td> ';
echo $odd_row ? 'odd' : 'even';
echo '">
<td> + ' .$source_tables_uncommon[$j]. "\n" . '</td> ';
echo '<td></td> echo '<td></td>
</tr>'; </tr>';
} }
foreach ($target_tables_uncommon as $tbl_nc_name) { foreach ($target_tables_uncommon as $tbl_nc_name) {
$odd_row = ! $odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td><td></td>';
echo $odd_row ? 'odd' : 'even';
echo '">
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td><td></td>';
echo '</tr>'; echo '</tr>';
} }
echo '</table>'; echo '</table>';
$odd_row = PMA_syncDisplayHeaderTargetAndMatchingTables($trg_db, $matching_tables); $odd_row = PMA_syncDisplayHeaderTargetAndMatchingTables($trg_db, $matching_tables);
foreach ($source_tables_uncommon as $tbl_nc_name) { foreach ($source_tables_uncommon as $tbl_nc_name) {
$odd_row = !$odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td>' .$tbl_nc_name . "\n" . ' </td>
echo $odd_row ? 'odd' : 'even';
echo '">
<td>' .$tbl_nc_name . "\n" . ' </td>
</tr>'; </tr>';
} }
foreach ($target_tables_uncommon as $tbl_nc_name) { foreach ($target_tables_uncommon as $tbl_nc_name) {
$odd_row = ! $odd_row; $odd_row = PMA_syncDisplayBeginTableRow($odd_row);
echo '<tr height="32" class=" '; echo '<td> ' .$tbl_nc_name . '</td>';
echo $odd_row ? 'odd' : 'even';
echo '">
<td> ' .$tbl_nc_name . '</td>';
echo '</tr>'; echo '</tr>';
} }
echo '</table> </div>'; echo '</table> </div>';