diff --git a/ChangeLog b/ChangeLog index 556bdcdece..dc68762949 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/js/makegrid.js b/js/makegrid.js index fc4d5f15ec..cae3a6a5e8 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -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 ''; + }); + + // wrap remaining cells, except actions cell, with span $(t).find('th, td:not(:has(span))') .wrapInner(''); diff --git a/js/messages.php b/js/messages.php index 1f83075fbc..bce0d84041 100644 --- a/js/messages.php +++ b/js/messages.php @@ -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'); diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 2c3a1cc3a9..1fe8934d89 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -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 = '_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); } } diff --git a/test/classes/PMA_DisplayResults_test.php b/test/classes/PMA_DisplayResults_test.php index 977d0f27ee..1db9aefe54 100644 --- a/test/classes/PMA_DisplayResults_test.php +++ b/test/classes/PMA_DisplayResults_test.php @@ -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, 'foo bar baz' . "\n" ) );