diff options
| author | 2013-11-15 14:36:34 +0100 | |
|---|---|---|
| committer | 2013-11-15 14:36:34 +0100 | |
| commit | 5dfe281d60e21fd59bfa780fad0aa177a8feaf14 (patch) | |
| tree | a4c4bc483e2b8f54822a2670d770e5116a0c18a4 | |
| parent | a387cc56ffdd169df1f48213f0c509240d6e8752 (diff) | |
Supprime le fichier lib_text
Seule la fonction lazyimg était utilisée, je l'ai déplacée dans lib_rss
| -rw-r--r-- | lib/lib_rss.php | 13 | ||||
| -rw-r--r-- | lib/lib_text.php | 96 |
2 files changed, 13 insertions, 96 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 7f22c8244..a27994e94 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -206,3 +206,16 @@ function dowload_favicon ($website, $id) { return $favicon_url; } + +/** + * Add support of image lazy loading + * Move content from src attribute to data-original + * @param content is the text we want to parse + */ +function lazyimg($content) { + return preg_replace( + '/<img([^<]+)src=([\'"])([^"\']*)([\'"])([^<]*)>/i', + '<img$1src="' . Url::display('/data/grey.gif') . '" data-original="$3"$5>', + $content + ); +} diff --git a/lib/lib_text.php b/lib/lib_text.php deleted file mode 100644 index 99bac0c36..000000000 --- a/lib/lib_text.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php - -function bbDecode($string) { - - $find = array( - "'\[b\](.*?)\[/b\]'is", - "'\[u\](.*?)\[/u\]'is", - "'\[i\](.*?)\[/i\]'is", - "'\[s\](.*?)\[/s\]'is", - "'\[code\](.*?)\[/code\]'is", - "'\[quote\](.*?)\[/quote\]'is", - "'\[quote=(.*?)\](.*?)\[/quote\]'is", - "'\[span=(.*?)\](.*?)\[/span\]'i", - "'\[div=(.*?)\](.*?)\[/div\]'is", - "'\[h\](.*?)\[/h\]'i", - "'\[url\](.*?)\[/url\]'i", - "'\[url=(.*?)\](.*?)\[/url\]'i", - "'\[video\](.*?)\[/video\]'i", - "'\[video width=(.*?) height=(.*?)\](.*?)\[/video\]'i", - "'\[img\](.*?)\[/img\]'i", - "'\[img title=(.*?) rel=(.*?)\](.*?)\[/img\]'i", - "'\[img title=(.*?)\](.*?)\[/img\]'i", - ); - - $replace = array( - "<strong>\\1</strong>", - "<u>\\1</u>", - "<i>\\1</i>", - "<del>\\1</del>", - "<pre>\\1</pre>", - "<q>\\1</q>", - "<q><span class=\"cite\">\\1 a écrit</span><br />\\2</q>", - "<span class=\"\\1\">\\2</span>", - "<div class=\"\\1\">\\2</div>", - "<b>\\1</b><br />", - "<a href=\"\\1\">\\1</a>", - "<a href=\"\\1\">\\2</a>", - "<object width=\"480\" height=\"387\" class=\"center\"><param name=\"movie\" value=\"\\1\"></param><embed src=\"\\1\" type=\"application/x-shockwave-flash\" width=\"480\" height=\"387\"></embed></object>", - "<object width=\"\\1\" height=\"\\2\" class=\"center\"><param name=\"movie\" value=\"\\3\"></param><embed src=\"\\3\" type=\"application/x-shockwave-flash\" width=\"\\1\" height=\"\\2\"></embed></object>", - "<a href=\"\\1\" rel=\"prettyPhoto\"><img src=\"\\1\" alt=\"\" /></a>", - "<img class=\"illustration\" src=\"\\3\" alt=\"\\1\" />", - "<img src=\"\\2\" alt=\"\\1\" />", - ); - - $string = makeLinks(preg_replace ($find, $replace, $string)); - $string = nl2brPlus ($string); - - return $string; -} - -// do nl2br except when in a <pre> tag -function nl2brPlus($string) { - $string = str_replace("\n", "<br />", $string); - if(preg_match_all('/\<pre\>(.*?)\<\/pre\>/', $string, $match)){ - foreach($match as $a){ - foreach($a as $b){ - $string = str_replace('<pre>'.$b.'</pre>', "<pre>".str_replace("<br />", "", $b)."</pre>", $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 ' <a href="'.$uri.'">'.$link.'</a>'; - } else { - return $uri; - } -} - -// parse la description pour ajouter les liens sur les tags -function parse_tags ($desc) { - $desc_parse = preg_replace ('/#([\w\dÀÇÈÉÊËÎÏÔÙÚÛÜàáâçèéêëîïóùúûü]+)/i', '<a class="linktag" href="?addtag=\\1">\\1</a>', $desc); - - return $desc_parse; -} - -function lazyimg($content) { - return preg_replace( - '/<img([^<]+)src=([\'"])([^"\']*)([\'"])([^<]*)>/i', - '<img$1src="' . Url::display('/data/grey.gif') . '" data-original="$3"$5>', - $content - ); -}
\ No newline at end of file |
