XF 2.1 Reactions

I think we just have to adjust the RegEx. Please post the both source codes: The one where the replacement should happen and the one where it should not.
 
Or maybe better: Change the overwritten function name form fnReaction to fnReact and see what happens :)
 
Where it shouldn't happen,
HTML:
<span class="hScroller-scroll is-calculated" style="margin-bottom: -47px;">
                        
                            <a class="tabs-tab tabs-tab--reaction0 is-active" role="tab" id="" aria-selected="true">
                                
                                    <bdi>All</bdi> (76)
                                
                            </a>
                        
                            <a class="tabs-tab tabs-tab--reaction1" role="tab" id="reaction-1">
                                
                                    <span class="reaction reaction--small reaction--1" data-reaction-id="1"><i aria-hidden="true"></i><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="reaction-sprite js-reaction" alt="Like" title="Like"> <span class="reaction-text js-reactionText"> React</span></span>
                                
                            </a>
                        
                            <a class="tabs-tab tabs-tab--reaction2" role="tab" id="reaction-2">
                                
                                    <span class="reaction reaction--small reaction--2" data-reaction-id="2"><i aria-hidden="true"></i><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="reaction-sprite js-reaction" alt="Love" title="Love"> <span class="reaction-text js-reactionText"> React</span></span>
                                
                            </a>
                        
                            <a class="tabs-tab tabs-tab--reaction3" role="tab" id="reaction-3">
                                
                                    <span class="reaction reaction--small reaction--3" data-reaction-id="3"><i aria-hidden="true"></i><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="reaction-sprite js-reaction" alt="Haha" title="Haha"> <span class="reaction-text js-reactionText"> React</span></span>
                                
                            </a>
                        
                            <a class="tabs-tab tabs-tab--reaction4" role="tab" id="reaction-4">
                                
                                    <span class="reaction reaction--small reaction--4" data-reaction-id="4"><i aria-hidden="true"></i><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="reaction-sprite js-reaction" alt="Wow" title="Wow"> <span class="reaction-text js-reactionText"> React</span></span>
                                
                            </a>
                        
                    </span>

And here,
HTML:
<div class="contentRow-main">
                        


    <div class="contentRow-title">
        
            <a href="/members/max-taxable.3/" class="username " dir="auto" data-user-id="3" data-xf-init="member-tooltip" id="js-XFUniqueId34"><span class="username--staff username--moderator username--admin">Max Taxable</span></a> reacted to your post in the thread <a href="/posts/81246/">Spaminator 1.0.0 Alpha 1</a> with <span class="reaction reaction--medium has-reaction reaction--2" data-reaction-id="2"><i aria-hidden="true"></i><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="reaction-sprite js-reaction" alt="Love" title="Love"> <span class="reaction-text js-reactionText"> React</span></span>.
        
    </div>

    <div class="contentRow-snippet">Okay, changed for the next version.</div>

    <div class="contentRow-minor"><time class="u-dt" dir="auto" datetime="2019-05-07T18:08:31-0500" data-time="1557270511" data-date-string="May 7, 2019" data-time-string="6:08 PM" title="May 7, 2019 at 6:08 PM">Tuesday at 6:08 PM</time></div>

                    </div>

Where it should happen,
HTML:
<a href="/posts/81089/react?reaction_id=1" class="reaction reaction--small actionBar-action actionBar-action--reaction reaction--imageHidden reaction--1" data-reaction-id="1" data-xf-init="reaction" data-reaction-list="< .js-post | .js-reactionsList" id="js-XFUniqueId14"><i aria-hidden="true"></i><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="reaction-sprite js-reaction" alt="Like" title="Like"> <span class="reaction-text js-reactionText"> React</span></a>
 
Strange, this should work:
PHP:
public function fnReact($templater, &$escape, array $config)
{
    $parent = parent::fnReact($templater, $escape, $config);

    $pattern = '#<span class="reaction-text js-reactionText">(.*)</span>#U';

    $replace = '<span class="reaction-text js-reactionText"><bdi>' . \XF::phrase('ozzmodz_reactionlike_react') .'</bdi></span>';

    $output = preg_replace($pattern, $replace, $parent);

    return $output;
}

(added <bdi>-Tag again)
 
The issue is that the reaction bar and the reaction list uses the exact same code.

If I were to make this add-on, I'd extend the \XF\Template\Compiler\Tag\React tag to add a label override parameter, but we are getting into some complex areas there.

Liam
 
Strange, this should work:
PHP:
public function fnReact($templater, &$escape, array $config)
{
    $parent = parent::fnReact($templater, $escape, $config);

    $pattern = '#<span class="reaction-text js-reactionText">(.*)</span>#U';

    $replace = '<span class="reaction-text js-reactionText"><bdi>' . \XF::phrase('ozzmodz_reactionlike_react') .'</bdi></span>';

    $output = preg_replace($pattern, $replace, $parent);

    return $output;
}

(added <bdi>-Tag again)


That seems to have solved it. Thank you once again.
 
Top Bottom