}
function closeShowCategory() {
- global $wgOut, $wgRequest, $wgExperimentalCategorySort;
+ global $wgOut, $wgRequest;
- if ( $wgExperimentalCategorySort ) {
- $from = $until = array();
- foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
- $from[$type] = $wgRequest->getVal( "{$type}from" );
- $until[$type] = $wgRequest->getVal( "{$type}until" );
- }
- } else {
- $from = $wgRequest->getVal( 'from' );
- $until = $wgRequest->getVal( 'until' );
+ $from = $until = array();
+ foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
+ $from[$type] = $wgRequest->getVal( "{$type}from" );
+ $until[$type] = $wgRequest->getVal( "{$type}until" );
}
$viewer = new CategoryViewer( $this->mTitle, $from, $until, $wgRequest->getValues() );
* else use sortkey...
*/
function getSubcategorySortChar( $title, $sortkey ) {
- global $wgContLang, $wgExperimentalCategorySort;
+ global $wgContLang;
if ( $title->getPrefixedText() == $sortkey ) {
$word = $title->getDBkey();
$word = $sortkey;
}
- if ( $wgExperimentalCategorySort ) {
- $firstChar = $wgContLang->firstLetterForLists( $word );
- } else {
- $firstChar = $wgContLang->firstChar( $word );
- }
+ $firstChar = $wgContLang->firstLetterForLists( $word );
return $wgContLang->convert( $firstChar );
}
*/
function addImage( Title $title, $sortkey, $pageLength, $isRedirect = false ) {
if ( $this->showGallery ) {
- global $wgExperimentalCategorySort;
- if ( $wgExperimentalCategorySort ) {
- $flip = $this->flip['file'];
- } else {
- $flip = $this->flip;
- }
+ $flip = $this->flip['file'];
if ( $flip ) {
$this->gallery->insert( $title );
} else {
* Add a miscellaneous page
*/
function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) {
- global $wgContLang, $wgExperimentalCategorySort;
+ global $wgContLang;
$this->articles[] = $isRedirect
? '<span class="redirect-in-category">' .
$this->getSkin()->link(
) . '</span>'
: $this->getSkin()->link( $title );
- if ( $wgExperimentalCategorySort ) {
- $this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstLetterForLists( $sortkey ) );
- } else {
- $this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstChar( $sortkey ) );
- }
+ $this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstLetterForLists( $sortkey ) );
}
function finaliseCategoryState() {
- global $wgExperimentalCategorySort;
- if ( ( !$wgExperimentalCategorySort && $this->flip )
- || ( $wgExperimentalCategorySort && $this->flip['subcat'] ) ) {
+ if ( $this->flip['subcat'] ) {
$this->children = array_reverse( $this->children );
$this->children_start_char = array_reverse( $this->children_start_char );
}
- if ( ( !$wgExperimentalCategorySort && $this->flip )
- || ( $wgExperimentalCategorySort && $this->flip['page'] ) ) {
+ if ( $this->flip['page'] ) {
$this->articles = array_reverse( $this->articles );
$this->articles_start_char = array_reverse( $this->articles_start_char );
}
}
function doCategoryQuery() {
- global $wgExperimentalCategorySort, $wgContLang;
+ global $wgContLang;
$dbr = wfGetDB( DB_SLAVE, 'category' );
$joins = array( 'categorylinks' => array( 'INNER JOIN', 'cl_from = page_id' ),
'category' => array( 'LEFT JOIN', 'cat_title = page_title AND page_namespace = ' . NS_CATEGORY ) );
- if ( $wgExperimentalCategorySort ) {
- # Copy-pasted from below, but that's okay, because the stuff below
- # will be deleted when this becomes the default.
- $this->nextPage = array(
- 'page' => null,
- 'subcat' => null,
- 'file' => null,
- );
- $this->flip = array( 'page' => false, 'subcat' => false, 'file' => false );
-
- foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
- # Get the sortkeys for start/end, if applicable. Note that if
- # the collation in the database differs from the one
- # $wgContLang is using, pagination might go totally haywire.
- $extraConds = array( 'cl_type' => $type );
- if ( $this->from[$type] !== null ) {
- $extraConds[] = 'cl_sortkey >= '
- . $dbr->addQuotes( $wgContLang->convertToSortkey( $this->from[$type] ) );
- } elseif ( $this->until[$type] !== null ) {
- $extraConds[] = 'cl_sortkey < '
- . $dbr->addQuotes( $wgContLang->convertToSortkey( $this->until[$type] ) );
- $this->flip[$type] = true;
- }
-
- $res = $dbr->select(
- $tables,
- array_merge( $fields, array( 'cl_sortkey_prefix' ) ),
- $conds + $extraConds,
- __METHOD__,
- $opts + array( 'ORDER BY' => $this->flip[$type] ? 'cl_sortkey DESC' : 'cl_sortkey' ),
- $joins
- );
-
- $count = 0;
- foreach ( $res as $row ) {
- $title = Title::newFromRow( $row );
- $rawSortkey = $title->getCategorySortkey( $row->cl_sortkey_prefix );
-
- if ( ++$count > $this->limit ) {
- # We've reached the one extra which shows that there
- # are additional pages to be had. Stop here...
- $this->nextPage[$type] = $rawSortkey;
- break;
- }
-
- if ( $title->getNamespace() == NS_CATEGORY ) {
- $cat = Category::newFromRow( $row, $title );
- $this->addSubcategoryObject( $cat, $rawSortkey, $row->page_len );
- } elseif ( $this->showGallery && $title->getNamespace() == NS_FILE ) {
- $this->addImage( $title, $rawSortkey, $row->page_len, $row->page_is_redirect );
- } else {
- $this->addPage( $title, $rawSortkey, $row->page_len, $row->page_is_redirect );
- }
- }
- }
-
- return;
- }
-
- # Non-$wgExperimentalCategorySort stuff
-
- if ( $this->from != '' ) {
- $pageCondition = 'cl_sortkey >= ' . $dbr->addQuotes( $this->from );
- $this->flip = false;
- } elseif ( $this->until != '' ) {
- $pageCondition = 'cl_sortkey < ' . $dbr->addQuotes( $this->until );
- $this->flip = true;
- } else {
- $pageCondition = '1 = 1';
- $this->flip = false;
- }
-
- $res = $dbr->select(
- $tables,
- $fields,
- $conds + array( $pageCondition ),
- __METHOD__,
- $opts + array( 'ORDER BY' => $this->flip ? 'cl_sortkey DESC' : 'cl_sortkey' ),
- $joins
+ $this->nextPage = array(
+ 'page' => null,
+ 'subcat' => null,
+ 'file' => null,
);
+ $this->flip = array( 'page' => false, 'subcat' => false, 'file' => false );
+
+ foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
+ # Get the sortkeys for start/end, if applicable. Note that if
+ # the collation in the database differs from the one
+ # $wgContLang is using, pagination might go totally haywire.
+ $extraConds = array( 'cl_type' => $type );
+ if ( $this->from[$type] !== null ) {
+ $extraConds[] = 'cl_sortkey >= '
+ . $dbr->addQuotes( $wgContLang->convertToSortkey( $this->from[$type] ) );
+ } elseif ( $this->until[$type] !== null ) {
+ $extraConds[] = 'cl_sortkey < '
+ . $dbr->addQuotes( $wgContLang->convertToSortkey( $this->until[$type] ) );
+ $this->flip[$type] = true;
+ }
- $count = 0;
- $this->nextPage = null;
+ $res = $dbr->select(
+ $tables,
+ array_merge( $fields, array( 'cl_sortkey_prefix' ) ),
+ $conds + $extraConds,
+ __METHOD__,
+ $opts + array( 'ORDER BY' => $this->flip[$type] ? 'cl_sortkey DESC' : 'cl_sortkey' ),
+ $joins
+ );
- foreach ( $res as $row ) {
- if ( ++$count > $this->limit ) {
- // We've reached the one extra which shows that there are
- // additional pages to be had. Stop here...
- $this->nextPage = $row->cl_sortkey;
- break;
- }
+ $count = 0;
+ foreach ( $res as $row ) {
+ $title = Title::newFromRow( $row );
+ $rawSortkey = $title->getCategorySortkey( $row->cl_sortkey_prefix );
- $title = Title::newFromRow( $row );
+ if ( ++$count > $this->limit ) {
+ # We've reached the one extra which shows that there
+ # are additional pages to be had. Stop here...
+ $this->nextPage[$type] = $rawSortkey;
+ break;
+ }
- if ( $title->getNamespace() == NS_CATEGORY ) {
- $cat = Category::newFromRow( $row, $title );
- $this->addSubcategoryObject( $cat, $row->cl_sortkey, $row->page_len );
- } elseif ( $this->showGallery && $title->getNamespace() == NS_FILE ) {
- $this->addImage( $title, $row->cl_sortkey, $row->page_len, $row->page_is_redirect );
- } else {
- $this->addPage( $title, $row->cl_sortkey, $row->page_len, $row->page_is_redirect );
+ if ( $title->getNamespace() == NS_CATEGORY ) {
+ $cat = Category::newFromRow( $row, $title );
+ $this->addSubcategoryObject( $cat, $rawSortkey, $row->page_len );
+ } elseif ( $this->showGallery && $title->getNamespace() == NS_FILE ) {
+ $this->addImage( $title, $rawSortkey, $row->page_len, $row->page_is_redirect );
+ } else {
+ $this->addPage( $title, $rawSortkey, $row->page_len, $row->page_is_redirect );
+ }
}
}
}
* @return String: HTML output, possibly empty if there are no other pages
*/
private function getSectionPagingLinks( $type ) {
- global $wgExperimentalCategorySort;
- if ( !$wgExperimentalCategorySort ) {
- return '';
- }
if ( $this->until[$type] !== null ) {
return $this->pagingLinks( $this->nextPage[$type], $this->until[$type], $type );
} elseif ( $this->nextPage[$type] !== null || $this->from[$type] !== null ) {
}
function getCategoryBottom() {
- global $wgExperimentalCategorySort;
- if ( $wgExperimentalCategorySort ) {
- # We have per-section paging links, no global ones.
- return '';
- }
- if ( $this->until != '' ) {
- return $this->pagingLinks( $this->nextPage, $this->until );
- } elseif ( $this->nextPage != '' || $this->from != '' ) {
- return $this->pagingLinks( $this->from, $this->nextPage );
- } else {
- return '';
- }
+ return '';
}
/**
* @private
*/
function getCategoryInsertions( $existing = array() ) {
- global $wgContLang, $wgExperimentalCategorySort, $wgCollationVersion;
+ global $wgContLang, $wgCollationVersion;
$diffs = array_diff_assoc( $this->mCategories, $existing );
$arr = array();
foreach ( $diffs as $name => $sortkey ) {
$nt = Title::makeTitleSafe( NS_CATEGORY, $name );
$wgContLang->findVariantLink( $name, $nt, true );
- if ( $wgExperimentalCategorySort ) {
- if ( $this->mTitle->getNamespace() == NS_CATEGORY ) {
- $type = 'subcat';
- } elseif ( $this->mTitle->getNamespace() == NS_FILE ) {
- $type = 'file';
- } else {
- $type = 'page';
- }
-
- # TODO: This is kind of wrong, because someone might set a sort
- # key prefix that's the same as the default sortkey for the
- # title. This should be fixed by refactoring code to replace
- # $sortkey in this array by a prefix, but it's basically harmless
- # (Title::moveTo() has had the same issue for a long time).
- if ( $this->mTitle->getCategorySortkey() == $sortkey ) {
- $prefix = '';
- $sortkey = $wgContLang->convertToSortkey( $sortkey );
- } else {
- # Treat custom sortkeys as a prefix, so that if multiple
- # things are forced to sort as '*' or something, they'll
- # sort properly in the category rather than in page_id
- # order or such.
- $prefix = $sortkey;
- $sortkey = $wgContLang->convertToSortkey(
- $this->mTitle->getCategorySortkey( $prefix ) );
- }
+ if ( $this->mTitle->getNamespace() == NS_CATEGORY ) {
+ $type = 'subcat';
+ } elseif ( $this->mTitle->getNamespace() == NS_FILE ) {
+ $type = 'file';
+ } else {
+ $type = 'page';
+ }
- $arr[] = array(
- 'cl_from' => $this->mId,
- 'cl_to' => $name,
- 'cl_sortkey' => $sortkey,
- 'cl_timestamp' => $this->mDb->timestamp(),
- 'cl_sortkey_prefix' => $prefix,
- 'cl_collation' => $wgCollationVersion,
- 'cl_type' => $type,
- );
+ # TODO: This is kind of wrong, because someone might set a sort
+ # key prefix that's the same as the default sortkey for the
+ # title. This should be fixed by refactoring code to replace
+ # $sortkey in this array by a prefix, but it's basically harmless
+ # (Title::moveTo() has had the same issue for a long time).
+ if ( $this->mTitle->getCategorySortkey() == $sortkey ) {
+ $prefix = '';
+ $sortkey = $wgContLang->convertToSortkey( $sortkey );
} else {
- $arr[] = array(
- 'cl_from' => $this->mId,
- 'cl_to' => $name,
- 'cl_sortkey' => $sortkey,
- 'cl_timestamp' => $this->mDb->timestamp()
- );
+ # Treat custom sortkeys as a prefix, so that if multiple
+ # things are forced to sort as '*' or something, they'll
+ # sort properly in the category rather than in page_id
+ # order or such.
+ $prefix = $sortkey;
+ $sortkey = $wgContLang->convertToSortkey(
+ $this->mTitle->getCategorySortkey( $prefix ) );
}
+
+ $arr[] = array(
+ 'cl_from' => $this->mId,
+ 'cl_to' => $name,
+ 'cl_sortkey' => $sortkey,
+ 'cl_timestamp' => $this->mDb->timestamp(),
+ 'cl_sortkey_prefix' => $prefix,
+ 'cl_collation' => $wgCollationVersion,
+ 'cl_type' => $type,
+ );
}
return $arr;
}