示例#1
0
             $filterObj = new trails();
             $filterResult = $filterObj->filterByLocation("city", $_GET['city'], $offset, 10, "Array", "showUnpublished");
             $filterCount = $filterResult['countReturned'];
             $totalMatched = $filterResult['totalMatched'];
             $trails = $filterResult['trails'];
         } else {
             $error = "city";
             $page_type = "error";
             $nomatch = true;
         }
     }
     if ($_GET['by'] == "zip") {
         $query = "?by=zip&zip=" . $_GET['zip'];
         $filtertext .= "in " . $_GET['zip'];
         $filterObj = new trails();
         $filterResult = $filterObj->filterByLocation("zip", $_GET['zip'], $offset, 10, "Array", "showUnpublished");
         $filterCount = $filterResult['countReturned'];
         $totalMatched = $filterResult['totalMatched'];
         $trails = $filterResult['trails'];
     }
 }
 if (10 > $totalMatched - $offset) {
     $through = $totalMatched;
 } else {
     $through = $offset + 10;
 }
 $start = $offset + 1;
 $title = $filtertext . "<br>showing " . $start . " - " . $through . " of " . $totalMatched;
 if ($totalMatched == 0) {
     $nomatch = true;
     $error = "nomatch";
示例#2
0
                    </pre>

                    <h3>Filter</h3>                    
                    <p>Our database can be searched by sending a <code>GET</code> request to <code><?php 
echo $baseurl;
?>
api/filter/</code> with filter commands as variables. Each request will return the number of trails returned as <code>countReturned</code> and the total number of trails matched by the query as <code>totalMatched</code>. Note, you must set <code>offset</code> and <code>count</code>. For example, <code>GET <?php 
echo $baseurl;
?>
api/filter/?by=city&city=Albuquerque&offset=0&count=6 </code> returns the following information in JSON:</p>
                    <pre>

	<?php 
$filterObj = new trails();
$filterResult = $filterObj->filterByLocation("city", "Albuquerque", 0, 6, "Array");
echo json_encode($filterResult, JSON_PRETTY_PRINT);
?>

                    </pre>
                    
                    <h3>Translations</h3>                    
                    <p>Notice that the JSON response for trail requests includes available translations under the key <code>translations</code>. In the request illustrated above, Spanish (es) is listed as an available translation. In order to retrieve this translation, we will send a <code>GET</code> request: <code>GET <?php 
echo $baseurl;
?>
api/translation/?id=2&lang=es</code></p>
                    <pre>

	<?php 
echo json_encode($GetTrail->getTranslation("es", "Array"), JSON_PRETTY_PRINT);
?>
示例#3
0
    $filtertext = $lexicon[45][$lang_set];
    //Trails near me
    $filtertextsm = $filtertext;
    if (!is_numeric($_GET['lat']) || !is_numeric($_GET['lat'])) {
        $error = "coord";
        $page_type = "error";
        require "/nfs/users/clind/public_html/prescriptiontrails.org/src/nav.php";
        require "../filter/error.php";
        echo "</div>";
        require "/nfs/users/clind/public_html/prescriptiontrails.org/src/drawer.php";
        require "/nfs/users/clind/public_html/prescriptiontrails.org/src/js_base.php";
        exit;
    }
    $coords = array("lat" => $_GET['lat'], "lng" => $_GET['lng']);
    $filterObj = new trails();
    $filterResult = $filterObj->filterByLocation("coord", $coords, 0, 24, "Array");
    $filterCount = $filterResult['countReturned'];
    $totalMatched = $filterResult['totalMatched'];
    $trails = $filterResult['trails'];
    $showLocaiton = true;
} else {
    $allTrails = new trails();
    $result = $allTrails->getAll();
    $count = $result['totalMatched'];
    $trails = $result['trails'];
    $showLocaiton = false;
}
function limit_text($text, $limit)
{
    if (str_word_count($text, 0) > $limit) {
        $words = str_word_count($text, 2);
示例#4
0
         $filterCount = $filterResult['countReturned'];
         $totalMatched = $filterResult['totalMatched'];
         $trails = $filterResult['trails'];
     }
     if ($_GET['by'] == "grade") {
         $filtertext = "Grade ";
         if ($_GET['grade'] == 4) {
             $filtertext .= "3++";
         } else {
             $filtertext .= $_GET['grade'];
         }
         $term = $_GET['grade'];
         $filtertext .= " Trails";
         $filtertextsm = $filtertext;
         $filterObj = new trails();
         $filterResult = $filterObj->filterByLocation("grade", $_GET['grade'], 0, 18, "Array");
         $filterCount = $filterResult['countReturned'];
         $totalMatched = $filterResult['totalMatched'];
         $trails = $filterResult['trails'];
     }
     if ($_GET['by'] == "name") {
         $term = urldecode(filter_input(INPUT_GET, 'name', FILTER_SANITIZE_STRING));
         $filtertext = "'" . htmlspecialchars($term, ENT_COMPAT, 'UTF-8') . "'";
         $filtertextsm = $filtertext;
         $filterObj = new trails();
         $filterResult = $filterObj->filterByTerm($term, 0, 18, "Array");
         $filterCount = $filterResult['countReturned'];
         $totalMatched = $filterResult['totalMatched'];
         $trails = $filterResult['trails'];
     }
 }
示例#5
0
    if ($_GET['by'] == "city" || $_GET['by'] == "zip" || $_GET['by'] == "grade" || $_GET['by'] == "name") {
        if ($_GET['by'] == "city") {
            $search = $_GET['city'];
            if (in_array($_GET['city'], $cities)) {
                $filterObj = new trails();
                $filterResult = $filterObj->filterByLocation("city", filter_input(INPUT_GET, 'city', FILTER_SANITIZE_STRING), intval($_GET['offset']), intval($_GET['count']), "JSON");
            } else {
                $response = array("status" => "error", "type" => "INVALID_CITY", "message" => "City not recognized. " . htmlspecialchars($_GET['city']) . " is not in our system. Filter can be used by city, zip, grade, name, or location. See " . $baseurl . "api/");
                echo json_encode($response);
                exit;
            }
        }
        if ($_GET['by'] == "zip") {
            $filterObj = new trails();
            $filterResult = $filterObj->filterByLocation("zip", intval($_GET['zip']), intval($_GET['offset']), intval($_GET['count']), "JSON");
        }
        if ($_GET['by'] == "grade") {
            $filterObj = new trails();
            $filterResult = $filterObj->filterByLocation("grade", intval($_GET['grade']), intval($_GET['offset']), intval($_GET['count']), "JSON");
        }
        if ($_GET['by'] == "name") {
            $term = urldecode(filter_input(INPUT_GET, 'name', FILTER_SANITIZE_STRING));
            $filterObj = new trails();
            $filterResult = $filterObj->filterByTerm($term, intval($_GET['offset']), intval($_GET['count']), "JSON");
        }
    }
    echo $filterResult;
} else {
    $response = array("status" => "error", "type" => "INVALID_REQUEST", "message" => "Request not recognized. Filter can be used by city, zip, grade, name, or location. See " . $baseurl . "api/");
    echo json_encode($response);
}