getColumns(); $columnTypeList = $types[ucfirst($colTypeCategory)]; } $GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']); $columns = (array) $GLOBALS['dbi']->getColumns( $db, $table, null, true, $GLOBALS['userlink'] ); $type = ""; $selectColHtml = ""; foreach ($columns as $column=>$def) { if (isset($def['Type'])) { $extracted_columnspec = PMA_Util::extractColumnSpec($def['Type']); $type = $extracted_columnspec['type']; } if (empty($columnTypeList) || in_array(strtoupper($type), $columnTypeList)) { if ($listType == 'checkbox') { $selectColHtml .= '' . htmlspecialchars($column) . ' [ ' . $def['Type'] . ' ]
'; } else { $selectColHtml .= ''; } } } return $selectColHtml; } /** * get the html of the form to add the new column to given table * * @param integer $num_fields number of columns to add * @param string $db current database * @param string $table current table * @param array $columnMeta array containing default values for the fields * * @return HTML */ function PMA_getHtmlForCreateNewColumn( $num_fields, $db, $table, $columnMeta=array() ) { $cfgRelation = PMA_getRelationsParam(); $content_cells = array(); $available_mime = array(); $mime_map = array(); $header_cells = PMA_getHeaderCells( true, null, $cfgRelation['mimework'], $db, $table ); if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) { $mime_map = PMA_getMIME($db, $table); $available_mime = PMA_getAvailableMIMEtypes(); } $comments_map = PMA_getComments($db, $table); for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) { $content_cells[$columnNumber] = PMA_getHtmlForColumnAttributes( $columnNumber, $columnMeta, '', 8, '', null, array(), null, null, null, $comments_map, null, true, array(), $cfgRelation, $available_mime, $mime_map ); } return PMA_getHtmlForTableFieldDefinitions($header_cells, $content_cells); } /** * build the html for step 1.1 of normalization * * @param string $db current database * @param string $table current table * * @return HTML for step 1.1 */ function PMA_getHtmlFor1NFStep1($db, $table) { $step = 1; $stepTxt = __('Make all columns atomic'); $html = "

" . __('First step of normalization (1NF)') . "

"; $html .= "
" . "
" . "" . __('Step 1.') . $step . " " . $stepTxt . "" . "

" . __( 'Do you have any column which can be split into more than' . ' one column? ' . 'For example: address can be split into street, city, country and zip.' ) . "
( " . __( 'Show me the central list of columns that are not already in this table' ) . " )

" . "

" . __( 'Select a column which can be split into more ' . 'than one. (on select of \'no such column\', it\'ll move to next step)' ) . "

" . "
" . "" . "" . __('split into ') . "" . "
" . "
" . "
" . "
" . "
"; return $html; } /** * build the html contents of various html elements in step 1.2 * * @param string $db current database * @param string $table current table * * @return HTML contents for step 1.2 */ function PMA_getHtmlContentsFor1NFStep2($db, $table) { $step = 2; $stepTxt = __('Have a primary key'); $primary = PMA_Index::getPrimary($table, $db); $hasPrimaryKey = "0"; $legendText = __('Step 1.') . $step . " " . $stepTxt; $extra = ''; if ($primary) { $headText = __("Primary key already exists."); $subText = __("Taking you to next step…"); $hasPrimaryKey = "1"; } else { $headText = __( "There is no primary key; please add one.
" . "Hint: A primary key is a column " . "(or combination of columns) that uniquely identify all rows." ); $subText = '' . PMA_Util::getIcon( 'b_index_add.png', __( 'Add a primary key on existing column(s)' ) ) . ''; $extra = __( "If it's not possible to make existing " . "column combinations as primary key" ) . "
" . '' . __('+ Add a new primary key column') . ''; } $res = array('legendText'=>$legendText, 'headText'=>$headText, 'subText'=>$subText, 'hasPrimaryKey'=>$hasPrimaryKey, 'extra'=>$extra); return $res; } /** * build the html contents of various html elements in step 1.3 * * @param string $db current database * @param string $table current table * * @return HTML contents for step 1.3 */ function PMA_getHtmlContentsFor1NFStep3($db, $table) { $step = 3; $stepTxt = __('Remove redundant columns'); $legendText = __('Step 1.') . $step . " " . $stepTxt; $headText = __( "Do you have group of columns which on combining gives an existing column? For example, if you have first_name, last_name and full_name then combining first_name and last_name gives full_name which is redundant" ); $subText = __( "Check the columns which are redundant and click on remove. " . "If no redundant column, click on 'No redundant column'" ); $extra = PMA_getHtmlForColumnsList($db, $table, 'all', "checkbox") . "
" . '' . ''; $res = array( 'legendText'=>$legendText, 'headText'=>$headText, 'subText'=>$subText, 'extra'=>$extra ); return $res; } /** * get html for options to normalize table * * @return HTML */ function PMA_getHtmlForNormalizetable() { $html_output = '
' . PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']) . ''; $html_output .= '
'; $html_output .= '' . __('Improve table structure (Normalization):') . ''; $html_output .= '

' . __('Select up to what step you want to normalize') . '

'; $choices = array( '1nf' => __('First step of normalization (1NF)'), '2nf' => __('Second step of normalization (1NF+2NF)'), '3nf' => __('Third step of normalization (1NF+2NF+3NF)')); $html_output .= PMA_Util::getRadioFields( 'normalizeTo', $choices, '1nf', true ); $html_output .= '
' . "" . __( 'Hint: Please follow the procedure carefully in order ' . 'to obtain correct normalization' ) . "" . '' . '
' . '
' . ''; return $html_output; }