Skip to content

Commit

Permalink
Move zoom-search result form's html to function
Browse files Browse the repository at this point in the history
  • Loading branch information
atul516 committed Jun 12, 2012
1 parent bf219df commit 2da7a2e
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 73 deletions.
88 changes: 87 additions & 1 deletion libraries/tbl_select.lib.php
Expand Up @@ -749,7 +749,6 @@ function PMA_tblSearchGetColumnProperties($db, $table, $columnNames, $columnType
function PMA_tblSearchGetRowsNormal($db, $table, $columnNames, $columnTypes,
$columnCollations, $columnNullFlags, $geomColumnFlag, $foreigners
) {
$titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
$geom_types = PMA_getGISDatatypes();
$odd_row = true;
$html_output = '';
Expand Down Expand Up @@ -1032,4 +1031,91 @@ function PMA_tblSearchGetSelectionForm($goto, $db, $table, $columnNames,
}
return $html_output;
}

/**
* Provides form for displaying point data and also the scatter plot
* (for tbl_zoom_select.php)
*
* @param string $goto Goto URL
* @param string $db Selected Database
* @param string $table Selected Table
* @param array $columnNames Names of columns in the table
* @param array $columnTypes Types of columns in the table
* @param array $columnNullFlags Null information of columns
* @param array $foreigners Array of foreign keys
* @param array $data Array containing SQL query data
*
* @return string form's html
*/
function PMA_tblSearchGetZoomResultsForm($goto, $db, $table, $columnNames,
$columnTypes, $columnNullFlags, $foreigners, $data
) {
$html_output = '';
$titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
$html_output .= '<form method="post" action="tbl_zoom_select.php"'
. ' name="displayResultForm" id="zoom_display_form"'
. ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : '') . '>';
$html_output .= PMA_generate_common_hidden_inputs($db, $table);
$html_output .= '<input type="hidden" name="goto" value="' . $goto . '" />';
$html_output .= '<input type="hidden" name="back" value="tbl_zoom_select.php" />';

$html_output .= '<fieldset id="displaySection">';
$html_output .= '<legend>' . __('Browse/Edit the points') . '</legend>';

//JSON encode the data(query result)
$html_output .= '<center>';
if (isset($_POST['zoom_submit']) && ! empty($data)) {
$html_output .= '<div id="resizer">';
$html_output .= '<center><a href="#" onclick="displayHelp();">'
. __('How to use') . '</a></center>';
$html_output .= '<div id="querydata" style="display:none">'
. json_encode($data) . '</div>';
$html_output .= '<div id="querychart"></div>';
$html_output .= '<button class="button-reset">'
. __('Reset zoom') . '</button>';
$html_output .= '</div>';
}
$html_output .= '</center>';

//Displays rows in point edit form
$html_output .= '<div id="dataDisplay" style="display:none">';
$html_output .= '<table><thead>';
$html_output .= '<tr>';
$html_output .= '<th>' . __('Column') . '</th>'
. '<th>' . __('Null') . '</th>'
. '<th>' . __('Value') . '</th>';
$html_output .= '</tr>';
$html_output .= '</thead>';

$html_output .= '<tbody>';
$odd_row = true;
for ($column_index = 0; $column_index < count($columnNames); $column_index++) {
$fieldpopup = $columnNames[$column_index];
$foreignData = PMA_getForeignData($foreigners, $fieldpopup, false, '', '');
$html_output .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">';
$odd_row = ! $odd_row;
//Display column Names
$html_output .= '<th>' . htmlspecialchars($columnNames[$column_index])
. '</th>';
//Null checkbox if column can be null
$html_output .= '<th>' . (($columnNullFlags[$column_index] == 'YES')
? '<input type="checkbox" class="checkbox_null"'
. ' name="criteriaColumnNullFlags[' . $column_index . ']"'
. ' id="edit_fields_null_id_' . $column_index . '" />'
: '');
$html_output .= '</th>';
//Column's Input box
$html_output .= '<th>';
$html_output .= PMA_getForeignFields_Values(
$foreigners, $foreignData, $fieldpopup, $columnTypes, $column_index, $db,
$table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], '', false, true
);
$html_output .= '</th></tr>';
}
$html_output .= '</tbody></table>';
$html_output .= '</div>';
$html_output .= '<input type="hidden" id="queryID" name="sql_query" />';
$html_output .= '</form>';
return $html_output;
}
?>
77 changes: 5 additions & 72 deletions tbl_zoom_select.php
Expand Up @@ -179,90 +179,23 @@
$uniqueCondition = PMA_getUniqueCondition(
$result, count($columnNames), $fields_meta, $tmpRow, true
);

//Append it to row array as where_clause
$row['where_clause'] = $uniqueCondition[0];

$tmpData = array(
$_POST['criteriaColumnNames'][0] => $row[$_POST['criteriaColumnNames'][0]],
$_POST['criteriaColumnNames'][1] => $row[$_POST['criteriaColumnNames'][1]],
'where_clause' => $uniqueCondition[0]
);
$tmpData[$dataLabel] = ($dataLabel) ? $row[$dataLabel] : '';

$data[] = $tmpData;
}
unset($tmpData);
/*
* Form for displaying point data and also the scatter plot
*/
?>
<form method="post" action="tbl_zoom_select.php" name="displayResultForm" id="zoom_display_form"
<?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : ''); ?>>
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<input type="hidden" name="back" value="tbl_zoom_select.php" />

<fieldset id="displaySection">
<legend><?php echo __('Browse/Edit the points') ?></legend>
<center>
<?php
//JSON encode the data(query result)
if (isset($zoom_submit) && ! empty($data)) {
?>
<div id="resizer">
<center><a href="#" onclick="displayHelp();"><?php echo __('How to use'); ?></a></center>
<div id="querydata" style="display:none">
<?php
echo json_encode($data);
?>
</div>
<div id="querychart"></div>
<button class="button-reset"><?php echo __('Reset zoom'); ?></button>
</div>
<?php
}
?>
</center>
<div id='dataDisplay' style="display:none">
<table>
<thead>
<tr>
<th> <?php echo __('Column'); ?> </th>
<th> <?php echo __('Null'); ?> </th>
<th> <?php echo __('Value'); ?> </th>
</tr>
</thead>
<tbody>
<?php
$odd_row = true;
for ($column_index = 0; $column_index < count($columnNames); $column_index++) {
$fieldpopup = $columnNames[$column_index];
$foreignData = PMA_getForeignData($foreigners, $fieldpopup, false, '', '');
?>
<tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
<th><?php echo htmlspecialchars($columnNames[$column_index]); ?></th>
<th><?php echo ($columnNullFlags[$column_index] == 'YES')
? '<input type="checkbox" class="checkbox_null" name="criteriaColumnNullFlags[ '
. $column_index . ' ]" id="edit_fields_null_id_' . $column_index . '" />'
: ''; ?>
</th>
<th> <?php
echo PMA_getForeignFields_Values(
$foreigners, $foreignData, $fieldpopup, $columnTypes,
$column_index, $db, $table, $titles,
$GLOBALS['cfg']['ForeignKeyMaxLimit'], '', false, true
); ?>
</th>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<input type="hidden" id="queryID" name="sql_query" />
</form>
<?php
//Displays form for point data and scatter plot
echo PMA_tblSearchGetZoomResultsForm($goto, $db, $table, $columnNames,
$columnTypes, $columnNullFlags, $foreigners, $data
);
}
require './libraries/footer.inc.php';
?>

0 comments on commit 2da7a2e

Please sign in to comment.