<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis

/**
 * Product view template
 *
 * @var $block \Magento\Catalog\Block\Product\View\Description
 */
?>
<?php
$_helper = $this->helper(Magento\Catalog\Helper\Output::class);
$_product = $block->getProduct();

if (!$_product instanceof \Magento\Catalog\Model\Product) {
    return;
}

$_call = $block->getAtCall();
$_code = $block->getAtCode();
$_className = $block->getCssClass();
$_attributeLabel = $block->getAtLabel();
$_attributeType = $block->getAtType();
$_attributeAddAttribute = $block->getAddAttribute();
//MNM
$_showMoreInfoLink = $block->getShowMoreInfoLink() == '1';

$renderLabel = true;
// if defined as 'none' in layout, do not render
if ($_attributeLabel == 'none') {
    $renderLabel = false;
}

if ($_attributeLabel && $_attributeLabel == 'default') {
    $_attributeLabel = $_product->getResource()->getAttribute($_code)->getStoreLabel();
}
if ($_attributeType && $_attributeType == 'text') {
    $_attributeValue = ($_helper->productAttribute($_product, $_product->$_call(), $_code))
        ? $_product->getAttributeText($_code)
        : '';
} else {
    $_attributeValue = $_helper->productAttribute($_product, $_product->$_call(), $_code);
}
?>

<?php if ($_attributeValue ) :?>
<div class="product attribute <?= $block->escapeHtmlAttr($_className) ?>">
<?php //MNM
    if($_attributeLabel == 'Inhalt'): ?>
        <?php
        preg_match('/[0-9]+ml/', $_attributeValue, $matches);
        if(count($matches)) : ?>
    		<p><strong class="type"><?= $block->escapeHtml($_attributeLabel) ?>: <?= /* @noEscape */ $_attributeValue ?></strong></p>
    	<?php endif; ?>
    <?php else: ?>
        <?php if ($renderLabel) :?>
            <strong class="type"><?= $block->escapeHtml($_attributeLabel) ?></strong>
        <?php endif; ?>
    <?php //MNM - added nl2br ?>
        <div class="value" <?= /* @noEscape */ $_attributeAddAttribute ?>><?= /* @noEscape */ nl2br($_attributeValue) ?></div>
    <?php endif; ?>
<?php //MNM ?>
</div>
<?php //MNM ?>
<?php if($_showMoreInfoLink): ?>
<p><a href="javascript:;" onclick="jQuery('html,body').animate({scrollTop: jQuery('#more_information').offset().top - 100}, 'slow');"><?= __('Weitere Informationen') ?></a></p>
<?php endif;
//MNM ?>
<?php endif; ?>
