Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2012-08-13 11:44:54 +02:00
commit c1a70c49bf
4 changed files with 427 additions and 63 deletions

View File

@ -183,7 +183,7 @@ class PMA_DisplayResults
*/
public function __get($property)
{
if(array_key_exists($property, $this->_property_array)) {
if (array_key_exists($property, $this->_property_array)) {
return $this->_property_array[$property];
}
}
@ -193,13 +193,13 @@ class PMA_DisplayResults
* Set values for any property of this class
*
* @param string $property name of the property
* @param $value value to set
* @param any $value value to set
*
* @return void
*/
public function __set($property, $value)
{
if(array_key_exists($property, $this->_property_array)) {
if (array_key_exists($property, $this->_property_array)) {
$this->_property_array[$property] = $value;
}
}
@ -858,8 +858,8 @@ class PMA_DisplayResults
$onsubmit = 'onsubmit="return '
. ($_SESSION['tmp_user_values']['pos']
+ $_SESSION['tmp_user_values']['max_rows']
< $this->__get('_unlim_num_rows')
+ $_SESSION['tmp_user_values']['max_rows']
< $this->__get('_unlim_num_rows')
&& $this->__get('_num_rows') >= $_SESSION['tmp_user_values']['max_rows'])
? 'true'
: 'false' . '"';
@ -951,11 +951,12 @@ class PMA_DisplayResults
/**
* Get the headers of the results table
*
* @param array &$is_display which elements to display
* @param array $analyzed_sql the analyzed query
* @param string $sort_expression sort expression
* @param string $sort_expression_nodirection sort expression without direction
* @param string $sort_direction sort direction
* @param array &$is_display which elements to display
* @param array $analyzed_sql the analyzed query
* @param string $sort_expression sort expression
* @param string $sort_expression_nodirection sort expression without direction
* @param string $sort_direction sort direction
* @param boolean $is_limited_display with limited operations or not
*
* @return string html content
*
@ -2438,11 +2439,12 @@ class PMA_DisplayResults
/**
* Prepare the body of the results table
*
* @param integer &$dt_result the link id associated to the query
* which results have to be displayed
* @param array &$is_display which elements to display
* @param array $map the list of relations
* @param array $analyzed_sql the analyzed query
* @param integer &$dt_result the link id associated to the query
* which results have to be displayed
* @param array &$is_display which elements to display
* @param array $map the list of relations
* @param array $analyzed_sql the analyzed query
* @param boolean $is_limited_display with limited operations or not
*
* @return string $table_body_html html content
*
@ -2795,17 +2797,16 @@ class PMA_DisplayResults
) {
$parsed_sql = PMA_SQP_parse($row[$i]);
$row[$i] = PMA_CommonFunctions::getInstance()->formatSql($parsed_sql, $row[$i]);
$row[$i] = PMA_CommonFunctions::getInstance()->formatSql(
$parsed_sql, $row[$i]
);
include_once $this->sytax_highlighting_column_info[strtolower($this->__get('_db'))][strtolower($this->__get('_table'))][strtolower($meta->name)][0];
$transformation_plugin = new $this->sytax_highlighting_column_info[strtolower($this->__get('_db'))][strtolower($this->__get('_table'))][strtolower($meta->name)][1](null);
$transform_options = PMA_transformation_getOptions(
isset($mime_map[$meta->name]
['transformation_options']
)
? $mime_map[$meta->name]
['transformation_options']
: ''
isset($mime_map[$meta->name]['transformation_options'])
? $mime_map[$meta->name]['transformation_options']
: ''
);
$meta->mimetype = str_replace(
@ -2822,7 +2823,9 @@ class PMA_DisplayResults
&& ($this->_isFieldNeedToLink(strtolower($meta->name)))
) {
$linking_url = $this->_getSpecialLinkUrl($row[$i], $row_info, strtolower($meta->name));
$linking_url = $this->_getSpecialLinkUrl(
$row[$i], $row_info, strtolower($meta->name)
);
include_once "libraries/plugins/transformations/Text_Plain_Link.class.php";
$transformation_plugin = new Text_Plain_Link(null);
@ -3036,7 +3039,8 @@ class PMA_DisplayResults
*
* @return boolean
*/
private function _isNeedToSytaxHighlight($field) {
private function _isNeedToSytaxHighlight($field)
{
if (! empty($this->sytax_highlighting_column_info[strtolower($this->__get('_db'))][strtolower($this->__get('_table'))][strtolower($field)])) {
return true;
}
@ -3050,7 +3054,8 @@ class PMA_DisplayResults
*
* @return boolean
*/
private function _isFieldNeedToLink($field) {
private function _isFieldNeedToLink($field)
{
if (! empty($GLOBALS['special_schema_links'][strtolower($this->__get('_db'))][strtolower($this->__get('_table'))][$field])) {
return true;
}
@ -3071,14 +3076,19 @@ class PMA_DisplayResults
{
$linking_url_params = array();
$link_relations = $GLOBALS['special_schema_links'][strtolower($this->__get('_db'))][strtolower($this->__get('_table'))][$field_name];
$link_relations = $GLOBALS['special_schema_links']
[strtolower($this->__get('_db'))]
[strtolower($this->__get('_table'))]
[$field_name];
if (! is_array($link_relations['link_param'])) {
$linking_url_params[$link_relations['link_param']] = $column_value;
} else {
// Consider only the case of creating link for column field
// sql query need to be pass as url param
$sql = 'SELECT `'.$column_value.'` FROM `'. $row_info[$link_relations['link_param'][1]] .'`.`'. $row_info[$link_relations['link_param'][2]] .'`';
$sql = 'SELECT `'.$column_value.'` FROM `'
. $row_info[$link_relations['link_param'][1]] .'`.`'
. $row_info[$link_relations['link_param'][2]] .'`';
$linking_url_params[$link_relations['link_param'][0]] = $sql;
}
@ -3090,13 +3100,16 @@ class PMA_DisplayResults
// If param_info is an array, set the key and value
// from that array
if (is_array($new_param['param_info'])) {
$linking_url_params[$new_param['param_info'][0]] = $new_param['param_info'][1];
$linking_url_params[$new_param['param_info'][0]]
= $new_param['param_info'][1];
} else {
$linking_url_params[$new_param['param_info']] = $row_info[strtolower($new_param['column_name'])];
$linking_url_params[$new_param['param_info']]
= $row_info[strtolower($new_param['column_name'])];
// Special case 1 - when executing routines, according
// to the type of the routine, url param changes
if (!empty($row_info['routine_type'])){
if (!empty($row_info['routine_type'])) {
if (strtolower($row_info['routine_type']) == self::ROUTINE_PROCEDURE) {
$linking_url_params['execute_routine'] = 1;
} else if (strtolower($row_info['routine_type']) == self::ROUTINE_FUNCTION) {
@ -3109,7 +3122,8 @@ class PMA_DisplayResults
}
return $link_relations['default_page'] . PMA_generate_common_url($linking_url_params);
return $link_relations['default_page']
. PMA_generate_common_url($linking_url_params);
}
@ -3644,7 +3658,6 @@ class PMA_DisplayResults
if ((PMA_strlen($column) > $GLOBALS['cfg']['LimitChars'])
&& ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT)
&& ! $this->_isNeedToSytaxHighlight(strtolower($meta->name))
) {
$column = PMA_substr($column, 0, $GLOBALS['cfg']['LimitChars'])
. '...';
@ -4434,12 +4447,13 @@ class PMA_DisplayResults
* Prepare a table of results returned by a SQL query.
* This function is called by the "sql.php" script.
*
* @param integer &$dt_result the link id associated to the query
* which results have to be displayed
* @param array &$the_disp_mode the display mode
* @param array $analyzed_sql the analyzed query
* @param integer &$dt_result the link id associated to the query
* which results have to be displayed
* @param array &$the_disp_mode the display mode
* @param array $analyzed_sql the analyzed query
* @param boolean $is_limited_display With limited operations or not
*
* @return sting Generated HTML content for resulted table
* @return sting $table_html Generated HTML content for resulted table
*
* @access public
*
@ -5070,7 +5084,8 @@ class PMA_DisplayResults
$links_html .= "\n";
$links_html .= '<input type="hidden" name="sql_query"'
.' value="' . htmlspecialchars($this->__get('_sql_query')) . '" />' . "\n";
.' value="' . htmlspecialchars($this->__get('_sql_query')) . '" />'
. "\n";
if (! empty($url_query)) {
$links_html .= '<input type="hidden" name="url_query"'

View File

@ -1257,6 +1257,45 @@ function printServerTraffic()
} else {
$full_text_link = 'server_status.php' . PMA_generate_common_url(array('full' => 1));
}
// This array contains display name and real column name of each
// sortable column in the table
$sortable_columns = array(
array(
'column_name' => __('ID'),
'order_by_field' => 'Id'
),
array(
'column_name' => __('User'),
'order_by_field' => 'User'
),
array(
'column_name' => __('Host'),
'order_by_field' => 'Host'
),
array(
'column_name' => __('Database'),
'order_by_field' => 'db'
),
array(
'column_name' => __('Command'),
'order_by_field' => 'Command'
),
array(
'column_name' => __('Time'),
'order_by_field' => 'Time'
),
array(
'column_name' => __('Status'),
'order_by_field' => 'State'
),
array(
'column_name' => __('SQL query'),
'order_by_field' => 'Info'
)
);
$sortable_columns_count = count($sortable_columns);
if (PMA_DRIZZLE) {
$sql_query = "SELECT
p.id AS Id,
@ -1269,47 +1308,102 @@ function printServerTraffic()
" . ($show_full_sql ? 's.query' : 'left(p.info, ' . (int)$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')') . " AS Info
FROM data_dictionary.PROCESSLIST p
" . ($show_full_sql ? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' : '');
if (!empty($_REQUEST['order_by_field'])
&& !empty($_REQUEST['sort_order'])
) {
$sql_query .= ' ORDER BY p.' . $_REQUEST['order_by_field'] . ' ' . $_REQUEST['sort_order'];
}
} else {
$sql_query = $show_full_sql
? 'SHOW FULL PROCESSLIST'
: 'SHOW PROCESSLIST';
if (!empty($_REQUEST['order_by_field'])
&& !empty($_REQUEST['sort_order'])
) {
$sql_query = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ORDER BY `'
. $_REQUEST['order_by_field'] . '` ' . $_REQUEST['sort_order'];
}
}
$result = PMA_DBI_query($sql_query);
/**
* Displays the page
*/
?>
<table id="tableprocesslist" class="data clearfloat noclick">
<table id="tableprocesslist" class="data clearfloat noclick sortable">
<thead>
<tr>
<th><?php echo __('Processes'); ?></th>
<th><?php echo __('ID'); ?></th>
<th><?php echo __('User'); ?></th>
<th><?php echo __('Host'); ?></th>
<th><?php echo __('Database'); ?></th>
<th><?php echo __('Command'); ?></th>
<th><?php echo __('Time'); ?></th>
<th><?php echo __('Status'); ?></th>
<th><?php
echo __('SQL query');
if (! PMA_DRIZZLE) {
<tr>
<th><?php echo __('Processes'); ?></th>
<?php foreach ($sortable_columns as $column): ?>
<?php
$is_sorted = !empty($_REQUEST['order_by_field'])
&& !empty($_REQUEST['sort_order'])
&& ($_REQUEST['order_by_field'] == $column['order_by_field']);
$column['sort_order'] = ($is_sorted
&& ($_REQUEST['sort_order'] == 'ASC'))
? 'DESC'
: 'ASC';
if ($is_sorted) {
if ($_REQUEST['sort_order'] == 'ASC') {
$asc_display_style = 'inline';
$desc_display_style = 'none';
} elseif ($_REQUEST['sort_order'] == 'DESC') {
$desc_display_style = 'inline';
$asc_display_style = 'none';
}
}
?>
<a href="<?php echo $full_text_link; ?>"
title="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?>">
<img src="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . ($show_full_sql ? 'partial' : 'full'); ?>text.png"
alt="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?>" />
</a>
<?php
}
?>
</th>
</tr>
<th>
<a href="server_status.php<?php echo PMA_generate_common_url($column) ?>"
<?php if ($is_sorted): ?>
onmouseout="$('.soimg').toggle()" onmouseover="$('.soimg').toggle()"
<?php endif; ?>
>
<?php echo $column['column_name']; ?>
<?php if ($is_sorted): ?>
<img class="icon ic_s_desc soimg" alt="Descending" title="" src="themes/dot.gif" style="display: <?php echo $desc_display_style; ?>;" />
<img class="icon ic_s_asc soimg hide" alt="Ascending" title="" src="themes/dot.gif" style="display: <?php echo $asc_display_style; ?>;" />
<?php endif; ?>
</a>
<?php if (! PMA_DRIZZLE && (0 === --$sortable_columns_count)): ?>
<a href="<?php echo $full_text_link; ?>"
title="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?>">
<img src="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . ($show_full_sql ? 'partial' : 'full'); ?>text.png"
alt="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?>" />
</a>
<?php endif; ?>
</th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php
$odd_row = true;
while ($process = PMA_DBI_fetch_assoc($result)) {
// Array keys need to modify due to the way it has used
// to display column values
if (!empty($_REQUEST['order_by_field'])
&& !empty($_REQUEST['sort_order'])
) {
foreach (array_keys($process) as $key) {
$new_key = ucfirst(strtolower($key));
$process[$new_key] = $process[$key];
unset($process[$key]);
}
}
$url_params['kill'] = $process['Id'];
$kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
?>

View File

@ -1397,6 +1397,261 @@ class PMA_DisplayResults_test extends PHPUnit_Framework_TestCase
)
);
}
/**
* Data provider for testIsNeedToSytaxHighlight
*
* @return array parameters and output
*/
public function dataProviderForTestIsNeedToSytaxHighlight()
{
return array(
array(
'information_schema',
'processlist',
array(
'information_schema' => array(
'processlist' => array(
'info' => array(
'libraries/plugins/transformations/Text_Plain_Formatted.class.php',
'Text_Plain_Formatted',
'Text_Plain'
)
)
)
),
'info',
true
),
array(
'incorrect_database',
'processlist',
array(
'information_schema' => array(
'processlist' => array(
'info' => array(
'libraries/plugins/transformations/Text_Plain_Formatted.class.php',
'Text_Plain_Formatted',
'Text_Plain'
)
)
)
),
'info',
false
)
);
}
/**
* Test _isNeedToSytaxHighlight
*
* @param string $db the database name
* @param string $table the table name
* @param array $data predifined data of columns need to sytax highlighted
* @param string $field the field name
* @param boolean $output output of _isNeedToSytaxHighlight
*
* @dataProvider dataProviderForTestIsNeedToSytaxHighlight
*/
public function testIsNeedToSytaxHighlight($db, $table, $data, $field, $output)
{
$this->object->__set('_db', $db);
$this->object->__set('_table', $table);
$this->object->__set('sytax_highlighting_column_info', $data);
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_isNeedToSytaxHighlight',
array($field)
)
);
}
/**
* Data provider for testIsFieldNeedToLink
*
* @return array parameters and output
*/
public function dataProviderForTestIsFieldNeedToLink()
{
return array(
array(
'mysql',
'proc',
'db',
true
),
array(
'incorrect_database',
'processlist',
'info',
false
)
);
}
/**
* Test _isFieldNeedToLink
*
* @param string $db the database name
* @param string $table the table name
* @param string $field the field name
* @param boolean $output output of _isFieldNeedToLink
*
* @dataProvider dataProviderForTestIsFieldNeedToLink
*/
public function testIsFieldNeedToLink($db, $table, $field, $output)
{
$GLOBALS['special_schema_links'] = array(
'mysql' => array(
'proc' => array(
'db' => array(
'link_param' => 'db',
'default_page' => 'index.php'
)
)
)
);
$this->object->__set('_db', $db);
$this->object->__set('_table', $table);
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_isFieldNeedToLink',
array($field)
)
);
}
/**
* Data provider for testGetSpecialLinkUrl
*
* @return array parameters and output
*/
public function dataProviderForTestGetSpecialLinkUrl()
{
return array(
array(
'information_schema',
'routines',
'circumference',
array(
'routine_name' => 'circumference',
'routine_schema' => 'data',
'routine_type' => 'FUNCTION'
),
'routine_name',
'db_routines.php?item_name=circumference&amp;db=data&amp;execute_dialog=1&amp;item_type=FUNCTION&amp;lang=en&amp;token=token'
),
array(
'information_schema',
'routines',
'area',
array(
'routine_name' => 'area',
'routine_schema' => 'data',
'routine_type' => 'PROCEDURE'
),
'routine_name',
'db_routines.php?item_name=area&amp;db=data&amp;execute_routine=1&amp;item_type=PROCEDURE&amp;lang=en&amp;token=token'
),
array(
'information_schema',
'columns',
'CHARACTER_SET_NAME',
array(
'table_schema' => 'information_schema',
'table_name' => 'CHARACTER_SETS'
),
'column_name',
'index.php?sql_query=SELECT+%60CHARACTER_SET_NAME%60+FROM+%60information_schema%60.%60CHARACTER_SETS%60&amp;db=information_schema&amp;test_name=value&amp;lang=en&amp;token=token'
)
);
}
/**
* Test _getSpecialLinkUrl
*
* @param string $db the database name
* @param string $table the table name
* @param string $column_value column value
* @param array $row_info information about row
* @param string $field_name column name
* @param boolean $output output of _getSpecialLinkUrl
*
* @dataProvider dataProviderForTestGetSpecialLinkUrl
*/
public function testGetSpecialLinkUrl(
$db, $table, $column_value, $row_info, $field_name, $output
) {
$GLOBALS['special_schema_links'] = array(
'information_schema' => array(
'routines' => array(
'routine_name' => array(
'link_param' => 'item_name',
'link_dependancy_params' => array(
0 => array(
'param_info' => 'db',
'column_name' => 'routine_schema'
),
1 => array(
'param_info' => 'item_type',
'column_name' => 'routine_type'
)
),
'default_page' => 'db_routines.php'
)
),
'columns' => array(
'column_name' => array(
'link_param' => array(
'sql_query',
'table_schema',
'table_name'
),
'link_dependancy_params' => array(
0 => array(
'param_info' => 'db',
'column_name' => 'table_schema'
),
1 => array(
'param_info' => array('test_name', 'value')
)
),
'default_page' => 'index.php'
)
)
)
);
$this->object->__set('_db', $db);
$this->object->__set('_table', $table);
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getSpecialLinkUrl',
array($column_value, $row_info, $field_name)
)
);
}
}

View File

@ -60,7 +60,7 @@
.ui-widget .ui-widget { font-size: 1em; }
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; }
.ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; color: #222222; }
.ui-widget-content a { color: #222222; }
.ui-widget-content a { color: #235A81; }
.ui-widget-header { border: 1px solid #aaaaaa; background: #cccccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x; color: #222222; font-weight: bold; }
.ui-widget-header a { color: #222222; }