本文整理汇总了PHP中PMA_Util::formatNumber方法的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Util::formatNumber方法的具体用法?PHP PMA_Util::formatNumber怎么用?PHP PMA_Util::formatNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMA_Util
的用法示例。
在下文中一共展示了PMA_Util::formatNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_buildHtmlForDb
/**
* Builds the HTML td elements for one database to display in the list
* of databases from server_databases.php (which can be modified by
* db_create.php)
*
* @param array $current current database
* @param boolean $is_superuser user status
* @param string $url_query url query
* @param array $column_order column order
* @param array $replication_types replication types
* @param array $replication_info replication info
*
* @return array $column_order, $out
*/
function PMA_buildHtmlForDb($current, $is_superuser, $url_query, $column_order, $replication_types, $replication_info)
{
$out = '';
if ($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) {
$out .= '<td class="tool">';
$out .= '<input type="checkbox" name="selected_dbs[]" class="checkall" ' . 'title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ' . 'value="' . htmlspecialchars($current['SCHEMA_NAME']) . '"';
if ($GLOBALS['dbi']->isSystemSchema($current['SCHEMA_NAME'], true)) {
$out .= ' disabled="disabled"';
}
$out .= ' /></td>';
}
$out .= '<td class="name">' . '<a href="' . PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . $url_query . '&db=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf(__('Jump to database'), htmlspecialchars($current['SCHEMA_NAME'])) . '">' . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . '</a>' . '</td>';
foreach ($column_order as $stat_name => $stat) {
if (array_key_exists($stat_name, $current)) {
$unit = '';
if (is_numeric($stat['footer'])) {
$column_order[$stat_name]['footer'] += $current[$stat_name];
}
if ($stat['format'] === 'byte') {
list($value, $unit) = PMA_Util::formatByteDown($current[$stat_name], 3, 1);
} elseif ($stat['format'] === 'number') {
$value = PMA_Util::formatNumber($current[$stat_name], 0);
} else {
$value = htmlentities($current[$stat_name], 0);
}
$out .= '<td class="value">';
if (isset($stat['description_function'])) {
$out .= '<dfn title="' . $stat['description_function']($current[$stat_name]) . '">';
}
$out .= $value;
if (isset($stat['description_function'])) {
$out .= '</dfn>';
}
$out .= '</td>';
if ($stat['format'] === 'byte') {
$out .= '<td class="unit">' . $unit . '</td>';
}
}
}
foreach ($replication_types as $type) {
if ($replication_info[$type]['status']) {
$out .= '<td class="tool" style="text-align: center;">';
$key = array_search($current["SCHEMA_NAME"], $replication_info[$type]['Ignore_DB']);
if (mb_strlen($key) > 0) {
$out .= PMA_Util::getIcon('s_cancel.png', __('Not replicated'));
} else {
$key = array_search($current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']);
if (mb_strlen($key) > 0 || isset($replication_info[$type]['Do_DB'][0]) && $replication_info[$type]['Do_DB'][0] == "" && count($replication_info[$type]['Do_DB']) == 1) {
// if ($key != null) did not work for index "0"
$out .= PMA_Util::getIcon('s_success.png', __('Replicated'));
}
}
$out .= '</td>';
}
}
if ($is_superuser && !PMA_DRIZZLE) {
$out .= '<td class="tool">' . '<a onclick="' . 'PMA_commonActions.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');' . '" href="server_privileges.php' . $url_query . '&db=' . urlencode($current['SCHEMA_NAME']) . '&checkprivsdb=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf(__('Check privileges for database "%s".'), htmlspecialchars($current['SCHEMA_NAME'])) . '">' . ' ' . PMA_Util::getIcon('s_rights.png', __('Check Privileges')) . '</a></td>';
}
return array($column_order, $out);
}
示例2: testFormatNumber
/**
* format number test, globals are defined
* @dataProvider formatNumberDataProvider
*/
public function testFormatNumber($a, $b, $c, $d)
{
$this->assertEquals(
$d,
(string) PMA_Util::formatNumber(
$a, $b, $c, false
)
);
}
示例3: PMA_formatVariable
/**
* Format Variable
*
* @param string $name variable name
* @param number $value variable value
* @param array $variable_doc_links documentation links
*
* @return string formatted string
*/
function PMA_formatVariable($name, $value, $variable_doc_links)
{
if (is_numeric($value)) {
if (isset($variable_doc_links[$name][3]) && $variable_doc_links[$name][3] == 'byte') {
return '<abbr title="' . PMA_Util::formatNumber($value, 0) . '">' . implode(' ', PMA_Util::formatByteDown($value, 3, 3)) . '</abbr>';
} else {
return PMA_Util::formatNumber($value, 0);
}
}
return htmlspecialchars($value);
}
示例4: getPageBufferpool
/**
* returns html tables with stats over inno db buffer pool
*
* @return string html table with stats
*/
public function getPageBufferpool()
{
// The following query is only possible because we know
// that we are on MySQL 5 here (checked above)!
// side note: I love MySQL 5 for this. :-)
$sql = '
SHOW STATUS
WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\'
OR Variable_name = \'Innodb_page_size\';';
$status = $GLOBALS['dbi']->fetchResult($sql, 0, 1);
$output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n" . ' <caption class="tblHeaders">' . "\n" . ' ' . __('Buffer Pool Usage') . "\n" . ' </caption>' . "\n" . ' <tfoot>' . "\n" . ' <tr>' . "\n" . ' <th colspan="2">' . "\n" . ' ' . __('Total') . "\n" . ' : ' . PMA_Util::formatNumber($status['Innodb_buffer_pool_pages_total'], 0) . ' ' . __('pages') . ' / ' . join(' ', PMA_Util::formatByteDown($status['Innodb_buffer_pool_pages_total'] * $status['Innodb_page_size'])) . "\n" . ' </th>' . "\n" . ' </tr>' . "\n" . ' </tfoot>' . "\n" . ' <tbody>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . __('Free pages') . '</th>' . "\n" . ' <td class="value">' . PMA_Util::formatNumber($status['Innodb_buffer_pool_pages_free'], 0) . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . __('Dirty pages') . '</th>' . "\n" . ' <td class="value">' . PMA_Util::formatNumber($status['Innodb_buffer_pool_pages_dirty'], 0) . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . __('Pages containing data') . '</th>' . "\n" . ' <td class="value">' . PMA_Util::formatNumber($status['Innodb_buffer_pool_pages_data'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . __('Pages to be flushed') . '</th>' . "\n" . ' <td class="value">' . PMA_Util::formatNumber($status['Innodb_buffer_pool_pages_flushed'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . __('Busy pages') . '</th>' . "\n" . ' <td class="value">' . PMA_Util::formatNumber($status['Innodb_buffer_pool_pages_misc'], 0) . "\n" . '</td>' . "\n" . ' </tr>';
// not present at least since MySQL 5.1.40
if (isset($status['Innodb_buffer_pool_pages_latched'])) {
$output .= ' <tr class="even">' . ' <th>' . __('Latched pages') . '</th>' . ' <td class="value">' . PMA_Util::formatNumber($status['Innodb_buffer_pool_pages_latched'], 0) . '</td>' . ' </tr>';
}
$output .= ' </tbody>' . "\n" . '</table>' . "\n\n" . '<table class="data" id="table_innodb_bufferpool_activity">' . "\n" . ' <caption class="tblHeaders">' . "\n" . ' ' . __('Buffer Pool Activity') . "\n" . ' </caption>' . "\n" . ' <tbody>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . __('Read requests') . '</th>' . "\n" . ' <td class="value">' . PMA_Util::formatNumber($status['Innodb_buffer_pool_read_requests'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . __('Write requests') . '</th>' . "\n" . ' <td class="value">' . PMA_Util::formatNumber($status['Innodb_buffer_pool_write_requests'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . __('Read misses') . '</th>' . "\n" . ' <td class="value">' . PMA_Util::formatNumber($status['Innodb_buffer_pool_reads'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . __('Write waits') . '</th>' . "\n" . ' <td class="value">' . PMA_Util::formatNumber($status['Innodb_buffer_pool_wait_free'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . __('Read misses in %') . '</th>' . "\n" . ' <td class="value">' . ($status['Innodb_buffer_pool_read_requests'] == 0 ? '---' : htmlspecialchars(PMA_Util::formatNumber($status['Innodb_buffer_pool_reads'] * 100 / $status['Innodb_buffer_pool_read_requests'], 3, 2)) . ' %') . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . __('Write waits in %') . '</th>' . "\n" . ' <td class="value">' . ($status['Innodb_buffer_pool_write_requests'] == 0 ? '---' : htmlspecialchars(PMA_Util::formatNumber($status['Innodb_buffer_pool_wait_free'] * 100 / $status['Innodb_buffer_pool_write_requests'], 3, 2)) . ' %') . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' </tbody>' . "\n" . '</table>' . "\n";
return $output;
}
示例5: PMA_generate_common_url
* DB search optimisation
*
* @package PhpMyAdmin
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/Util.class.php';
$db = $_GET['db'];
$table_term = $_GET['table'];
$common_url_query = PMA_generate_common_url($GLOBALS['db']);
$tables_full = PMA_Util::getTableList($db);
$tables_response = array();
foreach ($tables_full as $key => $table) {
if (strpos($key, $table_term) !== false) {
$link = '<li class="ajax_table"><a class="tableicon" title="' . htmlspecialchars($link_title) . ': ' . htmlspecialchars($table['Comment']) . ' (' . PMA_Util::formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"' . ' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' . ' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table['Name']) . '&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '" >';
$attr = array('id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name']));
if (PMA_Table::isView($table_db, $table['Name'])) {
$link .= PMA_Util::getImage('s_views.png', htmlspecialchars($link_title), $attr);
} else {
$link .= PMA_Util::getImage('b_browse.png', htmlspecialchars($link_title), $attr);
}
$link .= '</a>';
// link for the table name itself
$href = $GLOBALS['cfg']['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table['Name']) . '&pos=0';
$link .= '<a href="' . $href . '" title="' . htmlspecialchars(PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment'] . ' (' . PMA_Util::formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')') . '" id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">' . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>';
$link .= '</li>' . "\n";
$table['line'] = $link;
$tables_response[] = $table;
}
}
$response = PMA_Response::getInstance();
$response->addJSON('tables', $tables_response);
示例6: __
}
if (isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
echo "\n";
echo '<tr>';
echo '<td>' . __('Row size') . ' ø</td>';
echo '<td class="right">';
echo $avg_size . ' ' . $avg_unit;
echo '</td>';
echo '</tr>';
}
if (isset($showtable['Auto_increment'])) {
echo "\n";
echo '<tr>';
echo '<td>' . __('Next autoindex') . ' </td>';
echo '<td class="right">';
echo PMA_Util::formatNumber($showtable['Auto_increment'], 0);
echo '</td>';
echo '</tr>';
}
if (isset($showtable['Create_time'])) {
echo "\n";
echo '<tr>';
echo '<td>' . __('Creation') . '</td>';
echo '<td class="right">';
echo PMA_Util::localisedDate(strtotime($showtable['Create_time']));
echo '</td>';
echo '</tr>';
}
if (isset($showtable['Update_time'])) {
echo "\n";
echo '<tr>';
示例7: PMA_getHtmlForServerStatusQueriesDetails
/**
* Returns the html content for the query details
*
* @param PMA_ServerStatusData $ServerStatusData Server status data
*
* @return string
*/
function PMA_getHtmlForServerStatusQueriesDetails($ServerStatusData)
{
$hour_factor = 3600 / $ServerStatusData->status['Uptime'];
$used_queries = $ServerStatusData->used_queries;
$total_queries = array_sum($used_queries);
// reverse sort by value to show most used statements first
arsort($used_queries);
$odd_row = true;
//(- $ServerStatusData->status['Connections']);
$perc_factor = 100 / $total_queries;
$retval = '<table id="serverstatusqueriesdetails" ' . 'class="data sortable noclick">';
$retval .= '<col class="namecol" />';
$retval .= '<col class="valuecol" span="3" />';
$retval .= '<thead>';
$retval .= '<tr><th>' . __('Statements') . '</th>';
$retval .= '<th>';
/* l10n: # = Amount of queries */
$retval .= __('#');
$retval .= '</th>';
$retval .= '<th>ø ' . __('per hour') . '</th>';
$retval .= '<th>%</div></th>';
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$chart_json = array();
$query_sum = array_sum($used_queries);
$other_sum = 0;
foreach ($used_queries as $name => $value) {
$odd_row = !$odd_row;
// For the percentage column, use Questions - Connections, because
// the number of connections is not an item of the Query types
// but is included in Questions. Then the total of the percentages is 100.
$name = str_replace(array('Com_', '_'), array('', ' '), $name);
// Group together values that make out less than 2% into "Other", but only
// if we have more than 6 fractions already
if ($value < $query_sum * 0.02 && count($chart_json) > 6) {
$other_sum += $value;
} else {
$chart_json[$name] = $value;
}
$retval .= '<tr class="';
$retval .= $odd_row ? 'odd' : 'even';
$retval .= '">';
$retval .= '<th class="name">' . htmlspecialchars($name) . '</th>';
$retval .= '<td class="value">';
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 5, 0, true));
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= htmlspecialchars(PMA_Util::formatNumber($value * $hour_factor, 4, 1, true));
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= htmlspecialchars(PMA_Util::formatNumber($value * $perc_factor, 0, 2));
$retval .= '</td>';
$retval .= '</tr>';
}
$retval .= '</tbody>';
$retval .= '</table>';
$retval .= '<div id="serverstatusquerieschart"></div>';
$retval .= '<div id="serverstatusquerieschart_data" style="display:none;">';
if ($other_sum > 0) {
$chart_json[__('Other')] = $other_sum;
}
$retval .= htmlspecialchars(json_encode($chart_json));
$retval .= '</div>';
return $retval;
}
示例8: PMA_getHtmlForColumnOrder
/**
* Returns the html for Column Order
*
* @param array $column_order Column order
* @param array $first_database The first display database
*
* @return string
*/
function PMA_getHtmlForColumnOrder($column_order, $first_database)
{
$html = "";
foreach ($column_order as $stat_name => $stat) {
if (array_key_exists($stat_name, $first_database)) {
if ($stat['format'] === 'byte') {
list($value, $unit) = PMA_Util::formatByteDown($stat['footer'], 3, 1);
} elseif ($stat['format'] === 'number') {
$value = PMA_Util::formatNumber($stat['footer'], 0);
} else {
$value = htmlentities($stat['footer'], 0);
}
$html .= ' <th class="value">';
if (isset($stat['description_function'])) {
$html .= '<dfn title="' . $stat['description_function']($stat['footer']) . '">';
}
$html .= $value;
if (isset($stat['description_function'])) {
$html .= '</dfn>';
}
$html .= '</th>' . "\n";
if ($stat['format'] === 'byte') {
$html .= ' <th class="unit">' . $unit . '</th>' . "\n";
}
}
}
return $html;
}
示例9: getVariablesTableHtml
/**
* Returns a table with variables information
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function getVariablesTableHtml($ServerStatusData)
{
$retval = '';
$strShowStatus = getStatusVariablesDescriptions();
/**
* define some alerts
*/
// name => max value before alert
$alerts = array('Aborted_clients' => 0, 'Aborted_connects' => 0, 'Binlog_cache_disk_use' => 0, 'Created_tmp_disk_tables' => 0, 'Handler_read_rnd' => 0, 'Handler_read_rnd_next' => 0, 'Innodb_buffer_pool_pages_dirty' => 0, 'Innodb_buffer_pool_reads' => 0, 'Innodb_buffer_pool_wait_free' => 0, 'Innodb_log_waits' => 0, 'Innodb_row_lock_time_avg' => 10, 'Innodb_row_lock_time_max' => 50, 'Innodb_row_lock_waits' => 0, 'Slow_queries' => 0, 'Delayed_errors' => 0, 'Select_full_join' => 0, 'Select_range_check' => 0, 'Sort_merge_passes' => 0, 'Opened_tables' => 0, 'Table_locks_waited' => 0, 'Qcache_lowmem_prunes' => 0, 'Qcache_free_blocks' => isset($ServerStatusData->server_status['Qcache_total_blocks']) ? $ServerStatusData->server_status['Qcache_total_blocks'] / 5 : 0, 'Slow_launch_threads' => 0, 'Key_reads' => isset($ServerStatusData->status['Key_read_requests']) ? 0.01 * $ServerStatusData->status['Key_read_requests'] : 0, 'Key_writes' => isset($ServerStatusData->status['Key_write_requests']) ? 0.9 * $ServerStatusData->status['Key_write_requests'] : 0, 'Key_buffer_fraction' => 0.5, 'Threads_cached' => isset($ServerStatusData->variables['thread_cache_size']) ? 0.95 * $ServerStatusData->variables['thread_cache_size'] : 0);
$retval .= '<table class="data sortable noclick" id="serverstatusvariables">';
$retval .= '<col class="namecol" />';
$retval .= '<col class="valuecol" />';
$retval .= '<col class="descrcol" />';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th>' . __('Variable') . '</th>';
$retval .= '<th>' . __('Value') . '</th>';
$retval .= '<th>' . __('Description') . '</th>';
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$odd_row = false;
foreach ($ServerStatusData->status as $name => $value) {
$odd_row = !$odd_row;
$retval .= '<tr class="' . ($odd_row ? 'odd' : 'even') . (isset($ServerStatusData->allocationMap[$name]) ? ' s_' . $ServerStatusData->allocationMap[$name] : '') . '">';
$retval .= '<th class="name">';
$retval .= htmlspecialchars(str_replace('_', ' ', $name));
/* Fields containing % are calculated, they can not be described in MySQL documentation */
if (strpos($name, '%') === false) {
$retval .= PMA_Util::showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name);
}
$retval .= '</th>';
$retval .= '<td class="value"><span class="formatted">';
if (isset($alerts[$name])) {
if ($value > $alerts[$name]) {
$retval .= '<span class="attention">';
} else {
$retval .= '<span class="allfine">';
}
}
if ('%' === substr($name, -1, 1)) {
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 0, 2)) . ' %';
} elseif (strpos($name, 'Uptime') !== false) {
$retval .= htmlspecialchars(PMA_Util::timespanFormat($value));
} elseif (is_numeric($value) && $value == (int) $value && $value > 1000) {
$retval .= '<abbr title="' . htmlspecialchars(PMA_Util::formatNumber($value, 0)) . '">' . htmlspecialchars(PMA_Util::formatNumber($value, 3, 1));
} elseif (is_numeric($value) && $value == (int) $value) {
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 3, 0));
} elseif (is_numeric($value)) {
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 3, 1));
} else {
$retval .= htmlspecialchars($value);
}
if (isset($alerts[$name])) {
$retval .= '</span>';
}
$retval .= '</span>';
$retval .= '<span style="display:none;" class="original">';
$retval .= $value;
$retval .= '</span>';
$retval .= '</td>';
$retval .= '<td class="descr">';
if (isset($strShowStatus[$name])) {
$retval .= $strShowStatus[$name];
}
if (isset($ServerStatusData->links[$name])) {
foreach ($ServerStatusData->links[$name] as $link_name => $link_url) {
if ('doc' == $link_name) {
$retval .= PMA_Util::showMySQLDocu($link_url, $link_url);
} else {
$retval .= ' <a href="' . $link_url . '">' . $link_name . '</a>';
}
}
unset($link_url, $link_name);
}
$retval .= '</td>';
$retval .= '</tr>';
}
$retval .= '</tbody>';
$retval .= '</table>';
return $retval;
}
示例10: PMA_getHtmlForRenderVariables
/**
* Returns HTML for render variables list
*
* @param PMA_ServerStatusData $ServerStatusData Server status data
* @param Array $alerts Alert Array
* @param Array $strShowStatus Status Array
*
* @return string
*/
function PMA_getHtmlForRenderVariables($ServerStatusData, $alerts, $strShowStatus)
{
$retval = '<table class="data sortable noclick" id="serverstatusvariables">';
$retval .= '<col class="namecol" />';
$retval .= '<col class="valuecol" />';
$retval .= '<col class="descrcol" />';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th>' . __('Variable') . '</th>';
$retval .= '<th>' . __('Value') . '</th>';
$retval .= '<th>' . __('Description') . '</th>';
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$odd_row = false;
foreach ($ServerStatusData->status as $name => $value) {
$odd_row = !$odd_row;
$retval .= '<tr class="' . ($odd_row ? 'odd' : 'even') . (isset($ServerStatusData->allocationMap[$name]) ? ' s_' . $ServerStatusData->allocationMap[$name] : '') . '">';
$retval .= '<th class="name">';
$retval .= htmlspecialchars(str_replace('_', ' ', $name));
// Fields containing % are calculated,
// they can not be described in MySQL documentation
if (strpos($name, '%') === false) {
$retval .= PMA_Util::showMySQLDocu('server-status-variables', false, 'statvar_' . $name);
}
$retval .= '</th>';
$retval .= '<td class="value"><span class="formatted">';
if (isset($alerts[$name])) {
if ($value > $alerts[$name]) {
$retval .= '<span class="attention">';
} else {
$retval .= '<span class="allfine">';
}
}
if ('%' === substr($name, -1, 1)) {
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 0, 2)) . ' %';
} elseif (strpos($name, 'Uptime') !== false) {
$retval .= htmlspecialchars(PMA_Util::timespanFormat($value));
} elseif (is_numeric($value) && $value > 1000) {
$retval .= '<abbr title="' . htmlspecialchars(PMA_Util::formatNumber($value, 0)) . '">' . htmlspecialchars(PMA_Util::formatNumber($value, 3, 1)) . '</abbr>';
} elseif (is_numeric($value)) {
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 3, 1));
} else {
$retval .= htmlspecialchars($value);
}
if (isset($alerts[$name])) {
$retval .= '</span>';
}
$retval .= '</span>';
$retval .= '<span style="display:none;" class="original">';
if (isset($alerts[$name])) {
if ($value > $alerts[$name]) {
$retval .= '<span class="attention">';
} else {
$retval .= '<span class="allfine">';
}
}
$retval .= $value;
if (isset($alerts[$name])) {
$retval .= '</span>';
}
$retval .= '</span>';
$retval .= '</td>';
$retval .= '<td class="descr">';
if (isset($strShowStatus[$name])) {
$retval .= $strShowStatus[$name];
}
if (isset($ServerStatusData->links[$name])) {
foreach ($ServerStatusData->links[$name] as $link_name => $link_url) {
if ('doc' == $link_name) {
$retval .= PMA_Util::showMySQLDocu($link_url);
} else {
$retval .= ' <a href="' . $link_url . '">' . $link_name . '</a>';
}
}
unset($link_url, $link_name);
}
$retval .= '</td>';
$retval .= '</tr>';
}
$retval .= '</tbody>';
$retval .= '</table>';
return $retval;
}
示例11: testPMAGetHtmlForRowStatistics
/**
* Tests for PMA_getHtmlForRowStatistics() method.
*
* @return void
* @test
*/
public function testPMAGetHtmlForRowStatistics()
{
$showtable = array('Row_format' => "Fixed", 'Rows' => 10, 'Avg_row_length' => 123, 'Data_length' => 345, 'Auto_increment' => 1234, 'Create_time' => "today", 'Update_time' => "time2", 'Check_time' => "yesterday");
$cell_align_left = "cell_align_left";
$avg_size = 12;
$avg_unit = 45;
$mergetable = false;
$html = PMA_getHtmlForRowStatistics($showtable, $cell_align_left, $avg_size, $avg_unit, $mergetable);
$this->assertContains(__('Row Statistics:'), $html);
//validation 1 : Row_format
$this->assertContains(__('Format'), $html);
$this->assertContains($cell_align_left, $html);
//$showtable['Row_format'] == 'Fixed'
$this->assertContains(__('static'), $html);
//validation 2 : Avg_row_length
$length = PMA_Util::formatNumber($showtable['Avg_row_length'], 0);
$this->assertContains($length, $html);
$this->assertContains(__('Row size'), $html);
$this->assertContains($avg_size . ' ' . $avg_unit, $html);
//validation 3 : Auto_increment
$average = PMA_Util::formatNumber($showtable['Auto_increment'], 0);
$this->assertContains($average, $html);
$this->assertContains(__('Next autoindex'), $html);
//validation 4 : Create_time
$time = PMA_Util::localisedDate(strtotime($showtable['Create_time']));
$this->assertContains(__('Creation'), $html);
$this->assertContains($time, $html);
//validation 5 : Update_time
$time = PMA_Util::localisedDate(strtotime($showtable['Update_time']));
$this->assertContains(__('Last update'), $html);
$this->assertContains($time, $html);
//validation 6 : Check_time
$time = PMA_Util::localisedDate(strtotime($showtable['Check_time']));
$this->assertContains(__('Last check'), $html);
$this->assertContains($time, $html);
}
示例12: PMA_getTableHtmlForProfilingSummaryByState
/**
* Function to get HTML for summary by state table
*
* @param array $profiling_stats profiling stats
*
* @return string $table html for the table
*/
function PMA_getTableHtmlForProfilingSummaryByState($profiling_stats)
{
$table = '';
foreach ($profiling_stats['states'] as $name => $stats) {
$table .= ' <tr>' . "\n";
$table .= '<td>' . $name . '</td>' . "\n";
$table .= '<td align="right">' . PMA_Util::formatNumber($stats['total_time'], 3, 1) . 's<span style="display:none;" class="rawvalue">' . $stats['total_time'] . '</span></td>' . "\n";
$table .= '<td align="right">' . PMA_Util::formatNumber(100 * ($stats['total_time'] / $profiling_stats['total_time']), 0, 2) . '%</td>' . "\n";
$table .= '<td align="right">' . $stats['calls'] . '</td>' . "\n";
$table .= '<td align="right">' . PMA_Util::formatNumber($stats['total_time'] / $stats['calls'], 3, 1) . 's<span style="display:none;" class="rawvalue">' . number_format($stats['total_time'] / $stats['calls'], 8, '.', '') . '</span></td>' . "\n";
$table .= ' </tr>' . "\n";
}
return $table;
}
示例13: getServerTrafficHtml
/**
* Prints server traffic information
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function getServerTrafficHtml($ServerStatusData)
{
$hour_factor = 3600 / $ServerStatusData->status['Uptime'];
$start_time = PMA_DBI_fetch_value('SELECT UNIX_TIMESTAMP() - ' . $ServerStatusData->status['Uptime']);
$retval = '<h3>';
$retval .= sprintf(__('Network traffic since startup: %s'), implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent'], 3, 1)));
$retval .= '</h3>';
$retval .= '<p>';
$retval .= sprintf(__('This MySQL server has been running for %1$s. It started up on %2$s.'), PMA_Util::timespanFormat($ServerStatusData->status['Uptime']), PMA_Util::localisedDate($start_time)) . "\n";
$retval .= '</p>';
if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) {
$retval .= '<p class="notice">';
if ($GLOBALS['server_master_status'] && $GLOBALS['server_slave_status']) {
$retval .= __('This MySQL server works as <b>master</b> and ' . '<b>slave</b> in <b>replication</b> process.');
} elseif ($GLOBALS['server_master_status']) {
$retval .= __('This MySQL server works as <b>master</b> ' . 'in <b>replication</b> process.');
} elseif ($GLOBALS['server_slave_status']) {
$retval .= __('This MySQL server works as <b>slave</b> ' . 'in <b>replication</b> process.');
}
$retval .= ' ';
$retval .= __('For further information about replication status on the server, ' . 'please visit the <a href="#replication">replication section</a>.');
$retval .= '</p>';
}
/*
* if the server works as master or slave in replication process,
* display useful information
*/
if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) {
$retval .= '<hr class="clearfloat" />';
$retval .= '<h3><a name="replication">';
$retval .= __('Replication status');
$retval .= '</a></h3>';
foreach ($GLOBALS['replication_types'] as $type) {
if (isset(${"server_{$type}_status"}) && ${"server_{$type}_status"}) {
PMA_replication_print_status_table($type);
}
}
}
$retval .= '<table id="serverstatustraffic" class="data noclick">';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th colspan="2">';
$retval .= __('Traffic') . ' ';
$retval .= PMA_Util::showHint(__('On a busy server, the byte counters may overrun, so those statistics ' . 'as reported by the MySQL server may be incorrect.'));
$retval .= '</th>';
$retval .= '<th>ø ' . __('per hour') . '</th>';
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$retval .= '<tr class="odd">';
$retval .= '<th class="name">' . __('Received') . '</th>';
$retval .= '<td class="value">';
$retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_received'], 3, 1));
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_received'] * $hour_factor, 3, 1));
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '<tr class="even">';
$retval .= '<th class="name">' . __('Sent') . '</th>';
$retval .= '<td class="value">';
$retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_sent'], 3, 1));
$retval .= '</td>';
$retval .= '<td class="value"><?php echo';
$retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_sent'] * $hour_factor, 3, 1));
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '<tr class="odd">';
$retval .= '<th class="name">' . __('Total') . '</th>';
$retval .= '<td class="value">';
$retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent'], 3, 1));
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= implode(' ', PMA_Util::formatByteDown(($ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent']) * $hour_factor, 3, 1));
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '</tbody>';
$retval .= '</table>';
$retval .= '<table id="serverstatusconnections" class="data noclick">';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th colspan="2">' . __('Connections') . '</th>';
$retval .= '<th>ø ' . __('per hour') . '</th>';
$retval .= '<th>%</th>';
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$retval .= '<tr class="odd">';
$retval .= '<th class="name">' . __('max. concurrent connections') . '</th>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber($ServerStatusData->status['Max_used_connections'], 0);
$retval .= '</td>';
$retval .= '<td class="value">--- </td>';
//.........这里部分代码省略.........
示例14: getHtmlForRowStatsTable
/**
* Get HTML snippet for display Row statistics table
*
* @param array $showtable show table array
* @param string $tbl_collation table collation
* @param boolean $is_innodb whether table is innob or not
* @param boolean $mergetable Checks if current table is a merge table
* @param integer $avg_size average size
* @param string $avg_unit average unit
*
* @return string $html_output
*/
function getHtmlForRowStatsTable($showtable, $tbl_collation, $is_innodb, $mergetable, $avg_size, $avg_unit)
{
$odd_row = false;
$html_output = '<table id="tablerowstats" class="data">';
$html_output .= '<caption class="tblHeaders">' . __('Row statistics') . '</caption>';
$html_output .= '<tbody>';
if (isset($showtable['Row_format'])) {
if ($showtable['Row_format'] == 'Fixed') {
$value = __('static');
} elseif ($showtable['Row_format'] == 'Dynamic') {
$value = __('dynamic');
} else {
$value = $showtable['Row_format'];
}
$html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Format'), $value);
$odd_row = !$odd_row;
}
if (!empty($showtable['Create_options'])) {
if ($showtable['Create_options'] == 'partitioned') {
$value = __('partitioned');
} else {
$value = $showtable['Create_options'];
}
$html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Options'), $value);
$odd_row = !$odd_row;
}
if (!empty($tbl_collation)) {
$value = '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
$html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Collation'), $value);
$odd_row = !$odd_row;
}
if (!$is_innodb && isset($showtable['Rows'])) {
$html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Rows'), PMA_Util::formatNumber($showtable['Rows'], 0));
$odd_row = !$odd_row;
}
if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
list($avg_row_length_value, $avg_row_length_unit) = PMA_Util::formatByteDown($showtable['Avg_row_length'], 6, 1);
$html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Row length'), $avg_row_length_value . ' ' . $avg_row_length_unit);
unset($avg_row_length_value, $avg_row_length_unit);
$odd_row = !$odd_row;
}
if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
$html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Row size'), $avg_size . ' ' . $avg_unit);
$odd_row = !$odd_row;
}
if (isset($showtable['Auto_increment'])) {
$html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Next autoindex'), PMA_Util::formatNumber($showtable['Auto_increment'], 0));
$odd_row = !$odd_row;
}
if (isset($showtable['Create_time'])) {
$html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Creation'), PMA_Util::localisedDate(strtotime($showtable['Create_time'])));
$odd_row = !$odd_row;
}
if (isset($showtable['Update_time'])) {
$html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Last update'), PMA_Util::localisedDate(strtotime($showtable['Update_time'])));
$odd_row = !$odd_row;
}
if (isset($showtable['Check_time'])) {
$html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Last check'), PMA_Util::localisedDate(strtotime($showtable['Check_time'])));
}
$html_output .= '</tbody>' . '</table>';
return $html_output;
}
示例15: foreach
echo '</tr>' . "\n";
} // end foreach ($databases as $key => $current)
unset($current, $odd_row);
echo '</tbody><tfoot><tr>' . "\n";
if ($is_superuser || $cfg['AllowUserDropDatabase']) {
echo ' <th></th>' . "\n";
}
echo ' <th>' . __('Total') . ': <span id="databases_count">' . $databases_count . '</span></th>' . "\n";
foreach ($column_order as $stat_name => $stat) {
if (array_key_exists($stat_name, $first_database)) {
if ($stat['format'] === 'byte') {
list($value, $unit) = PMA_Util::formatByteDown($stat['footer'], 3, 1);
} elseif ($stat['format'] === 'number') {
$value = PMA_Util::formatNumber($stat['footer'], 0);
} else {
$value = htmlentities($stat['footer'], 0);
}
echo ' <th class="value">';
if (isset($stat['description_function'])) {
echo '<dfn title="' . $stat['description_function']($stat['footer']) . '">';
}
echo $value;
if (isset($stat['description_function'])) {
echo '</dfn>';
}
echo '</th>' . "\n";
if ($stat['format'] === 'byte') {
echo ' <th class="unit">' . $unit . '</th>' . "\n";
}