X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialBooksources.php;h=6d27c1b9815d258ffa72f8fdb6e8c9c5922c84dc;hb=2e641156d3b7b8812ea8226b4f36c9d36544e952;hp=87ba0cb1a6868c905731c695d51756dea905fed1;hpb=5446238520cceb067792338cdfc83a343b480e15;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialBooksources.php b/includes/specials/SpecialBooksources.php index 87ba0cb1a6..6d27c1b981 100644 --- a/includes/specials/SpecialBooksources.php +++ b/includes/specials/SpecialBooksources.php @@ -63,7 +63,7 @@ class SpecialBookSources extends SpecialPage { /** * Returns whether a given ISBN (10 or 13) is valid. True indicates validity. - * @param isbn string ISBN passed for check + * @param $isbn string ISBN passed for check * @return bool */ public static function isValidISBN( $isbn ) { @@ -130,6 +130,7 @@ class SpecialBookSources extends SpecialPage { * Determine where to get the list of book sources from, * format and output them * + * @throws MWException * @return string */ private function showList() { @@ -143,9 +144,18 @@ class SpecialBookSources extends SpecialPage { $page = $this->msg( 'booksources' )->inContentLanguage()->text(); $title = Title::makeTitleSafe( NS_PROJECT, $page ); # Show list in content language if( is_object( $title ) && $title->exists() ) { - $rev = Revision::newFromTitle( $title, false, Revision::AVOID_MASTER ); - $this->getOutput()->addWikiText( str_replace( 'MAGICNUMBER', $this->isbn, $rev->getText() ) ); - return true; + $rev = Revision::newFromTitle( $title, false, Revision::READ_NORMAL ); + $content = $rev->getContent(); + + if ( $content instanceof TextContent ) { + //XXX: in the future, this could be stored as structured data, defining a list of book sources + + $text = $content->getNativeData(); + $this->getOutput()->addWikiText( str_replace( 'MAGICNUMBER', $this->isbn, $text ) ); + return true; + } else { + throw new MWException( "Unexpected content type for book sources: " . $content->getModel() ); + } } # Fall back to the defaults given in the language file