1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Installer;
13
14 use Brickrouge\Element;
15 use Brickrouge\Form;
16 use Brickrouge\Group;
17 use Brickrouge\Text;
18
19 class UserForm extends PanelForm
20 {
21 public function __construct()
22 {
23 global $core;
24
25 $values = array();
26
27 if (isset($core->session->install['user']))
28 {
29 $values = $core->session->install['user'];
30
31 if (isset($values['password']))
32 {
33 $values['password'];
34 $values['password_confirm'] = $values['password'];
35 }
36 }
37
38 $random_password = \ICanBoogie\generate_token(8, \ICanBoogie\TOKEN_MEDIUM);
39
40 parent::__construct
41 (
42 array
43 (
44 PanelDecorator::TITLE => t('panel.user.title'),
45 PanelDecorator::DESCRIPTION => t('panel.user.description'),
46
47 Form::VALUES => $values,
48 Form::HIDDENS => array
49 (
50 'random_password' => $random_password
51 ),
52
53 Element::CHILDREN => array
54 (
55 'username' => new Text
56 (
57 array
58 (
59 Group::LABEL => 'Username',
60 Element::DESCRIPTION => t('panel.user.username'),
61 Element::DEFAULT_VALUE => 'admin'
62 )
63 ),
64
65 'email' => new Text
66 (
67 array
68 (
69 Group::LABEL => 'Your E-mail',
70 Element::REQUIRED => true,
71 Element::DESCRIPTION => t('panel.user.email')
72 )
73 ),
74
75 'password' => new Text
76 (
77 array
78 (
79 Group::LABEL => 'Password',
80 Element::DESCRIPTION => t('panel.user.password'),
81
82 'type' => 'password',
83 'placeholder' => $random_password
84 )
85 ),
86
87 'password_confirm' => new Text
88 (
89 array
90 (
91 Element::DESCRIPTION => t('panel.user.password_confirm'),
92 Element::LABEL_MISSING => "Password confirm",
93
94 'type' => 'password',
95 'placeholder' => empty($values['password']) ? $random_password : null
96 )
97 ),
98
99 'language' => new LanguageElement
100 (
101 array
102 (
103 Group::LABEL => 'Language',
104 Element::DESCRIPTION => t('panel.user.language')
105 )
106 )
107 ),
108
109 'action' => '/api/install/user',
110 'autocomplete' => 'off',
111 'name' => 'user'
112 )
113 );
114 }
115 }