From 98b65edb831e95695cc840692ab8ad294478f80d Mon Sep 17 00:00:00 2001 From: z0rglub Date: Sat, 23 Oct 2004 17:56:46 +0000 Subject: - refactoring of comments.php - creation of function get_thumbnail_src used everywhere a thumbnail must be displayed - creation of function parse_comment_content (used in comments.php and picture.php) - concerning undefined index on arrays retrieved in database, instead of testing possibly unset values, use of @ operator (smarter...) - add pre tag in default.css stylesheet for debugging purpose (need to have left aligned text) git-svn-id: http://piwigo.org/svn/trunk@579 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_html.inc.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'include/functions_html.inc.php') diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php index a7752e4c2..454c4c24f 100644 --- a/include/functions_html.inc.php +++ b/include/functions_html.inc.php @@ -269,4 +269,35 @@ function get_html_menu_category($category) return $menu; } + +/** + * returns HTMLized comment contents retrieved from database + * + * newlines becomes br tags, _word_ becomes underline, /word/ becomes + * italic, *word* becomes bolded + * + * @param string content + * @return string + */ +function parse_comment_content($content) +{ + $content = nl2br($content); + + // replace _word_ by an underlined word + $pattern = '/_([^\s]*)_/'; + $replacement = '\1'; + $content = preg_replace($pattern, $replacement, $content); + + // replace *word* by a bolded word + $pattern = '/\*([^\s]*)\*/'; + $replacement = '\1'; + $content = preg_replace($pattern, $replacement, $content); + + // replace /word/ by an italic word + $pattern = '/\/([^\s]*)\//'; + $replacement = '\1'; + $content = preg_replace($pattern, $replacement, $content); + + return $content; +} ?> -- cgit v1.2.3