function _rdfx_query_find_literal in RDF Extensions 7.2
2 calls to _rdfx_query_find_literal()
File
- ./
rdfx.query.inc, line 17 - Functions for querying with SPARQL or extracting triples from an ARC2-style data structure.
Code
function _rdfx_query_find_literal(&$model, $queries) {
$literal = array();
foreach ($queries as $query) {
list($s, $p, $o) = $query;
$triples = _rdfx_query_find_all($model, $s, $p, $o);
// We create an associative array based on the language code of the
// literal. The language codes Drupal uses are specified in includes/iso.inc.
foreach ($triples as $triple) {
if ($triple['o_lang'] !== '') {
// Chinese and Portuguese are the only languages with a >2 letter
// langcode.
if (preg_match('/(zh-hans)|(zh-hant)|(pt-pt)|(pt-br)/', $triple['o_lang'])) {
$langcode = $triple['o_lang'];
}
else {
$lang_array = explode('-', $triple['o_lang']);
$langcode = !empty($lang_array[0]) ? $lang_array[0] : $triple['o_lang'];
}
}
else {
$langcode = 'und';
}
$literal[$langcode] = $triple['o'];
}
}
return $literal;
}