From b5156e26ae5430aa95f3745f7f813ba455459091 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 14 Sep 2007 19:13:12 +0000 Subject: [PATCH] mlanthaler: Login forms are now styled and use the tabstrip library. Make sure you create a CSS file "tabs.css" in your mysite/css folder with the following content, otherwise the tabs will be without border. Maybe it would be a good idea to create a mysite gsoc branch for changes like this. Will post that issue in the forum. div.tab { clear: left; overflow: auto; border: 1px #AAA solid; border-top: none; position: relative; top: -3px; margin: 0; padding: 10px; /*width: 98%;*/ } div.tabset { border: 1px solid #fff; /* Hack for FF1.5/Win Float-Bug */ clear: left; margin: 0; } ul.tabstrip li { margin-left: 0; } (merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@41786 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- security/Authenticator.php | 8 ++++++++ security/LoginForm.php | 28 ++++++++++++++++++++++++++++ security/MemberAuthenticator.php | 10 ++++++++++ security/MemberLoginForm.php | 21 ++++++++++++++++----- security/OpenIDAuthenticator.php | 10 ++++++++++ security/OpenIDLoginForm.php | 20 +++++++++++++++++--- security/Security.php | 7 ++++++- 7 files changed, 95 insertions(+), 9 deletions(-) create mode 100644 security/LoginForm.php diff --git a/security/Authenticator.php b/security/Authenticator.php index 34056562c..3b8657714 100644 --- a/security/Authenticator.php +++ b/security/Authenticator.php @@ -40,6 +40,14 @@ abstract class Authenticator extends Object * method */ public abstract static function getLoginForm(Controller $controller); + + + /** + * Get the name of the authentication method + * + * @return string Returns the name of the authentication method. + */ + public abstract static function getName(); } ?> \ No newline at end of file diff --git a/security/LoginForm.php b/security/LoginForm.php new file mode 100644 index 000000000..903e97b5f --- /dev/null +++ b/security/LoginForm.php @@ -0,0 +1,28 @@ + + */ +abstract class LoginForm extends Form +{ + /** + * Get the authenticator class + * + * @return Authenticator Returns the authenticator class for this login + * form. + */ + public abstract static function getAuthenticator(); +} + +?> \ No newline at end of file diff --git a/security/MemberAuthenticator.php b/security/MemberAuthenticator.php index 8c63605cd..7f195d648 100644 --- a/security/MemberAuthenticator.php +++ b/security/MemberAuthenticator.php @@ -55,6 +55,16 @@ class MemberAuthenticator extends Authenticator { public static function getLoginForm(Controller $controller) { return Object::create("MemberLoginForm", $controller, "LoginForm"); } + + + /** + * Get the name of the authentication method + * + * @return string Returns the name of the authentication method. + */ + public static function getName() { + return "Default login method"; + } } ?> \ No newline at end of file diff --git a/security/MemberLoginForm.php b/security/MemberLoginForm.php index 55a303f0b..5a2c520f9 100644 --- a/security/MemberLoginForm.php +++ b/security/MemberLoginForm.php @@ -9,7 +9,7 @@ /** * Log-in form for the "member" authentication method */ -class MemberLoginForm extends Form { +class MemberLoginForm extends LoginForm { /** * Constructor @@ -49,12 +49,12 @@ class MemberLoginForm extends Form { } else { if(!$fields) { $fields = new FieldSet( - new HiddenField("AuthenticationMethod", null, "Member"), + new HiddenField("AuthenticationMethod", null, "Member", $this), new TextField("Email", "Email address", - Session::get('SessionForms.MemberLoginForm.Email')), - new EncryptField("Password", "Password"), + Session::get('SessionForms.MemberLoginForm.Email'), null, $this), + new EncryptField("Password", "Password", null, $this), new CheckboxField("Remember", "Remember me next time?", - Session::get('SessionForms.MemberLoginForm.Remember')) + Session::get('SessionForms.MemberLoginForm.Remember'), $this) ); } if(!$actions) { @@ -184,6 +184,17 @@ class MemberLoginForm extends Form { } } + + + /** + * Get the authenticator class + * + * @return Authenticator Returns the authenticator class for this login + * form. + */ + public static function getAuthenticator() { + return new MemberAuthenticator; + } } diff --git a/security/OpenIDAuthenticator.php b/security/OpenIDAuthenticator.php index d924584ce..336b3efe0 100644 --- a/security/OpenIDAuthenticator.php +++ b/security/OpenIDAuthenticator.php @@ -147,6 +147,16 @@ class OpenIDAuthenticator extends Authenticator { public static function getLoginForm(Controller $controller) { return Object::create("OpenIDLoginForm", $controller, "LoginForm"); } + + + /** + * Get the name of the authentication method + * + * @return string Returns the name of the authentication method. + */ + public static function getName() { + return "OpenID/i-name"; + } } diff --git a/security/OpenIDLoginForm.php b/security/OpenIDLoginForm.php index aba95eedb..30e5880f9 100644 --- a/security/OpenIDLoginForm.php +++ b/security/OpenIDLoginForm.php @@ -13,7 +13,7 @@ * * @author Markus Lanthaler */ -class OpenIDLoginForm extends Form { +class OpenIDLoginForm extends LoginForm { /** * Constructor @@ -54,9 +54,9 @@ class OpenIDLoginForm extends Form { $fields = new FieldSet( new HiddenField("AuthenticationMethod", null, "OpenID"), new TextField("OpenIDURL", "OpenID URL", - Session::get('SessionForms.OpenIDLoginForm.OpenIDURL')), + Session::get('SessionForms.OpenIDLoginForm.OpenIDURL'), null, $this), new CheckboxField("Remember", "Remember me next time?", - Session::get('SessionForms.OpenIDLoginForm.Remember')) + Session::get('SessionForms.OpenIDLoginForm.Remember'), $this) ); } if(!$actions) { @@ -124,6 +124,20 @@ class OpenIDLoginForm extends Form { $s = new Security(); $s->logout(); } + + + /** + * Get the authenticator class + * + * Attention: This method will return the class and not an + * instance of the authenticator class! + * + * @return Authenticator Returns the authenticator class for this login + * form. + */ + public static function getAuthenticator() { + return new OpenIDAuthenticator; + } } diff --git a/security/Security.php b/security/Security.php index d61283875..21d9dda75 100644 --- a/security/Security.php +++ b/security/Security.php @@ -164,7 +164,12 @@ class Security extends Controller { Requirements::javascript("jsparty/prototype_improvements.js"); Requirements::javascript("jsparty/scriptaculous/effects.js"); - $tmpPage = DataObject::get_one('Page', "URLSegment = 'home'"); + $customCSS = project() . '/css/tabs.css'; + if(Director::fileExists($customCSS)) { + Requirements::css($customCSS); + } + + $tmpPage = new Page(); $tmpPage->Title = "Log in"; $tmpPage->URLSegment = "Security";