diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index f5ff195bce..0db43c644d 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -13,15 +13,16 @@ if (! defined('PHPMYADMIN')) { /** * Retrieve form parameters for insert/edit form * + * @param string $db name of the database + * @param string $table name of the table * @param array $where_clauses where clauses * @param array $where_clause_array array of where clauses * @param string $err_url error url * * @return array $_form_params array of insert/edit form parameters */ -function PMA_getFormParametersForInsertForm($paramArray, $where_clauses, $where_clause_array, $err_url) +function PMA_getFormParametersForInsertForm($db, $table, $where_clauses, $where_clause_array, $err_url) { - list($table, $db) = $paramArray; $_form_params = array( 'db' => $db, 'table' => $table, @@ -40,30 +41,6 @@ function PMA_getFormParametersForInsertForm($paramArray, $where_clauses, $where_ return $_form_params; } -/** - * Retrieve the values for pma edit mode - * - * @param array $paramArray array containing $db and $table - * @param array $where_clause where clauses - * - * @return array containing insert_mode,whereClauses, result array - * where_clauses_array and found_unique_key boolean value - */ -function PMA_getValuesForEditMode($paramArray, $where_clause) -{ - $found_unique_key = false; - list($table, $db) = $paramArray; - if (isset($where_clause)) { - $where_clause_array = PMA_getWhereClauseArray($where_clause); - list($whereClauses, $resultArray, $rowsArray, $found_unique_key) - = PMA_analyzeWhereClauses($where_clause_array, $paramArray, $found_unique_key); - return array(false, $whereClauses, $resultArray, $rowsArray, $where_clause_array, $found_unique_key); - } else { - list($results, $row) = PMA_loadFirstRowInEditMode($paramArray); - return array(true, null, $results, $row, null, $found_unique_key); - } -} - /** * * @return whereClauseArray array of where clauses @@ -83,14 +60,14 @@ function PMA_getWhereClauseArray($where_clause) * Analysing where cluases array * * @param array $where_clause_array array of where clauses - * @param array $paramArray array containing $db and $table + * @param string $table name of the table + * @param string $db name of the database * @param boolean $found_unique_key boolean variable for unique key * * @return array $where_clauses, $result, $rows */ -function PMA_analyzeWhereClauses($where_clause_array, $paramArray, $found_unique_key) +function PMA_analyzeWhereClauses($where_clause_array, $table, $db, $found_unique_key) { - list($table, $db) = $paramArray; $rows = array(); $result = array(); $where_clauses = array(); @@ -114,7 +91,9 @@ function PMA_analyzeWhereClauses($where_clause_array, $paramArray, $found_unique * @param array $where_clause_array * @param string $local_query * @param array $result - * @param boolean $found_unique_key + * @param boolean $found_unique_key + * + * @return boolean $found_unique_key */ function PMA_showEmptyResultMessageOrSetUniqueCondition($rows, $key_id, $where_clause_array, $local_query, $result, $found_unique_key @@ -140,13 +119,13 @@ function PMA_showEmptyResultMessageOrSetUniqueCondition($rows, $key_id, /** * No primary key given, just load first row * - * @param array $paramArray array containing $db and $table + * @param string $table name of the table + * @param string $db name of the database * * @return array containing $result and $rows arrays */ -function PMA_loadFirstRowInEditMode($paramArray ) +function PMA_loadFirstRowInEditMode($table, $db) { - list($table, $db) = $paramArray; $result = PMA_DBI_query( 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT 1;', null, @@ -608,7 +587,7 @@ function PMA_getValueColumn($column, $backup_field, $column_name_appendix, } if (in_array($column['pma_type'], $gis_data_types)) { - $html_output .= PMA_getHTMLforGisDataTypes($vrow, $column); + $html_output .= PMA_getHTMLforGisDataTypes($current_row, $column); } return $html_output; @@ -992,7 +971,7 @@ function PMA_getBinaryAndBlobColumn($column, $data, $special_chars,$biggest_max_ $html_output .= $html_out; } - if (!empty($cfg['UploadDir'])) { + if (!empty($GLOBALS['cfg']['UploadDir'])) { $html_output .= PMA_getSelectOptionForUpload($vkey, $column); } @@ -1187,14 +1166,14 @@ function PMA_getColumnSize($column, $extracted_columnspec) /** * Get HTML for gis data types * - * @param string $vrow row description + * @param string $current_row row description * @param array $column description of column in given table * * @return string an html snippet */ -function PMA_getHTMLforGisDataTypes($vrow, $column) +function PMA_getHTMLforGisDataTypes($current_row, $column) { - $data_val = isset($vrow[$column['Field']]) ? $vrow[$column['Field']] : ''; + $data_val = isset($current_row[$column['Field']]) ? $current_row[$column['Field']] : ''; $_url_params = array( 'field' => $column['Field_title'], 'value' => $data_val, @@ -1211,14 +1190,15 @@ function PMA_getHTMLforGisDataTypes($vrow, $column) /** * get html for continue insertion form * - * @param array $paramArray array containing $db and $table + * @param string $table name of the table + * @param string $db name of the database * @param array $where_clause_array array of where clauses + * @param string $err_url error url * * @return string an html snippet */ -function PMA_getContinueInsertionForm($paramArray, $where_clause_array, $err_url) +function PMA_getContinueInsertionForm($table, $db, $where_clause_array, $err_url) { - list($table, $db) = $paramArray; $html_output = '
'; if ($insert_mode) { //Continue insertion form - $html_output .= PMA_getContinueInsertionForm($paramTableDbArray, $where_clause_array, $err_url); + $html_output .= PMA_getContinueInsertionForm($table, $db, $where_clause_array, $err_url); } echo $html_output; /** diff --git a/tbl_replace.php b/tbl_replace.php index f7e0f9e263..6c2ff58998 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -16,6 +16,11 @@ */ require_once 'libraries/common.inc.php'; +/** + * functions implementation for this script + */ +require_once 'libraries/insert_edit.lib.php'; + // Check parameters PMA_checkParameters(array('db', 'table', 'goto')); @@ -102,24 +107,7 @@ if (isset($_REQUEST['err_url'])) { /** * Prepares the update/insert of a row */ -if (isset($_REQUEST['where_clause'])) { - // we were editing something => use the WHERE clause - $loop_array = (is_array($_REQUEST['where_clause']) ? $_REQUEST['where_clause'] : array($_REQUEST['where_clause'])); - $using_key = true; - $is_insert = $_REQUEST['submit_type'] == 'insert' - || $_REQUEST['submit_type'] == 'showinsert' - || $_REQUEST['submit_type'] == 'insertignore'; - $is_insertignore = $_REQUEST['submit_type'] == 'insertignore'; -} else { - // new row => use indexes - $loop_array = array(); - foreach ($_REQUEST['fields']['multi_edit'] as $key => $dummy) { - $loop_array[] = $key; - } - $using_key = false; - $is_insert = true; - $is_insertignore = false; -} +list($loop_array, $using_key, $is_insert, $is_insertignore) = PMA_getParamsForUpdateOrInsert(); $query = array(); $value_sets = array();