Portage pour SPIP de la solution de gestion de consentement aux cookies Tarteaucitron.js
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

124 lines
4.0 KiB

<?php
if (!defined('_ECRIRE_INC_VERSION')) return;
include_spip('inc/tarteaucitron');
function formulaires_configurer_tarteaucitron_services_charger_dist(){
$valeurs = array();
$services_actifs = lire_config('tarteaucitron/services', array());
foreach($services_actifs as $service => $params) {
if (!empty($params)) {
$i = 0;
foreach($params as $name => $value) {
$valeurs[$service . '_p' . $i . '_' . substr($name,5)] = $value;
$i++;
}
}
}
return $valeurs;
}
function formulaires_configurer_tarteaucitron_services_traiter_dist(){
$ret = array();
$services_actifs = lire_config('tarteaucitron/services', array());
foreach($services_actifs as $service => $params) {
if (!empty($params)) {
$i = 0;
foreach($params as $name => $value) {
$valeur_saisie = _request($service . '_p' . $i . '_' . substr($name,5));
$valeur_saisie = is_null($valeur_saisie) ? '' : $valeur_saisie;
$services_actifs[$service][$name] = $valeur_saisie;
$i++;
}
}
}
if (ecrire_config('tarteaucitron/services',$services_actifs)) {
$ret['message_ok'] = _T('config_info_enregistree');
} else {
$ret['message_erreur'] = _T('erreur_technique_enregistrement_impossible');
}
$ret['editable'] = true;
return $ret;
}
function formulaires_configurer_tarteaucitron_services_saisies_dist(){
$saisies = [];
$json_source = find_in_path('json/services.json');
$json = file_get_contents($json_source);
$parsed_json = json_decode($json);
$types_actifs = tarteaucitron_liste_types_actifs();
foreach($types_actifs as $type => $liste_services) {
$fieldset = array(
'saisie' => 'fieldset',
'options' => array(
'nom' => $type,
'label' => $type,
'pliable' => 'oui',
'plie' => 'oui'
)
);
foreach($liste_services as $service => $params) {
$has_modele = $parsed_json->{$service}->{'hasModele'};
$fieldset['saisies'][] = array(
'saisie' => 'checkbox',
'options' => array(
'nom' => $service . '_actif',
'disable' => 'oui',
'datas' => array(
$service => $service
),
'defaut' => array($service)
)
);
if ($has_modele) {
$liste_modeles = scandir(_DIR_PLUGIN_TARTEAUCITRON . "modeles");
$modeles = '';
foreach($liste_modeles as $nom_fichier) {
if (preg_match('/^tac_' . $service . '(_\w+)?.html$/',$nom_fichier)) {
$modeles .= $nom_fichier . ', ';
}
}
$modeles = '(' . substr($modeles, 0, -2) . ')';
$fieldset['saisies'][] = array(
'saisie' => 'explication',
'options' => array(
'nom' => $service . '_hasmodele',
'titre' => _T('tarteaucitron:cfg_display_service', array('service' => $service)),
'texte' => _T('tarteaucitron:cfg_ajouter_modele', array('modeles' => $modeles))
)
);
}
$i = 0;
foreach($params as $param) {
$param = substr($param,5);
$fieldset['saisies'][] = array(
'saisie' => 'input',
'options' => array(
'nom' => $service . '_p' . $i . '_' . $param,
'label' => $param,
'explication' => 'Enter this parameter for ' . $service,
'placeholder' => $param,
'obligatoire' => 'oui'
)
);
$i++;
}
}
$saisies[] = $fieldset;
}
return $saisies;
}