summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/php/application.xml4
-rw-r--r--app/php/components/HeaderMenu.php16
-rw-r--r--app/php/components/HeaderMenu.tpl14
-rw-r--r--app/php/layouts/MainLayout.php9
-rw-r--r--app/php/layouts/MainLayout.tpl19
-rw-r--r--app/php/pages/Admin.page2
-rw-r--r--app/php/pages/Home.page11
-rw-r--r--app/php/pages/Login.page4
-rw-r--r--app/php/pages/Profile.page4
-rw-r--r--app/php/pages/Signup.page4
10 files changed, 72 insertions, 15 deletions
diff --git a/app/php/application.xml b/app/php/application.xml
index 9f1cb34..c89ca45 100644
--- a/app/php/application.xml
+++ b/app/php/application.xml
@@ -50,6 +50,8 @@
UserClass="Application.user.DbUser" />
</modules>
<services>
- <service id="page" class="TPageService" />
+ <service id="page" class="TPageService">
+ <pages MasterClass="Application.layouts.MainLayout" />
+ </service>
</services>
</application>
diff --git a/app/php/components/HeaderMenu.php b/app/php/components/HeaderMenu.php
new file mode 100644
index 0000000..bffe4d2
--- /dev/null
+++ b/app/php/components/HeaderMenu.php
@@ -0,0 +1,16 @@
+<?php
+
+Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
+
+class HeaderMenu extends TTemplateControl {
+
+ public function logoutUser($sender, $param) {
+ $this->Application->getModule('auth')->logout();
+ $this->Response->redirect(
+ $this->Service->ConstructUrl(NULL)
+ );
+ }
+
+}
+
+?>
diff --git a/app/php/components/HeaderMenu.tpl b/app/php/components/HeaderMenu.tpl
new file mode 100644
index 0000000..eceea1b
--- /dev/null
+++ b/app/php/components/HeaderMenu.tpl
@@ -0,0 +1,14 @@
+<nav role="navigation">
+ <com:THyperLink Text="Login">
+ <prop:NavigateUrl><%= $this->Service->constructUrl('Login') %></prop:NavigateUrl>
+ <prop:Visible><%= $this->User->IsGuest %></prop:Visible>
+ </com:THyperLink>
+ <com:TActiveLinkButton OnCommand="logoutUser">
+ <prop:Text>Logout (<%= $this->User->Name %>)</prop:Text>
+ <prop:Visible><%= !$this->User->IsGuest %></prop:Visible>
+ </com:TActiveLinkButton>
+ <com:THyperLink Text="New user">
+ <prop:NavigateUrl><%= $this->Service->constructUrl('Signup') %></prop:NavigateUrl>
+ <prop:Visible><%= $this->User->getIsAdmin() %></prop:Visible>
+ </com:THyperLink>
+</nav>
diff --git a/app/php/layouts/MainLayout.php b/app/php/layouts/MainLayout.php
new file mode 100644
index 0000000..678b1aa
--- /dev/null
+++ b/app/php/layouts/MainLayout.php
@@ -0,0 +1,9 @@
+<?php
+
+Prado::using('Application.components.HeaderMenu');
+
+class MainLayout extends TTemplateControl {
+
+}
+
+?>
diff --git a/app/php/layouts/MainLayout.tpl b/app/php/layouts/MainLayout.tpl
new file mode 100644
index 0000000..f8c5f50
--- /dev/null
+++ b/app/php/layouts/MainLayout.tpl
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+ <com:THead>
+ <com:TMetaTag HttpEquiv="Content-Type" Content="text/html; charset=utf-8" />
+ <title><com:TContentPlaceHolder ID="Title" /></title>
+ </com:THead>
+ <body>
+ <com:TForm>
+ <header role="banner">
+ <com:HeaderMenu />
+ </header>
+ <main role="main">
+ <com:TContentPlaceHolder ID="Content" />
+ </main>
+ <footer role="contentinfo">
+ </footer>
+ </com:TForm>
+ </body>
+</html>
diff --git a/app/php/pages/Admin.page b/app/php/pages/Admin.page
index 431a6fb..8b13789 100644
--- a/app/php/pages/Admin.page
+++ b/app/php/pages/Admin.page
@@ -1 +1 @@
-Page
+
diff --git a/app/php/pages/Home.page b/app/php/pages/Home.page
index 368b3e7..c247eb7 100644
--- a/app/php/pages/Home.page
+++ b/app/php/pages/Home.page
@@ -1,8 +1,3 @@
-<html>
-<head>
- <title>Welcome to PRADO</title>
-</head>
-<body>
-<h1>Welcome to PRADO!</h1>
-</body>
-</html> \ No newline at end of file
+<com:TContent ID="Content">
+ <h1>Welcome to PRADO!</h1>
+</com:TContent>
diff --git a/app/php/pages/Login.page b/app/php/pages/Login.page
index d0825a0..a2e5cd5 100644
--- a/app/php/pages/Login.page
+++ b/app/php/pages/Login.page
@@ -1,4 +1,4 @@
-<com:TForm>
+<com:TContent ID="Content">
Username: <com:TTextBox ID="Login" />
<com:TRequiredFieldValidator ControlToValidate="Login"
Display="Dynamic"
@@ -14,4 +14,4 @@
ErrorMessage="Username and password don't match" />
<br />
<com:TButton Text="Login" OnCommand="loginUser" />
-</com:TForm>
+</com:TContent>
diff --git a/app/php/pages/Profile.page b/app/php/pages/Profile.page
index 99455ed..b5dcf37 100644
--- a/app/php/pages/Profile.page
+++ b/app/php/pages/Profile.page
@@ -1 +1,3 @@
-Profile
+<com:TContent ID="Content">
+ Profile
+</com:TContent>
diff --git a/app/php/pages/Signup.page b/app/php/pages/Signup.page
index 0e35da2..a833da7 100644
--- a/app/php/pages/Signup.page
+++ b/app/php/pages/Signup.page
@@ -1,4 +1,4 @@
-<com:TForm>
+<com:TContent ID="Content">
Username: <com:TTextBox ID="Login" />
<com:TRequiredFieldValidator
ControlToValidate="Login"
@@ -34,4 +34,4 @@
<br />
<com:TButton Text="Create" OnCommand="registerUser" />
<com:TValidationSummary />
-</com:TForm>
+</com:TContent>