diff options
author | Jason <jason.daurus@gmail.com> | 2015-06-23 20:55:45 +0300 |
---|---|---|
committer | Jason <jason.daurus@gmail.com> | 2015-06-23 20:55:45 +0300 |
commit | 104c68d681c69667a053b3207091bfa8ba047505 (patch) | |
tree | 99c7d5793a88ffc6aef12ba260d380668ddb61e8 /tbl_indexes.php | |
parent | 8725217b2965acd685eee45428ef73524d9ed7c2 (diff) |
Introduce Controllers for tbl related scripts
Signed-off-by: Jason <jason.daurus@gmail.com>
Diffstat (limited to 'tbl_indexes.php')
-rw-r--r-- | tbl_indexes.php | 130 |
1 files changed, 4 insertions, 126 deletions
diff --git a/tbl_indexes.php b/tbl_indexes.php index ebf70f3480..e20d02847b 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -6,131 +6,9 @@ * @package PhpMyAdmin */ -/** - * Gets some core libraries - */ -require_once 'libraries/common.inc.php'; -require_once 'libraries/Index.class.php'; -require_once 'libraries/Template.class.php'; - -if (! isset($_REQUEST['create_edit_table'])) { - include_once 'libraries/tbl_common.inc.php'; -} - -if (isset($_REQUEST['index'])) { - if (is_array($_REQUEST['index'])) { - // coming already from form - $index = new PMA_Index($_REQUEST['index']); - } else { - $index = $GLOBALS['dbi']->getTable($db, $table) - ->getIndex($_REQUEST['index']); - } -} else { - $index = new PMA_Index; -} - -/** - * Process the data from the edit/create index form, - * run the query to build the new index - * and moves back to "tbl_sql.php" - */ -if (isset($_REQUEST['do_save_data'])) { - - $error = false; - - $sql_query = $GLOBALS['dbi']->getTable($db, $table) - ->getSqlQueryForIndexCreateOrEdit($index, $error); - - // If there is a request for SQL previewing. - if (isset($_REQUEST['preview_sql'])) { - - PMA_Response::getInstance()->addJSON( - 'sql_data', - PMA\Template::get('preview_sql') - ->render( - array( - 'query_data' => $sql_query - ) - ) - ); - } elseif (!$error) { - - $GLOBALS['dbi']->query($sql_query); - if ($GLOBALS['is_ajax_request'] == true) { - $message = PMA_Message::success( - __('Table %1$s has been altered successfully.') - ); - $message->addParam($table); - $response = PMA_Response::getInstance(); - $response->addJSON( - 'message', PMA_Util::getMessage($message, $sql_query, 'success') - ); - $response->addJSON('index_table', PMA_Index::getHtmlForIndexes($table, $db)); - } else { - include 'tbl_structure.php'; - } - } else { - $response = PMA_Response::getInstance(); - $response->isSuccess(false); - $response->addJSON('message', $error); - } - exit; -} // end builds the new index - - -/** - * Display the form to edit/create an index - */ -require_once 'libraries/tbl_info.inc.php'; - -$add_fields = 0; -if (isset($_REQUEST['index']) && is_array($_REQUEST['index'])) { - // coming already from form - if (isset($_REQUEST['index']['columns']['names'])) { - $add_fields = count($_REQUEST['index']['columns']['names']) - - $index->getColumnCount(); - } - if (isset($_REQUEST['add_fields'])) { - $add_fields += $_REQUEST['added_fields']; - } -} elseif (isset($_REQUEST['create_index'])) { - $add_fields = $_REQUEST['added_fields']; -} // end preparing form values - -// Get fields and stores their name/type -if (isset($_REQUEST['create_edit_table'])) { - $fields = json_decode($_REQUEST['columns'], true); - $index_params = array( - 'Non_unique' => ($_REQUEST['index']['Index_choice'] == 'UNIQUE') ? '0' : '1' - ); - $index->set($index_params); - $add_fields = count($fields); -} else { - $fields = $GLOBALS['dbi']->getTable($db, $table)->getNameAndTypeOfTheColumns(); -} - -$form_params = array( - 'db' => $db, - 'table' => $table, -); +require_once 'libraries/controllers/table/TableIndexesController.class.php'; -if (isset($_REQUEST['create_index'])) { - $form_params['create_index'] = 1; -} elseif (isset($_REQUEST['old_index'])) { - $form_params['old_index'] = $_REQUEST['old_index']; -} elseif (isset($_REQUEST['index'])) { - $form_params['old_index'] = $_REQUEST['index']; -} +use PMA\Controllers\Table\TableIndexesController; -$response = PMA_Response::getInstance(); -$response->addHTML(PMA\Template::get('index_form') - ->render(array( - 'fields' => $fields, - 'index' => $index, - 'form_params' => $form_params, - 'add_fields' => $add_fields - )) -); -$header = $response->getHeader(); -$scripts = $header->getScripts(); -$scripts->addFile('indexes.js'); +$controller = new TableIndexesController(); +$controller->indexAction(); |