Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 202 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 202 Rev 207
Line 4... Line 4...
4
	private $texteSansAccent = '';
4
	private $texteSansAccent = '';
5
	private $tags = array();
5
	private $tags = array();
6
	private $nbreSurlignageMaxParMot = 1;
6
	private $nbreSurlignageMaxParMot = 1;
7
	private $nbreSurlignageCourant = 0;
7
	private $nbreSurlignageCourant = 0;
Line 8... Line 8...
8
 
8
 
9
	public function __construct($texte = null, $surlignageMaxParMot = null, ChaineManipulateur $manipulateurDeChaine = null) {
9
	public function __construct($texte = null, $surlignageMaxParMot = null) {
10
		if (is_null($texte) == false) {
10
		if (is_null($texte) == false) {
11
			$this->setTexte($texte);
11
			$this->setTexte($texte);
12
		}
12
		}
13
		if (is_null($surlignageMaxParMot) == false) {
13
		if (is_null($surlignageMaxParMot) == false) {
14
			$this->setNbreMaxSurlignageParMot($surlignageMaxParMot);
14
			$this->setNbreMaxSurlignageParMot($surlignageMaxParMot);
15
		}
-
 
16
		
-
 
17
		$this->manipulateurDeChaine = is_null($manipulateurDeChaine) ? new ChaineManipulateur() : $manipulateurDeChaine;
15
		}
Line 18... Line 16...
18
	}
16
	}
19
 
17
 
20
	public function setTexte($txt) {
18
	public function setTexte($txt) {
Line 26... Line 24...
26
	}
24
	}
Line 27... Line 25...
27
 
25
 
28
	public function surlignerMots($mots) {
26
	public function surlignerMots($mots) {
29
		$this->verifierTableauDeMots($mots);
27
		$this->verifierTableauDeMots($mots);
30
		$this->texte = preg_replace_callback('`<[^>]+>`', array($this, 'sauverTags'), $this->texte);
-
 
31
		$this->texteSansAccent = $this->manipulateurDeChaine->supprimerAccents($this->texte);
28
		$this->texte = preg_replace_callback('`<[^>]+>`', array($this, 'sauverTags'), $this->texte);
32
		foreach ($mots as $mot) {
29
		foreach ($mots as $mot) {
33
			$this->initialiserNbreSurlignageCourant();
30
			$this->initialiserNbreSurlignageCourant();
34
			$this->texte = $this->surlignerMot($mot);
31
			$this->texte = $this->surlignerMot($mot);
35
		}
32
		}
Line 58... Line 55...
58
	private function initialiserNbreSurlignageCourant() {
55
	private function initialiserNbreSurlignageCourant() {
59
		$this->nbreSurlignageCourant = 0;
56
		$this->nbreSurlignageCourant = 0;
60
	}
57
	}
Line 61... Line 58...
61
 
58
 
62
	private function surlignerMot($mot) {
59
	private function surlignerMot($mot) {
63
		$positionDebutMot = stripos($this->texteSansAccent, $mot);
60
		$positionDebutMot = stripos($this->texte, $mot); 
64
		$longueurMot = strlen($mot);
61
		$longueurMot = strlen($mot);
65
		$surlignage = $this->texte;
62
		$surlignage = $this->texte;
66
		if ($positionDebutMot !== false) {
63
		if ($positionDebutMot !== false) {
67
			$this->nbreSurlignageCourant++;
64
			$this->nbreSurlignageCourant++;