3 # ISBNs in wiki pages will create links to this page, with
4 # the ISBN passed in via the query string.
6 function wfSpecialBooksources( $par )
12 $isbn = $wgRequest->getVal( 'isbn' );
14 $isbn = preg_replace( '/[^0-9X]/', '', $isbn );
16 $bsl = new BookSourceList( $isbn );
20 class BookSourceList
{
24 function BookSourceList( $isbn )
31 global $wgOut, $wgUser, $wgLang;
32 $fname = "BookSourceList::show()";
35 $wgOut->setPagetitle( wfMsg( "booksources" ) );
36 $bstext = wfMsg( "booksourcetext" );
39 $bstitle = Title
::newFromText( wfmsg( "booksources" ) );
40 $sql = "SELECT cur_text FROM cur " .
41 "WHERE cur_namespace=4 and cur_title='" .
42 wfStrencode( $bstitle->getDBkey() ) . "'";
43 $res = wfQuery( $sql, DB_READ
, $fname );
44 if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text
!= "" ) ) {
45 $bstext = $s->cur_text
;
46 $bstext = str_replace( "MAGICNUMBER", $this->mIsbn
, $bstext );
51 $wgOut->addWikiText( $bstext );
53 # If ISBN is blank, just show a list of links to the
54 # home page of the various book sites. Otherwise, show
55 # a list of links directly to the book.
57 if( !$noautolist ) { # only do this if we haven't already shown [[Wikipedia:Book sources]]
59 $bs = $wgLang->getBookstoreList() ;
60 $bsn = array_keys ( $bs ) ;
61 foreach ( $bsn as $name ) {
63 if ( ! $this->mIsbn
) {
64 $adr = explode ( ":" , $adr , 2 ) ;
65 $adr = explode ( "/" , $adr[1] ) ;
67 while ( $a == "" ) $a = array_shift ( $adr ) ;
70 $adr = str_replace ( "$1" , $this->mIsbn
, $adr ) ;
72 $s .= "<li><a href=\"{$adr}\" class=\"external\">{$name}</a></li>\n" ;
76 $wgOut->addHTML( $s );