UPDATE 4.4.0.0
[phpmyadmin.git] / tbl_indexes.php
blobf083edad717edde36a993b27175097cf76e75b9d
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Displays index edit/creation form and handles it
6 * @package PhpMyAdmin
7 */
9 /**
10 * Gets some core libraries
12 require_once 'libraries/common.inc.php';
13 require_once 'libraries/Index.class.php';
14 require_once 'libraries/tbl_indexes.lib.php';
16 if (! isset($_REQUEST['create_edit_table'])) {
17 include_once 'libraries/tbl_common.inc.php';
21 $index = PMA_prepareFormValues($db, $table);
22 /**
23 * Process the data from the edit/create index form,
24 * run the query to build the new index
25 * and moves back to "tbl_sql.php"
27 if (isset($_REQUEST['do_save_data'])) {
28 PMA_handleCreateOrEditIndex($db, $table, $index);
29 } // end builds the new index
32 /**
33 * Display the form to edit/create an index
35 require_once 'libraries/tbl_info.inc.php';
37 $add_fields = PMA_getNumberOfFieldsForForm($index);
39 $form_params = PMA_getFormParameters($db, $table);
41 // Get fields and stores their name/type
42 if (isset($_REQUEST['create_edit_table'])) {
43 $fields = json_decode($_REQUEST['columns'], true);
44 $index_params = array(
45 'Non_unique' => ($_REQUEST['index']['Index_choice'] == 'UNIQUE') ? '0' : '1'
47 $index->set($index_params);
48 $add_fields = count($fields);
49 } else {
50 $fields = PMA_getNameAndTypeOfTheColumns($db, $table);
53 $html = PMA_getHtmlForIndexForm($fields, $index, $form_params, $add_fields);
55 $response = PMA_Response::getInstance();
56 $response->addHTML($html);
57 $header = $response->getHeader();
58 $scripts = $header->getScripts();
59 $scripts->addFile('indexes.js');