3 # ISBNs in wiki pages will create links to this page, with
4 # the ISBN passed in via the query string.
6 function wfSpecialBooksources()
8 $isbn = $_REQUEST["isbn"];
10 $bsl = new BookSourceList( $isbn );
14 class BookSourceList
{
18 function BookSourceList( $isbn )
25 global $wgOut, $wgUser, $wgLang;
26 global $ip, $wpBlockAddress, $wpBlockReason;
27 $fname="BookSourceList->show()";
29 $wgOut->setPagetitle( wfMsg( "booksources" ) );
30 $bstext=wfMsg( "booksourcetext" );
34 $bstitle=Title
::newFromText(wfmsg("booksources"));
35 $sql="SELECT cur_text FROM cur WHERE cur_namespace=4 and cur_title='" . $bstitle->getPrefixedDBkey()."'";
36 $res=wfQuery($sql,$fname);
37 if( ($s=wfFetchObject($res)) and ($s->cur_text
!="")) {
40 $bstext=str_replace("WIKI-ISBN",$this->mIsbn
,$bstext);
47 $wgOut->addWikiText( $bstext );
50 # If ISBN is blank, just show a list of links to the
51 # home page of the various book sites. Otherwise, show
52 # a list of links directly to the book.
54 if(!$noautolist) { # only do this if we haven't already shown [[Wikipedia:Book sources]]
56 $bs = $wgLang->getBookstoreList() ;
57 $bsn = array_keys ( $bs ) ;
58 foreach ( $bsn as $name ) {
60 if ( ! $this->mIsbn
) {
61 $adr = explode ( ":" , $adr , 2 ) ;
62 $adr = explode ( "/" , $adr[1] ) ;
64 while ( $a == "" ) $a = array_shift ( $adr ) ;
67 $adr = str_replace ( "$1" , $this->mIsbn
, $adr ) ;
69 $s .= "<li><a href=\"{$adr}\">{$name}</a></li>\n" ;
73 $wgOut->addHTML( $s );