' . "\n";
}
/**
* Retrieve the default for datetime data type
*
* @param array $column containing column type, Default and null
*/
function PMA_getDefaultForDatetime($column)
{
// d a t e t i m e
//
// Current date should not be set as default if the field is NULL
// for the current row, but do not put here the current datetime
// if there is a default value (the real default value will be set
// in the Default value logic below)
// Note: (tested in MySQL 4.0.16): when lang is some UTF-8,
// $column['Default'] is not set if it contains NULL:
// Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime)
// but, look what we get if we switch to iso: (Default is NULL)
// Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime)
// so I force a NULL into it (I don't think it's possible
// to have an empty default value for DATETIME)
// then, the "if" after this one will work
if ($column['Type'] == 'datetime'
&& ! isset($column['Default'])
&& isset($column['Null'])
&& $column['Null'] == 'YES'
) {
$column['Default'] = null;
}
}
/**
* Analyze the table column array
*
* @param array $column description of column in given table
* @param array $comments_map comments for every column that has a comment
* @param integer $timestamp_seen 0 interger
*
* @return array description of column in given table
*/
function PMA_analyzeTableColumnsArray($column, $comments_map, $timestamp_seen)
{
$column['Field_html'] = htmlspecialchars($column['Field']);
$column['Field_md5'] = md5($column['Field']);
// True_Type contains only the type (stops at first bracket)
$column['True_Type'] = preg_replace('@\(.*@s', '', $column['Type']);
PMA_getDefaultForDatetime($column);
$column['len'] = preg_match('@float|double@', $column['Type']) ? 100 : -1;
$column['Field_title'] = PMA_getColumnTitle($column, $comments_map);
$column['is_binary'] = PMA_isColumnBinary($column);
$column['is_blob'] = PMA_isColumnBlob($column);
$column['is_char'] = PMA_isColumnChar($column);
list($column['pma_type'], $column['wrap'], $column['first_timestamp']) =
PMA_getEnumSetAndTimestampColumns($column, $timestamp_seen);
return $column;
}
/**
* Retrieve the column title
*
* @param array $column description of column in given table
* @param array $comments_map comments for every column that has a comment
*
* @return string column title
*/
function PMA_getColumnTitle($column, $comments_map)
{
if (isset($comments_map[$column['Field']])) {
return ''
. $column['Field_html'] . '';
} else {
return $column['Field_html'];
}
}
/**
* check whether the column is a bainary
*
* @param array $column description of column in given table
*
* @return boolean If check to ensure types such as "enum('one','two','binary',..)" or
* "enum('one','two','varbinary',..)" are not categorized as binary.
*/
function PMA_isColumnBinary($column)
{
// The type column.
// Fix for bug #3152931 'ENUM and SET cannot have "Binary" option'
if (stripos($column['Type'], 'binary') === 0
|| stripos($column['Type'], 'varbinary') === 0
) {
return stristr($column['Type'], 'binary');
} else {
return false;
}
}
/**
* check whether the column is a blob
*
* @param array $column description of column in given table
*
* @return boolean If check to ensure types such as "enum('one','two','blob',..)" or
* "enum('one','two','tinyblob',..)" etc. are not categorized as blob.
*/
function PMA_isColumnBlob($column)
{
if (stripos($column['Type'], 'blob') === 0
|| stripos($column['Type'], 'tinyblob') === 0
|| stripos($column['Type'], 'mediumblob') === 0
|| stripos($column['Type'], 'longblob') === 0
) {
return stristr($column['Type'], 'blob');
} else {
return false;
}
}
/**
* check is table column char
*
* @param array $column description of column in given table
*
* @return boolean If check to ensure types such as "enum('one','two','char',..)" or
* "enum('one','two','varchar',..)" are not categorized as char.
*/
function PMA_isColumnChar($column)
{
if (stripos($column['Type'], 'char') === 0
|| stripos($column['Type'], 'varchar') === 0
) {
return stristr($column['Type'], 'char');
} else {
return false;
}
}
/**
* Retieve set, enum, timestamp table columns
*
* @param array $column description of column in given table
* @param int $timestamp_seen 0 interger
*
* return array $column['pma_type'], $column['wrap'], $column['first_timestamp']
*/
function PMA_getEnumSetAndTimestampColumns($column, $timestamp_seen)
{
$column['first_timestamp'] = false;
switch ($column['True_Type']) {
case 'set':
$column['pma_type'] = 'set';
$column['wrap'] = '';
break;
case 'enum':
$column['pma_type'] = 'enum';
$column['wrap'] = '';
break;
case 'timestamp':
if (!$timestamp_seen) { // can only occur once per table
$timestamp_seen = 1;
$column['first_timestamp'] = true;
}
$column['pma_type'] = $column['Type'];
$column['wrap'] = ' nowrap';
break;
default:
$column['pma_type'] = $column['Type'];
$column['wrap'] = ' nowrap';
break;
}
return array($column['pma_type'], $column['wrap'], $column['first_timestamp']);
}
/**
* The function column
* We don't want binary data to be destroyed
* Note: from the MySQL manual: "BINARY doesn't affect how the column is
* stored or retrieved" so it does not mean that the contents is binary
*
* @param array $column description of column in given table
* @param boolean $is_upload upload or no
* @param string $column_name_appendix the name atttibute
* @param string $unnullify_trigger validation string
* @param array $no_support_types list of datatypes that are not (yet) handled by PMA
* @param integer $tabindex_for_function +3000
* @param integer $tabindex tab index
* @param integer $idindex id index
* @param boolean $insert_mode insert mode or edit mode
*
* @return string an html sippet
*/
function PMA_getFunctionColumn($column, $is_upload, $column_name_appendix,
$unnullify_trigger, $no_support_types, $tabindex_for_function,
$tabindex, $idindex, $insert_mode
) {
$html_output = '';
if (($GLOBALS['cfg']['ProtectBinary'] && $column['is_blob'] && !$is_upload)
|| ($GLOBALS['cfg']['ProtectBinary'] == 'all' && $column['is_binary'])
|| ($GLOBALS['cfg']['ProtectBinary'] == 'noblob' && !$column['is_blob'])
) {
$html_output .= '
' . "\n";
}
return $html_output;
}
/**
* The null column
*
* @param array $column description of column in given table
* @param string $column_name_appendix the name atttibute
* @param array $real_null_value is column value null or not null
* @param integer $tabindex tab index
* @param integer $tabindex_for_null +6000
* @param integer $idindex id index
* @param array $vkey [multi_edit]['row_id']
* @param array $foreigners keys into foreign fields
* @param array $foreignData data about the foreign keys
*
* @return string an html snippet
*/
function PMA_getNullColumn($column, $column_name_appendix, $real_null_value,
$tabindex, $tabindex_for_null, $idindex, $vkey, $foreigners, $foreignData
) {
$html_output = '';
$html_output .= '
' . "\n";
if ($column['Null'] == 'YES') {
$html_output .= ' ';
// nullify_code is needed by the js nullify() function
$nullify_code = PMA_getNullifyCodeForNullColumn($column, $foreigners, $foreignData);
// to be able to generate calls to nullify() in jQuery
$html_output .= '';
$html_output .= '';
$html_output .= '';
}
$html_output .= '
' . "\n";
return $html_output;
}
/**
* Retrieve the nullify code for the null column
*
* @param array $column description of column in given table
* @param array $foreigners keys into foreign fields
* @param array $foreignData data about the foreign keys
*
* @return integer $nullify_code
*/
function PMA_getNullifyCodeForNullColumn($column, $foreigners, $foreignData)
{
if (strstr($column['True_Type'], 'enum')) {
if (strlen($column['Type']) > 20) {
$nullify_code = '1';
} else {
$nullify_code = '2';
}
} elseif (strstr($column['True_Type'], 'set')) {
$nullify_code = '3';
} elseif ($foreigners && isset($foreigners[$column['Field']]) && $foreignData['foreign_link'] == false) {
// foreign key in a drop-down
$nullify_code = '4';
} elseif ($foreigners && isset($foreigners[$column['Field']]) && $foreignData['foreign_link'] == true) {
// foreign key with a browsing icon
$nullify_code = '6';
} else {
$nullify_code = '5';
}
return $nullify_code;
}
/**
* Get the HTML elements for value column in inert form
*
* @param array $column description of column in given table
* @param string $backup_field hidden input field
* @param string $column_name_appendix the name atttibute
* @param string $unnullify_trigger validation string
* @param integer $tabindex tab index
* @param integer $tabindex_for_value offset for the values tabindex
* @param integer $idindex id index
* @param array $data description of the column field
* @param array $special_chars special characters
* @param array $foreignData data about the foreign keys
* @param array $paramTableDbArray array containing $db and $table
* @param array $rownumber_param &rownumber=row_id
* @param array $titles An HTML IMG tag for a particular icon from a theme,
* which may be an actual file or an icon from a sprite
* @param array $text_dir
* @param string $special_chars_encoded replaced char if the string starts
* with a \r\n pair (0x0d0a) add an extra \n
* @param integer $biggest_max_file_size 0 intger
* @param string $default_char_editing default char editing mode which is stroe
* in the config.inc.php script
* @param array $no_support_types list of datatypes that are not (yet) handled by PMA
* @param array $gis_data_types list of GIS data types
*
* @return string an html snippet
*/
function PMA_getValueColumn($column, $backup_field, $column_name_appendix,
$unnullify_trigger,$tabindex, $tabindex_for_value, $idindex, $data,
$special_chars, $foreignData, $odd_row, $paramTableDbArray,$rownumber_param,
$titles, $text_dir, $special_chars_encoded, $vkey,$is_upload,$biggest_max_file_size,
$default_char_editing, $no_support_types, $gis_data_types, $extracted_columnspec
) {
$html_output = '';
if ($foreignData['foreign_link'] == true) {
$html_output .= PMA_getForeignLink($column, $backup_field, $column_name_appendix,
$unnullify_trigger, $tabindex, $tabindex_for_value, $idindex, $data,
$paramTableDbArray, $rownumber_param, $titles
);
} elseif (is_array($foreignData['disp_row'])) {
$html_output .= PMA_dispRowForeignData($backup_field, $column_name_appendix,
$unnullify_trigger, $tabindex, $tabindex_for_value, $idindex, $data, $foreignData
);
} elseif ($GLOBALS['cfg']['LongtextDoubleTextarea'] && strstr($column['pma_type'], 'longtext')) {
$html_output = ' ';
$html_output .= '';
$html_output .= '