{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>
<f: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 class="tb-badge tb-badge--easy">
                <vh:translate
                    id="property.attribute.{name}.values.{attribute}"
                    package="Newland.Toubiz.Poi.Neos"
                    source="Models/Article" />

                </span>
        </f:case>
        <f:case value="2">
            <span class="tb-badge tb-badge--medium">
                <vh:translate
                    id="property.attribute.{name}.values.{attribute}"
                    package="Newland.Toubiz.Poi.Neos"
                    source="Models/Article" />

            </span>
        </f:case>
        <f:case value="3">
            <span class="tb-badge tb-badge--hard">
                <vh:translate
                    id="property.attribute.{name}.values.{attribute}"
                    package="Newland.Toubiz.Poi.Neos"
                    source="Models/Article" />

            </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-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}">
        <div class="tb-rating">
            <div class="tb-rating__result">
                <span>
                    <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">
                    (
                        {numberOfRatings}
                        <vh:translate
                            id="property.attribute.totalVotes"
                            package="Newland.Toubiz.Poi.Neos"
                            source="Views/Teaser" />
                    )
                </p>
            </f:if>
        </div>
    </f:if>
</f:section>

<f:comment>
    <!--
        Renders text from a string or array.
    -->
</f:comment>
<f:section name="textType">
    <f:for each="{attribute}" as="item" iteration="iterator">
        <f:if condition="{vh:type.isArray(value: item)}">
            <f:then>
                {vh:collection.implode(collection: item, glue: ', ')}
            </f:then>
            <f:else>
                {item -> f:format.raw()}
            </f:else>
        </f:if>
    </f:for>
</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>
