* * @package Text_Wiki * */ class Text_Wiki_Parse_Motcles extends Text_Wiki_Parse { var $regex = '/\{\{MotCles mots="(.+?)"(?: condition="(ET|OU|et|ou)"|)(?: categorie="(.+?)"|)(?: condition="(ET|OU|et|ou)"|)(?: ordre="(ASC|DESC|asc|desc)"|)\}\}/'; /** * * Remplace l'action par une liste des pages contenant les mots clés choisis * Les options sont: * * 'mots' => les mots clés séparés par des virgules * * @access public * * @param array &$matches The array of matches from parse(). * * @return A delimited token to be used as a placeholder in * the source text, plus any text priot to the match. * */ function process(&$matches) { $options = array( 'mots' => $matches[1], 'condition' => $matches[2], 'categorie' => $matches[3], 'condition2' => $matches[4], 'ordre' => $matches[5] ); // Les conditions étant écrites en français, ce qui suit les traduit, "et" devient "AND" etc. if (isset($options['condition'])) { if ($options['condition'] == 'ET' || $options['condition'] == 'et') { $options['condition'] = 'AND'; } elseif ($options['condition'] == 'OU' || $options['condition'] == 'ou') { $options['condition'] = 'OR'; } } if (isset($options['condition2'])) { if ($options['condition2'] == 'ET' || $options['condition2'] == 'et') { $options['condition2'] = 'AND'; } elseif ($options['condition2'] == 'OU' || $options['condition2'] == 'ou') { $options['condition2'] = 'OR'; } } return $this->wiki->addToken($this->rule, $options); } } ?>