catalogTTList.php 1.21 KB
<?php

require_once 'config.php';

function catalogTTList(){

    $urls = [
        "catalog"   => file_get_contents(webAlias.'/php/rest/getCatalogsList.php'),
        "timeTable" => file_get_contents(webAlias.'/php/rest/getTimeTablesList.php')
    ];

    $parameters = [];
    foreach ($urls as $key => $url){
        $xml = simplexml_load_string(file_get_contents($url));
        if (empty($xml)) 
            continue;
        foreach($xml->xpath('//'.$key) as $parameter) {
            $attributes =  $parameter->attributes();
            $parameters[] = [
                "type"          => $key,
                "name"          => (string) $attributes->name,
                "id"            => (string) $attributes->id,
                "created"       => (string) $attributes->created,
                "description"   => (string) $attributes->description,
                "nbIntervals"   => (string) $attributes->nbIntervals,
                "surveyStart"   => (string) $attributes->surveyStart,
                "surveyStop"    => (string) $attributes->surveyStop,
                "sharedDate"    => (string) $attributes->sharedDate
            ];
        }
    }

    return json_encode($parameters);
}

echo catalogTTList();
?>