diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index f0c97ff912..dfd4672c58 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -130,7 +130,7 @@ function PMA_tbl_getSubTabs() * @param array $foreignData Foreign keys data * @param string $field Column name * @param string $tbl_fields_type Column type - * @param int $i Column index + * @param int $column_index Column index * @param string $db Selected database * @param string $table Selected table * @param array $titles Selected title @@ -143,7 +143,7 @@ function PMA_tbl_getSubTabs() * for search criteria input. */ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, - $tbl_fields_type, $i, $db, $table, $titles, $foreignMaxLimit, $fields, + $tbl_fields_type, $column_index, $db, $table, $titles, $foreignMaxLimit, $fields, $in_fbs = false, $in_zoom_search_edit = false ) { $str = ''; @@ -152,7 +152,8 @@ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, && is_array($foreignData['disp_row']) ) { // f o r e i g n k e y s - $str .= ''; // go back to first row // here, the 4th parameter is empty because there is no current // value of data for the dropdown (the search page initial values @@ -164,29 +165,30 @@ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $str .= ''; } elseif ($foreignData['foreign_link'] == true) { - if (isset($fields[$i]) && is_string($fields[$i])) { - $str .= ''; + if (isset($fields[$column_index]) && is_string($fields[$column_index])) { + $str .= ''; } else { - $str .= ''; + $str .= ''; } $str .= <<'; - } elseif (in_array($tbl_fields_type[$i], PMA_getGISDatatypes())) { + } elseif (in_array($tbl_fields_type[$column_index], PMA_getGISDatatypes())) { // g e o m e t r y - $str .= ''; + $str .= ''; if ($in_fbs) { $edit_url = 'gis_data_editor.php?' . PMA_generate_common_url(); @@ -198,8 +200,8 @@ EOT; $str .= ''; } - } elseif (strncasecmp($tbl_fields_type[$i], 'enum', 4) == 0 - || (strncasecmp($tbl_fields_type[$i], 'set', 3) == 0 && $in_zoom_search_edit) + } elseif (strncasecmp($tbl_fields_type[$column_index], 'enum', 4) == 0 + || (strncasecmp($tbl_fields_type[$column_index], 'set', 3) == 0 && $in_zoom_search_edit) ) { // e n u m s a n d s e t s @@ -211,23 +213,25 @@ EOT; $value = explode( ', ', - str_replace("'", '', substr($tbl_fields_type[$i], 5, -1)) + str_replace("'", '', substr($tbl_fields_type[$column_index], 5, -1)) ); $cnt_value = count($value); - if ((strncasecmp($tbl_fields_type[$i], 'enum', 4) && ! $in_zoom_search_edit) - || (strncasecmp($tbl_fields_type[$i], 'set', 3) && $in_zoom_search_edit) + if ((strncasecmp($tbl_fields_type[$column_index], 'enum', 4) && ! $in_zoom_search_edit) + || (strncasecmp($tbl_fields_type[$column_index], 'set', 3) && $in_zoom_search_edit) ) { - $str .= ''; } else { - $str .= ''; } for ($j = 0; $j < $cnt_value; $j++) { - if (isset($fields[$i]) - && is_array($fields[$i]) - && in_array($value[$j], $fields[$i]) + if (isset($fields[$column_index]) + && is_array($fields[$column_index]) + && in_array($value[$j], $fields[$column_index]) ) { $str .= ''; @@ -241,7 +245,7 @@ EOT; } else { // o t h e r c a s e s $the_class = 'textfield'; - $type = $tbl_fields_type[$i]; + $type = $tbl_fields_type[$column_index]; if ($type == 'date') { $the_class .= ' datefield'; @@ -251,14 +255,14 @@ EOT; $the_class .= ' bit'; } - if (isset($fields[$i]) && is_string($fields[$i])) { - $str .= ''; + . $column_index .'" value = "' . $fields[$column_index] . '"/>'; } else { - $str .= ''; + . $column_index .'" />'; } } return $str; @@ -469,14 +473,19 @@ function PMA_tblSearchGenerateWhereClause() // else continue to form the where clause from column criteria values $fullWhereClause = $charsets = array(); reset($_POST['criteriaColumnOperators']); - while (list($i, $operator) = each($_POST['criteriaColumnOperators'])) { - list($charsets[$i]) = explode('_', $_POST['criteriaColumnCollations'][$i]); + while (list($column_index, $operator) = each($_POST['criteriaColumnOperators'])) { + list($charsets[$column_index]) = explode( + '_', $_POST['criteriaColumnCollations'][$column_index] + ); $unaryFlag = $GLOBALS['PMA_Types']->isUnaryOperator($operator); - $tmp_geom_func = isset($geom_func[$i]) ? $geom_func[$i] : null; + $tmp_geom_func = isset($geom_func[$column_index]) ? $geom_func[$column_index] : null; $whereClause = PMA_tbl_search_getWhereClause( - $_POST['fields'][$i], $_POST['criteriaColumnNames'][$i], $_POST['criteriaColumnTypes'][$i], - $_POST['criteriaColumnCollations'][$i], $operator, $unaryFlag, $tmp_geom_func + $_POST['fields'][$column_index], + $_POST['criteriaColumnNames'][$column_index], + $_POST['criteriaColumnTypes'][$column_index], + $_POST['criteriaColumnCollations'][$column_index], $operator, $unaryFlag, + $tmp_geom_func ); if ($whereClause) { @@ -634,7 +643,7 @@ function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes $geom_types = PMA_getGISDatatypes(); // for every column present in table - for ($i = 0; $i < $columnCount; $i++) { + for ($column_index = 0; $column_index < $columnCount; $column_index++) { $html_output .= ''; $odd_row = !$odd_row; @@ -642,40 +651,40 @@ function PMA_tblSearchGetFieldsTableHtml($db, $table, $columnNames, $columnTypes * If 'Function' column is present */ $html_output .= PMA_tblSearchGetGeomFuncHtml( - $geomColumnFlag, $columnTypes, $geom_types, $i + $geomColumnFlag, $columnTypes, $geom_types, $column_index ); /** * Displays column's name, type and collation */ - $html_output .= '' . htmlspecialchars($columnNames[$i]) . ''; - $html_output .= '' . htmlspecialchars($columnTypes[$i]) . ''; - $html_output .= '' . $columnCollations[$i] . ''; + $html_output .= '' . htmlspecialchars($columnNames[$column_index]) . ''; + $html_output .= '' . htmlspecialchars($columnTypes[$column_index]) . ''; + $html_output .= '' . $columnCollations[$column_index] . ''; /** * Displays column's comparison operators depending on column type */ $html_output .= ''; /** * Displays column's foreign relations if any */ $html_output .= ''; - $field = $columnNames[$i]; + $field = $columnNames[$column_index]; $foreignData = PMA_getForeignData($foreigners, $field, false, '', ''); $html_output .= PMA_getForeignFields_Values( - $foreigners, $foreignData, $field, $columnTypes, $i, $db, $table, + $foreigners, $foreignData, $field, $columnTypes, $column_index, $db, $table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], '', true ); - $html_output .= '' - . '' - . ''; + $html_output .= '' + . '' + . ''; } // end for $html_output .= '';