diff --git a/examples/index_pages.php b/examples/index_pages.php index 2368df5..670e2ee 100644 --- a/examples/index_pages.php +++ b/examples/index_pages.php @@ -35,5 +35,7 @@ $existing = count( $prideAndPrejudiceIndex->getPageList( true ) ); // Output summary. -echo $prideAndPrejudiceIndex->getTitle() . " has $pagesCount pages ($existing of which exist) " - . "and is of quality '" . $prideAndPrejudiceIndex->getQuality() . "'.\n"; +echo $prideAndPrejudiceIndex->getTitle() + . " (on " . $enWs->getDomainName() . ", " . $enWs->getWikidataId() . ") " + . "has $pagesCount pages ($existing of which exist) " + . "and is of quality '" . $prideAndPrejudiceIndex->getQuality() . "'.\n"; diff --git a/examples/list.php b/examples/list.php index 7795113..ea1cfca 100644 --- a/examples/list.php +++ b/examples/list.php @@ -32,5 +32,5 @@ $wikisources = $wsApi->fetchWikisources(); echo count( $wikisources ) . " Wikisources found:\n"; foreach ( $wikisources as $ws ) { - echo "* " . $ws->getLanguageCode() . " - " . $ws->getLanguageName() . "\n"; + echo "* " . $ws->getLanguageCode() . " - " . $ws->getLanguageName() . " - " . $ws->getWikidataId() . "\n"; } diff --git a/src/Wikisource.php b/src/Wikisource.php index 4ea760f..9782790 100644 --- a/src/Wikisource.php +++ b/src/Wikisource.php @@ -121,7 +121,10 @@ public function getDomainName(): string { */ public function getWikidataId(): string { if ( !$this->wikidataId ) { - $this->getWikisoureApi()->fetchWikisource( $this->getLanguageCode() ); + // Get another Wikisource object, but via fetchWikisource() to ensure it has a Wikidata ID. + $this->wikidataId = $this->getWikisoureApi() + ->fetchWikisource( $this->getLanguageCode() ) + ->getWikidataId(); } return $this->wikidataId; }