<?php

class Dalten_Export_Api_NewRealitymix extends Dalten_Export_Api_SrealityLike
{
    protected function _convertListingData(array $listingData, array $additionalParams)
    {
        $originalListingData = $listingData;
        $listingData = parent::_convertListingData($listingData, $additionalParams);

        $hidePortals = '00';
        if (isset($additionalParams['listing']['hide_portals'])) {
            // data dostáváme v podobě pole integerů, když v něm je integer s danou hodnotou pošleme ho
            // 1=Prima HbbTV
            $hidePortals[1] = in_array(1, $additionalParams['listing']['hide_portals']) ? 1 : 0;
        }
        $listingData['hide_portals'] = $hidePortals;

        // z původních (nepřevedených) dat vytáhneme video
        $youtubeIdVideo = Dalten_Export_Helper_YoutubeIdExtractor::extractYoutubeId($originalListingData['nemovitost_video_prohlidka']);
        if ($youtubeIdVideo) {
            $listingData['video_url'] = $originalListingData['nemovitost_video_prohlidka'];
        }

        $youtubeIdVirtualniProhlidka = Dalten_Export_Helper_YoutubeIdExtractor::extractYoutubeId($originalListingData['nemovitost_virtualni_prohlidka']);
        if ($youtubeIdVirtualniProhlidka) {
            $listingData['video_url'] = $originalListingData['nemovitost_virtualni_prohlidka'];
        }

        return $listingData;
    }
}
