Support for [[Wikipedia:Book sources]] (or localized text), content of
authorErik Moeller <erik@users.mediawiki.org>
Mon, 19 May 2003 21:01:09 +0000 (21:01 +0000)
committerErik Moeller <erik@users.mediawiki.org>
Mon, 19 May 2003 21:01:09 +0000 (21:01 +0000)
this page, with WIKI-ISBN replaced by ISBN number, is used instead of the
text in LanguageFoo.php for queries that include an ISBN.

includes/SpecialBooksources.php

index a3722cd..c16b7eb 100644 (file)
@@ -24,34 +24,55 @@ class BookSourceList {
        {
                global $wgOut, $wgUser, $wgLang;
                global $ip, $wpBlockAddress, $wpBlockReason;
+               $fname="BookSourceList->show()";
 
                $wgOut->setPagetitle( wfMsg( "booksources" ) );
-               $wgOut->addWikiText( wfMsg( "booksourcetext" ) );
+               $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!="")) {
+       
+                               $bstext=$s->cur_text;
+                               $bstext=str_replace("WIKI-ISBN",$this->mIsbn,$bstext);
+                               $noautolist=1;
+                       }                       
+                       
+               }
+
+
+               $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.
 
-               $s = "<ul>\n";
-               $bs = $wgLang->getBookstoreList() ;
-               $bsn = array_keys ( $bs ) ;
-               foreach ( $bsn as $name ) {
-                       $adr = $bs[$name] ;
-                       if ( ! $this->mIsbn ) {
-                               $adr = explode ( ":" , $adr , 2 ) ;
-                               $adr = explode ( "/" , $adr[1] ) ;
-                               $a = "" ;
-                               while ( $a == "" ) $a = array_shift ( $adr ) ;
-                               $adr = "http://".$a ;
-                       } else {
-                               $adr = str_replace ( "$1" , $this->mIsbn , $adr ) ;
-                       }
-                       $s .= "<li><a href=\"{$adr}\">{$name}</a></li>\n" ;
-                       }
-               $s .= "</ul>\n";
+               if(!$noautolist) { # only do this if we haven't already shown [[Wikipedia:Book sources]]
+                       $s = "<ul>\n";
+                       $bs = $wgLang->getBookstoreList() ;
+                       $bsn = array_keys ( $bs ) ;
+                       foreach ( $bsn as $name ) {
+                               $adr = $bs[$name] ;
+                               if ( ! $this->mIsbn ) {
+                                       $adr = explode ( ":" , $adr , 2 ) ;
+                                       $adr = explode ( "/" , $adr[1] ) ;
+                                       $a = "" ;
+                                       while ( $a == "" ) $a = array_shift ( $adr ) ;
+                                       $adr = "http://".$a ;
+                               } else {
+                                       $adr = str_replace ( "$1" , $this->mIsbn , $adr ) ;
+                               }
+                               $s .= "<li><a href=\"{$adr}\">{$name}</a></li>\n" ;
+                               }
+                       $s .= "</ul>\n";
 
-               $wgOut->addHTML( $s );
-       }
+                       $wgOut->addHTML( $s );
+                       }
+               }
 }
 
 ?>