示例#1
0
<?php

include 'parsing_line_stations.php';
include 'misc_tag.php';
$colors = getColorForLine(getLineName($stationList['line']));
$lineBg = $colors['bg'];
$lineFg = $colors['fg'];
$style = "style='background:{$lineBg}; color:{$lineFg}; margin-bottom:4px'";
?>

<div id="stationsForLine" style="margin-bottom: 2em;">
   <?php 
foreach ($stationList['stations'] as $a_station) {
    ?>
      <div class="tuile aStation"  style="margin-top:-7px;" target="<?php 
    echo $a_station['id'];
    ?>
">
         <span class="text" <?php 
    echo $style;
    ?>
 >
            <?php 
    echo $a_station['name'];
    ?>
            <div style="clear:both;"></div>
         </span>
      </div>
   <?php 
}
?>
示例#2
0
<?php

include 'parsing_lineslist.php';
include 'misc_tag.php';
?>

<div id="linesList" style="margin-bottom: 2em;">
   <?php 
foreach ($linesList as $a_line) {
    $colors = getColorForLine(getLineName($a_line['name']));
    $lineBg = $colors['bg'];
    $lineFg = $colors['fg'];
    $style = "style='background:{$lineBg}; color:{$lineFg}; margin-bottom:4px'";
    ?>
      <div class="tuile aLine"  style="margin-top:-7px;" target="<?php 
    echo $a_line['id'];
    ?>
">
         <span class="text" <?php 
    echo $style;
    ?>
 >
            Ligne <?php 
    echo $a_line['name'];
    ?>
            <div style="clear:both;"></div>
         </span>
      </div>
   <?php 
}
?>
示例#3
0
$longitude = "&longitude=" . $lgt;
$fullUrl = $url . $latitude . $longitude;
$osmUrl = "http://www.openstreetmap.org/#map=19/" . $latitude . "/" . $longitude;
$html = file_get_html($fullUrl);
if (count($html->find('div.error')) == 1) {
    echo "<a href=" . $fullUrl . ">Mobitrans</a> <br />";
    echo json_encode("error");
    exit;
}
$resultNode = $html->find('div.corpsL')[0];
$nearStations = $resultNode->find('div');
$linesForStations = array();
foreach ($nearStations as $aLine) {
    $lineSpanNode = $aLine->find('span')[1];
    $lineName = $lineSpanNode->innertext;
    $lineName = getLineName($lineName);
    $stations = $aLine->find('a');
    $stationList = array();
    foreach ($stations as $aStation) {
        $stationName = utf8_encode($aStation->innertext);
        $distance = $aStation->next_sibling()->innertext;
        $pattern = "/(\\d*)m/";
        preg_match($pattern, $distance, $matches);
        $distance = $matches[1];
        parse_str($aStation->href, $urlarray);
        $stationId = $urlarray['id'];
        $stationInfo['station'] = $stationName;
        $stationInfo['distance'] = intval($distance);
        $stationInfo['stationID'] = intval($stationId);
        array_push($stationList, $stationInfo);
        if (!array_key_exists($stationName, $linesForStations)) {
示例#4
0
//retrieve page from mobitrans
$html = file_get_html($url);
//Test if the result is an error page
if (count($html->find('div.error')) == 1) {
    echo "<a href=" . $url . ">Mobitrans</a> <br />";
    echo json_encode("error");
    exit;
}
//All the resultat are in within <div class="corpsL"></div>
$resultNode = $html->find('div.corpsL')[0];
//first spanwhiteB has the station name
$arret = $resultNode->find('span.whiteB')[0]->innertext;
$res['station'] = utf8_encode(substr($arret, 7));
//third span has the ligne name
$ligne = $resultNode->find('span')[2]->innertext;
$ligne = getLineName($ligne);
$res['line'] = $ligne;
//Skipping the infoTrafic
$infoTrafic = $resultNode->find('.infoTrafic', 0);
$bNodeIndex = 0;
if (isset($infoTrafic)) {
    $bNodeIndex = count($infoTrafic->find('b'));
    $infoTrafic->outertext = '';
}
$directions = array();
$bNodeCount = count($resultNode->find('b'));
$exploded = explode("<br/><br/>", $resultNode->innertext);
//
//Parsing direction
//
//var_dump($exploded);