Initial revision
[lhc/web/wiklou.git] / includes / SpecialBooksources.php
1 <?
2
3 # ISBNs in wiki pages will create links to this page, with
4 # the ISBN passed in via the query string.
5
6 function wfSpecialBooksources()
7 {
8 $isbn = $_REQUEST["isbn"];
9
10 $bsl = new BookSourceList( $isbn );
11 $bsl->show();
12 }
13
14 class BookSourceList {
15
16 var $mIsbn;
17
18 function BookSourceList( $isbn )
19 {
20 $this->mIsbn = $isbn;
21 }
22
23 function show()
24 {
25 global $wgOut, $wgUser, $wgLang;
26 global $ip, $wpBlockAddress, $wpBlockReason;
27
28 $wgOut->setPagetitle( wfMsg( "booksources" ) );
29 $wgOut->addWikiText( wfMsg( "booksourcetext" ) );
30
31 # If ISBN is blank, just show a list of links to the
32 # home page of the various book sites. Otherwise, show
33 # a list of links directly to the book.
34
35 $s = "<ul>\n";
36 $bs = $wgLang->getBookstoreList() ;
37 $bsn = array_keys ( $bs ) ;
38 foreach ( $bsn as $name ) {
39 $adr = $bs[$name] ;
40 if ( ! $this->mIsbn ) {
41 $adr = explode ( ":" , $adr , 2 ) ;
42 $adr = explode ( "/" , $adr[1] ) ;
43 $a = "" ;
44 while ( $a == "" ) $a = array_shift ( $adr ) ;
45 $adr = "http://".$a ;
46 } else {
47 $adr = str_replace ( "$1" , $this->mIsbn , $adr ) ;
48 }
49 $s .= "<li><a href=\"{$adr}\">{$name}</a></li>\n" ;
50 }
51 $s .= "</ul>\n";
52
53 $wgOut->addHTML( $s );
54 }
55 }
56
57 ?>