Differences From Artifact [769331bd91]:

To Artifact [85e92511fe]:


18
19
20
21
22
23
24










25
26
27
28
29
30

31
32
33
34
35
36
37
		'tel'		=>	'Numéro de téléphone',
		'select'	=>	'Sélecteur à choix unique',
        'multiple'  =>  'Sélecteur à choix multiple',
		'country'	=>	'Sélecteur de pays',
		'text'		=>	'Texte',
		'textarea'	=>	'Texte multi-lignes',
	);











    protected $config_fields = array(
        'type',
        'title',
        'help',
        'editable',

        'mandatory',
        'private',
        'options'
    );

    static protected $presets = null;








>
>
>
>
>
>
>
>
>
>






>







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
		'tel'		=>	'Numéro de téléphone',
		'select'	=>	'Sélecteur à choix unique',
        'multiple'  =>  'Sélecteur à choix multiple',
		'country'	=>	'Sélecteur de pays',
		'text'		=>	'Texte',
		'textarea'	=>	'Texte multi-lignes',
	);

    protected $text_types = array(
        'email',
        'text',
        'select',
        'textarea',
        'url',
        'password',
        'country'
    );

    protected $config_fields = array(
        'type',
        'title',
        'help',
        'editable',
        'list_row',
        'mandatory',
        'private',
        'options'
    );

    static protected $presets = null;

111
112
113
114
115
116
117
118











119
120
121
122































123
124
125
126
127
128
129
                return $this->champs[$champ][$key];
            else
                return null;
        }

		return $this->champs[$champ];
	}












	public function getAll()
	{
		return $this->champs;
	}
































    /**
     * Vérifie la cohérence et la présence des bons éléments pour un champ
     * @param  string $name     Nom du champ
     * @param  array $config    Configuration du champ
     * @return boolean true
     */








>
>
>
>
>
>
>
>
>
>
>




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
                return $this->champs[$champ][$key];
            else
                return null;
        }

		return $this->champs[$champ];
	}

    public function isText($champ)
    {
        if (!array_key_exists($champ, $this->champs))
            return null;

        if (in_array($this->champs[$champ]['type'], $this->text_types))
            return true;
        else
            return false;
    }

	public function getAll()
	{
		return $this->champs;
	}

    public function getList()
    {
        $champs = $this->champs;
        unset($champs['passe']);
        return $champs;
    }

    public function getFirst()
    {
        reset($this->champs);
        return key($this->champs);
    }

    public function getListedFields()
    {
        $champs = $this->champs;

        $champs = array_filter($champs, function ($a) {
            return empty($a['list_row']) ? false : true;
        });

        uasort($champs, function ($a, $b) {
            if ($a['list_row'] == $b['list_row'])
                return 0;

            return ($a['list_row'] > $b['list_row']) ? 1 : -1;
        });

        return $champs;
    }

    /**
     * Vérifie la cohérence et la présence des bons éléments pour un champ
     * @param  string $name     Nom du champ
     * @param  array $config    Configuration du champ
     * @return boolean true
     */
147
148
149
150
151
152
153




154
155
156
157
158
159
160
            {
                throw new \BadMethodCallException('Champ '.$key.' non valide.');
            }

            if ($key == 'editable' || $key == 'private' || $key == 'mandatory')
            {
                $value = (bool) (int) $value;




            }
            elseif ($key == 'help' || $key == 'title')
            {
                $value = trim((string) $value);
            }
            elseif ($key == 'options')
            {







>
>
>
>







200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
            {
                throw new \BadMethodCallException('Champ '.$key.' non valide.');
            }

            if ($key == 'editable' || $key == 'private' || $key == 'mandatory')
            {
                $value = (bool) (int) $value;
            }
            elseif ($key == 'list_row')
            {
                $value = (int) $value;
            }
            elseif ($key == 'help' || $key == 'title')
            {
                $value = trim((string) $value);
            }
            elseif ($key == 'options')
            {
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
    		elseif ($cfg['type'] == 'multiple' || $cfg['type'] == 'checkbox')
    			$type = 'INTEGER';
    		elseif ($cfg['type'] == 'file')
    			$type = 'BLOB';
    		else
    			$type = 'TEXT';

    		$line = $key . ' ' . $type . ' ' . ',';

            if (!empty($cfg['title']))
            {
                $line .= '-- ' . str_replace(array("\n", "\r"), '', $cfg['title']);
            }

            $create[] = $line;

    		if (array_key_exists($key, $anciens_champs))
    		{
    			$copy[] = $key;







|



|







380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
    		elseif ($cfg['type'] == 'multiple' || $cfg['type'] == 'checkbox')
    			$type = 'INTEGER';
    		elseif ($cfg['type'] == 'file')
    			$type = 'BLOB';
    		else
    			$type = 'TEXT';

    		$line = $key . ' ' . $type . ',';

            if (!empty($cfg['title']))
            {
                $line .= ' -- ' . str_replace(array("\n", "\r"), '', $cfg['title']);
            }

            $create[] = $line;

    		if (array_key_exists($key, $anciens_champs))
    		{
    			$copy[] = $key;