Changeset 11325


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

correct regex, parse on notification email and admin page

Location:
extensions/reply_to
Files:
2 edited

Legend:

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

    r11299 r11325  
    2929  add_event_handler('render_comment_content', 'replyto_parse_picture', 60);
    3030}
     31// parse comment admin side (picture section)
     32else if (script_basename() == 'admin' AND isset($_GET['page']) AND $_GET['page'] == 'comments' AND ( !isset($_GET['section']) OR $_GET['section'] == 'pictures' ) )
     33{
     34  add_event_handler('render_comment_content', 'replyto_parse_picture', 60);
     35}
    3136// add link and parse on album page (compatibility with Comment on Albums)
    3237else if (script_basename() == 'index')
     
    3944  add_event_handler('render_comment_content', 'replyto_parse_album', 60);
    4045}
     46// parse comment admin side (album section)
     47else if (script_basename() == 'admin' AND isset($_GET['page']) AND $_GET['page'] == 'comments' AND $_GET['section'] == 'albums')
     48{
     49  add_event_handler('render_comment_content', 'replyto_parse_album', 60);
     50}
    4151   
    4252?>
  • 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.