<?php
/**
 * Maho
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2024 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/** @var Mage_Tag_Block_Customer_View $this */
?>
<div class="page-title">
    <h1><?= $this->__('My Tags') ?></h1>
</div>
<?= $this->getMessagesBlock()->toHtml() ?>
<p class="my-tag-edit">
    <a href="#" title="<?= Mage::helper('core')->quoteEscape($this->__('Delete')) ?>" onclick="if(confirm('<?= Mage::helper('core')->quoteEscape($this->__('Are you sure you want to delete this tag?'), true) ?>')) window.location='<?= $this->getTagInfo()->getRemoveTagUrl() ?>'; return false;" class="button btn-remove"><span><?= $this->__('Delete') ?></span></a>
    <?= $this->__('<strong>Tag Name:</strong> %s', $this->escapeHtml($this->getTagInfo()->getName())) ?>
</p>
<div class="clearer"></div>
<?= $this->getToolbarHtml() ?>
<table class="data-table" id="my-tags-table">
<?php if(count($this->getMyProducts()) > 0): ?>
    <?php $params[Mage_Core_Model_Url::FORM_KEY] = $this->getFormKey() ?>
    <col width="1" />
    <col />
    <col width="1" />
    <tbody>
    <?php $iterator = 0 ?>
    <?php foreach($this->getMyProducts() as $_product): ?>
        <tr<?php if($iterator % 2 == 0): ?> class="odd"<?php $iterator++;endif; ?>>
            <td><a href="<?= $_product->getProductUrl() ?>" title="<?= $this->escapeHtml($_product->getName()) ?>" class="product-image"><img src="<?= $this->helper('catalog/image')->init($_product, 'small_image')->resize(100, 100) ?>" width="100" height="100" alt="<?= $this->escapeHtml($_product->getName()) ?>" /></a></td>
            <td>
                <h2 class="product-name"><a href="<?= $_product->getProductUrl() ?>"><?= $this->escapeHtml($_product->getName()) ?></a></h2>
                <?= $this->getReviewsSummaryHtml($_product, 'short') ?>
                <?= $this->getPriceHtml($_product) ?>
                <?= $this->escapeHtml($_product->getDescription()) ?>
            </td>
            <td>
                <?php if($_product->isSaleable()): ?>
                    <?php $params['product'] = $_product->getId(); ?>
                    <button type="button" title="<?= Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?= $this->getUrl('checkout/cart/add', $params) ?>')"><?= $this->__('Add to Cart') ?></button>
                <?php endif ?>
                <?php if ($this->helper('wishlist')->isAllow()) : ?>
                <ul class="add-to-links">
                    <li>
                        <a href="#"
                           class="link-wishlist"
                           onclick="customFormSubmit(
                                   '<?= $this->getAddToWishlistUrlCustom($_product, false) ?>',
                                   '<?= $this->escapeHtml(json_encode(['form_key' => $params[Mage_Core_Model_Url::FORM_KEY]])) ?>',
                                   'post')">
                            <?= $this->__('Add to Wishlist') ?>
                        </a>
                    </li>
                </ul>
                <?php endif ?>
            </td>
        </tr>
    <?php endforeach ?>
    </tbody>
<?php else: ?>
    <tbody>
        <tr>
            <td>
                <?= $this->__("Unable to find any products tagged with '%s' in the current store", $this->escapeHtml($this->getTagInfo()->getName()) ) ?>
            </td>
        </tr>
    </tbody>
<?php endif ?>
</table>
<?= $this->getToolbarHtml() ?>
<div class="buttons-set">
    <p class="back-link"><a href="<?= $this->getUrl('*/*/') ?>"><small>&laquo; </small><?= $this->__('Back to Tags List') ?></a></p>
</div>
