2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Displays add field form and handles it
8 use PMA\libraries\PMA_String
;
11 * Get some core libraries
13 require_once 'libraries/common.inc.php';
15 $response = PMA\libraries\Response
::getInstance();
16 $header = $response->getHeader();
17 $scripts = $header->getScripts();
18 $scripts->addFile('tbl_structure.js');
21 PMA\libraries\Util
::checkParameters(array('db', 'table'));
25 * Defines the url to return to in case of error in a sql statement
27 $err_url = 'tbl_sql.php' . PMA_URL_getCommon(
29 'db' => $db, 'table' => $table
34 * The form used to define the field to add has been submitted
38 // check number of fields to be created
39 if (isset($_REQUEST['submit_num_fields'])) {
40 if (isset($_REQUEST['orig_after_field'])) {
41 $_REQUEST['after_field'] = $_REQUEST['orig_after_field'];
43 if (isset($_REQUEST['orig_field_where'])) {
44 $_REQUEST['field_where'] = $_REQUEST['orig_field_where'];
46 $num_fields = $_REQUEST['orig_num_fields'] +
$_REQUEST['added_fields'];
48 } elseif (isset($_REQUEST['num_fields']) && intval($_REQUEST['num_fields']) > 0) {
49 $num_fields = (int) $_REQUEST['num_fields'];
54 if (isset($_REQUEST['do_save_data'])) {
55 //avoid an incorrect calling of PMA_updateColumns() via
56 //tbl_structure.php below
57 unset($_REQUEST['do_save_data']);
59 include_once 'libraries/create_addfield.lib.php';
61 list($result, $sql_query) = PMA_tryColumnCreationQuery($db, $table, $err_url);
63 if ($result === true) {
64 // If comments were sent, enable relation stuff
65 include_once 'libraries/transformations.lib.php';
67 // Update comment table for mime types [MIME]
68 if (isset($_REQUEST['field_mimetype'])
69 && is_array($_REQUEST['field_mimetype'])
72 /** @var String $pmaString */
73 $pmaString = $GLOBALS['PMA_String'];
74 foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
75 if (isset($_REQUEST['field_name'][$fieldindex])
76 && /*overload*/mb_strlen($_REQUEST['field_name'][$fieldindex])
80 $_REQUEST['field_name'][$fieldindex],
82 $_REQUEST['field_transformation'][$fieldindex],
83 $_REQUEST['field_transformation_options'][$fieldindex],
84 $_REQUEST['field_input_transformation'][$fieldindex],
85 $_REQUEST['field_input_transformation_options'][$fieldindex]
91 // Go back to the structure sub-page
92 $message = PMA\libraries\Message
::success(
93 __('Table %1$s has been altered successfully.')
95 $message->addParam($table);
97 'message', PMA\libraries\Util
::getMessage($message, $sql_query, 'success')
101 $error_message_html = PMA\libraries\Util
::mysqlDie('', '', false, $err_url, false);
102 $response->addHTML($error_message_html);
103 $response->setRequestStatus(false);
106 } // end do alter table
109 * Displays the form used to define the new field
111 if ($abort == false) {
113 * Gets tables information
115 include_once 'libraries/tbl_common.inc.php';
116 include_once 'libraries/tbl_info.inc.php';
118 $active_page = 'tbl_structure.php';
122 $action = 'tbl_addfield.php';
123 include_once 'libraries/tbl_columns_definition_form.inc.php';