diff --git a/core/control/HTTPResponse.php b/core/control/HTTPResponse.php index c9e424a65..c184a1d23 100644 --- a/core/control/HTTPResponse.php +++ b/core/control/HTTPResponse.php @@ -230,4 +230,4 @@ class HTTPResponse extends Object { return $results; } -} \ No newline at end of file +} diff --git a/core/i18n.php b/core/i18n.php index 1eebd1ffe..942a2fcce 100755 --- a/core/i18n.php +++ b/core/i18n.php @@ -623,7 +623,7 @@ class i18n extends Object { 'lt' => array('Lithuanian', 'lietuviškai'), 'lmo' => array('Lombard', 'Lombardo'), 'mk' => array('Macedonian', 'македонски'), - 'mi' => array('Maori', 'Māori'), + 'mi' => array('Maori', 'Maori'), 'ms' => array('Malay', 'Bahasa melayu'), 'mt' => array('Maltese', 'Malti'), 'mr' => array('Marathi', 'मराठी'), diff --git a/core/model/fieldtypes/Date.php b/core/model/fieldtypes/Date.php index 9212583b7..0d8a41b7e 100644 --- a/core/model/fieldtypes/Date.php +++ b/core/model/fieldtypes/Date.php @@ -31,6 +31,10 @@ class Date extends DBField { if($this->value) return date('d/m/Y', strtotime($this->value)); } + function NiceUS() { + if($this->value) return date('m/d/Y', strtotime($this->value)); + } + /** * Returns the year from the given date */ diff --git a/forms/Validator.php b/forms/Validator.php index 083aa0f22..76c0aa61c 100755 --- a/forms/Validator.php +++ b/forms/Validator.php @@ -164,9 +164,10 @@ Behaviour.register({ validate : function(fromAnOnBlur) { initialiseForm(this, fromAnOnBlur); $code - + var error = hasHadFormError(); if(!error && fromAnOnBlur) clearErrorMessage(fromAnOnBlur); + if(error && !fromAnOnBlur) focusOnFirstErroredField(); return !error; }, diff --git a/javascript/Validator.js b/javascript/Validator.js index 2dd0b3b9b..fa4bd5581 100755 --- a/javascript/Validator.js +++ b/javascript/Validator.js @@ -1,7 +1,9 @@ var _CURRENT_FORM; +var _FIRST_ERRORED_FIELD = null; function initialiseForm(form, fromAnOnBlur) { _CURRENT_FORM = form; + _FIRST_ERRORED_FIELD = null; if(fromAnOnBlur) { limitValidationErrorsTo(fromAnOnBlur); @@ -17,6 +19,13 @@ function hasHadFormError() { return _HAS_HAD_FORM_ERROR || !_ERROR_CACHE; } +function focusOnFirstErroredField() { + try { + _FIRST_ERRORED_FIELD.focus(); + } catch(er) { + } +} + /** * Returns group with the correct classname */ @@ -259,6 +268,9 @@ function validationError(field,message, messageClass, cacheError) { // Keep a reference to it field.validationMessage = validationMessage; + // Keep a reference to the first errored field + if(field && !_FIRST_ERRORED_FIELD) _FIRST_ERRORED_FIELD = field; + // Set the attributes validationMessage.className = "message " + messageClass; validationMessage.innerHTML = message; diff --git a/security/Security.php b/security/Security.php index b0d4f1f36..7d9fb2fc6 100644 --- a/security/Security.php +++ b/security/Security.php @@ -193,7 +193,7 @@ class Security extends Controller { // Audit logging hook if($controller) $controller->extend('permissionDenied', $member); - Director::redirect("Security/login"); + Director::redirect("Security/login?BackURL=" . urlencode($_SERVER['REQUEST_URI'])); } return; } @@ -442,6 +442,7 @@ class Security extends Controller { $tmpPage = new Page(); $tmpPage->Title = _t('Security.LOSTPASSWORDHEADER'); $tmpPage->URLSegment = 'Security'; + $tmpPage->ID = -1; // Set the page ID to -1 so we dont get the top level pages as its children $controller = new Page_Controller($tmpPage); $controller->init(); @@ -479,6 +480,7 @@ class Security extends Controller { $tmpPage = new Page(); $tmpPage->Title = _t('Security.CHANGEPASSWORDHEADER', 'Change your password'); $tmpPage->URLSegment = 'Security'; + $tmpPage->ID = -1; // Set the page ID to -1 so we dont get the top level pages as its children $controller = new Page_Controller($tmpPage); $controller->init();