Make default functions configurable (RFE #821271).
This commit is contained in:
@@ -5,6 +5,11 @@ phpMyAdmin - Changelog
|
|||||||
$Id$
|
$Id$
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
|
2003-10-20 Michal Cihar <nijel@users.sourceforge.net>
|
||||||
|
* Documentation, config.inc.php3, tbl_change.php3,
|
||||||
|
libraries/common.lib.php3, libraries/config_import.lib.php3: Make
|
||||||
|
default functions configurable (RFE #821271).
|
||||||
|
|
||||||
2003-10-18 Marc Delisle <lem9@users.sourceforge.net>
|
2003-10-18 Marc Delisle <lem9@users.sourceforge.net>
|
||||||
* libraries/common.lib.php3: bug 821512, Safari 1.0 v85.5 and fonts
|
* libraries/common.lib.php3: bug 821512, Safari 1.0 v85.5 and fonts
|
||||||
* libraries/functions.js: bug 825665, scratchboard and paper size
|
* libraries/functions.js: bug 825665, scratchboard and paper size
|
||||||
|
@@ -1912,6 +1912,31 @@ $cfg['PmaAbsoluteUri'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
|
|||||||
<br /><br />
|
<br /><br />
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
<dt><b>$cfg['RestrictColumnTypes'] </b>array</dt>
|
||||||
|
<dd>
|
||||||
|
Mapping of column types to meta types used for prefering displayed
|
||||||
|
functions. In most cases you don't need to edit this.
|
||||||
|
<br /><br />
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt><b>$cfg['RestrictFunctions'] </b>array</dt>
|
||||||
|
<dd>
|
||||||
|
Functions prefered for column meta types as defined in
|
||||||
|
<code>$cfg['RestrictColumnTypes']</code>. In most cases you don't need
|
||||||
|
to edit this.
|
||||||
|
<br /><br />
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt><b>$cfg['DefaultFunctions'] </b>array</dt>
|
||||||
|
<dd>
|
||||||
|
Functions selected by default when insering/changing row, Functions
|
||||||
|
are defined for meta types from
|
||||||
|
<code>$cfg['RestrictColumnTypes']</code> and for
|
||||||
|
<code>first_timestamp</code>, which is used for first timestamp column
|
||||||
|
in table.
|
||||||
|
<br /><br />
|
||||||
|
</dd>
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<!-- TRANSFORMATIONS -->
|
<!-- TRANSFORMATIONS -->
|
||||||
|
@@ -14,8 +14,8 @@
|
|||||||
+ Version history: ChangeLog
|
+ Version history: ChangeLog
|
||||||
+ General notes: README
|
+ General notes: README
|
||||||
+ License: LICENSE
|
+ License: LICENSE
|
||||||
* Documentation version: $Id: Documentation.html,v 1.509 2003/10/13
|
* Documentation version: $Id: Documentation.html,v 1.510 2003/10/16
|
||||||
00:53:11 lem9 Exp $
|
15:22:11 nijel Exp $
|
||||||
|
|
||||||
Requirements
|
Requirements
|
||||||
|
|
||||||
@@ -1300,6 +1300,21 @@ $cfg['PmaAbsoluteUri'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
|
|||||||
A list of functions MySQL supports. In most cases you don't
|
A list of functions MySQL supports. In most cases you don't
|
||||||
need to edit this.
|
need to edit this.
|
||||||
|
|
||||||
|
$cfg['RestrictColumnTypes'] array
|
||||||
|
Mapping of column types to meta types used for prefering
|
||||||
|
displayed functions. In most cases you don't need to edit this.
|
||||||
|
|
||||||
|
$cfg['RestrictFunctions'] array
|
||||||
|
Functions prefered for column meta types as defined in
|
||||||
|
$cfg['RestrictColumnTypes']. In most cases you don't need to
|
||||||
|
edit this.
|
||||||
|
|
||||||
|
$cfg['DefaultFunctions'] array
|
||||||
|
Functions selected by default when insering/changing row,
|
||||||
|
Functions are defined for meta types from
|
||||||
|
$cfg['RestrictColumnTypes'] and for first_timestamp, which is
|
||||||
|
used for first timestamp column in table.
|
||||||
|
|
||||||
Transformations
|
Transformations
|
||||||
|
|
||||||
Introduction - Usage - File structure -
|
Introduction - Usage - File structure -
|
||||||
|
@@ -724,6 +724,15 @@ if ($cfg['ShowFunctionFields']) {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Default functions for above defined groups
|
||||||
|
$cfg['DefaultFunctions'] = array(
|
||||||
|
'FUNC_CHAR' => '',
|
||||||
|
'FUNC_DATE' => '',
|
||||||
|
'FUNC_NUMBER' => '',
|
||||||
|
'first_timestamp' => 'NOW'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
} // end if
|
} // end if
|
||||||
|
|
||||||
|
|
||||||
|
@@ -135,7 +135,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
|||||||
* Includes compatibility code for older config.inc.php3 revisions
|
* Includes compatibility code for older config.inc.php3 revisions
|
||||||
* if necessary
|
* if necessary
|
||||||
*/
|
*/
|
||||||
if (!isset($cfg['FileRevision']) || (int) substr($cfg['FileRevision'], 13, 3) < 203) {
|
if (!isset($cfg['FileRevision']) || (int) substr($cfg['FileRevision'], 13, 3) < 206) {
|
||||||
include('./libraries/config_import.lib.php3');
|
include('./libraries/config_import.lib.php3');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1012,109 +1012,120 @@ if (!defined('PMA_CONFIG_IMPORT_LIB_INCLUDED')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($cfg['Functions']) && $cfg['ShowFunctionFields']) {
|
if ($cfg['ShowFunctionFields']) {
|
||||||
if (isset($cfgFunctions)) {
|
if (!isset($cfg['Functions'])) {
|
||||||
$cfg['Functions'] = $cfgFunctions;
|
if (isset($cfgFunctions)) {
|
||||||
} else {
|
$cfg['Functions'] = $cfgFunctions;
|
||||||
$cfg['Functions'] = array(
|
} else {
|
||||||
'ASCII',
|
$cfg['Functions'] = array(
|
||||||
'CHAR',
|
'ASCII',
|
||||||
'SOUNDEX',
|
'CHAR',
|
||||||
'LCASE',
|
'SOUNDEX',
|
||||||
'UCASE',
|
'LCASE',
|
||||||
'NOW',
|
'UCASE',
|
||||||
'PASSWORD',
|
'NOW',
|
||||||
'MD5',
|
'PASSWORD',
|
||||||
'ENCRYPT',
|
'MD5',
|
||||||
'RAND',
|
'ENCRYPT',
|
||||||
'LAST_INSERT_ID',
|
'RAND',
|
||||||
'COUNT',
|
'LAST_INSERT_ID',
|
||||||
'AVG',
|
'COUNT',
|
||||||
'SUM',
|
'AVG',
|
||||||
'CURDATE',
|
'SUM',
|
||||||
'CURTIME',
|
'CURDATE',
|
||||||
'FROM_DAYS',
|
'CURTIME',
|
||||||
'FROM_UNIXTIME',
|
'FROM_DAYS',
|
||||||
'PERIOD_ADD',
|
'FROM_UNIXTIME',
|
||||||
'PERIOD_DIFF',
|
'PERIOD_ADD',
|
||||||
'TO_DAYS',
|
'PERIOD_DIFF',
|
||||||
'UNIX_TIMESTAMP',
|
'TO_DAYS',
|
||||||
'USER',
|
'UNIX_TIMESTAMP',
|
||||||
'WEEKDAY',
|
'USER',
|
||||||
'CONCAT'
|
'WEEKDAY',
|
||||||
|
'CONCAT'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Which column types will be mapped to which Group?
|
||||||
|
$cfg['RestrictColumnTypes'] = array(
|
||||||
|
'VARCHAR' => 'FUNC_CHAR',
|
||||||
|
'TINYINT' => 'FUNC_NUMBER',
|
||||||
|
'TEXT' => 'FUNC_CHAR',
|
||||||
|
'DATE' => 'FUNC_DATE',
|
||||||
|
'SMALLINT' => 'FUNC_NUMBER',
|
||||||
|
'MEDIUMINT' => 'FUNC_NUMBER',
|
||||||
|
'INT' => 'FUNC_NUMBER',
|
||||||
|
'BIGINT' => 'FUNC_NUMBER',
|
||||||
|
'FLOAT' => 'FUNC_NUMBER',
|
||||||
|
'DOUBLE' => 'FUNC_NUMBER',
|
||||||
|
'DECIMAL' => 'FUNC_NUMBER',
|
||||||
|
'DATETIME' => 'FUNC_DATE',
|
||||||
|
'TIMESTAMP' => 'FUNC_DATE',
|
||||||
|
'TIME' => 'FUNC_DATE',
|
||||||
|
'YEAR' => 'FUNC_DATE',
|
||||||
|
'CHAR' => 'FUNC_CHAR',
|
||||||
|
'TINYBLOB' => 'FUNC_CHAR',
|
||||||
|
'TINYTEXT' => 'FUNC_CHAR',
|
||||||
|
'BLOB' => 'FUNC_CHAR',
|
||||||
|
'MEDIUMBLOB' => 'FUNC_CHAR',
|
||||||
|
'MEDIUMTEXT' => 'FUNC_CHAR',
|
||||||
|
'LONGBLOB' => 'FUNC_CHAR',
|
||||||
|
'LONGTEXT' => 'FUNC_CHAR',
|
||||||
|
'ENUM' => '',
|
||||||
|
'SET' => ''
|
||||||
|
);
|
||||||
|
|
||||||
|
// Map above defined groups to any function
|
||||||
|
$cfg['RestrictFunctions'] = array(
|
||||||
|
'FUNC_CHAR' => array(
|
||||||
|
'ASCII',
|
||||||
|
'CHAR',
|
||||||
|
'SOUNDEX',
|
||||||
|
'LCASE',
|
||||||
|
'UCASE',
|
||||||
|
'PASSWORD',
|
||||||
|
'MD5',
|
||||||
|
'ENCRYPT',
|
||||||
|
'LAST_INSERT_ID',
|
||||||
|
'USER',
|
||||||
|
'CONCAT'
|
||||||
|
),
|
||||||
|
|
||||||
|
'FUNC_DATE' => array(
|
||||||
|
'NOW',
|
||||||
|
'CURDATE',
|
||||||
|
'CURTIME',
|
||||||
|
'FROM_DAYS',
|
||||||
|
'FROM_UNIXTIME',
|
||||||
|
'PERIOD_ADD',
|
||||||
|
'PERIOD_DIFF',
|
||||||
|
'TO_DAYS',
|
||||||
|
'UNIX_TIMESTAMP',
|
||||||
|
'WEEKDAY'
|
||||||
|
),
|
||||||
|
|
||||||
|
'FUNC_NUMBER' => array(
|
||||||
|
'ASCII',
|
||||||
|
'CHAR',
|
||||||
|
'MD5',
|
||||||
|
'ENCRYPT',
|
||||||
|
'RAND',
|
||||||
|
'LAST_INSERT_ID',
|
||||||
|
'COUNT',
|
||||||
|
'AVG',
|
||||||
|
'SUM'
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Which column types will be mapped to which Group?
|
if (!isset($cfg['DefaultFunctions'])) {
|
||||||
$cfg['RestrictColumnTypes'] = array(
|
$cfg['DefaultFunctions'] = array(
|
||||||
'VARCHAR' => 'FUNC_CHAR',
|
'FUNC_CHAR' => '',
|
||||||
'TINYINT' => 'FUNC_NUMBER',
|
'FUNC_DATE' => '',
|
||||||
'TEXT' => 'FUNC_CHAR',
|
'FUNC_NUMBER' => '',
|
||||||
'DATE' => 'FUNC_DATE',
|
'first_timestamp' => 'NOW'
|
||||||
'SMALLINT' => 'FUNC_NUMBER',
|
);
|
||||||
'MEDIUMINT' => 'FUNC_NUMBER',
|
}
|
||||||
'INT' => 'FUNC_NUMBER',
|
|
||||||
'BIGINT' => 'FUNC_NUMBER',
|
|
||||||
'FLOAT' => 'FUNC_NUMBER',
|
|
||||||
'DOUBLE' => 'FUNC_NUMBER',
|
|
||||||
'DECIMAL' => 'FUNC_NUMBER',
|
|
||||||
'DATETIME' => 'FUNC_DATE',
|
|
||||||
'TIMESTAMP' => 'FUNC_DATE',
|
|
||||||
'TIME' => 'FUNC_DATE',
|
|
||||||
'YEAR' => 'FUNC_DATE',
|
|
||||||
'CHAR' => 'FUNC_CHAR',
|
|
||||||
'TINYBLOB' => 'FUNC_CHAR',
|
|
||||||
'TINYTEXT' => 'FUNC_CHAR',
|
|
||||||
'BLOB' => 'FUNC_CHAR',
|
|
||||||
'MEDIUMBLOB' => 'FUNC_CHAR',
|
|
||||||
'MEDIUMTEXT' => 'FUNC_CHAR',
|
|
||||||
'LONGBLOB' => 'FUNC_CHAR',
|
|
||||||
'LONGTEXT' => 'FUNC_CHAR',
|
|
||||||
'ENUM' => '',
|
|
||||||
'SET' => ''
|
|
||||||
);
|
|
||||||
|
|
||||||
// Map above defined groups to any function
|
|
||||||
$cfg['RestrictFunctions'] = array(
|
|
||||||
'FUNC_CHAR' => array(
|
|
||||||
'ASCII',
|
|
||||||
'CHAR',
|
|
||||||
'SOUNDEX',
|
|
||||||
'LCASE',
|
|
||||||
'UCASE',
|
|
||||||
'PASSWORD',
|
|
||||||
'MD5',
|
|
||||||
'ENCRYPT',
|
|
||||||
'LAST_INSERT_ID',
|
|
||||||
'USER',
|
|
||||||
'CONCAT'
|
|
||||||
),
|
|
||||||
|
|
||||||
'FUNC_DATE' => array(
|
|
||||||
'NOW',
|
|
||||||
'CURDATE',
|
|
||||||
'CURTIME',
|
|
||||||
'FROM_DAYS',
|
|
||||||
'FROM_UNIXTIME',
|
|
||||||
'PERIOD_ADD',
|
|
||||||
'PERIOD_DIFF',
|
|
||||||
'TO_DAYS',
|
|
||||||
'UNIX_TIMESTAMP',
|
|
||||||
'WEEKDAY'
|
|
||||||
),
|
|
||||||
|
|
||||||
'FUNC_NUMBER' => array(
|
|
||||||
'ASCII',
|
|
||||||
'CHAR',
|
|
||||||
'MD5',
|
|
||||||
'ENCRYPT',
|
|
||||||
'RAND',
|
|
||||||
'LAST_INSERT_ID',
|
|
||||||
'COUNT',
|
|
||||||
'AVG',
|
|
||||||
'SUM'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($cfg['GD2Available'])) {
|
if (!isset($cfg['GD2Available'])) {
|
||||||
|
@@ -360,7 +360,9 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
|||||||
// or something similar. Then directly look up the entry in the RestrictFunctions array,
|
// or something similar. Then directly look up the entry in the RestrictFunctions array,
|
||||||
// which will then reveal the available dropdown options
|
// which will then reveal the available dropdown options
|
||||||
if (isset($cfg['RestrictFunctions']) && isset($cfg['RestrictColumnTypes']) && isset($cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]) && isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]])) {
|
if (isset($cfg['RestrictFunctions']) && isset($cfg['RestrictColumnTypes']) && isset($cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]) && isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]])) {
|
||||||
$dropdown = $cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]];
|
$current_func_type = $cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])];
|
||||||
|
$dropdown = $cfg['RestrictFunctions'][$current_func_type];
|
||||||
|
$default_function = $cfg['DefaultFunctions'][$current_func_type];
|
||||||
} else {
|
} else {
|
||||||
$dropdown = array();
|
$dropdown = array();
|
||||||
}
|
}
|
||||||
@@ -370,9 +372,9 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
|||||||
|
|
||||||
// garvin: loop on the dropdown array and print all available options for that field.
|
// garvin: loop on the dropdown array and print all available options for that field.
|
||||||
for ($j = 0; $j < count($dropdown); $j++) {
|
for ($j = 0; $j < count($dropdown); $j++) {
|
||||||
// for default function = NOW() on first timestamp field
|
// Is current function defined as default?
|
||||||
// -- swix/18jul01
|
$selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp'])
|
||||||
$selected = ($first_timestamp && $dropdown[$j] == 'NOW')
|
|| (!$first_timestamp && $dropdown[$j] == $default_function)
|
||||||
? ' selected="selected"'
|
? ' selected="selected"'
|
||||||
: '';
|
: '';
|
||||||
echo ' ';
|
echo ' ';
|
||||||
@@ -386,9 +388,9 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
|||||||
// yet.
|
// yet.
|
||||||
for ($j = 0; $j < count($cfg['Functions']); $j++) {
|
for ($j = 0; $j < count($cfg['Functions']); $j++) {
|
||||||
if (!isset($dropdown_built[$cfg['Functions'][$j]]) || $dropdown_built[$cfg['Functions'][$j]] != 'TRUE') {
|
if (!isset($dropdown_built[$cfg['Functions'][$j]]) || $dropdown_built[$cfg['Functions'][$j]] != 'TRUE') {
|
||||||
// for default function = NOW() on first timestamp field
|
// Is current function defined as default?
|
||||||
// -- swix/18jul01
|
$selected = ($first_timestamp && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp'])
|
||||||
$selected = ($first_timestamp && $cfg['Functions'][$j] == 'NOW')
|
|| (!$first_timestamp && $cfg['Functions'][$j] == $default_function)
|
||||||
? ' selected="selected"'
|
? ' selected="selected"'
|
||||||
: '';
|
: '';
|
||||||
if ($op_spacing_needed == TRUE) {
|
if ($op_spacing_needed == TRUE) {
|
||||||
|
Reference in New Issue
Block a user