3 * ISBNs in wiki pages will create links to this page, with the ISBN passed
4 * in via the query string.
7 * @subpackage SpecialPage
13 function wfSpecialBooksources( $par ) {
18 $isbn = $wgRequest->getVal( 'isbn' );
20 $isbn = preg_replace( '/[^0-9X]/', '', $isbn );
22 $bsl = new BookSourceList( $isbn );
29 * @subpackage SpecialPage
31 class BookSourceList
{
34 function BookSourceList( $isbn ) {
41 $wgOut->setPagetitle( wfMsg( "booksources" ) );
42 if( $this->mIsbn
== '' ) {
50 global $wgOut, $wgContLang;
52 # First, see if we have a custom list setup in
53 # [[Wikipedia:Book sources]] or equivalent.
54 $bstitle = Title
::makeTitleSafe( NS_PROJECT
, wfMsg( "booksources" ) );
56 $revision = Revision
::newFromTitle( $bstitle );
58 $bstext = $revision->getText();
60 $bstext = str_replace( "MAGICNUMBER", $this->mIsbn
, $bstext );
61 $wgOut->addWikiText( $bstext );
67 # Otherwise, use the list of links in the default Language.php file.
68 $s = wfMsgWikiHtml( 'booksourcetext' ) . "<ul>\n";
69 $bs = $wgContLang->getBookstoreList() ;
70 $bsn = array_keys ( $bs ) ;
71 foreach ( $bsn as $name ) {
73 if ( ! $this->mIsbn
) {
74 $adr = explode( ":" , $adr , 2 );
75 $adr = explode( "/" , $adr[1] );
78 $a = array_shift( $adr );
82 $adr = str_replace ( "$1" , $this->mIsbn
, $adr ) ;
84 $name = htmlspecialchars( $name );
85 $adr = htmlspecialchars( $adr );
86 $s .= "<li><a href=\"{$adr}\" class=\"external\">{$name}</a></li>\n" ;
90 $wgOut->addHTML( $s );
94 global $wgOut, $wgTitle;
96 $action = $wgTitle->escapeLocalUrl();
97 $isbn = htmlspecialchars( wfMsg( "isbn" ) );
98 $go = htmlspecialchars( wfMsg( "go" ) );
99 $out = "<form action=\"$action\" method='post'>
100 $isbn: <input name='isbn' id='isbn' />
101 <input type='submit' value=\"$go\" />
103 $wgOut->addHTML( $out );