<?php
    $title = $this->item['title'];
    $author = $this->item['author'];
    //$content = html_entity_decode($this->item['content']);
    $content = str_replace('&#34;', '"', $this->item['content']);
    $sourcetitle = $this->item['sourcetitle'];
    $this->viewHelper = new \helpers\ViewHelper();
    if (isset($this->search)) {
        $sourcetitle = $this->viewHelper->highlight($sourcetitle, $this->search);
        $title = $this->viewHelper->highlight($title, $this->search);
        $content = $this->viewHelper->highlight($content, $this->search);
    }

    if (\F3::get('camo_key') != '') {
        $content = $this->viewHelper->camoflauge($content);
    }

    $title = $this->viewHelper->lazyimg($title);
    $content = $this->viewHelper->lazyimg($content);
    $date = $this->viewHelper->dateago($this->item['datetime']);
?>
<div id="entry<?= $this->item['id']; ?>"
     data-entry-id="<?= $this->item['id']; ?>"
     data-entry-source="<?= $this->item['source']; ?>"
     data-entry-datetime="<?= $this->viewHelper->date_iso8601($this->item['datetime']); ?>"
     class="entry <?= $this->item['unread'] == 1 ? 'unread' : ''; ?>" role="article">

    <!-- icon -->
    <a href="<?= \helpers\Anonymizer::anonymize($this->item['link']); ?>" class="entry-icon" tabindex="-1">
        <?php if (strlen(trim($this->item['icon'])) > 0 && $this->item['icon'] != '0') : ?>
        <img src="<?= 'favicons/' . $this->item['icon']; ?>" alt="" >
        <?php endif; ?>
    </a>

    <!-- title -->
    <h2 class="entry-title"><?= $title; ?></h2>

    <span class="entry-tags">
        <?php foreach ($this->item['tags'] as $tag => $color) : ?>
            <span class="entry-tags-tag" style="color:<?= $color['foreColor']; ?>;background-color:<?= $color['backColor']; ?>"><?= $tag; ?></span>
        <?php endforeach; ?>
    </span>

    <!-- source -->
    <span class="entry-source"><?= $sourcetitle ?></span>

    <span class="entry-separator">&bull;</span>

    <!-- author -->
    <?php if (!empty($author)) : ?>
    <span class="entry-author"><?= $author; ?></span>
    <span class="entry-separator">&bull;</span>
    <?php endif; ?>

    <!-- datetime -->
    <a href="<?= \helpers\Anonymizer::anonymize($this->item['link']); ?>" class="entry-datetime" target="_blank" rel="noopener noreferrer">
        <?= $date; ?>
    </a>
    <a href="<?= $this->item['link']; ?>" class="entry-link"></a>

    <!-- thumbnail -->
    <?php if (isset($this->item['thumbnail']) && strlen(trim($this->item['thumbnail'])) > 0) : ?>
    <div class="entry-thumbnail">
        <a href="<?= \helpers\Anonymizer::anonymize($this->item['link']); ?>" target="_blank" rel="noopener noreferrer">
            <img src="<?= 'thumbnails/' . $this->item['thumbnail']; ?>" alt="<?= htmLawed(htmlspecialchars_decode($this->item['title']), ['deny_attribute' => '*', 'elements' => '-*']); ?>" />
        </a>
    </div>
    <?php endif; ?>

    <!-- content -->
    <div class="entry-content <?php if (strlen(strip_tags($content)) < 500) : ?>entry-content-nocolumns<?php endif; ?>">
        <?= $content; ?>

        <div class="entry-smartphone-share">
            <button class="entry-newwindow"><?= \F3::get('lang_open_window')?></button>
            <button class="entry-next"><?= \F3::get('lang_next')?></button>
        </div>
    </div>

    <!-- toolbar -->
    <div class="entry-toolbar">
        <button class="entry-starr <?= $this->item['starred'] == 1 ? 'active' : ''; ?>"><?= $this->item['starred'] == 1 ? \F3::get('lang_unstar') : \F3::get('lang_star'); ?></button>
        <button class="entry-unread <?= $this->item['unread'] == 1 ? 'active' : ''; ?>"><?= $this->item['unread'] == 1 ? \F3::get('lang_mark') : \F3::get('lang_unmark'); ?></button>
        <button class="entry-newwindow"><?= \F3::get('lang_open_window')?></button>
        <button class="entry-loadimages"><?= \F3::get('lang_load_img')?> </button>
        <button class="entry-next"><?= \F3::get('lang_next')?></button>
        <button class="entry-close"></button>
    </div>
</div>
