check();
$this->store = new LODrStore();
$this->user = new LODrUser($user, $this->store);
$this->updater = new LODrUpdater($this->user, $this->store);
$this->tagger = new LODrTagger($this->store);
$this->action = $action;
$this->format = $format;
LODrTools::set_lang($lang);
}
// Check config
private function check() {
global $user, $arc_config, $base, $secret;
if(!$user) echo 'Please set the $user var in config file';
if(!$arc_config) echo 'Please set the $arc_config var in config file';
if(!$base) echo 'Please set the $base var in config file';
if(!$secret) echo 'Please set the $secret var in config file';
}
// Accessors
public function set_item($item) {
$this->item = $item;
}
public function set_tag($tag) {
$this->tag = $tag;
}
public function set_uri($uri) {
// Regexp hack
$uri = str_replace('http:/', 'http://', $uri);
$uri = str_replace('https:/', 'https://', $uri);
$this->uri = $uri;
}
public function set_format($format) {
$this->format = $format;
}
public function set_view($view) {
$this->view = $view;
}
public function set_action($action) {
$this->action = $action;
}
public function set_update($tags) {
$this->update = $tags;
}
public function set_output($output) {
$this->output .= $output;
}
public function exhibit() {
global $base;
$exhibit = "{$base}exhibit/";
if($this->tag) $exhibit .= 'tag/'.$this->tag;
elseif($this->uri) $exhibit .= 'uri/'.$this->uri;
else $exhibit .= $this->action;
return $exhibit;
}
// Setup LODr engine
public function setup() {
global $base;
$this->store->setup();
$this->update();
echo "System is ready !";
}
// Update LODr data
public function update() {
$this->updater->update();
}
// Run SPARL query
public function do_query($query) {
return $this->store->do_query($query);
}
// Run the LODr engine !
public function go() {
if($this->action == 'clouds') $data = new LODrClouds($this->store);
if($this->action == 'items') $data = new LODrItemsList($this->store);
if($this->action == 'orphans') $data = new LODrOrphansList($this->store);
if($this->action == 'conflicts') $data = new LODrConflictsList($this->store);
if($this->action == 'lod') $data = new LODrLODedList($this->store);
if($this->action == 'tag') $data = new LODrTagList($this->store, $this->tag);
if($this->action == 'uri') $data = new LODrURIList($this->store, $this->uri);
elseif($this->item) {
$graph = LODrTools::get_graphuri($this->item);
$data = new LODrItem($this->store, $graph);
if($this->action == 'edit') $data->set_edit($this->action);
if($this->update) $this->msg = $this->tagger->update_tagging($graph, $this->update);
}
elseif($this->action == 'sitemap') {
$this->sitemap();
exit();
}
elseif($this->action == 'setup') {
$this->setup();
exit();
}
elseif($this->action == 'sparql') {
$this->store->endpoint();
exit();
}
elseif($this->action == 'update') {
$this->update();
exit();
}
$this->data = $data->go($this->format);
$this->title = $data->title;
$this->output();
}
private function sitemap() {
global $base;
// TODO :
// - Provide RDF informations about the dataset at sc:datasetURI (RDFa + VOID)
// - Provide random sampleURI
// LODrSitemap class ??
$xml = <<<_END_
LODr data at $base
$base
${base}item/
${base}tag/
*
${base}sparql
_END_;
header("Content-type: text/xml");
echo $xml;
}
public function output() {
global $base, $theme;
if($this->format == 'html') {
header('Content-Type: text/html; charset=utf-8');
require_once(dirname(__FILE__)."/themes/$theme/LODrTheme.php");
} elseif($this->format == 'exhibit') {
return $this->output;
}
}
}
?>