Line | |
---|
1 | <?php |
---|
2 | |
---|
3 | // Sécurité |
---|
4 | if (!defined('_ECRIRE_INC_VERSION')) { |
---|
5 | return; |
---|
6 | } |
---|
7 | |
---|
8 | function construire_configuration_saisie($saisie, $avec_nom = 'non') { |
---|
9 | include_spip('inc/yaml'); |
---|
10 | $configuration_saisie = yaml_decode_file(find_in_path('saisies/'.$saisie.'.yaml')); |
---|
11 | |
---|
12 | if (is_array($configuration_saisie)) { |
---|
13 | $configuration_saisie = $configuration_saisie['options']; |
---|
14 | // On ne met le premier champ permettant de configurer le "name" seulement si on le demande explicitement |
---|
15 | if ($avec_nom == 'oui') { |
---|
16 | array_unshift( |
---|
17 | $configuration_saisie[0]['contenu'], |
---|
18 | array( |
---|
19 | 'saisie' => 'input', |
---|
20 | 'options' => array( |
---|
21 | 'nom' => 'nom', |
---|
22 | 'label' => '<:saisies:option_nom_label:>', |
---|
23 | 'explication' => '<:saisies:option_nom_explication:>', |
---|
24 | 'obligatoire' => 'oui' |
---|
25 | ), |
---|
26 | 'verifier' => array( |
---|
27 | 'type' => 'regex', |
---|
28 | 'options' => array( |
---|
29 | 'modele' => '/^[\w]+$/' |
---|
30 | ) |
---|
31 | ) |
---|
32 | ) |
---|
33 | ); |
---|
34 | } |
---|
35 | } else { |
---|
36 | $configuration_saisie = array(); |
---|
37 | } |
---|
38 | return $configuration_saisie; |
---|
39 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.