/**
 * Function to get html for displaying the schema export
 *
 * @param string $db   database name
 * @param int    $page the page to be exported
 *
 * @return string
 */
function PMA_getHtmlForSchemaExport($db, $page)
{
    /* Scan for schema plugins */
    /* @var $export_list SchemaPlugin[] */
    $export_list = PMA_getPlugins("schema", 'libraries/plugins/schema/', null);
    /* Fail if we didn't find any schema plugin */
    if (empty($export_list)) {
        return Message::error(__('Could not load schema plugins, please check your installation!'))->getDisplay();
    }
    return PMA\libraries\Template::get('database/designer/schema_export')->render(array('db' => $db, 'page' => $page, 'export_list' => $export_list));
}
require_once './libraries/file_listing.php';
require_once './libraries/plugin_interface.lib.php';
function PMA_exportCheckboxCheck($str)
{
    if (isset($GLOBALS['cfg']['Export'][$str]) && $GLOBALS['cfg']['Export'][$str]) {
        echo ' checked="checked"';
    }
}
function PMA_exportIsActive($what, $val)
{
    if (isset($GLOBALS['cfg']['Export'][$what]) && $GLOBALS['cfg']['Export'][$what] == $val) {
        echo ' checked="checked"';
    }
}
/* Scan for plugins */
$export_list = PMA_getPlugins('./libraries/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('strCanNotLoadExportPlugins')->display();
    require './libraries/footer.inc.php';
}
?>

<form method="post" action="export.php" name="dump">

<?php 
if ($export_type == 'server') {
    echo PMA_generate_common_hidden_inputs('', '', 1);
} elseif ($export_type == 'database') {
    echo PMA_generate_common_hidden_inputs($db, '', 1);
} else {
/**
 * Gets HTML to display import dialogs
 *
 * @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
 *
 * @return string $html
 */
function PMA_getImportDisplay($import_type, $db, $table, $max_upload_size)
{
    global $SESSION_KEY;
    include_once './libraries/file_listing.lib.php';
    include_once './libraries/plugin_interface.lib.php';
    include_once './libraries/display_import_ajax.lib.php';
    list($SESSION_KEY, $upload_id, $plugins) = PMA_uploadProgressSetup();
    /* Scan for plugins */
    /* @var $import_list ImportPlugin[] */
    $import_list = PMA_getPlugins("import", 'libraries/plugins/import/', $import_type);
    /* Fail if we didn't find any plugin */
    if (empty($import_list)) {
        Message::error(__('Could not load import plugins, please check your installation!'))->display();
        exit;
    }
    if (PMA_isValid($_REQUEST['offset'], 'numeric')) {
        $offset = $_REQUEST['offset'];
    }
    if (isset($_REQUEST['timeout_passed'])) {
        $timeout_passed = $_REQUEST['timeout_passed'];
    }
    $local_import_file = '';
    if (isset($_REQUEST['local_import_file'])) {
        $local_import_file = $_REQUEST['local_import_file'];
    }
    $timeout_passed_str = isset($timeout_passed) ? $timeout_passed : null;
    $offset_str = isset($offset) ? $offset : null;
    return PMA_getHtmlForImport($upload_id, $import_type, $db, $table, $max_upload_size, $import_list, $timeout_passed_str, $offset_str, $local_import_file);
}
Example #4
0
/**
 * Function to get html for displaying the schema export
 *
 * @param string $db   database name
 * @param int    $page the page to be exported
 *
 * @return string
 */
function PMA_getHtmlForSchemaExport($db, $page)
{
    /* Scan for schema plugins */
    $export_list = PMA_getPlugins("schema", 'libraries/plugins/schema/', null);
    /* Fail if we didn't find any schema plugin */
    if (empty($export_list)) {
        return PMA_Message::error(__('Could not load schema plugins, please check your installation!'))->getDisplay();
    }
    $htmlString = '<form method="post" action="schema_export.php"' . ' class="disableAjax" id="id_export_pages">';
    $htmlString .= '<fieldset>';
    $htmlString .= PMA_URL_getHiddenInputs($db);
    $htmlString .= '<label>' . __('Select Export Relational Type') . '</label><br />';
    $htmlString .= PMA_pluginGetChoice('Schema', 'export_type', $export_list, 'format');
    $htmlString .= '<input type="hidden" name="page_number"' . ' value="' . htmlspecialchars($page) . '" />';
    $htmlString .= PMA_pluginGetOptions('Schema', $export_list);
    $htmlString .= '</fieldset>';
    $htmlString .= '</form>';
    return $htmlString;
}
Example #5
0
/**
 * 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;
}
/**
 *
 * @package PhpMyAdmin
 */
if (!defined('PHPMYADMIN')) {
    exit;
}
/**
 *
 */
require_once './libraries/file_listing.php';
require_once './libraries/plugin_interface.lib.php';
require_once './libraries/display_import_ajax.lib.php';
$common_functions = PMA_CommonFunctions::getInstance();
/* Scan for plugins */
$import_list = PMA_getPlugins("import", 'libraries/plugins/import/', $import_type);
/* Fail if we didn't find any plugin */
if (empty($import_list)) {
    PMA_Message::error(__('Could not load import plugins, please check your installation!'))->display();
    exit;
}
?>

<iframe id="import_upload_iframe" name="import_upload_iframe" width="1" height="1" style="display: none;"></iframe>
<div id="import_form_status" style="display: none;"></div>
<div id="importmain">
    <img src="<?php 
echo $GLOBALS['pmaThemeImage'];
?>
ajax_clock_small.gif" width="16" height="16" alt="ajax clock" style="display: none;" />
    <script type="text/javascript">
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 *
 * @package PhpMyAdmin
 */
if (!defined('PHPMYADMIN')) {
    exit;
}
/**
 *
 */
require_once './libraries/file_listing.php';
require_once './libraries/plugin_interface.lib.php';
require_once './libraries/display_import_ajax.lib.php';
/* Scan for plugins */
$import_list = PMA_getPlugins('./libraries/import/', $import_type);
/* Fail if we didn't find any plugin */
if (empty($import_list)) {
    PMA_Message::error(__('Could not load import plugins, please check your installation!'))->display();
    include './libraries/footer.inc.php';
}
?>

<iframe id="import_upload_iframe" name="import_upload_iframe" width="1" height="1" style="display: none;"></iframe>
<div id="import_form_status" style="display: none;"></div>
<div id="importmain">
    <img src="<?php 
echo $GLOBALS['pmaThemeImage'];
?>
ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
    <script type="text/javascript">
 /**
  * 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);
 }