<?php
/**
 * Maho
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2018-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_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content $this */
?>
<div id="<?= $this->getHtmlId() ?>">
    <ul class="messages">
        <li class="notice-msg">
            <ul>
                <li>
                    <?= Mage::helper('catalog')->__('Image type and information need to be specified for each store view.') ?>
                </li>
            </ul>
        </li>
    </ul>
    <div class="grid">
        <table cellspacing="0" class="data border" id="<?= $this->getHtmlId() ?>_grid" width="100%">
            <col width="1"/>
            <col/>
            <col width="70"/>
            <?php foreach ($this->getImageTypes() as $typeId => $type): ?>
                <col/>
            <?php endforeach ?>
            <col width="70"/>
            <col width="70"/>
            <thead>
            <tr class="headings">
                <th><?= Mage::helper('catalog')->__('Image') ?></th>
                <th><?= Mage::helper('catalog')->__('Label') ?></th>
                <th><?= Mage::helper('catalog')->__('Sort Order') ?></th>
                <?php foreach ($this->getImageTypes() as $typeId => $type): ?>
                    <th><?= $this->escapeHtml($type['label'], array('br')) ?></th>
                <?php endforeach ?>
                <th><?= Mage::helper('catalog')->__('Exclude') ?></th>
                <th class="last"><?= Mage::helper('catalog')->__('Remove') ?></th>
            </tr>
            </thead>
            <tbody id="<?= $this->getHtmlId() ?>_list">
            <tr id="<?= $this->getHtmlId() ?>_template" class="template no-display">
                <td class="cell-image">
                    <div class="place-holder"
                         onmouseover="<?= $this->getJsObjectName() ?>.loadImage('__file__')">
                        <span><?= Mage::helper('catalog')->__('Roll Over for preview') ?></span></div>
                    <img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" width="100" style="display:none;"
                         alt=""/></td>
                <td class="cell-label"><input
                            type="text" <?php if ($this->getElement()->getReadonly()): ?> disabled="disabled"<?php endif ?>
                            class="input-text"
                            onkeyup="<?= $this->getJsObjectName() ?>.updateImage('__file__')"
                            onchange="<?= $this->getJsObjectName() ?>.updateImage('__file__')"/></td>
                <td class="cell-position"><input
                            type="text" <?php if ($this->getElement()->getReadonly()): ?> disabled="disabled"<?php endif ?>
                            class="input-text validate-number"
                            onkeyup="<?= $this->getJsObjectName() ?>.updateImage('__file__')"
                            onchange="<?= $this->getJsObjectName() ?>.updateImage('__file__')"/></td>
                <?php foreach ($this->getImageTypes() as $typeId => $type): ?>
                    <td class="cell-<?= $typeId ?> a-center">
                        <input <?php if ($this->getElement()->getAttributeReadonly($typeId)) : ?> disabled="disabled" <?php endif ?>
                                type="radio" name="<?= $type['field'] ?>"
                                onclick="<?= $this->getJsObjectName() ?>.setProductImages('__file__')"
                                value="__file__"/></td>
                <?php endforeach ?>
                <td class="cell-disable a-center"><input
                            type="checkbox" <?php if ($this->getElement()->getReadonly()): ?> disabled="disabled"<?php endif ?>
                            onclick="<?= $this->getJsObjectName() ?>.updateImage('__file__')"/></td>
                <td class="cell-remove a-center last"><input
                            type="checkbox" <?php if ($this->getElement()->getReadonly()): ?> disabled="disabled"<?php endif ?>
                            onclick="<?= $this->getJsObjectName() ?>.updateImage('__file__')"/></td>
            </tr>
            <?php if ($this->hasUseDefault()): ?>
                <tr id="<?= $this->getHtmlId() ?>_default">
                    <td><?= Mage::helper('catalog')->__('Use Default Value') ?></td>
                    <td class="a-center">
                        <input id="use_default_label" class="default-checkbox" name="use_default[]" type="checkbox"
                            <?php if ($this->getElement()->getAttributeReadonly("label")): ?> disabled="disabled" <?php endif ?>
                               onclick="<?= $this->getJsObjectName() ?>.updateUseDefault(this)"
                               <?php if ($this->getElement()->usedDefault("label")): ?>checked<?php endif ?>
                               value="label"/>
                    </td>
                    <td>
                        <input id="use_default_position" class="default-checkbox" name="use_default[]" type="checkbox"
                            <?php if ($this->getElement()->getAttributeReadonly("position")): ?> disabled="disabled" <?php endif ?>
                               onclick="<?= $this->getJsObjectName() ?>.updateUseDefault(this)"
                               <?php if ($this->getElement()->usedDefault("position")): ?>checked<?php endif ?>
                               value="position"/>
                    </td>
                    <?php foreach ($this->getMediaAttributes() as $_attribute): ?>
                        <td class="a-center">
                            <?php if ($this->getElement()->canDisplayUseDefault($_attribute)): ?>
                                <input class="default-checkbox" name="use_default[]"
                                       type="checkbox" <?php if ($this->getElement()->getAttributeReadonly($_attribute->getAttributeCode())): ?> disabled="disabled" <?php endif ?>
                                       onclick="<?= $this->getJsObjectName() ?>.updateUseDefault()"
                                       <?php if ($this->getElement()->usedDefault($_attribute)): ?>checked<?php endif ?>
                                       value="<?= $_attribute->getAttributeCode() ?>"/>
                            <?php endif ?>
                        </td>
                    <?php endforeach ?>
                    <td>&nbsp;</td>
                    <td class="last">&nbsp;</td>
                </tr>
            <?php endif ?>
            <tr id="<?= $this->getHtmlId() ?>-image-0">
                <td class="cell-image"><?= Mage::helper('catalog')->__('No image') ?></td>
                <td class="cell-label"><input type="hidden"/>&nbsp;</td>
                <td class="cell-position"><input type="hidden"/>&nbsp;</td>
                <?php foreach ($this->getImageTypes() as $typeId => $type): ?>
                    <td class="cell-<?= $typeId ?> a-center"><input
                                type="radio" <?php if ($this->getElement()->getAttributeReadonly($typeId)) : ?> disabled="disabled" <?php endif ?>
                                name="<?= $type['field'] ?>"
                                onclick="<?= $this->getJsObjectName() ?>.setProductImages('no_selection')"
                                value="no_selection"/></td>
                <?php endforeach ?>
                <td class="cell-disable"><input type="hidden"/>&nbsp;</td>
                <td class="cell-remove last"><input type="hidden"/>&nbsp;</td>
            </tr>
            </tbody>
            <?php if (!$this->getElement()->getReadonly()): ?>
                <tfoot>
                <tr>
                    <td colspan="100" class="last" style="padding:8px">
                        <?= Mage::helper('catalog')->__('Maximum width and height dimension for upload image is %s.', Mage::getStoreConfig(Mage_Catalog_Helper_Image::XML_NODE_PRODUCT_MAX_DIMENSION)) ?>
                        <?= $this->getUploaderHtml() ?>
                    </td>
                </tr>
                </tfoot>
            <?php endif ?>
        </table>
    </div>
</div>
<input type="hidden" id="<?= $this->getHtmlId() ?>_save"
       name="<?= $this->getElement()->getName() ?>[images]"
       value="<?= $this->escapeHtml($this->getImagesJson()) ?>"/>
<input type="hidden" id="<?= $this->getHtmlId() ?>_save_image"
       name="<?= $this->getElement()->getName() ?>[values]"
       value="<?= $this->escapeHtml($this->getImagesValuesJson()) ?>"/>
<script type="text/javascript">
//<![CDATA[
var <?= $this->getJsObjectName() ?> = new Product.Gallery('<?= $this->getHtmlId() ?>', <?= $this->getImageTypesJson() ?>);
//]]>
</script>
