--- a/Utils/WikiTagUtils.php Thu Jan 30 17:52:14 2014 +0100
+++ b/Utils/WikiTagUtils.php Fri Jan 31 16:08:50 2014 +0100
@@ -281,16 +281,25 @@
/**
* Builds DbPedia URI
*/
- public static function getDbpediaUri($label, $params=[], $throw_error=true)
+ public static function getDbpediaUri($label, $params=[], $throw_error=true, $req_param="label")
{
// Get lang from url
$dbp_url = $GLOBALS["kernel"]->getContainer()->getParameter("wiki_tag.url_templates")["dbpedia_sparql"];
$lang = substr($dbp_url, 7, 2);
+ $query = 'select distinct * where { ?s rdfs:label "'.$label.'"@'.$lang.' . FILTER (regex(?s, "^http\\\\://[^:]+$")) }';
+ if($req_param=="pageid"){
+ $query = 'select distinct * where { ?s dbpedia-owl:wikiPageID '.$label.' }';
+ }
+ elseif ($req_param=="wikiurl"){
+ $query = 'select distinct * where { ?s foaf:isPrimaryTopicOf <'.$label.'> }';
+ }
+
+
// filter with regexp to avoid results with "category:LABEL" or other "abc:LABEL"
//"query" => 'select distinct * where { ?s rdfs:label "'.$label.'"@'.$lang.' }',
//"query" => 'select distinct * where { ?s rdfs:label "'.$label.'"@'.$lang.' . FILTER (regex(?s, "^http\\\\://[^:]+$")) }',
$params = [
- "query" => 'select distinct * where { ?s rdfs:label "'.$label.'"@'.$lang.' . FILTER (regex(?s, "^http\\\\://[^:]+$")) }',
+ "query" => $query,
"format" => 'application/json',
];