forked from iRail/The-DataTank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.php
90 lines (78 loc) · 3.23 KB
/
router.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* This file is the router. It's where all calls come in. It will accept a request en refer it to the right Controller
*
* @package The-Datatank
* @copyright (C) 2011 by iRail vzw/asbl
* @license AGPLv3
* @author Werner Laurensse
* @author Pieter Colpaert
* @author Jan Vansteenlandt
*/
include_once('includes/glue.php');
include_once('includes/rb.php');
include_once('aspects/caching/Cache.class.php');
include_once('aspects/errors/usage/Exceptions.php');
include_once('aspects/errors/system/Exceptions.php');
include_once('aspects/logging/ErrorLogger.class.php');
include_once('controllers/AController.class.php');
include_once('controllers/RController.class.php');
include_once('controllers/CUDController.class.php');
include_once('TDT.class.php'); //general purpose static class
include_once('Config.class.php'); //Configfile
include_once('model/AResourceFactory.class.php');
include_once('model/GenericResourceFactory.class.php');
include_once('model/InstalledResourceFactory.class.php');
include_once('model/RemoteResourceFactory.class.php');
include_once('model/ResourcesModel.class.php');
include_once('model/resources/AResource.class.php');
include_once('model/semantics/RDFMapper.class.php');
include_once('model/semantics/RDFOutput.class.php');
define("RDFAPI_INCLUDE_DIR", "model/semantics/rdfapi-php/api/");
include_once(RDFAPI_INCLUDE_DIR . "RdfAPI.php");
include_once(RDFAPI_INCLUDE_DIR . "util/RdfUtil.php");
include_once(RDFAPI_INCLUDE_DIR . "vocabulary/VocabularyRes.php");
include_once(RDFAPI_INCLUDE_DIR . "resModel/ResModelP.php");
include_once(RDFAPI_INCLUDE_DIR . "model/DBase.php");
// The code for the wrapper_handler is in aspects/logging/ErrorLogger.class.php
set_error_handler('wrapper_handler');
// Time is always in UTC
date_default_timezone_set('UTC');
// Initialize the ORM with the right credentials
R::setup(Config::$DB,Config::$DB_USER,Config::$DB_PASSWORD);
//map urls to a classname
$urls = array(
// Calling the Read- controller
// This is a request on the representation
// explanation of the last part of regex:
// continue the REST parameters as long as no . is encountered. Continue format as long as no ? or end of URI occurs
// /package/resource/rest/para/meters.json?para=meter&filt=er
'/(?P<package>[^/]*)/(?P<resource>[^/]*)/?(?P<RESTparameters>([^.]*\.)*(?P<format>[^?/]*)).*' => 'RController',
// Calling the Create, Update, Delete- controller
// This is a request on the real-world object
// examples of matches:
// PUT /package/
// POST /package/resource/property/
// POST /package/resource
// DELETE /package/resource
// But also:
// GET /package/ - should give all resources in package in an exception
// GET /package/resource - should give a HTTP/1.1 303 See Other to the .about representation
'/(?P<package>[^/.]*)/?(?P<resource>[^/.]*)?/?(?P<RESTparameters>[^?.]*).*' => 'CUDController'
);
//This function will do the magic. See includes/glue.php
try {
glue::stick($urls);
}
catch(Exception $e){
ErrorHandler::logException($e);
}
//TODO Werner: needs to move.
class FeedbackHandler {
function POST($matches) {
require_once ('PostMessage.class.php');
$post = new PostMessage();
$post->post();
}
}
?>