From ac91ba03c551357875095becef306044b19fcdff Mon Sep 17 00:00:00 2001 From: Bimal Yashodha Date: Mon, 17 Mar 2014 20:16:32 +0530 Subject: [PATCH 1/5] Refactor - Move duplicate code to a parent class Signed-off-by: Bimal Yashodha --- .../schema/Dia_Relation_Schema.class.php | 116 ++++-------- .../schema/Eps_Relation_Schema.class.php | 110 ++++------- .../schema/Pdf_Relation_Schema.class.php | 105 ++++------- .../schema/Svg_Relation_Schema.class.php | 114 ++++-------- libraries/schema/TableStats.class.php | 174 ++++++++++++++++++ 5 files changed, 312 insertions(+), 307 deletions(-) create mode 100644 libraries/schema/TableStats.class.php diff --git a/libraries/schema/Dia_Relation_Schema.class.php b/libraries/schema/Dia_Relation_Schema.class.php index 8309d08e3d..bb7ee6e848 100644 --- a/libraries/schema/Dia_Relation_Schema.class.php +++ b/libraries/schema/Dia_Relation_Schema.class.php @@ -187,6 +187,8 @@ class PMA_DIA extends XMLWriter } } +require_once './libraries/schema/TableStats.class.php'; + /** * Table preferences/statistics * @@ -197,15 +199,11 @@ class PMA_DIA extends XMLWriter * @name Table_Stats_Dia * @see PMA_DIA */ -class Table_Stats_Dia +class Table_Stats_Dia extends TableStats { /** * Defines properties */ - public $tableName; - public $fields = array(); - public $x, $y; - public $primary = array(); public $tableId; public $tableColor; @@ -226,80 +224,8 @@ class Table_Stats_Dia function __construct($tableName, $pageNumber, $showKeys = false) { global $dia, $cfgRelation, $db; + parent::__construct($dia, $db, $pageNumber, $tableName, $showKeys, false); - $this->tableName = $tableName; - $sql = 'DESCRIBE ' . PMA_Util::backquote($tableName); - $result = $GLOBALS['dbi']->tryQuery( - $sql, null, PMA_DatabaseInterface::QUERY_STORE - ); - if (! $result || ! $GLOBALS['dbi']->numRows($result)) { - $dia->dieSchema( - $pageNumber, "DIA", - sprintf(__('The %s table doesn\'t exist!'), $tableName) - ); - } - /* - * load fields - * check to see if it will load all fields or only the foreign keys - */ - if ($showKeys) { - $indexes = PMA_Index::getFromTable($this->tableName, $db); - $all_columns = array(); - foreach ($indexes as $index) { - $all_columns = array_merge( - $all_columns, - array_flip(array_keys($index->getColumns())) - ); - } - $this->fields = array_keys($all_columns); - } else { - while ($row = $GLOBALS['dbi']->fetchRow($result)) { - $this->fields[] = $row[0]; - } - } - - $sql = 'SELECT x, y FROM ' - . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_Util::backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\'' - . ' AND table_name = \'' - . PMA_Util::sqlAddSlashes($tableName) . '\'' - . ' AND pdf_page_number = ' . $pageNumber; - $result = PMA_queryAsControlUser( - $sql, false, PMA_DatabaseInterface::QUERY_STORE - ); - if (! $result || ! $GLOBALS['dbi']->numRows($result)) { - $dia->dieSchema( - $pageNumber, - "DIA", - sprintf( - __('Please configure the coordinates for table %s'), - $tableName - ) - ); - } - list($this->x, $this->y) = $GLOBALS['dbi']->fetchRow($result); - $this->x = (double) $this->x; - $this->y = (double) $this->y; - /* - * displayfield - */ - $this->displayfield = PMA_getDisplayField($db, $tableName); - /* - * index - */ - $result = $GLOBALS['dbi']->query( - 'SHOW INDEX FROM ' . PMA_Util::backquote($tableName) . ';', - null, - PMA_DatabaseInterface::QUERY_STORE - ); - if ($GLOBALS['dbi']->numRows($result) > 0) { - while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { - if ($row['Key_name'] == 'PRIMARY') { - $this->primary[] = $row['Column_name']; - } - } - } /** * Every object in Dia document needs an ID to identify * so, we used a static variable to keep the things unique @@ -308,6 +234,38 @@ class Table_Stats_Dia $this->tableId = PMA_Dia_Relation_Schema::$objectId; } + /** + * Displays an error when the table cannot be found. + * + * @return void + */ + protected function showMissingTableError() + { + $this->diagram->dieSchema( + $this->pageNumber, + "DIA", + sprintf(__('The %s table doesn\'t exist!'), $this->tableName) + ); + } + + /** + * Diaplays an error on missing coordinates + * + * @return void + */ + protected function showMissingCoordinatesError() + { + $this->diagram->dieSchema( + $this->pageNumber, + "DIA", + sprintf( + __('Please configure the coordinates for table %s'), + $this->tableName + ) + ); + } + + /** * Do draw the table * @@ -385,7 +343,7 @@ class Table_Stats_Dia - #' . $this->tableName . '# + #' . $this->_tableName . '# ## diff --git a/libraries/schema/Eps_Relation_Schema.class.php b/libraries/schema/Eps_Relation_Schema.class.php index f32102d039..30548c5ac4 100644 --- a/libraries/schema/Eps_Relation_Schema.class.php +++ b/libraries/schema/Eps_Relation_Schema.class.php @@ -297,6 +297,8 @@ class PMA_EPS } } +require_once './libraries/schema/TableStats.class.php'; + /** * Table preferences/statistics * @@ -307,22 +309,15 @@ class PMA_EPS * @name Table_Stats_Eps * @see PMA_EPS */ -class Table_Stats_Eps +class Table_Stats_Eps extends TableStats { /** * Defines properties */ - - private $_tableName; - private $_showInfo = false; - public $width = 0; public $height; - public $fields = array(); public $heightCell = 0; public $currentCell = 0; - public $x, $y; - public $primary = array(); /** * The "Table_Stats_Eps" constructor @@ -350,88 +345,49 @@ class Table_Stats_Eps $showKeys = false, $showInfo = false ) { global $eps, $cfgRelation, $db; - - $this->_tableName = $tableName; - $sql = 'DESCRIBE ' . PMA_Util::backquote($tableName); - $result = $GLOBALS['dbi']->tryQuery( - $sql, null, PMA_DatabaseInterface::QUERY_STORE + parent::__construct( + $esp, $db, $pageNumber, $tableName, $showKeys, $showInfo ); - if (! $result || ! $GLOBALS['dbi']->numRows($result)) { - $eps->dieSchema( - $pageNumber, "EPS", - sprintf(__('The %s table doesn\'t exist!'), $tableName) - ); - } - - /* - * load fields - * check to see if it will load all fields or only the foreign keys - */ - if ($showKeys) { - $indexes = PMA_Index::getFromTable($this->_tableName, $db); - $all_columns = array(); - foreach ($indexes as $index) { - $all_columns = array_merge( - $all_columns, - array_flip(array_keys($index->getColumns())) - ); - } - $this->fields = array_keys($all_columns); - } else { - while ($row = $GLOBALS['dbi']->fetchRow($result)) { - $this->fields[] = $row[0]; - } - } - - $this->_showInfo = $showInfo; // height and width $this->_setHeightTable($fontSize); - // setWidth must me after setHeight, because title // can include table height which changes table width $this->_setWidthTable($font, $fontSize); if ($same_wide_width < $this->width) { $same_wide_width = $this->width; } + } - // x and y - $sql = 'SELECT x, y FROM ' - . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_Util::backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\'' - . ' AND table_name = \'' . PMA_Util::sqlAddSlashes($tableName) . '\'' - . ' AND pdf_page_number = ' . $pageNumber; - $result = PMA_queryAsControlUser( - $sql, false, PMA_DatabaseInterface::QUERY_STORE + /** + * Displays an error when the table cannot be found. + * + * @return void + */ + protected function showMissingTableError() + { + $this->diagram->dieSchema( + $this->pageNumber, + "EPS", + sprintf(__('The %s table doesn\'t exist!'), $this->tableName) ); + } - if (! $result || ! $GLOBALS['dbi']->numRows($result)) { - $eps->dieSchema( - $pageNumber, "EPS", - sprintf( - __('Please configure the coordinates for table %s'), - $tableName - ) - ); - } - list($this->x, $this->y) = $GLOBALS['dbi']->fetchRow($result); - $this->x = (double) $this->x; - $this->y = (double) $this->y; - // displayfield - $this->displayfield = PMA_getDisplayField($db, $tableName); - // index - $result = $GLOBALS['dbi']->query( - 'SHOW INDEX FROM ' . PMA_Util::backquote($tableName) . ';', - null, PMA_DatabaseInterface::QUERY_STORE + /** + * Diaplays an error on missing coordinates + * + * @return void + */ + protected function showMissingCoordinatesError() + { + $this->diagram->dieSchema( + $this->pageNumber, + "EPS", + sprintf( + __('Please configure the coordinates for table %s'), + $this->tableName + ) ); - if ($GLOBALS['dbi']->numRows($result) > 0) { - while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { - if ($row['Key_name'] == 'PRIMARY') { - $this->primary[] = $row['Column_name']; - } - } - } } /** @@ -443,7 +399,7 @@ class Table_Stats_Eps */ private function _getTitle() { - return ($this->_showInfo + return ($this->showInfo ? sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->heightCell) : '') . ' ' . $this->_tableName; diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php index 93def6ebb0..e5e79c003e 100644 --- a/libraries/schema/Pdf_Relation_Schema.class.php +++ b/libraries/schema/Pdf_Relation_Schema.class.php @@ -358,6 +358,8 @@ class PMA_Schema_PDF extends PMA_PDF } } +require_once './libraries/schema/TableStats.class.php'; + /** * Table preferences/statistics * @@ -368,21 +370,15 @@ class PMA_Schema_PDF extends PMA_PDF * @package PhpMyAdmin * @see PMA_Schema_PDF */ -class Table_Stats_Pdf +class Table_Stats_Pdf extends TableStats { /** * Defines properties */ - private $_tableName; - private $_showInfo = false; - public $nb_fiels; public $width = 0; public $height; - public $fields = array(); public $heightCell = 6; - public $x, $y; - public $primary = array(); private $_ff = PMA_PDF_FONT; /** @@ -407,34 +403,10 @@ class Table_Stats_Pdf $showKeys = false, $showInfo = false ) { global $pdf, $cfgRelation, $db; - - $this->_tableName = $tableName; - $sql = 'DESCRIBE ' . PMA_Util::backquote($tableName); - $result = $GLOBALS['dbi']->tryQuery( - $sql, null, PMA_DatabaseInterface::QUERY_STORE + parent::__construct( + $pdf, $db, $pageNumber, $tableName, $showKeys, $showInfo ); - if (! $result || ! $GLOBALS['dbi']->numRows($result)) { - $pdf->Error(sprintf(__('The %s table doesn\'t exist!'), $tableName)); - } - // load fields - //check to see if it will load all fields or only the foreign keys - if ($showKeys) { - $indexes = PMA_Index::getFromTable($this->_tableName, $db); - $all_columns = array(); - foreach ($indexes as $index) { - $all_columns = array_merge( - $all_columns, - array_flip(array_keys($index->getColumns())) - ); - } - $this->fields = array_keys($all_columns); - } else { - while ($row = $GLOBALS['dbi']->fetchRow($result)) { - $this->fields[] = $row[0]; - } - } - $this->_showInfo = $showInfo; $this->_setHeight(); /* * setWidth must me after setHeight, because title @@ -444,44 +416,37 @@ class Table_Stats_Pdf if ($sameWideWidth < $this->width) { $sameWideWidth = $this->width; } - $sql = 'SELECT x, y FROM ' - . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_Util::backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\'' - . ' AND table_name = \'' . PMA_Util::sqlAddSlashes($tableName) . '\'' - . ' AND pdf_page_number = ' . $pageNumber; - $result = PMA_queryAsControlUser( - $sql, false, PMA_DatabaseInterface::QUERY_STORE + } + + /** + * Displays an error when the table cannot be found. + * + * @return void + */ + protected function showMissingTableError() + { + $this->diagram->dieSchema( + $this->pageNumber, + "PDF", + sprintf(__('The %s table doesn\'t exist!'), $this->tableName) ); - if (! $result || ! $GLOBALS['dbi']->numRows($result)) { - $pdf->Error( - sprintf( - __('Please configure the coordinates for table %s'), - $tableName - ) - ); - } - list($this->x, $this->y) = $GLOBALS['dbi']->fetchRow($result); - $this->x = (double) $this->x; - $this->y = (double) $this->y; - /* - * displayfield - */ - $this->displayfield = PMA_getDisplayField($db, $tableName); - /* - * index - */ - $result = $GLOBALS['dbi']->query( - 'SHOW INDEX FROM ' . PMA_Util::backquote($tableName) . ';', - null, PMA_DatabaseInterface::QUERY_STORE + } + + /** + * Diaplays an error on missing coordinates + * + * @return void + */ + protected function showMissingCoordinatesError() + { + $this->diagram->dieSchema( + $this->pageNumber, + "PDF", + sprintf( + __('Please configure the coordinates for table %s'), + $this->tableName + ) ); - if ($GLOBALS['dbi']->numRows($result) > 0) { - while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { - if ($row['Key_name'] == 'PRIMARY') { - $this->primary[] = $row['Column_name']; - } - } - } } /** @@ -493,7 +458,7 @@ class Table_Stats_Pdf private function _getTitle() { $ret = ''; - if ($this->_showInfo) { + if ($this->showInfo) { $ret = sprintf('%.0fx%0.f', $this->width, $this->height); } return $ret . ' ' . $this->_tableName; diff --git a/libraries/schema/Svg_Relation_Schema.class.php b/libraries/schema/Svg_Relation_Schema.class.php index 72b5ffc6fa..fc86e15c4e 100644 --- a/libraries/schema/Svg_Relation_Schema.class.php +++ b/libraries/schema/Svg_Relation_Schema.class.php @@ -263,6 +263,8 @@ class PMA_SVG extends XMLWriter } } +require_once './libraries/schema/TableStats.class.php'; + /** * Table preferences/statistics * @@ -273,22 +275,15 @@ class PMA_SVG extends XMLWriter * @name Table_Stats_Svg * @see PMA_SVG */ -class Table_Stats_Svg +class Table_Stats_Svg extends TableStats { /** * Defines properties */ - - private $_tableName; - private $_showInfo = false; - public $width = 0; public $height; - public $fields = array(); public $heightCell = 0; public $currentCell = 0; - public $x, $y; - public $primary = array(); /** * The "Table_Stats_Svg" constructor @@ -317,92 +312,49 @@ class Table_Stats_Svg &$same_wide_width, $showKeys = false, $showInfo = false ) { global $svg, $cfgRelation, $db; - - $this->_tableName = $tableName; - $sql = 'DESCRIBE ' . PMA_Util::backquote($tableName); - $result = $GLOBALS['dbi']->tryQuery( - $sql, null, PMA_DatabaseInterface::QUERY_STORE + parent::__construct( + $svg, $db, $pageNumber, $tableName, $showKeys, $showInfo ); - if (! $result || ! $GLOBALS['dbi']->numRows($result)) { - $svg->dieSchema( - $pageNumber, - "SVG", - sprintf(__('The %s table doesn\'t exist!'), $tableName) - ); - } - - /* - * load fields - * check to see if it will load all fields or only the foreign keys - */ - - if ($showKeys) { - $indexes = PMA_Index::getFromTable($this->_tableName, $db); - $all_columns = array(); - foreach ($indexes as $index) { - $all_columns = array_merge( - $all_columns, - array_flip(array_keys($index->getColumns())) - ); - } - $this->fields = array_keys($all_columns); - } else { - while ($row = $GLOBALS['dbi']->fetchRow($result)) { - $this->fields[] = $row[0]; - } - } - - $this->_showInfo = $showInfo; // height and width $this->_setHeightTable($fontSize); - // setWidth must me after setHeight, because title // can include table height which changes table width $this->_setWidthTable($font, $fontSize); if ($same_wide_width < $this->width) { $same_wide_width = $this->width; } + } - // x and y - $sql = 'SELECT x, y FROM ' - . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_Util::backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\'' - . ' AND table_name = \'' . PMA_Util::sqlAddSlashes($tableName) . '\'' - . ' AND pdf_page_number = ' . $pageNumber; - $result = PMA_queryAsControlUser( - $sql, false, PMA_DatabaseInterface::QUERY_STORE + /** + * Displays an error when the table cannot be found. + * + * @return void + */ + protected function showMissingTableError() + { + $this->diagram->dieSchema( + $this->pageNumber, + "SVG", + sprintf(__('The %s table doesn\'t exist!'), $this->tableName) ); + } - if (! $result || ! $GLOBALS['dbi']->numRows($result)) { - $svg->dieSchema( - $pageNumber, - "SVG", - sprintf( - __('Please configure the coordinates for table %s'), - $tableName - ) - ); - } - list($this->x, $this->y) = $GLOBALS['dbi']->fetchRow($result); - $this->x = (double) $this->x; - $this->y = (double) $this->y; - // displayfield - $this->displayfield = PMA_getDisplayField($db, $tableName); - // index - $result = $GLOBALS['dbi']->query( - 'SHOW INDEX FROM ' . PMA_Util::backquote($tableName) . ';', - null, - PMA_DatabaseInterface::QUERY_STORE + /** + * Diaplays an error on missing coordinates + * + * @return void + */ + protected function showMissingCoordinatesError() + { + $this->diagram->dieSchema( + $this->pageNumber, + "SVG", + sprintf( + __('Please configure the coordinates for table %s'), + $this->tableName + ) ); - if ($GLOBALS['dbi']->numRows($result) > 0) { - while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { - if ($row['Key_name'] == 'PRIMARY') { - $this->primary[] = $row['Column_name']; - } - } - } } /** @@ -414,7 +366,7 @@ class Table_Stats_Svg */ private function _getTitle() { - return ($this->_showInfo + return ($this->showInfo ? sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->heightCell) : '' diff --git a/libraries/schema/TableStats.class.php b/libraries/schema/TableStats.class.php new file mode 100644 index 0000000000..a0f2b37f35 --- /dev/null +++ b/libraries/schema/TableStats.class.php @@ -0,0 +1,174 @@ +diagram = $diagram; + $this->db = $db; + $this->pageNumber = $pageNumber; + $this->tableName = $tableName; + + $this->showKeys = $showKeys; + $this->showInfo = $showInfo; + + // checks whether the table exists + // and loads fields + $this->validateTableAndLoadFields(); + // load table coordinates + $this->loadCoordinates(); + // loads display field + $this->loadDisplayField(); + // loads primary keys + $this->loadPrimaryKey(); + } + + /** + * Validate whether the table exists. + * + * @return void + */ + protected function validateTableAndLoadFields() + { + $sql = 'DESCRIBE ' . PMA_Util::backquote($this->tableName); + $result = $GLOBALS['dbi']->tryQuery( + $sql, null, PMA_DatabaseInterface::QUERY_STORE + ); + if (! $result || ! $GLOBALS['dbi']->numRows($result)) { + $this->showMissingTableError(); + } + + if ($this->showKeys) { + $indexes = PMA_Index::getFromTable($this->tableName, $this->db); + $all_columns = array(); + foreach ($indexes as $index) { + $all_columns = array_merge( + $all_columns, + array_flip(array_keys($index->getColumns())) + ); + } + $this->fields = array_keys($all_columns); + } else { + while ($row = $GLOBALS['dbi']->fetchRow($result)) { + $this->fields[] = $row[0]; + } + } + } + + /** + * Displays an error when the table cannot be found. + * + * @return void + * @abstract + */ + protected abstract function showMissingTableError(); + + /** + * Loads coordinates of a table + * + * @return void + */ + protected function loadCoordinates() + { + global $cfgRelation; + + $sql = "SELECT x, y FROM " + . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . "." + . PMA_Util::backquote($cfgRelation['table_coords']) + . " WHERE db_name = '" . PMA_Util::sqlAddSlashes($this->db) . "'" + . " AND table_name = '" . PMA_Util::sqlAddSlashes($this->tableName) . "'" + . " AND pdf_page_number = " . $this->pageNumber; + $result = PMA_queryAsControlUser( + $sql, false, PMA_DatabaseInterface::QUERY_STORE + ); + if (! $result || ! $GLOBALS['dbi']->numRows($result)) { + $this->showMissingCoordinatesError(); + } + list($this->x, $this->y) = $GLOBALS['dbi']->fetchRow($result); + $this->x = (double) $this->x; + $this->y = (double) $this->y; + } + + /** + * Diaplays an error on missing coordinates + * + * @return void + * @abstract + */ + protected abstract function showMissingCoordinatesError(); + + /** + * Loads the table's display field + * + * @return void + */ + protected function loadDisplayField() + { + $this->displayField = PMA_getDisplayField($this->db, $this->tableName); + } + + /** + * Loads the PRIMARY key. + * + * @return void + */ + protected function loadPrimaryKey() + { + $result = $GLOBALS['dbi']->query( + 'SHOW INDEX FROM ' . PMA_Util::backquote($this->tableName) . ';', + null, PMA_DatabaseInterface::QUERY_STORE + ); + if ($GLOBALS['dbi']->numRows($result) > 0) { + while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { + if ($row['Key_name'] == 'PRIMARY') { + $this->primary[] = $row['Column_name']; + } + } + } + } +} +?> \ No newline at end of file From 860aa89510c7a5c7d53a5b3be62a7ceba8073a45 Mon Sep 17 00:00:00 2001 From: Bimal Yashodha Date: Wed, 19 Mar 2014 19:33:24 +0530 Subject: [PATCH 2/5] Update references to new variable names Signed-off-by: Bimal Yashodha --- libraries/schema/Dia_Relation_Schema.class.php | 2 +- libraries/schema/Eps_Relation_Schema.class.php | 6 +++--- libraries/schema/Pdf_Relation_Schema.class.php | 14 +++++++------- libraries/schema/Svg_Relation_Schema.class.php | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libraries/schema/Dia_Relation_Schema.class.php b/libraries/schema/Dia_Relation_Schema.class.php index bb7ee6e848..3b40cdcf45 100644 --- a/libraries/schema/Dia_Relation_Schema.class.php +++ b/libraries/schema/Dia_Relation_Schema.class.php @@ -343,7 +343,7 @@ class Table_Stats_Dia extends TableStats - #' . $this->_tableName . '# + #' . $this->tableName . '# ## diff --git a/libraries/schema/Eps_Relation_Schema.class.php b/libraries/schema/Eps_Relation_Schema.class.php index 30548c5ac4..b391f867e3 100644 --- a/libraries/schema/Eps_Relation_Schema.class.php +++ b/libraries/schema/Eps_Relation_Schema.class.php @@ -346,7 +346,7 @@ class Table_Stats_Eps extends TableStats ) { global $eps, $cfgRelation, $db; parent::__construct( - $esp, $db, $pageNumber, $tableName, $showKeys, $showInfo + $eps, $db, $pageNumber, $tableName, $showKeys, $showInfo ); // height and width @@ -402,7 +402,7 @@ class Table_Stats_Eps extends TableStats return ($this->showInfo ? sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->heightCell) - : '') . ' ' . $this->_tableName; + : '') . ' ' . $this->tableName; } /** @@ -466,7 +466,7 @@ class Table_Stats_Eps extends TableStats public function tableDraw($showColor) { global $eps; - //echo $this->_tableName.'
'; + //echo $this->tableName.'
'; $eps->rect($this->x, $this->y + 12, $this->width, $this->heightCell, 1); $eps->showXY($this->_getTitle(), $this->x + 5, $this->y + 14); foreach ($this->fields as $field) { diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php index e5e79c003e..baf979dba4 100644 --- a/libraries/schema/Pdf_Relation_Schema.class.php +++ b/libraries/schema/Pdf_Relation_Schema.class.php @@ -461,7 +461,7 @@ class Table_Stats_Pdf extends TableStats if ($this->showInfo) { $ret = sprintf('%.0fx%0.f', $this->width, $this->height); } - return $ret . ' ' . $this->_tableName; + return $ret . ' ' . $this->tableName; } /** @@ -534,9 +534,9 @@ class Table_Stats_Pdf extends TableStats $pdf->SetFillColor(0, 0, 128); } if ($withDoc) { - $pdf->SetLink($pdf->PMA_links['RT'][$this->_tableName]['-'], -1); + $pdf->SetLink($pdf->PMA_links['RT'][$this->tableName]['-'], -1); } else { - $pdf->PMA_links['doc'][$this->_tableName]['-'] = ''; + $pdf->PMA_links['doc'][$this->tableName]['-'] = ''; } $pdf->cellScale( @@ -547,7 +547,7 @@ class Table_Stats_Pdf extends TableStats 1, 'C', $setColor, - $pdf->PMA_links['doc'][$this->_tableName]['-'] + $pdf->PMA_links['doc'][$this->tableName]['-'] ); $pdf->setXScale($this->x); $pdf->SetFont($this->_ff, '', $fontSize); @@ -564,9 +564,9 @@ class Table_Stats_Pdf extends TableStats } } if ($withDoc) { - $pdf->SetLink($pdf->PMA_links['RT'][$this->_tableName][$field], -1); + $pdf->SetLink($pdf->PMA_links['RT'][$this->tableName][$field], -1); } else { - $pdf->PMA_links['doc'][$this->_tableName][$field] = ''; + $pdf->PMA_links['doc'][$this->tableName][$field] = ''; } $pdf->cellScale( @@ -577,7 +577,7 @@ class Table_Stats_Pdf extends TableStats 1, 'L', $setColor, - $pdf->PMA_links['doc'][$this->_tableName][$field] + $pdf->PMA_links['doc'][$this->tableName][$field] ); $pdf->setXScale($this->x); $pdf->SetFillColor(255); diff --git a/libraries/schema/Svg_Relation_Schema.class.php b/libraries/schema/Svg_Relation_Schema.class.php index fc86e15c4e..b343013246 100644 --- a/libraries/schema/Svg_Relation_Schema.class.php +++ b/libraries/schema/Svg_Relation_Schema.class.php @@ -370,7 +370,7 @@ class Table_Stats_Svg extends TableStats ? sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->heightCell) : '' - ) . ' ' . $this->_tableName; + ) . ' ' . $this->tableName; } /** @@ -436,7 +436,7 @@ class Table_Stats_Svg extends TableStats public function tableDraw($showColor) { global $svg; - //echo $this->_tableName.'
'; + //echo $this->tableName.'
'; $svg->printElement( 'rect', $this->x, $this->y, $this->width, $this->heightCell, null, 'fill:red;stroke:black;' From ccde0e70bdcbad640d9a1c846435ede1839842dc Mon Sep 17 00:00:00 2001 From: Bimal Yashodha Date: Wed, 19 Mar 2014 23:08:22 +0530 Subject: [PATCH 3/5] Rename the field to its old value Signed-off-by: Bimal Yashodha --- libraries/schema/TableStats.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/schema/TableStats.class.php b/libraries/schema/TableStats.class.php index a0f2b37f35..5c945d117f 100644 --- a/libraries/schema/TableStats.class.php +++ b/libraries/schema/TableStats.class.php @@ -28,7 +28,7 @@ abstract class TableStats protected $showKeys; protected $showInfo; - public $displayField; + public $displayfield; public $fields = array(); public $primary = array(); public $x, $y; @@ -148,7 +148,7 @@ abstract class TableStats */ protected function loadDisplayField() { - $this->displayField = PMA_getDisplayField($this->db, $this->tableName); + $this->displayfield = PMA_getDisplayField($this->db, $this->tableName); } /** From b362d0e8b608bad5fa988eb3caf8e74a2511b629 Mon Sep 17 00:00:00 2001 From: Bimal Yashodha Date: Thu, 20 Mar 2014 22:48:22 +0530 Subject: [PATCH 4/5] Move getTitle() method to parent class Signed-off-by: Bimal Yashodha --- .../schema/Eps_Relation_Schema.class.php | 21 ++---------------- .../schema/Pdf_Relation_Schema.class.php | 9 ++++---- .../schema/Svg_Relation_Schema.class.php | 22 ++----------------- libraries/schema/TableStats.class.php | 17 ++++++++++++++ 4 files changed, 25 insertions(+), 44 deletions(-) diff --git a/libraries/schema/Eps_Relation_Schema.class.php b/libraries/schema/Eps_Relation_Schema.class.php index b391f867e3..031139fad0 100644 --- a/libraries/schema/Eps_Relation_Schema.class.php +++ b/libraries/schema/Eps_Relation_Schema.class.php @@ -314,9 +314,7 @@ class Table_Stats_Eps extends TableStats /** * Defines properties */ - public $width = 0; public $height; - public $heightCell = 0; public $currentCell = 0; /** @@ -390,21 +388,6 @@ class Table_Stats_Eps extends TableStats ); } - /** - * Returns title of the current table, - * title can have the dimensions/co-ordinates of the table - * - * @return string The relation/table name - * @access private - */ - private function _getTitle() - { - return ($this->showInfo - ? sprintf('%.0f', $this->width) . 'x' - . sprintf('%.0f', $this->heightCell) - : '') . ' ' . $this->tableName; - } - /** * Sets the width of the table * @@ -432,7 +415,7 @@ class Table_Stats_Eps extends TableStats * table title is affected by the tabe width value */ while ($this->width - < PMA_Font::getStringWidth($this->_getTitle(), $font, $fontSize)) { + < PMA_Font::getStringWidth($this->getTitle(), $font, $fontSize)) { $this->width += 7; } } @@ -468,7 +451,7 @@ class Table_Stats_Eps extends TableStats global $eps; //echo $this->tableName.'
'; $eps->rect($this->x, $this->y + 12, $this->width, $this->heightCell, 1); - $eps->showXY($this->_getTitle(), $this->x + 5, $this->y + 14); + $eps->showXY($this->getTitle(), $this->x + 5, $this->y + 14); foreach ($this->fields as $field) { $this->currentCell += $this->heightCell; $showColor = 'none'; diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php index baf979dba4..1ec55c21a2 100644 --- a/libraries/schema/Pdf_Relation_Schema.class.php +++ b/libraries/schema/Pdf_Relation_Schema.class.php @@ -376,9 +376,7 @@ class Table_Stats_Pdf extends TableStats * Defines properties */ public $nb_fiels; - public $width = 0; public $height; - public $heightCell = 6; private $_ff = PMA_PDF_FONT; /** @@ -407,6 +405,7 @@ class Table_Stats_Pdf extends TableStats $pdf, $db, $pageNumber, $tableName, $showKeys, $showInfo ); + $this->heightCell = 6; $this->_setHeight(); /* * setWidth must me after setHeight, because title @@ -455,7 +454,7 @@ class Table_Stats_Pdf extends TableStats * * @return string */ - private function _getTitle() + protected function getTitle() { $ret = ''; if ($this->showInfo) { @@ -490,7 +489,7 @@ class Table_Stats_Pdf extends TableStats * it is unknown what value must be added, because * table title is affected by the tabe width value */ - while ($this->width < $pdf->GetStringWidth($this->_getTitle())) { + while ($this->width < $pdf->GetStringWidth($this->getTitle())) { $this->width += 5; } $pdf->SetFont($this->_ff, '', $fontSize); @@ -542,7 +541,7 @@ class Table_Stats_Pdf extends TableStats $pdf->cellScale( $this->width, $this->heightCell, - $this->_getTitle(), + $this->getTitle(), 1, 1, 'C', diff --git a/libraries/schema/Svg_Relation_Schema.class.php b/libraries/schema/Svg_Relation_Schema.class.php index b343013246..a23ff87afa 100644 --- a/libraries/schema/Svg_Relation_Schema.class.php +++ b/libraries/schema/Svg_Relation_Schema.class.php @@ -280,9 +280,7 @@ class Table_Stats_Svg extends TableStats /** * Defines properties */ - public $width = 0; public $height; - public $heightCell = 0; public $currentCell = 0; /** @@ -357,22 +355,6 @@ class Table_Stats_Svg extends TableStats ); } - /** - * Returns title of the current table, - * title can have the dimensions/co-ordinates of the table - * - * @return string title of the current table - * @access private - */ - private function _getTitle() - { - return ($this->showInfo - ? sprintf('%.0f', $this->width) . 'x' - . sprintf('%.0f', $this->heightCell) - : '' - ) . ' ' . $this->tableName; - } - /** * Sets the width of the table * @@ -401,7 +383,7 @@ class Table_Stats_Svg extends TableStats * table title is affected by the tabe width value */ while ($this->width - < PMA_Font::getStringWidth($this->_getTitle(), $font, $fontSize) + < PMA_Font::getStringWidth($this->getTitle(), $font, $fontSize) ) { $this->width += 7; } @@ -443,7 +425,7 @@ class Table_Stats_Svg extends TableStats ); $svg->printElement( 'text', $this->x + 5, $this->y+ 14, $this->width, $this->heightCell, - $this->_getTitle(), 'fill:none;stroke:black;' + $this->getTitle(), 'fill:none;stroke:black;' ); foreach ($this->fields as $field) { $this->currentCell += $this->heightCell; diff --git a/libraries/schema/TableStats.class.php b/libraries/schema/TableStats.class.php index 5c945d117f..2c15abae73 100644 --- a/libraries/schema/TableStats.class.php +++ b/libraries/schema/TableStats.class.php @@ -33,6 +33,8 @@ abstract class TableStats public $primary = array(); public $x, $y; + public $width = 0; + public $heightCell = 0; /** * Constructor @@ -170,5 +172,20 @@ abstract class TableStats } } } + + /** + * Returns title of the current table, + * title can have the dimensions/co-ordinates of the table + * + * @return string title of the current table + */ + protected function getTitle() + { + return ($this->showInfo + ? sprintf('%.0fx%0.f', $this->width, $this->heightCell) + : '' + ) + . ' ' . $this->tableName; + } } ?> \ No newline at end of file From ae7830985f09cb066e03e2f0261d66b7094086cd Mon Sep 17 00:00:00 2001 From: Bimal Yashodha Date: Fri, 21 Mar 2014 07:11:27 +0530 Subject: [PATCH 5/5] Correct spelling mistakes Signed-off-by: Bimal Yashodha --- libraries/schema/Dia_Relation_Schema.class.php | 2 +- libraries/schema/Eps_Relation_Schema.class.php | 2 +- libraries/schema/Pdf_Relation_Schema.class.php | 2 +- libraries/schema/Svg_Relation_Schema.class.php | 2 +- libraries/schema/TableStats.class.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/schema/Dia_Relation_Schema.class.php b/libraries/schema/Dia_Relation_Schema.class.php index 3b40cdcf45..49051a6250 100644 --- a/libraries/schema/Dia_Relation_Schema.class.php +++ b/libraries/schema/Dia_Relation_Schema.class.php @@ -249,7 +249,7 @@ class Table_Stats_Dia extends TableStats } /** - * Diaplays an error on missing coordinates + * Displays an error on missing coordinates * * @return void */ diff --git a/libraries/schema/Eps_Relation_Schema.class.php b/libraries/schema/Eps_Relation_Schema.class.php index 031139fad0..f0480f9e22 100644 --- a/libraries/schema/Eps_Relation_Schema.class.php +++ b/libraries/schema/Eps_Relation_Schema.class.php @@ -372,7 +372,7 @@ class Table_Stats_Eps extends TableStats } /** - * Diaplays an error on missing coordinates + * Displays an error on missing coordinates * * @return void */ diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php index 1ec55c21a2..cb4e2bffe6 100644 --- a/libraries/schema/Pdf_Relation_Schema.class.php +++ b/libraries/schema/Pdf_Relation_Schema.class.php @@ -432,7 +432,7 @@ class Table_Stats_Pdf extends TableStats } /** - * Diaplays an error on missing coordinates + * Displays an error on missing coordinates * * @return void */ diff --git a/libraries/schema/Svg_Relation_Schema.class.php b/libraries/schema/Svg_Relation_Schema.class.php index a23ff87afa..4cb0b9f19a 100644 --- a/libraries/schema/Svg_Relation_Schema.class.php +++ b/libraries/schema/Svg_Relation_Schema.class.php @@ -339,7 +339,7 @@ class Table_Stats_Svg extends TableStats } /** - * Diaplays an error on missing coordinates + * Displays an error on missing coordinates * * @return void */ diff --git a/libraries/schema/TableStats.class.php b/libraries/schema/TableStats.class.php index 2c15abae73..a59366b24d 100644 --- a/libraries/schema/TableStats.class.php +++ b/libraries/schema/TableStats.class.php @@ -136,7 +136,7 @@ abstract class TableStats } /** - * Diaplays an error on missing coordinates + * Displays an error on missing coordinates * * @return void * @abstract