$db ); if ($action == 'tbl_create.php') { $form_params['reload'] = 1; } elseif ($action == 'tbl_addfield.php') { $form_params['field_where'] = $_REQUEST['field_where']; $form_params['after_field'] = $_REQUEST['after_field']; $form_params['table'] = $table; } else { $form_params['table'] = $table; } if (isset($num_fields)) { $form_params['orig_num_fields'] = $num_fields; } if (isset($_REQUEST['field_where'])) { $form_params['orig_field_where'] = $_REQUEST['field_where']; } if (isset($_REQUEST['after_field'])) { $form_params['orig_after_field'] = $_REQUEST['after_field']; } if (isset($selected) && is_array($selected)) { foreach ($selected as $o_fld_nr => $o_fld_val) { $form_params['selected[' . $o_fld_nr . ']'] = $o_fld_val; } } return $form_params; } /** * Function to get html for table comments, storage engine, collation and * partition definition * * @return string */ function PMA_getHtmlForTableConfigurations() { $html = '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . ''; if (PMA_Partition::havePartitioning()) { $html .= '' . '' . '' . '' . '' . ''; } $html .= '
' . __('Table comments:') . ' ' . __('Storage Engine:') . PMA_Util::showMySQLDocu('Storage_engines') . ' ' . __('Collation:') . '
' . ' ' . PMA_StorageEngine::getHtmlSelect( 'tbl_storage_engine', null, (isset($_REQUEST['tbl_storage_engine']) ? $_REQUEST['tbl_storage_engine'] : null ) ) . ' ' . PMA_generateCharsetDropdownBox( PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, (isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null ), false, 3 ) . '
' . __('PARTITION definition:') . ' ' . PMA_Util::showMySQLDocu('Partitioning') . '
' . '' . '
' . '
'; return $html; } /** * Function to get html for the footer * * @return string */ function PMA_getHtmlForFooter() { $html = '
' . '' . '
' . '
' . ''; $html .= ''; return $html; } /** * Function to get html for table create table name and number of fields * * @return string */ function PMA_getHtmlForTableNameAndNoOfColumns() { $html = '' . '' . '' . '' . '' . '
' . __('Table name') . ': ' . ''; $html .= sprintf( __('Add %s column(s)'), '' ); $html .= ''; $html .= '
'; return $html; } /** * Function to get html for table field definitions * * @param array $header_cells header cells * @param array $content_cells content cells * * @return string */ function PMA_getHtmlForTableFieldDefinitions($header_cells, $content_cells) { $html = ''; $html .= ''; $html .= ''; foreach ($header_cells as $header_val) { $html .= ''; } $html .= ''; $odd_row = true; foreach ($content_cells as $content_row) { $html .= ''; $odd_row = ! $odd_row; if (is_array($content_row)) { foreach ($content_row as $content_row_val) { $html .= ''; } } $html .= ''; } $html .= '
' . __('Structure') . PMA_Util::showMySQLDocu('CREATE_TABLE') . '
' . $header_val . '
' . $content_row_val . '
' . '
'; return $html; } /** * Function to get html for the create table or field add view * * @param string $action action * @param array $form_params forms parameters * @param array $content_cells content cells * @param array $header_cells header cells * * @return string */ function PMA_getHtmlForTableCreateOrAddField($action, $form_params, $content_cells, $header_cells ) { $html = '
'; $html .= PMA_URL_getHiddenInputs($form_params); if ($action == 'tbl_create.php') { $html .= PMA_getHtmlForTableNameAndNoOfColumns(); } if (is_array($content_cells) && is_array($header_cells)) { $html .= PMA_getHtmlForTableFieldDefinitions($header_cells, $content_cells); } if ($action == 'tbl_create.php') { $html .= PMA_getHtmlForTableConfigurations(); } $html .= PMA_getHtmlForFooter(); return $html; } /** * Function to get header cells * * @param bool $is_backup whether backup or not * @param array $columnMeta column meta data * @param bool $mimework whether mimework or not * @param string $db current database * @param string $table current table * * @return array */ function PMA_getHeaderCells($is_backup, $columnMeta, $mimework, $db, $table) { $header_cells = array(); $header_cells[] = __('Name'); $header_cells[] = __('Type') . PMA_Util::showMySQLDocu('data-types'); $header_cells[] = __('Length/Values') . PMA_Util::showHint( __( 'If column type is "enum" or "set", please enter the values using' . ' this format: \'a\',\'b\',\'c\'…
If you ever need to put' . ' a backslash ("\") or a single quote ("\'") amongst those' . ' values, precede it with a backslash (for example \'\\\\xyz\'' . ' or \'a\\\'b\').' ) ); $header_cells[] = __('Default') . PMA_Util::showHint( __( 'For default values, please enter just a single value,' . ' without backslash escaping or quotes, using this format: a' ) ); $header_cells[] = __('Collation'); $header_cells[] = __('Attributes'); $header_cells[] = __('Null'); // We could remove this 'if' and let the key information be shown and // editable. However, for this to work, structure.lib.php must be modified // to use the key fields, as tbl_addfield does. if (! $is_backup) { $header_cells[] = __('Index'); } $header_cells[] = 'A_I'; $header_cells[] = __('Comments'); if (isset($columnMeta)) { $header_cells[] = __('Move column'); } if ($mimework && $GLOBALS['cfg']['BrowseMIME']) { $header_cells[] = __('MIME type'); $header_cells[] = '' . __('Browser transformation') . ''; $header_cells[] = __('Transformation options') . PMA_Util::showHint( __( 'Please enter the values for transformation options using this' . ' format: \'a\', 100, b,\'c\'…
If you ever need to put' . ' a backslash ("\") or a single quote ("\'") amongst those' . ' values, precede it with a backslash (for example \'\\\\xyz\'' . ' or \'a\\\'b\').' ) ); } return $header_cells; } /** * Function for moving, load all available column names * * @param string $db current database * @param string $table current table * * @return array */ function PMA_getMoveColumns($db, $table) { $move_columns_sql_query = 'SELECT * FROM ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table) . ' LIMIT 1'; $move_columns_sql_result = $GLOBALS['dbi']->tryQuery($move_columns_sql_query); $move_columns = $GLOBALS['dbi']->getFieldsMeta($move_columns_sql_result); return $move_columns; } /** * Function to get row data for regenerating previous when error occurred. * * @param int $columnNumber coulmn number * @param array $submit_fulltext submit full text * * @return array */ function PMA_getRowDataForRegeneration($columnNumber, $submit_fulltext) { $columnMeta['Field'] = isset($_REQUEST['field_name'][$columnNumber]) ? $_REQUEST['field_name'][$columnNumber] : false; $columnMeta['Type'] = isset($_REQUEST['field_type'][$columnNumber]) ? $_REQUEST['field_type'][$columnNumber] : false; $columnMeta['Collation'] = isset($_REQUEST['field_collation'][$columnNumber]) ? $_REQUEST['field_collation'][$columnNumber] : ''; $columnMeta['Null'] = isset($_REQUEST['field_null'][$columnNumber]) ? $_REQUEST['field_null'][$columnNumber] : ''; $columnMeta['Key'] = ''; if (isset($_REQUEST['field_key'][$columnNumber])) { $parts = explode('_', $_REQUEST['field_key'][$columnNumber], 2); if (count($parts) == 2 && $parts[1] == $columnNumber) { switch ($parts[0]) { case 'primary': $columnMeta['Key'] = 'PRI'; break; case 'index': $columnMeta['Key'] = 'MUL'; break; case 'unique': $columnMeta['Key'] = 'UNI'; break; case 'fulltext': $columnMeta['Key'] = 'FULLTEXT'; break; } } } // put None in the drop-down for Default, when someone adds a field $columnMeta['DefaultType'] = isset($_REQUEST['field_default_type'][$columnNumber]) ? $_REQUEST['field_default_type'][$columnNumber] : 'NONE'; $columnMeta['DefaultValue'] = isset($_REQUEST['field_default_value'][$columnNumber]) ? $_REQUEST['field_default_value'][$columnNumber] : ''; switch ($columnMeta['DefaultType']) { case 'NONE' : $columnMeta['Default'] = null; break; case 'USER_DEFINED' : $columnMeta['Default'] = $columnMeta['DefaultValue']; break; case 'NULL' : case 'CURRENT_TIMESTAMP' : $columnMeta['Default'] = $columnMeta['DefaultType']; break; } $columnMeta['Extra'] = (isset($_REQUEST['field_extra'][$columnNumber]) ? $_REQUEST['field_extra'][$columnNumber] : false); $columnMeta['Comment'] = (isset($submit_fulltext[$columnNumber]) && ($submit_fulltext[$columnNumber] == $columnNumber) ? 'FULLTEXT' : false); return $columnMeta; } /** * Function to get submit properties for regenerating previous when error occurred. * * @param int $columnNumber coulmn number * * @return array */ function PMA_getSubmitPropertiesForRegeneration($columnNumber) { $submit_length = (isset($_REQUEST['field_length'][$columnNumber]) ? $_REQUEST['field_length'][$columnNumber] : false); $submit_attribute = (isset($_REQUEST['field_attribute'][$columnNumber]) ? $_REQUEST['field_attribute'][$columnNumber] : false); $submit_default_current_timestamp = (isset($_REQUEST['field_default_current_timestamp'][$columnNumber]) ? true : false); return array( $submit_length, $submit_attribute, $submit_default_current_timestamp ); } /** * An error happened with previous inputs, so we will restore the data * to embed it once again in this form. * * @param int $columnNumber coulmn number * @param array $submit_fulltext submit full text * @param array $comments_map comments map * @param array $mime_map mime map * * @return array */ function PMA_handleRegeneration($columnNumber, $submit_fulltext, $comments_map, $mime_map ) { $columnMeta = PMA_getRowDataForRegeneration( $columnNumber, isset($submit_fulltext) ? $submit_fulltext : null ); list($submit_length, $submit_attribute, $submit_default_current_timestamp) = PMA_getSubmitPropertiesForRegeneration($columnNumber); if (isset($_REQUEST['field_comments'][$columnNumber])) { $comments_map[$columnMeta['Field']] = $_REQUEST['field_comments'][$columnNumber]; } if (isset($_REQUEST['field_mimetype'][$columnNumber])) { $mime_map[$columnMeta['Field']]['mimetype'] = $_REQUEST['field_mimetype'][$columnNumber]; } if (isset($_REQUEST['field_transformation'][$columnNumber])) { $mime_map[$columnMeta['Field']]['transformation'] = $_REQUEST['field_transformation'][$columnNumber]; } if (isset($_REQUEST['field_transformation_options'][$columnNumber])) { $mime_map[$columnMeta['Field']]['transformation_options'] = $_REQUEST['field_transformation_options'][$columnNumber]; } return array( $columnMeta, $submit_length, $submit_attribute, $submit_default_current_timestamp, $comments_map, $mime_map ); } /** * Function to get row data for $columnMeta set * * @param array $columnMeta column meta * @param bool $isDefault whether the row value is default * * @return array */ function PMA_getColumnMetaForDefault($columnMeta, $isDefault) { switch ($columnMeta['Default']) { case null: if ($columnMeta['Null'] == 'YES') { $columnMeta['DefaultType'] = 'NULL'; $columnMeta['DefaultValue'] = ''; // SHOW FULL COLUMNS does not report the case // when there is a DEFAULT value which is empty so we need to use the // results of SHOW CREATE TABLE } elseif ($isDefault) { $columnMeta['DefaultType'] = 'USER_DEFINED'; $columnMeta['DefaultValue'] = $columnMeta['Default']; } else { $columnMeta['DefaultType'] = 'NONE'; $columnMeta['DefaultValue'] = ''; } break; case 'CURRENT_TIMESTAMP': $columnMeta['DefaultType'] = 'CURRENT_TIMESTAMP'; $columnMeta['DefaultValue'] = ''; break; default: $columnMeta['DefaultType'] = 'USER_DEFINED'; $columnMeta['DefaultValue'] = $columnMeta['Default']; break; } return $columnMeta; } /** * Function to get html for the column name * * @param int $columnNumber column number * @param int $ci cell index * @param int $ci_offset cell index offset * @param array $columnMeta column meta * * @return string */ function PMA_getHtmlForColumnName($columnNumber, $ci, $ci_offset, $columnMeta) { $html = ''; return $html; } /** * Function to get html for the column type * * @param int $columnNumber column number * @param int $ci cell index * @param int $ci_offset cell index offset * @param string $type_upper type inuppercase * * @return string */ function PMA_getHtmlForColumnType($columnNumber, $ci, $ci_offset, $type_upper) { $select_id = 'field_' . $columnNumber . '_' . ($ci - $ci_offset); $html = ''; return $html; } /** * Function to get html for transformation option * * @param int $columnNumber column number * @param int $ci cell index * @param int $ci_offset cell index offset * @param array $columnMeta column meta * @param array $mime_map mime map * * @return string */ function PMA_getHtmlForTransformationOption($columnNumber, $ci, $ci_offset, $columnMeta, $mime_map ) { $val = isset($columnMeta['Field']) && isset($mime_map[$columnMeta['Field']]['transformation_options']) ? htmlspecialchars( $mime_map[$columnMeta['Field']] ['transformation_options'] ) : ''; $html = ''; return $html; } /** * Function to get html for mime type * * @param int $columnNumber column number * @param int $ci cell index * @param int $ci_offset cell index offset * @param array $available_mime available mime * @param array $columnMeta column meta * @param array $mime_map mime map * * @return string */ function PMA_getHtmlForMimeType($columnNumber, $ci, $ci_offset, $available_mime, $columnMeta, $mime_map ) { $html = ''; return $html; } /** * Function to get html for browser transformation * * @param int $columnNumber column number * @param int $ci cell index * @param int $ci_offset cell index offset * @param array $available_mime available mime * @param array $columnMeta column meta * @param array $mime_map mime map * * @return string */ function PMA_getHtmlForBrowserTransformation($columnNumber, $ci, $ci_offset, $available_mime, $columnMeta, $mime_map ) { $html = ''; return $html; } /** * Function to get html for move column * * @param int $columnNumber column number * @param int $ci cell index * @param int $ci_offset cell index offset * @param array $move_columns move columns * @param array $columnMeta column meta * * @return string */ function PMA_getHtmlForMoveColumn($columnNumber, $ci, $ci_offset, $move_columns, $columnMeta ) { $html = ''; return $html; } /** * Function to get html for column comment * * @param int $columnNumber column number * @param int $ci cell index * @param int $ci_offset cell index offset * @param array $columnMeta column meta * @param array $comments_map comments map * * @return string */ function PMA_getHtmlForColumnComment($columnNumber, $ci, $ci_offset, $columnMeta, $comments_map ) { $html = ''; return $html; } /** * Function get html for column auto increment * * @param int $columnNumber column number * @param int $ci cell index * @param int $ci_offset cell index offset * @param array $columnMeta column meta * * @return string */ function PMA_getHtmlForColumnAutoIncrement($columnNumber, $ci, $ci_offset, $columnMeta ) { $html = ''; $html .= ''; $html .= PMA_getHtmlForIndexTypeOption( $columnNumber, $columnMeta, 'Primary', 'PRI' ); $html .= PMA_getHtmlForIndexTypeOption( $columnNumber, $columnMeta, 'Unique', 'UNI' ); $html .= PMA_getHtmlForIndexTypeOption( $columnNumber, $columnMeta, 'Index', 'MUL' ); if (!PMA_DRIZZLE) { $html .= PMA_getHtmlForIndexTypeOption( $columnNumber, $columnMeta, 'Fulltext', 'FULLTEXT' ); } $html .= ''; return $html; } /** * Function to get html for the index options * * @param int $columnNumber column number * @param array $columnMeta column meta * @param string $type index type * @param string $key column meta key * * @return string */ function PMA_getHtmlForIndexTypeOption($columnNumber, $columnMeta, $type, $key) { $html = '