*
* Author: David B. Lowery
*/
include_once '../../../config/symbini.php';
include_once 'fp/FPNetworkFactory.php';
include_once 'fp/common/AnnotationGenerator.php';
// check that the client helper has been installed
$file = 'fp/FPNetworkFactory.php';
$includePaths = explode(PATH_SEPARATOR, get_include_path());
$fileExists = false;
foreach ($includePaths as $p) {
    $fullname = $p . DIRECTORY_SEPARATOR . $file;
    if (is_file($fullname)) {
        $fileExists = true;
        break;
    }
}
if (!$fileExists) {
    echo "FilteredPush Support has been enabled in this Symbiota installation, but FilteredPush helper code is not installed.<BR>";
    echo "<strong>{$file} not found.</strong>";
} else {
    // Check for required query params
    if (array_key_exists('catalognumber', $_GET) && (array_key_exists('collectioncode', $_GET) || array_key_exists('institutioncode', $_GET))) {
        $endpoint = FPNetworkFactory::getSparqlEndpoint();
        // returns query result formatted as html
        $results = $endpoint->getAnnotations($_GET);
        echo $results;
    } else {
        throw new Exception("catalognumber and either collectioncode or institutioncode required for \"Annotations\" tab view.");
    }
}