<?php
/**
 * Utilisations de pipelines par Feuillet
 *
 * @plugin     Feuillet
 * @copyright  2010-2024
 * @author     Renaud LAURETTE
 * @licence    GNU/GPL
 * @package    SPIP\Feuillet\Pipelines
 */


if (!defined('_ECRIRE_INC_VERSION')) {
	return;
}


function feuillet_insert_head($flux)
{
	// Insertion des styles requis par la carte.
	$flux .="\n<!-- feuillet start -->";
	$flux .="\n".'<script type="text/javascript" src="'. url_absolue(find_in_path('lib/leaflet/leaflet.js')) .'"></script>';
	$flux .="\n".'<script type="text/javascript" src="'. url_absolue(find_in_path('lib/leaflet.draw/leaflet.draw.js')) .'"></script>';
	$flux .="\n".'<script type="text/javascript" src="'. url_absolue(find_in_path('lib/leaflet-omnivore/leaflet-omnivore.js')) .'"></script>';
	$flux .="\n".'<script type="text/javascript" src="'. url_absolue(find_in_path('lib/leaflet-fullscreen/Control.FullScreen.js')) .'"></script>';
	$flux .="\n".'<script type="text/javascript" src="'. url_absolue(find_in_path('lib/feuillet/feuillet.js')) .'"></script>';
//  $flux .="\n".'<script src="'. url_absolue(find_in_path('lib/feuillet/feuillet-styles.js')) .'"></script>';
	$flux .="\n".'<link rel="stylesheet" href="'. url_absolue(find_in_path('lib/leaflet/leaflet.css')) .'" type="text/css" media="projection, screen, tv" />';
	$flux .="\n".'<link rel="stylesheet" href="'. url_absolue(find_in_path('lib/leaflet-fullscreen/Control.FullScreen.css')) .'" type="text/css" media="projection, screen, tv" />';
	$flux .="\n".'<link rel="stylesheet" href="'. url_absolue(find_in_path('lib/leaflet.draw/leaflet.draw.css')) .'" type="text/css" media="projection, screen, tv" />';
	$flux .="\n<!-- feuillet end -->";
	$flux .="\n";
	return $flux;
}    

function feuillet_header_prive($flux) {
	foreach(['leaflet/leaflet.js','leaflet.draw/leaflet.draw.js',
			'leaflet-omnivore/leaflet-omnivore.js','leaflet-fullscreen/Control.FullScreen.js',
			'feuillet/feuillet.js'] as $script) {
				$js = timestamp(find_in_path('lib/'.$script));
				$flux .= "\n<script type='text/javascript' src='$js'></script>\n";
			}
	foreach(['leaflet/leaflet.css','leaflet.draw/leaflet.draw.css',
			'leaflet-fullscreen/Control.FullScreen.css'] as $script) {
				$css = timestamp(find_in_path('lib/'.$script));
				$flux .= "\n<link rel='stylesheet' type='text/css' href='$css'/>\n";
			}
	return $flux;
}

?>
