[Solution] Spoiler not works

kj2
1
Joined: December 20th, 2016, 4:43 pm

December 20th, 2016, 5:16 pm

Note: I speak spanish and understand english, but I not have practice speaking this second, then sorry for the rarely diction on this post (I'm not using Google translate, because it is worse xD).

I use SMF with Quick Spoiler mod (with some changes made by me), but the spoilers not works :(.

First, Tapatalk don't support spoiler for SMF:

https://support.tapatalk.com/threads/su ... post-99323

But have support if "spoiler" bbcode is on the post (you can find it on the source code of the tapatalk mod), then we need modify Quick Spoiler for works with this tapatalk mod:

First edit the file "Sources/Sub-QuickSpoiler.php" and search this:

Code: Select all

if (allowedTo('view_spoiler')) {
            $codes[] = array(
                'tag'         => 'spoiler',
                'before'      => '<div class="sp-wrap"><div class="sp-head sp-open">' . (!empty($modSettings['qs_title']) ? $modSettings['qs_title'] : $txt['quick_spoiler']) . '</div><div class="sp-body">',
                'after'       => '</div></div>',
                'block_level' => true,
            );
            $codes[] = array(
                'tag'         => 'spoiler',
                'type'        => 'unparsed_equals',
                'before'      => '<div class="sp-wrap"><div class="sp-head sp-open">$1</div><div class="sp-body">',
                'after'       => '</div></div>',
                'block_level' => true,
            );
        }
        else {
            $codes[] = array(
                'tag'         => 'spoiler',
                'type'        => 'unparsed_content',
                'content'     => '<div class="sp-wrap centertext">' . $txt['qs_no_spoiler_sorry'] . '</div>',
                'block_level' => true,
            );
            $codes[] = array(
                'tag'         => 'spoiler',
                'type'        => 'unparsed_equals_content',
                'content'     => '<div class="sp-wrap centertext">' . $txt['qs_no_spoiler_sorry'] . '</div>',
                'block_level' => true,
            );
        }
And change it for this:

Code: Select all

if (defined('IN_MOBIQUO')){ // Comprobamos si está usando tapatalk
  if (allowedTo('view_spoiler')) {
           $codes[] = array(
                'tag'         => 'spoiler',
                'before'      => '[spoiler]',
                'after'       => '[/spoiler]',
                'block_level' => true,
            );
            $codes[] = array(
                'tag'         => 'spoiler',
                'type'        => 'unparsed_equals',
                'before'      => '[spoiler]',
                'after'       => '[/spoiler]',
                'block_level' => true,
            );
        }
        else {
            $codes[] = array(
                'tag'         => 'spoiler',
                'type'        => 'unparsed_content',
                'content'     => '[spoiler]' . $txt['qs_no_spoiler_sorry'] . '[/spoiler]',
                'block_level' => true,
            );
            $codes[] = array(
                'tag'         => 'spoiler',
                'type'        => 'unparsed_equals_content',
                'content'     => '[spoiler]' . $txt['qs_no_spoiler_sorry'] . '[/spoiler]',
                'block_level' => true,
            );
        }
    } else{
        if (allowedTo('view_spoiler')) {
            $codes[] = array(
                'tag'         => 'spoiler',
                'before'      => '<div class="sp-wrap"><div class="sp-head sp-open">' . (!empty($modSettings['qs_title']) ? $modSettings['qs_title'] : $txt['quick_spoiler']) . '</div><div class="sp-body">',
                'after'       => '</div></div>',
                'block_level' => true,
            );
            $codes[] = array(
                'tag'         => 'spoiler',
                'type'        => 'unparsed_equals',
                'before'      => '<div class="sp-wrap"><div class="sp-head sp-open">$1</div><div class="sp-body">',
                'after'       => '</div></div>',
                'block_level' => true,
            );
        }
        else {
            $codes[] = array(
                'tag'         => 'spoiler',
                'type'        => 'unparsed_content',
                'content'     => '<div class="sp-wrap centertext">' . $txt['qs_no_spoiler_sorry'] . '</div>',
                'block_level' => true,
            );
            $codes[] = array(
                'tag'         => 'spoiler',
                'type'        => 'unparsed_equals_content',
                'content'     => '<div class="sp-wrap centertext">' . $txt['qs_no_spoiler_sorry'] . '</div>',
                'block_level' => true,
            );
        }
    }
But have a problem, the tapatalk only show "spoiler for hidden" on some spoilers, the problem is explained here:

https://support.tapatalk.com/threads/sp ... ule.20549/

The tapatalk mod only works with "Spolier" (with capital "S"), but this is a error :/, then now we need mod the tapatalk mod for ignore upper/down case for the bbcode:

Edit the file "mobiquo/mobiquo_common.php" and go to the lines 607 and 608...

Code: Select all

    $message = str_replace('[spoiler]', "\nSpoiler for Hiden:\n[quote]", $message);
    $message = str_replace('[/spoiler]', '[/quote]', $message);
...and comment it.

Code: Select all

    //$message = str_replace('[spoiler]', "\nSpoiler for Hiden:\n[quote]", $message);
    //$message = str_replace('[/spoiler]', '[/quote]', $message);
And now all spoilers works fine :D.

User avatar
moledj
Joined: October 29th, 2012, 3:44 pm

December 20th, 2016, 5:20 pm

good finding!
we will check to make native support to it in our next plugin, but thank you in find this solution and share it with the community

Mil gracias ;)

User avatar
Shambles
Joined: October 20th, 2010, 5:28 pm

December 20th, 2016, 5:42 pm

Excellent post and thanks, @kj2