| 335 |
jpm |
1 |
<?php
|
| 408 |
alexandre_ |
2 |
// $Id: Motcles.php,v 1.4 2005-07-08 15:14:51 alexandre_tb Exp $
|
| 335 |
jpm |
3 |
|
|
|
4 |
|
|
|
5 |
/**
|
|
|
6 |
*
|
|
|
7 |
* This class implements a Text_Wiki_Parse to find source text marked as
|
|
|
8 |
* an Interwiki link. See the regex for a detailed explanation of the
|
|
|
9 |
* text matching procedure; e.g., "InterWikiName:PageName".
|
|
|
10 |
*
|
|
|
11 |
* @author Paul M. Jones <pmjones@ciaweb.net>
|
|
|
12 |
*
|
|
|
13 |
* @package Text_Wiki
|
|
|
14 |
*
|
|
|
15 |
*/
|
|
|
16 |
class Text_Wiki_Parse_Motcles extends Text_Wiki_Parse {
|
|
|
17 |
|
| 408 |
alexandre_ |
18 |
var $regex = '/\{\{MotCles mots="(.+?)"(?: condition="(ET|OU|et|ou)"|)(?: categorie="(.+?)"|)(?: condition="(ET|OU|et|ou)"|)(?: ordre="(ASC|DESC|asc|desc)"|)\}\}/';
|
| 335 |
jpm |
19 |
|
|
|
20 |
/**
|
|
|
21 |
*
|
|
|
22 |
* Remplace l'action par une liste des pages contenant les mots clés choisis
|
|
|
23 |
* Les options sont:
|
|
|
24 |
*
|
|
|
25 |
* 'mots' => les mots clés séparés par des virgules
|
|
|
26 |
*
|
|
|
27 |
* @access public
|
|
|
28 |
*
|
|
|
29 |
* @param array &$matches The array of matches from parse().
|
|
|
30 |
*
|
|
|
31 |
* @return A delimited token to be used as a placeholder in
|
|
|
32 |
* the source text, plus any text priot to the match.
|
|
|
33 |
*
|
|
|
34 |
*/
|
|
|
35 |
function process(&$matches)
|
|
|
36 |
{
|
|
|
37 |
$options = array(
|
| 395 |
jpm |
38 |
'mots' => $matches[1],
|
|
|
39 |
'condition' => $matches[2],
|
| 408 |
alexandre_ |
40 |
'categorie' => $matches[3],
|
|
|
41 |
'condition2' => $matches[4],
|
|
|
42 |
'ordre' => $matches[5]
|
| 335 |
jpm |
43 |
);
|
| 408 |
alexandre_ |
44 |
|
|
|
45 |
// Les conditions étant écrites en français, ce qui suit les traduit, "et" devient "AND" etc.
|
| 395 |
jpm |
46 |
if (isset($options['condition'])) {
|
|
|
47 |
if ($options['condition'] == 'ET' || $options['condition'] == 'et') {
|
|
|
48 |
$options['condition'] = 'AND';
|
|
|
49 |
} elseif ($options['condition'] == 'OU' || $options['condition'] == 'ou') {
|
|
|
50 |
$options['condition'] = 'OR';
|
|
|
51 |
}
|
|
|
52 |
}
|
| 408 |
alexandre_ |
53 |
if (isset($options['condition2'])) {
|
|
|
54 |
if ($options['condition2'] == 'ET' || $options['condition2'] == 'et') {
|
|
|
55 |
$options['condition2'] = 'AND';
|
|
|
56 |
} elseif ($options['condition2'] == 'OU' || $options['condition2'] == 'ou') {
|
|
|
57 |
$options['condition2'] = 'OR';
|
|
|
58 |
}
|
|
|
59 |
}
|
| 335 |
jpm |
60 |
|
|
|
61 |
return $this->wiki->addToken($this->rule, $options);
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
}
|
|
|
65 |
?>
|