From dba5237520255b60785034b513d67b502067b820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Thu, 16 Nov 2017 18:35:21 -0200 Subject: [PATCH 1/9] Use template for _getShowAllCheckboxForTableNavigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Results.php | 32 ++++++------------- .../display/results/show_all_checkbox.twig | 13 ++++++++ test/classes/Display/ResultsTest.php | 30 +++++++++++++---- 3 files changed, 47 insertions(+), 28 deletions(-) create mode 100644 templates/display/results/show_all_checkbox.twig diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index e01438264ba2..fc5a4b9d0add 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -1018,28 +1018,16 @@ private function _getMoveBackwardButtonsForTableNavigation( private function _getShowAllCheckboxForTableNavigation( $showing_all, $html_sql_query ) { - return "\n" - . '' - . '
' - . Url::getHiddenInputs( - $this->__get('db'), $this->__get('table') - ) - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '
' - . ''; + return Template::get('display/results/show_all_checkbox')->render([ + 'db' => $this->__get('db'), + 'table' => $this->__get('table'), + 'is_browse_distinct' => $this->__get('is_browse_distinct'), + 'goto' => $this->__get('goto'), + 'unique_id' => $this->__get('unique_id'), + 'html_sql_query' => $html_sql_query, + 'showing_all' => $showing_all, + 'max_rows' => intval($GLOBALS['cfg']['MaxRows']), + ]); } // end of the '_getShowAllButtonForTableNavigation()' function diff --git a/templates/display/results/show_all_checkbox.twig b/templates/display/results/show_all_checkbox.twig new file mode 100644 index 000000000000..ca740ce01ff9 --- /dev/null +++ b/templates/display/results/show_all_checkbox.twig @@ -0,0 +1,13 @@ + +
+ {{ Url_getHiddenInputs(db, table) }} + + + + + + + +
+ diff --git a/test/classes/Display/ResultsTest.php b/test/classes/Display/ResultsTest.php index ed0d820019b4..0eccbb7f7a2c 100644 --- a/test/classes/Display/ResultsTest.php +++ b/test/classes/Display/ResultsTest.php @@ -1197,12 +1197,30 @@ public function testGetShowAllCheckboxForTableNavigation( $this->object->__set('goto', $goto); $this->object->__set('unique_id', $unique_id); - $this->assertEquals( - $output, - $this->_callPrivateFunction( - '_getShowAllCheckboxForTableNavigation', - array(false, $html_sql_query) - ) + $result = $this->_callPrivateFunction( + '_getShowAllCheckboxForTableNavigation', + array(false, $html_sql_query) + ); + + $this->assertContains( + 'name="db" value="' . $db . '"', + $result + ); + $this->assertContains( + 'name="table" value="' . $table . '"', + $result + ); + $this->assertContains( + 'name="sql_query" value="' . $html_sql_query . '"', + $result + ); + $this->assertContains( + 'name="goto" value="' . $goto . '"', + $result + ); + $this->assertContains( + '', + $result ); } From 1852c2c4da69ba98b71cec42ddc330cb840ba995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 17 Nov 2017 15:09:18 -0200 Subject: [PATCH 2/9] Use template for _getAdditionalFieldsForTableNavigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Results.php | 42 +++++++------------ .../display/results/additional_fields.twig | 14 +++++++ .../display/results/show_all_checkbox.twig | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) create mode 100644 templates/display/results/additional_fields.twig diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index fc5a4b9d0add..014cd8df91a4 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -1098,30 +1098,16 @@ private function _getMoveForwardButtonsForTableNavigation( * Prepare fields for table navigation * Number of rows * - * @param string $html_sql_query the sql encoded by htmlspecialchars() + * @param string $sqlQuery the sql encoded by htmlspecialchars() * - * @return string $additional_fields_html html content + * @return string html content * * @access private * * @see _getTableNavigation() */ - private function _getAdditionalFieldsForTableNavigation( - $html_sql_query - ) { - - $additional_fields_html = ''; - - $additional_fields_html .= '' - . '' - . '' - . '' ; - + private function _getAdditionalFieldsForTableNavigation($sqlQuery) + { $numberOfRowsPlaceholder = null; if ($_SESSION['tmpval']['max_rows'] == self::ALL_ROWS) { $numberOfRowsPlaceholder = __('All'); @@ -1134,17 +1120,17 @@ private function _getAdditionalFieldsForTableNavigation( '250' => 250, '500' => 500 ); - $additional_fields_html .= __('Number of rows:') . ' '; - $additional_fields_html .= Util::getDropdown( - 'session_max_rows', $numberOfRowsChoices, - $_SESSION['tmpval']['max_rows'], '', - 'autosubmit', $numberOfRowsPlaceholder - ); - - return $additional_fields_html; - - } // end of the '_getAdditionalFieldsForTableNavigation()' function + return Template::get('display/results/additional_fields')->render([ + 'goto' => $this->__get('goto'), + 'is_browse_distinct' => $this->__get('is_browse_distinct'), + 'sql_query' => $sqlQuery, + 'number_of_rows_choices' => $numberOfRowsChoices, + 'number_of_rows_placeholder' => $numberOfRowsPlaceholder, + 'pos' => $_SESSION['tmpval']['pos'], + 'max_rows' => $_SESSION['tmpval']['max_rows'], + ]); + } /** * Get the headers of the results table, for all of the columns diff --git a/templates/display/results/additional_fields.twig b/templates/display/results/additional_fields.twig new file mode 100644 index 000000000000..745b3bbdcb30 --- /dev/null +++ b/templates/display/results/additional_fields.twig @@ -0,0 +1,14 @@ + + +{# Do not change the position when changing the number of rows #} + + +{% trans 'Number of rows:' %} +{{ Util_getDropdown( + 'session_max_rows', + number_of_rows_choices, + max_rows, + '', + 'autosubmit', + number_of_rows_placeholder +) }} diff --git a/templates/display/results/show_all_checkbox.twig b/templates/display/results/show_all_checkbox.twig index ca740ce01ff9..b2674d3893e8 100644 --- a/templates/display/results/show_all_checkbox.twig +++ b/templates/display/results/show_all_checkbox.twig @@ -1,7 +1,7 @@
{{ Url_getHiddenInputs(db, table) }} - + From dfa796be071d7d06dea67a9f5435b866e757f6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 17 Nov 2017 15:53:25 -0200 Subject: [PATCH 3/9] Use template for _getTableNavigationButton MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Results.php | 47 +++++++++---------- .../results/table_navigation_button.twig | 12 +++++ test/classes/Display/ResultsTest.php | 42 ++++++++--------- 3 files changed, 55 insertions(+), 46 deletions(-) create mode 100644 templates/display/results/table_navigation_button.twig diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index 014cd8df91a4..4a4cf9dabdc7 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -723,10 +723,15 @@ private function _isSelect(array $analyzed_sql_results) * _getMoveForwardButtonsForTableNavigation() */ private function _getTableNavigationButton( - $caption, $title, $pos, $html_sql_query, $back, $onsubmit = '', - $input_for_real_end = '', $onclick = '' + $caption, + $title, + $pos, + $html_sql_query, + $back, + $onsubmit = '', + $input_for_real_end = '', + $onclick = '' ) { - $caption_output = ''; if ($back) { if (Util::showIcons('TableNavigationLinksMode')) { @@ -743,29 +748,21 @@ private function _getTableNavigationButton( $caption_output .= ' ' . $caption; } } - $title_output = ' title="' . $title . '"'; - - return '' - . '' - . Url::getHiddenInputs( - $this->__get('db'), $this->__get('table') - ) - . '' - . '' - . '' - . '' - . $input_for_real_end - . '' - . '' - . ''; - - } // end function _getTableNavigationButton() + return Template::get('display/results/table_navigation_button')->render([ + 'db' => $this->__get('db'), + 'table' => $this->__get('table'), + 'sql_query' => $html_sql_query, + 'pos' => $pos, + 'is_browse_distinct' => $this->__get('is_browse_distinct'), + 'goto' => $this->__get('goto'), + 'input_for_real_end' => $input_for_real_end, + 'caption_output' => $caption_output, + 'title' => $title, + 'onsubmit' => $onsubmit, + 'onclick' => $onclick, + ]); + } /** * Possibly return a page selector for table navigation diff --git a/templates/display/results/table_navigation_button.twig b/templates/display/results/table_navigation_button.twig new file mode 100644 index 000000000000..eb4fa42e648e --- /dev/null +++ b/templates/display/results/table_navigation_button.twig @@ -0,0 +1,12 @@ + +
+ {{ Url_getHiddenInputs(db, table) }} + + + + + {{ input_for_real_end|raw }} + +
+ diff --git a/test/classes/Display/ResultsTest.php b/test/classes/Display/ResultsTest.php index 0eccbb7f7a2c..28b98abe0308 100644 --- a/test/classes/Display/ResultsTest.php +++ b/test/classes/Display/ResultsTest.php @@ -111,25 +111,37 @@ public function testisSelect() * @param string $title text for button * @param integer $pos position for next query * @param string $html_sql_query query ready for display - * @param string $output output from the _getTableNavigationButton - * method * * @return void * * @dataProvider providerForTestGetTableNavigationButton */ public function testGetTableNavigationButton( - $caption, $title, $pos, $html_sql_query, $output + $caption, $title, $pos, $html_sql_query ) { $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; $_SESSION[' PMA_token '] = 'token'; - $this->assertEquals( - $output, - $this->_callPrivateFunction( - '_getTableNavigationButton', - array(&$caption, $title, $pos, $html_sql_query, true) - ) + $actual = $this->_callPrivateFunction( + '_getTableNavigationButton', + array(&$caption, $title, $pos, $html_sql_query, true) + ); + + $this->assertContains( + '
', + $actual + ); + $this->assertContains( + 'name="sql_query" value="SELECT * FROM `pma_bookmark` WHERE 1"', + $actual + ); + $this->assertContains( + 'name="pos" value="1"', + $actual + ); + $this->assertContains( + 'value="btn" title="Submit"', + $actual ); } @@ -146,18 +158,6 @@ public function providerForTestGetTableNavigationButton() 'Submit', 1, 'SELECT * FROM `pma_bookmark` WHERE 1', - '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '
' ) ); } From f513738e7acba6c881619478c5fd24d6e6e32e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 18 Nov 2017 01:25:39 -0200 Subject: [PATCH 4/9] Use template for _getOptionsBlock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Results.php | 137 ++----------------- templates/display/results/options_block.twig | 99 ++++++++++++++ 2 files changed, 114 insertions(+), 122 deletions(-) create mode 100644 templates/display/results/options_block.twig diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index 4a4cf9dabdc7..858edfddbdc5 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -1667,137 +1667,30 @@ private function _getDataForResettingColumnOrder(array $analyzed_sql_results) /** * Prepare option fields block * - * @return string $options_html html content + * @return string html content * - * @access private + * @access private * - * @see _getTableHeaders() + * @see _getTableHeaders() */ private function _getOptionsBlock() { - - $options_html = ''; - - $options_html .= '
render([ + 'unique_id' => $this->__get('unique_id'), + 'geo_option' => $_SESSION['tmpval']['geoOption'], + 'hide_transformation' => $_SESSION['tmpval']['hide_transformation'], + 'display_blob' => $_SESSION['tmpval']['display_blob'], + 'display_binary' => $_SESSION['tmpval']['display_binary'], + 'relational_display' => $_SESSION['tmpval']['relational_display'], + 'displaywork' => $GLOBALS['cfgRelation']['displaywork'], + 'relwork' => $GLOBALS['cfgRelation']['relwork'], + 'pftext' => $_SESSION['tmpval']['pftext'], 'db' => $this->__get('db'), 'table' => $this->__get('table'), 'sql_query' => $this->__get('sql_query'), 'goto' => $this->__get('goto'), - 'display_options_form' => 1 - ); - - $options_html .= Url::getHiddenInputs($url_params) - . '
' - . Util::getDivForSliderEffect( - '', __('Options') - ) - . '
'; - - $options_html .= '
'; - $choices = array( - 'P' => __('Partial texts'), - 'F' => __('Full texts') - ); - - // pftext means "partial or full texts" (done to reduce line lengths) - $options_html .= Util::getRadioFields( - 'pftext', $choices, - $_SESSION['tmpval']['pftext'], - true, true, '', 'pftext_' . $this->__get('unique_id') - ) - . '
'; - - if ($GLOBALS['cfgRelation']['relwork'] - && $GLOBALS['cfgRelation']['displaywork'] - ) { - $options_html .= '
'; - $choices = array( - 'K' => __('Relational key'), - 'D' => __('Display column for relationships') - ); - - $options_html .= Util::getRadioFields( - 'relational_display', $choices, - $_SESSION['tmpval']['relational_display'], - true, true, '', 'relational_display_' . $this->__get('unique_id') - ) - . '
'; - } - - $options_html .= '
' - . Template::get('checkbox') - ->render( - array( - 'html_field_name' => 'display_binary', - 'label' => __('Show binary contents'), - 'checked' => ! empty($_SESSION['tmpval']['display_binary']), - 'onclick' => false, - 'html_field_id' => 'display_binary_' . $this->__get('unique_id'), - ) - ) - . '
' - . Template::get('checkbox') - ->render( - array( - 'html_field_name' => 'display_blob', - 'label' => __('Show BLOB contents'), - 'checked' => ! empty($_SESSION['tmpval']['display_blob']), - 'onclick' => false, - 'html_field_id' => 'display_blob_' . $this->__get('unique_id'), - ) - ) - . '
'; - - // I would have preferred to name this "display_transformation". - // This is the only way I found to be able to keep this setting sticky - // per SQL query, and at the same time have a default that displays - // the transformations. - $options_html .= '
' - . Template::get('checkbox') - ->render( - array( - 'html_field_name' => 'hide_transformation', - 'label' => __('Hide browser transformation'), - 'checked' => ! empty($_SESSION['tmpval']['hide_transformation']), - 'onclick' => false, - 'html_field_id' => 'hide_transformation_' . $this->__get('unique_id'), - ) - ) - . '
'; - - $options_html .= '
'; - $choices = array( - 'GEOM' => __('Geometry'), - 'WKT' => __('Well Known Text'), - 'WKB' => __('Well Known Binary') - ); - - $options_html .= Util::getRadioFields( - 'geoOption', $choices, - $_SESSION['tmpval']['geoOption'], - true, true, '', 'geoOption_' . $this->__get('unique_id') - ); - $options_html .= '
'; - - $options_html .= '
' - . '
'; - - $options_html .= '
' - . '' - . '
' - . '' - . '
'; - - return $options_html; - - } // end of the '_getOptionsBlock()' function - + ]); + } /** * Get full/partial text button or link diff --git a/templates/display/results/options_block.twig b/templates/display/results/options_block.twig new file mode 100644 index 000000000000..b713616ccb07 --- /dev/null +++ b/templates/display/results/options_block.twig @@ -0,0 +1,99 @@ + From fdf7cd75dbbb0b86c121bcfb42cd9f793a1c2425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 18 Nov 2017 21:29:02 -0200 Subject: [PATCH 5/9] Use template for _getFormForMultiRowOperations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Results.php | 39 ++++++------------- .../results/multi_row_operations_form.twig | 12 ++++++ 2 files changed, 23 insertions(+), 28 deletions(-) create mode 100644 templates/display/results/multi_row_operations_form.twig diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index 858edfddbdc5..6ceec80e59e4 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -1735,7 +1735,7 @@ private function _getFullOrPartialTextButtonOrLink() /** * Prepare html form for multi row operations * - * @param string $del_lnk the delete link of current row + * @param string $deleteLink the delete link of current row * * @return string $form_html html content * @@ -1743,34 +1743,17 @@ private function _getFullOrPartialTextButtonOrLink() * * @see _getTableHeaders() */ - private function _getFormForMultiRowOperations($del_lnk) + private function _getFormForMultiRowOperations($deleteLink) { - - $form_html = ''; - - if (($del_lnk == self::DELETE_ROW) || ($del_lnk == self::KILL_PROCESS)) { - - $form_html .= '
__get('db'), $this->__get('table'), 1 - ) - . ''; - } - - $form_html .= '
__get('unique_id') . '"'; - $form_html .= '>'; - - return $form_html; - - } // end of the '_getFormForMultiRowOperations()' function - + return Template::get('display/results/multi_row_operations_form')->render([ + 'delete_link' => $deleteLink, + 'delete_row' => self::DELETE_ROW, + 'kill_process' => self::KILL_PROCESS, + 'unique_id' => $this->__get('unique_id'), + 'db' => $this->__get('db'), + 'table' => $this->__get('table'), + ]); + } /** * Get comment for row diff --git a/templates/display/results/multi_row_operations_form.twig b/templates/display/results/multi_row_operations_form.twig new file mode 100644 index 000000000000..bf87c7e0d0cf --- /dev/null +++ b/templates/display/results/multi_row_operations_form.twig @@ -0,0 +1,12 @@ +{% if delete_link == delete_row or delete_link == kill_process %} + + {{ Url_getHiddenInputs(db, table, 1) }} + +{% endif %} + +
+
From 9d79d04af723b8831447d7c24cb6a8d908facc25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 18 Nov 2017 23:15:02 -0200 Subject: [PATCH 6/9] Use template for _getCommentForRow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Results.php | 40 ++++++------------- .../display/results/comment_for_row.twig | 10 +++++ 2 files changed, 22 insertions(+), 28 deletions(-) create mode 100644 templates/display/results/comment_for_row.twig diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index 6ceec80e59e4..854505ea067e 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -1758,39 +1758,23 @@ private function _getFormForMultiRowOperations($deleteLink) /** * Get comment for row * - * @param array $comments_map comments array - * @param array $fields_meta set of field properties + * @param array $commentsMap comments array + * @param array $fieldsMeta set of field properties * - * @return string $comment html content + * @return string html content * - * @access private + * @access private * - * @see _getTableHeaders() + * @see _getTableHeaders() */ - private function _getCommentForRow(array $comments_map, $fields_meta) + private function _getCommentForRow(array $commentsMap, $fieldsMeta) { - $comments = ''; - if (isset($comments_map[$fields_meta->table]) - && isset($comments_map[$fields_meta->table][$fields_meta->name]) - ) { - $sanitized_comments = htmlspecialchars( - $comments_map[$fields_meta->table][$fields_meta->name] - ); - - $comments = ''; - $limitChars = $GLOBALS['cfg']['LimitChars']; - if (mb_strlen($sanitized_comments) > $limitChars) { - $sanitized_comments = mb_substr( - $sanitized_comments, 0, $limitChars - ) . '…'; - } - $comments .= $sanitized_comments; - $comments .= ''; - } - return $comments; - } // end of the '_getCommentForRow()' function - + return Template::get('display/results/comment_for_row')->render([ + 'comments_map' => $commentsMap, + 'fields_meta' => $fieldsMeta, + 'limit_chars' => $GLOBALS['cfg']['LimitChars'], + ]); + } /** * Prepare parameters and html for sorted table header fields diff --git a/templates/display/results/comment_for_row.twig b/templates/display/results/comment_for_row.twig new file mode 100644 index 000000000000..5380b71dc01a --- /dev/null +++ b/templates/display/results/comment_for_row.twig @@ -0,0 +1,10 @@ +{% if comments_map[fields_meta.table] is defined + and comments_map[fields_meta.table][fields_meta.name] is defined %} + + {% if comments_map[fields_meta.table][fields_meta.name]|length > limit_chars %} + {{ comments_map[fields_meta.table][fields_meta.name]|slice(0, limit_chars) }}… + {% else %} + {{ comments_map[fields_meta.table][fields_meta.name] }} + {% endif %} + +{% endif %} From 70e9ec0fcd01f72d79eea3ebff9be45d908bb99a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 18 Nov 2017 23:40:56 -0200 Subject: [PATCH 7/9] Use template for _buildValueDisplay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Results.php | 18 ++++++++++-------- templates/display/results/value_display.twig | 3 +++ test/classes/Display/ResultsTest.php | 11 +++++++---- 3 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 templates/display/results/value_display.twig diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index 854505ea067e..88be9626b90a 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -2339,9 +2339,9 @@ private function _getColumnAtRightSide( /** * Prepares the display for a value * - * @param string $class class of table cell - * @param bool $condition_field whether to add CSS class condition - * @param string $value value to display + * @param string $class class of table cell + * @param bool $conditionField whether to add CSS class condition + * @param string $value value to display * * @return string the td * @@ -2350,12 +2350,14 @@ private function _getColumnAtRightSide( * @see _getDataCellForGeometryColumns(), * _getDataCellForNonNumericColumns() */ - private function _buildValueDisplay($class, $condition_field, $value) + private function _buildValueDisplay($class, $conditionField, $value) { - return ''; - } // end of the '_buildValueDisplay()' function - + return Template::get('display/results/value_display')->render([ + 'class' => $class, + 'condition_field' => $conditionField, + 'value' => $value, + ]); + } /** * Prepares the display for a null value diff --git a/templates/display/results/value_display.twig b/templates/display/results/value_display.twig new file mode 100644 index 000000000000..35640b91ca51 --- /dev/null +++ b/templates/display/results/value_display.twig @@ -0,0 +1,3 @@ + diff --git a/test/classes/Display/ResultsTest.php b/test/classes/Display/ResultsTest.php index 28b98abe0308..87cde0cf5699 100644 --- a/test/classes/Display/ResultsTest.php +++ b/test/classes/Display/ResultsTest.php @@ -1491,11 +1491,13 @@ public function dataProviderForTestGetDataCellForNonNumericColumns() array(), 0, 'binary', - '' + . 'class="disableAjax">[BLOB - 4 B]' . PHP_EOL + . '' . PHP_EOL ), array( 'noblob', @@ -1512,8 +1514,9 @@ public function dataProviderForTestGetDataCellForNonNumericColumns() array(), 0, 'binary', - '' + '' . PHP_EOL ), array( 'noblob', From bdb35e57692ef84b466e2dc1dcb4825789eeb867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sun, 19 Nov 2017 00:21:12 -0200 Subject: [PATCH 8/9] Use template for _buildNullDisplay method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Results.php | 26 ++++++++++----------- templates/display/results/null_display.twig | 7 ++++++ test/classes/Display/ResultsTest.php | 8 +++++-- 3 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 templates/display/results/null_display.twig diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index 88be9626b90a..19a5cd649671 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -2362,10 +2362,10 @@ private function _buildValueDisplay($class, $conditionField, $value) /** * Prepares the display for a null value * - * @param string $class class of table cell - * @param bool $condition_field whether to add CSS class condition - * @param object $meta the meta-information about this field - * @param string $align cell alignment + * @param string $class class of table cell + * @param bool $conditionField whether to add CSS class condition + * @param object $meta the meta-information about this field + * @param string $align cell alignment * * @return string the td * @@ -2375,18 +2375,16 @@ private function _buildValueDisplay($class, $conditionField, $value) * _getDataCellForGeometryColumns(), * _getDataCellForNonNumericColumns() */ - private function _buildNullDisplay($class, $condition_field, $meta, $align = '') + private function _buildNullDisplay($class, $conditionField, $meta, $align = '') { - // the null class is needed for grid editing - $decimals = isset($meta->decimals) ? $meta->decimals : '-1'; - return ''; - } // end of the '_buildNullDisplay()' function + $classes = $this->_addClass($class, $conditionField, $meta, ''); + return Template::get('display/results/null_display')->render([ + 'align' => $align, + 'meta' => $meta, + 'classes' => $classes, + ]); + } /** * Prepares the display for an empty value diff --git a/templates/display/results/null_display.twig b/templates/display/results/null_display.twig new file mode 100644 index 000000000000..f2ea2e5f2fe4 --- /dev/null +++ b/templates/display/results/null_display.twig @@ -0,0 +1,7 @@ + diff --git a/test/classes/Display/ResultsTest.php b/test/classes/Display/ResultsTest.php index 87cde0cf5699..f620c358d719 100644 --- a/test/classes/Display/ResultsTest.php +++ b/test/classes/Display/ResultsTest.php @@ -1533,8 +1533,12 @@ public function dataProviderForTestGetDataCellForNonNumericColumns() array(), 0, 0, - '' + '' . PHP_EOL ), array( 'all', From f50cac4d86c001a965d05594bfd6ae28a13998d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sun, 19 Nov 2017 00:36:22 -0200 Subject: [PATCH 9/9] Use template for _buildEmptyDisplay method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Results.php | 22 ++++++++++---------- templates/display/results/empty_display.twig | 1 + 2 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 templates/display/results/empty_display.twig diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index 19a5cd649671..10050acb23e7 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -2389,10 +2389,10 @@ private function _buildNullDisplay($class, $conditionField, $meta, $align = '') /** * Prepares the display for an empty value * - * @param string $class class of table cell - * @param bool $condition_field whether to add CSS class condition - * @param object $meta the meta-information about this field - * @param string $align cell alignment + * @param string $class class of table cell + * @param bool $conditionField whether to add CSS class condition + * @param object $meta the meta-information about this field + * @param string $align cell alignment * * @return string the td * @@ -2402,15 +2402,15 @@ private function _buildNullDisplay($class, $conditionField, $meta, $align = '') * _getDataCellForGeometryColumns(), * _getDataCellForNonNumericColumns() */ - private function _buildEmptyDisplay($class, $condition_field, $meta, $align = '') + private function _buildEmptyDisplay($class, $conditionField, $meta, $align = '') { - return ''; - } // end of the '_buildEmptyDisplay()' function + $classes = $this->_addClass($class, $conditionField, $meta, 'nowrap'); + return Template::get('display/results/empty_display')->render([ + 'align' => $align, + 'classes' => $classes, + ]); + } /** * Adds the relevant classes. diff --git a/templates/display/results/empty_display.twig b/templates/display/results/empty_display.twig new file mode 100644 index 000000000000..cd43ebc756ec --- /dev/null +++ b/templates/display/results/empty_display.twig @@ -0,0 +1 @@ +
' . $value . ' + {{ value|raw }} +' . PHP_EOL + . ' [BLOB - 4 B]' - . '1001' . PHP_EOL + . ' 1001' . PHP_EOL + . 'NULL + NULL +NULL' . PHP_EOL + . ' NULL' . PHP_EOL + . '