Overview

Namespaces

  • Alpha
    • Controller
      • Front
    • Exception
    • Model
      • Type
    • Task
    • Util
      • Backup
      • Cache
      • Code
        • Highlight
        • Metric
      • Config
      • Convertor
      • Email
      • Extension
      • Feed
      • File
      • Graph
      • Helper
      • Http
        • Filter
        • Session
      • Image
      • Logging
      • Search
      • Security
    • View
      • Renderer
        • Html
        • Json
      • Widget

Classes

  • ArticleCommentView
  • ArticleView
  • DEnumView
  • PersonView
  • SequenceView
  • View
  • ViewState
  • Overview
  • Namespace
  • Class
  • Tree
  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:  * The rendering class for the Person class.
 16:  *
 17:  * @since 1.0
 18:  *
 19:  * @author John Collins <dev@alphaframework.org>
 20:  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
 21:  * @copyright Copyright (c) 2015, John Collins (founder of Alpha Framework).
 22:  * All rights reserved.
 23:  *
 24:  * <pre>
 25:  * Redistribution and use in source and binary forms, with or
 26:  * without modification, are permitted provided that the
 27:  * following conditions are met:
 28:  *
 29:  * * Redistributions of source code must retain the above
 30:  *   copyright notice, this list of conditions and the
 31:  *   following disclaimer.
 32:  * * Redistributions in binary form must reproduce the above
 33:  *   copyright notice, this list of conditions and the
 34:  *   following disclaimer in the documentation and/or other
 35:  *   materials provided with the distribution.
 36:  * * Neither the name of the Alpha Framework nor the names
 37:  *   of its contributors may be used to endorse or promote
 38:  *   products derived from this software without specific
 39:  *   prior written permission.
 40:  *
 41:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 42:  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 43:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 44:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 45:  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 46:  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 47:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 48:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 49:  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 50:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 51:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 52:  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 53:  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 54:  * </pre>
 55:  */
 56: class PersonView extends View
 57: {
 58:     /**
 59:      * Method to render the login HTML form.
 60:      *
 61:      * @return string
 62:      *
 63:      * @since 1.0
 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:      * Method to render the reset password HTML form.
102:      *
103:      * @return string
104:      *
105:      * @since 1.0
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:      * Method to render the user registration form.
144:      *
145:      * @return string
146:      *
147:      * @since 1.0
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 .= '&nbsp;&nbsp;';
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: 
Alpha Framework 2.0.4 API Documentation API documentation generated by ApiGen 2.8.0