forked from jquery/testswarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSignupPage.php
66 lines (55 loc) · 1.8 KB
/
SignupPage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* "Signup" page.
*
* @author John Resig, 2008-2011
* @author Jörn Zaefferer, 2012
* @since 0.1.0
* @package TestSwarm
*/
class SignupPage extends Page {
public function execute() {
$action = SignupAction::newFromContext( $this->getContext() );
$action->doAction();
$error = $action->getError();
if ( !$error ) {
$data = $action->getData();
if ( $data["status"] === "logged-in" ) {
$this->redirect( swarmpath( "user/" . $data["username"] ) );
}
}
$this->setAction( $action );
$this->content = $this->initContent();
}
protected function initContent() {
$request = $this->getContext()->getRequest();
$this->setTitle( "Signup" );
$html = '<form action="' . swarmpath( "signup" ) . '" method="post" class="form-horizontal">'
. '<fieldset>'
. '<legend>Signup</legend>';
$error = $this->getAction()->getError();
if ( $request->wasPosted() && $error ) {
$html .= html_tag( 'div', array( 'class' => 'alert alert-error' ), $error['info'] );
}
$html .=
'<div class="well">'
. '<p>Create an account. If you already have an account you may <a href="' . swarmpath( "login" )
. '">login here</a>.</p>'
. '<div class="control-group">'
. '<label class="control-label" for="form-username">Username</label>'
. '<div class="controls">'
. '<input id="form-username" type="text" name="username" maxlength="255">'
. '</div>'
. '</div><div class="control-group">'
. '<label class="control-label" for="form-password">Password</label>'
. '<div class="controls">'
. '<input id="form-password" type="password" name="password">'
. '</div>'
. '</div>'
. '</div><div class="form-actions">'
. '<input type="submit" value="Signup" class="btn btn-primary">'
. '</div>';
$html .= '</fieldset></form>';
return $html;
}
}