<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_search
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
 * @license      GNU General Public License version 2 or later; see LICENSE.txt
 */
/**
 * @package jDownloads
 * @version 4.0
 * Some parts from the search component 3.x (and search content plugin) adapted and modified to can use it in jDownloads 4.x as an internal search function.
 */

defined('_JEXEC') or die;

use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;

$result_count = $this->pagination->limitstart;

?>

<div class="search-results<?php echo $this->pageclass_sfx; ?> container pb-4">
    <div class="row g-3">
    <?php foreach ($this->results as $result) : ?>
        <div class="col-12">
            <article class="card border-0 shadow-sm h-100">
                <div class="card-body">
                    <div class="d-flex flex-wrap align-items-start gap-3 mb-2">
                        <span class="badge text-bg-light border d-inline-flex align-items-center justify-content-center lh-sm"><?php echo ++$result_count; ?></span>
                        <div class="flex-grow-1">
                            <h2 class="h5 mb-2 result-title">
                                <?php if ($result->href) : ?>
                                    <a class="link-primary text-decoration-none" href="<?php echo Route::_($result->href); ?>"<?php if ($result->browsernav == 1) : ?> target="_blank" rel="noopener"<?php endif; ?>><?php echo $result->title; ?></a>
                                <?php else : ?>
                                    <?php echo $result->title; ?>
                                <?php endif; ?>
                            </h2>
                            <?php if ($result->section) : ?>
                            <div class="mb-2 text-body-secondary small"><?php echo $this->escape($result->section); ?></div>
                            <?php endif; ?>
                            <div class="result-text"><?php echo $result->text; ?></div>
                            <?php if ($this->params->get('show_date') == 1) : ?>
                            <div class="mt-3 text-body-secondary small"><?php echo Text::sprintf('JGLOBAL_CREATED_DATE_ON', $result->created); ?></div>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
            </article>
        </div>
    <?php endforeach; ?>
    </div>

    <div class="mt-4 d-flex justify-content-center">
        <?php echo $this->pagination->getPagesLinks(); ?>
    </div>
</div>
