Extension:AllBooks

What can this extension do?

 * Creates the variable.
 * This extension will list all books in a Wikibooks wiki when using two of the most common naming schemes:  and.
 * Currently books with a subtitle like  are not detected as a book (they are considered not to be a top-level page because there is a colon in the title); they should be "registered" with this extension by providing a soft redirect from   to   so that the book will be listed and counted properly. The All pages links on Special:AllBooks links to Special:PrefixIndex/Book, so the book subpages will not be listed there. Users will have to click the link at the soft redirect to get to your book. Perhaps using that naming convention isn't the best thing to do anyways, as it makes very long pagenames.
 * This behaviour may change in the future to accommodate additional naming schemes in use on the various language editions of Wikibooks, or to better accommodate the two mentioned above.

Usage

 * Special:AllBooks lists all books, and links to the appropriate PrefixIndex.
 * Allows you to list books starting at some point in the alphabet using
 * is the number of books on the wiki.

Download instructions
There are four files, which all go in. Please cut and paste the code found below for each file. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation
To install this extension, add the following to LocalSettings.php:

AllBooks.php

 * This code goes in the file

AllBooks_body.php
';   #output $wgOut->addHTML(     wfMsgExt( 'allbookspagetext', array( 'parse' ) ) . $modulo .      $pager->getNavigationBar .      $pager->getBody .      $pager->getNavigationBar    ); } }
 * This code goes in the file

class AllBooksPager extends AlphabeticPager {

#return the information for querying the database function getQueryInfo { global $wgRequest; #get request data $allb_ns = $wgRequest->getText('namespace'); if (is_null($allb_ns)) $allb_ns = NS_MAIN; return array(     'tables' => 'page',      'fields' => "page_title",      'conds' => array("page_is_redirect" => 0, "page_namespace" => $allb_ns, "page_title NOT REGEXP '".wfMsg('allbooks-regex')."'")      ); } function getStartBody { return ''; } function getEndBody { return ''; } function getEmptyBody { return Xml::elementClean('em', null, wfMsg('allbooks-empty')); } #get the field used for indexing function getIndexField { return "page_title"; }

#return a row function formatRow( $row ) { global $wgRequest; #get request data $allb_ns = $wgRequest->getText('namespace'); if (is_null($allb_ns)) $allb_ns = NS_MAIN; #get a new title from the db key $titolo = Title::newFromDBkey($row->page_title); #link to allpages $allp = Title::newFromText("Special:PrefixIndex"); $allp = $allp->getFullURL("from=".$titolo->getPartialURL."&namespace=".$allb_ns); #get a list item $link = Xml::elementClean('a', array('href' =>$titolo->getFullURL), $titolo->getText); $allp_l = Xml::elementClean('a', array('href' => $allp), wfMsg('allbooks-allp')); $s = "$link ($allp_l) "; return $s; }

}

AllBooks.i18n.php

 * This code goes in the file

NumberOfBooks.php

 * This code goes in the file