Beispiel #1
0
function DescriptionFromRDF(&$article)
{
    $nt = $article->getTitle();
    $uri = $nt->getFullUrl();
    $model = MwRdfGetModel($article);
    $results = $model->rdqlQuery("SELECT ?description " . "WHERE (<{$uri}> dc:description ?description) " . "USING dc FOR http://purl.org/dc/elements/1.1/", FALSE);
    $desc = '';
    foreach ($results as $row) {
        $rowval = preg_replace("/^\"(.*?)\"\$/", '\\1', $row['?description']);
        $desc .= ($desc ? ' ' : '') . $rowval;
    }
    return $desc;
}
Beispiel #2
0
 function wfSpecialRdf($par)
 {
     global $wgRequest, $wgRdfDefaultModels, $wgRdfOutputFunctions;
     $target = $wgRequest->getVal('target');
     if (!isset($target)) {
         # no target parameter
         MwRdfShowForm();
     } else {
         if (strlen($target) == 0) {
             # no target contents
             MwRdfShowForm(wfMsg('badtitle'));
         } else {
             $nt = Title::newFromText($target);
             if ($nt->getArticleID() == 0) {
                 # not an article
                 MwRdfShowForm(wfMsg('badtitle'));
             } else {
                 $article = new Article($nt);
                 # Note: WebRequest chokes on arrays here
                 $modelnames = $_REQUEST['modelnames'];
                 if (is_null($modelnames)) {
                     $modelnames = $wgRdfDefaultModels;
                 }
                 if (is_string($modelnames)) {
                     $modelnames = explode(',', $modelnames);
                 }
                 $format = $wgRequest->getVal('format', 'xml');
                 $outfun = $wgRdfOutputFunctions[$format];
                 if (!isset($outfun)) {
                     wfDebugDieBacktrace("No output function for format '{$format}'.");
                 }
                 $fullModel = MwRdfGetModel($article, $modelnames);
                 $outfun($fullModel);
             }
         }
     }
 }