diff --git a/ext/user/main.php b/ext/user/main.php index 074ad28c..830c0514 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -25,8 +25,12 @@ class UserPageBuildingEvent extends Event { } class UserPage extends Extension { + var $theme; + // event handling {{{ public function receive_event($event) { + if(is_null($this->theme)) $this->theme = get_theme_object("user", "UserPageTheme"); + if(is_a($event, 'InitExtEvent')) { global $config; $config->set_default_bool("login_signup_enabled", true); @@ -44,11 +48,7 @@ class UserPage extends Extension { $this->login(); } else { - $page->set_title("Login"); - $page->set_heading("Login"); - $page->add_block(new NavBlock()); - $page->add_block(new Block("Login There", - "There should be a login box to the left")); + $this->theme->display_login_page($event->page); } } else if($event->get_arg(0) == "logout") { @@ -81,7 +81,7 @@ class UserPage extends Extension { global $page; if($user->is_anonymous()) { - $page->add_block(new Block("Login", $this->build_login_block(), "left", 90)); + $this->theme->display_login_block($event->page); } else { $page->add_block(new Block("User Links", $this->build_links_block(), "left", 90)); @@ -185,10 +185,7 @@ class UserPage extends Extension { } } else { - $page->set_title("Create Account"); - $page->set_heading("Create Account"); - $page->add_block(new NavBlock()); - $page->add_block(new Block("Signup", $this->build_signup_form())); + $this->theme->display_signup_page($page); } } //}}} @@ -279,30 +276,6 @@ class UserPage extends Extension { } // }}} // HTML building {{{ - private function build_signup_form() { - global $config; - $tac = $config->get_string("login_tac"); - - if(empty($tac)) { - $html = ""; - } - else { - $html = "

$tac

"; - } - $html .= " -
- - - - - - -
Name
Password
Repeat Password
Email (Optional)
-
- "; - return $html; - } - private function build_user_page($duser) { global $page; global $user; @@ -445,22 +418,6 @@ class UserPage extends Extension { return $html; } - private function build_login_block() { - global $config; - $html = " -
- - - - -
Name
Password
-
- "; - if($config->get_bool("login_signup_enabled")) { - $html .= "Create Account"; - } - return $html; - } // }}} } add_event_listener(new UserPage()); diff --git a/ext/user/theme.php b/ext/user/theme.php new file mode 100644 index 00000000..34d1c604 --- /dev/null +++ b/ext/user/theme.php @@ -0,0 +1,54 @@ +set_title("Login"); + $page->set_heading("Login"); + $page->add_block(new NavBlock()); + $page->add_block(new Block("Login There", + "There should be a login box to the left")); + } + + public function display_signup_page($page) { + global $config; + $tac = $config->get_string("login_tac"); + + if(empty($tac)) {$html = "";} + else {$html = "

$tac

";} + + $html .= " +
+ + + + + + +
Name
Password
Repeat Password
Email (Optional)
+
+ "; + + $page->set_title("Create Account"); + $page->set_heading("Create Account"); + $page->add_block(new NavBlock()); + $page->add_block(new Block("Signup", $html)); + } + + public function display_login_block($page) { + global $config; + $html = " +
+ + + + +
Name
Password
+
+ "; + if($config->get_bool("login_signup_enabled")) { + $html .= "Create Account"; + } + $page->add_block(new Block("Login", $html, "left", 90)); + } +} +?>