diff options
author | wei <> | 2007-05-10 23:00:04 +0000 |
---|---|---|
committer | wei <> | 2007-05-10 23:00:04 +0000 |
commit | e2cb0b52aaa02a3f3f41d0df377d189529713738 (patch) | |
tree | ee4c2a3fece40c9a2d4dde75f6e758f7ef05f8f6 /demos/blog-tutorial/protected/pages/Day3/CreateLoginUser.page | |
parent | ef2fc3942664d4d7131542080e838f7754a3081f (diff) |
Update blog tutorial
Diffstat (limited to 'demos/blog-tutorial/protected/pages/Day3/CreateLoginUser.page')
-rw-r--r-- | demos/blog-tutorial/protected/pages/Day3/CreateLoginUser.page | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/demos/blog-tutorial/protected/pages/Day3/CreateLoginUser.page b/demos/blog-tutorial/protected/pages/Day3/CreateLoginUser.page index 61ce27b7..d54fc967 100644 --- a/demos/blog-tutorial/protected/pages/Day3/CreateLoginUser.page +++ b/demos/blog-tutorial/protected/pages/Day3/CreateLoginUser.page @@ -31,19 +31,19 @@ Below we show the template for <tt>LoginPage</tt>. As we see, the page mainly co <span>Username:</span>
<com:TRequiredFieldValidator
- ControlToValidate="Username"
- ErrorMessage="Please provide your username."
- Display="Dynamic" />
+ ControlToValidate="Username"
+ ErrorMessage="Please provide your username."
+ Display="Dynamic" />
<br/>
<com:TTextBox ID="Username" />
<br/>
<span>Password:</span>
<com:TCustomValidator
- ControlToValidate="Password"
- ErrorMessage="Your entered an invalid password."
- Display="Dynamic"
- OnServerValidate="validateUser" />
+ ControlToValidate="Password"
+ ErrorMessage="Your entered an invalid password."
+ Display="Dynamic"
+ OnServerValidate="validateUser" />
<br/>
<com:TTextBox ID="Password" TextMode="Password" />
@@ -62,36 +62,36 @@ Like the <a href="?page=Day1.CreateContact">Contact</a> page, the <tt>LoginUser< <com:TTextHighlighter CssClass="source" Language="php">
class LoginUser extends TPage
{
- /**
- * Validates whether the username and password are correct.
- * This method responds to the TCustomValidator's OnServerValidate event.
- * @param mixed event sender
- * @param mixed event parameter
- */
- public function validateUser($sender,$param)
- {
- $authManager=$this->Application->getModule('auth');
- if(!$authManager->login($this->Username->Text,$this->Password->Text))
- $param->IsValid=false; // tell the validator that validation fails
- }
-
- /**
- * Redirects the user's browser to appropriate URL if login succeeds.
- * This method responds to the login button's OnClick event.
- * @param mixed event sender
- * @param mixed event parameter
- */
- public function loginButtonClicked($sender,$param)
- {
- if($this->Page->IsValid) // all validations succeed
- {
- // obtain the URL of the privileged page that the user wanted to visit originally
- $url=$this->Application->getModule('auth')->ReturnUrl;
- if(empty($url)) // the user accesses the login page directly
- $url=$this->Service->constructUrl($this->Service->DefaultPage);
- $this->Response->redirect($url);
- }
- }
+ /**
+ * Validates whether the username and password are correct.
+ * This method responds to the TCustomValidator's OnServerValidate event.
+ * @param mixed event sender
+ * @param mixed event parameter
+ */
+ public function validateUser($sender,$param)
+ {
+ $authManager=$this->Application->getModule('auth');
+ if(!$authManager->login($this->Username->Text,$this->Password->Text))
+ $param->IsValid=false; // tell the validator that validation fails
+ }
+
+ /**
+ * Redirects the user's browser to appropriate URL if login succeeds.
+ * This method responds to the login button's OnClick event.
+ * @param mixed event sender
+ * @param mixed event parameter
+ */
+ public function loginButtonClicked($sender,$param)
+ {
+ if($this->Page->IsValid) // all validations succeed
+ {
+ // obtain the URL of the privileged page that the user wanted to visit originally
+ $url=$this->Application->getModule('auth')->ReturnUrl;
+ if(empty($url)) // the user accesses the login page directly
+ $url=$this->Service->constructUrl($this->Service->DefaultPage);
+ $this->Response->redirect($url);
+ }
+ }
}
</com:TTextHighlighter>
@@ -117,12 +117,12 @@ We modify the footer section of the <tt>MainLayout</tt>'s template as follows. T <com:TTextHighlighter CssClass="source" Language="prado">
<div id="footer">
<com:THyperLink Text="Login"
- NavigateUrl="<%= $this->Service->constructUrl('users.LoginUser') %>"
- Visible="<%= $this->User->IsGuest %>" />
+ NavigateUrl="<%= $this->Service->constructUrl('users.LoginUser') %>"
+ Visible="<%= $this->User->IsGuest %>" />
<com:TLinkButton Text="Logout"
- OnClick="logoutButtonClicked"
- Visible="<%= !$this->User->IsGuest %>" />
+ OnClick="logoutButtonClicked"
+ Visible="<%= !$this->User->IsGuest %>" />
<br/>
<%= PRADO::poweredByPrado() %>
@@ -136,18 +136,18 @@ Since the "logout" button attaches its <tt>OnClick</tt> event with a method call <com:TTextHighlighter CssClass="source" Language="php">
class MainLayout extends TTemplateControl
{
- /**
- * Logs out a user.
- * This method responds to the "logout" button's OnClick event.
- * @param mixed event sender
- * @param mixed event parameter
- */
- public function logoutButtonClicked($sender,$param)
- {
- $this->Application->getModule('auth')->logout();
- $url=$this->Service->constructUrl($this->Service->DefaultPage);
- $this->Response->redirect($url);
- }
+ /**
+ * Logs out a user.
+ * This method responds to the "logout" button's OnClick event.
+ * @param mixed event sender
+ * @param mixed event parameter
+ */
+ public function logoutButtonClicked($sender,$param)
+ {
+ $this->Application->getModule('auth')->logout();
+ $url=$this->Service->constructUrl($this->Service->DefaultPage);
+ $this->Response->redirect($url);
+ }
}
</com:TTextHighlighter>
|