<?php

use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\CoreExtension;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
use Twig\TemplateWrapper;

/* pages/admin.twig */
class __TwigTemplate_9953ee20db26573f1b0e2b3758f3423d extends Template
{
    private Source $source;
    /**
     * @var array<string, Template>
     */
    private array $macros = [];

    public function __construct(Environment $env)
    {
        parent::__construct($env);

        $this->source = $this->getSourceContext();

        $this->blocks = [
            'title' => [$this, 'block_title'],
            'content' => [$this, 'block_content'],
        ];
    }

    protected function doGetParent(array $context): bool|string|Template|TemplateWrapper
    {
        // line 1
        return "layout.twig";
    }

    protected function doDisplay(array $context, array $blocks = []): iterable
    {
        $macros = $this->macros;
        $this->parent = $this->load("layout.twig", 1);
        yield from $this->parent->unwrap()->yield($context, array_merge($this->blocks, $blocks));
    }

    // line 3
    /**
     * @return iterable<null|scalar|\Stringable>
     */
    public function block_title(array $context, array $blocks = []): iterable
    {
        $macros = $this->macros;
        yield "Admin – Gestion des articles";
        yield from [];
    }

    // line 5
    /**
     * @return iterable<null|scalar|\Stringable>
     */
    public function block_content(array $context, array $blocks = []): iterable
    {
        $macros = $this->macros;
        // line 6
        yield "<h2>Gestion des articles</h2>

<!-- Lien d'ajout -->
<p>
    <a href=\"/admin/edit/0\" class=\"btn btn-primary\">+ Ajouter un article</a>
</p>

";
        // line 13
        if ((($tmp =  !Twig\Extension\CoreExtension::testEmpty(($context["posts"] ?? null))) && $tmp instanceof Markup ? (string) $tmp : $tmp)) {
            // line 14
            yield "<table class=\"admin-table\">
    <thead>
        <tr>
            <th>Titre</th>
            <th>Créé le</th>
            <th>Modifié le</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
        ";
            // line 24
            $context['_parent'] = $context;
            $context['_seq'] = CoreExtension::ensureTraversable(($context["posts"] ?? null));
            foreach ($context['_seq'] as $context["_key"] => $context["post"]) {
                // line 25
                yield "        <tr>
            <td>
                <strong>";
                // line 27
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["post"], "title", [], "any", false, false, false, 27), "html", null, true);
                yield "</strong>
                ";
                // line 28
                if ((($tmp = CoreExtension::getAttribute($this->env, $this->source, $context["post"], "isRecent", [7], "method", false, false, false, 28)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) {
                    // line 29
                    yield "                <span class=\"badge badge-new\">Nouveau</span>
                ";
                }
                // line 31
                yield "            </td>
            <td>";
                // line 32
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, $context["post"], "createdAt", [], "any", false, false, false, 32), "d/m/Y H:i"), "html", null, true);
                yield "</td>
            <td>";
                // line 33
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, $context["post"], "updatedAt", [], "any", false, false, false, 33), "d/m/Y H:i"), "html", null, true);
                yield "</td>
            <td class=\"admin-actions\">
                <a href=\"/admin/edit/";
                // line 35
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["post"], "id", [], "any", false, false, false, 35), "html", null, true);
                yield "\" class=\"btn btn-sm btn-secondary\">Éditer</a>

                <form method=\"post\" action=\"/admin/delete/";
                // line 37
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["post"], "id", [], "any", false, false, false, 37), "html", null, true);
                yield "\" style=\"display:inline;\">
                    <button type=\"submit\" class=\"btn btn-sm btn-danger\"
                        onclick=\"return confirm('Supprimer cet article ?')\">
                        Supprimer
                    </button>
                </form>
            </td>
        </tr>
        ";
            }
            $_parent = $context['_parent'];
            unset($context['_seq'], $context['_key'], $context['post'], $context['_parent']);
            $context = array_intersect_key($context, $_parent) + $_parent;
            // line 46
            yield "    </tbody>
</table>
";
        } else {
            // line 49
            yield "<p><em>Aucun article à gérer.</em></p>
";
        }
        yield from [];
    }

    /**
     * @codeCoverageIgnore
     */
    public function getTemplateName(): string
    {
        return "pages/admin.twig";
    }

    /**
     * @codeCoverageIgnore
     */
    public function isTraitable(): bool
    {
        return false;
    }

    /**
     * @codeCoverageIgnore
     */
    public function getDebugInfo(): array
    {
        return array (  148 => 49,  143 => 46,  128 => 37,  123 => 35,  118 => 33,  114 => 32,  111 => 31,  107 => 29,  105 => 28,  101 => 27,  97 => 25,  93 => 24,  81 => 14,  79 => 13,  70 => 6,  63 => 5,  52 => 3,  41 => 1,);
    }

    public function getSourceContext(): Source
    {
        return new Source("", "pages/admin.twig", "/home/julien/Documents/Git/julien/blog-slim/views/pages/admin.twig");
    }
}
