rfe #1146 Show original size of truncated columns

Signed-off-by: Marc Delisle <marc@infomarc.info>
This commit is contained in:
Marc Delisle 2015-04-30 09:42:24 -04:00
parent 4ab6f29302
commit bb7a254ce4
5 changed files with 61 additions and 25 deletions

View File

@ -28,6 +28,7 @@ phpMyAdmin - ChangeLog
+ rfe Option groups for 'With selected' dropdown in database structure page
+ rfe #1661 Support checksum table
+ rfe #1380 Support for Paramaters with raw SQL
+ rfe #1146 Show original size of truncated columns
4.4.5.0 (not yet released)
- bug Table overhead stats: missing space before the unit

View File

@ -1863,7 +1863,15 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
* Initialize grid
******************/
// wrap all data cells, except actions cell, with span
// wrap all truncated data cells with span indicating the original length
// todo update the original length after a grid edit
$(t).find('td.data.truncated:not(:has(span))')
.wrapInner(function() {
return '<span title="' + PMA_messages.strOriginalLength + ' '
+ $(this).data('originallength') + '"></span>';
});
// wrap remaining cells, except actions cell, with span
$(t).find('th, td:not(:has(span))')
.wrapInner('<span />');

View File

@ -457,6 +457,7 @@ $js_messages['strShowAllCol'] = __('Show all');
$js_messages['strAlertNonUnique'] = __('This table does not contain a unique column. Features related to the grid edit, checkbox, Edit, Copy and Delete links may not work after saving.');
$js_messages['strEnterValidHex'] = __('Please enter a valid hexadecimal string. Valid characters are 0-9, A-F.');
$js_messages['strShowAllRowsWarning'] = __('Do you really want to see all of the rows? For a big table this could crash the browser.');
$js_messages['strOriginalLength'] = __('Original length');
/** Drag & Drop sql import messages */
$js_messages['dropImportMessageCancel'] = __('cancel');

View File

@ -3604,7 +3604,7 @@ class PMA_DisplayResults
$analyzed_sql, $meta, $map, $column,
$transformation_plugin, $default_function, $nowrap,
$where_comparison, $transform_options,
$is_field_truncated
$is_field_truncated, ''
);
} else {
@ -3677,13 +3677,17 @@ class PMA_DisplayResults
// Convert to WKT format
$wktval = PMA_Util::asWKT($column);
$is_field_truncated = $this->_getPartialText($wktval);
list(
$is_field_truncated,
$wktval,
// skip 3rd param
) = $this->_getPartialText($wktval);
$cell = $this->_getRowData(
$class, $condition_field, $analyzed_sql, $meta, $map,
$wktval, $transformation_plugin, $default_function, '',
$where_comparison, $transform_options,
$is_field_truncated
$is_field_truncated, ''
);
return $cell;
}
@ -3694,14 +3698,18 @@ class PMA_DisplayResults
$where_comparison = ' = ' . $column;
$wkbval = substr(bin2hex($column), 8);
$is_field_truncated = $this->_getPartialText($wkbval);
list(
$is_field_truncated,
$wkbval,
// skip 3rd param
) = $this->_getPartialText($wkbval);
$cell = $this->_getRowData(
$class, $condition_field,
$analyzed_sql, $meta, $map, $wkbval,
$transformation_plugin, $default_function, '',
$where_comparison, $transform_options,
$is_field_truncated
$is_field_truncated, ''
);
return $cell;
}
@ -3795,7 +3803,11 @@ class PMA_DisplayResults
&& strpos($transformation_plugin->getName(), 'Link') !== false)
&& !stristr($field_flags, self::BINARY_FIELD)
) {
$is_field_truncated = $this->_getPartialText($column);
list(
$is_field_truncated,
$column,
$original_length
) = $this->_getPartialText($column);
}
$formatted = false;
@ -3863,7 +3875,7 @@ class PMA_DisplayResults
$analyzed_sql, $meta, $map, $column,
$transformation_plugin, $default_function, $nowrap,
$where_comparison, $transform_options,
$is_field_truncated
$is_field_truncated, $original_length
);
return $cell;
@ -5168,7 +5180,11 @@ class PMA_DisplayResults
) {
// in this case, restart from the original $content
$result = bin2hex($content);
$is_truncated = $this->_getPartialText($result);
list(
$is_truncated,
$result,
// skip 3rd param
) = $this->_getPartialText($result);
}
/* Create link to download */
@ -5205,6 +5221,7 @@ class PMA_DisplayResults
* @param string $where_comparison data for the where clause
* @param array $transform_options options for transformation
* @param bool $is_field_truncated whether the field is truncated
* @param string $original_length of a truncated column, or ''
*
* @return string formatted data
*
@ -5217,14 +5234,21 @@ class PMA_DisplayResults
private function _getRowData(
$class, $condition_field, $analyzed_sql, $meta, $map, $data,
$transformation_plugin, $default_function, $nowrap, $where_comparison,
$transform_options, $is_field_truncated
$transform_options, $is_field_truncated, $original_length=''
) {
$relational_display = $_SESSION['tmpval']['relational_display'];
$printview = $this->__get('printview');
$decimals = isset($meta->decimals) ? $meta->decimals : '-1';
$result = '<td data-decimals="' . $decimals . '" data-type="'
. $meta->type . '" class="'
$result = '<td data-decimals="' . $decimals . '"'
. ' data-type="' . $meta->type . '"';
if (! empty($original_length)) {
// cannot use data-original-length
$result .= ' data-originallength="' . $original_length . '"';
}
$result .= ' class="'
. $this->_addClass(
$class, $condition_field, $meta, $nowrap,
$is_field_truncated, $transformation_plugin, $default_function
@ -5641,34 +5665,35 @@ class PMA_DisplayResults
} // end of the '_getCheckboxAndLinks()' function
/**
* Truncates given string based on LimitChars configuration
* and Session pftext variable
* (string is truncated only if necessary)
*
* @param string &$str string to be truncated
* @param string $str string to be truncated
*
* @return boolean true if truncated, otherwise false
* @return mixed
*
* @access private
*
* @see _handleNonPrintableContents(), _getDataCellForGeometryColumns(),
* _getDataCellForNonNumericColumns
*/
private function _getPartialText(&$str)
private function _getPartialText($str)
{
if (/*overload*/mb_strlen($str) > $GLOBALS['cfg']['LimitChars']
$original_length = /*overload*/mb_strlen($str);
if ($original_length > $GLOBALS['cfg']['LimitChars']
&& $_SESSION['tmpval']['pftext'] === self::DISPLAY_PARTIAL_TEXT
) {
$str = /*overload*/mb_substr(
$str, 0, $GLOBALS['cfg']['LimitChars']
) . '...';
return true;
$truncated = true;
} else {
$truncated = false;
}
return false;
return array($truncated, $str, $original_length);
}
}

View File

@ -1423,10 +1423,10 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase
public function dataProviderForTestGetPartialText()
{
return array(
array('P', 10, 'foo', false),
array('P', 1, 'foo', true),
array('F', 10, 'foo', false),
array('F', 1, 'foo', false)
array('P', 10, 'foo', array(false, 'foo', 3)),
array('P', 1, 'foo', array(true, 'f...', 3)),
array('F', 10, 'foo', array(false, 'foo', 3)),
array('F', 1, 'foo', array(false, 'foo', 3))
);
}
@ -1451,7 +1451,7 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase
$output,
$this->_callPrivateFunction(
'_getPartialText',
array(&$str)
array($str)
)
);
}
@ -1676,6 +1676,7 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase
0,
0,
'<td data-decimals="0" data-type="string" '
. 'data-originallength="11" '
. 'class="grid_edit ">foo bar baz</td>' . "\n"
)
);