/** * Returns the html for Database List * * @param Array $databases GBI return databases * @param int $databases_count database count * @param int $pos display pos * @param Array $dbstats database status * @param string $sort_by sort by string * @param string $sort_order sort order string * @param bool $is_superuser User status * @param Array $cfg configuration * @param string $replication_types replication types * @param string $replication_info replication info * @param string $url_query url query * * @return string */ function PMA_getHtmlForDatabase($databases, $databases_count, $pos, $dbstats, $sort_by, $sort_order, $is_superuser, $cfg, $replication_types, $replication_info, $url_query) { $html = '<div id="tableslistcontainer">'; reset($databases); $first_database = current($databases); // table col order $column_order = PMA_getColumnOrder(); $_url_params = array('pos' => $pos, 'dbstats' => $dbstats, 'sort_by' => $sort_by, 'sort_order' => $sort_order); $html .= PMA_Util::getListNavigator($databases_count, $pos, $_url_params, 'server_databases.php', 'frame_content', $GLOBALS['cfg']['MaxDbList']); $_url_params['pos'] = $pos; $html .= '<form class="ajax" action="server_databases.php" '; $html .= 'method="post" name="dbStatsForm" id="dbStatsForm">' . "\n"; $html .= PMA_URL_getHiddenInputs($_url_params); $_url_params['sort_by'] = 'SCHEMA_NAME'; $_url_params['sort_order'] = $sort_by == 'SCHEMA_NAME' && $sort_order == 'asc' ? 'desc' : 'asc'; $html .= '<table id="tabledatabases" class="data">' . "\n" . '<thead>' . "\n" . '<tr>' . "\n"; $html .= PMA_getHtmlForColumnOrderWithSort($is_superuser, $cfg['AllowUserDropDatabase'], $_url_params, $sort_by, $sort_order, $column_order, $first_database); $html .= PMA_getHtmlForReplicationType($is_superuser, $replication_types, $cfg['ActionLinksMode']); $html .= '</tr>' . "\n" . '</thead>' . "\n"; list($output, $column_order) = PMA_getHtmlAndColumnOrderForDatabaseList($databases, $is_superuser, $url_query, $column_order, $replication_types, $replication_info); $html .= $output; unset($output); $html .= PMA_getHtmlForTableFooter($cfg['AllowUserDropDatabase'], $is_superuser, $databases_count, $column_order, $replication_types, $first_database); $html .= '</table>' . "\n"; $html .= PMA_getHtmlForTableFooterButtons($cfg['AllowUserDropDatabase'], $is_superuser, $sort_by, $sort_order, $dbstats); if (empty($dbstats)) { //we should put notice above database list $html = PMA_getHtmlForNoticeEnableStatistics($url_query, $html); } $html .= '</form>'; $html .= '</div>'; return $html; }
/** * Test for PMA_getColumnOrder */ public function testPMA_getColumnOrder(){ if (! function_exists('PMA_getServerCollation')) { function PMA_getServerCollation() { return 'footer'; } } $this->assertEquals( PMA_getColumnOrder(), array( 'DEFAULT_COLLATION_NAME' => array( 'disp_name' => __('Collation'), 'description_function' => 'PMA_getCollationDescr', 'format' => 'string', 'footer' => 'footer' ), 'SCHEMA_TABLES' => array( 'disp_name' => __('Tables'), 'format' => 'number', 'footer' => 0 ), 'SCHEMA_TABLE_ROWS' => array( 'disp_name' => __('Rows'), 'format' => 'number', 'footer' => 0 ), 'SCHEMA_DATA_LENGTH' => array( 'disp_name' => __('Data'), 'format' => 'byte', 'footer' => 0 ), 'SCHEMA_INDEX_LENGTH' => array( 'disp_name' => __('Indexes'), 'format' => 'byte', 'footer' => 0 ), 'SCHEMA_LENGTH' => array( 'disp_name' => __('Total'), 'format' => 'byte', 'footer' => 0 ), 'SCHEMA_DATA_FREE' => array( 'disp_name' => __('Overhead'), 'format' => 'byte', 'footer' => 0 ) ) ); }
/** * If in an Ajax request, build the output and send it */ if ($GLOBALS['is_ajax_request'] == true) { //Construct the html for the new database, so that it can be appended to // the list of databases on server_databases.php /** * Build the array to be passed to {@link PMA_URL_getCommon} * to generate the links * * @global array $GLOBALS['db_url_params'] * @name $db_url_params */ $db_url_params['db'] = $_POST['new_db']; $is_superuser = $GLOBALS['dbi']->isSuperuser(); $column_order = PMA_getColumnOrder(); $url_query = PMA_URL_getCommon(array('db' => $_POST['new_db'])); /** * String that will contain the output HTML * @name $new_db_string */ $new_db_string = '<tr>'; if (empty($db_collation_for_ajax)) { $db_collation_for_ajax = PMA_getServerCollation(); } // $dbstats comes from the create table dialog if (!empty($dbstats)) { $current = array('SCHEMA_NAME' => $_POST['new_db'], 'DEFAULT_COLLATION_NAME' => $db_collation_for_ajax, 'SCHEMA_TABLES' => '0', 'SCHEMA_TABLE_ROWS' => '0', 'SCHEMA_DATA_LENGTH' => '0', 'SCHEMA_MAX_DATA_LENGTH' => '0', 'SCHEMA_INDEX_LENGTH' => '0', 'SCHEMA_LENGTH' => '0', 'SCHEMA_DATA_FREE' => '0'); } else { $current = array('SCHEMA_NAME' => $_POST['new_db'], 'DEFAULT_COLLATION_NAME' => $db_collation_for_ajax); }
/** * Data for testBuildHtmlForDb * * @return array data for testBuildHtmlForDb test case */ public function providerForTestBuildHtmlForDb() { return array(array(array('SCHEMA_NAME' => 'pma'), true, 'target=main.php', PMA_getColumnOrder(), array('SCHEMA_NAME' => 'pma'), array('pma' => array('status' => 'true', 'Ignore_DB' => array('pma' => 'pma'))), array('<td class="tool">', '<input type="checkbox" name="selected_dbs[]" class="checkall" title="pma" value="pma"')), array(array('SCHEMA_NAME' => 'INFORMATION_SCHEMA'), true, 'target=main.php', PMA_getColumnOrder(), array('SCHEMA_NAME' => 'INFORMATION_SCHEMA'), array('INFORMATION_SCHEMA' => array('status' => 'false', 'Ignore_DB' => array('INFORMATION_SCHEMA' => 'INFORMATION_SCHEMA'))), array('<input type="checkbox" name="selected_dbs[]" class="checkall" title="INFORMATION_SCHEMA" value="INFORMATION_SCHEMA" disabled="disabled"'))); }
/** * Data for testBuildHtmlForDb * * @return array data for testBuildHtmlForDb test case */ public function providerForTestBuildHtmlForDb() { return array(array(array('SCHEMA_NAME' => 'pma'), true, 'target=main.php', PMA_getColumnOrder(), array('SCHEMA_NAME' => 'pma'), array('pma' => array('status' => 'true', 'Ignore_DB' => array('pma' => 'pma'))), array(array('tag' => 'td', 'attributes' => array('class' => 'tool'), 'child' => array('tag' => 'input', 'attributes' => array('type' => 'checkbox', 'name' => 'selected_dbs[]', 'value' => 'pma'))), array('tag' => 'td', 'attributes' => array('class' => 'name'), 'child' => array('tag' => 'a', 'attributes' => array('title' => 'Jump to database'), 'content' => 'pma')), array('tag' => 'td', 'attributes' => array('class' => 'tool'), 'descendant' => array('tag' => 'img', 'attributes' => array('title' => 'Not replicated'))), array('tag' => 'td', 'attributes' => array('class' => 'tool'), 'child' => array('tag' => 'a', 'child' => array('tag' => 'span', 'child' => array('tag' => 'img', 'attributes' => array('title' => 'Check Privileges'))))))), array(array('SCHEMA_NAME' => 'sakila'), true, 'target=main.php', PMA_getColumnOrder(), array('SCHEMA_NAME' => 'sakila'), array('sakila' => array('status' => 'true', 'Ignore_DB' => array('pma' => 'pma'), 'Do_DB' => array('sakila' => 'sakila'))), array(array('tag' => 'td', 'attributes' => array('class' => 'tool'), 'child' => array('tag' => 'input', 'attributes' => array('type' => 'checkbox', 'name' => 'selected_dbs[]', 'value' => 'sakila'))), array('tag' => 'td', 'attributes' => array('class' => 'tool'), 'descendant' => array('tag' => 'img', 'attributes' => array('title' => 'Replicated'))))), array(array('SCHEMA_NAME' => 'INFORMATION_SCHEMA'), true, 'target=main.php', PMA_getColumnOrder(), array('SCHEMA_NAME' => 'INFORMATION_SCHEMA'), array('INFORMATION_SCHEMA' => array('status' => 'false', 'Ignore_DB' => array('INFORMATION_SCHEMA' => 'INFORMATION_SCHEMA'))), array(array('tag' => 'td', 'attributes' => array('class' => 'tool'), 'child' => array('tag' => 'input', 'attributes' => array('type' => 'checkbox', 'name' => 'selected_dbs[]', 'value' => 'INFORMATION_SCHEMA', 'disabled' => 'disabled')))))); }
/** * Data for testBuildHtmlForDb * * @return array data for testBuildHtmlForDb test case */ public function providerForTestBuildHtmlForDb() { return array( array( array('SCHEMA_NAME' => 'pma'), true, '', 'target=main.php', PMA_getColumnOrder(), array( 'SCHEMA_NAME' => 'pma', ), array( 'pma' => array( 'status' => 'true', 'Ignore_DB' => array( 'pma' => 'pma' ), ) ), '<td class="tool"><input type="checkbox" name="selected_dbs[]" class="checkall" title="pma" value="pma" /></td><td class="name"> <a onclick="if (window.parent.openDb && window.parent.openDb(\'pma\')) return false;" href="index.php?target=main.php&db=pma" title="Jump to database" target="_parent"> pma</a></td><td class="tool" style="text-align: center;"><span class="nowrap"><img src="theme/s_cancel.png" title="Not replicated" alt="Not replicated" /></span></td><td class="tool"><a onclick="if (window.parent.setDb) window.parent.setDb(\'`pma`\');" href="server_privileges.php?target=main.php&checkprivs=pma" title="Check privileges for database "pma"."> <span class="nowrap"><img src="theme/s_rights.png" title="Check Privileges" alt="Check Privileges" /></span></a></td>' ) ); }