Browse Source

Gestion des services spécifiques (facebook video)

pull/19/head
Chancellier Pierre-Jean 9 months ago
parent
commit
518ff133c5
  1. 4
      action/tarteaucitron_desactiver_service.php
  2. 18
      action/tarteaucitron_referencer_services.php
  3. 0
      icones_barre/facebook_video.png
  4. 2
      json/services.json
  5. 0
      modeles/tac_facebook_like.html
  6. 5
      modeles/tac_facebook_video.html
  7. 62
      tarteaucitron_pipelines.php

4
action/tarteaucitron_desactiver_service.php

@ -37,9 +37,7 @@ function action_tarteaucitron_desactiver_service_dist(){
include_spip('inc/config');
$services_actifs = lire_config("tarteaucitron/services");
if ($services_actifs[$service]) {
unset($services_actifs[$service]);
}
unset($services_actifs[$service]);
ecrire_config("tarteaucitron/services", $services_actifs);
}

18
action/tarteaucitron_referencer_services.php

@ -21,6 +21,8 @@ function action_tarteaucitron_referencer_services_dist(){
}
$list_services = array();
$services_specifiques = array();
if ($lines=file(find_in_path('lib/tarteaucitron/tarteaucitron.services.js'))){
$i=0;
foreach($lines as $line) {
@ -58,7 +60,16 @@ function action_tarteaucitron_referencer_services_dist(){
$is_modele_found = false;
$is_service_hidden = in_array($list_services[$service]['type'],array('support','analytic'));
if (!$is_service_hidden) {
$list_services[$service]['params_modele'] = array();
// Gestion des services spécifiques
switch ($service) {
case 'facebook':
$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
@ -101,7 +112,6 @@ function action_tarteaucitron_referencer_services_dist(){
$param = $param_list[$j];
$nom_param = str_replace(" ","_",$param->textContent);
if ($is_service_hidden) {
$nom_param = "ptac_" . $nom_param;
@ -130,11 +140,11 @@ function action_tarteaucitron_referencer_services_dist(){
if ($is_service_hidden) {
$script = strip_tags($script);
$list_services[$service]['JS'] = $script . "\n" . $list_services[$service]['JS'];
} else {
} elseif (!in_array($service,$services_specifiques)) {
$fichier_modele = _DIR_PLUGIN_TARTEAUCITRON . "modeles/tac_" . $service . ".html";
file_put_contents($fichier_modele, $script);
}
}
}
}
}

0
icones_barre/facebook.png → icones_barre/facebook_video.png

Before

Width:  |  Height:  |  Size: 615 B

After

Width:  |  Height:  |  Size: 615 B

2
json/services.json

File diff suppressed because one or more lines are too long

0
modeles/tac_facebook.html → modeles/tac_facebook_like.html

5
modeles/tac_facebook_video.html

@ -0,0 +1,5 @@
[<div class="fb-video"
data-href="https://www.facebook.com/watch/?v=(#ENV{video_id})"
data-allowfullscreen="true"
data-width="[(#ENV{width,500})]">
</div>]

62
tarteaucitron_pipelines.php

@ -86,24 +86,45 @@ function tarteaucitron_porte_plume_barre_pre_charger($barres){
$json_source = find_in_path('json/services.json');
$json = file_get_contents($json_source);
$parsed_json = json_decode($json);
$liste_modeles = scandir(_DIR_PLUGIN_TARTEAUCITRON . "modeles");
foreach ($services_actifs as $service => $params) {
if (($modele=find_in_path('modeles/tac_' . $service . '.html')) && (find_in_path('icones_barre/' . $service . '.png'))) {
$params_modele = (!empty($parsed_json->{$service}->{'params_modele'})) ? $parsed_json->{$service}->{'params_modele'} : array();
$params_modele = (!empty($parsed_json->{$service}->{'params_modele'})) ? $parsed_json->{$service}->{'params_modele'} : array();
foreach($liste_modeles as $nom_fichier) {
$create_item = false;
$close = '';
foreach($params_modele as $param_modele) {
$close .= '|' . $param_modele . '=[![' . $param_modele . ' :]!]';
if (($nom_fichier == 'tac_' . $service . '.html') && (find_in_path('icones_barre/' . $service . '.png'))) {
$nom_modele = $service;
$create_item = true;
foreach($params_modele as $param_modele) {
$close .= '|' . $param_modele . '=[![' . $param_modele . ' :]!]';
}
} elseif (strpos($nom_fichier,'tac_' . $service . '_') !== false) {
$nom_modele = substr($nom_fichier,0, strpos($nom_fichier,'.html'));
$nom_modele = substr($nom_modele,4, strlen($nom_modele)-4);
if (find_in_path('icones_barre/' . $nom_modele . '.png')) {
$create_item = true;
foreach($params_modele->{$nom_modele} as $param_modele) {
$close .= '|' . $param_modele . '=[![' . $param_modele . ' :]!]';
}
}
}
$menu_items[] = array(
"id" => $service,
"name" => $service,
"className" => 'tac_' . $service,
"openWith" => "<tac_" . $service,
'closeWith' => $close . '>',
"display" => true
);
if ($create_item) {
$menu_items[] = array(
"id" => $nom_modele,
"name" => $nom_modele,
"className" => 'tac_' . $nom_modele,
"openWith" => "<tac_" . $nom_modele,
'closeWith' => $close . '>',
"display" => true
);
}
}
}
@ -135,9 +156,22 @@ function tarteaucitron_porte_plume_barre_pre_charger($barres){
function tarteaucitron_porte_plume_lien_classe_vers_icone($flux){
$icons = array('tac_drop' => 'tac.png');
$services_actifs = lire_config('tarteaucitron/services', array());
$liste_modeles = scandir(_DIR_PLUGIN_TARTEAUCITRON . "modeles");
foreach ($services_actifs as $service => $value) {
if (($modele=find_in_path('modeles/tac_' . $service . '.html')) && (find_in_path('icones_barre/' . $service . '.png'))) {
$icons['tac_' . $service] = $service . '.png';
foreach($liste_modeles as $nom_fichier) {
$nom_modele = "";
if ($nom_fichier == 'tac_' . $service . '.html') {
$nom_modele = $service;
} elseif (strpos($nom_fichier,'tac_' . $service . '_') !== false) {
$nom_modele = substr($nom_fichier,0, strpos($nom_fichier,'.html'));
$nom_modele = substr($nom_modele,4, strlen($nom_modele)-4);
}
if (($nom_modele != "") && (find_in_path('icones_barre/' . $nom_modele . '.png'))) {
$icons['tac_' . $nom_modele] = $nom_modele . '.png';
}
}
}

Loading…
Cancel
Save