<?php

require_once "../config/mobi_web_constants.php";
require_once PAGE_HEADER;
if ($search_terms = $_REQUEST['filter']) {
    $results = map_search($search_terms);
    $total = count($results);
    if (count($results) == 1) {
        header("Location: " . detailURL($results[0]));
    } else {
        $content = new ResultsContent("items", "map", $page);
        require "{$page->branch}/search.html";
        $page->output();
    }
} else {
    header("Location: ./");
}
function detailURL($place)
{
    $id = substr($place->id, 7);
    return "detail.php?selectvalues={$id}&snippets=" . urlencode(implode(", ", $place->snippets));
}
function map_search($terms)
{
    $query = array("type" => "query", "q" => $terms, "output" => "json");
    $json = file_get_contents("http://map-dev.mit.edu/search?" . http_build_query($query));
    $data = json_decode($json);
    //sort data by priority
    $high = array();
    $low = array();
    foreach ($data as $place) {
<?php

require_once "../config/mobi_web_constants.php";
require_once PAGE_HEADER;
require_once LIBDIR . "StellarData.php";
require_once "stellar_lib.php";
function selfURL()
{
    $start = $_REQUEST["start"] ? (int) $_REQUEST["start"] : 0;
    $query = http_build_query(array("filter" => $_REQUEST['filter'], "start" => $start));
    return "search.php?{$query}";
}
$classes = StellarData::search_subjects($_REQUEST['filter']);
// if exactly one class is found redirect to that
// classes detail page
if (count($classes) == 1) {
    header("Location: " . detailURL($classes[0], selfURL()));
    die;
}
$content = new ResultsContent("items", "stellar", $page);
require "{$page->branch}/search.html";
$page->output();
Example #3
0
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */
// various copy includes
require_once "../../config.gen.inc.php";
require_once "data/data.inc.php";
// records stats
require_once "../page_builder/page_header.php";
// libs
require_once "lib/map.lib.inc.php";
if ($search_terms = $_REQUEST['filter']) {
    $results = map_search($search_terms);
    $total = count($results);
    if (count($results) == 1) {
        header("Location: " . detailURL($results[0]['id'], $results[0]['latitude'], $results[0]['longitude']));
    } else {
        require "templates/{$prefix}/search.html";
        $page->output();
    }
} else {
    header("Location: ./");
}
function map_search($terms)
{
    $db = new db();
    $sql = "SELECT * FROM Buildings WHERE (name LIKE '%" . $terms . "%' OR physical_address LIKE '%" . $terms . "%' OR code LIKE '%" . $terms . "%') and (type != 'Parking Lot' AND type != 'Public Parking') GROUP BY name ORDER BY name ASC";
    $stmt = $db->connection->prepare($sql);
    $stmt->execute();
    $result = $stmt->fetchAll();
    return $result;
Example #4
0
<?php

/**
 * Copyright (c) 2008 Massachusetts Institute of Technology
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */
// various copy includes
require_once "../../config.gen.inc.php";
require_once "data/data.inc.php";
// records stats
require_once "../page_builder/page_header.php";
// sets up adapter class
$adapter = ModuleAdapter::find();
require_once "adapters/" . $adapter . "/adapter.php";
// libs
require_once "lib/map.lib.inc.php";
$results = MapAdapter::searchPlaces($_REQUEST['filter']);
$total = count($results);
if (count($results) == 1) {
    $result = $results[0];
    header("Location: " . detailURL($result['id'], $result['latitude'], $result['longitude']) . "&ir=true");
} else {
    require "templates/{$prefix}/search.html";
    $page->output();
}