X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FSpecialBooksources.php;h=13994c404a937e04d15ea04ea96f615aac3fb046;hb=eebe7e3ef58635e18d08bc6ee9b2c53d57370112;hp=c16b7eb8d619c521b76535ec4bd31d8dfa8198c3;hpb=b9d208a4f2e5b821954321efd01451b27b291d10;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialBooksources.php b/includes/SpecialBooksources.php index c16b7eb8d6..13994c404a 100644 --- a/includes/SpecialBooksources.php +++ b/includes/SpecialBooksources.php @@ -1,78 +1,94 @@ -getVal( 'isbn' ); + } + $isbn = preg_replace( '/[^0-9X]/', '', $isbn ); + $bsl = new BookSourceList( $isbn ); $bsl->show(); } class BookSourceList { - var $mIsbn; - function BookSourceList( $isbn ) - { + function BookSourceList( $isbn ) { $this->mIsbn = $isbn; } - function show() - { - global $wgOut, $wgUser, $wgLang; - global $ip, $wpBlockAddress, $wpBlockReason; - $fname="BookSourceList->show()"; + function show() { + global $wgOut; $wgOut->setPagetitle( wfMsg( "booksources" ) ); - $bstext=wfMsg( "booksourcetext" ); - - if($this->mIsbn) - { - $bstitle=Title::newFromText(wfmsg("booksources")); - $sql="SELECT cur_text FROM cur WHERE cur_namespace=4 and cur_title='" . $bstitle->getPrefixedDBkey()."'"; - $res=wfQuery($sql,$fname); - if( ($s=wfFetchObject($res)) and ($s->cur_text!="")) { + if( empty( $this->mIsbn ) ) { + $this->askForm(); + } else { + $this->showList(); + } + } - $bstext=$s->cur_text; - $bstext=str_replace("WIKI-ISBN",$this->mIsbn,$bstext); - $noautolist=1; - } - + function showList() { + global $wgOut, $wgUser, $wgLang; + $fname = "BookSourceList::showList()"; + + # First, see if we have a custom list setup in + # [[Wikipedia:Book sources]] or equivalent. + $bstitle = Title::makeTitle( NS_WIKIPEDIA, wfMsg( "booksources" ) ); + $dbr =& wfGetDB( DB_SLAVE ); + $bstext = $dbr->selectField( 'cur', 'cur_text', $bstitle->curCond(), $fname ); + if( $bstext ) { + $bstext = str_replace( "MAGICNUMBER", $this->mIsbn, $bstext ); + $wgOut->addWikiText( $bstext ); + return; } - - - $wgOut->addWikiText( $bstext ); - - # If ISBN is blank, just show a list of links to the - # home page of the various book sites. Otherwise, show - # a list of links directly to the book. - - if(!$noautolist) { # only do this if we haven't already shown [[Wikipedia:Book sources]] - $s = "\n"; + + $wgOut->addHTML( $s ); + } + + function askForm() { + global $wgOut, $wgLang, $wgTitle; + $fname = "BookSourceList::askForm()"; + + $action = $wgTitle->escapeLocalUrl(); + $isbn = htmlspecialchars( wfMsg( "isbn" ) ); + $go = htmlspecialchars( wfMsg( "go" ) ); + $out = "
+ $isbn: + +
"; + $wgOut->addHTML( $out ); + } } ?>