{namespace vh=Newland\NeosViewHelpers\ViewHelpers}
{namespace common=Newland\Toubiz\Common\Neos\ViewHelpers}
{namespace poi=Newland\Toubiz\Poi\Neos\ViewHelpers}


<f:if condition="{common:context()} != 'Production'">
    <!--
        sourceInformation slot.
        Modify prototype(Newland.Toubiz.Poi.Neos:Slot.DetailSourceInformation) to adjust rendering

        If you want to hide this section for certain clients you can do so as follows:

        prototype(Newland.Toubiz.Poi.Neos:Slot.DetailSourceInformation) {
                @if.isSpecificClient=${article.flatAttributes.clientId[0] != '08052682-ef35-47e8-aade-1292690f36c2'}
        }

        <f:if condition="{article.flatAttributes.clientId}">
            The clientId of the current article is `{article.flatAttributes.clientId}`
        </f:if>
    -->
</f:if>

<poi:collection.attributes.notAllEmpty strings="{
    0: article.flatAttributes.authorName,
    1: article.flatAttributes.clientName,
    2: article.flatAttributes.license
}">
    <vh:render section="content" arguments="{_all}" />
</poi:collection.attributes.notAllEmpty>

<f:section name="content">
    <h2 class="mt-0 mb-2 text-xl">
        {vh:translate(id: 'source.header', package: 'Newland.Toubiz.Poi.Neos', source: 'Views/Show')}
    </h2>

    <div
        class="tb-source"
        itemprop="subjectOf"
        itemscope
        itemtype="http://schema.org/CreativeWork">

        <div class="tb-source__text flex">
            <vh:render section="clientImage" arguments="{_all}" />
            <div>
                <vh:render section="clientName" arguments="{_all}" />
                <br />
                <vh:render section="author" arguments="{_all}" />
                <br />
                <vh:render section="license" arguments="{_all}" />
            </div>
        </div>
    </div>
</f:section>

<f:section name="author">
    <f:if condition="{article.flatAttributes.authorName}">
        <span itemprop="author">{article.flatAttributes.authorName}</span>
    </f:if>
</f:section>

<f:section name="clientImage">
    <f:if condition="{article.flatAttributes.clientImage}">
        <img
            src="{article.flatAttributes.clientImage}"
            class="tb-source__image mr-4"
        />
    </f:if>
</f:section>

<f:section name="clientName">
    <f:if condition="{article.flatAttributes.clientName}">
        <f:if condition="{article.flatAttributes.clientUrl}">
            <f:then>
                <a href="{article.flatAttributes.clientUrl}" itemprop="sourceOrganization">
                    {article.flatAttributes.clientName}
                </a>
            </f:then>
            <f:else>
                <strong itemprop="sourceOrganization">
                    {article.flatAttributes.clientName}
                </strong>
            </f:else>
        </f:if>
    </f:if>
</f:section>

<f:section name="license">
    <f:if condition="{article.flatAttributes.license}">
        <f:if condition="{article.flatAttributes.licenseUrl}">
            <f:then>
                <a href="{article.flatAttributes.licenseUrl}">
                    {article.flatAttributes.license}
                </a>
            </f:then>
            <f:else>
                <span>
                    {article.flatAttributes.license}
                </span>
            </f:else>
        </f:if>
    </f:if>
</f:section>
