Fix message.
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
* OpenDocument Spreadsheet import plugin for phpMyAdmin
|
* OpenDocument Spreadsheet import plugin for phpMyAdmin
|
||||||
*
|
*
|
||||||
* @todo Pretty much everything
|
* @todo Pretty much everything
|
||||||
* @todo Importing of accented characters seems to fail
|
* @todo Importing of accented characters seems to fail
|
||||||
* @version 0.5-beta
|
* @version 0.5-beta
|
||||||
* @package phpMyAdmin-Import
|
* @package phpMyAdmin-Import
|
||||||
*/
|
*/
|
||||||
@@ -25,7 +25,7 @@ if (isset($plugin_list)) {
|
|||||||
array('type' => 'bool', 'name' => 'col_names', 'text' => __('Column names in first row')),
|
array('type' => 'bool', 'name' => 'col_names', 'text' => __('Column names in first row')),
|
||||||
array('type' => 'bool', 'name' => 'empty_rows', 'text' => __('Do not import empty rows')),
|
array('type' => 'bool', 'name' => 'empty_rows', 'text' => __('Do not import empty rows')),
|
||||||
array('type' => 'bool', 'name' => 'recognize_percentages', 'text' => __('Import percentages as proper decimals (12.00% to .12)')),
|
array('type' => 'bool', 'name' => 'recognize_percentages', 'text' => __('Import percentages as proper decimals (12.00% to .12)')),
|
||||||
array('type' => 'bool', 'name' => 'recognize_currency', 'text' => __('Import currencies (.00 to 5.00)')),
|
array('type' => 'bool', 'name' => 'recognize_currency', 'text' => __('Import currencies ($5.00 to 5.00)')),
|
||||||
),
|
),
|
||||||
'options_text' => __('Options'),
|
'options_text' => __('Options'),
|
||||||
);
|
);
|
||||||
@@ -89,7 +89,7 @@ $rows = array();
|
|||||||
/* Iterate over tables */
|
/* Iterate over tables */
|
||||||
foreach ($sheets as $sheet) {
|
foreach ($sheets as $sheet) {
|
||||||
$col_names_in_first_row = $_REQUEST['ods_col_names'];
|
$col_names_in_first_row = $_REQUEST['ods_col_names'];
|
||||||
|
|
||||||
/* Iterate over rows */
|
/* Iterate over rows */
|
||||||
foreach ($sheet as $row) {
|
foreach ($sheet as $row) {
|
||||||
$type = $row->getName();
|
$type = $row->getName();
|
||||||
@@ -98,7 +98,7 @@ foreach ($sheets as $sheet) {
|
|||||||
foreach ($row as $cell) {
|
foreach ($row as $cell) {
|
||||||
$text = $cell->children('text', true);
|
$text = $cell->children('text', true);
|
||||||
$cell_attrs = $cell->attributes('office', true);
|
$cell_attrs = $cell->attributes('office', true);
|
||||||
|
|
||||||
if (count($text) != 0) {
|
if (count($text) != 0) {
|
||||||
if (! $col_names_in_first_row) {
|
if (! $col_names_in_first_row) {
|
||||||
if ($_REQUEST['ods_recognize_percentages'] && !strcmp('percentage', $cell_attrs['value-type'])) {
|
if ($_REQUEST['ods_recognize_percentages'] && !strcmp('percentage', $cell_attrs['value-type'])) {
|
||||||
@@ -117,14 +117,14 @@ foreach ($sheets as $sheet) {
|
|||||||
$col_names[] = (string)$text;
|
$col_names[] = (string)$text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++$col_count;
|
++$col_count;
|
||||||
} else {
|
} else {
|
||||||
/* Number of blank columns repeated */
|
/* Number of blank columns repeated */
|
||||||
if ($col_count < count($row->children('table', true)) - 1) {
|
if ($col_count < count($row->children('table', true)) - 1) {
|
||||||
$attr = $cell->attributes('table', true);
|
$attr = $cell->attributes('table', true);
|
||||||
$num_null = (int)$attr['number-columns-repeated'];
|
$num_null = (int)$attr['number-columns-repeated'];
|
||||||
|
|
||||||
if ($num_null) {
|
if ($num_null) {
|
||||||
if (! $col_names_in_first_row) {
|
if (! $col_names_in_first_row) {
|
||||||
for ($i = 0; $i < $num_null; ++$i) {
|
for ($i = 0; $i < $num_null; ++$i) {
|
||||||
@@ -143,18 +143,18 @@ foreach ($sheets as $sheet) {
|
|||||||
} else {
|
} else {
|
||||||
$col_names[] = PMA_getColumnAlphaName($col_count + 1);
|
$col_names[] = PMA_getColumnAlphaName($col_count + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
++$col_count;
|
++$col_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the widest row */
|
/* Find the widest row */
|
||||||
if ($col_count > $max_cols) {
|
if ($col_count > $max_cols) {
|
||||||
$max_cols = $col_count;
|
$max_cols = $col_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't include a row that is full of NULL values */
|
/* Don't include a row that is full of NULL values */
|
||||||
if (! $col_names_in_first_row) {
|
if (! $col_names_in_first_row) {
|
||||||
if ($_REQUEST['ods_empty_rows']) {
|
if ($_REQUEST['ods_empty_rows']) {
|
||||||
@@ -168,13 +168,13 @@ foreach ($sheets as $sheet) {
|
|||||||
$tempRows[] = $tempRow;
|
$tempRows[] = $tempRow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$col_count = 0;
|
$col_count = 0;
|
||||||
$col_names_in_first_row = false;
|
$col_names_in_first_row = false;
|
||||||
$tempRow = array();
|
$tempRow = array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip over empty sheets */
|
/* Skip over empty sheets */
|
||||||
if (count($tempRows) == 0 || count($tempRows[0]) == 0) {
|
if (count($tempRows) == 0 || count($tempRows[0]) == 0) {
|
||||||
$col_names = array();
|
$col_names = array();
|
||||||
@@ -182,18 +182,18 @@ foreach ($sheets as $sheet) {
|
|||||||
$tempRows = array();
|
$tempRows = array();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill out each row as necessary to make
|
* Fill out each row as necessary to make
|
||||||
* every one exactly as wide as the widest
|
* every one exactly as wide as the widest
|
||||||
* row. This included column names.
|
* row. This included column names.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Fill out column names */
|
/* Fill out column names */
|
||||||
for ($i = count($col_names); $i < $max_cols; ++$i) {
|
for ($i = count($col_names); $i < $max_cols; ++$i) {
|
||||||
$col_names[] = PMA_getColumnAlphaName($i + 1);
|
$col_names[] = PMA_getColumnAlphaName($i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill out all rows */
|
/* Fill out all rows */
|
||||||
$num_rows = count($tempRows);
|
$num_rows = count($tempRows);
|
||||||
for ($i = 0; $i < $num_rows; ++$i) {
|
for ($i = 0; $i < $num_rows; ++$i) {
|
||||||
@@ -201,11 +201,11 @@ foreach ($sheets as $sheet) {
|
|||||||
$tempRows[$i][] = 'NULL';
|
$tempRows[$i][] = 'NULL';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Store the table name so we know where to place the row set */
|
/* Store the table name so we know where to place the row set */
|
||||||
$tbl_attr = $sheet->attributes('table', true);
|
$tbl_attr = $sheet->attributes('table', true);
|
||||||
$tables[] = array((string)$tbl_attr['name']);
|
$tables[] = array((string)$tbl_attr['name']);
|
||||||
|
|
||||||
/* Store the current sheet in the accumulator */
|
/* Store the current sheet in the accumulator */
|
||||||
$rows[] = array((string)$tbl_attr['name'], $col_names, $tempRows);
|
$rows[] = array((string)$tbl_attr['name'], $col_names, $tempRows);
|
||||||
$tempRows = array();
|
$tempRows = array();
|
||||||
@@ -229,7 +229,7 @@ for ($i = 0; $i < $num_tbls; ++$i) {
|
|||||||
if (! isset($tables[$i][COL_NAMES])) {
|
if (! isset($tables[$i][COL_NAMES])) {
|
||||||
$tables[$i][] = $rows[$j][COL_NAMES];
|
$tables[$i][] = $rows[$j][COL_NAMES];
|
||||||
}
|
}
|
||||||
|
|
||||||
$tables[$i][ROWS] = $rows[$j][ROWS];
|
$tables[$i][ROWS] = $rows[$j][ROWS];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user