improve js validators

add missing validations and language strings
This commit is contained in:
Crack
2010-06-16 23:54:35 +02:00
parent eb31291dca
commit c7b304b6e6
6 changed files with 81 additions and 52 deletions

View File

@@ -169,13 +169,16 @@ var validate = {};
// form validator list // form validator list
var validators = { var validators = {
// regexp: numeric value // regexp: numeric value
_regexp_numeric: new RegExp('^[0-9]*$'), _regexp_numeric: new RegExp('^[0-9]+$'),
/** /**
* Validates positive number * Validates positive number
* *
* @param {boolean} isKeyUp * @param {boolean} isKeyUp
*/ */
validate_positive_number: function (isKeyUp) { validate_positive_number: function (isKeyUp) {
if (isKeyUp && this.value == '') {
return true;
}
var result = this.value != '0' && validators._regexp_numeric.test(this.value); var result = this.value != '0' && validators._regexp_numeric.test(this.value);
return result ? true : PMA_messages['error_nan_p']; return result ? true : PMA_messages['error_nan_p'];
}, },
@@ -185,6 +188,9 @@ var validators = {
* @param {boolean} isKeyUp * @param {boolean} isKeyUp
*/ */
validate_non_negative_number: function (isKeyUp) { validate_non_negative_number: function (isKeyUp) {
if (isKeyUp && this.value == '') {
return true;
}
var result = validators._regexp_numeric.test(this.value); var result = validators._regexp_numeric.test(this.value);
return result ? true : PMA_messages['error_nan_nneg']; return result ? true : PMA_messages['error_nan_nneg'];
}, },
@@ -194,6 +200,9 @@ var validators = {
* @param {boolean} isKeyUp * @param {boolean} isKeyUp
*/ */
validate_port_number: function(isKeyUp) { validate_port_number: function(isKeyUp) {
if (isKeyUp && this.value == '') {
return true;
}
var result = validators._regexp_numeric.test(this.value) && this.value != '0'; var result = validators._regexp_numeric.test(this.value) && this.value != '0';
if (!result || this.value > 65536) { if (!result || this.value > 65536) {
result = PMA_messages['error_incorrect_port']; result = PMA_messages['error_incorrect_port'];

View File

@@ -39,6 +39,7 @@ $cfg_db['LeftDefaultTabTable'] = array(
$cfg_db['NavigationBarIconic'] = array(true, false, 'both'); $cfg_db['NavigationBarIconic'] = array(true, false, 'both');
$cfg_db['Order'] = array('ASC', 'DESC', 'SMART'); $cfg_db['Order'] = array('ASC', 'DESC', 'SMART');
$cfg_db['ProtectBinary'] = array(false, 'blob', 'all'); $cfg_db['ProtectBinary'] = array(false, 'blob', 'all');
$cfg_db['DefaultDisplay'] = array('horizontal', 'vertical', 'horizontalflipped');
$cfg_db['CharEditing'] = array('input', 'textarea'); $cfg_db['CharEditing'] = array('input', 'textarea');
$cfg_db['PropertiesIconic'] = array(true, false, 'both'); $cfg_db['PropertiesIconic'] = array(true, false, 'both');
$cfg_db['DefaultTabServer'] = array( $cfg_db['DefaultTabServer'] = array(
@@ -97,20 +98,26 @@ $cfg_db['_overrides']['Servers/1/extension'] = extension_loaded('mysqli')
* Use only full paths and form ids * Use only full paths and form ids
*/ */
$cfg_db['_validators'] = array( $cfg_db['_validators'] = array(
'CharTextareaCols' => 'validate_positive_number',
'CharTextareaRows' => 'validate_positive_number',
'DefaultPropDisplay' => 'validate_DefaultPropDisplay',
'ForeignKeyMaxLimit' => 'validate_positive_number',
'Import/skip_queries' => 'validate_non_negative_number',
'InsertRows' => 'validate_positive_number',
'LeftFrameTableLevel' => 'validate_positive_number',
'LimitChars' => 'validate_positive_number',
'LoginCookieValidity' => 'validate_positive_number',
'LoginCookieStore' => 'validate_non_negative_number',
'MaxCharactersInDisplayedSQL' => 'validate_positive_number',
'MaxRows' => 'validate_positive_number',
'QueryHistoryMax' => 'validate_positive_number',
'QueryWindowWidth' => 'validate_positive_number',
'QueryWindowHeight' => 'validate_positive_number',
'RepeatCells' => 'validate_non_negative_number',
'Server' => 'validate_server', 'Server' => 'validate_server',
'Server_pmadb' => 'validate_pmadb', 'Server_pmadb' => 'validate_pmadb',
'Servers/1/port' => 'validate_port_number', 'Servers/1/port' => 'validate_port_number',
'Servers/1/hide_db' => 'validate_regex', 'Servers/1/hide_db' => 'validate_regex',
'TrustedProxies' => 'validate_trusted_proxies', 'TextareaCols' => 'validate_positive_number',
'LoginCookieValidity' => 'validate_positive_number', 'TrustedProxies' => 'validate_trusted_proxies');
'LoginCookieStore' => 'validate_non_negative_number',
'QueryHistoryMax' => 'validate_positive_number',
'LeftFrameTableLevel' => 'validate_positive_number',
'MaxRows' => 'validate_positive_number',
'CharTextareaCols' => 'validate_positive_number',
'CharTextareaRows' => 'validate_positive_number',
'InsertRows' => 'validate_positive_number',
'ForeignKeyMaxLimit' => 'validate_positive_number',
'DefaultPropDisplay' => 'validate_DefaultPropDisplay',
'Import/skip_queries' => 'validate_non_negative_number');
?> ?>

View File

@@ -43,6 +43,7 @@ $strSetupConfirm_name = __('Confirm DROP queries');
$strSetupCtrlArrowsMoving_name = __('Field navigation using Ctrl+Arrows'); $strSetupCtrlArrowsMoving_name = __('Field navigation using Ctrl+Arrows');
$strSetupDefaultCharset_desc = __('Default character set used for conversions'); $strSetupDefaultCharset_desc = __('Default character set used for conversions');
$strSetupDefaultCharset_name = __('Default character set'); $strSetupDefaultCharset_name = __('Default character set');
$strSetupDefaultDisplay_name = __('Default display direction');
$strSetupDefaultLanguage = __('Default language'); $strSetupDefaultLanguage = __('Default language');
$strSetupDefaultPropDisplay_name = __('Display direction for altering/creating columns'); $strSetupDefaultPropDisplay_name = __('Display direction for altering/creating columns');
$strSetupDefaultPropDisplay_desc = __('[kbd]horizontal[/kbd], [kbd]vertical[/kbd] or a number that indicates maximum number for which vertical model is used'); $strSetupDefaultPropDisplay_desc = __('[kbd]horizontal[/kbd], [kbd]vertical[/kbd] or a number that indicates maximum number for which vertical model is used');
@@ -54,6 +55,8 @@ $strSetupDefaultTabServer_name = __('Default server tab');
$strSetupDefaultTabTable_desc = __('Tab that is displayed when entering a table'); $strSetupDefaultTabTable_desc = __('Tab that is displayed when entering a table');
$strSetupDefaultTabTable_name = __('Default table tab'); $strSetupDefaultTabTable_name = __('Default table tab');
$strSetupDirectoryNotice = __('This value should be double checked to ensure that this directory is neither world accessible nor readable or writable by other users on your server.'); $strSetupDirectoryNotice = __('This value should be double checked to ensure that this directory is neither world accessible nor readable or writable by other users on your server.');
$strSetupDisplayBinaryAsHex_name = __('Show binary contents as HEX');
$strSetupDisplayBinaryAsHex_desc = __('Show binary contents as HEX by default');
$strSetupDisplayDatabasesList_desc = __('Show database listing as a list instead of a drop down'); $strSetupDisplayDatabasesList_desc = __('Show database listing as a list instead of a drop down');
$strSetupDisplayDatabasesList_name = __('Display databases as a list'); $strSetupDisplayDatabasesList_name = __('Display databases as a list');
$strSetupDisplay = __('Display'); $strSetupDisplay = __('Display');
@@ -61,6 +64,8 @@ $strSetupDisplayServersList_desc = __('Show server listing as a list instead of
$strSetupDisplayServersList_name = __('Display servers as a list'); $strSetupDisplayServersList_name = __('Display servers as a list');
$strSetupDonateLink = __('Donate'); $strSetupDonateLink = __('Donate');
$strSetupDownload = __('Download'); $strSetupDownload = __('Download');
$strSetupEditInWindow_name = __('Edit in window');
$strSetupEditInWindow_desc = __('Edit SQL queries in popup window');
$strSetupEndOfLine = __('End of line'); $strSetupEndOfLine = __('End of line');
$strSetupErrorIconic_name = __('Iconic errors'); $strSetupErrorIconic_name = __('Iconic errors');
$strSetupErrorIconic_desc = __('Show icons for warning, error and information messages'); $strSetupErrorIconic_desc = __('Show icons for warning, error and information messages');
@@ -109,7 +114,7 @@ $strSetupForm_Other_core_settings = __('Other core settings');
$strSetupForm_Query_window_desc = __('Customize query window options'); $strSetupForm_Query_window_desc = __('Customize query window options');
$strSetupForm_Query_window = __('Query window'); $strSetupForm_Query_window = __('Query window');
$strSetupForm_Page_titles = __('Page titles'); $strSetupForm_Page_titles = __('Page titles');
$strSetupForm_Page_titles_desc = __('Specify windows\' title bar. Refer to [a@Documentation.html#cfg_TitleTable]documentation[/a] for magic strings that can be used to get special values.'); $strSetupForm_Page_titles_desc = __('Specify browser\'s title bar text. Refer to [a@Documentation.html#cfg_TitleTable]documentation[/a] for magic strings that can be used to get special values.');
$strSetupForm_Security_desc = __('Please note that phpMyAdmin is just a user interface and its features do not limit MySQL'); $strSetupForm_Security_desc = __('Please note that phpMyAdmin is just a user interface and its features do not limit MySQL');
$strSetupForm_Security = __('Security'); $strSetupForm_Security = __('Security');
$strSetupForm_Server = __('Basic settings'); $strSetupForm_Server = __('Basic settings');
@@ -178,6 +183,8 @@ $strSetupLeftPointerEnable_name = __('Enable highlighting');
$strSetupLetUserChoose = __('let the user choose'); $strSetupLetUserChoose = __('let the user choose');
$strSetupLightTabs_desc = __('Use less graphically intense tabs'); $strSetupLightTabs_desc = __('Use less graphically intense tabs');
$strSetupLightTabs_name = __('Light tabs'); $strSetupLightTabs_name = __('Light tabs');
$strSetupLimitChars_name = __('Limit column characters');
$strSetupLimitChars_desc = __('Maximum number of characters shown in any non-numeric column on browse view');
$strSetupLoad = __('Load'); $strSetupLoad = __('Load');
$strSetupLoginCookieDeleteAll_desc = __('If TRUE, logout deletes cookies for all servers; when set to FALSE, logout only occurs for the current server. Setting this to FALSE makes it easy to forget to log out from other servers when connected to multiple servers.'); $strSetupLoginCookieDeleteAll_desc = __('If TRUE, logout deletes cookies for all servers; when set to FALSE, logout only occurs for the current server. Setting this to FALSE makes it easy to forget to log out from other servers when connected to multiple servers.');
$strSetupLoginCookieDeleteAll_name = __('Delete all cookies on logout'); $strSetupLoginCookieDeleteAll_name = __('Delete all cookies on logout');
@@ -201,6 +208,8 @@ $strSetupMaxTableList_desc = __('Maximum number of tables displayed in table lis
$strSetupMaxTableList_name = __('Maximum tables'); $strSetupMaxTableList_name = __('Maximum tables');
$strSetupMemoryLimit_desc = __('The number of bytes a script is allowed to allocate, eg. [kbd]32M[/kbd] ([kbd]0[/kbd] for no limit)'); $strSetupMemoryLimit_desc = __('The number of bytes a script is allowed to allocate, eg. [kbd]32M[/kbd] ([kbd]0[/kbd] for no limit)');
$strSetupMemoryLimit_name = __('Memory limit'); $strSetupMemoryLimit_name = __('Memory limit');
$strSetupModifyDeleteAtLeft_name = __('Show left delete link');
$strSetupModifyDeleteAtRight_name = __('Show right delete link');
$strSetupNaturalOrder_name = __('Natural order'); $strSetupNaturalOrder_name = __('Natural order');
$strSetupNaturalOrder_desc = __('Use natural order for sorting table and database names'); $strSetupNaturalOrder_desc = __('Use natural order for sorting table and database names');
$strSetupNavigationBarIconic_desc = __('Use only icons, only text or both'); $strSetupNavigationBarIconic_desc = __('Use only icons, only text or both');
@@ -219,12 +228,18 @@ $strSetupPropertiesIconic_desc = __('Use only icons, only text or both');
$strSetupPropertiesIconic_name = __('Iconic table operations'); $strSetupPropertiesIconic_name = __('Iconic table operations');
$strSetupProtectBinary_desc = __('Disallow BLOB and BINARY columns from editing'); $strSetupProtectBinary_desc = __('Disallow BLOB and BINARY columns from editing');
$strSetupProtectBinary_name = __('Protect binary columns'); $strSetupProtectBinary_name = __('Protect binary columns');
$strSetupRepeatCells_name = __('Repeat headers');
$strSetupRepeatCells_desc = __('Repeat the headers every X cells, [kbd]0[/kbd] deactivates this feature');
$strSetupQueryHistoryDB_desc = __('Enable if you want DB-based query history (requires pmadb). If disabled, this utilizes JS-routines to display query history (lost by window close).'); $strSetupQueryHistoryDB_desc = __('Enable if you want DB-based query history (requires pmadb). If disabled, this utilizes JS-routines to display query history (lost by window close).');
$strSetupQueryHistoryDB_name = __('Permanent query history'); $strSetupQueryHistoryDB_name = __('Permanent query history');
$strSetupQueryHistoryMax_desc = __('How many queries are kept in history'); $strSetupQueryHistoryMax_desc = __('How many queries are kept in history');
$strSetupQueryHistoryMax_name = __('Query history length'); $strSetupQueryHistoryMax_name = __('Query history length');
$strSetupQueryWindowDefTab_desc = __('Tab displayed when opening a new query window'); $strSetupQueryWindowDefTab_desc = __('Tab displayed when opening a new query window');
$strSetupQueryWindowDefTab_name = __('Default query window tab'); $strSetupQueryWindowDefTab_name = __('Default query window tab');
$strSetupQueryWindowHeight_name = __('Query window height');
$strSetupQueryWindowHeight_desc = __('Query window height (in pixels)');
$strSetupQueryWindowWidth_name = __('Query window width');
$strSetupQueryWindowWidth_desc = __('Query window height (in pixels)');
$strSetupRecodingEngine_desc = __('Select which functions will be used for character set conversion'); $strSetupRecodingEngine_desc = __('Select which functions will be used for character set conversion');
$strSetupRecodingEngine_name = __('Recoding engine'); $strSetupRecodingEngine_name = __('Recoding engine');
$strSetupReplaceHelpImg_name = __('Show help button'); $strSetupReplaceHelpImg_name = __('Show help button');
@@ -328,6 +343,8 @@ $strSetupShowAll_name = __('Allow to display all the rows');
$strSetupShowChgPassword_desc = __('Please note that enabling this has no effect with [kbd]config[/kbd] authentication mode because the password is hard coded in the configuration file; this does not limit the ability to execute the same command directly'); $strSetupShowChgPassword_desc = __('Please note that enabling this has no effect with [kbd]config[/kbd] authentication mode because the password is hard coded in the configuration file; this does not limit the ability to execute the same command directly');
$strSetupShowChgPassword_name = __('Show password change form'); $strSetupShowChgPassword_name = __('Show password change form');
$strSetupShowCreateDb_name = __('Show create database form'); $strSetupShowCreateDb_name = __('Show create database form');
$strSetupShowFieldTypesInDataEditView_name = __('Show field types');
$strSetupShowFieldTypesInDataEditView_desc = __('Defines whether or not type fields should be initially displayed in edit/insert mode');
$strSetupShowForm = __('Show form'); $strSetupShowForm = __('Show form');
$strSetupShowFunctionFields_desc = __('Display the function fields in edit/insert mode'); $strSetupShowFunctionFields_desc = __('Display the function fields in edit/insert mode');
$strSetupShowFunctionFields_name = __('Show function fields'); $strSetupShowFunctionFields_name = __('Show function fields');

View File

@@ -16,30 +16,30 @@ $forms['Features']['Text_fields'] = array(
'CharEditing', 'CharEditing',
'CharTextareaCols', 'CharTextareaCols',
'CharTextareaRows', 'CharTextareaRows',
'TextareaCols',// [s-] 'TextareaCols',
'TextareaRows',// [s-] 'TextareaRows',
'LongtextDoubleTextarea');// [s-] 'LongtextDoubleTextarea');
$forms['Sql_queries']['Sql_queries'] = array( $forms['Sql_queries']['Sql_queries'] = array(
'ShowSQL', 'ShowSQL',
'Confirm', 'Confirm',
'IgnoreMultiSubmitErrors', 'IgnoreMultiSubmitErrors',
'VerboseMultiSubmit', 'VerboseMultiSubmit',
'MaxCharactersInDisplayedSQL',// [s-] 'MaxCharactersInDisplayedSQL',
'EditInWindow',// [s-] 'EditInWindow',
'QueryWindowWidth',// [s-] 'QueryWindowWidth',
'QueryWindowHeight',// [s-] 'QueryWindowHeight',
'QueryWindowDefTab');// [s-] 'QueryWindowDefTab');
$forms['Sql_queries']['Sql_box'] = array( $forms['Sql_queries']['Sql_box'] = array(
'SQLQuery/Edit',// [s-] 'SQLQuery/Edit',
'SQLQuery/Explain',// [s-] 'SQLQuery/Explain',
'SQLQuery/ShowAsPHP',// [s-] 'SQLQuery/ShowAsPHP',
'SQLQuery/Validate',// [false or no override] 'SQLQuery/Validate',// [false or no override]
'SQLQuery/Refresh');// [s-] 'SQLQuery/Refresh');
$forms['Features']['Page_titles'] = array( $forms['Features']['Page_titles'] = array(
'TitleDefault',// [s-] 'TitleDefault',
'TitleTable',// [s-] 'TitleTable',
'TitleDatabase',// [s-] 'TitleDatabase',
'TitleServer');// [s-] 'TitleServer');
$forms['Left_frame']['Left_frame'] = array( $forms['Left_frame']['Left_frame'] = array(
'LeftFrameLight', 'LeftFrameLight',
'LeftDisplayLogo', 'LeftDisplayLogo',
@@ -72,20 +72,20 @@ $forms['Main_frame']['Browse'] = array(
'DisplayBinaryAsHex', 'DisplayBinaryAsHex',
'BrowsePointerEnable', 'BrowsePointerEnable',
'BrowseMarkerEnable', 'BrowseMarkerEnable',
'RepeatCells',// [s-] 'RepeatCells',
'LimitChars',// [s-] 'LimitChars',
'ModifyDeleteAtLeft',// [s-] 'ModifyDeleteAtLeft',
'ModifyDeleteAtRight',// [s-] 'ModifyDeleteAtRight',
'DefaultDisplay');// [s-] 'DefaultDisplay');
$forms['Main_frame']['Edit'] = array( $forms['Main_frame']['Edit'] = array(
'ProtectBinary', 'ProtectBinary',
'ShowFunctionFields', 'ShowFunctionFields',
'ShowFieldTypesInDataEditView',// [s-] 'ShowFieldTypesInDataEditView',
'InsertRows', 'InsertRows',
'ForeignKeyDropdownOrder',// [s, ? custom text value] 'ForeignKeyDropdownOrder',// [s, ? custom text value]
'ForeignKeyMaxLimit', 'ForeignKeyMaxLimit',
'CtrlArrowsMoving', 'CtrlArrowsMoving',
'DefaultPropDisplay');// [s-] 'DefaultPropDisplay');
$forms['Main_frame']['Tabs'] = array( $forms['Main_frame']['Tabs'] = array(
'LightTabs', 'LightTabs',
'PropertiesIconic', 'PropertiesIconic',

View File

@@ -270,7 +270,7 @@ fieldset th small {
color: #666; color: #666;
} }
fieldset th, fieldset td { fieldset th, fieldset td, .form .lastrow {
border-top: 1px #555 dotted; border-top: 1px #555 dotted;
} }
@@ -280,10 +280,6 @@ fieldset .lastrow, .form .lastrow {
text-align: center; text-align: center;
} }
.form .lastrow {
border-top: 1px #555 dotted;
}
fieldset .lastrow input, .form .lastrow input { fieldset .lastrow input, .form .lastrow input {
font-weight: bold; font-weight: bold;
} }

View File

@@ -1228,14 +1228,14 @@ table#serverconnection_trg_local {
float:left; float:left;
} }
/** /**
* Validation error message styles * Validation error message styles<style>/*
*/ */
.invalid_value .invalid_value
{background:#F00;} {background:#F00;}
/* config forms */ /* config forms */
.config-form ul.tabs { .config-form ul.tabs {
margin: 1em 0.2em 0; margin: 1.1em 0.2em 0;
padding: 0 0 0.3em 0; padding: 0 0 0.3em 0;
list-style: none; list-style: none;
font-weight: bold; font-weight: bold;
@@ -1270,7 +1270,7 @@ table#serverconnection_trg_local {
margin-top: 0; margin-top: 0;
padding: 0; padding: 0;
clear: both; clear: both;
border-color: <?php echo $GLOBALS['cfg']['BgTwo']; ?>; /*border-color: <?php echo $GLOBALS['cfg']['BgTwo']; ?>;*/
} }
.config-form legend { .config-form legend {
@@ -1286,7 +1286,7 @@ table#serverconnection_trg_local {
margin: 0 -2px 1em -2px; margin: 0 -2px 1em -2px;
padding: 0.5em 1.5em; padding: 0.5em 1.5em;
background: #FBEAD9; background: #FBEAD9;
border: 1px #C83838 solid; border: 0 #C83838 solid;
border-width: 1px 0; border-width: 1px 0;
list-style: none; list-style: none;
font-family: sans-serif; font-family: sans-serif;
@@ -1327,8 +1327,12 @@ table#serverconnection_trg_local {
color: #444; color: #444;
} }
.config-form fieldset th, fieldset td { .config-form fieldset th, .config-form fieldset td {
border-top: 1px #666 dotted; border-top: 1px <?php echo $GLOBALS['cfg']['BgTwo']; ?> solid;
}
.config-form .lastrow {
border-top: 1px #000 solid;
} }
.config-form .lastrow { .config-form .lastrow {
@@ -1337,10 +1341,6 @@ table#serverconnection_trg_local {
text-align: center; text-align: center;
} }
.config-form .form .lastrow {
border-top: 1px #555 dotted;
}
.config-form .lastrow input { .config-form .lastrow input {
font-weight: bold; font-weight: bold;
} }