From b7577ba0fd7596ac09437c5c169f4e5dd75ce09e Mon Sep 17 00:00:00 2001 From: Morven Lewis-Everley Date: Thu, 22 Feb 2018 12:19:49 +0000 Subject: [PATCH] Streamline account templates --- code/control/Users_Account_Controller.php | 37 +++++++++++++++---- templates/Includes/UsersAccountSections.ss | 5 +++ templates/Includes/UsersProfileSummary.ss | 9 +++++ templates/Layout/UserAccount.ss | 13 +------ .../Layout/UserAccount_changepassword.ss | 22 ----------- templates/Layout/UserAccount_edit.ss | 22 ----------- 6 files changed, 45 insertions(+), 63 deletions(-) create mode 100644 templates/Includes/UsersAccountSections.ss create mode 100644 templates/Includes/UsersProfileSummary.ss delete mode 100644 templates/Layout/UserAccount_changepassword.ss delete mode 100644 templates/Layout/UserAccount_edit.ss diff --git a/code/control/Users_Account_Controller.php b/code/control/Users_Account_Controller.php index bda8d43..1687ba6 100755 --- a/code/control/Users_Account_Controller.php +++ b/code/control/Users_Account_Controller.php @@ -139,14 +139,33 @@ public function RelativeLink($action = null) */ public function index() { + // Setup default profile summary sections + $sections = ArrayList::create(); + + $sections->push(ArrayData::create(array( + "Title" => "", + "Content" => $this->renderWith( + "UsersProfileSummary", + array("CurrentUser" => Member::currentUser()) + ) + ))); + + // Allow users to add extra content sections to the + // summary + $this->extend("updateContentSections", $sections); + $this->customise(array( - "ClassName" => "AccountPage" + "Title" => _t('Users.ProfileSummary', 'Profile Summary'), + "MetaTitle" => _t('Users.ProfileSummary', 'Profile Summary'), + "Content" => $this->renderWith( + "UsersAccountSections", + array("Sections" => $sections) + ) )); $this->extend("onBeforeIndex"); return $this->renderWith(array( - "UserAccount", "UserAccount", "Page" )); @@ -162,7 +181,8 @@ public function edit() } $this->customise(array( - "ClassName" => "AccountPage", + "Title" => _t("Users.EditAccountDetails", "Edit account details"), + "MetaTitle" => _t("Users.EditAccountDetails", "Edit account details"), "Form" => $form )); @@ -197,7 +217,8 @@ public function changepassword() } $this->customise(array( - "ClassName" => "AccountPage", + "Title" => _t("Security.ChangeYourPassword", "Change your password"), + "MetaTitle" => _t("Security.ChangeYourPassword", "Change your password"), "Form" => $form )); @@ -263,25 +284,25 @@ public function ChangePasswordForm() */ public function getAccountMenu() { - $menu = new ArrayList(); + $menu = ArrayList::create(); $curr_action = $this->request->param("Action"); - $menu->add(new ArrayData(array( + $menu->add(ArrayData::create(array( "ID" => 0, "Title" => _t('Users.PROFILESUMMARY', "Profile Summary"), "Link" => $this->Link(), "LinkingMode" => (!$curr_action) ? "current" : "link" ))); - $menu->add(new ArrayData(array( + $menu->add(ArrayData::create(array( "ID" => 10, "Title" => _t('Users.EDITDETAILS', "Edit account details"), "Link" => $this->Link("edit"), "LinkingMode" => ($curr_action == "edit") ? "current" : "link" ))); - $menu->add(new ArrayData(array( + $menu->add(ArrayData::create(array( "ID" => 30, "Title" => _t('Users.CHANGEPASSWORD', "Change password"), "Link" => $this->Link("changepassword"), diff --git a/templates/Includes/UsersAccountSections.ss b/templates/Includes/UsersAccountSections.ss new file mode 100644 index 0000000..8ee7601 --- /dev/null +++ b/templates/Includes/UsersAccountSections.ss @@ -0,0 +1,5 @@ +<% loop $Sections %> +

$Title

+ +
$Content
+<% end_loop %> \ No newline at end of file diff --git a/templates/Includes/UsersProfileSummary.ss b/templates/Includes/UsersProfileSummary.ss new file mode 100644 index 0000000..38331a0 --- /dev/null +++ b/templates/Includes/UsersProfileSummary.ss @@ -0,0 +1,9 @@ +<% with $CurrentUser %> +
+

+ <% _t('Member.FIRSTNAME',"First Name") %> $FirstName
+ <% _t('Member.SURNAME',"Surname") %> $Surname
+ <% _t("Member.EMAIL","Email") %> $Email
+

+
+<% end_with %> \ No newline at end of file diff --git a/templates/Layout/UserAccount.ss b/templates/Layout/UserAccount.ss index 2a859aa..aee874d 100755 --- a/templates/Layout/UserAccount.ss +++ b/templates/Layout/UserAccount.ss @@ -14,18 +14,9 @@ <% end_if %> -

<%t Users.ProfileSummary "Profile Summary" %>

- - <% with $CurrentUser %> -
-

- <% _t('Member.FIRSTNAME',"First Name") %> $FirstName
- <% _t('Member.SURNAME',"Surname") %> $Surname
- <% _t("Member.EMAIL","Email") %> $Email
-

-
- <% end_with %> +

$Title

+
$Content
$Form diff --git a/templates/Layout/UserAccount_changepassword.ss b/templates/Layout/UserAccount_changepassword.ss deleted file mode 100644 index 06c34d3..0000000 --- a/templates/Layout/UserAccount_changepassword.ss +++ /dev/null @@ -1,22 +0,0 @@ -
- -
\ No newline at end of file diff --git a/templates/Layout/UserAccount_edit.ss b/templates/Layout/UserAccount_edit.ss deleted file mode 100644 index 369db37..0000000 --- a/templates/Layout/UserAccount_edit.ss +++ /dev/null @@ -1,22 +0,0 @@ -
- -
\ No newline at end of file