| @@ 1390-1409 (lines=20) @@ | ||
| 1387 | * @param string $lang |
|
| 1388 | * @return array array of labels (key: lang, val: label), or null if resource doesn't exist |
|
| 1389 | */ |
|
| 1390 | public function queryLabel($uri, $lang) { |
|
| 1391 | $query = $this->generateLabelQuery($uri, $lang); |
|
| 1392 | $result = $this->query($query); |
|
| 1393 | $ret = array(); |
|
| 1394 | foreach ($result as $row) { |
|
| 1395 | if (!isset($row->label)) { |
|
| 1396 | // existing concept but no labels |
|
| 1397 | return array(); |
|
| 1398 | } |
|
| 1399 | $ret[$row->label->getLang()] = $row->label; |
|
| 1400 | } |
|
| 1401 | ||
| 1402 | if (sizeof($ret) > 0) { |
|
| 1403 | // existing concept, with label(s) |
|
| 1404 | return $ret; |
|
| 1405 | } else { |
|
| 1406 | // nonexistent concept |
|
| 1407 | return null; |
|
| 1408 | } |
|
| 1409 | } |
|
| 1410 | ||
| 1411 | /** |
|
| 1412 | * Generates a SPARQL query to retrieve the super properties of a given property URI. |
|
| @@ 1433-1451 (lines=19) @@ | ||
| 1430 | * @param string $uri URI of a propertyes |
|
| 1431 | * @return array array super properties, or null if none exist |
|
| 1432 | */ |
|
| 1433 | public function querySuperProperties($uri) { |
|
| 1434 | $query = $this->generateSubPropertyOfQuery($uri); |
|
| 1435 | $result = $this->query($query); |
|
| 1436 | $ret = array(); |
|
| 1437 | foreach ($result as $row) { |
|
| 1438 | if (isset($row->superProperty)) { |
|
| 1439 | $ret[] = $row->superProperty->getUri(); |
|
| 1440 | } |
|
| 1441 | ||
| 1442 | } |
|
| 1443 | ||
| 1444 | if (sizeof($ret) > 0) { |
|
| 1445 | // return result |
|
| 1446 | return $ret; |
|
| 1447 | } else { |
|
| 1448 | // no result, return null |
|
| 1449 | return null; |
|
| 1450 | } |
|
| 1451 | } |
|
| 1452 | ||
| 1453 | ||
| 1454 | /** |
|