Merge remote-tracking branch 'origin/master'

This commit is contained in:
Michal Čihař 2012-05-30 18:31:05 +02:00
commit 4784643764
4 changed files with 406 additions and 246 deletions

View File

@ -148,18 +148,24 @@ class PMA_Types
/**
* Returns operators for given type as html options
*
* @param string $type Type of field
* @param boolean $null Whether field can be NULL
* @param string $type Type of field
* @param boolean $null Whether field can be NULL
* @param string $selectedOperator Option to be selected
*
* @return array
* @return string Generated Html
*/
public function getTypeOperatorsHtml($type, $null)
public function getTypeOperatorsHtml($type, $null, $selectedOperator = null)
{
$html = '';
foreach ($this->getTypeOperators($type, $null) as $fc) {
$escaped = htmlspecialchars($fc);
$html .= '<option value="' . $escaped . '">' . $escaped . '</option>';
if (isset($selectedOperator) && $selectedOperator == $fc) {
$html .= '<option value="' . htmlspecialchars($fc) . '" selected="selected">'
. htmlspecialchars($fc) . '</option>';
} else {
$html .= '<option value="' . htmlspecialchars($fc) . '">'
. htmlspecialchars($fc) . '</option>';
}
}
return $html;

View File

@ -44,7 +44,7 @@ function PMA_tbl_getFields($db, $table)
} else {
// strip the "BINARY" attribute, except if we find "BINARY(" because
// this would be a BINARY or VARBINARY field type
if (!preg_match('@BINARY[\(]@i', $type)) {
if (! preg_match('@BINARY[\(]@i', $type)) {
$type = preg_replace('@BINARY@i', '', $type);
}
$type = preg_replace('@ZEROFILL@i', '', $type);
@ -331,7 +331,7 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations,
$w = $backquoted_name . ' ' . $func_type . ' ' . $gis_data;
} elseif (strncasecmp($types, 'enum', 4) == 0) {
if (!empty($fields)) {
if (! empty($fields)) {
if (! is_array($fields)) {
$fields = explode(',', $fields);
}
@ -410,4 +410,356 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations,
return $w;
}
/**
* Builds the sql search query from the post parameters
*
* @param string $table Selected table
* @param array $fields Entered values of the columns
* @param array $criteriaColumnNames Names of all columns
* @param array $criteriaColumnTypes Types of all columns
* @param array $criteriaColumnCollations Collations of all columns
* @param array $criteriaColumnOperators Operators for given column type
*
* @return string the generated SQL query
*/
function PMA_tblSearchBuildSqlQuery($table, $fields, $criteriaColumnNames,
$criteriaColumnTypes, $criteriaColumnCollations, $criteriaColumnOperators)
{
$sql_query = 'SELECT ';
// If only distinct values are needed
$is_distinct = (isset($_POST['distinct'])) ? 'true' : 'false';
if ($is_distinct == 'true') {
$sql_query .= 'DISTINCT ';
}
// if all column names were selected to display, we do a 'SELECT *'
// (more efficient and this helps prevent a problem in IE
// if one of the rows is edited and we come back to the Select results)
if (count($_POST['columnsToDisplay']) == count($criteriaColumnNames)) {
$sql_query .= '* ';
} else {
$sql_query .= implode(', ', PMA_backquote($_POST['columnsToDisplay']));
} // end if
$sql_query .= ' FROM ' . PMA_backquote($table);
$whereClause = PMA_tblSearchGenerateWhereClause(
$fields, $criteriaColumnNames, $criteriaColumnTypes,
$criteriaColumnCollations, $criteriaColumnOperators
);
$sql_query .= $whereClause;
// if the search results are to be ordered
if ($_POST['orderByColumn'] != '--nil--') {
$sql_query .= ' ORDER BY ' . PMA_backquote($_POST['orderByColumn'])
. ' ' . $_POST['order'];
} // end if
return $sql_query;
}
/**
* Generates the where clause for the SQL search query to be executed
*
* @param array $fields Entered values of the columns
* @param array $criteriaColumnNames Names of all columns
* @param array $criteriaColumnTypes Types of all columns
* @param array $criteriaColumnCollations Collations of all columns
* @param array $criteriaColumnOperators Operators for given column type
*
* @return string the generated where clause
*/
function PMA_tblSearchGenerateWhereClause($fields, $criteriaColumnNames,
$criteriaColumnTypes, $criteriaColumnCollations, $criteriaColumnOperators)
{
$fullWhereClause = '';
if (trim($_POST['customWhereClause']) != '') {
$fullWhereClause .= ' WHERE ' . $_POST['customWhereClause'];
return $fullWhereClause;
}
// If there are no search criterias set, return
if (! array_filter($fields)) {
return $fullWhereClause;
}
// else continue to form the where clause from column criteria values
$fullWhereClause = $charsets = array();
reset($criteriaColumnOperators);
while (list($i, $operator) = each($criteriaColumnOperators)) {
list($charsets[$i]) = explode('_', $criteriaColumnCollations[$i]);
$unaryFlag = $GLOBALS['PMA_Types']->isUnaryOperator($operator);
$tmp_geom_func = isset($geom_func[$i]) ? $geom_func[$i] : null;
$whereClause = PMA_tbl_search_getWhereClause(
$fields[$i], $criteriaColumnNames[$i], $criteriaColumnTypes[$i],
$criteriaColumnCollations[$i], $operator, $unaryFlag, $tmp_geom_func
);
if ($whereClause) {
$fullWhereClause[] = $whereClause;
}
} // end while
if ($fullWhereClause) {
$fullWhereClause = ' WHERE ' . implode(' AND ', $fullWhereClause);
}
return $fullWhereClause;
}
/**
* Generates HTML for a geometrical function column to be displayed in table
* search selection form
*
* @param boolean $geomColumnFlag whether a geometry column is present
* @param array $columnTypes array containing types of all columns in the table
* @param array $geom_types array of GIS data types
* @param integer $column_index index of current column in $columnTypes array
*
* @return string the generated HTML
*/
function PMA_tblSearchGetGeomFuncHtml($geomColumnFlag, $columnTypes,
$geom_types, $column_index)
{
$html_output = '';
// return if geometrical column is not present
if (! $geomColumnFlag) {
return $html_output;
}
/**
* Displays 'Function' column if it is present
*/
$html_output .= '<td>';
// if a geometry column is present
if (in_array($columnTypes[$column_index], $geom_types)) {
$html_output .= '<select class="geom_func" name="geom_func['
. $column_index . ']">';
// get the relevant list of GIS functions
$funcs = PMA_getGISFunctions($columnTypes[$column_index], true, true);
/**
* For each function in the list of functions, add an option to select list
*/
foreach ($funcs as $func_name => $func) {
$name = isset($func['display']) ? $func['display'] : $func_name;
$html_output .= '<option value="' . htmlspecialchars($name) . '">'
. htmlspecialchars($name) . '</option>';
}
$html_output .= '</select>';
} else {
$html_output .= '&nbsp;';
}
$html_output .= '</td>';
return $html_output;
}
/**
* Generates formatted HTML for extra search options in table search form
*
* @param array $columnNames Array containing types of all columns in the table
* @param integer $columnCount Number of columns in the table
*
* @return string the generated HTML
*/
function PMA_tblSearchGetOptions($columnNames, $columnCount)
{
$html_output = '';
$html_output .= PMA_getDivForSliderEffect('searchoptions', __('Options'));
/**
* Displays columns select list for selecting distinct columns in the search
*/
$html_output .= '<fieldset id="fieldset_select_fields">'
. '<legend>' . __('Select columns (at least one):') . '</legend>'
. '<select name="columnsToDisplay[]" size="' . min($columnCount, 10)
. '" multiple="multiple">';
// Displays the list of the fields
foreach ($columnNames as $each_field) {
$html_output .= ' '
. '<option value="' . htmlspecialchars($each_field) . '"'
. ' selected="selected">' . htmlspecialchars($each_field)
. '</option>' . "\n";
} // end for
$html_output .= '</select>'
. '<input type="checkbox" name="distinct" value="DISTINCT" id="oDistinct" />'
. '<label for="oDistinct">DISTINCT</label></fieldset>';
/**
* Displays input box for custom 'Where' clause to be used in the search
*/
$html_output .= '<fieldset id="fieldset_search_conditions">'
. '<legend>' . '<em>' . __('Or') . '</em> '
. __('Add search conditions (body of the "where" clause):') . '</legend>';
$html_output .= PMA_showMySQLDocu('SQL-Syntax', 'Functions');
$html_output .= '<input type="text" name="customWhereClause" class="textfield" size="64" />'
. '</fieldset>';
/**
* Displays option of changing default number of rows displayed per page
*/
$html_output .= '<fieldset id="fieldset_limit_rows">'
. '<legend>' . __('Number of rows per page') . '</legend>'
. '<input type="text" size="4" name="session_max_rows" '
. 'value="' . $GLOBALS['cfg']['MaxRows'] . '" class="textfield" />'
. '</fieldset>';
/**
* Displays option for ordering search results by a column value (Asc or Desc)
*/
$html_output .= '<fieldset id="fieldset_display_order">'
. '<legend>' . __('Display order:') . '</legend>'
. '<select name="orderByColumn"><option value="--nil--"></option>';
foreach ($columnNames as $each_field) {
$html_output .= ' '
. '<option value="' . htmlspecialchars($each_field) . '">'
. htmlspecialchars($each_field) . '</option>' . "\n";
} // end for
$html_output .= '</select>';
$choices = array(
'ASC' => __('Ascending'),
'DESC' => __('Descending')
);
$html_output .= PMA_getRadioFields('order', $choices, 'ASC', false, true, "formelement");
unset($choices);
$html_output .= '</fieldset><br style="clear: both;"/></div></fieldset>';
return $html_output;
}
/**
* Generates HTML for displaying fields table in search form
*
* @param array $columnNames Names of columns in the table
* @param array $columnTypes Types of columns in the table
* @param array $columnCollations Collation of all columns
* @param array $columnNullFlags Null information of columns
* @param boolean $geomColumnFlag Whether a geometry column is present
* @param integer $columnCount Number of columns in the table
* @param array $foreigners Array of foreign keys
* @param string $db Selected database
* @param string $table Selected table
*
* @return string the generated HTML
*/
function PMA_tblSearchGetFieldsTableHtml($columnNames, $columnTypes,
$columnCollations, $columnNullFlags, $geomColumnFlag, $columnCount,
$foreigners, $db, $table)
{
$html_output = '';
$html_output .= '<table class="data">';
$html_output .= PMA_tbl_setTableHeader($geomColumnFlag) . '<tbody>';
$odd_row = true;
$titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
$geom_types = PMA_getGISDatatypes();
// for every column present in table
for ($i = 0; $i < $columnCount; $i++) {
$html_output .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">';
$odd_row = !$odd_row;
/**
* If 'Function' column is present
*/
$html_output .= PMA_tblSearchGetGeomFuncHtml(
$geomColumnFlag, $columnTypes, $geom_types, $i
);
/**
* Displays column's name, type and collation
*/
$html_output .= '<th>' . htmlspecialchars($columnNames[$i]) . '</th>';
$html_output .= '<td>' . htmlspecialchars($columnTypes[$i]) . '</td>';
$html_output .= '<td>' . $columnCollations[$i] . '</td>';
/**
* Displays column's comparison operators depending on column type
*/
$html_output .= '<td><select name="criteriaColumnOperators[]">';
$html_output .= $GLOBALS['PMA_Types']->getTypeOperatorsHtml(
preg_replace('@\(.*@s', '', $columnTypes[$i]),
$columnNullFlags[$i]
);
$html_output .= '</select></td>';
/**
* Displays column's foreign relations if any
*/
$html_output .= '<td>';
$field = $columnNames[$i];
$foreignData = PMA_getForeignData($foreigners, $field, false, '', '');
$html_output .= PMA_getForeignFields_Values(
$foreigners, $foreignData, $field, $columnTypes, $i, $db, $table,
$titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], '', true
);
$html_output .= '<input type="hidden" name="criteriaColumnNames[' . $i . ']" value="'
. htmlspecialchars($columnNames[$i]) . '" />'
. '<input type="hidden" name="criteriaColumnTypes[' . $i . ']" value="'
. $columnTypes[$i] . '" />'
. '<input type="hidden" name="criteriaColumnCollations[' . $i . ']" value="'
. $columnCollations[$i] . '" /></td></tr>';
} // end for
$html_output .= '</tbody></table>';
return $html_output;
}
/**
* Generates the table search form under table search tab
*
* @param string $goto Goto URL
* @param array $columnNames Names of columns in the table
* @param array $columnTypes Types of columns in the table
* @param array $columnCollations Collation of all columns
* @param array $columnNullFlags Null information of columns
* @param boolean $geomColumnFlag Whether a geometry column is present
* @param integer $columnCount Number of columns in the table
* @param array $foreigners Array of foreign keys
* @param string $db Selected database
* @param string $table Selected table
*
* @return string the generated HTML for table search form
*/
function PMA_tblSearchGetSelectionForm($goto, $columnNames, $columnTypes,
$columnCollations, $columnNullFlags, $geomColumnFlag, $columnCount,
$foreigners, $db, $table)
{
$html_output = '';
$html_output .= '<fieldset id="fieldset_subtab">';
$url_params = array();
$url_params['db'] = $db;
$url_params['table'] = $table;
$html_output .= PMA_generateHtmlTabs(PMA_tbl_getSubTabs(), $url_params, 'topmenu2');
$html_output .= '<form method="post" action="tbl_select.php" name="insertForm"'
. ' id="tbl_search_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_select.php" />'
. '<fieldset id="fieldset_table_search"><fieldset id="fieldset_table_qbe">'
. '<legend>' . __('Do a "query by example" (wildcard: "%")') . '</legend>';
/**
* Displays table fields
*/
$html_output .= PMA_tblSearchGetFieldsTableHtml(
$columnNames, $columnTypes, $columnCollations, $columnNullFlags,
$geomColumnFlag, $columnCount, $foreigners, $db, $table
);
$html_output .= '<div id="gis_editor"></div>'
. '<div id="popup_background"></div>'
. '</fieldset>';
/**
* Displays slider options form
*/
$html_output .= PMA_tblSearchGetOptions($columnNames, $columnCount);
/**
* Displays selection form's footer elements
*/
$html_output .= '<fieldset class="tblFooters">'
. '<input type="submit" name="submit" value="' . __('Go') . '" />'
. '</fieldset></form><div id="sqlqueryresults"></div></fieldset>';
return $html_output;
}
?>

View File

@ -23,26 +23,16 @@ $GLOBALS['js_include'][] = 'tbl_change.js';
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
$GLOBALS['js_include'][] = 'gis_data_editor.js';
$titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
$geom_types = PMA_getGISDatatypes();
$post_params = array(
'ajax_request',
'collations',
'criteriaColumnCollations',
'db',
'distinct',
'fields',
'func',
'max_number_of_fields',
'names',
'order',
'orderField',
'param',
'criteriaColumnOperators',
'criteriaColumnNames',
'session_max_rows',
'table',
'types',
'where',
'criteriaColumnTypes',
);
foreach ($post_params as $one_post_param) {
if (isset($_POST[$one_post_param])) {
@ -54,14 +44,14 @@ foreach ($post_params as $one_post_param) {
/**
* Not selection yet required -> displays the selection form
*/
if (! isset($param) || $param[0] == '') {
if (! isset($_POST['columnsToDisplay']) || $_POST['columnsToDisplay'][0] == '') {
// Gets some core libraries
include_once 'libraries/tbl_common.inc.php';
//$err_url = 'tbl_select.php' . $err_url;
$url_query .= '&amp;goto=tbl_select.php&amp;back=tbl_select.php';
/**
* Gets tables informations
* Gets table's information
*/
include_once 'libraries/tbl_info.inc.php';
@ -72,230 +62,30 @@ if (! isset($param) || $param[0] == '') {
$err_url = $goto . '?' . PMA_generate_common_url($db, $table);
// Gets the list and number of fields
list($fields_list, $fields_type, $fields_collation, $fields_null, $geom_column_present)
list($columnNames, $columnTypes, $columnCollations, $columnNullFlags, $geomColumnFlag)
= PMA_tbl_getFields($db, $table);
$fields_cnt = count($fields_list);
$columnCount = count($columnNames);
// retrieve keys into foreign fields, if any
// check also foreigners even if relwork is FALSE (to get
// foreign keys from innodb)
$foreigners = PMA_getForeigners($db, $table);
?>
<fieldset id="fieldset_subtab">
<?php
$url_params = array();
$url_params['db'] = $db;
$url_params['table'] = $table;
echo PMA_generateHtmlTabs(PMA_tbl_getSubTabs(), $url_params, 'topmenu2');
?>
<form method="post" action="tbl_select.php" name="insertForm" id="tbl_search_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_select.php" />
<fieldset id="fieldset_table_search">
<fieldset id="fieldset_table_qbe">
<legend><?php echo __('Do a "query by example" (wildcard: "%")') ?></legend>
<table class="data">
<?php echo PMA_tbl_setTableHeader($geom_column_present); ?>
<tbody>
<?php
$odd_row = true;
for ($i = 0; $i < $fields_cnt; $i++) {
?>
<tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
<?php
// if 'Function' column is present
if ($geom_column_present) {
echo('<td>');
// if a geometry column
if (in_array($fields_type[$i], $geom_types)) {
echo('<select class="geom_func" name="geom_func['. $i .']">');
// get the relevant list of functions
$funcs = PMA_getGISFunctions($fields_type[$i], true, true);
foreach ($funcs as $func_name => $func) {
$name = isset($func['display']) ? $func['display'] : $func_name;
echo('<option value="' . htmlspecialchars($name) . '">'
. htmlspecialchars($name) . '</option>');
}
echo('</select>');
} else {
echo('&nbsp;');
}
echo('</td>');
}
?>
<th><?php echo htmlspecialchars($fields_list[$i]); ?></th>
<td><?php echo htmlspecialchars($fields_type[$i]); ?></td>
<td><?php echo $fields_collation[$i]; ?></td>
<td><select name="func[]">
<?php
echo $GLOBALS['PMA_Types']->getTypeOperatorsHtml(
preg_replace('@\(.*@s', '', $fields_type[$i]),
$fields_null[$i]
);
?>
</select>
</td>
<td>
<?php
$field = $fields_list[$i];
$foreignData = PMA_getForeignData($foreigners, $field, false, '', '');
echo PMA_getForeignFields_Values(
$foreigners, $foreignData, $field, $fields_type, $i, $db, $table,
$titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], '', true
);
?>
<input type="hidden" name="names[<?php echo $i; ?>]"
value="<?php echo htmlspecialchars($fields_list[$i]); ?>" />
<input type="hidden" name="types[<?php echo $i; ?>]"
value="<?php echo $fields_type[$i]; ?>" />
<input type="hidden" name="collations[<?php echo $i; ?>]"
value="<?php echo $fields_collation[$i]; ?>" />
</td>
</tr>
<?php
} // end for
?>
</tbody>
</table>
<div id="gis_editor"></div><div id="popup_background"></div>
</fieldset>
<?php
echo PMA_getDivForSliderEffect('searchoptions', __('Options'));
?>
<fieldset id="fieldset_select_fields">
<legend><?php echo __('Select columns (at least one):'); ?></legend>
<select name="param[]" size="<?php echo min($fields_cnt, 10); ?>"
multiple="multiple">
<?php
// Displays the list of the fields
foreach ($fields_list as $each_field) {
echo ' '
.'<option value="' . htmlspecialchars($each_field) . '"'
.' selected="selected">' . htmlspecialchars($each_field)
.'</option>' . "\n";
}
?>
</select>
<input type="checkbox" name="distinct" value="DISTINCT" id="oDistinct" />
<label for="oDistinct">DISTINCT</label>
</fieldset>
<fieldset id="fieldset_search_conditions">
<legend><?php echo '<em>' . __('Or') . '</em> ' . __('Add search conditions (body of the "where" clause):'); ?></legend>
<?php echo PMA_showMySQLDocu('SQL-Syntax', 'Functions'); ?>
<input type="text" name="where" class="textfield" size="64" />
</fieldset>
<fieldset id="fieldset_limit_rows">
<legend><?php echo __('Number of rows per page'); ?></legend>
<input type="text" size="4" name="session_max_rows"
value="<?php echo $GLOBALS['cfg']['MaxRows']; ?>" class="textfield" />
</fieldset>
<fieldset id="fieldset_display_order">
<legend><?php echo __('Display order:'); ?></legend>
<select name="orderField">
<option value="--nil--"></option>
<?php
foreach ($fields_list as $each_field) {
echo ' '
.'<option value="' . htmlspecialchars($each_field) . '">'
.htmlspecialchars($each_field) . '</option>' . "\n";
} // end for
?>
</select>
<?php
$choices = array(
'ASC' => __('Ascending'),
'DESC' => __('Descending')
// Displays the table search form
echo PMA_tblSearchGetSelectionForm(
$goto, $columnNames, $columnTypes, $columnCollations, $columnNullFlags,
$geomColumnFlag, $columnCount, $foreigners, $db, $table
);
echo PMA_getRadioFields('order', $choices, 'ASC', false, true, "formelement");
unset($choices);
?>
</fieldset>
<br style="clear: both;"/>
</div>
</fieldset>
<fieldset class="tblFooters">
<input type="hidden" name="max_number_of_fields"
value="<?php echo $fields_cnt; ?>" />
<input type="submit" name="submit" value="<?php echo __('Go'); ?>" />
</fieldset>
</form>
<div id="sqlqueryresults"></div>
</fieldset>
<?php
include 'libraries/footer.inc.php';
} else {
/**
* Selection criteria have been submitted -> do the work
*/
// Builds the query
$sql_query = 'SELECT ' . (isset($distinct) ? 'DISTINCT ' : '');
// if all fields were selected to display, we do a SELECT *
// (more efficient and this helps prevent a problem in IE
// if one of the rows is edited and we come back to the Select results)
if (count($param) == $max_number_of_fields) {
$sql_query .= '* ';
} else {
$param = PMA_backquote($param);
$sql_query .= implode(', ', $param);
} // end if
// avoid a loop, for example when $cfg['DefaultTabTable'] is set
// to 'tbl_select.php'
unset($param);
$sql_query .= ' FROM ' . PMA_backquote($table);
// The where clause
if (trim($where) != '') {
$sql_query .= ' WHERE ' . $where;
} else {
$w = $charsets = array();
$cnt_func = count($func);
reset($func);
while (list($i, $func_type) = each($func)) {
list($charsets[$i]) = explode('_', $collations[$i]);
$unaryFlag = $GLOBALS['PMA_Types']->isUnaryOperator($func_type);
$tmp_geom_func = isset($geom_func[$i]) ? $geom_func[$i] : null;
$whereClause = PMA_tbl_search_getWhereClause(
$fields[$i], $names[$i], $types[$i], $collations[$i],
$func_type, $unaryFlag, $tmp_geom_func
);
if ($whereClause) {
$w[] = $whereClause;
}
} // end while
if ($w) {
$sql_query .= ' WHERE ' . implode(' AND ', $w);
}
} // end if
if ($orderField != '--nil--') {
$sql_query .= ' ORDER BY ' . PMA_backquote($orderField) . ' ' . $order;
} // end if
$sql_query = PMA_tblSearchBuildSqlQuery(
$table, $fields, $criteriaColumnNames, $criteriaColumnTypes,
$criteriaColumnCollations, $criteriaColumnOperators
);
include 'sql.php';
}
?>

View File

@ -45,7 +45,6 @@ $post_params = array(
'fields',
'fields_null',
'inputs',
'max_number_of_fields',
'maxPlotLimit',
'types',
'zoom_submit',
@ -170,7 +169,6 @@ $fields_cnt = count($fields_list);
// check also foreigners even if relwork is FALSE (to get
// foreign keys from innodb)
$foreigners = PMA_getForeigners($db, $table);
$flag = 1;
$tbl_fields_type = $tbl_fields_collation = $tbl_fields_null = array();
if (! isset($zoom_submit) && ! isset($inputs)) {
@ -189,13 +187,30 @@ echo PMA_generateHtmlTabs(PMA_tbl_getSubTabs(), $url_params, 'topmenu2');
* Set the field name,type,collation and whether null on select of a coulmn
*/
if (isset($inputs) && ($inputs[0] != 'pma_null' || $inputs[1] != 'pma_null')) {
$flag = 2;
for ($i = 0 ; $i < 4 ; $i++) {
if ($inputs[$i] != 'pma_null') {
$key = array_search($inputs[$i], $fields_list);
$tbl_fields_type[$i] = $fields_type[$key];
$tbl_fields_collation[$i] = $fields_collation[$key];
$tbl_fields_null[$i] = $fields_null[$key];
$tbl_fields_func[$i] = '<select name="zoomFunc[]">';
$tbl_fields_func[$i] .= $GLOBALS['PMA_Types']->getTypeOperatorsHtml(
preg_replace('@\(.*@s', '', $fields_type[$key]),
$fields_null[$key], $zoomFunc[$i]
);
$tbl_fields_func[$i] .= '</select>';
$foreignData = PMA_getForeignData($foreigners, $inputs[$i], false, '', '');
$tbl_fields_value[$i] = PMA_getForeignFields_Values(
$foreigners,
$foreignData,
$inputs[$i],
$tbl_fields_type,
$i,
$db,
$table,
$titles,
$GLOBALS['cfg']['ForeignKeyMaxLimit'],
$fields
);
}
}
}
@ -210,7 +225,6 @@ if (isset($inputs) && ($inputs[0] != 'pma_null' || $inputs[1] != 'pma_null')) {
<?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" />
<input type="hidden" name="flag" id="id_flag" value="<?php echo $flag; ?>" />
<fieldset id="inputSection">
@ -244,10 +258,10 @@ for ($i = 0; $i < 4; $i++) {
}
} ?>
</select></th>
<td></td>
<td></td>
<td></td>
<td></td>
<td><?php if (isset($tbl_fields_type[$i])) echo $tbl_fields_type[$i]; ?></td>
<td><?php if (isset($tbl_fields_collation[$i])) echo $tbl_fields_collation[$i]; ?></td>
<td><?php if (isset($tbl_fields_func[$i])) echo $tbl_fields_func[$i]; ?></td>
<td><?php if (isset($tbl_fields_value[$i])) echo $tbl_fields_value[$i]; ?></td>
</tr>
<tr><td>
<input type="hidden" name="types[<?php echo $i; ?>]" id="types_<?php echo $i; ?>"
@ -312,8 +326,6 @@ echo '" /></td></tr>';
</fieldset>
<fieldset class="tblFooters">
<input type="hidden" name="max_number_of_fields"
value="<?php echo $fields_cnt; ?>" />
<input type="submit" name="zoom_submit" id="inputFormSubmitId" value="<?php echo __('Go'); ?>" />
</fieldset>
</form>