View file MMO-Hide-2.3.4/upload/src/addons/MMO/Hide/BbCode/Tag/HidePosts.php

File size: 1.05Kb
<?php

namespace MMO\Hide\BbCode\Tag;

use MMO\CoreLib\Util\Plural;
use MMO\Hide\BbCode\AbstractTag;

class HidePosts extends AbstractTag
{
    /**
     * @inheritDoc
     */
    public function render($content, array $tagChildren, $tagOption, array $tag, array $options)
    {
        $requiredPosts = \intval($tagOption);
        $currentPosts = $this->visitor()->message_count;

        $params = [
            'need_posts' => Plural::choice('mh_tag_posts_need_posts', $requiredPosts),
            'now_posts'  => Plural::choice('mh_tag_posts_now_posts', $currentPosts)
        ];

        $title = [
            'visible' => $this->getTitleVisible('mh_tag_posts', $params),
            'hidden'  => $this->getTitleHidden('mh_tag_posts', $params)
        ];

        return $this->renderTemplate($content, $title, [
            'canView' => $requiredPosts <= $currentPosts || $this->visitor()->canIgnoreHideTagCondition($tag['tag'], $requiredPosts),
            'options' => $options,
            'tag' => $tag['tag']
        ]);
    }
}