All pastes #200798 Raw Edit

Anonyme

public text v1 · immutable
#200798 ·published 2006-10-13 11:48 UTC
rendered paste body
dans le squelette:
      <div class="contenu"><div>[(#DESCRIPTIF|sinon{[(#CHAPO*|sinon{#TEXTE*}|resumer{200})]})]</div><div class="suite"><a href="#URL_ARTICLE" class="spip_in" title="#TITRE">Lire la suite</a></div></div>


dans mes_fonctions:
function resumer($texte,$limite,$suite="<span> (...)</span>") {

if (strlen($texte) <= $limite) return $texte;

$pos = strpos(substr($texte, $limite), " ");
 if (is_integer($pos)){
   $limite += $pos;
   $pos = strpos(substr($texte, $limite), "\n");
 }
// s'il y a un espace après $limite caractères ou juste après $limite  caractères
// on retourne la partie de $texte jusqu'avant cet espace
if (is_integer($pos) && $pos)
  return traiter_raccourcis(substr($texte, 0, $limite+ $pos)).$suite;
// sinon (pas d'espace après $limite caractères ou juste après  $limite caractères) on retourne le texte
 else return traiter_raccourcis($texte);
}