From ceffd6934b1e9da2279127c8a5fb27247caee569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Mon, 5 Jun 2017 00:52:46 -0300 Subject: [PATCH] Refactor index.lib function into static method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- libraries/Index.php | 33 +++++++++++++++ .../table/TableRelationController.php | 4 +- .../table/TableStructureController.php | 1 - libraries/index.lib.php | 41 ------------------- .../table/structure/display_structure.phtml | 3 +- 5 files changed, 36 insertions(+), 46 deletions(-) delete mode 100644 libraries/index.lib.php diff --git a/libraries/Index.php b/libraries/Index.php index 269b448eb5..c6c814aab0 100644 --- a/libraries/Index.php +++ b/libraries/Index.php @@ -634,6 +634,39 @@ class Index return $this->_columns; } + /** + * Get HTML for display indexes + * + * @return string $html_output + */ + public static function getHtmlForDisplayIndexes() + { + $html_output = '
'; + $html_output .= self::getHtmlForIndexes( + $GLOBALS['table'], + $GLOBALS['db'] + ); + $html_output .= '' + . '
'; + + return $html_output; + } + /** * Show index data * diff --git a/libraries/controllers/table/TableRelationController.php b/libraries/controllers/table/TableRelationController.php index 163c2d74eb..39b7cd7662 100644 --- a/libraries/controllers/table/TableRelationController.php +++ b/libraries/controllers/table/TableRelationController.php @@ -8,8 +8,6 @@ namespace PMA\libraries\controllers\table; -require_once 'libraries/index.lib.php'; - use PMA\libraries\controllers\TableController; use PMA\libraries\DatabaseInterface; use PMA\libraries\Index; @@ -191,7 +189,7 @@ class TableRelationController extends TableController ); if (Util::isForeignKeySupported($this->tbl_storage_engine)) { - $this->response->addHTML(PMA_getHtmlForDisplayIndexes()); + $this->response->addHTML(Index::getHtmlForDisplayIndexes()); } $this->response->addHTML(''); } diff --git a/libraries/controllers/table/TableStructureController.php b/libraries/controllers/table/TableStructureController.php index b213ad2a35..6377c38783 100644 --- a/libraries/controllers/table/TableStructureController.php +++ b/libraries/controllers/table/TableStructureController.php @@ -118,7 +118,6 @@ class TableStructureController extends TableController * Function implementations for this script */ include_once 'libraries/check_user_privileges.lib.php'; - include_once 'libraries/index.lib.php'; $this->response->getHeader()->getScripts()->addFiles( array( diff --git a/libraries/index.lib.php b/libraries/index.lib.php deleted file mode 100644 index de1d76da31..0000000000 --- a/libraries/index.lib.php +++ /dev/null @@ -1,41 +0,0 @@ -'; - $html_output .= PMA\libraries\Index::getHtmlForIndexes( - $GLOBALS['table'], - $GLOBALS['db'] - ); - $html_output .= '' - . ''; - - return $html_output; -} diff --git a/templates/table/structure/display_structure.phtml b/templates/table/structure/display_structure.phtml index e441d428b5..bb36efd06a 100644 --- a/templates/table/structure/display_structure.phtml +++ b/templates/table/structure/display_structure.phtml @@ -1,4 +1,5 @@ - +