Compare commits
80 Commits
Author | SHA1 | Date |
---|---|---|
|
c85da131e3 | 4 months ago |
|
e928506c56 | 4 months ago |
|
ba8711f7cb | 5 months ago |
|
2d540a0013 | 10 months ago |
|
2935475919 | 10 months ago |
|
f25027888c | 10 months ago |
|
b811de0142 | 10 months ago |
|
5e90243518 | 10 months ago |
|
fe4899a8cc | 10 months ago |
|
1fb1c95710 | 10 months ago |
|
e4f9eacbd9 | 10 months ago |
|
4e9689dd11 | 10 months ago |
|
0f48c3e24d | 10 months ago |
|
2477469b46 | 10 months ago |
|
d80109e174 | 10 months ago |
|
c5086040d6 | 10 months ago |
|
8f322b8a5a | 10 months ago |
|
02dd431dde | 10 months ago |
|
4193cd5361 | 10 months ago |
|
0d58131e3a | 10 months ago |
|
a8c05f89e7 | 10 months ago |
|
eb93edf929 | 10 months ago |
|
92df54af6d | 10 months ago |
|
5b83a42ed5 | 10 months ago |
|
fea2d75431 | 10 months ago |
|
c59a432d53 | 10 months ago |
|
f62a479c0d | 10 months ago |
|
4213a40512 | 10 months ago |
|
a569f5fe5e | 10 months ago |
|
31e7647ab6 | 10 months ago |
|
383674f0d7 | 10 months ago |
|
a501d9d706 | 10 months ago |
|
31d18de482 | 10 months ago |
|
ed9e3b66a5 | 10 months ago |
|
540441bafd | 10 months ago |
|
d46fc7ad6b | 10 months ago |
|
7f9ee0d7a1 | 10 months ago |
|
fa7b344d09 | 10 months ago |
|
7d12b2d291 | 11 months ago |
|
cdffea5ae2 | 11 months ago |
|
fba54b2f72 | 11 months ago |
|
e4c753c85e | 11 months ago |
|
32d824f0e7 | 11 months ago |
|
a28a1f6fbb | 12 months ago |
|
e99a3e1bea | 12 months ago |
|
cd7f1d444b | 1 year ago |
|
1f0450e9b1 | 1 year ago |
|
d0575fb858 | 1 year ago |
|
6164fa8ec1 | 1 year ago |
|
767424a23d | 1 year ago |
|
8447795753 | 1 year ago |
|
37649590f0 | 1 year ago |
|
48efe8da5d | 1 year ago |
|
f2ae4c3396 | 1 year ago |
|
560a69c52d | 1 year ago |
|
97dd116740 | 1 year ago |
|
aa8cd69568 | 1 year ago |
|
54b85e0e03 | 1 year ago |
|
0be5ff36f2 | 1 year ago |
|
c9f95321cb | 1 year ago |
|
7c6832e0d0 | 1 year ago |
|
e66f3acffb | 1 year ago |
|
c165cff667 | 1 year ago |
|
458d27c551 | 1 year ago |
|
172bdc8f18 | 1 year ago |
|
5fcab4ecc2 | 1 year ago |
|
bee67752b6 | 1 year ago |
|
3063dee284 | 1 year ago |
|
b9f522f64f | 1 year ago |
|
b4bf4150c1 | 1 year ago |
|
0cb56644fc | 1 year ago |
|
38b96e9ef8 | 1 year ago |
|
9a7f8114b2 | 1 year ago |
|
1f87548d87 | 2 years ago |
|
b8c0845f5e | 2 years ago |
|
09f8f0e9ec | 2 years ago |
|
f36aea4774 | 2 years ago |
|
449b39e653 | 2 years ago |
|
d50ab860f4 | 2 years ago |
|
04cdf52659 | 2 years ago |
160 changed files with 7764 additions and 2717 deletions
@ -0,0 +1,52 @@
|
||||
<?php |
||||
/** |
||||
* Plugin TarteAuCitron |
||||
* Licence GPL3 |
||||
* |
||||
*/ |
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')){ |
||||
return; |
||||
} |
||||
|
||||
/** |
||||
* Active un service |
||||
* appelé avec ?action=tarteaucitron_activer_service&service=service |
||||
* autorisé pour les seuls webmestres |
||||
*/ |
||||
function action_tarteaucitron_activer_service_dist(){ |
||||
include_spip('inc/autoriser'); |
||||
|
||||
if (!autoriser('webmestre')){ |
||||
die('Pas autorise'); |
||||
} |
||||
|
||||
include_spip('inc/tarteaucitron'); |
||||
|
||||
$service = _request('service'); |
||||
$list_services = tarteaucitron_liste_services(); |
||||
|
||||
if (!array_key_exists($service,$list_services)) { |
||||
die('Service inexistant'); |
||||
} |
||||
|
||||
if ($list_services[$service]['statut']=='actif') { |
||||
die('Service déjà actif'); |
||||
} |
||||
|
||||
include_spip('inc/config'); |
||||
|
||||
$services_actifs = lire_config("tarteaucitron/services"); |
||||
$services_actifs[$service] = array(); |
||||
|
||||
$json_source = find_in_path('json/services.json'); |
||||
$json = file_get_contents($json_source); |
||||
$parsed_json = json_decode($json); |
||||
$params = $parsed_json->{$service}->{'params'}; |
||||
|
||||
foreach($params as $param) { |
||||
$services_actifs[$service][$param] = substr($param,5); |
||||
} |
||||
|
||||
ecrire_config("tarteaucitron/services/", $services_actifs); |
||||
} |
@ -0,0 +1,43 @@
|
||||
<?php |
||||
/** |
||||
* Plugin TarteAuCitron |
||||
* Licence GPL3 |
||||
* |
||||
*/ |
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')){ |
||||
return; |
||||
} |
||||
|
||||
/** |
||||
* Désactive un service |
||||
* appelé avec ?action=tarteaucitron_desactiver_service&service=service |
||||
* autorisé pour les seuls webmestres |
||||
*/ |
||||
function action_tarteaucitron_desactiver_service_dist(){ |
||||
include_spip('inc/autoriser'); |
||||
|
||||
if (!autoriser('webmestre')){ |
||||
die('Pas autorise'); |
||||
} |
||||
|
||||
include_spip('inc/tarteaucitron'); |
||||
|
||||
$service = _request('service'); |
||||
$list_services = tarteaucitron_liste_services(); |
||||
|
||||
if (!array_key_exists($service,$list_services)) { |
||||
die('Service inexistant'); |
||||
} |
||||
|
||||
if ($list_services[$service]['statut']=='inactif') { |
||||
die('Service déjà inactif'); |
||||
} |
||||
|
||||
include_spip('inc/config'); |
||||
$services_actifs = lire_config("tarteaucitron/services"); |
||||
|
||||
unset($services_actifs[$service]); |
||||
|
||||
ecrire_config("tarteaucitron/services", $services_actifs); |
||||
} |
@ -0,0 +1,251 @@
|
||||
<?php |
||||
/** |
||||
* Plugin TarteAuCitron |
||||
* Licence GPL3 |
||||
* |
||||
*/ |
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')){ |
||||
return; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Conversion des iframe en modèles pour TarteAuCitron |
||||
* appelé avec ?action=tarteaucitron_nettoyer_iframes |
||||
* autorisé pour les seuls webmestres |
||||
*/ |
||||
function action_tarteaucitron_nettoyer_iframes_dist(){ |
||||
include_spip('inc/autoriser'); |
||||
include_spip('inc/filtres'); |
||||
include_spip('action/editer_objet'); |
||||
if (!autoriser('webmestre')){ |
||||
die('Pas autorise'); |
||||
} |
||||
echo '<h1>Conversion des <iframe></h1>'; |
||||
$simu = true; |
||||
if (_request('modif')){ |
||||
$simu = false; |
||||
} |
||||
if ($simu){ |
||||
echo "<p><strong>mode SIMULATION</strong> (ajoutez &modif=1 dans l'url pour modifier les contenus)</p>"; |
||||
} |
||||
|
||||
$tables = array( |
||||
'spip_articles' => array('descriptif', 'chapo', 'texte', 'ps'), |
||||
); |
||||
|
||||
foreach ($tables as $table => $champs){ |
||||
$objet = objet_type($table); |
||||
foreach ($champs as $champ){ |
||||
$primary = id_table_objet($table); |
||||
$res = sql_select("$primary,$champ", $table, "$champ LIKE '%iframe%' OR $champ LIKE '%object%'"); |
||||
while ($row = sql_fetch($res)){ |
||||
$pre = "$primary=" . $row[$primary] . ":$champ:"; |
||||
|
||||
$texte = $row[$champ]; |
||||
$iframes = extraire_balises($texte, 'iframe'); |
||||
if (count($iframes)){ |
||||
foreach ($iframes as $iframe){ |
||||
$url = ''; |
||||
$src = extraire_attribut($iframe, 'src'); |
||||
if (strncmp($src, '//', 2)==0){ |
||||
$src = 'http:' . $src; |
||||
} |
||||
if (strpos($iframe, 'youtube')!==false){ |
||||
if (strpos($src, '/embed/')!==false){ |
||||
$url = str_replace('?', '&', $src); |
||||
$url = str_replace('/embed/videoseries&', '/playlist?', $url); |
||||
$url = str_replace('/embed/', '/watch?v=', $url); |
||||
$url = str_replace('&feature=player_embedded', '', $url); |
||||
preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match); |
||||
$url = "<tac_youtube|id=" . $match[1] . ">"; |
||||
|
||||
echo "$pre Youtube " . entites_html($url) . "<br />"; |
||||
} |
||||
if (!$url){ |
||||
var_dump($row); |
||||
var_dump(entites_html($iframe)); |
||||
die('youtube inconnue'); |
||||
} |
||||
} elseif (strpos($iframe, 'dailymotion')!==false) { |
||||
if (strpos($src, '/embed/')!==false){ |
||||
$url = str_replace('/embed/', '/', $src); |
||||
$url = explode('?', $url); |
||||
$url = reset($url); |
||||
$url = "<tac_dailymotion|id=" . strtok(basename($url), '_') . ">"; |
||||
echo "$pre DailyMotion" . entites_html($url) . "<br />"; |
||||
} |
||||
if (!$url){ |
||||
var_dump($row); |
||||
var_dump($iframe); |
||||
die('dailymotion inconnue'); |
||||
} |
||||
} elseif (strpos($iframe, 'player.vimeo')!==false) { |
||||
if (strpos($src, '/video/')!==false){ |
||||
$url = str_replace('/video/', '/', $src); |
||||
$url = str_replace('player.vimeo', 'vimeo', $url); |
||||
$url = explode('?', $url); |
||||
$url = reset($url); |
||||
preg_match('%https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)%i', $url, $match); |
||||
$url = "<tac_vimeo|id=" . $match[3] . ">"; |
||||
echo "$pre Vimeo " . entites_html($url) . "<br />"; |
||||
} |
||||
if (!$url){ |
||||
var_dump($row); |
||||
var_dump($iframe); |
||||
die('vimeo inconnue'); |
||||
} |
||||
} /*elseif (strpos($iframe, 'soundcloud') !== false) { |
||||
// un peu complique : |
||||
// il faut faire une requete oembed sur l'url api, avec iframe=false |
||||
// pour recuperer du html avec un lien vers la page soundcloud |
||||
parse_str(end(explode('?', $src)), $args); |
||||
$api_url = $args['url']; |
||||
include_spip('inc/oembed'); |
||||
include_spip('inc/distant'); |
||||
$provider = oembed_verifier_provider($api_url); |
||||
$data_url = parametre_url(url_absolue($provider['endpoint'], url_de_base()), 'url', $api_url, '&'); |
||||
$data_url = parametre_url($data_url, 'format', 'json', '&'); |
||||
$data_url = parametre_url($data_url, 'iframe', 'false', '&'); |
||||
$json = recuperer_page($data_url); |
||||
$json = json_decode($json, true); |
||||
$link = extraire_balise($json['html'], 'a'); |
||||
if ($url = extraire_attribut($link, 'href')) { |
||||
echo "$pre SoundCloud $url<br />"; |
||||
} |
||||
if (!$url) { |
||||
var_dump($row); |
||||
var_dump($iframe); |
||||
die('soundcloud inconnue'); |
||||
} |
||||
} */ elseif (strpos($iframe, 'www.google.com/calendar') !== false) { |
||||
if (strpos($src, '/embed')!==false){ |
||||
preg_match('#(src=)(\w+)$#', $src, $match); |
||||
$url = "<tac_gagenda|id=" . $match[2] . ">"; |
||||
|
||||
echo "$pre Google Agenda " . entites_html($url) . "<br />"; |
||||
} |
||||
} elseif (strpos($iframe, 'www.canal-u.tv/video') !== false) { |
||||
if (strpos($src, '/embed')!==false){ |
||||
preg_match('#(/embed.1/)(.+)(\?)#', $src, $match); |
||||
$url = "<tac_canalu|id=" . $match[2] . ">"; |
||||
$divs = extraire_balises($texte, 'div'); |
||||
foreach ($divs as $div) { |
||||
if (strpos($div, $match[2])!==false) { |
||||
$iframe = $div; |
||||
} |
||||
} |
||||
|
||||
echo "$pre Canal-U.tv " . entites_html($url) . "<br />"; |
||||
} |
||||
} elseif (strpos($iframe, 'webtv.normandie-univ.fr') !== false) { |
||||
if (strpos($src, '/permalink/')!==false){ |
||||
preg_match('#(/permalink/)(\w+)(/iframe)#', $src, $match); |
||||
$url = "<tac_webtvnu|id=" . $match[2] . ">"; |
||||
echo "$pre WebTV Normandie Université " . entites_html($url) . "<br />"; |
||||
} |
||||
} else { |
||||
echo "$pre iframe inconnue : " . entites_html($iframe) . '<br />'; |
||||
} |
||||
if ($url){ |
||||
$texte = str_replace($iframe, "\n\n" . $url . "\n\n", $texte); |
||||
if (preg_match(',<center>\s*' . preg_quote($url, ',') . '.*</center>,Uims', $texte, $m)){ |
||||
$texte = str_replace($m[0], "\n\n" . $url . "\n\n", $texte); |
||||
} |
||||
$texte = preg_replace(',\s+' . preg_quote($url, ',') . '\s+,ims', "\n\n" . $url . "\n\n", $texte); |
||||
} |
||||
} |
||||
if ($texte!==$row[$champ]){ |
||||
echo "$pre Corrige $champ <br />"; |
||||
if (!$simu){ |
||||
echo "$pre Corrige $champ <br />"; |
||||
objet_modifier($objet, $row[$primary], array($champ => $texte)); |
||||
} else { |
||||
echo "SIMU : $pre Corrige $champ <br />"; |
||||
} |
||||
} |
||||
} |
||||
$objects = extraire_balises($texte, 'object'); |
||||
if (count($objects)){ |
||||
foreach ($objects as $object){ |
||||
$url = ''; |
||||
$src = extraire_attribut($object, 'data'); |
||||
if (strncmp($src, '//', 2)==0){ |
||||
$src = 'http:' . $src; |
||||
} |
||||
if (strpos($src, 'youtube')!==false){ |
||||
if (strpos($src, '/v/')!==false){ |
||||
$url = str_replace('?', '&', $src); |
||||
$url = str_replace('/v/', '/watch?v=', $url); |
||||
} elseif (strpos($src, '/embed/')!==false) { |
||||
$url = str_replace('?', '&', $src); |
||||
$url = str_replace('/embed/', '/watch?v=', $url); |
||||
} |
||||
if (!$url){ |
||||
var_dump($row); |
||||
var_dump(entites_html($object)); |
||||
die('youtube inconnue'); |
||||
} else { |
||||
preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match); |
||||
$url = "<tac_youtube|id=" . $match[1] . ">"; |
||||
echo "$pre Youtube " . entites_html($url) . "<br />"; |
||||
} |
||||
} elseif (strpos($src, 'dailymotion')!==false) { |
||||
if (strpos($src, '/swf/video/')!==false){ |
||||
$url = str_replace('/swf/video/', '/video/', $src); |
||||
$url = explode('?', $url); |
||||
$url = reset($url); |
||||
} elseif (strpos($src, '/swf/')!==false) { |
||||
$url = str_replace('/swf/', '/video/', $src); |
||||
$url = explode('?', $url); |
||||
$url = reset($url); |
||||
} |
||||
if (!$url){ |
||||
var_dump($row); |
||||
var_dump($object); |
||||
die('dailymotion inconnue'); |
||||
} else { |
||||
$url = "<tac_dailymotion|id=" . strtok(basename($url), '_') . ">"; |
||||
echo "$pre DailyMotion" . entites_html($url) . "<br />"; |
||||
} |
||||
} elseif (strpos($src, 'vimeo.com')!==false) { |
||||
if (strpos($src, 'moogaloop')!==false |
||||
and $id = parametre_url($src, 'clip_id')){ |
||||
$url = "https://vimeo.com/$id"; |
||||
} elseif (strpos($src, '/video/')!==false) { |
||||
$url = $src; |
||||
} |
||||
if (!$url){ |
||||
var_dump($row); |
||||
var_dump(entites_html($object)); |
||||
die('vimeo inconnue'); |
||||
} else { |
||||
preg_match('%https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)%i', $url, $match); |
||||
$url = "<tac_vimeo|id=" . $match[3] . ">"; |
||||
echo "$pre Vimeo " . entites_html($url) . "<br />"; |
||||
} |
||||
} else { |
||||
echo "$pre object inconnue : " . entites_html($object) . '<br />'; |
||||
} |
||||
if ($url){ |
||||
$texte = str_replace($object, "\n\n" . $url . "\n\n", $texte); |
||||
if (preg_match(',<center>\s*' . preg_quote($url, ',') . '.*</center>,Uims', $texte, $m)){ |
||||
$texte = str_replace($m[0], "\n\n" . $url . "\n\n", $texte); |
||||
} |
||||
$texte = preg_replace(',\s+' . preg_quote($url, ',') . '\s+,ims', "\n\n" . $url . "\n\n", $texte); |
||||
} |
||||
} |
||||
if ($texte!==$row[$champ]){ |
||||
if (!$simu){ |
||||
echo "$pre Corrige $champ <br />"; |
||||
objet_modifier($objet, $row[$primary], array($champ => $texte)); |
||||
} else { |
||||
echo "SIMU : $pre Corrige $champ <br />"; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,181 @@
|
||||
<?php |
||||
/** |
||||
* Plugin TarteAuCitron |
||||
* Licence GPL3 |
||||
* |
||||
*/ |
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')){ |
||||
return; |
||||
} |
||||
|
||||
/** |
||||
* Mise à jour du fichier services/services.html |
||||
* appelé avec ?action=tarteaucitron_referencer_services |
||||
* autorisé pour les seuls webmestres |
||||
*/ |
||||
function action_tarteaucitron_referencer_services_dist(){ |
||||
include_spip('inc/autoriser'); |
||||
if (!autoriser('webmestre')){ |
||||
die('Pas autorise'); |
||||
} |
||||
|
||||
$list_services = array(); |
||||
$services_specifiques = array(); |
||||
|
||||
if ($lines=file(find_in_path('lib/tarteaucitron/tarteaucitron.services.js'))){ |
||||
$i=0; |
||||
foreach($lines as $line) { |
||||
if(preg_match('/^tarteaucitron\.services\.(\w+)/', $line, $matches)) { |
||||
$service = $matches[1]; |
||||
|
||||
$list_services[$service] = array(); |
||||
$list_services[$service]['hasModele'] = false; |
||||
$list_services[$service]['params'] = array(); |
||||
|
||||
if (preg_match('/["\']?type["\']?: ["\'](\w+)["\'],/', $lines[$i+2], $matches)) { |
||||
$type = $matches[1]; |
||||
$list_services[$service]['type'] = $type; |
||||
} |
||||
} |
||||
$i++; |
||||
} |
||||
} |
||||
|
||||
$tarteaucitron_url = 'https://tarteaucitron.io/fr/install/'; |
||||
$html = file_get_contents($tarteaucitron_url); |
||||
$doc = new DOMDocument('1.0', 'UTF-8'); |
||||
$internalErrors = libxml_use_internal_errors(true); |
||||
$doc->loadHTML($html); |
||||
libxml_use_internal_errors($internalErrors); |
||||
|
||||
foreach($list_services as $service => $prop) { |
||||
$div_service = $doc->getElementById('s_' . $service); |
||||
|
||||
if (!empty($div_service)) { |
||||
$id = $div_service->lastChild->attributes['id']->value; |
||||
$div_code = $doc->getElementById('m' . $id); |
||||
$span_list = $div_code->getElementsByTagName('span'); |
||||
$nb_items = $span_list->length; |
||||
$k = 0; |
||||
$is_modele_found = false; |
||||
$is_service_hidden = in_array($list_services[$service]['type'],array('support','analytic')); |
||||
if (!$is_service_hidden) { |
||||
// Gestion des services spécifiques |
||||
switch ($service) { |
||||
case 'facebook': |
||||
$list_services[$service]['hasModele'] = true; |
||||
$list_services[$service]['params_modele']['facebook_video'][] = 'video_id'; |
||||
$services_specifiques[] = $service; |
||||
break; |
||||
default : |
||||
$list_services[$service]['params_modele'] = array(); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
// Pour chaque span.code |
||||
for($i=0; $i<$nb_items; $i++) { |
||||
$span = $span_list->item($i); |
||||
$class_attr = $span->attributes->getNamedItem("class"); |
||||
|
||||
if ((!is_null($class_attr)) && ($class_attr->nodeValue=='code')) { |
||||
$k++; |
||||
|
||||
// Récupère le code JS pour activer le service |
||||
if ($k==1) { |
||||
$param_list = $span->getElementsByTagName('b'); |
||||
$nb_params = $param_list->length; |
||||
$j = $nb_params -1; |
||||
|
||||
while ($j > -1) { |
||||
$param = $param_list[$j]; |
||||
$nom_param = "ptac_" . str_replace(" ","_",$param->textContent); |
||||
$newelement = $doc->createTextNode("'" . $nom_param . "'"); |
||||
$span->replaceChild($newelement,$param); |
||||
array_unshift($list_services[$service]['params'],$nom_param); |
||||
$j--; |
||||
} |
||||
|
||||
$s = $span->getElementsByTagName('s'); |
||||
$span->removeChild($s[0]); |
||||
$script = trim(strip_tags($span->nodeValue)); |
||||
$script = preg_replace('/(\n\s+)/', "\n", $script); |
||||
$script = str_replace("''","'",$script); |
||||
$list_services[$service]['JS'] = $script; |
||||
// Récupère le modèle HTML |
||||
} elseif (($i!=$nb_items-1) && (!$is_modele_found)) { |
||||
$is_modele_found = true; |
||||
$pattern = array(); |
||||
$param_list = $span->getElementsByTagName('b'); |
||||
$nb_params = $param_list->length; |
||||
$j = $nb_params -1; |
||||
|
||||
while ($j > -1) { |
||||
$param = $param_list[$j]; |
||||
$nom_param = str_replace(" ","_",$param->textContent); |
||||
// Si le paramètre contient des valeurs entre parenthèses comme (true | false), on les enlève |
||||
if (preg_match('/(_\(.+\))/',$nom_param,$matches)) { |
||||
$nom_param = str_replace($matches[1],"", $nom_param); |
||||
} |
||||
|
||||
if ($is_service_hidden) { |
||||
$nom_param = "ptac_" . $nom_param; |
||||
|
||||
if (!in_array($nom_param,$list_services[$service]['params'])) { |
||||
array_unshift($list_services[$service]['params'],$nom_param); |
||||
} |
||||
} else { |
||||
array_unshift($list_services[$service]['params_modele'],$nom_param); |
||||
$nom_param = "(#ENV{" . $nom_param . "})"; |
||||
$pattern[] = '/(\s?[\w\-.]*\s?[=:]?\s?[\'\"]?' . quotemeta($nom_param) . '[\'\"]?\w*[,;]?)/'; |
||||
} |
||||
|
||||
$newelement = $doc->createTextNode($nom_param); |
||||
$span->replaceChild($newelement,$param); |
||||
$j--; |
||||
} |
||||
|
||||
$script = trim($span->nodeValue); |
||||
|
||||
if (!$is_service_hidden) { |
||||
// On ajoute les crochets pour la syntaxe SPIP |
||||
$script = preg_replace($pattern,'[${1}]',$script); |
||||
} |
||||
|
||||
$script = preg_replace('/(\n\s+)/', "\n", $script); |
||||
$script = str_replace("''","'",$script); |
||||
|
||||
if ($is_service_hidden) { |
||||
$script = strip_tags($script); |
||||
$list_services[$service]['JS'] = $script . "\n" . $list_services[$service]['JS']; |
||||
} elseif (!in_array($service,$services_specifiques)) { |
||||
$list_services[$service]['hasModele'] = true; |
||||
$fichier_modele = _DIR_PLUGIN_TARTEAUCITRON . "modeles/tac_" . $service . ".html"; |
||||
file_put_contents($fichier_modele, $script); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Supprimer les clés qui sont des tableaux vides |
||||
foreach($list_services[$service] as $prop => $value) { |
||||
if ((is_array($list_services[$service][$prop])) && (empty($list_services[$service][$prop]))) { |
||||
unset($list_services[$service][$prop]); |
||||
} |
||||
} |
||||
} else { |
||||
unset($list_services[$service]); |
||||
} |
||||
} |
||||
|
||||
// Création du JSON avec les services, leur type, leur(s) paramètre(s) et le code JS associé |
||||
$file_json = find_in_path('json/services.json'); |
||||
|
||||
if (file_put_contents($file_json, json_encode($list_services))) { |
||||
echo "Opération réussie !<br>"; |
||||
echo "Le fichier <b>" . $file_json . "</b> a été mis à jour."; |
||||
} else { |
||||
echo "Erreur lors de l'écriture du fichier " . $file_json . "."; |
||||
} |
||||
} |
@ -0,0 +1,30 @@
|
||||
<?php |
||||
/** |
||||
* Plugin TarteAuCitron |
||||
* Licence GPL3 |
||||
* |
||||
*/ |
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')){ |
||||
return; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Retourne la lise des services avec leur type et leur statut (installe/desinstalle) |
||||
* au format json |
||||
* appelé avec ?exec=tarteaucitron_liste_services |
||||
*/ |
||||
function exec_tarteaucitron_liste_services_dist(){ |
||||
include_spip('inc/tarteaucitron'); |
||||
include_spip('inc/autoriser'); |
||||
|
||||
if (!autoriser('webmestre')){ |
||||
die('Pas autorise'); |
||||
} |
||||
|
||||
header('Content-Type: application/json'); |
||||
$list_services = tarteaucitron_liste_services(); |
||||
|
||||
echo json_encode($list_services); |
||||
} |
@ -0,0 +1,86 @@
|
||||
<div id="formulaire_#FORM"" class="formulaire_spip formulaire_configurer formulaire_#FORM"> |
||||
<div class="box__header"> |
||||
<h3><:tarteaucitron:cfg_titre_ajouter_services:></h3> |
||||
</div> |
||||
<div> |
||||
<ol class="explication"> |
||||
<:tarteaucitron:cfg_explication:> |
||||
</ol> |
||||
<div class="editer-groupe"> |
||||
<div class="editer editer_searchService obligatoire saisie_input editer_even"> |
||||
<label class="label" for="champ_searchService"><:tarteaucitron:cfg_titre_recherche_services:></label> |
||||
<input type="text" name="searchService" class="text" id="champ_searchService" value="" required="required" placeholder="<:tarteaucitron:cfg_titre_placeholder_recherche_services:>" autocomplete="off"> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="image_loading"></div> |
||||
<fieldset> |
||||
<legend><:tarteaucitron:cfg_titre_result_recherche_services:></legend> |
||||
<div id="tac_results"></div> |
||||
</fieldset> |
||||
</div> |
||||
</div> |
||||
<script> |
||||
var tac_url = '?exec=tarteaucitron_liste_services', |
||||
oldValue = '' |
||||
services = {}; |
||||
|
||||
$('#formulaire_#FORM').animateLoading(); |
||||
|
||||
$.ajax({ |
||||
url: tac_url, |
||||
dataType: 'json', |
||||
success: (data) => { |
||||
services = data |
||||
}, |
||||
complete: () => { |
||||
$('#formulaire_#FORM').endLoading(true) |
||||
} |
||||
}); |
||||
|
||||
// Appliquer un délai à l'exécution d'une fonction |
||||
function delay(fn, ms) { |
||||
let timer = 0 |
||||
return function(...args) { |
||||
clearTimeout(timer) |
||||
timer = setTimeout(fn.bind(this, ...args), ms || 0) |
||||
} |
||||
} |
||||
|
||||
// Fonction de recherche |
||||
function rechService(search) { |
||||
if (!search) { |
||||
$('#tac_results').html('') |
||||
return false |
||||
} |
||||
|
||||
var html = '<ul class="liste-items">' |
||||
jQuery.each(services, function(service, prop) { |
||||
var status = '' |
||||
var properties = Object.entries(prop) |
||||
jQuery.each(properties, function(i,property){ |
||||
if (property[0]=='statut') { |
||||
status = property[1] |
||||
} |
||||
}) |
||||
if (service.toLowerCase().indexOf(search) >= 0) { |
||||
var btn_texte = (status=='inactif') ? '<:tarteaucitron:cfg_installer:>' : '<:tarteaucitron:cfg_desinstaller:>' |
||||
var action = (status=='inactif') ? 'tarteaucitron_activer_service' : 'tarteaucitron_desactiver_service' |
||||
html += '<li class="item">' + service + '<a href="?action=' + action + '&service=' + service + '&redirect=?exec=configurer_services" class="btn">' + btn_texte + '</a></li>' |
||||
} |
||||
}); |
||||
html += '</ul>' |
||||
|
||||
$('#tac_results').html(html) |
||||
} |
||||
|
||||
// On actualise les résultats de recherche à chaque modification |
||||
$('#champ_searchService').keyup(delay((e) => { |
||||
if (e.target.value == oldValue) { |
||||
e.preventDefault() |
||||
return false |
||||
} |
||||
oldValue = e.target.value |
||||
rechService(e.target.value) |
||||
}, 250)); |
||||
</script> |
@ -1,37 +1,25 @@
|
||||
<div class="formulaire_spip formulaire_configurer formulaire_#FORM"> |
||||
|
||||
<h3 class="titrem"><:tarteaucitron:cfg_titre_bandeau:></h3> |
||||
|
||||
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>] |
||||
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>] |
||||
|
||||
<form method="post" action="#ENV{action}"> |
||||
<div> |
||||
#ACTION_FORMULAIRE{#ENV{action}} |
||||
#ACTION_FORMULAIRE{#ENV{action}} |
||||
|
||||
<fieldset> |
||||
<legend><:tarteaucitron:legend_bandeau_principal:></legend> |
||||
<div class="editer-groupe"> |
||||
[(#SAISIE{radio, highprivacy, label=<:tarteaucitron:cfg_afficher_bandeau:>, explication=<:tarteaucitron:cfg_afficher_bandeau_explication:>, defaut=true, datas=[(#ARRAY{true,Oui,false,Non})]})] |
||||
[(#SAISIE{radio, orientation, label=<:tarteaucitron:cfg_placement_bandeau:>, defaut=top, datas=[(#ARRAY{top,Haut,bottom,Bas})]})] |
||||
[(#SAISIE{radio, acceptallcta, label=<:tarteaucitron:cfg_btn_accetpall:>, explication=<:tarteaucitron:cfg_btn_accetpall_explication:>, defaut=true, datas=[(#ARRAY{true,Oui,false,Non})]})] |
||||
[(#SAISIE{input, readmoreLink, label=<:tarteaucitron:cfg_readmoreLink:>, explication=<:tarteaucitron:cfg_readmoreLink_explication:>})] |
||||
</div> |
||||
</fieldset> |
||||
|
||||
<fieldset> |
||||
<legend><:tarteaucitron:legend_cookie:></legend> |
||||
<p class="explication"><:tarteaucitron:cfg_btn_showIcon_explication:></p> |
||||
<div class="editer-groupe"> |
||||
[(#SAISIE{radio, showIcon, label=<:tarteaucitron:cfg_btn_showIcon:>, defaut=true, datas=[(#ARRAY{true,Oui,false,Non})]})] |
||||
[(#SAISIE{radio, iconPosition, label=<:tarteaucitron:cfg_iconposition:>, defaut=BottomRight, datas=[(#ARRAY{BottomRight, En bas à doite, BottomLeft, En bas à gauche, TopRight, En haut à droite, TopLeft, En haut à gauche})]})] |
||||
[(#SAISIE{checkbox, highprivacy, label=<:tarteaucitron:cfg_afficher_bandeau:>, explication=<:tarteaucitron:cfg_afficher_bandeau_explication:>, attention=<:tarteaucitron:cfg_afficher_bandeau_attention:>, data=[(#ARRAY{true,<:item_oui:>})]})] |
||||
[(#SAISIE{selection, orientation, option_intro=<:tarteaucitron:cfg_choose_option:>, label=<:tarteaucitron:cfg_placement_bandeau:>, defaut=middle, data=[(#ARRAY{top,<:tarteaucitron:cfg_bandeau_haut_page:>,middle,<:tarteaucitron:cfg_bandeau_milieu:>,bottom,<:tarteaucitron:cfg_bandeau_bas_page:>})]})] |
||||
[(#SAISIE{radio, boutons, label=<:tarteaucitron:cfg_btn_accetpall:>, explication=<:tarteaucitron:cfg_btn_accetpall_explication:>, attention=<:tarteaucitron:cfg_btn_accetpall_attention:>, data=[(#ARRAY{none,<:tarteaucitron:cfg_btn_aucun:>,both,<:tarteaucitron:cfg_btn_deux:>,acceptallonly,<:tarteaucitron:cfg_btn_acceptonly:>})]})] |
||||
[(#SAISIE{textarea, lang_alertBigPrivacy, label=<:tarteaucitron:cfg_text_alertbigprivacy:>, explication=<:tarteaucitron:cfg_text_alertbigprivacy_explication:>, rows=2})] |
||||
[(#SAISIE{checkbox, closePopup, label=<:tarteaucitron:cfg_close_popup:>, explication=<:tarteaucitron:cfg_close_popup_explication:>, data=[(#ARRAY{true,<:item_oui:>})]})] |
||||
</div> |
||||
</fieldset> |
||||
|
||||
<input type="hidden" name="_meta_casier" value="tarteaucitron" /> |
||||
<p class="boutons"><span class="image_loading"> </span><input type="submit" class="submit" value="<:bouton_enregistrer:>" /></p> |
||||
</div> |
||||
|
||||
<input type="hidden" name="_meta_casier" value="tarteaucitron" /> |
||||
<p class="boutons"><span class="image_loading"> </span><input type="submit" class="submit" value="<:bouton_enregistrer:>" /></p> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
|
@ -0,0 +1,20 @@
|
||||
<div class="formulaire_spip formulaire_configurer formulaire_#FORM"> |
||||
|
||||
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>] |
||||
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>] |
||||
|
||||
<form method="post" action="#ENV{action}" enctype="multipart/form-data"> |
||||
<div> |
||||
#ACTION_FORMULAIRE{#ENV{action}} |
||||
|
||||
<fieldset> |
||||
<legend><:tarteaucitron:legend_cookie:></legend> |
||||
<p class="explication"><:tarteaucitron:cfg_btn_showIcon_explication:></p> |
||||
<div class="editer-groupe"> |
||||
#GENERER_SAISIES{#ENV{_saisies}} |
||||
</div> |
||||
</fieldset> |
||||
<p class="boutons"><span class="image_loading"> </span><input type="submit" class="submit" value="<:bouton_enregistrer:>" /></p> |
||||
</div> |
||||
</form> |
||||
</div> |
@ -0,0 +1,167 @@
|
||||
<?php |
||||
if (!defined('_ECRIRE_INC_VERSION')) return; |
||||
|
||||
// Nécessaire pour bigup |
||||
/** |
||||
* @param array $args |
||||
* @param \Spip\Bigup\Formulaire $formulaire |
||||
* @return \Spip\Bigup\Formulaire |
||||
*/ |
||||
function inc_bigup_medias_formulaire_configurer_tarteaucitron_ouverture_dist($args, $formulaire) { |
||||
$formulaire->preparer_input_class( |
||||
'bigup', |
||||
['previsualiser' => true, 'editer_class' => ''] |
||||
); |
||||
return $formulaire; |
||||
} |
||||
|
||||
function formulaires_configurer_tarteaucitron_ouverture_charger_dist(){ |
||||
// Nécessaire pour bigup |
||||
$valeurs['_bigup_rechercher_fichiers'] = true; |
||||
|
||||
return $valeurs; |
||||
} |
||||
|
||||
function formulaires_configurer_tarteaucitron_ouverture_verifier_dist(){ |
||||
$erreurs = array(); |
||||
if (!empty($_FILES['upload_icon'])) { |
||||
$file = $_FILES['upload_icon']; |
||||
$verifier = charger_fonction('verifier', 'inc/'); |
||||
$options_verif = array( |
||||
'mime' => 'image_web', |
||||
'hauteur_max' => 50, |
||||
'largeur_max' => 50 |
||||
); |
||||
|
||||
if ($erreur = $verifier($file, 'fichiers', $options_verif)) { |
||||
$erreurs['upload_icon'] = $erreur; |
||||
$dest = $file['tmp_name']; |
||||
if (file_exists($dest)) { |
||||
@unlink($dest); |
||||
} |
||||
} |
||||
} |
||||
|
||||
return $erreurs; |
||||
} |
||||
|
||||
function formulaires_configurer_tarteaucitron_ouverture_traiter_dist(){ |
||||
include_spip('inc/cvt_configurer'); |
||||
|
||||
$retours = [ |
||||
'message_ok' => _T('config_info_enregistree'), |
||||
'editable' => true, |
||||
]; |
||||
|
||||
// On garde en mémoire l'existant (l'API vide sinon) |
||||
if ($icone_actuelle = lire_config('tarteaucitron/icon')) { |
||||
set_request('icon', $icone_actuelle); |
||||
} |
||||
|
||||
// On enregistre la nouvelle configuration |
||||
$trace = cvtconf_formulaires_configurer_enregistre('configurer_tarteaucitron_ouverture', array()); |
||||
|
||||
// On vérifie si on supprime l'image existante |
||||
if (_request("supprimer_upload_icon")) { |
||||
ecrire_config('tarteaucitron/icon', ''); |
||||
if ($icone_actuelle) { |
||||
@unlink($icone_actuelle); |
||||
} |
||||
// On vérifie si on envoie une nouvelle image |
||||
} elseif (!empty($_FILES['upload_icon'])) { |
||||
include_spip('action/ajouter_documents'); |
||||
|
||||
$file = $_FILES['upload_icon']; |
||||
$extension = pathinfo($file['name'], PATHINFO_EXTENSION); |
||||
$extension = corriger_extension(strtolower($extension)); |
||||
$dest_name = 'tarteaucitron_icon.' . $extension; |
||||
$dest = _DIR_IMG . $dest_name; |
||||
|
||||
include_spip('inc/documents'); |
||||
if ($chemin = deplacer_fichier_upload($file['tmp_name'],$dest)) { |
||||
if ($icone_actuelle != $dest) { |
||||
@unlink($icone_actuelle); |
||||
} |
||||
ecrire_config('tarteaucitron/icon', $dest); |
||||
} else { |
||||
$retours['message_ok'] = ''; |
||||
$retours['message_erreur'] = _T('texte_inc_meta_1', array('fichier' => $dest_name)) . ' ' . |
||||
_T('texte_inc_meta_2') . ' ' . |
||||
_T('texte_inc_meta_3', array('repertoire' => _DIR_IMG)); |
||||
} |
||||
} |
||||
|
||||
// Cette partie est vraiment nécessaire ? |
||||
include_spip('inc/invalideur'); |
||||
suivre_invalideur('1'); # tout effacer |
||||
|
||||
return $retours; |
||||
} |
||||
|
||||
function formulaires_configurer_tarteaucitron_ouverture_saisies_dist(){ |
||||
$saisies = array( |
||||
array( |
||||
'saisie' => 'selection', |
||||
'options' => array( |
||||
'nom' => 'ouverture', |
||||
'option_intro' => '<:tarteaucitron:cfg_aucun:>', |
||||
'label' => '<:tarteaucitron:cfg_ouverture_type:>', |
||||
'defaut' => '', |
||||
'data' => array( |
||||
'image' => '<:tarteaucitron:cfg_image:>', |
||||
'alertSmall' => '<:tarteaucitron:cfg_small_alert:>' |
||||
) |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'selection', |
||||
'options' => array( |
||||
'nom' => 'iconPosition', |
||||
'label' => '<:tarteaucitron:cfg_iconposition:>', |
||||
'cacher_option_intro' => 'oui', |
||||
'defaut' => 'BottomRight', |
||||
'data' => array( |
||||
'BottomRight' => '<:tarteaucitron:cfg_position_bd:>', |
||||
'BottomLeft' => '<:tarteaucitron:cfg_position_bg:>', |
||||
'TopRight' => '<:tarteaucitron:cfg_position_hd:>', |
||||
'TopLeft' => '<:tarteaucitron:cfg_position_hg:>' |
||||
), |
||||
'afficher_si' => '@ouverture@ == "image"' |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'tac_upload', |
||||
'options' => array( |
||||
'nom' => 'upload_icon', |
||||
'type' => 'file', |
||||
'attributs' => "accept=image/*", |
||||
'class' => 'bigup', |
||||
'label' => '<:tarteaucitron:cfg_icon:>', |
||||
'explication' => '<:tarteaucitron:cfg_icon_explication:>', |
||||
'afficher_si' => '@ouverture@ == "image"', |
||||
'src_img' => lire_config('tarteaucitron/icon') |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'checkbox', |
||||
'options' => array( |
||||
'nom' => 'cookieslist', |
||||
'label' => '<:tarteaucitron:cfg_cookieslist:>', |
||||
'explication' => '<:tarteaucitron:cfg_cookieslist_explication:>', |
||||
'data' => array( |
||||
'true' => '<:item_oui:>' |
||||
), |
||||
'afficher_si' => '@ouverture@ == "alertSmall"' |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'hidden', |
||||
'options' => array( |
||||
'nom' => '_meta_casier', |
||||
'defaut' => 'tarteaucitron' |
||||
) |
||||
) |
||||
); |
||||
|
||||
return $saisies; |
||||
} |
@ -0,0 +1,20 @@
|
||||
<div class="formulaire_spip formulaire_configurer formulaire_#FORM"> |
||||
|
||||
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>] |
||||
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>] |
||||
|
||||
<form method="post" action="#ENV{action}"> |
||||
<div> |
||||
#ACTION_FORMULAIRE{#ENV{action}} |
||||
|
||||
<fieldset> |
||||
<legend><:tarteaucitron:legend_cookies_management_panel:></legend> |
||||
<div class="editer-groupe"> |
||||
#GENERER_SAISIES{#ENV{_saisies}} |
||||
</div> |
||||
</fieldset> |
||||
|
||||
<p class="boutons"><span class="image_loading"> </span><input type="submit" class="submit" value="<:bouton_enregistrer:>" /></p> |
||||
</div> |
||||
</form> |
||||
</div> |
@ -0,0 +1,83 @@
|
||||
<?php |
||||
if (!defined('_ECRIRE_INC_VERSION')) return; |
||||
|
||||
|
||||
/** |
||||
* Un simple formulaire de config, |
||||
* on a juste à déclarer les saisies |
||||
**/ |
||||
function formulaires_configurer_tarteaucitron_panneau_saisies_dist(){ |
||||
// $saisies est un tableau décrivant les saisies à afficher dans le formulaire de configuration |
||||
$saisies = array( |
||||
array( |
||||
'saisie' => 'textarea', |
||||
'options' => array( |
||||
'nom' => 'lang_disclaimer', |
||||
'label' => '<:tarteaucitron:cfg_text_disclaimer:>', |
||||
'explication' => '<:tarteaucitron:cfg_text_disclaimer_explication:>', |
||||
'rows' => 3 |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'checkbox', |
||||
'options' => array( |
||||
'nom' => 'mandatory', |
||||
'label' => '<:tarteaucitron:cfg_mandatory:>', |
||||
'explication' => '<:tarteaucitron:cfg_mandatory_explication:>', |
||||
'data' => array( |
||||
'true' => '<:item_oui:>' |
||||
) |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'checkbox', |
||||
'options' => array( |
||||
'nom' => 'moreInfoLink', |
||||
'label' => '<:tarteaucitron:cfg_moreinfolink:>', |
||||
'data' => array( |
||||
'true' => '<:item_oui:>' |
||||
) |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'input', |
||||
'options' => array( |
||||
'nom' => 'readmoreLink', |
||||
'label' => '<:tarteaucitron:cfg_readmorelink:>', |
||||
'explication' => '<:tarteaucitron:cfg_readmorelink_explication:>', |
||||
'afficher_si' => '@moreInfoLink@ == "true"' |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'checkbox', |
||||
'options' => array( |
||||
'nom' => 'groupServices', |
||||
'label' => '<:tarteaucitron:cfg_group_services:>', |
||||
'explication' => '<:tarteaucitron:cfg_group_services_explication:>', |
||||
'data' => array( |
||||
'true' => '<:item_oui:>' |
||||
) |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'checkbox', |
||||
'options' => array( |
||||
'nom' => 'removeCredit', |
||||
'label' => '<:tarteaucitron:cfg_remove_credit:>', |
||||
'explication' => '<:tarteaucitron:cfg_remove_credit_explication:>', |
||||
'attention' => '<:tarteaucitron:cfg_remove_credit_attention:>', |
||||
'data' => array( |
||||
'true' => '<:item_oui:>' |
||||
) |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'hidden', |
||||
'options' => array( |
||||
'nom' => '_meta_casier', |
||||
'defaut' => 'tarteaucitron' |
||||
) |
||||
) |
||||
); |
||||
return $saisies; |
||||
} |
@ -1,33 +1,16 @@
|
||||
<div class="formulaire_spip formulaire_configurer formulaire_#FORM"> |
||||
|
||||
<h3 class="titrem"><:tarteaucitron:cfg_titre_ajouter_services:></h3> |
||||
|
||||
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>] |
||||
<div id="formulaire_#FORM"" class="formulaire_spip formulaire_configurer formulaire_#FORM"> |
||||
<div class="box__header"> |
||||
<h3><:tarteaucitron:cfg_titre_activation_services:></h3> |
||||
</div> |
||||
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>] |
||||
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>] |
||||
|
||||
<form method="post" action="#ENV{action}"> |
||||
<div> |
||||
#ACTION_FORMULAIRE{#ENV{action}} |
||||
|
||||
<fieldset> |
||||
<legend>Services Google</legend> |
||||
[(#REM) Gtag : voir à ce propos |
||||
https://developers.google.com/analytics/devguides/collection/gtagjs/ |
||||
et https://juliencoquet.com/en/2017/09/11/switch-google-analytics-global-site-tag/][ |
||||
(#SAISIE{input, gtag, label=Google global site tag (gtag.js), explication=Replace GA_MEASUREMENT_ID with the ID of the Google Analytics property to which you want to send data, placeholder=GA_MEASUREMENT_ID})] |
||||
|
||||
[(#SAISIE{input, gmap, label=Google Map API Key, explication=Enter your Google Map API Key, placeholder=API KEY})] |
||||
</fieldset> |
||||
|
||||
<fieldset> |
||||
<legend>Services Facebook</legend> |
||||
[(#SAISIE{checkbox, fb, label=Boutons de Like et Partage Facebook, datas=[(#ARRAY{fb,fb})]})] |
||||
|
||||
[(#SAISIE{input, fb_pixel, label=Facebook Pixel, explication=Enter your FacebookPixel ID, placeholder=YOUR_ID})] |
||||
</fieldset> |
||||
|
||||
<input type="hidden" name="_meta_casier" value="tarteaucitron/services" /> |
||||
<p class="boutons"><span class="image_loading"> </span><input type="submit" class="submit" value="<:bouton_enregistrer:>" /></p> |
||||
</div> |
||||
</form> |
||||
<div> |
||||
#ACTION_FORMULAIRE{#ENV{action}} |
||||
<div class="editer-groupe"> |
||||
#GENERER_SAISIES{#ENV{_saisies}} |
||||
</div> |
||||
<p class="boutons"><span class="image_loading"> </span><input type="submit" class="submit" value="<:bouton_enregistrer:>" /></p> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
|
@ -0,0 +1,124 @@
|
||||
<?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; |
||||
} |
@ -0,0 +1,29 @@
|
||||
<div class="formulaire_spip formulaire_configurer formulaire_#FORM"> |
||||
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>] |
||||
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>] |
||||
|
||||
<form method="post" action="#ENV{action}"> |
||||
<div> |
||||
#ACTION_FORMULAIRE{#ENV{action}} |
||||
<fieldset> |
||||
<legend><:tarteaucitron:cfg_avance:></legend> |
||||
|
||||
<div class="editer-groupe"> |
||||
[(#SAISIE{input, cookieName, label=<:tarteaucitron:cfg_cookiename:>, placeholder=tarteaucitron})] |
||||
[(#SAISIE{checkbox, adblocker, label=<:tarteaucitron:cfg_adblocker:>, data=[(#ARRAY{true,<:item_oui:>})]})] |
||||
[(#SAISIE{checkbox, useExternalCss, label=<:tarteaucitron:cfg_externalcss:>, explication=<:tarteaucitron:cfg_externalcss_explication:>, data=[(#ARRAY{true,<:item_oui:>})]})] |
||||
[(#SAISIE{input, cookieDomain, label=<:tarteaucitron:cfg_cookiedomain:>, explication=<:tarteaucitron:cfg_cookiedomain_explication:>, placeholder=.my-multisite-domaine.fr})] |
||||
</div> |
||||
</fieldset> |
||||
|
||||
<input type="hidden" name="_meta_casier" value="tarteaucitron" /> |
||||
<p class="boutons"><span class="image_loading"> </span><input type="submit" class="submit" value="<:bouton_enregistrer:>" /></p> |
||||