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

<f:comment>
    <!--
        This partial is responsible for rendering article attributes
        in various formats.
    -->
</f:comment>
<vh:render section="{type}Type" arguments="{_all}" />

<f:comment>
    <!--
        Renders a difficulty label.
    -->
</f:comment>
<f:section name="difficultyType">
    <f:switch expression="{attribute}">
        <f:case value="1">
            <span itemprop="additionalProperty" itemscope itemtype="http://schema.org/PropertyValue">
                <meta itemprop="name" content="label" />
                <span class="tb-badge tb-badge--easy" itemprop="value">
                    <vh:translate
                        id="property.attribute.{name}.values.{attribute}"
                        package="Newland.Toubiz.Poi.Neos"
                        source="Models/Article" />

                </span>
            </span>
        </f:case>
        <f:case value="2">
            <span itemprop="additionalProperty" itemscope itemtype="http://schema.org/PropertyValue">
                <meta itemprop="name" content="label" />
                <span class="tb-badge tb-badge--medium" itemprop="value">
                    <vh:translate
                        id="property.attribute.{name}.values.{attribute}"
                        package="Newland.Toubiz.Poi.Neos"
                        source="Models/Article" />

                </span>
            </span>
        </f:case>
        <f:case value="3">
            <span itemprop="additionalProperty" itemscope itemtype="http://schema.org/PropertyValue">
                <meta itemprop="name" content="label" />
                <span class="tb-badge tb-badge--hard" itemprop="value">
                    <vh:translate
                        id="property.attribute.{name}.values.{attribute}"
                        package="Newland.Toubiz.Poi.Neos"
                        source="Models/Article" />

                </span>
            </span>
        </f:case>
    </f:switch>
</f:section>


<f:comment>
    <!--
        Renders horizontal dots.
    -->
</f:comment>
<f:section name="tourRatingType">
    <ul class="tb-tour-rating">
        <li class="tb-tour-rating__item {f:if(condition: '{attribute} >= 1', then: 'tb-tour-rating__item--marked')}">
            •
        </li>
        <li class="tb-tour-rating__item {f:if(condition: '{attribute} >= 2', then: 'tb-tour-rating__item--marked')}">
            •
        </li>
        <li class="tb-tour-rating__item {f:if(condition: '{attribute} >= 3', then: 'tb-tour-rating__item--marked')}">
            •
        </li>
        <li class="tb-tour-rating__item {f:if(condition: '{attribute} >= 4', then: 'tb-tour-rating__item--marked')}">
            •
        </li>
        <li class="tb-tour-rating__item {f:if(condition: '{attribute} >= 5', then: 'tb-tour-rating__item--marked')}">
            •
        </li>
    </ul>
</f:section>


<f:comment>
    <!--
        Renders ratings.
    -->
</f:comment>
<f:section name="teaserRatingType">
    <f:if condition="{starClassification}">
        <div class="tb-rating">
            <div class="tb-rating__result">
                <span>
                    <vh:translate
                        id="property.attribute.stars"
                        arguments="{ 0: starClassification }"
                        package="Newland.Toubiz.Poi.Neos"
                        source="Views/Teaser" />

                </span>
            </div>
            <ul class="tb-rating__list list-reset">
                <li class="tb-rating__item {f:if(condition: '{starClassification} >= 1', then: 'tb-rating__item--full')}"></li>
                <li class="tb-rating__item {f:if(condition: '{starClassification} >= 2', then: 'tb-rating__item--full')}"></li>
                <li class="tb-rating__item {f:if(condition: '{starClassification} >= 3', then: 'tb-rating__item--full')}"></li>
                <li class="tb-rating__item {f:if(condition: '{starClassification} >= 4', then: 'tb-rating__item--full')}"></li>
                <li class="tb-rating__item {f:if(condition: '{starClassification} >= 5', then: 'tb-rating__item--full')}"></li>
            </ul>
        </div>
    </f:if>
    <f:if condition="{averageRating}">
        <f:if condition="{numberOfRatings} > 0">
            <f:then>
                <div class="tb-rating"
                     itemprop="aggregateRating"
                     itemscope
                     itemtype="http://schema.org/AggregateRating">
                    <vh:render section="starRatingContent" arguments="{_all}"/>
                </div>
            </f:then>
            <f:else>
                <div class="tb-rating">
                    <vh:render section="starRatingContent" arguments="{_all}"/>
                </div>
            </f:else>
        </f:if>
    </f:if>
</f:section>

<f:comment>
    <!--
        Renders text from a string or array.
    -->
</f:comment>
<f:section name="textType">
    {attribute -> f:format.raw()}
</f:section>

<f:section name="listType">
    <ul>
        <f:for each="{attribute}" as="content">
            <li>{content}</li>
        </f:for>
    </ul>
</f:section>

<f:comment>
    <!--
        Renders an array of strings with their corresponding translation.
    -->
</f:comment>
<f:section name="translationArrayType">
    <f:for each="{attribute}" as="item" iteration="iterator">
        <vh:translate id="{path}.{item}" package="Newland.Toubiz.Poi.Neos" source="{source}" />{f:if(condition: iterator.isLast, then: '', else: ', ')}
    </f:for>
</f:section>

<f:comment>
    <!--
        Renders a distance.
    -->
</f:comment>
<f:section name="distanceType">
    <f:if condition="{subType} == 'meter'">
        {attribute.intValue} m
    </f:if>
    <f:if condition="{subType} == 'kilometer'">
        {attribute -> vh:math.divide(by: 1000) -> vh:math.round(precision: 1)} km
    </f:if>
</f:section>

<f:comment>
    <!--
        Renders a time from minutes.
    -->
</f:comment>
<f:section name="timeType">
    {attribute -> vh:math.toHours()} h
</f:section>

<f:section name="starRatingContent">
    <div class="tb-rating__result">
                <span itemprop="ratingValue">
                    <vh:translate
                            id="property.attribute.voteAverage"
                            package="Newland.Toubiz.Poi.Neos"
                            source="Views/Teaser"
                            arguments="{ 0: '{averageRating/20}' }"/>

                </span>
    </div>
    <ul class="tb-rating list-reset">
        <f:for each="{poi:ratingAverage(ratingValue: averageRating)}" as="item">
            <li class="tb-rating__item {f:if(condition: item, then: 'tb-rating__item--{item}')}"></li>
        </f:for>
    </ul>
    <f:if condition="{numberOfRatings} > 0">
        <p class="tb-rating__votes">
            (
            <span itemprop="reviewCount">{numberOfRatings}</span>
            <vh:translate
                    id="property.attribute.totalVotes"
                    package="Newland.Toubiz.Poi.Neos"
                    source="Views/Teaser"/>
            )
        </p>
    </f:if>
</f:section>
