<?php

namespace Signteer\Web\Admin\Page;

use Plainwork\Core\App;
use Plainwork\Http\Request;
use Plainwork\Ui\Html;

final class AboutPage
{
    public $app = App::class;

    public function __invoke(Request $request)
    {
        $isPro = class_exists(\Signteer\ProBoot::class);

        $html = new Html();

        $ret = $html->dl()->asTable();

        $v = $this->app->name();
        if ($isPro) {
            $v .= ' Pro';
        }

        $v = '<a href="https://www.signteer.com/" target="_blank">' . $v . '</a>';
        $ret->add('__Plugin name__', $v);

        $v = $this->app->version();
        $ret->add('__Version__', $v);

        if (!$isPro) {
            $promo = 'Enjoying our plugin? Please consider rating it 5-stars <a href="https://wordpress.org/support/plugin/signteer/reviews/#new-post" target="_blank">on WordPress</a>. Thanks!'; 
            $promo2 = '<a class="button" href="https://www.signteer.com/" target="_blank">Go to plugin\'s homepage</a>'; 
            $ret = $html->blockList($ret, $promo)->largeSpacing();
        }

        $ret = $html->main($ret);
        $ret->title = $html->el('h1', '__About__');
        // $ret->afterContentMenu->add($html->link('uninstall', [], '__Uninstall__'));

        return $ret;
    }
}
