Subversion Repositories Applications.papyrus

Rev

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

Rev 1146 Rev 1183
Line 19... Line 19...
19
// |                                                                                                      |
19
// |                                                                                                      |
20
// | You should have received a copy of the GNU General Public License                                    |
20
// | You should have received a copy of the GNU General Public License                                    |
21
// | along with Foobar; if not, write to the Free Software                                                |
21
// | along with Foobar; if not, write to the Free Software                                                |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
23
// +------------------------------------------------------------------------------------------------------+
23
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id: more_recherche.class.php,v 1.10 2006-12-12 13:54:41 jp_milcent Exp $
24
// CVS : $Id: more_recherche.class.php,v 1.11 2007-01-02 18:49:22 jp_milcent Exp $
25
/**
25
/**
26
* Classe permettant d'effectuer des recherches sur les métas informations des menus.
26
* Classe permettant d'effectuer des recherches sur les métas informations des menus.
27
*
27
*
28
* Permet de rechercher et classer les menus en fonction d'une chaine.
28
* Permet de rechercher et classer les menus en fonction d'une chaine.
29
*
29
*
Line 32... Line 32...
32
//Auteur original :
32
//Auteur original :
33
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
33
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
34
//Autres auteurs :
34
//Autres auteurs :
35
*@author        aucun
35
*@author        aucun
36
*@copyright     Tela-Botanica 2000-2004
36
*@copyright     Tela-Botanica 2000-2004
37
*@version       $Revision: 1.10 $ $Date: 2006-12-12 13:54:41 $
37
*@version       $Revision: 1.11 $ $Date: 2007-01-02 18:49:22 $
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
39
*/
39
*/
Line 40... Line 40...
40
 
40
 
41
// +------------------------------------------------------------------------------------------------------+
41
// +------------------------------------------------------------------------------------------------------+
Line 127... Line 127...
127
	*/
127
	*/
128
	function retournerOccurenceMotif($motif, &$texte, $mode = MORE_MODE)
128
	function retournerOccurenceMotif($motif, &$texte, $mode = MORE_MODE)
129
	{
129
	{
130
		$nbre_correspondance = 0;
130
		$nbre_correspondance = 0;
131
		$nbre_correspondance_total = 0;
131
		$nbre_correspondance_total = 0;
-
 
132
		$motif = $this->traiterMotif($motif, 'simple');
-
 
133
		// Si demande de recherche d'expression complète
-
 
134
		if (preg_match('/^".+"$/', $motif)) {
-
 
135
			$mode = 2;
-
 
136
			
-
 
137
		}
-
 
138
		$motif = $this->traiterMotif($motif, 'recherche');
132
		if ($mode == 1) {
139
		switch ($mode) {
-
 
140
			case '1' :
133
			// Découpage en mot
141
				// Découpage en mot
134
			$tab_motif = explode(' ', trim($motif));
142
				$tab_motif = explode(' ', $motif);
-
 
143
				break;
135
		} else {
144
			case '2' :
136
			// La chaine saisie par l'utilisateur est recherchée tel quel
145
				// La chaine saisie par l'utilisateur est recherchée tel quel
137
			$tab_motif[] = trim($motif);
146
				$tab_motif[] = $motif;
-
 
147
				break;
-
 
148
			default:
-
 
149
				$e = 'Mode pour le moteur de recherche inconnu : '.$mode.
-
 
150
				trigger_error($e, E_USER_ERROR);
138
		}
151
		}
139
		// Nous recherchons chaque mot
152
		// Nous recherchons chaque mot
140
		$compteur_mot = 0;
153
		$compteur_mot = 0;
141
		foreach ($tab_motif as $mot) {
154
		foreach ($tab_motif as $mot) {
142
			//$nbre_correspondance += preg_match_all('/'.$mot.'/i', $texte, $tab_morceaux);
155
			//$nbre_correspondance += preg_match_all('/'.$mot.'/i', $texte, $tab_morceaux);
143
			$nbre_correspondance = substr_count(strtolower($texte), strtolower(stripslashes($mot)));
156
			$nbre_correspondance = substr_count(strtolower($texte), strtolower($mot));
144
			if ($nbre_correspondance > 0) {
157
			if ($nbre_correspondance > 0) {
145
				$compteur_mot++;
158
				$compteur_mot++;
146
			}
159
			}
147
			$nbre_correspondance_total += $nbre_correspondance; 
160
			$nbre_correspondance_total += $nbre_correspondance; 
148
		}
161
		}
Line 152... Line 165...
152
		} else {
165
		} else {
153
			return 0;
166
			return 0;
154
		}
167
		}
155
	}
168
	}
Line -... Line 169...
-
 
169
	
-
 
170
	function traiterMotif($motif, $type = 0)
-
 
171
    {
-
 
172
    	switch ($type) {
-
 
173
			case 'simple' :
-
 
174
				return trim(stripslashes($motif));
-
 
175
				break;
-
 
176
			case 'recherche' :
-
 
177
				if (preg_match('/^"(.+)"$/', $motif, $match)) {
-
 
178
					$motif = $match[1];
-
 
179
				}
-
 
180
				return $motif;
-
 
181
				break;
-
 
182
			case 'url' :
-
 
183
				$motif = trim(stripslashes($motif));
-
 
184
				if (preg_match('/^"(.+)"$/', $motif, $match)) {
-
 
185
					$motif = $match[1];
-
 
186
				}
-
 
187
				return urlencode($motif);
-
 
188
				break;
-
 
189
			default:
-
 
190
				return $motif;
-
 
191
		}
-
 
192
    }
156
	
193
    
157
    function traduireMois($mois_numerique)
194
    function traduireMois($mois_numerique)
158
    {
195
    {
159
        switch ($mois_numerique) {
196
        switch ($mois_numerique) {
160
            case '01' :
197
            case '01' :
Line 188... Line 225...
188
}
225
}
Line 189... Line 226...
189
 
226
 
190
/* +--Fin du code ----------------------------------------------------------------------------------------+
227
/* +--Fin du code ----------------------------------------------------------------------------------------+
191
*
228
*
-
 
229
* $Log: not supported by cvs2svn $
-
 
230
* Revision 1.10  2006/12/12 13:54:41  jp_milcent
-
 
231
* Correction bogue : variable non initialisée.
192
* $Log: not supported by cvs2svn $
232
*
193
* Revision 1.9  2006/10/17 09:21:40  jp_milcent
233
* Revision 1.9  2006/10/17 09:21:40  jp_milcent
194
* Mise en commun des spécifications de la recherche.
234
* Mise en commun des spécifications de la recherche.
195
*
235
*
196
* Revision 1.8  2006/05/23 14:18:19  jp_milcent
236
* Revision 1.8  2006/05/23 14:18:19  jp_milcent