Subversion Repositories Applications.papyrus

Rev

Rev 1964 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1964 Rev 2104
Line 137... Line 137...
137
	*/
137
	*/
138
	function retournerOccurenceMotif($motif, &$texte, $mode = MORE_MODE)
138
	function retournerOccurenceMotif($motif, &$texte, $mode = MORE_MODE)
139
	{
139
	{
140
		$nbre_correspondance = 0;
140
		$nbre_correspondance = 0;
141
		$nbre_correspondance_total = 0;
141
		$nbre_correspondance_total = 0;
142
		$motif = $this->traiterMotif($motif, 'simple');
142
		$motif = self::traiterMotif($motif, 'simple');
143
		// Si demande de recherche d'expression complète
143
		// Si demande de recherche d'expression complète
144
		if (preg_match('/^".+"$/', $motif)) {
144
		if (preg_match('/^".+"$/', $motif)) {
145
			$mode = 2;
145
			$mode = 2;
Line 146... Line 146...
146
			
146
			
147
		}
147
		}
148
		$motif = $this->traiterMotif($motif, 'recherche');
148
		$motif = self::traiterMotif($motif, 'recherche');
149
		switch ($mode) {
149
		switch ($mode) {
150
			case '1' :
150
			case '1' :
151
				// Découpage en mot
151
				// Découpage en mot
152
				$tab_motif = explode(' ', $motif);
152
				$tab_motif = explode(' ', $motif);
Line 175... Line 175...
175
		} else {
175
		} else {
176
			return 0;
176
			return 0;
177
		}
177
		}
178
	}
178
	}
Line 179... Line 179...
179
	
179
	
180
	function traiterMotif($motif, $type = 0)
180
	static function traiterMotif($motif, $type = 0)
181
    { 	
181
    { 	
182
    	switch ($type) {
182
    	switch ($type) {
183
			case 'simple' :
183
			case 'simple' :
184
				return trim(stripslashes($motif));
184
				return trim(stripslashes($motif));
Line 198... Line 198...
198
				break;
198
				break;
199
			default:
199
			default:
200
				return $motif;
200
				return $motif;
201
		}
201
		}
202
    }
202
    }
203
    
203
 
204
    function traduireMois($mois_numerique)
204
    function traduireMois($mois_numerique)
205
    {
205
    {
206
        switch ($mois_numerique) {
206
        switch ($mois_numerique) {
207
            case '01' :
207
            case '01' :
208
                return 'janvier';              
208
                return 'janvier';              
Line 237... Line 237...
237
     * Coupe un texte suivant une taille donnée, pour éviter qu'il ne soit 
237
     * Coupe un texte suivant une taille donnée, pour éviter qu'il ne soit 
238
     * trop long lors de l'affichage
238
     * trop long lors de l'affichage
239
     * @param String texte à couper
239
     * @param String texte à couper
240
     * @param int taille maximum du texte
240
     * @param int taille maximum du texte
241
     */
241
     */
242
	function couperTexte($texte, $taille = 50)
242
	static function couperTexte($texte, $taille = 50)
243
	{
243
	{
244
		$texte = substr($texte, 0, 400 + 2*$taille); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
244
		$texte = substr($texte, 0, 400 + 2*$taille); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
Line 245... Line 245...
245
	
245
	
246
		// on utilise les \r pour passer entre les gouttes
246
		// on utilise les \r pour passer entre les gouttes
Line 253... Line 253...
253
	
253
	
254
		// supprimer les traits, lignes etc
254
		// supprimer les traits, lignes etc
Line 255... Line 255...
255
		$texte = ereg_replace("(^|\r|\n)(-[-#\*]*|_ )", "\r", $texte);
255
		$texte = ereg_replace("(^|\r|\n)(-[-#\*]*|_ )", "\r", $texte);
256
	
256
	
257
		// supprimer les tags
257
		// supprimer les tags
258
		$texte = $this->supprimerTags($texte);
258
		$texte = self::supprimerTags($texte);
Line 259... Line 259...
259
		$texte = trim(str_replace("\n"," ", $texte));
259
		$texte = trim(str_replace("\n"," ", $texte));
260
		$texte .= "\n";	// marquer la fin
260
		$texte .= "\n";	// marquer la fin
Line 275... Line 275...
275
	
275
	
276
		// supprimer les tableaux
276
		// supprimer les tableaux
Line 277... Line 277...
277
		$texte = ereg_replace("(^|\r)\|.*\|\r", "\r", $texte);
277
		$texte = ereg_replace("(^|\r)\|.*\|\r", "\r", $texte);
278
	
278
	
279
		// couper au mot precedent
279
		// couper au mot precedent
280
		$long = $this->gererSubstr($texte, 0, max($taille-4,1));
280
		$long = self::gererSubstr($texte, 0, max($taille-4,1));
Line 281... Line 281...
281
		$court = ereg_replace("([^[:space:]][[:space:]]+)[^[:space:]]*\n?$", "\\1", $long);
281
		$court = ereg_replace("([^[:space:]][[:space:]]+)[^[:space:]]*\n?$", "\\1", $long);
282
		$points = MORE_LG_RESULTAT_ETC;
282
		$points = MORE_LG_RESULTAT_ETC;
283
	
283
	
284
		// trop court ? ne pas faire de (...)
284
		// trop court ? ne pas faire de (...)
285
		if (strlen($court) < max(0.75 * $taille,2)) {
285
		if (strlen($court) < max(0.75 * $taille,2)) {
286
			$points = '';
286
			$points = '';
287
			$long = $this->gererSubstr($texte, 0, $taille);
287
			$long = self::gererSubstr($texte, 0, $taille);
288
			$texte = ereg_replace("([^[:space:]][[:space:]]+)[^[:space:]]*$", "\\1", $long);
288
			$texte = ereg_replace("([^[:space:]][[:space:]]+)[^[:space:]]*$", "\\1", $long);
289
			// encore trop court ? couper au caractere
289
			// encore trop court ? couper au caractere
Line 304... Line 304...
304
		return trim($texte).$points;
304
		return trim($texte).$points;
305
	}
305
	}
Line 306... Line 306...
306
	
306
	
307
	// Gerer les outils mb_string
307
	// Gerer les outils mb_string
308
	// Fichier : inc_texte.php3	
308
	// Fichier : inc_texte.php3	
309
	function gererSubstr($c, $start=0, $end='')
309
	static function gererSubstr($c, $start=0, $end='')
310
	{
310
	{
311
		// methode substr normale
311
		// methode substr normale
312
		if ($end) {
312
		if ($end) {
313
			return substr($c, $start, $end);
313
			return substr($c, $start, $end);
Line 316... Line 316...
316
		}
316
		}
317
	}
317
	}
Line 318... Line 318...
318
 
318
 
319
	// Suppression basique et brutale de tous les <...>
319
	// Suppression basique et brutale de tous les <...>
320
	// Fichier : inc_filtres.php3
320
	// Fichier : inc_filtres.php3
321
	function supprimerTags($texte, $rempl = "")
321
	static function supprimerTags($texte, $rempl = "")
322
	{
322
	{
323
		$texte = preg_replace(",<[^>]*>,U", $rempl, $texte);
323
		$texte = preg_replace(",<[^>]*>,U", $rempl, $texte);
324
		// ne pas oublier un < final non ferme
324
		// ne pas oublier un < final non ferme
325
		$texte = str_replace('<', ' ', $texte);
325
		$texte = str_replace('<', ' ', $texte);