Merge remote-tracking branch 'origin/master'

This commit is contained in:
Michal Čihař 2012-04-14 14:26:19 +02:00
commit 88d7eb6f1a
17 changed files with 280 additions and 192 deletions

View File

@ -12,7 +12,7 @@ require_once 'libraries/common.inc.php';
$GLOBALS['js_include'][] = 'functions.js';
require_once 'libraries/mysql_charsets.lib.php';
if (!PMA_DRIZZLE) {
if (! PMA_DRIZZLE) {
include_once 'libraries/replication.inc.php';
}
require 'libraries/build_html_for_db.lib.php';
@ -41,9 +41,11 @@ $err_url = 'main.php?' . PMA_generate_common_url();
* Builds and executes the db creation sql query
*/
$sql_query = 'CREATE DATABASE ' . PMA_backquote($new_db);
if (!empty($db_collation)) {
if (! empty($db_collation)) {
list($db_charset) = explode('_', $db_collation);
if (in_array($db_charset, $mysql_charsets) && in_array($db_collation, $mysql_collations[$db_charset])) {
if (in_array($db_charset, $mysql_charsets)
&& in_array($db_collation, $mysql_collations[$db_charset])
) {
$sql_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
}
$db_collation_for_ajax = $db_collation;
@ -85,10 +87,13 @@ if (! $result) {
*/
$extra_data['sql_query'] = PMA_showMessage(null, $sql_query, 'success');
//Construct the html for the new database, so that it can be appended to the list of databases on server_databases.php
//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_generate_common_url} to generate the links
* Build the array to be passed to {@link PMA_generate_common_url}
* to generate the links
*
* @global array $GLOBALS['db_url_params']
* @name $db_url_params
*/
@ -127,7 +132,10 @@ if (! $result) {
);
}
list($column_order, $generated_html) = PMA_buildHtmlForDb($current, $is_superuser, (isset($checkall) ? $checkall : ''), $url_query, $column_order, $replication_types, $replication_info);
list($column_order, $generated_html) = PMA_buildHtmlForDb(
$current, $is_superuser, (isset($checkall) ? $checkall : ''),
$url_query, $column_order, $replication_types, $replication_info
);
$new_db_string .= $generated_html;
$new_db_string .= '</tr>';

View File

@ -204,9 +204,10 @@ foreach ($tables as $table) {
$field_name = $row['Field'];
if (PMA_MYSQL_INT_VERSION < 50025
&& ! empty($analyzed_sql[0]['create_table_fields'][$field_name]['type'])
&& $analyzed_sql[0]['create_table_fields'][$field_name]['type'] == 'TIMESTAMP'
&& $analyzed_sql[0]['create_table_fields'][$field_name]['timestamp_not_null']) {
&& ! empty($analyzed_sql[0]['create_table_fields'][$field_name]['type'])
&& $analyzed_sql[0]['create_table_fields'][$field_name]['type'] == 'TIMESTAMP'
&& $analyzed_sql[0]['create_table_fields'][$field_name]['timestamp_not_null']
) {
// here, we have a TIMESTAMP that SHOW FULL COLUMNS reports as having the
// NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
// the latter.

View File

@ -48,7 +48,8 @@ if (!empty($selected_tbl) && empty($table_select)) {
$table_select = $selected_tbl;
}
// Check if the selected tables are defined in $_GET (from clicking Back button on export.php)
// Check if the selected tables are defined in $_GET
// (from clicking Back button on export.php)
if (isset($_GET['table_select'])) {
$_GET['table_select'] = urldecode($_GET['table_select']);
$_GET['table_select'] = explode(",", $_GET['table_select']);
@ -62,7 +63,8 @@ foreach ($tables as $each_table) {
$is_selected = '';
}
} elseif (! empty($unselectall)
|| (! empty($table_select) && !in_array($each_table['Name'], $table_select))) {
|| (! empty($table_select) && !in_array($each_table['Name'], $table_select))
) {
$is_selected = '';
} else {
$is_selected = ' selected="selected"';

View File

@ -60,10 +60,15 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
} else {
$sql_query = ''; // in case target db exists
$_error = false;
if ($move || (isset($create_database_before_copying) && $create_database_before_copying)) {
if ($move
|| (isset($create_database_before_copying)
&& $create_database_before_copying)
) {
// lower_case_table_names=1 `DB` becomes `db`
if (!PMA_DRIZZLE) {
$lower_case_table_names = PMA_DBI_fetch_value('SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1);
if (! PMA_DRIZZLE) {
$lower_case_table_names = PMA_DBI_fetch_value(
'SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1
);
if ($lower_case_table_names === '1') {
$newname = PMA_strtolower($newname);
}
@ -206,7 +211,9 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
unset($triggers);
// this does not apply to a rename operation
if (isset($GLOBALS['add_constraints']) && !empty($GLOBALS['sql_constraints_query'])) {
if (isset($GLOBALS['add_constraints'])
&& ! empty($GLOBALS['sql_constraints_query'])
) {
$GLOBALS['sql_constraints_query_full_db'][] = $GLOBALS['sql_constraints_query'];
unset($GLOBALS['sql_constraints_query']);
}
@ -245,21 +252,24 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
PMA_DBI_select_db($newname);
foreach ($GLOBALS['sql_constraints_query_full_db'] as $one_query) {
PMA_DBI_query($one_query);
// and prepare to display them
// and prepare to display them
$GLOBALS['sql_query'] .= "\n" . $one_query;
}
unset($GLOBALS['sql_constraints_query_full_db'], $one_query);
}
if (!PMA_DRIZZLE && PMA_MYSQL_INT_VERSION >= 50100) {
if (! PMA_DRIZZLE && PMA_MYSQL_INT_VERSION >= 50100) {
// here DELIMITER is not used because it's not part of the
// language; each statement is sent one by one
// to avoid selecting alternatively the current and new db
// we would need to modify the CREATE definitions to qualify
// the db name
$event_names = PMA_DBI_fetch_result('SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \'' . PMA_sqlAddSlashes($db, true) . '\';');
$event_names = PMA_DBI_fetch_result(
'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \''
. PMA_sqlAddSlashes($db, true) . '\';'
);
if ($event_names) {
foreach ($event_names as $event_name) {
PMA_DBI_select_db($db);
@ -447,7 +457,7 @@ if ($db != 'mysql') {
// Don't even try to drop information_schema. You won't be able to. Believe me. You won't.
// Don't allow to easily drop mysql database, RFE #1327514.
if (($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase'])
&& !$db_is_information_schema
&& ! $db_is_information_schema
&& (PMA_DRIZZLE || $db != 'mysql')) {
?>
<div class="operations_half_width">
@ -534,8 +544,10 @@ echo __('Remove database');
<?php
unset($drop_clause);
if (isset($_COOKIE) && isset($_COOKIE['pma_switch_to_new'])
&& $_COOKIE['pma_switch_to_new'] == 'true') {
if (isset($_COOKIE)
&& isset($_COOKIE['pma_switch_to_new'])
&& $_COOKIE['pma_switch_to_new'] == 'true'
) {
$pma_switch_to_new = 'true';
}
?>
@ -580,7 +592,9 @@ echo __('Remove database');
. '</form></div>' . "\n";
if ($num_tables > 0
&& ! $cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == false) {
&& ! $cfgRelation['allworks']
&& $cfg['PmaNoRelation_DisableWarning'] == false
) {
$message = PMA_Message::notice(__('The phpMyAdmin configuration storage has been deactivated. To find out why click %shere%s.'));
$message->addParam('<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $url_query . '">', false);
$message->addParam('</a>', false);

View File

@ -115,7 +115,8 @@ if ($num_tables == 0) {
$odd_row = true;
foreach ($tables as $sts_data) {
if (PMA_Table::isMerge($db, $sts_data['TABLE_NAME'])
|| strtoupper($sts_data['ENGINE']) == 'FEDERATED') {
|| strtoupper($sts_data['ENGINE']) == 'FEDERATED'
) {
$merged_size = true;
} else {
$merged_size = false;
@ -171,8 +172,9 @@ if ($num_tables == 0) {
}
if (! empty($sts_data['Create_time'])
|| ! empty($sts_data['Update_time'])
|| ! empty($sts_data['Check_time'])) {
|| ! empty($sts_data['Update_time'])
|| ! empty($sts_data['Check_time'])
) {
echo $needs_break;
?>
<table width="100%">

View File

@ -95,7 +95,10 @@ if (PMA_isValid($_REQUEST['TableList'], 'array')) {
/**
* Prepares the form
*/
$tbl_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
$tbl_result = PMA_DBI_query(
'SHOW TABLES FROM ' . PMA_backquote($db) . ';',
null, PMA_DBI_QUERY_STORE
);
$tbl_result_cnt = PMA_DBI_num_rows($tbl_result);
if (0 == $tbl_result_cnt) {
PMA_Message::error(__('No tables found in database.'))->display();
@ -107,7 +110,7 @@ if (0 == $tbl_result_cnt) {
while (list($tbl) = PMA_DBI_fetch_row($tbl_result)) {
$fld_results = PMA_DBI_get_columns($db, $tbl);
if (empty($tbl_names[$tbl]) && !empty($_REQUEST['TableList'])) {
if (empty($tbl_names[$tbl]) && ! empty($_REQUEST['TableList'])) {
$tbl_names[$tbl] = '';
} else {
$tbl_names[$tbl] = ' selected="selected"';
@ -166,7 +169,7 @@ function showColumnSelectCell($columns, $column_number, $selected = '')
}
?>
<?php if (!empty($tab_designer['link'])) {
<?php if (! empty($tab_designer['link'])) {
$tab_designer['link'] = htmlentities($tab_designer['link']);
$tab_designer['link'] = $tab_designer['link'] . PMA_generate_common_url($url_params);
if (! empty($tab_designer['args'])) {
@ -223,7 +226,7 @@ for ($x = 0; $x < $col; $x++) {
<?php
$z = 0;
for ($x = 0; $x < $col; $x++) {
if (!empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
if (! empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
?>
<td class="center">
<select style="width: <?php echo $realwidth; ?>" name="Sort[<?php echo $z; ?>]" size="1">
@ -237,7 +240,7 @@ for ($x = 0; $x < $col; $x++) {
} // end if
echo "\n";
if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
if (! empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
continue;
}
?>
@ -287,7 +290,7 @@ for ($x = 0; $x < $col; $x++) {
<?php
$z = 0;
for ($x = 0; $x < $col; $x++) {
if (!empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
if (! empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
?>
<td class="center">
<input type="checkbox" name="Show[<?php echo $z; ?>]" />
@ -297,7 +300,7 @@ for ($x = 0; $x < $col; $x++) {
} // end if
echo "\n";
if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
if (! empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
continue;
}
if (isset($Show[$x])) {
@ -323,7 +326,7 @@ for ($x = 0; $x < $col; $x++) {
<?php
$z = 0;
for ($x = 0; $x < $col; $x++) {
if (!empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
if (! empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
?>
<td class="center">
<input type="text" name="criteria[<?php echo $z; ?>]" value="" class="textfield" style="width: <?php echo $realwidth; ?>" size="20" />
@ -333,14 +336,15 @@ for ($x = 0; $x < $col; $x++) {
} // end if
echo "\n";
if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
if (! empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
continue;
}
if (isset($criteria[$x])) {
$tmp_criteria = $criteria[$x];
}
if ((empty($prev_criteria) || ! isset($prev_criteria[$x]))
|| $prev_criteria[$x] != htmlspecialchars($tmp_criteria)) {
|| $prev_criteria[$x] != htmlspecialchars($tmp_criteria)
) {
$curCriteria[$z] = $tmp_criteria;
} else {
$curCriteria[$z] = $prev_criteria[$x];
@ -481,7 +485,7 @@ for ($y = 0; $y <= $row; $y++) {
<?php
$z = 0;
for ($x = 0; $x < $col; $x++) {
if (!empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
if (! empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
echo "\n";
$or = 'Or' . $w . '[' . $z . ']';
?>
@ -491,7 +495,7 @@ for ($y = 0; $y <= $row; $y++) {
<?php
$z++;
} // end if
if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
if (! empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
continue;
}
@ -500,7 +504,7 @@ for ($y = 0; $y <= $row; $y++) {
if (! isset(${$or})) {
${$or} = '';
}
if (!empty(${$or}) && isset(${$or}[$x])) {
if (! empty(${$or}) && isset(${$or}[$x])) {
$tmp_or = ${$or}[$x];
} else {
$tmp_or = '';
@ -510,7 +514,7 @@ for ($y = 0; $y <= $row; $y++) {
<input type="text" name="Or<?php echo $w . '[' . $z . ']'; ?>" value="<?php echo htmlspecialchars($tmp_or); ?>" class="textfield" style="width: <?php echo $realwidth; ?>" size="20" />
</td>
<?php
if (!empty(${$or}) && isset(${$or}[$x])) {
if (! empty(${$or}) && isset(${$or}[$x])) {
${'cur' . $or}[$z] = ${$or}[$x];
}
$z++;
@ -530,7 +534,7 @@ for ($y = 0; $y <= $row; $y++) {
<?php
$z = 0;
for ($x = 0; $x < $col; $x++) {
if (!empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
if (! empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
$curAndOrCol[$z] = $and_or_col[$y];
if ($and_or_col[$z] == 'or') {
$chk['or'] = ' checked="checked"';
@ -556,7 +560,7 @@ for ($x = 0; $x < $col; $x++) {
} // end if
echo "\n";
if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
if (! empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
continue;
}
@ -667,7 +671,7 @@ if (! isset($qry_select)) {
$qry_select = '';
}
for ($x = 0; $x < $col; $x++) {
if (!empty($curField[$x]) && isset($curShow[$x]) && $curShow[$x] == 'on') {
if (! empty($curField[$x]) && isset($curShow[$x]) && $curShow[$x] == 'on') {
if ($last_select) {
$qry_select .= ', ';
}
@ -675,7 +679,7 @@ for ($x = 0; $x < $col; $x++) {
$last_select = 1;
}
} // end for
if (!empty($qry_select)) {
if (! empty($qry_select)) {
echo 'SELECT ' . htmlspecialchars($qry_select) . "\n";
}
@ -700,14 +704,14 @@ if (isset($Field) && count($Field) > 0) {
// We only start this if we have fields, otherwise it would be dumb
foreach ($Field as $value) {
$parts = explode('.', $value);
if (!empty($parts[0]) && !empty($parts[1])) {
if (! empty($parts[0]) && ! empty($parts[1])) {
$tab_raw = $parts[0];
$tab = str_replace('`', '', $tab_raw);
$tab_all[$tab] = $tab;
$col_raw = $parts[1];
$col_all[] = $tab . '.' . str_replace('`', '', $col_raw);
}
}
} // end while
// Check 'where' clauses
@ -716,7 +720,7 @@ if (isset($Field) && count($Field) > 0) {
$crit_cnt = count($criteria);
for ($x = 0; $x < $crit_cnt; $x++) {
$curr_tab = explode('.', $Field[$x]);
if (!empty($curr_tab[0]) && !empty($curr_tab[1])) {
if (! empty($curr_tab[0]) && ! empty($curr_tab[1])) {
$tab_raw = $curr_tab[0];
$tab = str_replace('`', '', $tab_raw);
@ -725,7 +729,7 @@ if (isset($Field) && count($Field) > 0) {
$col1 = $tab . '.' . $col1;
// Now we know that our array has the same numbers as $criteria
// we can check which of our columns has a where clause
if (!empty($criteria[$x])) {
if (! empty($criteria[$x])) {
if (substr($criteria[$x], 0, 1) == '=' || stristr($criteria[$x], 'is')) {
$col_where[$col] = $col1;
$tab_wher[$tab] = $tab;
@ -866,7 +870,7 @@ if (empty($qry_from) && isset($tab_all)) {
$qry_from = implode(', ', $tab_all);
}
// Now let's see what we got
if (!empty($qry_from)) {
if (! empty($qry_from)) {
echo 'FROM ' . htmlspecialchars($qry_from) . "\n";
}
@ -874,10 +878,10 @@ if (!empty($qry_from)) {
$qry_where = '';
$criteria_cnt = 0;
for ($x = 0; $x < $col; $x++) {
if (!empty($curField[$x]) && !empty($curCriteria[$x]) && $x && isset($last_where) && isset($curAndOrCol)) {
if (! empty($curField[$x]) && ! empty($curCriteria[$x]) && $x && isset($last_where) && isset($curAndOrCol)) {
$qry_where .= ' ' . strtoupper($curAndOrCol[$last_where]) . ' ';
}
if (!empty($curField[$x]) && !empty($curCriteria[$x])) {
if (! empty($curField[$x]) && ! empty($curCriteria[$x])) {
$qry_where .= '(' . $curField[$x] . ' ' . $curCriteria[$x] . ')';
$last_where = $x;
$criteria_cnt++;
@ -895,10 +899,10 @@ for ($y = 0; $y <= $row; $y++) {
$qry_orwhere = '';
$last_orwhere = '';
for ($x = 0; $x < $col; $x++) {
if (!empty($curField[$x]) && !empty(${'curOr' . $y}[$x]) && $x) {
if (! empty($curField[$x]) && ! empty(${'curOr' . $y}[$x]) && $x) {
$qry_orwhere .= ' ' . strtoupper($curAndOrCol[$last_orwhere]) . ' ';
}
if (!empty($curField[$x]) && !empty(${'curOr' . $y}[$x])) {
if (! empty($curField[$x]) && ! empty(${'curOr' . $y}[$x])) {
$qry_orwhere .= '(' . $curField[$x]
. ' '
. ${'curOr' . $y}[$x]
@ -910,14 +914,14 @@ for ($y = 0; $y <= $row; $y++) {
if ($criteria_cnt > 1) {
$qry_orwhere = '(' . $qry_orwhere . ')';
}
if (!empty($qry_orwhere)) {
if (! empty($qry_orwhere)) {
$qry_where .= "\n"
. strtoupper(isset($curAndOrRow[$y]) ? $curAndOrRow[$y] . ' ' : '')
. $qry_orwhere;
} // end if
} // end for
if (!empty($qry_where) && $qry_where != '()') {
if (! empty($qry_where) && $qry_where != '()') {
echo 'WHERE ' . htmlspecialchars($qry_where) . "\n";
} // end if
@ -928,10 +932,10 @@ if (! isset($qry_orderby)) {
$qry_orderby = '';
}
for ($x = 0; $x < $col; $x++) {
if ($last_orderby && $x && !empty($curField[$x]) && !empty($curSort[$x])) {
if ($last_orderby && $x && ! empty($curField[$x]) && ! empty($curSort[$x])) {
$qry_orderby .= ', ';
}
if (!empty($curField[$x]) && !empty($curSort[$x])) {
if (! empty($curField[$x]) && ! empty($curSort[$x])) {
// if they have chosen all fields using the * selector,
// then sorting is not available
// Fix for Bug #570698
@ -941,7 +945,7 @@ for ($x = 0; $x < $col; $x++) {
}
}
} // end for
if (!empty($qry_orderby)) {
if (! empty($qry_orderby)) {
echo 'ORDER BY ' . htmlspecialchars($qry_orderby) . "\n";
}
?>

View File

@ -46,8 +46,10 @@ $search_options = array(
'4' => __('as regular expression'),
);
if (empty($_REQUEST['search_option']) || ! is_string($_REQUEST['search_option'])
|| ! array_key_exists($_REQUEST['search_option'], $search_options)) {
if (empty($_REQUEST['search_option'])
|| ! is_string($_REQUEST['search_option'])
|| ! array_key_exists($_REQUEST['search_option'], $search_options)
) {
$search_option = 1;
unset($_REQUEST['submit_search']);
} else {
@ -66,7 +68,9 @@ if (empty($_REQUEST['search_str']) || ! is_string($_REQUEST['search_str'])) {
//
// Usage example: If user is seaching for a literal $ in a regexp search,
// he should enter \$ as the value.
$search_str = PMA_sqlAddSlashes($_REQUEST['search_str'], ($search_option == 4 ? false : true));
$search_str = PMA_sqlAddSlashes(
$_REQUEST['search_str'], ($search_option == 4 ? false : true)
);
}
$tables_selected = array();
@ -106,6 +110,15 @@ if (isset($_REQUEST['submit_search'])) {
/**
* Builds the SQL search query
*
* @param string $table the table name
* @param string $field restrict the search to this field
* @param string $search_str the string to search
* @param integer $search_option type of search
* (1 -> 1 word at least, 2 -> all words,
* 3 -> exact string, 4 -> regexp)
*
* @return array 3 SQL querys (for count, display and delete results)
*
* @todo can we make use of fulltextsearch IN BOOLEAN MODE for this?
* PMA_backquote
* PMA_DBI_free_result
@ -114,13 +127,6 @@ if (isset($_REQUEST['submit_search'])) {
* explode
* count
* strlen
* @param string the table name
* @param string restrict the search to this field
* @param string the string to search
* @param integer type of search (1 -> 1 word at least, 2 -> all words,
* 3 -> exact string, 4 -> regexp)
*
* @return array 3 SQL querys (for count, display and delete results)
*/
function PMA_getSearchSqls($table, $field, $search_str, $search_option)
{
@ -152,16 +158,16 @@ if (isset($_REQUEST['submit_search'])) {
// Drizzle has no CONVERT and all text columns are UTF-8
if (PMA_DRIZZLE) {
$thefieldlikevalue[] = PMA_backquote($tblfield['Field'])
. ' ' . $like_or_regex . ' '
. "'" . $automatic_wildcard
. $search_word
. $automatic_wildcard . "'";
. ' ' . $like_or_regex . ' '
. "'" . $automatic_wildcard
. $search_word
. $automatic_wildcard . "'";
} else {
$thefieldlikevalue[] = 'CONVERT(' . PMA_backquote($tblfield['Field']) . ' USING utf8)'
. ' ' . $like_or_regex . ' '
. "'" . $automatic_wildcard
. $search_word
. $automatic_wildcard . "'";
. ' ' . $like_or_regex . ' '
. "'" . $automatic_wildcard
. $search_word
. $automatic_wildcard . "'";
}
}
} // end for
@ -217,7 +223,10 @@ if (isset($_REQUEST['submit_search'])) {
foreach ($tables_selected as $each_table) {
// Gets the SQL statements
$newsearchsqls = PMA_getSearchSqls($each_table, (! empty($field_str) ? $field_str : ''), $search_str, $search_option);
$newsearchsqls = PMA_getSearchSqls(
$each_table, (! empty($field_str) ? $field_str : ''),
$search_str, $search_option
);
// Executes the "COUNT" statement
$res_cnt = PMA_DBI_fetch_value($newsearchsqls['select_count']);

View File

@ -59,7 +59,10 @@ if ($num_tables == 0 && empty($db_query_force)) {
/**
* Query box, bookmark, insert data from textfile
*/
PMA_sqlQueryForm(true, false, isset($_REQUEST['delimiter']) ? htmlspecialchars($_REQUEST['delimiter']) : ';');
PMA_sqlQueryForm(
true, false,
isset($_REQUEST['delimiter']) ? htmlspecialchars($_REQUEST['delimiter']) : ';'
);
/**
* Displays the footer

View File

@ -172,12 +172,14 @@ foreach ($tables as $keyname => $each_table) {
}
if ($is_show_stats) {
$tblsize = doubleval($each_table['Data_length']) + doubleval($each_table['Index_length']);
$sum_size += $tblsize;
list($formatted_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0);
$tblsize = doubleval($each_table['Data_length']) + doubleval($each_table['Index_length']);
$sum_size += $tblsize;
list($formatted_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0);
if (isset($each_table['Data_free']) && $each_table['Data_free'] > 0) {
list($formatted_overhead, $overhead_unit) = PMA_formatByteDown($each_table['Data_free'], 3, ($each_table['Data_free'] > 0) ? 1 : 0);
$overhead_size += $each_table['Data_free'];
list($formatted_overhead, $overhead_unit) = PMA_formatByteDown(
$each_table['Data_free'], 3, ($each_table['Data_free'] > 0) ? 1 : 0
);
$overhead_size += $each_table['Data_free'];
}
}
break;
@ -201,9 +203,9 @@ foreach ($tables as $keyname => $each_table) {
// Drizzle doesn't provide data and index length, check for null
if ($is_show_stats && $each_table['Data_length'] !== null) {
$tblsize = $each_table['Data_length'] + $each_table['Index_length'];
$sum_size += $tblsize;
list($formatted_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0);
$tblsize = $each_table['Data_length'] + $each_table['Index_length'];
$sum_size += $tblsize;
list($formatted_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0);
}
//$display_rows = ' - ';
break;
@ -281,7 +283,7 @@ foreach ($tables as $keyname => $each_table) {
if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) {
// $showtable might already be set from ShowDbStructureCreation, see above
if (!isset($showtable)) {
if (! isset($showtable)) {
$showtable = PMA_Table::sGetStatusInfo($db, $each_table['TABLE_NAME'], null, true);
}
$update_time = isset($showtable['Update_time']) ? $showtable['Update_time'] : false;
@ -294,7 +296,7 @@ foreach ($tables as $keyname => $each_table) {
if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) {
// $showtable might already be set from ShowDbStructureCreation, see above
if (!isset($showtable)) {
if (! isset($showtable)) {
$showtable = PMA_Table::sGetStatusInfo($db, $each_table['TABLE_NAME'], null, true);
}
$check_time = isset($showtable['Check_time']) ? $showtable['Check_time'] : false;
@ -305,10 +307,10 @@ foreach ($tables as $keyname => $each_table) {
}
}
$alias = (!empty($tooltip_aliasname) && isset($tooltip_aliasname[$each_table['TABLE_NAME']]))
$alias = (! empty($tooltip_aliasname) && isset($tooltip_aliasname[$each_table['TABLE_NAME']]))
? str_replace(' ', '&nbsp;', htmlspecialchars($tooltip_truename[$each_table['TABLE_NAME']]))
: str_replace(' ', '&nbsp;', htmlspecialchars($each_table['TABLE_NAME']));
$truename = (!empty($tooltip_truename) && isset($tooltip_truename[$each_table['TABLE_NAME']]))
$truename = (! empty($tooltip_truename) && isset($tooltip_truename[$each_table['TABLE_NAME']]))
? str_replace(' ', '&nbsp;', htmlspecialchars($tooltip_truename[$each_table['TABLE_NAME']]))
: str_replace(' ', '&nbsp;', htmlspecialchars($each_table['TABLE_NAME']));
@ -359,11 +361,11 @@ foreach ($tables as $keyname => $each_table) {
$empty_table .= 'class="truncate_table_anchor"';
}
$empty_table .= ' href="sql.php?' . $tbl_url_query
. '&amp;sql_query=';
. '&amp;sql_query=';
$empty_table .= urlencode('TRUNCATE ' . PMA_backquote($each_table['TABLE_NAME']))
. '&amp;message_to_show='
. urlencode(sprintf(__('Table %s has been emptied'), htmlspecialchars($each_table['TABLE_NAME'])))
.'">';
. '&amp;message_to_show='
. urlencode(sprintf(__('Table %s has been emptied'), htmlspecialchars($each_table['TABLE_NAME'])))
.'">';
if ($may_have_rows) {
$empty_table .= $titles['Empty'];
} else {
@ -413,8 +415,6 @@ foreach ($tables as $keyname => $each_table) {
$do = false;
if ($server_slave_status) {
////////////////////////////////////////////////////////////////
if ((strlen(array_search($truename, $server_slave_Do_Table)) > 0)
|| (strlen(array_search($db, $server_slave_Do_DB)) > 0)
|| (count($server_slave_Do_DB) == 1 && count($server_slave_Ignore_DB) == 1)
@ -429,7 +429,7 @@ foreach ($tables as $keyname => $each_table) {
$do = true;
}
}
////////////////////////////////////////////////////////////////////
if ((strlen(array_search($truename, $server_slave_Ignore_Table)) > 0)
|| (strlen(array_search($db, $server_slave_Ignore_DB)) > 0)
) {
@ -489,8 +489,8 @@ foreach ($tables as $keyname => $each_table) {
$row_count_pre = '';
$show_superscript = '';
if ($table_is_view) {
// Drizzle views use FunctionEngine, and the only place where they are available are I_S and D_D
// schemas, where we do exact counting
// Drizzle views use FunctionEngine, and the only place where they are
// available are I_S and D_D schemas, where we do exact counting
if ($each_table['TABLE_ROWS'] >= $GLOBALS['cfg']['MaxExactCountViews']
&& $each_table['ENGINE'] != 'FunctionEngine'
) {

View File

@ -100,7 +100,9 @@ if (PMA_DBI_num_rows($all_tables_result) > 0) {
if (true == $GLOBALS['cfg']['PropertiesIconic']) {
$drop_image_or_text .= PMA_getImage('b_drop.png', __('Delete tracking data for this table'));
}
if ('both' === $GLOBALS['cfg']['PropertiesIconic'] || false === $GLOBALS['cfg']['PropertiesIconic']) {
if ('both' === $GLOBALS['cfg']['PropertiesIconic']
|| false === $GLOBALS['cfg']['PropertiesIconic']
) {
$drop_image_or_text .= __('Drop');
}
@ -110,7 +112,9 @@ if (PMA_DBI_num_rows($all_tables_result) > 0) {
$table_query = ' SELECT * FROM ' .
PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
' WHERE `db_name` = \'' . PMA_sqlAddSlashes($_REQUEST['db']) . '\' AND `table_name` = \'' . PMA_sqlAddSlashes($table_name) . '\' AND `version` = \'' . $version_number . '\'';
' WHERE `db_name` = \'' . PMA_sqlAddSlashes($_REQUEST['db'])
. '\' AND `table_name` = \'' . PMA_sqlAddSlashes($table_name)
. '\' AND `version` = \'' . $version_number . '\'';
$table_result = PMA_query_as_controluser($table_query);
$version_data = PMA_DBI_fetch_array($table_result);
@ -120,8 +124,10 @@ if (PMA_DBI_num_rows($all_tables_result) > 0) {
} else {
$version_status = __('not active');
}
$tmp_link = 'tbl_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']);
$delete_link = 'db_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']) . '&amp;delete_tracking=true&amp';
$tmp_link = 'tbl_tracking.php?' . $url_query . '&amp;table='
. htmlspecialchars($version_data['table_name']);
$delete_link = 'db_tracking.php?' . $url_query . '&amp;table='
. htmlspecialchars($version_data['table_name']) . '&amp;delete_tracking=true&amp';
?>
<tr class="noclick <?php echo $style;?>">
<td><?php echo htmlspecialchars($version_data['db_name']);?></td>
@ -196,7 +202,8 @@ if (isset($my_tables)) {
foreach ($my_tables as $key => $tablename) {
if (PMA_Tracker::getVersion($GLOBALS['db'], $tablename) == -1) {
$my_link = '<a href="tbl_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($tablename) .'">';
$my_link = '<a href="tbl_tracking.php?' . $url_query
. '&amp;table=' . htmlspecialchars($tablename) .'">';
$my_link .= PMA_getIcon('eye.png', __('Track table')) . '</a>';
?>
<tr class="noclick <?php echo $style;?>">

View File

@ -97,10 +97,12 @@ abstract class PMA_GIS_Geometry
*/
protected function getBoundsForOl($srid, $scale_data)
{
return 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.LonLat('
return 'bound = new OpenLayers.Bounds(); '
. 'bound.extend(new OpenLayers.LonLat('
. $scale_data['minX'] . ', ' . $scale_data['minY']
. ').transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject())); bound.extend(new OpenLayers.LonLat('
. $srid . '"), map.getProjectionObject())); '
. 'bound.extend(new OpenLayers.LonLat('
. $scale_data['maxX'] . ', ' . $scale_data['maxY']
. ').transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject()));';
@ -215,49 +217,121 @@ abstract class PMA_GIS_Geometry
return $points_arr;
}
/**
* Generates JavaScript for adding an array of polygons to OpenLayers.
*
* @param array $polygons x and y coordinates for each polygon
* @param string $srid spatial reference id
*
* @return string JavaScript for adding an array of polygons to OpenLayers
* @access protected
*/
protected function getPolygonArrayForOpenLayers($polygons, $srid)
{
$ol_array = 'new Array(';
foreach ($polygons as $polygon) {
$rings = explode("),(", $polygon);
$ol_array .= $this->getPolygonForOpenLayers($rings, $srid) . ', ';
}
$ol_array = substr($ol_array, 0, strlen($ol_array) - 2);
$ol_array .= ')';
return $ol_array;
}
/**
* Generates JavaScript for adding points for OpenLayers polygon.
*
* @param string $polygon points of a polygon in WKT form
* @param array $polygon x and y coordinates for each line
* @param string $srid spatial reference id
*
* @return string JavaScript for adding points for OpenLayers polygon
* @access protected
*/
protected function addPointsForOpenLayersPolygon($polygon, $srid)
protected function getPolygonForOpenLayers($polygon, $srid)
{
$row = 'new OpenLayers.Geometry.Polygon(new Array(';
// If the polygon doesnt have an inner polygon
if (strpos($polygon, "),(") === false) {
$points_arr = $this->extractPoints($polygon, null);
$row .= 'new OpenLayers.Geometry.LinearRing(new Array(';
foreach ($points_arr as $point) {
$row .= '(new OpenLayers.Geometry.Point('
. $point[0] . ', ' . $point[1] . '))'
. '.transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject()), ';
}
$row = substr($row, 0, strlen($row) - 2);
$row .= '))';
} else {
// Seperate outer and inner polygons
$parts = explode("),(", $polygon);
foreach ($parts as $ring) {
$points_arr = $this->extractPoints($ring, null);
$row .= 'new OpenLayers.Geometry.LinearRing(new Array(';
foreach ($points_arr as $point) {
$row .= '(new OpenLayers.Geometry.Point('
. $point[0] . ', ' . $point[1] . '))'
. '.transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject()), ';
}
$row = substr($row, 0, strlen($row) - 2);
$row .= ')), ';
}
$row = substr($row, 0, strlen($row) - 2);
return 'new OpenLayers.Geometry.Polygon('
. $this->getLineArrayForOpenLayers($polygon, $srid, false)
. ')';
}
/**
* Generates JavaScript for adding an array of LineString
* or LineRing to OpenLayers.
*
* @param array $lines x and y coordinates for each line
* @param string $srid spatial reference id
* @param bool $is_line_string whether it's an array of LineString
*
* @return string JavaScript for adding an array of LineString
* or LineRing to OpenLayers
* @access protected
*/
protected function getLineArrayForOpenLayers($lines, $srid, $is_line_string = true)
{
$ol_array = 'new Array(';
foreach ($lines as $line) {
$points_arr = $this->extractPoints($line, null);
$ol_array .= $this->getLineForOpenLayers($points_arr, $srid, $is_line_string) . ', ';
}
$row .= ')), ';
return $row;
$ol_array = substr($ol_array, 0, strlen($ol_array) - 2);
$ol_array .= ')';
return $ol_array;
}
/**
* Generates JavaScript for adding a LineString or LineRing to OpenLayers.
*
* @param array $points_arr x and y coordinates for each point
* @param string $srid spatial reference id
* @param bool $is_line_string whether it's a LineString
*
* @return string JavaScript for adding a LineString or LineRing to OpenLayers
* @access protected
*/
protected function getLineForOpenLayers($points_arr, $srid, $is_line_string = true)
{
return 'new OpenLayers.Geometry.'
. ($is_line_string ? 'LineString' : 'LinearRing') . '('
. $this->getPointsArrayForOpenLayers($points_arr, $srid)
. ')';
}
/**
* Generates JavaScript for adding an array of points to OpenLayers.
*
* @param array $points_arr x and y coordinates for each point
* @param string $srid spatial reference id
*
* @return string JavaScript for adding an array of points to OpenLayers
* @access protected
*/
protected function getPointsArrayForOpenLayers($points_arr, $srid)
{
$ol_array = 'new Array(';
foreach ($points_arr as $point) {
$ol_array .= $this->getPointForOpenLayers($point, $srid) . ', ';
}
$ol_array = substr($ol_array, 0, strlen($ol_array) - 2);
$ol_array .= ')';
return $ol_array;
}
/**
* Generates JavaScript for adding a point to OpenLayers.
*
* @param array $point array containing the x and y coordinates of the point
* @param string $srid spatial reference id
*
* @return string JavaScript for adding points to OpenLayers
* @access protected
*/
protected function getPointForOpenLayers($point, $srid)
{
return '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))'
. '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject())';
}
}
?>

View File

@ -202,18 +202,9 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
$linesrting = substr($spatial, 11, (strlen($spatial) - 12));
$points_arr = $this->extractPoints($linesrting, null);
$row = 'new Array(';
foreach ($points_arr as $point) {
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', '
. $point[1] . ')).transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject()), ';
}
$row = substr($row, 0, strlen($row) - 2);
$row .= ')';
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
. 'new OpenLayers.Geometry.LineString(' . $row . '), null, '
. json_encode($style_options) . '));';
. $this->getLineForOpenLayers($points_arr, $srid)
. ', null, ' . json_encode($style_options) . '));';
return $result;
}

View File

@ -233,20 +233,9 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
$linestirngs = explode("),(", $multilinestirng);
$row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
. 'new OpenLayers.Geometry.MultiLineString(new Array(';
foreach ($linestirngs as $linestring) {
$points_arr = $this->extractPoints($linestring, null);
$row .= 'new OpenLayers.Geometry.LineString(new Array(';
foreach ($points_arr as $point) {
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', '
. $point[1] . ')).transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject()), ';
}
$row = substr($row, 0, strlen($row) - 2);
$row .= ')), ';
}
$row = substr($row, 0, strlen($row) - 2);
$row .= ')), null, ' . json_encode($style_options) . '));';
. 'new OpenLayers.Geometry.MultiLineString('
. $this->getLineArrayForOpenLayers($linestirngs, $srid)
. '), null, ' . json_encode($style_options) . '));';
return $row;
}

View File

@ -204,22 +204,10 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
$multipoint = substr($spatial, 11, (strlen($spatial) - 12));
$points_arr = $this->extractPoints($multipoint, null);
$row = 'new Array(';
foreach ($points_arr as $point) {
if ($point[0] != '' && $point[1] != '') {
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1]
. ')).transform(new OpenLayers.Projection("EPSG:' . $srid
. '"), map.getProjectionObject()), ';
}
}
if (substr($row, strlen($row) - 2) == ', ') {
$row = substr($row, 0, strlen($row) - 2);
}
$row .= ')';
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
. 'new OpenLayers.Geometry.MultiPoint(' . $row . '), null, '
. json_encode($style_options) . '));';
. 'new OpenLayers.Geometry.MultiPoint('
. $this->getPointsArrayForOpenLayers($points_arr, $srid)
. '), null, ' . json_encode($style_options) . '));';
return $result;
}

View File

@ -283,13 +283,9 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$polygons = explode(")),((", $multipolygon);
$row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
. 'new OpenLayers.Geometry.MultiPolygon(new Array(';
foreach ($polygons as $polygon) {
$row .= $this->addPointsForOpenLayersPolygon($polygon, $srid);
}
$row = substr($row, 0, strlen($row) - 2);
$row .= ')), null, ' . json_encode($style_options) . '));';
. 'new OpenLayers.Geometry.MultiPolygon('
. $this->getPolygonArrayForOpenLayers($polygons, $srid)
. '), null, ' . json_encode($style_options) . '));';
return $row;
}

View File

@ -195,10 +195,8 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
$points_arr = $this->extractPoints($point, null);
if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector(('
. 'new OpenLayers.Geometry.Point(' . $points_arr[0][0] . ', '
. $points_arr[0][1] . ').transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject())), null, '
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
. $this->getPointForOpenLayers($points_arr[0], $srid). ', null, '
. json_encode($style_options) . '));';
}
return $result;

View File

@ -246,9 +246,11 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = substr($spatial, 9, (strlen($spatial) - 11));
$row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector(';
$row .= $this->addPointsForOpenLayersPolygon($polygon, $srid);
$row .= 'null, ' . json_encode($style_options) . '));';
// Seperate outer and inner polygons
$parts = explode("),(", $polygon);
$row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
. $this->getPolygonForOpenLayers($parts, $srid)
. ', null, ' . json_encode($style_options) . '));';
return $row;
}