2021-02-06 22:22:13 +01:00
|
|
|
<?php
|
|
|
|
if (!defined('_ECRIRE_INC_VERSION')) {
|
2021-05-11 22:18:36 +02:00
|
|
|
return;
|
2021-02-06 22:22:13 +01:00
|
|
|
}
|
|
|
|
|
2021-05-11 22:18:36 +02:00
|
|
|
function filtre_escape_json($texte) {
|
|
|
|
return str_replace("\"", "\\\"", str_replace("\n", "\\n", str_replace("\n\n", "\n<br><br>\n", $texte)));
|
|
|
|
}
|
|
|
|
|
|
|
|
function filtre_decode_html($texte) {
|
|
|
|
return html_entity_decode($texte);
|
|
|
|
}
|
|
|
|
|
2021-05-28 10:25:45 +02:00
|
|
|
function filtre_libreavous_supp_numero($texte) {
|
2021-05-11 22:18:36 +02:00
|
|
|
$idx = strpos($texte, "-");
|
|
|
|
return trim(substr($texte, $idx +1));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-21 10:00:24 +02:00
|
|
|
// plutot utiliser la fonction spip taille_en_octets
|
|
|
|
function libreavous_mio($number) {
|
|
|
|
$mio = round($number / (1024 * 1024), 1);
|
|
|
|
if ($mio < 10) {
|
|
|
|
$mio = round($mio, 2);
|
|
|
|
return number_format($mio, 2, ',', ' ');
|
|
|
|
} else if ($mio < 100) {
|
|
|
|
$mio = round($mio, 1);
|
|
|
|
return number_format($mio, 1, ',', ' ');
|
|
|
|
} else {
|
|
|
|
$mio = round($mio, 0);
|
|
|
|
return number_format($mio, 0, ',', ' ');
|
|
|
|
}
|
|
|
|
return $mio;
|
|
|
|
}
|
|
|
|
|
2021-09-02 20:04:44 +02:00
|
|
|
function titre_chronique_court($titre) {
|
2021-09-15 16:16:10 +02:00
|
|
|
// annuler le filtre
|
|
|
|
return $titre;
|
2021-09-02 20:04:44 +02:00
|
|
|
}
|
|
|
|
|
2021-09-24 00:40:12 +02:00
|
|
|
// calculer la durée d'un chapitre
|
|
|
|
// $start et $end sous form hh:mm:ss
|
2021-10-05 18:19:43 +02:00
|
|
|
function libreavous_duree($start,$end) {
|
2021-09-24 00:40:12 +02:00
|
|
|
|
|
|
|
$timestart = new DateTime($start);
|
|
|
|
$timeend = new DateTime($end);
|
|
|
|
$timeduree = $timestart->diff($timeend);
|
|
|
|
$duree = $timeduree->format('%h h %i min. %s s.');
|
|
|
|
|
|
|
|
return $duree;
|
|
|
|
|
|
|
|
}
|
|
|
|
// retirer l'heure si 0 h dans la duree
|
2021-10-05 18:19:43 +02:00
|
|
|
function libreavous_sanszeroh($chaine) {
|
2021-09-24 00:40:12 +02:00
|
|
|
$chaine = str_replace('0 h ','',$chaine);
|
|
|
|
return $chaine;
|
|
|
|
}
|
2021-10-05 18:19:43 +02:00
|
|
|
// ajoute un 0 si un seul chiffre (date du jour < à 10)
|
|
|
|
function libreavous_aveczerod($chaine) {
|
2021-10-12 17:06:22 +02:00
|
|
|
$chaineaveczero = $chaine;
|
2021-10-05 18:19:43 +02:00
|
|
|
if (strlen($chaine) == '1') {
|
|
|
|
$chaineaveczero = '0'.$chaine;
|
|
|
|
}
|
|
|
|
return $chaineaveczero;
|
|
|
|
}
|