--- a/stopList.php +++ b/stopList.php @@ -17,25 +17,14 @@ */ include ('include/common.inc.php'); $stops = Array(); -function stopCompare($stopName) { - return substr(trim(preg_replace("/\(Platform.*/", "", $stopName)),0,9); -} -function stopGroupTitle($stopName,$stopdesc) { - if (preg_match("/Dr |Cct |Cir |Av |St /",$stopName)) { - $descParts = explode("<br>",$stopdesc); - return trim(str_replace("Street: ","",$descParts[0])); - } else { - return trim(preg_replace("/\(Platform.*/", "",$stopName)); - } -} + function navbar() { echo ' <div data-role="navbar"> <ul> - <li><a href="stopList.php">Timing Points</a></li> + <li><a href="stopList.php">Stops by Name</a></li> <li><a href="stopList.php?bysuburbs=yes">By Suburb</a></li> <li><a href="stopList.php?nearby=yes">Nearby Stops</a></li> - <li><a href="stopList.php?allstops=yes">All Stops</a></li> </ul> </div> '; @@ -47,8 +36,8 @@ navbar(); echo ' <ul data-role="listview" data-filter="true" data-inset="true" >'; if (!isset($firstLetter)) { - foreach (range('A', 'Z') as $letter) { - echo "<li><a href=\"stopList.php?firstLetter=$letter&bysuburbs=yes\">$letter...</a></li>\n"; + foreach (range('A', 'Y') as $letter) { // no suburbs start with J, Q, U, V, X or Z + if ($letter != "J" && $letter != "Q" && $letter != "U" && $letter != "V" && $letter != "X") echo "<li><a href=\"stopList.php?firstLetter=$letter&bysuburbs=yes\">$letter...</a></li>\n"; } } else { foreach ($suburbs as $suburb) { @@ -60,12 +49,7 @@ echo '</ul>'; } else { // Timing Points / All stops - if (isset($allstops)) { - $listType = 'allstops=yes'; - $stops = getStops($firstLetter); - include_header("All Stops", "stopList"); - navbar(); - } else if (isset($nearby)) { + if (isset($nearby)) { $listType = 'nearby=yes'; include_header("Nearby Stops", "stopList", true, true); trackEvent("Stop Lists", "Stops Nearby", $_SESSION['lat'] . "," . $_SESSION['lon']); @@ -76,7 +60,7 @@ die(); } $stops = getNearbyStops($_SESSION['lat'], $_SESSION['lon'], 15); - echo '<span class="content-secondary">'; + echo '<div class="content-secondary">'; $stopPositions[] = Array( $_SESSION['lat'], $_SESSION['lon'] @@ -89,35 +73,35 @@ } echo staticmap($stopPositions, true, true); placeSettings(); - echo '</span><span class="content-primary">'; + echo '</div><div class="content-primary">'; } else if (isset($suburb)) { $stops = getStopsBySuburb($suburb); include_header("Stops in " . ucwords($suburb), "stopList"); navbar(); trackEvent("Stop Lists", "Stops By Suburb", $suburb); } else { - $stops = getStops(true, $firstLetter); - include_header("Timing Points / Major Stops", "stopList"); + $listType = 'allstops=yes'; + $stops = getStops((isset($firstLetter)? $firstLetter : "")); + include_header("Stops by Name", "stopList"); navbar(); - } + } echo ' <ul data-role="listview" data-filter="true" data-inset="true" >'; - if (!isset($firstLetter) && !isset($suburb) && !isset($nearby)) { - foreach (range('A', 'Z') as $letter) { - echo "<li><a href=\"stopList.php?firstLetter=$letter&$listType\">$letter...</a></li>\n"; + if (!isset($firstLetter) && !isset($suburb) && !isset($nearby)) { // all stops by letter + foreach (range('A', 'Y') as $letter) { // no streets start with X or Z + if ($letter != "X") echo "<li><a href=\"stopList.php?firstLetter=$letter&$listType\">$letter...</a></li>\n"; } } else { //var_dump($stops); $stopsGrouped = Array(); foreach ($stops as $key => $stop) { - if (stopCompare($stops[$key]["stop_name"]) - != stopCompare($stops[$key + 1]["stop_name"]) - || $key + 1 >= sizeof($stops)) { + if ($key + 1 >= sizeof($stops) || + stopCompare($stops[$key]["stop_name"]) != stopCompare($stops[$key + 1]["stop_name"])) { if (sizeof($stopsGrouped) > 0) { // print and empty grouped stops // subsequent duplicates $stopsGrouped["stop_ids"][] = $stop['stop_id']; echo '<li>'; - echo '<a href="stop.php?stopids=' . implode(",", $stopsGrouped['stop_ids']) . '">'; + echo '<a href="stop.php?stopids=' . implode(",", $stopsGrouped['stop_ids']) . '&stopcodes=' . implode(",", $stopsGrouped['stop_codes']) . '">'; if (isset($_SESSION['lat']) && isset($_SESSION['lon'])) { echo '<span class="ui-li-count">' . distance($stop['stop_lat'], $stop['stop_lon'], $_SESSION['lat'], $_SESSION['lon'], true) . 'm away</span>'; } @@ -154,14 +138,15 @@ } else { // subsequent duplicates $stopsGrouped["stop_ids"][] = $stop['stop_id']; - ; + } } } } echo '</ul>'; - if (isset($nearby)) - echo '</span>'; + if (isset($nearby)) { + echo '</div>'; +} } include_footer(); ?>