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

function transform( $text ) { return trim( $text, ' *' ); }

function isUsable( $text ) { return substr( $text, 0, 1 ) == '*'; }

function getNamespaces($input) { global $wgContLang, $wgRequest; $lines = explode( "\n", $input ); $ns = array; foreach( $lines as $line ) { $line = trim( $line ); #check if line is usable and if namespace exists if( AllBooks::isUsable( $line ) ) { $line = AllBooks::transform($line); if ($line == 'main') { $line = wfMsg( 'blanknamespace');} #default $nsId = $wgContLang->getLocalNsIndex($line); $ns[$nsId] = $line; }	}	return $ns; } function getCheckboxes ($ns) { global $wgRequest; $fields = ''; $allfalse = true; foreach($ns as $nsId => $line) $allfalse = $allfalse && !( $wgRequest->getCheck( 'ns'. $nsId ) ); foreach($ns as $nsId => $line) { $fields .= Xml::openElement('span', array('style' => 'white-space: nowrap;')). Xml::check("ns$nsId", $wgRequest->getCheck( 'ns'. $nsId) || $allfalse, array('id' => $line)). ' ' .						Xml::element('label', array('for' => $line), $line). Xml::closeElement('span')." \n"; }	return $fields; }

function getNsOK ($ns) { global $wgRequest; $r = array; $allfalse = true; foreach($ns as $nsId => $line) $allfalse = $allfalse && !( $wgRequest->getCheck( 'ns'. $nsId ) ); foreach($ns as $nsId => $line) { if ( $wgRequest->getCheck( 'ns'. $nsId) || $allfalse ) $r[$nsId] = $line; } 	return $r; } }

class AllBooksPager extends AlphabeticPager { #return the information for querying the database function getQueryInfo { global $wgRequest; #get request data $allb_ns = AllBooks::getNsOK(AllBooks::getNamespaces(wfMsg('allbooksnamespaces'))); $allb_ns = array_keys($allb_ns); return array(     'tables' => 'page',      'fields' => array("page_title","page_namespace"),      '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 $wgContLang; #get a new title from the db key $title = $wgContLang->getNsText($row->page_namespace).":".$row->page_title; $titolo = Title::newFromDBkey($title); #link to allpages $allp = Title::newFromText($wgContLang->specialPage("Prefixindex")); $allp = $allp->getFullURL("from=".$titolo->getPartialURL."&namespace=".$row->page_namespace); #get a list item $link = Xml::elementClean('a', array('href' => $titolo->getFullURL), $titolo->getPrefixedText); $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