diff --git a/ecrire/inc/texte.php b/ecrire/inc/texte.php index 13e5489e2c3c2273c42dec033445aa6ca51ea1d2..b047c11863dc1230024e832c42e1ce1341d81af9 100644 --- a/ecrire/inc/texte.php +++ b/ecrire/inc/texte.php @@ -313,13 +313,13 @@ function echappe_retour_modeles($letexte) } // http://doc.spip.org/@nettoyer_raccourcis_typo -function nettoyer_raccourcis_typo($texte){ +function nettoyer_raccourcis_typo($texte, $connect=''){ $texte = pipeline('nettoyer_raccourcis_typo',$texte); // remplacer les liens if (preg_match_all(',[[]([^][]*)->(>?)([^][]*)[]],S', $texte, $regs, PREG_SET_ORDER)) foreach ($regs as $reg) { list ($titre,,)= traiter_raccourci_lien_atts($reg[1]); - $titre = calculer_url($reg[3], $titre, 'titre'); + $titre = calculer_url($reg[3], $titre, 'titre', $connect); $titre = corriger_typo(supprimer_tags($titre)); $texte = str_replace($reg[0], $titre, $texte); } @@ -405,30 +405,6 @@ function couper($texte, $taille=50, $suite = ' (...)') { return quote_amp(trim($texte)).$points; } -// prendre <intro>...</intro> sinon couper a la longueur demandee -// http://doc.spip.org/@couper_intro -function couper_intro($texte, $long, $suite = ' (...)') { - $texte = extraire_multi(preg_replace(",(</?)intro>,i", "\\1intro>", $texte)); // minuscules - $intro = ''; - while ($fin = strpos($texte, "</intro>")) { - $zone = substr($texte, 0, $fin); - $texte = substr($texte, $fin + strlen("</intro>")); - if ($deb = strpos($zone, "<intro>") OR substr($zone, 0, 7) == "<intro>") - $zone = substr($zone, $deb + 7); - $intro .= $zone; - } - - if ($intro) - $intro .= $suite; - else { - $intro = preg_replace(',([|]\s*)+,S', '; ', couper($texte, $long, $suite)); - } - - // supprimer un eventuel chapo redirecteur =http:/..... - return $intro; -} - - // // Les elements de propre() // @@ -634,7 +610,7 @@ function typer_raccourci ($lien) { // http://doc.spip.org/@calculer_url function calculer_url ($lien, $texte='', $pour='url', $connect='') { - + include_spip('base/abstract_sql'); if ($match = typer_raccourci($lien)) { @list($f,,$id,,$param,,$ancre) = $match; $res = ''; @@ -1312,6 +1288,8 @@ function chapo_redirige($chapo, $url=false) return !$url ? $m[3] : calculer_url($m[3]); } +function chapo_redirigetil($chapo) { return $chapo[0] == '=';} + // http://doc.spip.org/@traiter_poesie function traiter_poesie($letexte) { diff --git a/ecrire/public/balises.php b/ecrire/public/balises.php index 40be94afd9d330e67a281289c00b869fa65f9be9..a5518fb4587f8e92c26c5fcdb74ced971cca626d 100644 --- a/ecrire/public/balises.php +++ b/ecrire/public/balises.php @@ -392,15 +392,17 @@ function balise_SPIP_CRON_dist ($p) { function balise_INTRODUCTION_dist ($p) { $type = $p->type_requete; $_texte = champ_sql('texte', $p); - if ($type == 'articles') { - $_chapo = champ_sql('chapo', $p); - $_descriptif = champ_sql('descriptif', $p); + if ($type != 'articles') { + $code = $_texte; } else { - $_chapo = "''"; - $_descriptif = "''"; + $_chapo = champ_sql('chapo', $p); + $_descriptif = champ_sql('descriptif', $p); + $code = "($_descriptif ? $_descriptif\n\t" . + ": (chapo_redirigetil($_chapo) ? ''\n\t\t" . + ": ($_chapo . \"\n\n\n\" . $_texte)))"; } $f = chercher_filtre('introduction'); - $p->code = $f."('$type', $_texte, $_chapo, $_descriptif)"; + $p->code = "$f($code, '$type', \$connect)"; #$p->interdire_scripts = true; return $p; diff --git a/ecrire/public/composer.php b/ecrire/public/composer.php index b6dac6faf455014b072af6ac558801b805087704..7b47e77441431760e12648838908fbe0f8cceda9 100644 --- a/ecrire/public/composer.php +++ b/ecrire/public/composer.php @@ -180,38 +180,32 @@ function calcule_logo($type, $onoff, $id, $id_rubrique, $flag_fichier) { // // fonction standard de calcul de la balise #INTRODUCTION // on peut la surcharger en definissant dans mes_fonctions : -// function introduction($type,$texte,$chapo,$descriptif) {...} +// function introduction ... // +@define('_INTRODUCTION_SUITE', ' (...)'); + // http://doc.spip.org/@filtre_introduction_dist -function filtre_introduction_dist($type, $texte, $chapo='', $descriptif='') { - define('_INTRODUCTION_SUITE', ' (...)'); - - switch ($type) { - case 'articles': - # si descriptif contient juste des espaces ca produit une intro vide, - # c'est une fonctionnalite, pas un bug - if (strlen($descriptif)) - return propre($descriptif); - else if (substr($chapo, 0, 1) == '=') // article virtuel - return ''; - else - return PtoBR(propre(supprimer_tags(couper_intro($chapo."\n\n\n".$texte, 500, _INTRODUCTION_SUITE)))); - break; - case 'breves': - return PtoBR(propre(supprimer_tags(couper_intro($texte, 300, _INTRODUCTION_SUITE)))); - break; - case 'forums': - return PtoBR(propre(supprimer_tags(couper_intro($texte, 600, _INTRODUCTION_SUITE)))); - break; - case 'rubriques': - if (strlen($descriptif)) - return propre($descriptif); - else - return PtoBR(propre(supprimer_tags(couper_intro($texte, 600, _INTRODUCTION_SUITE)))); - break; +function filtre_introduction_dist($texte, $type, $connect) { + +// prendre <intro>...</intro> sinon couper a la longueur demandee + + $texte = extraire_multi(preg_replace(",(</?)intro>,i", "\\1intro>", $texte)); // minuscules + $intro = ''; + while ($fin = strpos($texte, "</intro>")) { + $zone = substr($texte, 0, $fin); + $texte = substr($texte, $fin + strlen("</intro>")); + if ($deb = strpos($zone, "<intro>") OR substr($zone, 0, 7) == "<intro>") + $zone = substr($zone, $deb + 7); + $intro .= $zone; } -} + $texte = nettoyer_raccourcis_typo($intro ? $intro : $texte); + $long = $type=='articles' ? 600 : 300; + // il faudrait optimiser un peu le traitement des raccourcis + // (car traiter_raccourcis ne fait pas que ce qu'elle dit) + return PtoBR(traiter_raccourcis(preg_replace(',([|]\s*)+,S', '; ', + couper($texte, $long, _INTRODUCTION_SUITE)))); +} // // Balises dynamiques