{* Load global settings if not given from outside *}
{if empty($etGlobalSettings)}
    {et_getGlobalSettings assign="etGlobalSettings"}
{/if}
{$gpsrContext=$gpsrContext|default:'default'}
{$gpsrProduct=$gpsrProduct|default:null}
{$gpsrContent=$gpsrContent|default:null}
{$gpsrShowTitle=$gpsrShowTitle|default:false}
{if $gpsrProduct === null && !empty($Artikel)}
    {$gpsrProduct = $Artikel}
{/if}
{* Check gpsrSource first *}
{if !empty($etGlobalSettings.gpsrSource) && !empty($gpsrProduct) && $etGlobalSettings.gpsrSource !== 'none'}
    {* Render the actual GPSR content first, to determine if we should show anything for this product, in the first place. *}
    {if $gpsrContent === null}
        {capture name="etGpsrContent" nocache}{include file="widgets/snippets/gpsr_content.tpl" etGlobalSettings=$etGlobalSettings product=$gpsrProduct context=$gpsrContext}{/capture}
        {$gpsrContent=$smarty.capture.etGpsrContent}
    {/if}
    {* Display according to context and mode, or not at all if link. *}
    {$gpsrMode = 'immediate'}
    {if $gpsrContext === 'detail'}
        {$gpsrMode = $etGlobalSettings.gpsrDetailMode}
    {elseif $gpsrContext === 'slider'}
        {$gpsrMode = $etGlobalSettings.gpsrSliderMode}
    {elseif $gpsrContext === 'gallery'}
        {$gpsrMode = $etGlobalSettings.gpsrProductListGalleryMode}
    {elseif $gpsrContext === 'list'}
        {$gpsrMode = $etGlobalSettings.gpsrProductListListMode}
    {elseif $gpsrContext === 'cart'}
        {$gpsrMode = $etGlobalSettings.gpsrCartMode}
    {elseif $gpsrContext === 'freegift'}
        {$gpsrMode = $etGlobalSettings.gpsrFreegiftMode}
    {elseif $gpsrContext === 'wishlist'}
        {$gpsrMode = $etGlobalSettings.gpsrWishlistMode}
    {/if}
    {if !empty($smarty.capture.etGpsrContent) && $gpsrMode !== 'none'}
        {block name="et-gpsr"}
            <div class="{block name="et-gpsr-class"}et-gpsr et-gpsr-context-{$gpsrContext}{/block}">
                {if $gpsrMode === 'link'}
                    {block name="et-gpsr-link"}
                        <a href="{$gpsrProduct->cURLFull}" title="{$gpsrProduct->cKurzbezeichnung|unescape:'htmlall'|escape:'html'}" target="_blank">
                            {et_language key='et360_gpsr_link_title'}
                        </a>
                    {/block}
                {else}
                    {if $gpsrMode === 'collapse'}
                        {block name="et-gpsr-collapse-control"}
                            <a class="et-collapse link-discreet" data-toggle="collapse" href="#et-gpsr-content-{$gpsrProduct->kArtikel}" aria-expanded="false" aria-controls="et-gpsr-content-{$gpsrProduct->kArtikel}">
                                <span>{et_language key='et360_gpsr_collapse_title'}</span>
                                <i class='{et_getIcon key="collapseOpen"} et-collapse-open et-collapse-inline'></i>
                                <i class='{et_getIcon key="collapseClosed"} et-collapse-closed et-collapse-inline'></i>
                            </a>
                        {/block}
                    {/if}
                    {if $gpsrMode === 'modal'}
                        {block name="et-gpsr-modal-control"}
                            <a href="#et-gpsr-content-{$gpsrProduct->kArtikel}" data-toggle="modal" title="{et_language key='et360_gpsr_modal_title'}">
                                {et_language key='et360_gpsr_modal_title'}
                            </a>
                        {/block}
                    {/if}
                    {block name="et-gpsr-content"}
                        <div class="{block name="et-gpsr-content-class"}et-gpsr-content{if $gpsrMode === 'collapse'} collapse{/if}{if $gpsrMode === 'modal'} modal fade{/if}{/block}" id="et-gpsr-content-{$gpsrProduct->kArtikel}"
                            {if $gpsrMode === 'modal'}data-backdrop="static" tabindex="-1" aria-hidden="true"{/if}
                        >
                            {if $gpsrMode === 'modal'}
                                {block name="et-gpsr-modal"}
                                    <div class="modal-dialog modal-dialog-centered" role="document">
                                        <div class="modal-content">
                                            {block name="et-gpsr-modal-header"}
                                            <div class="modal-header">
                                                <div class="modal-title h5">{et_language key='et360_gpsr_modal_heading'} {$gpsrProduct->cKurzbezeichnung|unescape:'htmlall'|escape:'html'}</div>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="{lang key='close' section='account data'}">
                                                    <i class="{et_getIcon key="close"}"></i>
                                                </button>
                                            </div>
                                            {/block}
                                            {block name="et-gpsr-modal-body"}
                                            <div class="modal-body">
                                                {$gpsrContent}
                                            </div>
                                            {/block}
                                            {block name="et-gpsr-modal-footer"}{/block}
                                        </div>
                                    </div>
                                {/block}
                            {else}
                                {block name="et-gpsr-content-title"}
                                    {if $gpsrContext === 'detail'}
                                        {if $gpsrMode === 'description'}{block name="et-gpsr-content-title-description"}<div class="et-gpsr-description-title h3">{et_language key='et360_gpsr_description_title'}</div>{/block}{/if}
                                        {if $gpsrMode === 'descriptionShort'}{block name="et-gpsr-content-title-description-short"}<div class="et-gpsr-description-short-title">{et_language key='et360_gpsr_description_short_title'}</div>{/block}{/if}
                                    {else}
                                        {if $gpsrMode === 'immediate'}{block name="et-gpsr-content-title-immediate"}<div class="et-gpsr-immediate-title">{et_language key='et360_gpsr_immediate_title'}</div>{/block}{/if}
                                    {/if}
                                {/block}
                                {block name="et-gpsr-content-body"}
                                    {$gpsrContent}
                                {/block}
                            {/if}
                        </div>
                    {/block}
                {/if}
            </div>
        {/block}
    {/if}
{/if}