View file upload/src/addons/MMO/Hide/BbCode/Tag/HideDays.php

File size: 867B
<?php

namespace MMO\Hide\BbCode\Tag;

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

class HideDays extends AbstractTag
{
    /**
     * @inheritDoc
     */
    public function render($content, array $tagChildren, $tagOption, array $tag, array $options)
    {
        $tagOptions = \intval($tagOption);
        $user_date = \intval((\XF::$time - $this->visitor()->register_date) / 86400);

        $title = \XF::phrase('mh_tag_days_x_y', [
            'need_days' => Plural::choice('mh_tag_days_need_days', $tagOptions),
            'now_days' => Plural::choice('mh_tag_days_now_days', $user_date)
        ])->render('raw');

        return $this->renderTemplate($content, $title, [
            'canView' => $tagOptions <= $user_date,
            'options' => $options,
            'tag' => $tag['tag']
        ]);
    }
}