Hawk - PHP documentation
  • Namespace
  • Class
  • Tree

Namespaces

  • Hawk
    • View
      • Plugins

Classes

  • Hawk\App
  • Hawk\ButtonInput
  • Hawk\Cache
  • Hawk\CheckboxInput
  • Hawk\ColorInput
  • Hawk\Conf
  • Hawk\Controller
  • Hawk\Crypto
  • Hawk\DatabaseSessionHandler
  • Hawk\DatetimeInput
  • Hawk\DB
  • Hawk\DBExample
  • Hawk\DeleteInput
  • Hawk\Dialogbox
  • Hawk\EmailInput
  • Hawk\ErrorHandler
  • Hawk\Event
  • Hawk\FileInput
  • Hawk\FileSystem
  • Hawk\FloatInput
  • Hawk\Form
  • Hawk\FormFieldset
  • Hawk\FormInput
  • Hawk\GenericModel
  • Hawk\GifImage
  • Hawk\HawkApi
  • Hawk\HawkUpdater
  • Hawk\HiddenInput
  • Hawk\HtmlInput
  • Hawk\HTTPRequest
  • Hawk\Icon
  • Hawk\Image
  • Hawk\IntegerInput
  • Hawk\ItemList
  • Hawk\ItemListField
  • Hawk\JpegImage
  • Hawk\Lang
  • Hawk\Language
  • Hawk\LeftSidebarTab
  • Hawk\Less
  • Hawk\Logger
  • Hawk\Mail
  • Hawk\MenuItem
  • Hawk\Model
  • Hawk\NoSidebarTab
  • Hawk\NumberInput
  • Hawk\ObjectInput
  • Hawk\Option
  • Hawk\Panel
  • Hawk\PasswordInput
  • Hawk\Permission
  • Hawk\Plugin
  • Hawk\PluginInstaller
  • Hawk\PngImage
  • Hawk\ProfileQuestion
  • Hawk\ProfileQuestionValue
  • Hawk\RadioInput
  • Hawk\Request
  • Hawk\Response
  • Hawk\RightSidebarTab
  • Hawk\Role
  • Hawk\RolePermission
  • Hawk\Route
  • Hawk\Router
  • Hawk\SelectInput
  • Hawk\Session
  • Hawk\Singleton
  • Hawk\SubmitInput
  • Hawk\Tabs
  • Hawk\TextareaInput
  • Hawk\TextInput
  • Hawk\Theme
  • Hawk\TimeInput
  • Hawk\Upload
  • Hawk\User
  • Hawk\View
  • Hawk\View\Plugins\Accordion
  • Hawk\View\Plugins\Button
  • Hawk\View\Plugins\Form
  • Hawk\View\Plugins\Icon
  • Hawk\View\Plugins\Import
  • Hawk\View\Plugins\Panel
  • Hawk\View\Plugins\Tabs
  • Hawk\View\Plugins\Text
  • Hawk\View\Plugins\Uri
  • Hawk\View\Plugins\Widget
  • Hawk\ViewPlugin
  • Hawk\Widget
  • Hawk\WysiwygInput

Traits

  • Hawk\Utils

Exceptions

  • Hawk\AppStopException
  • Hawk\DBExampleException
  • Hawk\DBException
  • Hawk\FileSystemException
  • Hawk\HawkApiException
  • Hawk\ImageException
  • Hawk\MailException
  • Hawk\UploadException
  • Hawk\ViewException
 1 <?php
 2 /**
 3  * PasswordInput.php
 4  *
 5  * @author  Elvyrra SAS
 6  * @license http://rem.mit-license.org/ MIT
 7  */
 8 
 9 namespace Hawk;
10 
11 /**
12  * This class describes the behavior of password inputs
13  *
14  * @package Form\Input
15  */
16 class PasswordInput extends FormInput{
17     const TYPE = "password";
18 
19     /**
20      * Variable that has to be got from the database for displaying
21      *
22      * @var bool
23      */
24     public $get = false,
25 
26     /**
27      * The decryption function
28      *
29      * @var callable
30      */
31     $decrypt = null,
32 
33     /**
34      * The encryption function
35      *
36      * @var callable
37      */
38     $encrypt = null,
39 
40     /**
41      * The input pattern
42      *
43      * @var string
44      */
45     $pattern = '/^(?=.*\d)(?=.*[a-zA-Z]).{6,16}$/';
46 
47     /**
48      * Display the input
49      *
50      * @return string The HTML result to display
51      */
52     public function display(){
53         $decrypt = $this->decrypt;
54         $this->value = ($this->get && $decrypt && is_callable($decrypt)) ? $decrypt($this->value) : "";
55         return parent::display();
56     }
57 
58     /**
59      * Check the submitted value
60      *
61      * @param Form $form The form this input is associated to
62      *
63      * @return bool True if the input format is correct, else False
64      */
65     public function check(&$form = null){
66         if(parent::check($form)) {
67             // Check the confirmation password
68             if(!empty($this->compare) && $form) {
69                 if($this->value != $form->getData($this->compare)) {
70                     $form->error($this->errorAt, Lang::get('form.password-comparison'));
71                     return false;
72                 }
73             }
74 
75             return true;
76         }
77         else{
78             return false;
79         }
80     }
81 
82 
83     /**
84      * Get the input value, formatted for SQL database
85      *
86      * @return string The formatted value
87      */
88     public function dbvalue(){
89         if($this->encrypt && is_callable($this->encrypt)) {
90             return call_user_func($this->encrypt, $this->value);
91         }
92         else
93             return $this->value;
94     }
95 }
96 
Hawk - PHP documentation API documentation generated by ApiGen