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.
74 lines
1.9 KiB
74 lines
1.9 KiB
<?php |
|
/** |
|
* Utilisations de pipelines par Tarteaucitron |
|
* |
|
* @plugin Tarteaucitron |
|
* @copyright 2019 |
|
* @author Peetdu |
|
* @licence GNU/GPL |
|
* @package SPIP\Tarteaucitron\Pipelines |
|
*/ |
|
|
|
if (!defined('_ECRIRE_INC_VERSION')) { |
|
return; |
|
} |
|
|
|
/** |
|
* Inserer tarteaucitron.js + le javascript contenant les paramètres venant de la config du plugin |
|
* |
|
* @pipeline insert_head |
|
* @pipeline recuperer_fond |
|
* |
|
* @param string $flux |
|
* Le contenu de la balise #INSERT_HEAD |
|
* @return mixed |
|
*/ |
|
function tarteaucitron_insert_head($flux) { |
|
include_spip('inc/tarteaucitron'); |
|
|
|
$tarteaucitron = find_in_path('lib/tarteaucitron/tarteaucitron.js'); |
|
$tarteaucitron_config = recuperer_fond('javascript/tarteaucitron_config'); |
|
|
|
// Note importante : ici on ajoute un id à la déclaration du script pour que celui-ci ne soit pas compressé par le Compresseur de SPIP si ce dernier est activé. |
|
if (tarteaucitron_actif()) { |
|
$flux .= "<script type='text/javascript' src='$tarteaucitron' id='tauc'></script>\n" |
|
."$tarteaucitron_config\n"; |
|
} |
|
|
|
return $flux; |
|
} |
|
|
|
|
|
/** |
|
* Inserer les JS correspondants aux services activés dans la configuration du plugin |
|
* |
|
* @pipeline recuperer_fond |
|
* |
|
* @param string $flux |
|
* @return mixed |
|
*/ |
|
function tarteaucitron_recuperer_fond($flux) { |
|
|
|
if (test_plugin_actif('zcore') and $flux['args']['fond'] == 'structure') { |
|
|
|
$ajouter_services = null; |
|
|
|
// rechercher les skel du type /services/truc.html |
|
$match = '.+[.]html$'; |
|
$services = find_all_in_path('services/', $match); |
|
if (count($services)) { |
|
foreach ($services as $squelette => $chemin) { |
|
$type = preg_replace(',[.]html$,i', '', $squelette); |
|
if (lire_config('tarteaucitron/services/'.$type)) { |
|
$ajouter_services .= recuperer_fond('services/'.$type); |
|
} |
|
} |
|
} |
|
|
|
if ($ajouter_services) { |
|
$flux['data']['texte'] = str_replace('</body>', $ajouter_services. '</body>', $flux['data']['texte']); |
|
} |
|
} |
|
|
|
return $flux; |
|
}
|
|
|