Ignore:
Timestamp:
Jun 11, 2011, 11:06:33 PM (13 years ago)
Author:
mistic100
Message:

correct regex, parse on notification email and admin page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/reply_to/reply_to.inc.php

    r11299 r11325  
    2727  {
    2828    add_event_handler('render_comment_content', 'replyto_parse_picture', 60);
     29    add_event_handler('user_comment_insertion', 'replyto_parse_picture_mail');
    2930    if ( !is_a_guest() OR $conf['comments_forall'] )
    3031    {
     
    4041  {
    4142    add_event_handler('render_comment_content', 'replyto_parse_album', 60);
     43    add_event_handler('user_comment_insertion', 'replyto_parse_album_mail');
    4244    if ( !is_a_guest() OR $conf['comments_forall'] )
    4345    {
     
    8082{if not isset($comment.IN_EDIT)}
    8183<div class="actions" style="float:right;">
    82   <a title="{\'reply to this comment\'|@translate}" class="replyTo" onclick="replyto(\'{$comment.ID}\', \'{$comment.AUTHOR}\');">&nbsp;</a>
     84  <a href="#commentform" title="{\'reply to this comment\'|@translate}" class="replyTo" onclick="replyto(\'{$comment.ID}\', \'{$comment.AUTHOR}\');">&nbsp;</a>
    8385</div>
    8486{/if}'
     
    9193.$search[2];
    9294
     95  $search[3] = '<legend>{\'Add a comment\'|@translate}</legend>';
     96  $replace[3] = $search[3].'
     97<a name="commentform"></a>';
     98
    9399  return str_replace($search, $replace, $content);
    94100}
     
    100106function replyto_parse_picture($comment)
    101107{
    102   if (preg_match('#\[reply=([1-9]+)\](.*)\[/reply\]#si', $comment, $matches))
     108  if (preg_match('#\[reply=([0-9]+)\]([^\[\]]*)\[/reply\]#i', $comment, $matches))
    103109  {
    104110    // picture informations
     
    141147      ));                 
    142148     
    143       $search = "#\[reply=([1-9]+)\](.*)\[/reply\]#si";
    144       $replace = '@ <a href="'.$image['url'].'#comment-$1">$2</a> :';
     149      $search = "#\[reply=([0-9]+)\]([^\[\]]*)\[/reply\]#i";
     150      $replace = '@ <a href="'.get_absolute_root_url().$image['url'].'#comment-$1">$2</a> :';
    145151    }
    146152    else
    147153    {
    148       $search = "#\[reply=([1-9]+)\](.*)\[/reply\]#si";
     154      $search = "#\[reply=([0-9]+)\]([^\[\]]*)\[/reply\]#i";
    149155      $replace = '';
    150156    }
     
    160166function replyto_parse_album($comment)
    161167{
    162   if (preg_match('#\[reply=([1-9]+)\](.*)\[/reply\]#si', $comment, $matches))
     168  if (preg_match('#\[reply=([0-9]+)\]([^\[\]]*)\[/reply\]#i', $comment, $matches))
    163169  { 
    164170    // check if the comment is really an album comment
    165171    // (both comments_on_albums script and default comments script are executed...
    166172    //  with the same 'render_comment_content' event)
     173    ## THIS CAN INDUCE ERRORS, MUST FIND A BETTER WAY
    167174    $query = '
    168175SELECT id
     
    199206      ));                 
    200207   
    201       $search = "#\[reply=([1-9]+)\](.*)\[/reply\]#si";
    202       $replace = '@ <a href="'.$category['url'].'#comment-$1">$2</a> :';
     208      $search = "#\[reply=([0-9]+)\]([^\[\]]*)\[/reply\]#i";
     209      $replace = '@ <a href="'.get_absolute_root_url().$category['url'].'#comment-$1">$2</a> :';
    203210    }
    204211    else
    205212    {
    206       $search = "#\[reply=([1-9]+)\](.*)\[/reply\]#si";
     213      $search = "#\[reply=([0-9]+)\]([^\[\]]*)\[/reply\]#i";
    207214      $replace = '';
    208215    }
     
    216223}
    217224
     225/**
     226 * Replace BBcode tag by a link in notification mails
     227 */
     228function replyto_parse_picture_mail($comment)
     229{
     230  $comment['content'] = replyto_parse_picture($comment['content']);
     231  var_dump($comment);
     232  return $comment;
     233}
     234
     235function replyto_parse_album_mail($comment)
     236{
     237  $comment['content'] = replyto_parse_album($comment['content']);
     238  return $comment;
     239}
     240
    218241?>
Note: See TracChangeset for help on using the changeset viewer.