diff options
author | z0rglub <z0rglub@piwigo.org> | 2004-10-23 17:56:46 +0000 |
---|---|---|
committer | z0rglub <z0rglub@piwigo.org> | 2004-10-23 17:56:46 +0000 |
commit | 98b65edb831e95695cc840692ab8ad294478f80d (patch) | |
tree | 2b1ffe5ba3c8bc1fcdb209e8f8d793bd18e9dd1d /include/functions_html.inc.php | |
parent | 60ac6f180e9500c6fea0c872277f107f05d7d26d (diff) |
- 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
Diffstat (limited to 'include/functions_html.inc.php')
-rw-r--r-- | include/functions_html.inc.php | 31 |
1 files changed, 31 insertions, 0 deletions
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 = '<span style="text-decoration:underline;">\1</span>'; + $content = preg_replace($pattern, $replacement, $content); + + // replace *word* by a bolded word + $pattern = '/\*([^\s]*)\*/'; + $replacement = '<span style="font-weight:bold;">\1</span>'; + $content = preg_replace($pattern, $replacement, $content); + + // replace /word/ by an italic word + $pattern = '/\/([^\s]*)\//'; + $replacement = '<span style="font-style:italic;">\1</span>'; + $content = preg_replace($pattern, $replacement, $content); + + return $content; +} ?> |