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.
 
 
 

108 lines
3.3 KiB

<?php
/**
* Utilisations de pipelines par Select2
*
* @plugin Select2
* @copyright 2019
* @author Matthieu Marcillaud
* @licence GNU/GPL
* @package SPIP\Select2\Pipelines
*/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
/**
* Ajoute Select2 aux plugins JS chargés
*
* @param array $flux
* Liste des js chargés
* @return array
* Liste complétée des js chargés
**/
function select2_jquery_plugins($flux) {
$active = test_espace_prive();
if (!$active) {
include_spip('inc/config');
$config = lire_config('select2/active', 'non');
$active = ($config === 'oui');
}
if ($active) {
$flux[] = 'javascript/select2.fork.full.js'; # lib (presque) originale
$lang = $GLOBALS['spip_lang'];
if (!find_in_path("lib/select2/js/i18n/$lang.js")) {
$lang = 'en';
}
$flux[] = "lib/select2/js/i18n/$lang.js";
$flux[] = 'javascript/spip_select2.js'; # chargements SPIP automatiques
}
return $flux;
}
/**
* Ajoute Select2 aux css chargées dans le privé
*
* @param string $flux Contenu du head HTML concernant les CSS
* @return string Contenu du head HTML concernant les CSS
*/
function select2_header_prive($flux) {
include_spip('inc/config');
$flux .= '<script type="text/javascript">/* <![CDATA[ */
var select2 = select2 || {};
select2.selector = "' . trim(lire_config('select2/selecteur_commun')) . '";
/* ]]> */</script>'."\n";
return $flux;
}
/**
* Ajoute Select2 aux css chargées dans le privé
*
* @param string $flux Contenu du head HTML concernant les CSS
* @return string Contenu du head HTML concernant les CSS
*/
function select2_header_prive_css($flux) {
$css = sinon(find_in_path('css/select2.css'), find_in_path('lib/select2/css/select2.css'));
$flux .= "<link rel='stylesheet' type='text/css' media='all' href='".direction_css($css)."' />\n";
$css = find_in_path('css/spip.select2.css');
$flux .= "<link rel='stylesheet' type='text/css' media='all' href='".direction_css($css)."' />\n";
return $flux;
}
/**
* Ajoute Select2 aux css chargées dans le public
*
* @return string Contenu du head HTML concernant les CSS
**/
function select2_insert_head_css($flux) {
include_spip('inc/config');
$config = lire_config('select2', array());
if (isset($config['active']) and $config['active']=='oui') {
$css = sinon(find_in_path('css/select2_public.css'), sinon(find_in_path('css/select2.css'), find_in_path('lib/select2/css/select2.css')));
$flux .= '<link rel="stylesheet" href="'.direction_css($css).'" type="text/css" media="all" />';
$css = find_in_path('css/spip.select2.css');
$flux .= '<link rel="stylesheet" href="'.direction_css($css).'" type="text/css" media="all" />';
}
return $flux;
}
/**
* Ajoute Select2 aux css chargées dans le public
*
* @param string $flux Contenu du head HTML concernant les CSS
* @return string Contenu du head HTML concernant les CSS
**/
function select2_insert_head($flux) {
include_spip('inc/config');
$config = lire_config('select2', array());
if (isset($config['active']) and $config['active']=='oui') {
$flux .= '<script type="text/javascript">/* <![CDATA[ */
var select2 = select2 || {};
select2.selector = "' . trim(isset($config['selecteur_commun']) ? $config['selecteur_commun'] : '') . '";
/* ]]> */</script>'."\n";
}
return $flux;
}