Ce filtre s’applique à la version 1.7.2
Ce script est une variante du filtre de Aurelien Pierrard avec en plus l’ajout de la taille de la police. et introduit deux nouveaux raccourcis typographique à SPIP.
Mise en Place du script
Pour le webmaster : Il suffit d’ajouter |couleur|taille aux tags spip situé dans les squelettes (fichiers .html).
Repérez la ligne :
[<div class="texte">(#TEXTE|target)</div>]
<code>
{{et remplacez par celle ci}}
<code>
[<div class="texte">(#TEXTE|target|taille|couleur)</div>]
Utilisation
Pour le rédacteur : Il suffit d’encadrer le texte à mettre en couleur
- exemple pour la couleur : [blue]bonjour[/blue]
- exemple pour la taille (valeur possible entre 12 et 40) : [16]bonjour[/16]
<?php
/*
* +----------------------------------+
* Nom du Filtre : Couleur Texte et Taille Texte
* Version Spip 1.7.2
* +----------------------------------+
* Date : Dimanche 2 Avril 2006
* Auteur : Xavier Devors : http://www.asm11.fr
* +-------------------------------------+
* Fonctions de ce filtre :
* Permet de modifier la couleur du texte
* Utilisation pour le rédacteur : [blue]test[/blue]
* Utilisation pour le webmaster : [(#TEXTE|couleur)]
*
Permet de modifier la taille du texte
* Utilisation pour le rédacteur : [taille]bonjour[/taille] ex: [30]bonjour[30]
* Utilisation pour le webmaster : [(#TEXTE|taille)]
+-------------------------------------+
*
*/
function couleur($texte) {
$texte = preg_replace("/(\[aliceblue\])(.*?)(\[\/aliceblue\])/", "<span style=\"color:#9fcf00;\">\\2</span>", $texte);
$texte = preg_replace("/(\[antiquewhite\])(.*?)(\[\/antiquewhite\])/", "<span style=\"color:#faebd7;\">\\2</span>", $texte);
$texte = preg_replace("/(\[aqua\])(.*?)(\[\/aqua\])/", "<span style=\"color:#00ffff;\">\\2</span>", $texte);
$texte = preg_replace("/(\[aquamarine\])(.*?)(\[\/aquamarine\])/", "<span style=\"color:#7fffd4;\">\\2</span>", $texte);
$texte = preg_replace("/(\[azure\])(.*?)(\[\/azure\])/", "<span style=\"color:#f0ffff;\">\\2</span>", $texte);
$texte = preg_replace("/(\[beige\])(.*?)(\[\/beige\])/", "<span style=\"color:#f5f5dc;\">\\2</span>", $texte);
$texte = preg_replace("/(\[bisque\])(.*?)(\[\/bisque\])/", "<span style=\"color:#ffe4c4;\">\\2</span>", $texte);
$texte = preg_replace("/(\[black\])(.*?)(\[\/black\])/", "<span style=\"color:#000000;\">\\2</span>", $texte);
$texte = preg_replace("/(\[blanchedalmond\])(.*?)(\[\/blachedalmond\])/", "<span style=\"color:#ffebcd;\">\\2</span>", $texte);
$texte = preg_replace("/(\[blue\])(.*?)(\[\/blue\])/", "<span style=\"color:#0000ff;\">\\2</span>",$texte);
$texte = preg_replace("/(\[blueviolet\])(.*?)(\[\/blueviolet\])/", "<span style=\"color:#8a2be2;\">\\2</span>",$texte);
$texte = preg_replace("/(\[brown\])(.*?)(\[\/brown\])/", "<span style=\"color:#a52a2a;\">\\2</span>",$texte);
$texte = preg_replace("/(\[burlywood\])(.*?)(\[\/burlywood\])/", "<span style=\"color:#deb887;\">\\2</span>",$texte);
$texte = preg_replace("/(\[cadetblue\])(.*?)(\[\/cadetblue\])/", "<span style=\"color:#5f9ea0;\">\\2</span>",$texte);
$texte = preg_replace("/(\[chartreuse\])(.*?)(\[\/chartreuse\])/", "<span style=\"color:#7ffff00;\">\\2</span>",$texte);
$texte = preg_replace("/(\[chocolate\])(.*?)(\[\/chocolate\])/", "<span style=\"color:#d2691e;\">\\2</span>",$texte);
$texte = preg_replace("/(\[coral\])(.*?)(\[\/coral\])/", "<span style=\"color:#ff7f50;\">\\2</span>",$texte);
$texte = preg_replace("/(\[cornflowerblue\])(.*?)(\[\/cornflowerblue\])/", "<span style=\"color:#6495ed;\">\\2</span>",$texte);
$texte = preg_replace("/(\[cornsilk\])(.*?)(\[\/cornsilk\])/", "<span style=\"color:#fff8dc;\">\\2</span>",$texte);
$texte = preg_replace("/(\[crimson\])(.*?)(\[\/crimson\])/", "<span style=\"color:#dc143c;\">\\2</span>",$texte);
$texte = preg_replace("/(\[cyan\])(.*?)(\[\/cyan\])/", "<span style=\"color:#00ffff;\">\\2</span>",$texte);
$texte = preg_replace("/(\[darkblue\])(.*?)(\[\/darkblue\])/", "<span style=\"color:#00008b;\">\\2</span>",$texte);
$texte = preg_replace("/(\[darkcyan\])(.*?)(\[\/darkcyan\])/", "<span style=\"color:#008b8b;\">\\2</span>",$texte);
$texte = preg_replace("/(\[darkgoldenrod\])(.*?)(\[\/darkgoldenrod\])/", "<span style=\"color:#b8860b;\">\\2</span>",$texte);
$texte = preg_replace("/(\[darkgray\])(.*?)(\[\/darkgray\])/", "<span style=\"color:#a9a9a9;\">\\2</span>",$texte);
$texte = preg_replace("/(\[darkgreen\])(.*?)(\[\/darkgreen\])/", "<span style=\"color:#006400;\">\\2</span>",$texte);
$texte = preg_replace("/(\[darkkhaki\])(.*?)(\[\/darkkhaki\])/", "<span style=\"color:#bdb76b;\">\\2</span>",$texte);
$texte = preg_replace("/(\[darkmagenta\])(.*?)(\[\/darkmagenta\])/", "<span style=\"color:#8b008b;\">\\2</span>",$texte);
$texte = preg_replace("/(\[lightsalmon\])(.*?)(\[\/lightsalmon\])/", "<span style=\"color:#ffa07a;\">\\2</span>",$texte);
$texte = preg_replace("/(\[lightseagreen\])(.*?)(\[\/lighseagreen\])/", "<span style=\"color:#20b2aa;\">\\2</span>",$texte);
$texte = preg_replace("/(\[lightskyblue\])(.*?)(\[\/lighskyblue\])/", "<span style=\"color:#87cefa;\">\\2</span>",$texte);
$texte = preg_replace("/(\[lightslategray\])(.*?)(\[\/lightslategray\])/", "<span style=\"color:#778899;\">\\2</span>",$texte);
$texte = preg_replace("/(\[lightsteelblue\])(.*?)(\[\/lightsteelblue\])/", "<span style=\"color:#b0c4de;\">\\2</span>",$texte);
$texte = preg_replace("/(\[lightsyellow\])(.*?)(\[\/lightyellow\])/", "<span style=\"color:#ffffe0;\">\\2</span>",$texte);
$texte = preg_replace("/(\[lime\])(.*?)(\[\/lime\])/", "<span style=\"color:#00ff00;\">\\2</span>",$texte);
$texte = preg_replace("/(\[limegreen\])(.*?)(\[\/limegreen\])/", "<span style=\"color:#32cd32;\">\\2</span>",$texte);
$texte = preg_replace("/(\[linen\])(.*?)(\[\/linen\])/", "<span style=\"color:#faf0e6;\">\\2</span>",$texte);
$texte = preg_replace("/(\[magenta\])(.*?)(\[\/magenta\])/", "<span style=\"color:#ff00ff;\">\\2</span>",$texte);
$texte = preg_replace("/(\[maroon\])(.*?)(\[\/maroon\])/", "<span style=\"color:#800000;\">\\2</span>",$texte);
$texte = preg_replace("/(\[mediummaquamarine\])(.*?)(\[\/mediummaquamarine\])/", "<span style=\"color:#66cdaa;\">\\2</span>",$texte);
$texte = preg_replace("/(\[mediumblue\])(.*?)(\[\/mediumblue\])/", "<span style=\"color:#0000cd;\">\\2</span>",$texte);
$texte = preg_replace("/(\[mediummorchin\])(.*?)(\[\/mediummorchin\])/", "<span style=\"color:#ba55d3;\">\\2</span>",$texte);
$texte = preg_replace("/(\[mediumpurple\])(.*?)(\[\/mediumpurple\])/", "<span style=\"color:#9370db;\">\\2</span>",$texte);
$texte = preg_replace("/(\[mediumseagreen\])(.*?)(\[\/mediumseagreen\])/", "<span style=\"color:#3cb371;\">\\2</span>",$texte);
$texte = preg_replace("/(\[mediumslateblue\])(.*?)(\[\/mediumslateblue\])/", "<span style=\"color:#7b68ee;\">\\2</span>",$texte);
$texte = preg_replace("/(\[mediumspringgreen\])(.*?)(\[\/mediumspringgreen\])/", "<span style=\"color:#0fa9a;\">\\2</span>",$texte);
$texte = preg_replace("/(\[mediumturquoise\])(.*?)(\[\/mediumturquoise\])/", "<span style=\"color:#48d1cc;\">\\2</span>",$texte);
$texte = preg_replace("/(\[mediumvioletred\])(.*?)(\[\/mediumvioletred\])/", "<span style=\"color:#c71585;\">\\2</span>",$texte);
$texte = preg_replace("/(\[midnightblue\])(.*?)(\[\/midnightblue\])/", "<span style=\"color:#191970;\">\\2</span>",$texte);
$texte = preg_replace("/(\[mintcream\])(.*?)(\[\/mintcream\])/", "<span style=\"color:#f5fffa;\">\\2</span>",$texte);
$texte = preg_replace("/(\[mistyrose\])(.*?)(\[\/mistyrose\])/", "<span style=\"color:#ffe4e1;\">\\2</span>",$texte);
$texte = preg_replace("/(\[moccasin\])(.*?)(\[\/moccasin\])/", "<span style=\"color:#ffe4b5;\">\\2</span>",$texte);
$texte = preg_replace("/(\[navajowhite\])(.*?)(\[\/navajowhite\])/", "<span style=\"color:#ffdead;\">\\2</span>",$texte);
$texte = preg_replace("/(\[navy\])(.*?)(\[\/navy\])/", "<span style=\"color:#000080;\">\\2</span>",$texte);
$texte = preg_replace("/(\[oldlace\])(.*?)(\[\/oldace\])/", "<span style=\"color:#fdf5e6;\">\\2</span>",$texte);
$texte = preg_replace("/(\[olive\])(.*?)(\[\/olive\])/", "<span style=\"color:#808000;\">\\2</span>",$texte);
// vous pouvez en rajouter car la liste n'est pas exhaustive
return $texte;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function taille($texte) {
$texte = preg_replace("/(\[12\])(.*?)(\[\/12\])/", "<div style=\"font-size:12px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[13\])(.*?)(\[\/13\])/", "<div style=\"font-size:13px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[14\])(.*?)(\[\/14\])/", "<div style=\"font-size:14px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[15\])(.*?)(\[\/15\])/", "<div style=\"font-size:15px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[15\])(.*?)(\[\/15\])/", "<div style=\"font-size:15px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[16\])(.*?)(\[\/16\])/", "<div style=\"font-size:16px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[17\])(.*?)(\[\/17\])/", "<div style=\"font-size:17px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[18\])(.*?)(\[\/18\])/", "<div style=\"font-size:18px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[19\])(.*?)(\[\/19\])/", "<div style=\"font-size:19px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[20\])(.*?)(\[\/20\])/", "<div style=\"font-size:20px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[21\])(.*?)(\[\/21\])/", "<div style=\"font-size:21px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[22\])(.*?)(\[\/22\])/", "<div style=\"font-size:22px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[23\])(.*?)(\[\/23\])/", "<div style=\"font-size:23px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[24\])(.*?)(\[\/24\])/", "<div style=\"font-size:24px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[25\])(.*?)(\[\/25\])/", "<div style=\"font-size:25px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[26\])(.*?)(\[\/26\])/", "<div style=\"font-size:26px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[27\])(.*?)(\[\/27\])/", "<div style=\"font-size:27px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[28\])(.*?)(\[\/28\])/", "<div style=\"font-size:28px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[29\])(.*?)(\[\/29\])/", "<div style=\"font-size:29px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[30\])(.*?)(\[\/30\])/", "<div style=\"font-size:30px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[31\])(.*?)(\[\/31\])/", "<div style=\"font-size:31px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[32\])(.*?)(\[\/32\])/", "<div style=\"font-size:32px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[33\])(.*?)(\[\/33\])/", "<div style=\"font-size:33px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[34\])(.*?)(\[\/34\])/", "<div style=\"font-size:34px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[35\])(.*?)(\[\/35\])/", "<div style=\"font-size:35px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[36\])(.*?)(\[\/36\])/", "<div style=\"font-size:36px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[37\])(.*?)(\[\/37\])/", "<div style=\"font-size:37px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[38\])(.*?)(\[\/38\])/", "<div style=\"font-size:38px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[39\])(.*?)(\[\/39\])/", "<div style=\"font-size:39px;\">\\2</div style>", $texte);
$texte = preg_replace("/(\[40\])(.*?)(\[\/40\])/", "<div style=\"font-size:40px;\">\\2</div style>", $texte);
// Vous pouvez naturellement ajouter d'autres valeurs si vous le juger utile !!!
return $texte;
}
// fin du script
?>
Discussions par date d’activité
2 discussions
Bonjour, je travaille en local avec la version 1.9
Si je comprends bien, je devrais voir cette fonction dans l’espace rédaction ? Ce n’est pas le cas. J’ai mis « mes fonctions » à la racine, faut-il le placer dans « ecrire » , ou ailleurs SVP ?
Merci
Parfait ! Tout marche impec ! merci !
Répondre à ce message
ce filtre s’applique t il a la version 1,9 de spip ?
merci
Bonjour,
Actuellement ce filtre n’est prévu que pour la version 1.7 mais je pense qu’il peut être adaptable a la version 1.9,
je trouve un moment je pourrai me pencher sur la question.
bonne continuation.........
Répondre à ce message
Ajouter un commentaire
Avant de faire part d’un problème sur un plugin X, merci de lire ce qui suit :
Merci d’avance pour les personnes qui vous aideront !
Par ailleurs, n’oubliez pas que les contributeurs et contributrices ont une vie en dehors de SPIP.
Suivre les commentaires : |