diff options
Diffstat (limited to 'demos')
| -rw-r--r-- | demos/personal/protected/Pages/Home.php | 14 | ||||
| -rw-r--r-- | demos/personal/protected/Pages/Layout.php | 5 | ||||
| -rw-r--r-- | demos/personal/protected/Pages/Layout.tpl | 42 | ||||
| -rw-r--r-- | demos/personal/protected/Pages/Settings.page | 4 | ||||
| -rw-r--r-- | demos/personal/protected/Pages/UserLogin.page | 23 | ||||
| -rw-r--r-- | demos/personal/protected/Pages/UserLogin.php | 13 | ||||
| -rw-r--r-- | demos/personal/protected/Pages/config.xml | 3 | ||||
| -rw-r--r-- | demos/personal/protected/application.xml | 6 | 
8 files changed, 72 insertions, 38 deletions
diff --git a/demos/personal/protected/Pages/Home.php b/demos/personal/protected/Pages/Home.php index cca7d57b..badbca73 100644 --- a/demos/personal/protected/Pages/Home.php +++ b/demos/personal/protected/Pages/Home.php @@ -2,20 +2,6 @@  class Home extends TPage
  {
 -	public function onPreInit($param)
 -	{
 -		parent::onPreInit($param);
 -		if(!$this->getUser()->getIsGuest())
 -			$this->setTheme('');
 -	}
 -
 -	public function testClick($sender,$param)
 -	{
 -		if($sender->BackColor==='')
 -			$sender->BackColor='blue';
 -		else
 -			$sender->BackColor='';
 -	}
  }
  ?>
\ No newline at end of file diff --git a/demos/personal/protected/Pages/Layout.php b/demos/personal/protected/Pages/Layout.php index ba96038b..37ed95d4 100644 --- a/demos/personal/protected/Pages/Layout.php +++ b/demos/personal/protected/Pages/Layout.php @@ -2,6 +2,11 @@  class Layout extends TTemplateControl
  {
 +	public function logout($sender,$param)
 +	{
 +		$this->Application->getModule('auth')->logout();
 +		$this->Response->redirect($this->Service->constructUrl('Home'));
 +	}
  }
  ?>
\ No newline at end of file diff --git a/demos/personal/protected/Pages/Layout.tpl b/demos/personal/protected/Pages/Layout.tpl index db6dd242..f1064231 100644 --- a/demos/personal/protected/Pages/Layout.tpl +++ b/demos/personal/protected/Pages/Layout.tpl @@ -1,29 +1,45 @@  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
 -<head>
 -<title>My Personal Website</title>
 -</head>
 +
 +<com:THead Title="My Personal WebSite" />
 +
  <body>
 +
  <com:TForm>
 +
  <div class="header">
 -  <h1>Your Name Here</h1>
 -  <h2>My Personal Site</h2>
 -  <div class="nav">
 -    <a href=<%=$this->Service->constructUrl('Home') %> >HOME</a> |
 -    <a href=<%=$this->Service->constructUrl('Resume') %> >RESUME</a> |
 -    <a href=<%=$this->Service->constructUrl('Links') %> >LINKS</a> |
 -    <a href=<%=$this->Service->constructUrl('Albums') %> >ALBUMS</a> |
 -    <a href=<%=$this->Service->constructUrl('UserLogin') %> >LOGIN</a>
 -  </div>
 +<h1>Your Name Here</h1>
 +<h2>My Personal Site</h2>
 +<div class="nav">
 +<a href="<%=$this->Service->constructUrl('Home') %>" >HOME</a> |
 +<a href="<%=$this->Service->constructUrl('Blog') %>" >BLOG</a> |
 +<a href="<%=$this->Service->constructUrl('Albums') %>" >ALBUMS</a> |
 +<a href="<%=$this->Service->constructUrl('Links') %>" >LINKS</a> |
 +<a href="<%=$this->Service->constructUrl('Settings') %>" >SETTINGS</a> |
 +<com:THyperLink
 +	NavigateUrl=<%=$this->Service->constructUrl('UserLogin') %>
 +	Text="LOGIN"
 +	Visible=<%= $this->User->IsGuest %>
 +	/>
 +<com:TLinkButton
 +	Text="LOGOUT"
 +	Visible=<%= !$this->User->IsGuest %>
 +	Click="logout"
 +	/>
  </div>
 +</div>
 +<hr/>
  <div class="main">
  <com:TContentPlaceHolder ID="main" />
  </div>
 +<hr/>
  <div class="footer">
 -  Copyright © 2005 Your Name here.<br/>
 +  Copyright © 2006 Your Name here.<br/>
    Powered by <a href="http://www.pradosoft.com/">PRADO</a>.
  </div>
 +
  </com:TForm>
 +
  </body>
  </html>
\ No newline at end of file diff --git a/demos/personal/protected/Pages/Settings.page b/demos/personal/protected/Pages/Settings.page new file mode 100644 index 00000000..48dfde96 --- /dev/null +++ b/demos/personal/protected/Pages/Settings.page @@ -0,0 +1,4 @@ +<com:TContent ID="main" >
 +Welcome, <com:TLabel Text=<%= $this->User->Name %> />!
 +This page contains site settings accessible only to site admin.
 +</com:TContent>
\ No newline at end of file diff --git a/demos/personal/protected/Pages/UserLogin.page b/demos/personal/protected/Pages/UserLogin.page index 588b8f6a..4bad6780 100644 --- a/demos/personal/protected/Pages/UserLogin.page +++ b/demos/personal/protected/Pages/UserLogin.page @@ -1,7 +1,18 @@  <com:TContent ID="main" >
 -Username: <com:TTextBox ID="username" /><br/>
 -Password: <com:TTextBox ID="password" TextMode="Password" /><br/>
 -<com:TButton Text="Login" Click="login" />
 -<com:TLabel ID="error" />
 -</com:TContent>
 -
 +Username:
 +<com:TTextBox ID="Username" />
 +<com:TRequiredFieldValidator
 +	ControlToValidate="Username"
 +	Text="Username is required."
 +	Display="Dynamic"/>
 +<br/>
 +Password: <com:TTextBox ID="Password" TextMode="Password" /><br/>
 +<com:TButton Text="Login" />
 +<com:TCustomValidator
 +	ControlToValidate="Password"
 +	Text="Login failed."
 +	Display="Dynamic"
 +	ServerValidate="login"
 +	/>
 +<com:TLabel ID="Error" />
 +</com:TContent>
\ No newline at end of file diff --git a/demos/personal/protected/Pages/UserLogin.php b/demos/personal/protected/Pages/UserLogin.php index 70cbc986..0dd2cd79 100644 --- a/demos/personal/protected/Pages/UserLogin.php +++ b/demos/personal/protected/Pages/UserLogin.php @@ -5,10 +5,15 @@ class UserLogin extends TPage  	public function login($sender,$param)
  	{
  		$manager=$this->Application->getModule('auth');
 -		if($manager->login($this->username->Text,$this->password->Text))
 -			$this->Application->Response->redirect($this->Application->Request->Items['ReturnUrl']);
 -		else
 -			$this->error->Text='login failed';
 +		if(!$manager->login($this->Username->Text,$this->Password->Text))
 +			$param->IsValid=false;
 +	}
 +
 +	public function onLoadComplete($param)
 +	{
 +		parent::onLoadComplete($param);
 +		if($this->IsPostBack && $this->IsValid)
 +			$this->Response->redirect($this->Request->Items['ReturnUrl']);
  	}
  }
 diff --git a/demos/personal/protected/Pages/config.xml b/demos/personal/protected/Pages/config.xml index ca63c17b..fa047ceb 100644 --- a/demos/personal/protected/Pages/config.xml +++ b/demos/personal/protected/Pages/config.xml @@ -1,5 +1,8 @@  <?xml version="1.0" encoding="utf-8"?>
  <configuration>
 +  <authorization>
 +    <deny pages="Settings" users="?" />
 +  </authorization>
    <pages MasterClass="Application.Pages.Layout" />
  </configuration>
\ No newline at end of file diff --git a/demos/personal/protected/application.xml b/demos/personal/protected/application.xml index dbb51264..84467e98 100644 --- a/demos/personal/protected/application.xml +++ b/demos/personal/protected/application.xml @@ -7,6 +7,10 @@      <module id="cache" class="System.Data.TSqliteCache" />
      -->
      <module id="session" class="THttpSession" />
 +    <module id="log" class="System.Log.TLogRouter">
 +      <route class="TBrowserLogRoute" Categories="System.Web.UI.TPage" />
 +      <route class="TFileLogRoute" Categories="System.Web.UI.TPage" />
 +    </module>
    </modules>
    <services>
      <!-- page service -->
 @@ -18,7 +22,7 @@            <user name="demo" password="demo" />
          </module>
          <!-- auth manager module -->
 -        <module id="auth" class="System.Security.TAuthManager" UserManager="users" LoginPage="Login" />
 +        <module id="auth" class="System.Security.TAuthManager" UserManager="users" LoginPage="UserLogin" />
        </modules>
      </service>
    </services>
  | 
