From bf24aa601f96d184f9635fa72377d7521b324b4f Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 20 Mar 2013 22:56:17 +0100 Subject: Ajout controller Rss pour export au format RSS (très très basique) #34 + ajout lib text pour gérer le bbcode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/lib_text.php | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 lib/lib_text.php (limited to 'lib') diff --git a/lib/lib_text.php b/lib/lib_text.php new file mode 100644 index 000000000..6e8f7b2bf --- /dev/null +++ b/lib/lib_text.php @@ -0,0 +1,88 @@ +\\1", + "\\1", + "\\1", + "\\1", + "
\\1
", + "\\1", + "\\1 a écrit
\\2
", + "\\2", + "
\\2
", + "\\1
", + "\\1", + "\\2", + "", + "", + "\"\"", + "\"\\1\"", + "\"\\1\"", + ); + + $string = makeLinks(preg_replace ($find, $replace, $string)); + $string = nl2brPlus ($string); + + return $string; +} + +// do nl2br except when in a
 tag
+function nl2brPlus($string) {
+	$string = str_replace("\n", "
", $string); + if(preg_match_all('/\(.*?)\<\/pre\>/', $string, $match)){ + foreach($match as $a){ + foreach($a as $b){ + $string = str_replace('
'.$b.'
', "
".str_replace("
", "", $b)."
", $string); + } + } + } + return $string; +} + +# Transform URL and e-mails into links +function makeLinks($string) { + $string = preg_replace_callback('/\s(http|https|ftp):(\/\/){0,1}([^\"\s]*)/i','splitUri',$string); + return $string; +} + +# Split links, require for makeLinks +function splitUri($matches) { + $uri = $matches[1].':'.$matches[2].$matches[3]; + $t = parse_url($uri); + $link = $matches[3]; + + if (!empty($t['scheme'])) { + return ' '.$link.''; + } else { + return $uri; + } +} + +// parse la description pour ajouter les liens sur les tags +function parse_tags ($desc) { + $desc_parse = preg_replace ('/#([\w\dÀÇÈÉÊËÎÏÔÙÚÛÜàáâçèéêëîïóùúûü]+)/i', '\\1', $desc); + + return $desc_parse; +} -- cgit v1.2.3