mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-05 17:32:25 +02:00
- 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:
@@ -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;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user