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.
89 lines
2.3 KiB
89 lines
2.3 KiB
<?php |
|
if (!defined('_ECRIRE_INC_VERSION')) { |
|
return; |
|
} |
|
|
|
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); |
|
} |
|
|
|
function filtre_libreavous_supp_numero($texte) { |
|
$idx = strpos($texte, "-"); |
|
return trim(substr($texte, $idx +1)); |
|
} |
|
|
|
|
|
// 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; |
|
} |
|
|
|
function titre_chronique_court($titre) { |
|
// annuler le filtre |
|
return $titre; |
|
} |
|
|
|
// calculer la durée d'un chapitre |
|
// $start et $end sous form hh:mm:ss |
|
function libreavous_duree($start,$end) { |
|
|
|
$timestart = new DateTime($start); |
|
$timeend = new DateTime($end); |
|
$timeduree = $timestart->diff($timeend); |
|
$duree = $timeduree->format('%h h %i min. %s s.'); |
|
|
|
return $duree; |
|
|
|
} |
|
// calculer la durée d'un chapitre |
|
// $start et $end sous form hh:mm:ss |
|
// renvoi dans un format hh:mm:ss (pour le champ itunes:duration |
|
function libreavous_duree_podcast($start,$end) { |
|
|
|
$timestart = new DateTime($start); |
|
$timeend = new DateTime($end); |
|
$timeduree = $timestart->diff($timeend); |
|
$duree = $timeduree->format('%H:%I:%S'); |
|
|
|
return $duree; |
|
|
|
} |
|
// retirer les microseconds d'une durée |
|
function libreavous_remove_microseconds ($duration) { |
|
|
|
$durationobject = new DateTime($duration); |
|
$newduration = $durationobject->format('H:i:s'); |
|
|
|
return $newduration; |
|
} |
|
// retirer l'heure si 0 h dans la duree |
|
function libreavous_sanszeroh($chaine) { |
|
$chaine = str_replace('0 h ','',$chaine); |
|
return $chaine; |
|
} |
|
// ajoute un 0 si un seul chiffre (date du jour < à 10) |
|
function libreavous_aveczerod($chaine) { |
|
$chaineaveczero = $chaine; |
|
if (strlen($chaine) == '1') { |
|
$chaineaveczero = '0'.$chaine; |
|
} |
|
if ($chaine == '1er') { |
|
$chaineaveczero = '01'; |
|
} |
|
return $chaineaveczero; |
|
}
|
|
|