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.
72 lines
1.5 KiB
72 lines
1.5 KiB
<?php |
|
|
|
/** |
|
* Fonctions internes du plugin |
|
*/ |
|
|
|
if (!defined('_ECRIRE_INC_VERSION')) { |
|
return; |
|
} |
|
|
|
include_spip('inc/config'); |
|
/** |
|
* Détecter si au moins un service est actif. |
|
* |
|
* @return boolean |
|
*/ |
|
|
|
function tarteaucitron_actif() { |
|
$actif = false; |
|
$liste_services = lire_config('tarteaucitron/services', array()); |
|
|
|
foreach ($liste_services as $value => $params) { |
|
if (!empty($value)) { |
|
$actif = true; |
|
} |
|
} |
|
return $actif; |
|
} |
|
|
|
/** |
|
* Retourne la liste des services TarteAuCitron avec leur statut (actif,inactif) |
|
* et leur(s) éventuel(s) paramètre(s) |
|
* |
|
* @return Array |
|
*/ |
|
|
|
function tarteaucitron_liste_services() { |
|
$services_actifs = lire_config('tarteaucitron/services', array()); |
|
$list_services = []; |
|
$json_source = find_in_path('json/services.json'); |
|
$json = file_get_contents($json_source); |
|
$parsed_json = json_decode($json); |
|
|
|
foreach($parsed_json as $service => $prop) { |
|
$list_services[$service] = array( |
|
'type' => $prop->{'type'}, |
|
'statut' => (array_key_exists($service,$services_actifs)) ? 'actif' : 'inactif', |
|
'params' => (!empty($prop->{'params'})) ? $prop->{'params'} : array() |
|
); |
|
} |
|
|
|
return $list_services; |
|
} |
|
|
|
/** |
|
* Retourne la liste des types des services TarteAuCitron installés |
|
* |
|
* @return Array |
|
*/ |
|
|
|
function tarteaucitron_liste_types_actifs() { |
|
$list_types = []; |
|
$services = tarteaucitron_liste_services(); |
|
|
|
foreach($services as $service => $prop) { |
|
if ($prop['statut']=='actif') { |
|
$list_types[$prop['type']][$service] = $prop['params']; |
|
} |
|
} |
|
|
|
return $list_types; |
|
} |