function socialtags_json($cfg)
{
    if (!is_array($cfg)) {
        return '[]';
    }
    $json = array();
    include_spip('socialtags_fonctions');
    foreach (socialtags_liste() as $service) {
        if (in_array($a = $service['lesauteurs'], $cfg)) {
            $t = _q($service['titre']);
            $u = _q($service['url']);
            $d = isset($service['descriptif']) ? _q($service['descriptif']) : $t;
            $u_site = _q($GLOBALS['meta']['adresse_site']);
            $i = _q('data:image/png;base64,' . base64_encode(file_get_contents(find_in_path('images/' . $a . '.png'))));
            $json[] = "{ a: '{$a}', n: {$t}, i: {$i}, u: {$u}, u_site: {$u_site}}";
        }
    }
    return "[\n" . join(",\n", $json) . "\n]";
}
function socialtags_choix()
{
    include_spip('socialtags_fonctions');
    global $couleur_fonce;
    $cfg = is_array($cfg = lire_config('socialtags/tags')) ? $cfg : array();
    $retour = array();
    foreach (socialtags_liste() as $service) {
        $t = $service['titre'];
        $u = $service['url'];
        $a = $service['lesauteurs'];
        $d = isset($service['descriptif']) ? $service['descriptif'] : '';
        $category = count($service['tags']) ? textebrut(reset($service['tags'])) : '99';
        $image = 'data:image/png;base64,' . base64_encode(file_get_contents(find_in_path('images/' . $a . '.png')));
        //$image = find_in_path('images/'.$a.'.png');
        $checked = in_array($a, $cfg) ? ' checked="checked"' : '';
        $retour[$category] .= "<div class='choix'>\n\t\t\t\t<input type='checkbox' id='choix_{$a}' name='tags[]' value='{$a}'{$checked} />\n\t\t\t\t<label for='choix_{$a}'>\n\t\t\t\t\t<img src=\"{$image}\" title=\"" . texte_script($t) . "\" alt=\"\" style=\"max-width:16px; height:auto;\" />\n\t\t\t\t\t" . ($checked ? "<strong>{$t}</strong>" : $t) . ($d ? "&nbsp;<span style='color:{$couleur_fonce};font-size:90%'>{$d}</span>" : "") . "\n\t\t\t\t</label>\n\t\t\t</div>";
    }
    ksort($retour);
    return implode("<hr />", $retour);
}