Beispiel #1
0
function outputRdf($rdf, $title = 'Serialized RDF')
{
    if (!clientAcceptsRDF()) {
        dump($rdf, $title);
    } else {
        ob_clean();
        header("Content-Type: application/rdf+xml;charset=utf-8");
        header("Cache-Control: no-cache, must-revalidate");
        header("Expires: " . gmdate("D, d M Y H:i:s", time()));
        echo $rdf;
    }
}
Beispiel #2
0
        header("HTTP/1.1 500 Internal Server Error");
        echo parameterize($HTML_TEMPLATE_ERROR, array('TITLE' => 'Flickr error #' . $FLICKRSERVICE->errCode, 'MESSAGE' => $FLICKRSERVICE->errMsg, 'FLICKRWRAPPR_HOMEPAGE' => FLICKRWRAPPR_HOMEPAGE));
    } else {
        header("HTTP/1.1 404 Not Found");
        if (!isset($_REQUEST['item'])) {
            echo parameterize($HTML_TEMPLATE_ERROR, array('TITLE' => 'Sorry, no photos found in the specified area', 'MESSAGE' => 'Please extend the search radius or verify the coordinates!', 'FLICKRWRAPPR_HOMEPAGE' => FLICKRWRAPPR_HOMEPAGE));
        } else {
            if ($resourceFound) {
                echo parameterize($HTML_TEMPLATE_ERROR, array('TITLE' => 'Sorry, no photos found for DBpedia.org resource ' . $_REQUEST['item'], 'MESSAGE' => 'You specified a valid resource, but we were unable to locate any photos for it!', 'FLICKRWRAPPR_HOMEPAGE' => FLICKRWRAPPR_HOMEPAGE));
            } else {
                echo parameterize($HTML_TEMPLATE_ERROR, array('TITLE' => 'DBpedia.org resource ' . $_REQUEST['item'] . ' does not exist', 'MESSAGE' => 'Sorry, we were unable to find a resource at <a href="http://dbpedia.org">http://dbpedia.org</a> that matches your request!', 'FLICKRWRAPPR_HOMEPAGE' => FLICKRWRAPPR_HOMEPAGE));
            }
        }
    }
    exit;
} else {
    /* Output model */
    $ser = new RdfSerializer();
    $rdf = $ser->serialize($resultModel);
    if (clientAcceptsRDF()) {
        outputRdf($rdf);
    } else {
        /* Prepare HTML version */
        $res = $resultModel->sparqlQuery($QUERY_DISPLAY);
        $photos_html = "";
        foreach ($res as $line) {
            $photos_html .= parameterize($HTML_TEMPLATE_PHOTO, array("SRC" => $line['?img']->getURI(), "HREF" => $line['?flickrpage']->getURI()));
        }
        echo parameterize($HTML_TEMPLATE_RESULTS, array("TITLE" => $resultsLabel, "RDF" => htmlspecialchars($rdf), "PHOTOS_HTML" => $photos_html, "FLICKRWRAPPR_HOMEPAGE" => FLICKRWRAPPR_HOMEPAGE, "FLICKR_TOS_URL" => FLICKR_TOS_URL));
    }
}