예제 #1
0
 public function match($uri)
 {
     global $conf;
     global $localUri;
     global $uri;
     global $acceptContentType;
     global $endpoints;
     global $lodspk;
     require_once $conf['home'] . 'classes/MetaDb.php';
     $metaDb = new MetaDb($conf['metadata']['db']['location']);
     $pair = Queries::getMetadata($localUri, $acceptContentType, $metaDb);
     if ($pair == NULL) {
         // Original URI is not in metadata
         if (Queries::uriExist($uri, $endpoints['local'])) {
             $page = Queries::createPage($uri, $localUri, $acceptContentType, $metaDb);
             if ($page == NULL) {
                 HTTPStatus::send500("Can't write sqlite database.");
             }
             if ($conf['debug']) {
                 Logging::log("URI found, redirecting to " . $page);
             }
             HTTPStatus::send303($page, $acceptContentType);
             exit(0);
         } else {
             return false;
         }
     }
     return $pair;
 }
예제 #2
0
 public function match($uri)
 {
     global $conf;
     global $localUri;
     global $uri;
     global $acceptContentType;
     global $endpoints;
     global $lodspk;
     global $results;
     global $firstResults;
     require_once $conf['home'] . 'classes/MetaDb.php';
     $metaDb = new MetaDb($conf['metadata']['db']['location']);
     $pair = Queries::getMetadata($localUri, $acceptContentType, $metaDb);
     if ($pair == NULL) {
         // Original URI is not in metadata
         if (Queries::uriExist($uri, $endpoints['local'])) {
             $page = Queries::createPage($uri, $localUri, $acceptContentType, $metaDb);
             if ($page == NULL) {
                 HTTPStatus::send500("Can't write sqlite database.");
             }
             HTTPStatus::send303($page, $acceptContentType);
             exit(0);
         } else {
             return false;
         }
     }
     list($res, $page, $format) = $pair;
     $uri = $res;
     $queries = $this->getQueries();
     $e = $endpoints['local'];
     require_once $conf['home'] . 'lib/Haanga/lib/Haanga.php';
     Haanga::configure(array('cache_dir' => $conf['home'] . 'cache/', 'autoescape' => FALSE));
     $vars = compact('uri', 'lodspk', 'models', 'first');
     foreach ($queries as $l => $v) {
         $q = Utils::addPrefixes(file_get_contents($v));
         $fnc = Haanga::compile($q);
         $query = $fnc($vars, TRUE);
         $aux = $e->query($query, Utils::getResultsType($query));
         if ($aux["boolean"] === true) {
             $pair[] = $l;
             return $pair;
         }
     }
     return false;
 }
예제 #3
0
 public function match($uri)
 {
     global $conf;
     global $localUri;
     global $uri;
     global $acceptContentType;
     global $endpoints;
     global $lodspk;
     if ($conf['disableComponents'] == true) {
         return FALSE;
     }
     require_once 'classes/MetaDb.php';
     $metaDb = new MetaDb($conf['metadata']['db']['location']);
     $pair = Queries::getMetadata($localUri, $acceptContentType, $metaDb);
     if ($pair == NULL) {
         // Original URI is not in metadata
         if (Queries::uriExist($uri, $endpoints['local'])) {
             $page = Queries::createPage($uri, $localUri, $acceptContentType, $metaDb);
             if ($page == NULL) {
                 HTTPStatus::send500("Can't write sqlite database.");
             }
             HTTPStatus::send303($page, $acceptContentType);
             exit(0);
         } else {
             return false;
         }
     }
     $extension = Utils::getExtension($pair[2]);
     $curie = Utils::uri2curie($pair[0]);
     list($modelFile, $viewFile) = $this->getModelandView($curie, $extension);
     if ($modelFile == NULL) {
         return FALSE;
     }
     $result = array('res' => $pair[0], 'page' => $pair[1], 'format' => $pair[2], 'modelFile' => $modelFile, 'viewFile' => $viewFile);
     return $result;
 }