- 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
This commit is contained in:
z0rglub
2004-10-23 17:56:46 +00:00
parent 60ac6f180e
commit 98b65edb83
12 changed files with 322 additions and 392 deletions
+31
View File
@@ -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;
}
?>