Changeset 180


Ignore:
Timestamp:
Oct 5, 2003, 3:43:00 PM (21 years ago)
Author:
z0rglub
Message:

Support of special syntax to underline, emphasis or italic words in users
comments

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/comments.php

    r163 r180  
    9191      $displayed_date = format_date( $subrow['date'], 'unix', true );
    9292      $vtp->setVar( $sub, 'comment.date', $displayed_date );
    93       $vtp->setVar( $sub, 'comment.content', nl2br( $subrow['content'] ) );
     93
     94      $content = nl2br( $subrow['content'] );
     95     
     96      // replace _word_ by an underlined word
     97      $pattern = '/_([^\s]*)_/';
     98      $replacement = '<span style="text-decoration:underline;">\1</span>';
     99      $content = preg_replace( $pattern, $replacement, $content );
     100     
     101      // replace *word* by a bolded word
     102      $pattern = '/\*([^\s]*)\*/';
     103      $replacement = '<span style="font-weight:bold;">\1</span>';
     104      $content = preg_replace( $pattern, $replacement, $content );
     105
     106      // replace /word/ by an italic word
     107      $pattern = '/\/([^\s]*)\//';
     108      $replacement = '<span style="font-style:italic;">\1</span>';
     109      $content = preg_replace( $pattern, $replacement, $content );
     110
     111      $vtp->setVar( $sub, 'comment.content', $content );
     112
    94113      $vtp->addSession( $sub, 'delete' );
    95114      $url = './admin.php?page=comments';
  • trunk/comments.php

    r179 r180  
    109109      $displayed_date = format_date( $subrow['date'], 'unix', true );
    110110      $vtp->setVar( $handle, 'comment.date', $displayed_date );
    111       $vtp->setVar( $handle, 'comment.content', nl2br( $subrow['content'] ) );
     111
     112      $content = nl2br( $subrow['content'] );
     113     
     114      // replace _word_ by an underlined word
     115      $pattern = '/_([^\s]*)_/';
     116      $replacement = '<span style="text-decoration:underline;">\1</span>';
     117      $content = preg_replace( $pattern, $replacement, $content );
     118     
     119      // replace *word* by a bolded word
     120      $pattern = '/\*([^\s]*)\*/';
     121      $replacement = '<span style="font-weight:bold;">\1</span>';
     122      $content = preg_replace( $pattern, $replacement, $content );
     123
     124      // replace /word/ by an italic word
     125      $pattern = '/\/([^\s]*)\//';
     126      $replacement = '<span style="font-style:italic;">\1</span>';
     127      $content = preg_replace( $pattern, $replacement, $content );
     128     
     129      $vtp->setVar( $handle, 'comment.content', $content );
    112130      $vtp->closeSession( $handle, 'comment' );
    113131    }
  • trunk/picture.php

    r118 r180  
    684684    $vtp->setVar( $handle, 'comment.date',
    685685                  format_date( $row['date'], 'unix', true ) );
    686     $vtp->setVar( $handle, 'comment.content', nl2br( $row['content'] ) );
     686    $content = nl2br( $row['content'] );
     687
     688    // replace _word_ by an underlined word
     689    $pattern = '/_([^\s]*)_/';
     690    $replacement = '<span style="text-decoration:underline;">\1</span>';
     691    $content = preg_replace( $pattern, $replacement, $content );
     692
     693    // replace *word* by a bolded word
     694    $pattern = '/\*([^\s]*)\*/';
     695    $replacement = '<span style="font-weight:bold;">\1</span>';
     696    $content = preg_replace( $pattern, $replacement, $content );
     697
     698    // replace /word/ by an italic word
     699    $pattern = '/\/([^\s]*)\//';
     700    $replacement = '<span style="font-style:italic;">\1</span>';
     701    $content = preg_replace( $pattern, $replacement, $content );
     702   
     703    $vtp->setVar( $handle, 'comment.content', $content );
    687704    if ( $user['status'] == 'admin' )
    688705    {
Note: See TracChangeset for help on using the changeset viewer.