<?php

/*
 * PuzzleApp
 * Webemyos
 * Jérôme Oliva
 * GNU Licence
 */

namespace Apps\Immo\Helper;

use Apps\Immo\Entity\ImmoCity;

class SitemapHelper {
    /*     * *
     * Obtient le site map du blog
     */

    public static function GetSiteMap($core, $returnUrl = false) {
        $urlBase = $core->GetPath("/estimation");
        $urlBaseImmo = $core->GetPath("/immobilier");
        
        $sitemap .= "<url><loc>$urlBase</loc></url>";
        $urls = "";
      
        $category = new ImmoCity($core);
        $categorys = $category->GetAll();

        foreach ($categorys as $category) {
            $sitemap .= "<url><loc>$urlBase/ville/" . $category->Code->Value . "</loc></url>";
            $sitemap .= "<url><loc>$urlBaseImmo/ville/" . $category->Code->Value . "</loc></url>";
            
            $url = $urlBase . "/ville/" . $category->Code->Value;
            $urls .= '<br/><a target="__blank" href="' . $url . '">' . $url . '</a>';

            $url = $urlBaseImmo . "/ville/" . $category->Code->Value;
            $urls .= '<br/><a target="__blank" href="' . $url . '">' . $url . '</a>';
        }


       if ($returnUrl == true) {
            return $urls;
        } else {
            return $sitemap;
        }
    }
}
