Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16766 | Rev 16985 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15459 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\Network;
6
 
7
use Laminas\Form\Form;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use Laminas\Log\LoggerInterface;
10
use LeadersLinked\Mapper\ThemeMapper;
11
use LeadersLinked\Model\Network;
12
 
13
class NetworkEditForm extends Form
14
{
15
 
16
    /**
17
     *
18
     * @param AdapterInterface $adapter
19
     */
20
    public function __construct($adapter)
21
    {
22
 
23
        parent::__construct();
24
        $this->setInputFilter(new NetworkEditFilter($adapter));
25
 
26
 
27
        $this->add([
28
            'name' => 'name',
29
            'type' => \Laminas\Form\Element\Text::class,
30
             'attributes' => [
31
                'maxlength' 	=> 128,
32
                'id' 			=> 'name',
33
            ]
34
         ]);
35
 
36
        $this->add([
37
            'name' => 'main_hostname',
38
            'type' => \Laminas\Form\Element\Text::class,
39
            'attributes' => [
40
                'maxlength' 	=> 250,
41
                'id' 			=> 'main_hostname',
42
            ]
43
        ]);
44
 
45
        $this->add([
46
            'name' => 'alternative_hostname',
47
            'type' => \Laminas\Form\Element\Text::class,
48
            'attributes' => [
49
                'maxlength' 	=> 250,
50
                'id' 			=> 'alternative_hostname',
51
            ]
52
        ]);
53
 
54
 
55
 
56
        $this->add([
57
            'name' => 'admin_hostname',
58
            'type' => \Laminas\Form\Element\Text::class,
59
            'attributes' => [
60
                'maxlength' 	=> 250,
61
                'id' 			=> 'admin_hostname',
62
            ]
63
        ]);
64
 
65
        $this->add([
16948 efrain 66
            'name' => 'service_hostname',
67
            'type' => \Laminas\Form\Element\Text::class,
68
            'attributes' => [
69
                'maxlength' 	=> 250,
70
                'id' 			=> 'service_hostname',
71
            ]
72
        ]);
73
 
74
 
75
 
76
        $this->add([
15459 efrain 77
            'name' => 'status',
78
            'type' => \Laminas\Form\Element\Checkbox::class,
79
            'attributes' => [
80
                'id' 			=> 'status',
81
            ],
82
            'options' => [
16766 efrain 83
                'use_hidden_element' => false,
15459 efrain 84
                'unchecked_value' => \LeadersLinked\Model\Network::STATUS_INACTIVE,
85
                'checked_value'=> \LeadersLinked\Model\Network::STATUS_ACTIVE,
86
            ]
87
        ]);
88
 
15831 efrain 89
 
15459 efrain 90
        $this->add([
15831 efrain 91
            'name' => 'moodle_name',
92
            'type' => \Laminas\Form\Element\Text::class,
93
            'attributes' => [
94
                'maxlength' 	=> 20,
95
                'id' 			=> 'moodle_name',
96
            ]
97
        ]);
98
 
99
        $this->add([
15459 efrain 100
            'name' => 'moodle_url',
101
            'type' => \Laminas\Form\Element\Text::class,
102
            'attributes' => [
103
                'maxlength' 	=> 250,
104
                'id' 			=> 'moodle_url',
105
            ]
106
        ]);
107
 
15831 efrain 108
        $this->add([
109
            'name' => 'microlearning_appstore',
110
            'type' => \Laminas\Form\Element\Text::class,
111
            'attributes' => [
112
                'maxlength' 	=> 250,
113
                'id' 			=> 'microlearning_appstore',
114
            ]
115
        ]);
15459 efrain 116
 
117
        $this->add([
15831 efrain 118
            'name' => 'microlearning_playstore',
119
            'type' => \Laminas\Form\Element\Text::class,
120
            'attributes' => [
121
                'maxlength' 	=> 250,
122
                'id' 			=> 'mmicrolearning_playstore',
123
            ]
124
        ]);
125
 
126
 
127
        $this->add([
15459 efrain 128
            'name' => 'relationship_user_mode',
129
            'type' => \Laminas\Form\Element\Select::class,
130
            'attributes' => [
131
                'id' => 'relationship_user_mode',
132
            ],
133
            'options' => [
134
                'value_options' => [
135
                    Network::RELATIONSHIP_USER_MODE_USER_2_USER => 'LABEL_RELATIONSHIP_USER_MODE_USER_2_USER',
136
                    Network::RELATIONSHIP_USER_MODE_ALL_2_ALL => 'LABEL_RELATIONSHIP_USER_MODE_ALL_2_ALL',
137
                ]
138
            ]
139
        ]);
140
 
141
 
142
        $this->add([
143
            'name' => 'theme_id',
144
            'type' => \Laminas\Form\Element\Select::class,
145
            'attributes' => [
146
                'id' => 'theme_id',
147
            ],
148
            'options' => [
149
                'disable_inarray_validator' => true,
150
                'value_options' => $this->optionsTheme($adapter)
151
            ]
152
        ]);
153
 
154
 
155
    }
156
 
157
    /**
158
     *
159
     * @param AdapterInterface $adapter
160
     */
161
    private function optionsTheme($adapter)
162
    {
163
        $options = [];
164
 
165
        $mapper = ThemeMapper::getInstance($adapter);
166
        $records = $mapper->fetchAll();
167
 
168
        foreach($records as $record)
169
        {
170
            $options[$record->uuid] = $record->name;
171
        }
172
        return $options;
173
    }
174
 
175
 
176
 
177
}