Commit | Line | Data |
---|---|---|
c495c100 P |
1 | <?php |
2 | ||
3 | // Outil SMILEYS - 25 decembre 2006 | |
4 | // balise #SMILEYS : Patrice Vanneufville, 2007 | |
5 | // Toutes les infos sur : http://www.spip-contrib.net/?article1561 | |
6 | // dessin des frimousses : Sylvain Michel [http://www.guaph.net/] | |
7 | ||
8 | function balise_SMILEYS_dist($p) { | |
9 | // le tableau des smileys est present dans les metas | |
10 | $smileys = unserialize($GLOBALS['meta']['cs_smileys']); | |
11 | // valeurs par defaut | |
12 | $nb_col = 8; | |
13 | $titre = _T('couteau:smileys_dispos'); | |
14 | $head = ''; | |
15 | $liens = false; | |
16 | // traitement des arguments : [(#SMILEYS{arg1, arg2, ...})] | |
17 | $n=1; | |
18 | $arg = interprete_argument_balise($n++,$p); | |
19 | while ($arg){ | |
20 | // un nombre est le nombre de colonne | |
21 | if (preg_match(",'([0-9]+)',", $arg, $reg)) | |
22 | $nb_col = intval($reg[1]); | |
23 | // on veut un titre | |
24 | elseif ($arg=="'titre'") | |
25 | $head = "<thead><tr class=\"row_first\"><td colspan=\"$nb_col\">$titre</td></tr></thead>"; | |
26 | // on veut un lien d'insertion sur chaque smiley | |
27 | elseif ($arg=="'liens'") { | |
28 | $liens = true; | |
29 | include_spip('outils/smileys'); | |
30 | $smileys = smileys_uniques($smileys); | |
31 | } | |
32 | $arg = interprete_argument_balise($n++,$p); | |
33 | } | |
34 | $max = count($smileys[0]); | |
35 | if (!$nb_col) $nb_col = $max; | |
36 | $html = "<table summary=\"$titre\" class=\"spip cs_smileys smileys\">$head"; | |
37 | $l = 1; | |
38 | for ($i=0; $i<$max; $i++) { | |
39 | if ($i % $nb_col == 0) { | |
40 | $class = 'row_'.alterner($l++, 'even', 'odd'); | |
41 | $html .= "<tr class=\"$class\">"; | |
42 | } | |
43 | $html .= $liens | |
44 | ?"<td><a href=\"javascript:barre_inserer('{$smileys[0][$i]}',document.getElementById('".(defined('_SPIP19300')?'texte':'textarea_1')."'))\">{$smileys[1][$i]}</a></td>" | |
45 | :"<td>{$smileys[1][$i]}<br />{$smileys[0][$i]}</td>"; | |
46 | if ($i % $nb_col == $nb_col - 1) | |
47 | $html .= "</tr>\n"; | |
48 | } | |
49 | // on finit la ligne qd meme... | |
50 | if ($i = $max % $nb_col) $html .= str_repeat('<td> </td>', $nb_col - $i) . '</tr>'; | |
51 | ||
52 | // accessibilite : alt et title avec le smiley en texte | |
53 | $html = echappe_retour($html, 'SMILE'); | |
54 | $html = str_replace("'", "\'", $html); | |
55 | $p->code = "'$html\n</table>\n'"; | |
56 | $p->interdire_scripts = true; | |
57 | $p->type = 'html'; | |
58 | return $p; | |
59 | } | |
60 | ||
61 | ?> |