3 * ISBNs in wiki pages will create links to this page, with the ISBN passed
4 * in via the query string.
12 function wfSpecialBooksources( $par ) {
17 $isbn = $wgRequest->getVal( 'isbn' );
19 $isbn = preg_replace( '/[^0-9X]/', '', $isbn );
21 $bsl = new BookSourceList( $isbn );
28 class BookSourceList
{
31 function BookSourceList( $isbn ) {
38 $wgOut->setPagetitle( wfMsg( "booksources" ) );
39 if( empty( $this->mIsbn
) ) {
47 global $wgOut, $wgUser, $wgLang;
48 $fname = "BookSourceList::showList()";
50 # First, see if we have a custom list setup in
51 # [[Wikipedia:Book sources]] or equivalent.
52 $bstitle = Title
::makeTitleSafe( NS_PROJECT
, wfMsg( "booksources" ) );
53 $dbr =& wfGetDB( DB_SLAVE
);
54 $bstext = $dbr->selectField( 'cur', 'cur_text', $bstitle->curCond(), $fname );
56 $bstext = str_replace( "MAGICNUMBER", $this->mIsbn
, $bstext );
57 $wgOut->addWikiText( $bstext );
61 # Otherwise, use the list of links in the default Language.php file.
62 $s = wfMsg( "booksourcetext" ) . "<ul>\n";
63 $bs = $wgLang->getBookstoreList() ;
64 $bsn = array_keys ( $bs ) ;
65 foreach ( $bsn as $name ) {
67 if ( ! $this->mIsbn
) {
68 $adr = explode( ":" , $adr , 2 );
69 $adr = explode( "/" , $adr[1] );
72 $a = array_shift( $adr );
76 $adr = str_replace ( "$1" , $this->mIsbn
, $adr ) ;
78 $name = htmlspecialchars( $name );
79 $adr = htmlspecialchars( $adr );
80 $s .= "<li><a href=\"{$adr}\" class=\"external\">{$name}</a></li>\n" ;
84 $wgOut->addHTML( $s );
88 global $wgOut, $wgLang, $wgTitle;
89 $fname = "BookSourceList::askForm()";
91 $action = $wgTitle->escapeLocalUrl();
92 $isbn = htmlspecialchars( wfMsg( "isbn" ) );
93 $go = htmlspecialchars( wfMsg( "go" ) );
94 $out = "<form action=\"$action\" method='post'>
95 $isbn: <input name='isbn' id='isbn' />
96 <input type='submit' value=\"$go\" />
98 $wgOut->addHTML( $out );