From 78b3ac810ffa023dbda8f30b696df77e1971d5ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 3 Feb 2018 22:23:24 -0200 Subject: [PATCH] Move CharEditing setting to constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- db_central_columns.php | 3 -- libraries/classes/CentralColumns.php | 47 ++++++++++++++-------------- test/classes/CentralColumnsTest.php | 3 -- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/db_central_columns.php b/db_central_columns.php index bc18cd1dad..ec00a61949 100644 --- a/db_central_columns.php +++ b/db_central_columns.php @@ -88,7 +88,6 @@ if (isset($_REQUEST['edit_central_columns_page'])) { $selected_fld = $_REQUEST['selected_fld']; $selected_db = $_REQUEST['db']; $edit_central_column_page = $centralColumns->getHtmlForEditingPage( - $GLOBALS['cfg']['CharEditing'], $GLOBALS['cfg']['Server']['DisableIS'], $selected_fld, $selected_db @@ -122,7 +121,6 @@ if (Core::isValid($_REQUEST['pos'], 'integer')) { $pos = 0; } $addNewColumn = $centralColumns->getHtmlForAddNewColumn( - $GLOBALS['cfg']['CharEditing'], $GLOBALS['cfg']['Server']['DisableIS'], $db, $total_rows @@ -167,7 +165,6 @@ $result = $centralColumns->getColumnsList($db, $pos, $max_rows); $row_num = 0; foreach ($result as $row) { $tableHtmlRow = $centralColumns->getHtmlForTableRow( - $GLOBALS['cfg']['CharEditing'], $GLOBALS['cfg']['Server']['DisableIS'], $row, $row_num, diff --git a/libraries/classes/CentralColumns.php b/libraries/classes/CentralColumns.php index ddded1f7ce..0888a306e9 100644 --- a/libraries/classes/CentralColumns.php +++ b/libraries/classes/CentralColumns.php @@ -43,6 +43,13 @@ class CentralColumns */ private $maxRows; + /** + * Which editor should be used for CHAR/VARCHAR fields + * + * @var string + */ + private $charEditing; + /** * Constructor * @@ -54,6 +61,7 @@ class CentralColumns $this->user = $GLOBALS['cfg']['Server']['user']; $this->maxRows = (int) $GLOBALS['cfg']['MaxRows']; + $this->charEditing = $GLOBALS['cfg']['CharEditing']; } /** @@ -750,7 +758,7 @@ class CentralColumns * * @return string html for table header in central columns view/edit page */ - public function getTableHeader($class='', $title='', $actionCount=0) + public function getTableHeader($class = '', $title = '', $actionCount = 0) { $action = ''; if ($actionCount > 0) { @@ -896,16 +904,14 @@ class CentralColumns /** * build html for a row in central columns table * - * @param string $charEditing which editor should be used for CHAR/VARCHAR fields - * @param boolean $disableIs Disable use of INFORMATION_SCHEMA - * @param array $row array contains complete information of a particular row of central list table - * @param int $row_num position the row in the table - * @param string $db current database + * @param boolean $disableIs Disable use of INFORMATION_SCHEMA + * @param array $row array contains complete information of a particular row of central list table + * @param int $row_num position the row in the table + * @param string $db current database * * @return string html of a particular row in the central columns table. */ public function getHtmlForTableRow( - $charEditing, $disableIs, array $row, $row_num, @@ -1003,7 +1009,7 @@ class CentralColumns 'ci_offset' => 0, 'type_upper' => mb_strtoupper($row['col_type']), 'column_meta' => $meta, - 'char_editing' => $charEditing, + 'char_editing' => $this->charEditing, ) ) . ''; @@ -1075,16 +1081,14 @@ class CentralColumns /** * build html for editing a row in central columns table * - * @param string $charEditing which editor should be used for CHAR/VARCHAR fields - * @param boolean $disableIs Disable use of INFORMATION_SCHEMA - * @param array $row array contains complete information of a - * particular row of central list table - * @param int $row_num position the row in the table + * @param boolean $disableIs Disable use of INFORMATION_SCHEMA + * @param array $row array contains complete information of a + * particular row of central list table + * @param int $row_num position the row in the table * * @return string html of a particular row in the central columns table. */ private function getHtmlForEditTableRow( - $charEditing, $disableIs, array $row, $row_num @@ -1154,7 +1158,7 @@ class CentralColumns 'ci_offset' => 0, 'type_upper' => mb_strtoupper($row['col_default']), 'column_meta' => $meta, - 'char_editing' => $charEditing, + 'char_editing' => $this->charEditing, ) ) . ''; @@ -1340,16 +1344,14 @@ class CentralColumns /** * build html for adding a new user defined column to central list * - * @param string $charEditing which editor should be used for CHAR/VARCHAR fields - * @param boolean $disableIs Disable use of INFORMATION_SCHEMA - * @param string $db current database - * @param integer $total_rows number of rows in central columns + * @param boolean $disableIs Disable use of INFORMATION_SCHEMA + * @param string $db current database + * @param integer $total_rows number of rows in central columns * * @return string html of the form to let user add a new user defined column to the * list */ public function getHtmlForAddNewColumn( - $charEditing, $disableIs, $db, $total_rows @@ -1412,7 +1414,7 @@ class CentralColumns 'ci_offset' => 0, 'type_upper' => '', 'column_meta' => array(), - 'char_editing' => $charEditing, + 'char_editing' => $this->charEditing, ) ) . '' @@ -1470,7 +1472,6 @@ class CentralColumns /** * Get HTML for editing page central columns * - * @param string $charEditing which editor should be used for CHAR/VARCHAR fields * @param boolean $disableIs Disable use of INFORMATION_SCHEMA * @param array $selected_fld Array containing the selected fields * @param string $selected_db String containing the name of database @@ -1478,7 +1479,6 @@ class CentralColumns * @return string HTML for complete editing page for central columns */ public function getHtmlForEditingPage( - $charEditing, $disableIs, array $selected_fld, $selected_db @@ -1499,7 +1499,6 @@ class CentralColumns $row_num = 0; foreach ($list_detail_cols as $row) { $tableHtmlRow = $this->getHtmlForEditTableRow( - $charEditing, $disableIs, $row, $row_num diff --git a/test/classes/CentralColumnsTest.php b/test/classes/CentralColumnsTest.php index 848a7c9b4c..d299a6e87a 100644 --- a/test/classes/CentralColumnsTest.php +++ b/test/classes/CentralColumnsTest.php @@ -435,7 +435,6 @@ class CentralColumnsTest extends TestCase $this->returnValue($this->columnData) ); $result = $this->centralColumns->getHtmlForEditingPage( - $GLOBALS['cfg']['CharEditing'], $GLOBALS['cfg']['Server']['DisableIS'], array("col1", "col2"), 'phpmyadmin' @@ -467,7 +466,6 @@ class CentralColumnsTest extends TestCase $this->callProtectedMethod( 'getHtmlForEditTableRow', [ - $GLOBALS['cfg']['CharEditing'], $GLOBALS['cfg']['Server']['DisableIS'], $list_detail_cols[0], 0, @@ -611,7 +609,6 @@ class CentralColumnsTest extends TestCase public function testGetHtmlForAddNewColumn() { $result = $this->centralColumns->getHtmlForAddNewColumn( - $GLOBALS['cfg']['CharEditing'], $GLOBALS['cfg']['Server']['DisableIS'], 'phpmyadmin', 0