<?php

/**
 * This file is part of JohnCMS Content Management System.
 *
 * @copyright JohnCMS Community
 * @license   https://opensource.org/licenses/GPL-3.0 GPL-3.0
 * @link      https://johncms.com JohnCMS Project
 */

/**
 * @var \Johncms\Users\User $item
 */
?>

<div class="new_post-item">
    <div class="new_post-header d-flex justify-content-between">
        <div class="post-user">
            <?php if ($item->id !== $user->id): ?>
                <a href="<?= $item->profile_url ?>">
                    <div class="avatar">
                        <img src="<?= $this->avatar($item->id) ?>" class="img-fluid" alt=".">
                    </div>
                </a>
            <?php else: ?>
                <div class="avatar">
                    <img src="<?= $this->avatar($item->id) ?>" class="img-fluid" alt=".">
                </div>
            <?php endif; ?>
            <span class="user-status <?= $item->is_online ? 'online' : 'offline' ?> shadow"></span>
            <?php if (! empty($item->rights_name)): ?>
                <div class="post-of-user"
                     data-toggle="tooltip"
                     data-placement="top"
                     data-html="true"
                     title="<?= $item->rights_name ?>">
                    <svg class="icon-post">
                        <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>?4#check"/>
                    </svg>
                </div>
            <?php endif ?>
        </div>
        <div class="flex-grow-1 post-user d-flex flex-wrap overflow-hidden d-flex align-items-center">
            <div class="w-100">
                <?php if ($item->id !== $user->id): ?>
                    <a href="<?= $item->profile_url ?>"><span class="user-name d-inline mr-2"><?= $item->name ?></span></a>
                <?php else: ?>
                    <div class="user-name d-inline mr-2"><?= $item->name ?></div>
                <?php endif; ?>
            </div>
            <?php if (! empty($item->status)): ?>
                <div class="overflow-hidden text-nowrap text-dark-brown overflow-ellipsis small">
                    <span class="font-weight-bold"><?= $item->status ?></span>
                </div>
            <?php endif ?>
        </div>
    </div>
    <?php if (! empty($active_tab)): ?>
        <div class="post-body">
            <?php if ($active_tab === 'guest'): ?>
                <?= $item['postguest'] ?> <?= n__('post', 'posts', $item['postguest']) ?>
            <?php elseif ($active_tab === 'comm'): ?>
                <?= $item['komm'] ?> <?= n__('comment', 'comments', $item['komm']) ?>
            <?php elseif ($active_tab === 'karma'): ?>
                <?= $item['karma'] ?> <?= n__('point', 'points', $item['karma']) ?>
            <?php elseif ($active_tab === 'forum'): ?>
                <?= $item['postforum'] ?> <?= n__('post', 'posts', $item['postforum']) ?>
            <?php endif; ?>
        </div>
    <?php endif; ?>
    <div class="post-footer d-flex justify-content-between">
        <div class="overflow-hidden">
            <?php if ($user->rights): ?>
                <div class="post-meta d-flex">
                    <div class="user-ip mr-2">
                        <a href="<?= $item->search_ip_url ?>"><?= $item->ip ?></a>
                        <?php if (! empty($item->ip_via_proxy)): ?>
                            / <a href="<?= $item->search_ip_via_proxy_url ?>"><?= $item->ip_via_proxy ?></a>
                        <?php endif; ?>
                    </div>
                    <div class="useragent">
                        <span><?= $item->browser ?></span>
                    </div>
                </div>
            <?php endif; ?>
        </div>
        <div class="d-flex">
            <?php if (! empty($item['delete_url'])): ?>
                <a href="<?= $item['delete_url'] ?>"><?= __('Delete') ?></a>
            <?php endif; ?>
        </div>
    </div>
</div>
