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;
51 $fname = "BookSourceList::showList()";
53 # First, see if we have a custom list setup in
54 # [[Wikipedia:Book sources]] or equivalent.
55 $bstitle = Title
::makeTitleSafe( NS_PROJECT
, wfMsg( "booksources" ) );
57 $revision = Revision
::newFromTitle( $bstitle );
59 $bstext = $revision->getText();
61 $bstext = str_replace( "MAGICNUMBER", $this->mIsbn
, $bstext );
62 $wgOut->addWikiText( $bstext );
68 # Otherwise, use the list of links in the default Language.php file.
69 $s = wfMsgWikiHtml( 'booksourcetext' ) . "<ul>\n";
70 $bs = $wgContLang->getBookstoreList() ;
71 $bsn = array_keys ( $bs ) ;
72 foreach ( $bsn as $name ) {
74 if ( ! $this->mIsbn
) {
75 $adr = explode( ":" , $adr , 2 );
76 $adr = explode( "/" , $adr[1] );
79 $a = array_shift( $adr );
83 $adr = str_replace ( "$1" , $this->mIsbn
, $adr ) ;
85 $name = htmlspecialchars( $name );
86 $adr = htmlspecialchars( $adr );
87 $s .= "<li><a href=\"{$adr}\" class=\"external\">{$name}</a></li>\n" ;
91 $wgOut->addHTML( $s );
95 global $wgOut, $wgTitle;
96 $fname = "BookSourceList::askForm()";
98 $action = $wgTitle->escapeLocalUrl();
99 $isbn = htmlspecialchars( wfMsg( "isbn" ) );
100 $go = htmlspecialchars( wfMsg( "go" ) );
101 $out = "<form action=\"$action\" method='post'>
102 $isbn: <input name='isbn' id='isbn' />
103 <input type='submit' value=\"$go\" />
105 $wgOut->addHTML( $out );