1: <?php
2:
3: namespace Alpha\View;
4:
5: use Alpha\Util\Config\ConfigProvider;
6: use Alpha\Util\Helper\Validator;
7: use Alpha\Util\Security\SecurityUtils;
8: use Alpha\Util\Http\Request;
9: use Alpha\Controller\Front\FrontController;
10: use Alpha\Model\Type\String;
11: use Alpha\View\Widget\StringBox;
12: use Alpha\View\Widget\Button;
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: class PersonView extends View
57: {
58: 59: 60: 61: 62: 63: 64:
65: public function displayLoginForm()
66: {
67: $config = ConfigProvider::getInstance();
68:
69: $html = '<div class="bordered padded">';
70: $html .= '<h1>Login</h1>';
71: $html .= '<form action="'.FrontController::generateSecureURL('act=Alpha\Controller\LoginController').'" method="POST" id="loginForm" accept-charset="UTF-8">';
72:
73: $request = new Request(array('method' => 'GET'));
74: $email = new String($request->getParam('email', ''));
75: $email->setRule(Validator::REQUIRED_EMAIL);
76: $email->setSize(70);
77: $email->setHelper('Please provide a valid e-mail address!');
78: $stringBox = new StringBox($email, $this->BO->getDataLabel('email'), 'email', 'loginForm', '50');
79: $html .= $stringBox->render();
80:
81: $password = new String();
82: $password->isPassword();
83:
84: $stringBox = new StringBox($password, $this->BO->getDataLabel('password'), 'password', 'loginForm', '50');
85: $html .= $stringBox->render();
86:
87: $temp = new Button('submit', 'Login', 'loginBut');
88: $html .= '<div class="centered">'.$temp->render(80).'</div>';
89:
90: $html .= $this->renderSecurityFields();
91:
92: $html .= '</form>';
93:
94: $html .= '<p><a href="'.FrontController::generateSecureURL('act=Alpha\Controller\LoginController&reset=true').'">Forgotten your password?</a></p>';
95: $html .= '</div>';
96:
97: return $html;
98: }
99:
100: 101: 102: 103: 104: 105: 106:
107: public function displayResetForm()
108: {
109: $config = ConfigProvider::getInstance();
110:
111: $html = '<div class="bordered padded">';
112: $html .= '<h1>Password reset</h1>';
113: $html .= '<p>If you have forgotten your password, you can use this form to have a new password automatically generated and sent to your e-mail address.</p>';
114: $html .= '<form action="'.FrontController::generateSecureURL('act=Alpha\Controller\LoginController&reset=true').'" method="POST" id="resetForm" accept-charset="UTF-8">';
115:
116: $request = new Request(array('method' => 'GET'));
117: $email = new String($request->getParam('email', ''));
118: $email->setRule(Validator::REQUIRED_EMAIL);
119: $email->setSize(70);
120: $email->setHelper('Please provide a valid e-mail address!');
121: $stringBox = new StringBox($email, $this->BO->getDataLabel('email'), 'email', 'resetForm', '50');
122: $html .= $stringBox->render();
123:
124: $html .= '<div class="form-group lower spread">';
125:
126: $temp = new Button('submit', 'Reset Password', 'resetBut');
127: $html .= $temp->render();
128:
129: $temp = new Button("document.location.replace('".$config->get('app.url')."')", 'Cancel', 'cancelBut');
130: $html .= $temp->render();
131:
132: $html .= '</div>';
133:
134: $html .= $this->renderSecurityFields();
135:
136: $html .= '</form>';
137: $html .= '</div>';
138:
139: return $html;
140: }
141:
142: 143: 144: 145: 146: 147: 148:
149: public function displayRegisterForm()
150: {
151: $config = ConfigProvider::getInstance();
152:
153: $request = new Request(array('method' => 'GET'));
154:
155: $html = '<p>In order to access this site, you will need to create a user account. In order to do so, please provide a valid email address below and a password will be sent to your inbox shortly (you can change your password once you log in).</p>';
156: $html .= '<table cols="2">';
157: $html .= '<form action="'.$request->getURI().'?reset=true" method="POST" accept-charset="UTF-8">';
158: $html .= '<tr>';
159: if ($config->get('security.encrypt.http.fieldnames')) {
160: $fieldname = base64_encode(SecurityUtils::encrypt('displayname'));
161: } else {
162: $fieldname = 'displayname';
163: }
164: $html .= ' <td>Forum name</td> <td><input type="text" name="'.$fieldname.'" size="50" value="'.$request->getParam($fieldname, '').'"/></td>';
165: $html .= '</tr>';
166: $html .= '<tr>';
167: if ($config->get('security.encrypt.http.fieldnames')) {
168: $fieldname = base64_encode(SecurityUtils::encrypt('email'));
169: } else {
170: $fieldname = 'email';
171: }
172: $html .= ' <td>E-mail Address</td> <td><input type="text" name="'.$fieldname.'" size="50" value="'.$request->getParam($fieldname, '').'"/></td>';
173: $html .= '</tr>';
174: $html .= '<tr><td colspan="2">';
175: $temp = new Button('submit', 'Register', 'registerBut');
176: $html .= $temp->render();
177: $html .= ' ';
178: $temp = new Button("document.location.replace('".$config->get('app.url')."')", 'Cancel', 'cancelBut');
179: $html .= $temp->render();
180: $html .= '</td></tr>';
181:
182: $html .= $this->renderSecurityFields();
183:
184: $html .= '</form>';
185: $html .= '</table>';
186:
187: return $html;
188: }
189: }
190: