<?php

namespace Anax\View;

$imgPrefix = $_SERVER["SERVER_NAME"] == "www.student.bth.se" ? "/~rasb14/dbwebb-kurser/oophp/me/kmom10/proj/htdocs/image/" : "/image/";

if (!$product) {
    return;
}


$tf = new \Rasb14\Util\TextFilter();
$imgSuffix = substr($product->image, -4) === '.gif' ? '': '?w=200';
?>
<?php if ($isAdmin) : ?>
<p>
    <a href="product/edit?id=<?= $product->id ?>">
        <i class="fas fa-edit"></i>
        Ändra
    </a>
    <a href="product/delete?id=<?= $product->id ?>">
        <i class="fas fa-trash-alt"></i>
        Ta bort
    </a>
</p>
<?php endif; ?>
<h1><?= $product->title ?></h1>
<img src="<?= $imgPrefix . $product->image . $imgSuffix ?>" alt="<?= $product->image ?>">
<p><?= $tf->markdown($product->description) ?></p>
<p>Webbsida: <a href="<?= $product->url ?>"><?= $product->url ?></a></p>
<p>Producent: <?= $product->producer ?></p>
<p>Kostnad: <?= $product->cost ?></p>
