Subversion Repositories Applications.papyrus

Rev

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

Rev 2059 Rev 2081
Line 45... Line 45...
45
													'(?:\s*'.
45
													'(?:\s*'.
46
														'(?:'.
46
														'(?:'.
47
															'(url="[^"]*")|'.
47
															'(url="[^"]*")|'.
48
															'(titre="[^"]*")|'.
48
															'(titre="[^"]*")|'.
49
															'(nb="?\d+"?)|'.
49
															'(nb="?\d+"?)|'.
-
 
50
															'(tailledesc="?\d+"?)|'.
-
 
51
															'(voirsuite="[^"]*")|'.
-
 
52
															'(dureecache="?\d+"?)|'.
-
 
53
															'(id="[^"]*")|'.
50
															'(nbmax="?\d+"?)|'.
54
															'(nbmax="?\d+"?)|'.
51
															'(nouvellefenetre="?(?:0|1)"?)|'.
55
															'(nouvellefenetre="?(?:0|1)"?)|'.
52
															'(formatdate="[^"]*")|'.
56
															'(formatdate="[^"]*")|'.
53
															'(formatdatepro="[^"]*")|'.
57
															'(formatdatepro="[^"]*")|'.
54
															'(template=".*")|'.
58
															'(template=".*")|'.
Line 97... Line 101...
97
		$string_arguments = "";
101
		$string_arguments = "";
98
	//+----------------------------------------------------------------------------------------------------------------+
102
	//+----------------------------------------------------------------------------------------------------------------+
99
	// Gestion des arguments
103
	// Gestion des arguments
100
	$balise = $tab_applette_arguments[0];
104
	$balise = $tab_applette_arguments[0];
101
    $tab_arguments = $tab_applette_arguments;
105
    $tab_arguments = $tab_applette_arguments;
-
 
106
    
102
	unset($tab_arguments[0]);
107
	unset($tab_arguments[0]);
103
    foreach($tab_arguments as $argument) {
108
    foreach($tab_arguments as $argument) {
104
    	if ($argument != '') {
109
    	if ($argument != '') {
105
	    		$string_arguments .= $argument;
110
	    		$string_arguments .= $argument;
106
	    	$tab_parametres = explode('=', $argument, 2);
111
	    	$tab_parametres = explode('=', $argument, 2);
107
	    	$options[$tab_parametres[0]] = trim($tab_parametres[1], '"');
112
	    	$options[$tab_parametres[0]] = trim($tab_parametres[1], '"');
108
    	}
113
    	}
109
    }
114
    }
Line 110... Line 115...
110
 
115
 
-
 
116
    $id_cache = md5($string_arguments);
-
 
117
	//Greg : possibilité d'ajouter une durée au cache
-
 
118
	if (!isset($options['dureecache'])) {
-
 
119
		$options['dureecache'] = CACHE_LIFETIME;
Line 111... Line 120...
111
    $id_cache = md5($string_arguments);
120
	}
112
 
121
 
113
	if($contenu_cache = verifierCache($id_cache)) {
122
	if($contenu_cache = verifierCache($id_cache, $options['dureecache'])) {
114
		return $contenu_cache;
123
		return $contenu_cache;
115
	}
124
	}
116
	//
125
	//
-
 
126
	//+----------------------------------------------------------------------------------------------------------------+
117
	//+----------------------------------------------------------------------------------------------------------------+
127
    // Gestion des erreurs de paramétrage
118
    // Gestion des erreurs de paramétrage
128
    
119
	if (!isset($options['url'])) {
129
	if (!isset($options['url'])) {
120
		$GLOBALS['_SYNDICATION_']['erreurs'][] = sprintf(SYND_LG_ERREUR_URL, $balise);
130
		$GLOBALS['_SYNDICATION_']['erreurs'][] = sprintf(SYND_LG_ERREUR_URL, $balise);
121
	}
131
	}
Line 126... Line 136...
126
		$options['nb'] = SYND_NOMBRE;
136
		$options['nb'] = SYND_NOMBRE;
127
	}
137
	}
128
	if (!isset($options['nbmax'])) {
138
	if (!isset($options['nbmax'])) {
129
		$options['nbmax'] = SYND_NOMBRE_MAX;
139
		$options['nbmax'] = SYND_NOMBRE_MAX;
130
	}
140
	}
131
    if (!isset($options['nouvellefenetre'])) {
141
    	if (!isset($options['nouvellefenetre'])) {
132
		$options['nouvellefenetre'] = SYND_OUVRIR_LIEN_RSS_NOUVELLE_FENETRE;
142
		$options['nouvellefenetre'] = SYND_OUVRIR_LIEN_RSS_NOUVELLE_FENETRE;
133
	}
143
	}
134
	if (!isset($options['formatdate'])) {
144
	if (!isset($options['formatdate'])) {
135
		$options['formatdate'] = SYND_FORMAT_DATE;
145
		$options['formatdate'] = SYND_FORMAT_DATE;
136
	}
146
	}
Line 142... Line 152...
142
	} else {
152
	} else {
143
		if (file_exists(SYND_CHEMIN_SQUELETTE.$options['template'])) {
153
		if (file_exists(SYND_CHEMIN_SQUELETTE.$options['template'])) {
144
			$options['template'] = SYND_CHEMIN_SQUELETTE.$options['template'];
154
			$options['template'] = SYND_CHEMIN_SQUELETTE.$options['template'];
145
		}
155
		}
146
	}
156
	}
-
 
157
	
147
 
158
	
-
 
159
	
-
 
160
	
148
    //+----------------------------------------------------------------------------------------------------------------+
161
    //+----------------------------------------------------------------------------------------------------------------+
149
    // Recuperation des donnees
162
    // Recuperation des donnees
150
    if (count($GLOBALS['_SYNDICATION_']['erreurs']) == 0) {
163
    if (count($GLOBALS['_SYNDICATION_']['erreurs']) == 0) {
151
		$tab_url = array_map('trim', explode(',', $options['url']));
164
		$tab_url = array_map('trim', explode(',', $options['url']));
152
        foreach ($tab_url as $cle => $url) {
165
        foreach ($tab_url as $cle => $url) {
Line 204... Line 217...
204
				if ( $options['titre'] == '' ) {
217
				if ( $options['titre'] == '' ) {
205
					$aso_site['titre'] = mb_convert_encoding($feed->title, 'HTML-ENTITIES', $encodages);
218
					$aso_site['titre'] = mb_convert_encoding($feed->title, 'HTML-ENTITIES', $encodages);
206
				} else if ( $options['titre'] != '0' ) {
219
				} else if ( $options['titre'] != '0' ) {
207
					$aso_site['titre'] = $options['titre'];
220
					$aso_site['titre'] = $options['titre'];
208
				}
221
				}
-
 
222
				
-
 
223
				//Gestion de l'ID
-
 
224
				if ( $options['id'] != '' ) {
-
 
225
					$aso_site['id'] = $options['id'];
-
 
226
				}
-
 
227
				
-
 
228
				//Gestion du lien vers la suite
-
 
229
				if ( $options['voirsuite'] != '' ) {
-
 
230
					$aso_site['voirsuite'] = $options['voirsuite'];
-
 
231
				}
-
 
232
				
209
				// Gestion de l'url du site
233
				// Gestion de l'url du site
210
				$aso_site['url'] = htmlentities($feed->link);
234
				$aso_site['url'] = htmlentities($feed->link);
Line 211... Line 235...
211
 
235
 
212
				// Ouverture du lien dans une nouvelle fenetre
236
				// Ouverture du lien dans une nouvelle fenetre
Line 217... Line 241...
217
				// Gestion des pages syndiquees
241
				// Gestion des pages syndiquees
218
				$i = 0;
242
				$i = 0;
219
			    $nb_item = $feed->numberEntries;
243
			    $nb_item = $feed->numberEntries;
Line 220... Line 244...
220
 
244
 
221
				foreach ($feed as $item) {
245
				foreach ($feed as $item) {
222
 
246
					
223
					if ($options['nb'] != 0 && $nb_item >= $options['nb'] && $i >= $options['nb']) {
247
					if ($options['nb'] != 0 && $nb_item >= $options['nb'] && $i >= $options['nb']) {
224
						break;
248
						break;
225
					}
249
					}
Line 226... Line 250...
226
					$i++;
250
					$i++;
227
 
251
 
228
					$aso_page = array();
252
					$aso_page = array();
229
					$aso_page['site'] = $aso_site;
253
					$aso_page['site'] = $aso_site;
230
					$aso_page['url'] = htmlentities($item->link);
254
					$aso_page['url'] = htmlentities($item->link);
-
 
255
					$aso_page['titre'] = mb_convert_encoding($item->title, 'HTML-ENTITIES', $encodages);
-
 
256
					$aso_page['description'] = mb_convert_encoding($item->description, 'HTML-ENTITIES', $encodages);
-
 
257
					
-
 
258
					/* Extraction de l'image si incluse dans description */
-
 
259
					$image = "";
-
 
260
					$description = $aso_page['description'];
-
 
261
					
-
 
262
					$taille = $options['tailledesc'];
-
 
263
					
-
 
264
					if (!(strpos($description, '<img') === false))	{
-
 
265
						$pos_debut = strpos($description, '<img');
-
 
266
						$pos_fin_image = strpos($description, '>', $posimage) + 1;
-
 
267
						$image = substr($description, $pos_debut, ($pos_fin_image - $pos_debut));
-
 
268
						$description = substr_replace($description,' ', $pos_debut,  ($pos_fin_image - $pos_debut));
-
 
269
					}
-
 
270
					
-
 
271
					$aso_page['image'] = $image;
-
 
272
					$aso_page['description_sans_image'] = $description; 
-
 
273
 
-
 
274
					if ($taille != null)	{
-
 
275
						
-
 
276
						//Attention : si on coupe simplement, on peut couper une balise en plein milieu.
-
 
277
						//On va donc vérifier 
-
 
278
						//1. recherche de tags simples <i> ou <b>
-
 
279
						$description = html_entity_decode($description);
-
 
280
						$description = strip_tags($description, "<i><b>");
-
 
281
						
-
 
282
						//Va-ton couper un mot ?
-
 
283
						
-
 
284
						if ($description[$taille] != ' ' && $description[$taille+1] != ' ' && $description[$taille-1] != ' ')	{
-
 
285
  								$strpos = strpos($description, ' ', $taille);
-
 
286
  								if ($strpos === true)	{
-
 
287
  									$taille = $strpos;
-
 
288
  								}
-
 
289
  						}
-
 
290
  						
-
 
291
  						
-
 
292
						$description = substr($description, 0, $taille);
-
 
293
						$description.='(...)';
-
 
294
						
-
 
295
						$pattern = '#<([ib])[ ]*[a-z]*>(.*?)</\1>#i';
-
 
296
						//1. remplacer toutes le	s balises fermées
-
 
297
						$chaine = preg_replace($pattern, '$2', $description);
-
 
298
						$nb_occurences_i = substr_count($chaine, '<i');
-
 
299
						for ($occurences = 0; $occurences < $nb_occurences_i; $occurences++)	{
-
 
300
							$description .= "</i>";
-
 
301
						}
-
 
302
						
-
 
303
						$nb_occurences_b = substr_count($chaine, '<b');
-
 
304
						for ($occurences = 0; $occurences < $nb_occurences_b; $occurences++)	{
-
 
305
							$description .= "</b>";
-
 
306
						}
-
 
307
					}
-
 
308
				
-
 
309
					$aso_page['description_light'] = $description;
-
 
310
 
-
 
311
					//Greg : ajout GUID
231
					$aso_page['titre'] = mb_convert_encoding($item->title, 'HTML-ENTITIES', $encodages);
312
					$aso_page['guid'] = mb_convert_encoding($item->model->getElementsByTagName('guid')->item(0)->nodeValue, 'HTML-ENTITIES', $encodages);
232
					$aso_page['description'] = mb_convert_encoding($item->description, 'HTML-ENTITIES', $encodages);
313
					
-
 
314
					$aso_page['category'] = mb_convert_encoding($item->model->getElementsByTagName('category')->item(0)->nodeValue, 'HTML-ENTITIES', $encodages);
-
 
315
					$aso_page['author'] = mb_convert_encoding($item->author, 'HTML-ENTITIES', $encodages);
233
					$aso_page['category'] = mb_convert_encoding($item->model->getElementsByTagName('category')->item(0)->nodeValue, 'HTML-ENTITIES', $encodages);
316
					
234
					$aso_page['author'] = mb_convert_encoding($item->author, 'HTML-ENTITIES', $encodages);
317
					
235
					$aso_page['date'] = $item->pubDate;
318
					$aso_page['date'] = $item->pubDate;
236
					if ($options['formatdatepro']) {
319
					if ($options['formatdatepro']) {
237
						switch ($options['formatdatepro']) {
320
						switch ($options['formatdatepro']) {
Line 289... Line 372...
289
	ob_start();
372
	ob_start();
290
	// Inclusion du fichier
373
	// Inclusion du fichier
291
	include($options['template']);
374
	include($options['template']);
292
	// Recuperer le  contenu du buffer
375
	// Recuperer le  contenu du buffer
293
	$sortie = ob_get_contents();
376
	$sortie = ob_get_contents();
294
	creer_cache($id_cache,$sortie);
377
	creer_cache($id_cache,$sortie, $options['dureecache']);
295
	// Arrete et detruit le buffer
378
	// Arrete et detruit le buffer
296
	ob_end_clean();
379
	ob_end_clean();
Line 297... Line 380...
297
 
380
 
298
	//+----------------------------------------------------------------------------------------------------------------+
381
	//+----------------------------------------------------------------------------------------------------------------+
Line 353... Line 436...
353
* Ajout de l'applette Syndication.
436
* Ajout de l'applette Syndication.
354
*
437
*
355
*
438
*
356
* +-- Fin du code ----------------------------------------------------------------------------------------+
439
* +-- Fin du code ----------------------------------------------------------------------------------------+
357
*/
440
*/
358
?>
-
 
359
441
?>
-
 
442