/** * Adds the site links of the given item to the RDF graph. * * @param Item $item */ public function addSiteLinks(Item $item) { $entityLName = $this->vocabulary->getEntityLName($item->getId()); /** @var SiteLink $siteLink */ foreach ($item->getSiteLinkList() as $siteLink) { if (!$this->isSiteIncluded($siteLink->getSiteId())) { continue; } // FIXME: we should check the site exists using hasGlobalId here before asuming it does $site = $this->siteLookup->getSite($siteLink->getSiteId()); // XXX: ideally, we'd use https if the target site supports it. $baseUrl = str_replace('$1', rawurlencode($siteLink->getPageName()), $site->getLinkPath()); // $site->getPageUrl( $siteLink->getPageName() ); if (!parse_url($baseUrl, PHP_URL_SCHEME)) { $url = "http:" . $baseUrl; } else { $url = $baseUrl; } $this->writer->about($url)->a(RdfVocabulary::NS_SCHEMA_ORG, 'Article')->say(RdfVocabulary::NS_SCHEMA_ORG, 'about')->is(RdfVocabulary::NS_ENTITY, $entityLName)->say(RdfVocabulary::NS_SCHEMA_ORG, 'inLanguage')->text($this->vocabulary->getCanonicalLanguageCode($site->getLanguageCode())); foreach ($siteLink->getBadges() as $badge) { $this->writer->say(RdfVocabulary::NS_ONTOLOGY, 'badge')->is(RdfVocabulary::NS_ENTITY, $this->vocabulary->getEntityLName($badge)); } } }