Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 706e69e

Browse files
author
Marc Delisle
committed
Refactor: new PMA_getHtmlForDisplayedExportHeader()
Signed-off-by: Marc Delisle <[email protected]>
1 parent c9c87fa commit 706e69e

2 files changed

Lines changed: 53 additions & 34 deletions

File tree

export.php

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -334,40 +334,11 @@
334334
exit();
335335
}
336336
}
337-
echo "\n" . '<div style="text-align: ' . $cell_align_left . '">' . "\n";
338-
//echo ' <pre>' . "\n";
339-
340-
/**
341-
* Displays a back button with all the $_REQUEST data in the URL
342-
* (store in a variable to also display after the textarea)
343-
*/
344-
$back_button = '<p>[ <a href="';
345-
if ($export_type == 'server') {
346-
$back_button .= 'server_export.php?' . PMA_URL_getCommon();
347-
} elseif ($export_type == 'database') {
348-
$back_button .= 'db_export.php?' . PMA_URL_getCommon($db);
349-
} else {
350-
$back_button .= 'tbl_export.php?' . PMA_URL_getCommon($db, $table);
351-
}
352-
353-
// Convert the multiple select elements from an array to a string
354-
if ($export_type == 'server' && isset($_REQUEST['db_select'])) {
355-
$_REQUEST['db_select'] = implode(",", $_REQUEST['db_select']);
356-
} elseif ($export_type == 'database'
357-
&& isset($_REQUEST['table_select'])
358-
) {
359-
$_REQUEST['table_select'] = implode(",", $_REQUEST['table_select']);
360-
}
361-
362-
foreach ($_REQUEST as $name => $value) {
363-
$back_button .= '&amp;' . urlencode($name) . '=' . urlencode($value);
364-
}
365-
$back_button .= '&amp;repopulate=1">Back</a> ]</p>';
366-
367-
echo $back_button;
368-
echo '<form name="nofunction">' . "\n";
369-
echo '<textarea name="sqldump" cols="50" rows="30" '
370-
. 'id="textSQLDUMP" wrap="OFF">' . "\n";
337+
list($html, $back_button) = PMA_getHtmlForDisplayedExportHeader(
338+
$export_type, $db, $table
339+
);
340+
echo $html;
341+
unset($html);
371342
} // end download
372343
}
373344

libraries/export.lib.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,52 @@ function PMA_compressExport($dump_buffer, $compression)
397397
}
398398
return $dump_buffer;
399399
}
400+
401+
/**
402+
* Returns HTML containing the header for a displayed export
403+
*
404+
* @param string $export_type the export type
405+
* @param string $db the database name
406+
* @param string $table the table name
407+
*
408+
* @return array the generated HTML and back button
409+
*/
410+
function PMA_getHtmlForDisplayedExportHeader($export_type, $db, $table)
411+
{
412+
$html = '<div style="text-align: ' . $GLOBALS['cell_align_left'] . '">';
413+
414+
/**
415+
* Displays a back button with all the $_REQUEST data in the URL
416+
* (store in a variable to also display after the textarea)
417+
*/
418+
$back_button = '<p>[ <a href="';
419+
if ($export_type == 'server') {
420+
$back_button .= 'server_export.php?' . PMA_URL_getCommon();
421+
} elseif ($export_type == 'database') {
422+
$back_button .= 'db_export.php?' . PMA_URL_getCommon($db);
423+
} else {
424+
$back_button .= 'tbl_export.php?' . PMA_URL_getCommon($db, $table);
425+
}
426+
427+
// Convert the multiple select elements from an array to a string
428+
if ($export_type == 'server' && isset($_REQUEST['db_select'])) {
429+
$_REQUEST['db_select'] = implode(",", $_REQUEST['db_select']);
430+
} elseif ($export_type == 'database'
431+
&& isset($_REQUEST['table_select'])
432+
) {
433+
$_REQUEST['table_select'] = implode(",", $_REQUEST['table_select']);
434+
}
435+
436+
foreach ($_REQUEST as $name => $value) {
437+
$back_button .= '&amp;' . urlencode($name) . '=' . urlencode($value);
438+
}
439+
$back_button .= '&amp;repopulate=1">Back</a> ]</p>';
440+
441+
$html .= $back_button
442+
. '<form name="nofunction">'
443+
. '<textarea name="sqldump" cols="50" rows="30" '
444+
. 'id="textSQLDUMP" wrap="OFF">';
445+
446+
return array($html, $back_button);
447+
}
400448
?>

0 commit comments

Comments
 (0)