Subversion Repositories Applications.papyrus

Rev

Rev 384 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
335 jpm 1
<?php
395 jpm 2
// $Id: Motcles.php,v 1.3 2005-06-08 18:43:34 jpm 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
 
395 jpm 18
    var $regex = '/\{\{MotCles mots="(.+?)"(?: 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],
40
            'ordre' => $matches[3]
335 jpm 41
        );
395 jpm 42
        if (isset($options['condition'])) {
43
            if ($options['condition'] == 'ET' || $options['condition'] == 'et') {
44
                $options['condition'] = 'AND';
45
            } elseif ($options['condition'] == 'OU' || $options['condition'] == 'ou') {
46
                $options['condition'] = 'OR';
47
            }
48
        }
335 jpm 49
 
50
        return $this->wiki->addToken($this->rule, $options);
51
    }
52
 
53
}
54
?>