/** * Gets HTML to display export dialogs * * @param String $export_type export type: server|database|table * @param String $db selected DB * @param String $table selected table * @param String $sql_query SQL query * @param Int $num_tables number of tables * @param Int $unlim_num_rows unlimited number of rows * @param String $multi_values selector options * * @return string $html */ function PMA_getExportDisplay($export_type, $db, $table, $sql_query, $num_tables, $unlim_num_rows, $multi_values) { $cfgRelation = PMA_getRelationsParam(); if (isset($_REQUEST['single_table'])) { $GLOBALS['single_table'] = $_REQUEST['single_table']; } include_once './libraries/file_listing.lib.php'; include_once './libraries/plugin_interface.lib.php'; include_once './libraries/display_export.lib.php'; /* Scan for plugins */ /* @var $export_list ExportPlugin[] */ $export_list = PMA_getPlugins("export", 'libraries/plugins/export/', array('export_type' => $export_type, 'single_table' => isset($GLOBALS['single_table']))); /* Fail if we didn't find any plugin */ if (empty($export_list)) { Message::error(__('Could not load export plugins, please check your installation!'))->display(); exit; } $html = PMA_getHtmlForExportOptionHeader($export_type, $db, $table); if ($cfgRelation['exporttemplateswork']) { $html .= PMA_getHtmlForExportTemplateLoading($export_type); } $html .= '<form method="post" action="export.php" ' . ' name="dump" class="disableAjax">'; //output Hidden Inputs $single_table_str = isset($GLOBALS['single_table']) ? $GLOBALS['single_table'] : ''; $html .= PMA_getHtmlForHiddenInput($export_type, $db, $table, $single_table_str, $sql_query); //output Export Options $html .= PMA_getHtmlForExportOptions($export_type, $db, $table, $multi_values, $num_tables, $export_list, $unlim_num_rows); $html .= '</form>'; return $html; }
exit; } // Get relations & co. status $cfgRelation = PMA_getRelationsParam(); if (isset($_REQUEST['single_table'])) { $GLOBALS['single_table'] = $_REQUEST['single_table']; } require_once './libraries/file_listing.lib.php'; require_once './libraries/plugin_interface.lib.php'; require_once './libraries/display_export.lib.php'; /* Scan for plugins */ /* @var $export_list ExportPlugin[] */ $export_list = PMA_getPlugins("export", 'libraries/plugins/export/', array('export_type' => $export_type, 'single_table' => isset($single_table))); /* Fail if we didn't find any plugin */ if (empty($export_list)) { PMA_Message::error(__('Could not load export plugins, please check your installation!'))->display(); exit; } $html = '<form method="post" action="export.php" ' . ' name="dump" class="disableAjax">'; //output Hidden Inputs $single_table_str = isset($single_table) ? $single_table : ''; $sql_query_str = isset($sql_query) ? $sql_query : ''; $html .= PMA_getHtmlForHiddenInput($export_type, $db, $table, $single_table_str, $sql_query_str); //output Export Options $num_tables_str = isset($num_tables) ? $num_tables : ''; $unlim_num_rows_str = isset($unlim_num_rows) ? $unlim_num_rows : ''; $multi_values_str = isset($multi_values) ? $multi_values : ''; $html .= PMA_getHtmlForExportOptions($export_type, $db, $table, $multi_values_str, $num_tables_str, $export_list, $unlim_num_rows_str); $html .= '</form>'; $response = PMA_Response::getInstance(); $response->addHTML($html);
/** * Prints Html For Display Import * * @param int $upload_id The selected upload id * @param String $import_type Import type: server, database, table * @param String $db Selected DB * @param String $table Selected Table * @param int $max_upload_size Max upload size * @param Array $import_list Import list * @param String $timeout_passed Timeout passed * @param String $offset Timeout offset * * @return string */ function PMA_getHtmlForImport($upload_id, $import_type, $db, $table, $max_upload_size, $import_list, $timeout_passed, $offset) { global $SESSION_KEY; $html = ''; $html .= '<iframe id="import_upload_iframe" name="import_upload_iframe" ' . 'width="1" height="1" style="display: none;"></iframe>'; $html .= '<div id="import_form_status" style="display: none;"></div>'; $html .= '<div id="importmain">'; $html .= ' <img src="' . $GLOBALS['pmaThemeImage'] . 'ajax_clock_small.gif" ' . 'width="16" height="16" alt="ajax clock" style="display: none;" />'; $html .= PMA_getHtmlForImportJS($upload_id); $html .= ' <form id="import_file_form" action="import.php" method="post" ' . 'enctype="multipart/form-data"'; $html .= ' name="import"'; if ($_SESSION[$SESSION_KEY]["handler"] != "UploadNoplugin") { $html .= ' target="import_upload_iframe"'; } $html .= ' class="ajax"'; $html .= '>'; $html .= ' <input type="hidden" name="'; $html .= $_SESSION[$SESSION_KEY]['handler']::getIdKey(); $html .= '" value="' . $upload_id . '" />'; $html .= PMA_getHtmlForHiddenInputs($import_type, $db, $table); $html .= PMA_getHtmlForExportOptions($import_type, $db, $table); $html .= PMA_getHtmlForImportOptionsFile($max_upload_size, $import_list); $html .= PMA_getHtmlForImportOptionsPartialImport($timeout_passed, $offset); $html .= PMA_getHtmlForImportOptionsFormat($import_list); $html .= PMA_getHtmlForImportOptionsSubmit(); $html .= '</form>'; $html .= '</div>'; return $html; }
/** * Test for PMA_getHtmlForExportOptions * * @return void */ public function testPMAGetHtmlForExportOptions() { global $cfg; $cfg['Export']['method'] = "XML"; $cfg['SaveDir'] = "/tmp"; $export_type = "server"; $db = "PMA"; $table = "PMA_test"; $multi_values_str = "multi_values_str"; $num_tables_str = "10"; $unlim_num_rows_str = "unlim_num_rows_str"; $single_table = "single_table"; PMA_Table::$cache[$db][$table]['ENGINE'] = "MERGE"; $columns_info = array('test_column1' => array('COLUMN_NAME' => 'test_column1'), 'test_column2' => array('COLUMN_NAME' => 'test_column2')); $dbi = $this->getMockBuilder('PMA_DatabaseInterface')->disableOriginalConstructor()->getMock(); $dbi->expects($this->any())->method('getColumnsFull')->will($this->returnValue($columns_info)); $GLOBALS['dbi'] = $dbi; /* Scan for plugins */ $export_list = PMA_getPlugins("export", 'libraries/plugins/export/', array('export_type' => $export_type, 'single_table' => isset($single_table))); //Call the test function $html = PMA_getHtmlForExportOptions($export_type, $db, $table, $multi_values_str, $num_tables_str, $export_list, $unlim_num_rows_str); //validate 1: PMA_getHtmlForExportOptionHeader $this->assertContains('<div class="exportoptions" id="header">', $html); $this->assertContains(__('Exporting databases from the current server'), $html); //validate 2: PMA_getHtmlForExportOptionsMethod $this->assertContains($cfg['Export']['method'], $html); $this->assertContains('<div class="exportoptions" id="quick_or_custom">', $html); $this->assertContains(__('Export Method:'), $html); $this->assertContains(__('Custom - display all possible options'), $html); //validate 3: PMA_getHtmlForExportOptionsSelection $this->assertContains('<div class="exportoptions" id="databases_and_tables">', $html); $this->assertContains('<h3>' . __('Database(s):') . '</h3>', $html); $this->assertContains($multi_values_str, $html); //validate 4: PMA_getHtmlForExportOptionsQuickExport $this->assertContains('<input type="checkbox" name="onserver" value="saveit" ', $html); $dir = htmlspecialchars(PMA_Util::userDir($cfg['SaveDir'])); $this->assertContains('Save on server in the directory <b>' . $dir . '</b>', $html); //validate 5: PMA_getHtmlForAliasModalDialog $this->assertContains('<div id="alias_modal" class="hide" title="' . 'Rename exported databases/tables/columns">', $html); $this->assertContains('Select database', $html); $this->assertContains('Select table', $html); $this->assertContains('New database name', $html); $this->assertContains('New table name', $html); $this->assertContains('test_column', $html); //validate 6: PMA_getHtmlForExportOptionsOutput $this->assertContains('<div class="exportoptions" id="output">', $html); $this->assertContains('user value for test', $html); //validate 7: PMA_getHtmlForExportOptionsFormat $this->assertContains('<div class="exportoptions" id="format">', $html); $this->assertContains('<h3>' . __('Format:') . '</h3>', $html); }
/** * Test for PMA_getHtmlForExportOptions * * @return vgetUserValue */ public function testPMAGetHtmlForExportOptions() { global $cfg; $cfg['Export']['method'] = "XML"; $cfg['SaveDir'] = "/tmp"; $export_type = "server"; $db = "PMA"; $table = "PMA_test"; $multi_values_str = "multi_values_str"; $num_tables_str = "10"; $export_list = null; $unlim_num_rows_str = "unlim_num_rows_str"; $single_table = "single_table"; PMA_Table::$cache[$db][$table]['ENGINE'] = "MERGE"; /* Scan for plugins */ $export_list = PMA_getPlugins("export", 'libraries/plugins/export/', array('export_type' => $export_type, 'single_table' => isset($single_table))); //Call the test function $html = PMA_getHtmlForExportOptions($export_type, $db, $table, $multi_values_str, $num_tables_str, $export_list, $unlim_num_rows_str); //validate 1: PMA_getHtmlForExportOptionHeader $this->assertContains('<div class="exportoptions" id="header">', $html); $this->assertContains(__('Exporting databases from the current server'), $html); //validate 2: PMA_getHtmlForExportOptionsMethod $this->assertContains($cfg['Export']['method'], $html); $this->assertContains('<div class="exportoptions" id="quick_or_custom">', $html); $this->assertContains(__('Export Method:'), $html); $this->assertContains(__('Custom - display all possible options'), $html); //validate 3: PMA_getHtmlForExportOptionsSelection $this->assertContains('<div class="exportoptions" id="databases_and_tables">', $html); $this->assertContains('<h3>' . __('Database(s):') . '</h3>', $html); $this->assertContains($multi_values_str, $html); //validate 4: PMA_getHtmlForExportOptionsQuickExport $this->assertContains('<input type="checkbox" name="onserver" value="saveit" ', $html); $dir = htmlspecialchars(PMA_Util::userDir($cfg['SaveDir'])); $this->assertContains('Save on server in the directory <b>' . $dir . '</b>', $html); //validate 5: PMA_getHtmlForExportOptionsOutput $this->assertContains('<div class="exportoptions" id="output">', $html); $this->assertContains('user value for test', $html); //validate 6: PMA_getHtmlForExportOptionsFormat $this->assertContains('<div class="exportoptions" id="format">', $html); $this->assertContains('<h3>' . __('Format:') . '</h3>', $html); }