Your IP : 216.73.216.42


Current Path : /home/b/o/u/bourgleram/www/398a1/
Upload File :
Current File : /home/b/o/u/bourgleram/www/398a1/fr.php.tar

home/bourgleram/www/ecrire/typographie/fr.php000070500000004515152525613430015414 0ustar00<?php

/***************************************************************************\
 *  SPIP, Systeme de publication pour l'internet                           *
 *                                                                         *
 *  Copyright (c) 2001-2016                                                *
 *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
 *                                                                         *
 *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
 *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
\***************************************************************************/

if (!defined('_ECRIRE_INC_VERSION')) return;

// Correction typographique francaise

function typographie_fr_dist($letexte) {

	static $trans;

	// Nettoyer 160 = nbsp ; 187 = raquo ; 171 = laquo ; 176 = deg ;
	// 147 = ldquo; 148 = rdquo; ' = zouli apostrophe
	if (!$trans) {
		$trans = array(
			"'" => "&#8217;",
			"&nbsp;" => "~",
			"&raquo;" => "&#187;",
			"&laquo;" => "&#171;",
			"&rdquo;" => "&#8221;",
			"&ldquo;" => "&#8220;",
			"&deg;" => "&#176;"
		);
		$chars = array(160 => '~', 187 => '&#187;', 171 => '&#171;', 148 => '&#8221;', 147 => '&#8220;', 176 => '&#176;');
		$chars_trans = array_keys($chars);
		$chars = array_values($chars);
		$chars_trans = implode(' ',array_map('chr',$chars_trans));
		$chars_trans = unicode2charset(charset2unicode($chars_trans, 'iso-8859-1', 'forcer'));
		$chars_trans = explode(" ",$chars_trans);
		foreach($chars as $k=>$r)
			$trans[$chars_trans[$k]] = $r;
	}

	$letexte = strtr($letexte, $trans);

	$cherche1 = array(
		/* 1 */ 	'/((?:^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/S',
		/* 2 */		'/&#187;| --?,|(?::(?!:)| %)(?:\W|$)/S',
		/* 3 */		'/([^[<(!?.])([!?][!?\.]*)/iS',
		/* 4 */		'/&#171;|(?:M(?:M?\.|mes?|r\.?)|[MnN]&#176;) /S'
	);
	$remplace1 = array(
		/* 1 */		'\1~;',
		/* 2 */		'~\0',
		/* 3 */		'\1~\2',
		/* 4 */		'\0~'
	);
	$letexte = preg_replace($cherche1, $remplace1, $letexte);
	$letexte = preg_replace("/ *~+ */S", "~", $letexte);

	$cherche2 = array(
		'/([^-\n]|^)--([^-]|$)/S',
		',(' ._PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S',
		'/~/'
	);
	$remplace2 = array(
		'\1&mdash;\2',
		'\1\3\4',
		'&nbsp;'
	);
	$letexte = preg_replace($cherche2, $remplace2, $letexte);

	return $letexte;
}
home/bourgleram/www/plugins-dist/textwheel/typographie/fr.php000070500000005372152527523510020601 0ustar00<?php

/***************************************************************************\
 *  SPIP, Systeme de publication pour l'internet                           *
 *                                                                         *
 *  Copyright (c) 2001-2016                                                *
 *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
 *                                                                         *
 *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
 *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
\***************************************************************************/

if (!defined("_ECRIRE_INC_VERSION")) return;

// Correction typographique francaise

function typographie_fr($t) {

	static $trans;

	if (!isset($trans)) {
		$trans = array(
		"&nbsp;" => '~',
		"&raquo;" => '&#187;',
		"&laquo;" => '&#171;',
		"&rdquo;" => '&#8221;',
		"&ldquo;" => '&#8220;',
		"&deg;" => '&#176;',
		"'" => '&#8217;'
		);
		switch ($GLOBALS['meta']['charset']) {
			case 'utf-8':
				$trans["\xc2\xa0"] = '~';
				$trans["\xc2\xbb"] = '&#187;';
				$trans["\xc2\xab"] = '&#171;';
				$trans["\xe2\x80\x94"] = '--';
				$trans["\xe2\x80\x9d"] = '&#8221;';
				$trans["\xe2\x80\x9c"] = '&#8220;';
				$trans["\xc2\xb0"] = '&#176;';
				$trans["\xe2\x80\x89"] = '~'; # &finesp;
				break;
			default:
				$trans["\xa0"] = '~';
				$trans["\xab"] = '&#171;';
				$trans["\xbb"] = '&#187;';
				$trans["\xb0"] = '&#176;';
				break;
		}
	}

	# cette chaine ne peut pas exister,
	# cf. TYPO_PROTECTEUR dans inc/texte
	$pro = "-\x2-";

	$t = str_replace(array_keys($trans), array_values($trans), $t);

	# la typo du ; risque de clasher avec les entites &xxx;
	if (strpos($t, ';') !== false) {
		$t = str_replace(';', '~;', $t);
		$t = preg_replace(',(&#?[0-9a-z]+)~;,iS', '$1;', $t);
	}

	/* 2 ; ajout d'insecable */
	$t = preg_replace('/&#187;| --?,|(?::| %)(?:\W|$)/S', '~$0', $t);

	// {»} guillemet en italiques : ne pas doubler l'insecable 
	$t = str_replace('~{~', '~{', $t);
	$t = str_replace('~}~', '}~', $t);


	/* 3 */
	$t = preg_replace('/[!?][!?\.]*/S', "$pro~$0", $t, -1, $c);
	if ($c) {
		$t = preg_replace("/([\[<\(!\?\.])$pro~/S", '$1', $t);
		$t = str_replace("$pro", '', $t);
	}

	/* 4 */
	$t = preg_replace('/&#171;|M(?:M?\.|mes?|r\.?|&#176;) |[nN]&#176; /S', '$0~', $t);

	if (strpos($t, '~') !== false)
		$t = preg_replace("/ *~+ */S", "~", $t);

	$t = preg_replace("/--([^-]|$)/S", "$pro&mdash;$1", $t, -1, $c);
	if ($c) {
		$t = preg_replace("/([-\n])$pro&mdash;/S", "$1--", $t);
		$t = str_replace($pro, '', $t);
	}

	$t = preg_replace(',(' ._PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', '$1$3$4', $t);
	$t = str_replace('~', '&nbsp;', $t);

	return $t;
}