Ignore:
Timestamp:
Oct 23, 2004, 7:56:46 PM (20 years ago)
Author:
z0rglub
Message:
  • 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)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_html.inc.php

    r572 r579  
    270270  return $menu;
    271271}
     272
     273/**
     274 * returns HTMLized comment contents retrieved from database
     275 *
     276 * newlines becomes br tags, _word_ becomes underline, /word/ becomes
     277 * italic, *word* becomes bolded
     278 *
     279 * @param string content
     280 * @return string
     281 */
     282function parse_comment_content($content)
     283{
     284  $content = nl2br($content);
     285 
     286  // replace _word_ by an underlined word
     287  $pattern = '/_([^\s]*)_/';
     288  $replacement = '<span style="text-decoration:underline;">\1</span>';
     289  $content = preg_replace($pattern, $replacement, $content);
     290 
     291  // replace *word* by a bolded word
     292  $pattern = '/\*([^\s]*)\*/';
     293  $replacement = '<span style="font-weight:bold;">\1</span>';
     294  $content = preg_replace($pattern, $replacement, $content);
     295 
     296  // replace /word/ by an italic word
     297  $pattern = '/\/([^\s]*)\//';
     298  $replacement = '<span style="font-style:italic;">\1</span>';
     299  $content = preg_replace($pattern, $replacement, $content);
     300
     301  return $content;
     302}
    272303?>
Note: See TracChangeset for help on using the changeset viewer.