*/
protected $maxPerPage = 345;
- /**
- * Maximum number of pages to show on single index subpage.
- *
- * @var int $maxLineCount
- */
- protected $maxLineCount = 100;
-
- /**
- * Maximum number of chars to show for an entry.
- *
- * @var int $maxPageLength
- */
- protected $maxPageLength = 70;
-
- /**
- * Maximum number of pages in a hierarchical ("top level") list.
- *
- * Traversal of the entire page list by spidering the top levels is thought
- * to require O(N^3) DB CPU time where N is the number of pages on the wiki.
- * See bug 56840. If this limit is exceeded, the behaviour becomes like a
- * simple alphabetic pager.
- */
- protected $maxTopLevelPages = 50000;
-
/**
* Determines, which message describes the input field 'nsfrom'.
*
$where[] = 'page_title <= ' . $dbr->addQuotes( $to );
}
- global $wgMemc;
- $key = wfMemcKey( 'allpages', 'ns', $namespace, sha1( $from ), sha1( $to ) );
- $lines = $wgMemc->get( $key );
-
- $count = $dbr->estimateRowCount( 'page', '*', $where, __METHOD__ );
-
- // Don't show a hierarchical list if the number of pages is very large,
- // since generating it will cause a lot of scanning
- if ( $count > $this->maxTopLevelPages ) {
- $this->showChunk( $namespace, $from, $to, $hideredirects );
-
- return;
- }
-
- $maxPerSubpage = intval( $count / $this->maxLineCount );
- $maxPerSubpage = max( $maxPerSubpage, $this->maxPerPage );
-
- if ( !is_array( $lines ) ) {
- $options = array( 'LIMIT' => 1 );
- $options['ORDER BY'] = 'page_title ASC';
- $firstTitle = $dbr->selectField( 'page', 'page_title', $where, __METHOD__, $options );
- $lastTitle = $firstTitle;
- # This array is going to hold the page_titles in order.
- $lines = array( $firstTitle );
- # If we are going to show n rows, we need n+1 queries to find the relevant titles.
- $done = false;
- while ( !$done ) {
- // Fetch the last title of this chunk and the first of the next
- $chunk = ( $lastTitle === false )
- ? array()
- : array( 'page_title >= ' . $dbr->addQuotes( $lastTitle ) );
- $res = $dbr->select( 'page', /* FROM */
- 'page_title', /* WHAT */
- array_merge( $where, $chunk ),
- __METHOD__,
- array( 'LIMIT' => 2, 'OFFSET' => $maxPerSubpage - 1, 'ORDER BY' => 'page_title ASC' )
- );
-
- $s = $dbr->fetchObject( $res );
- if ( $s ) {
- array_push( $lines, $s->page_title );
- } else {
- // Final chunk, but ended prematurely. Go back and find the end.
- $endTitle = $dbr->selectField( 'page', 'MAX(page_title)',
- array_merge( $where, $chunk ),
- __METHOD__ );
- array_push( $lines, $endTitle );
- $done = true;
- }
-
- $s = $res->fetchObject();
- if ( $s ) {
- array_push( $lines, $s->page_title );
- $lastTitle = $s->page_title;
- } else {
- // This was a final chunk and ended exactly at the limit.
- // Rare but convenient!
- $done = true;
- }
- $res->free();
- }
- $wgMemc->add( $key, $lines, 3600 );
- }
-
- // If there are only two or less sections, don't even display them.
- // Instead, display the first section directly.
- if ( count( $lines ) <= 2 ) {
- if ( !empty( $lines ) ) {
- $this->showChunk( $namespace, $from, $to, $hideredirects );
- } else {
- $output->addHTML( $this->namespaceForm( $namespace, $from, $to, $hideredirects ) );
- }
-
- return;
- }
-
- # At this point, $lines should contain an even number of elements.
- $out .= Xml::openElement( 'table', array( 'class' => 'allpageslist' ) );
- while ( count( $lines ) > 0 ) {
- $inpoint = array_shift( $lines );
- $outpoint = array_shift( $lines );
- $out .= $this->showline( $inpoint, $outpoint, $namespace, $hideredirects );
- }
- $out .= Xml::closeElement( 'table' );
- $nsForm = $this->namespaceForm( $namespace, $from, $to, $hideredirects );
-
- # Is there more?
- if ( $this->including() ) {
- $out2 = '';
- } else {
- if ( isset( $from ) || isset( $to ) ) {
- $out2 = Xml::openElement( 'table', array( 'class' => 'mw-allpages-table-form' ) ) .
- '<tr>
- <td>' .
- $nsForm .
- '</td>
- <td class="mw-allpages-nav">' .
- Linker::link( $this->getPageTitle(), $this->msg( 'allpages' )->escaped(),
- array(), array(), 'known' ) .
- "</td>
- </tr>" .
- Xml::closeElement( 'table' );
- } else {
- $out2 = $nsForm;
- }
- }
- $output->addHTML( $out2 . $out );
- }
-
- /**
- * Show a line of "ABC to DEF" ranges of articles
- *
- * @param string $inpoint Lower limit of pagenames
- * @param string $outpoint Upper limit of pagenames
- * @param int $namespace (Default NS_MAIN)
- * @param bool $hideRedirects Don't show redirects. Default: false
- * @return string
- */
- function showline( $inpoint, $outpoint, $namespace = NS_MAIN, $hideRedirects = false ) {
- // Use content language since page titles are considered to use content language
- global $wgContLang;
-
- $inpointf = str_replace( '_', ' ', $inpoint );
- $outpointf = str_replace( '_', ' ', $outpoint );
-
- // Don't let the length runaway
- $inpointf = $wgContLang->truncate( $inpointf, $this->maxPageLength );
- $outpointf = $wgContLang->truncate( $outpointf, $this->maxPageLength );
-
- $queryParams = array(
- 'from' => $inpoint,
- 'to' => $outpoint,
- );
-
- if ( $namespace ) {
- $queryParams['namespace'] = $namespace;
- }
- if ( $hideRedirects ) {
- $queryParams['hideredirects'] = 1;
- }
-
- $url = $this->getPageTitle()->getLocalURL( $queryParams );
- $inlink = Html::element( 'a', array( 'href' => $url ), $inpointf );
- $outlink = Html::element( 'a', array( 'href' => $url ), $outpointf );
-
- $out = $this->msg( 'alphaindexline' )->rawParams(
- "$inlink</td><td>",
- "</td><td>$outlink"
- )->escaped();
-
- return '<tr><td class="mw-allpages-alphaindexline">' . $out . '</td></tr>';
+ $this->showChunk( $namespace, $from, $to, $hideredirects );
}
/**