Example #1
0
function html_street_lookup($label, $name, $intersection = FALSE)
{
    return '
		' . html_utf8(i18n('Bookmarks')) . ': <select name="' . $name . '_bookmarks" id="' . $name . '_bookmarks"></select><br />
		<label for="' . $name . '">' . html_utf8(i18n(ucfirst($label . ':'))) . '</label> <input type="text" name="' . $name . '" id="' . $name . '" value="' . (isset($_REQUEST[$name]) ? htmlentities($_REQUEST[$name], ENT_QUOTES) : '') . '" />
		<input type="hidden" name="' . $name . '_id" id="' . $name . '_id" value="' . (isset($_REQUEST[$name . '_id']) ? htmlentities($_REQUEST[$name . '_id'], ENT_QUOTES) : '') . '" />
                <div id="' . $name . '_options"></div>
                <script type="text/javascript">
                        new Ajax.Autocompleter("' . $name . '", "' . $name . '_options", "street_lookup.php", {"callback": function(element, params) { return params + "&zone=" + encodeURI($F("zones")) + "&subzone=" + encodeURI($F("subzones")); }, "paramName": "street", "afterUpdateElement": function(element, selected) { $("' . $name . '_id").value = selected.id.substr(7); } });
                </script>' . ($intersection === FALSE ? '' : '<br /><label for="' . $name . '_intersection">' . html_utf8(i18n(ucfirst($label . ' intersection:'))) . '</label> <input type="text" name="' . $name . '_intersection" id="' . $name . '_intersection" value="' . (isset($_REQUEST[$name . '_intersection']) ? htmlentities($_REQUEST[$name . '_intersection'], ENT_QUOTES) : '') . '" />
		<input type="hidden" name="' . $name . '_intersection_id" id="' . $name . '_intersection_id" value="' . (isset($_REQUEST[$name . '_intersection_id']) ? htmlentities($_REQUEST[$name . '_intersection_id'], ENT_QUOTES) : '') . '" />
                <div id="' . $name . '_intersection_options"></div>
		<input type="button" value="' . html_utf8(i18n('Bookmark!')) . '" id="bookmark_' . $name . '" />
                <script type="text/javascript">
                        new Ajax.Autocompleter("' . $name . '_intersection", "' . $name . '_intersection_options", "street_intersection_lookup.php", { "callback": function(element, params) { return params + "&street_id=" + encodeURI($F("' . $name . '_id")) + "&zone=" + encodeURI($F("zones")) + "&subzone=" + encodeURI($F("subzones")); }, "paramName": "street_intersection", "afterUpdateElement": function(element, selected) { $("' . $name . '_intersection_id").value = selected.id.substr(7); if ($("' . $name . '_intersection_id").value.length == 0) $("' . $name . '_intersection").value = ""; } });
			Event.observe($("bookmark_' . $name . '"), "click", function() {
				if ($F("' . $name . '").length * $F("' . $name . '_id").length * $F("' . $name . '_intersection").length * $F("' . $name . '_intersection_id").length == 0) {
					alert("' . i18n('Please fill in a street and an intersection') . '");
				} else {
					var name = prompt("Name the bookmark");
					window.bookmarks.push({ "name": name, "street_id" : $F("' . $name . '_id"), "street_name": $F("' . $name . '"), "street_intersection_id" : $F("' . $name . '_intersection_id"), "street_intersection_name": $F("' . $name . '_intersection") });
					createCookie("bookmarks", window.bookmarks.toJSON());
					reloadBookmarks();
					alert("Bookmark created");
				}
			});
			Event.observe($("' . $name . '_bookmarks"), "change", function() {
				var key = $F("' . $name . '_bookmarks");
				if (key < 0) return;
				var info = window.bookmarks[$F("' . $name . '_bookmarks")];
				$("' . $name . '").value = info.street_name;
				$("' . $name . '_id").value = info.street_id;
				$("' . $name . '_intersection").value = info.street_intersection_name;
				$("' . $name . '_intersection_id").value = info.street_intersection_id;
			});

			if (!window.bookmarks_selects) window.bookmarks_selects = [];
			function reloadBookmarks() {
				for (var i = 0; i <  window.bookmarks_selects.length; i++) {
					var select = window.bookmarks_selects[i];
					$(select).update("");
					$(select).insert(new Element("option", { "value": "-1" }));
					for (var j = 0; j < window.bookmarks.length; j++)
						$(select).insert(new Element("option", { value: j } ).update(window.bookmarks[j].name));
				}
			}
			window.bookmarks_selects.push($("' . $name . '_bookmarks"));
			reloadBookmarks();
                </script>
		');
}
Example #2
0
if (isset($_REQUEST['train'])) {
    $types[] = 'train';
}
foreach ($types as $type) {
    $temp = 'get_' . pluralize($type) . '_near_node';
    $from_railways = $temp($from_node['lat'], $from_node['lon'], $from_walk_upto);
    $to_railways = $temp($to_node['lat'], $to_node['lon'], $from_walk_upto);
    foreach (filter_useful_railways($from_railways, $to_railways, $type) as $railway_id) {
        $temp = 'get_' . $type . '_info';
        $railway_info = $temp($railway_id);
        $temp = 'get_' . $type . '_ways';
        $results[] = array('name' => $railway_info['name'], 'operator' => $railway_info['operator'], 'ways' => $temp($railway_id), 'from_node' => $from_railways[$railway_id]['node'], 'from_ways' => list_way_names_for_node_id($from_railways[$railway_id]['node']['id']), 'to_node' => $to_railways[$railway_id]['node'], 'to_ways' => list_way_names_for_node_id($to_railways[$railway_id]['node']['id']), 'walk_distance' => $from_railways[$railway_id]['distance'] + $to_railways[$railway_id]['distance'], 'type' => $type);
    }
}
function walk_distance_sort($a, $b)
{
    if ($a['walk_distance'] == $b['walk_distance']) {
        return 0;
    }
    return $a['walk_distance'] < $b['walk_distance'] ? -1 : 1;
}
usort($results, 'walk_distance_sort');
//$results = array_reverse($results);
if (count($results) == 0) {
    die('Unable to find any route matching both directions');
}
echo '<table border="1" width="100%">';
foreach ($results as $result) {
    echo '<tr><td>' . html_utf8($result['type']) . '</td><td>' . html_utf8($result['name']) . '</td><td>' . round($result['walk_distance'] * 1000) . ' m</td><td>' . html_utf8(implode(', ', $result['from_ways'])) . '</td><td>' . html_utf8(implode(', ', $result['to_ways'])) . '</td></tr>';
}
echo '</table>';
$streets = mysql_query('SELECT street.id, street.full_name FROM street JOIN street_suburbs ON street.id = street_suburbs.street_id JOIN suburb ON street_suburbs.suburb_id = suburb.node_id WHERE ' . $subzone . ' suburb.is_in = "' . mysql_real_escape_string($_REQUEST['zone']) . '" AND street.id != "' . mysql_real_escape_string($_REQUEST['street_id']) . '" AND street.name LIKE "%' . str_replace(array('%', '?'), array('\\%', '\\?'), mysql_real_escape_string($_REQUEST['street_intersection'])) . '%" GROUP BY street.id LIMIT 20') or die(mysql_error());
*/
$i = 0;
if (isset($streets) && mysql_num_rows($streets) > 0) {
    ?>
<ul>
<?php 
    while ($street = mysql_fetch_assoc($streets)) {
        ?>
<li class="<?php 
        echo $i++ & 1 == 1 ? 'odd' : 'even';
        ?>
" id="street_<?php 
        echo $street['id'];
        ?>
"><?php 
        echo html_utf8($street['full_name']);
        ?>
</li>
<?php 
    }
    ?>
</ul>
<?php 
} else {
    ?>
<ul>
<li class="even">Unable to find specified street</li>
</ul>
<?php 
}
Example #4
0
?>
/><label for="bus"><?php 
echo html_utf8(i18n('Bus'));
?>
</label>
		<input type="checkbox" name="train" id="train" <?php 
if (isset($_POST['train'])) {
    echo 'checked="checked" ';
}
?>
/><label for="train"><?php 
echo html_utf8(i18n('Train'));
?>
</label>
		<input type="checkbox" name="railway" id="railway" <?php 
if (isset($_POST['railway'])) {
    echo 'checked="checked" ';
}
?>
/><label for="railway"><?php 
echo html_utf8(i18n('Subway'));
?>
</label>
	</div>
	<div>
		<input type="submit" value="Buscar" />
	</div>
</form>
</body>
</html>