Merge pull request #13356 from mauriciofauth/index-lib

Refactor index.lib function into static method
This commit is contained in:
Michal Čihař 2017-06-06 11:15:56 +02:00 committed by GitHub
commit 5231ac3e5f
5 changed files with 36 additions and 46 deletions

View File

@ -634,6 +634,39 @@ class Index
return $this->_columns;
}
/**
* Get HTML for display indexes
*
* @return string $html_output
*/
public static function getHtmlForDisplayIndexes()
{
$html_output = '<div id="index_div" class="ajax" >';
$html_output .= self::getHtmlForIndexes(
$GLOBALS['table'],
$GLOBALS['db']
);
$html_output .= '<fieldset class="tblFooters print_ignore" style="text-align: '
. 'left;"><form action="tbl_indexes.php" method="post">';
$html_output .= URL::getHiddenInputs(
$GLOBALS['db'], $GLOBALS['table']
);
$html_output .= sprintf(
__('Create an index on &nbsp;%s&nbsp;columns'),
'<input type="number" name="added_fields" value="1" '
. 'min="1" required="required" />'
);
$html_output .= '<input type="hidden" name="create_index" value="1" />'
. '<input class="add_index ajax"'
. ' type="submit" value="' . __('Go') . '" />';
$html_output .= '</form>'
. '</fieldset>'
. '</div>';
return $html_output;
}
/**
* Show index data
*

View File

@ -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('</div>');
}

View File

@ -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(

View File

@ -1,41 +0,0 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* set of functions for structure section in pma
*
* @package PhpMyAdmin
*/
use PMA\libraries\URL;
/**
* Get HTML for display indexes
*
* @return string $html_output
*/
function PMA_getHtmlForDisplayIndexes()
{
$html_output = '<div id="index_div" class="ajax" >';
$html_output .= PMA\libraries\Index::getHtmlForIndexes(
$GLOBALS['table'],
$GLOBALS['db']
);
$html_output .= '<fieldset class="tblFooters print_ignore" style="text-align: '
. 'left;"><form action="tbl_indexes.php" method="post">';
$html_output .= URL::getHiddenInputs(
$GLOBALS['db'], $GLOBALS['table']
);
$html_output .= sprintf(
__('Create an index on &nbsp;%s&nbsp;columns'),
'<input type="number" name="added_fields" value="1" '
. 'min="1" required="required" />'
);
$html_output .= '<input type="hidden" name="create_index" value="1" />'
. '<input class="add_index ajax"'
. ' type="submit" value="' . __('Go') . '" />';
$html_output .= '</form>'
. '</fieldset>'
. '</div>';
return $html_output;
}

View File

@ -1,4 +1,5 @@
<?php
use PMA\libraries\Index;
use PMA\libraries\Partition;
use PMA\libraries\Template;
use PMA\libraries\Tracker;
@ -167,7 +168,7 @@ $rownum = 0; ?>
<!--Displays indexes-->
<?php if (! $tbl_is_view
&& ! $db_is_system_schema && 'ARCHIVE' != $tbl_storage_engine): ?>
<?= PMA_getHtmlForDisplayIndexes(); ?>
<?= Index::getHtmlForDisplayIndexes(); ?>
<?php endif; ?>
<!--Display partition details-->