}
function closeShowCategory() {
- global $wgOut;
+ global $wgOut, $wgRequest;
+ // Use these as defaults for back compat --catrope
+ $oldFrom = $wgRequest->getVal( 'from' );
+ $oldUntil = $wgRequest->getVal( 'until' );
+
$from = $until = array();
foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
- # Use $_GET instead of $wgRequest, because the latter helpfully
- # normalizes Unicode, which removes nulls. TODO: do something
- # smarter than passing nulls in URLs. :/
- $from[$type] = isset( $_GET["{$type}from"] ) ? $_GET["{$type}from"] : null;
- $until[$type] = isset( $_GET["{$type}until"] ) ? $_GET["{$type}until"] : null;
+ $from[$type] = $wgRequest->getVal( "{$type}from", $oldFrom );
+ $until[$type] = $wgRequest->getVal( "{$type}until", $oldUntil );
}
- $viewer = new $this->mCategoryViewerClass( $this->mTitle, $from, $until, $_GET );
+ $viewer = new $this->mCategoryViewerClass( $this->mTitle, $from, $until, $wgRequest->getValues() );
$wgOut->addHTML( $viewer->getHTML() );
}
}
class CategoryViewer {
- var $title, $limit, $from, $until,
+ var $limit, $from, $until,
$articles, $articles_start_char,
$children, $children_start_char,
- $showGallery, $gallery,
- $imgsNoGalley, $imgsNoGallery_start_char,
- $skin, $collation;
- # Category object for this page
+ $showGallery, $imgsNoGalley,
+ $imgsNoGallery_start_char,
+ $skin, $imgsNoGallery;
+
+ /**
+ * @var
+ */
+ var $nextPage;
+
+ /**
+ * @var Array
+ */
+ var $flip;
+
+ /**
+ * @var Title
+ */
+ var $title;
+
+ /**
+ * @var Collation
+ */
+ var $collation;
+
+ /**
+ * @var ImageGallery
+ */
+ var $gallery;
+
+ /**
+ * Category object for this page
+ * @var Category
+ */
private $cat;
- # The original query array, to be used in generating paging links.
+
+ /**
+ * The original query array, to be used in generating paging links.
+ * @var array
+ */
private $query;
function __construct( $title, $from = '', $until = '', $query = array() ) {
}
}
+ /**
+ * @return Skin
+ */
function getSkin() {
if ( !$this->skin ) {
global $wgUser;
function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) {
// Subcategory; strip the 'Category' namespace from the link text.
$title = $cat->getTitle();
- $this->children[] = $this->getSkin()->link(
- $title,
- $title->getText(),
- array(),
- array(),
- array( 'known', 'noclasses' )
- );
+
+ $link = $this->getSkin()->link( $title, $title->getText() );
+ if ( $title->isRedirect() ) {
+ // This didn't used to add redirect-in-category, but might
+ // as well be consistent with the rest of the sections
+ // on a category page.
+ $link = '<span class="redirect-in-category">' . $link . '</span>';
+ }
+ $this->children[] = $link;
$this->children_start_char[] =
$this->getSubcategorySortChar( $cat->getTitle(), $sortkey );
* entry in the categorylinks table is Category:A, not A, which it SHOULD be.
* Workaround: If sortkey == "Category:".$title, than use $title for sorting,
* else use sortkey...
+ *
+ * @param Title $title
+ * @param string $sortkey
*/
function getSubcategorySortChar( $title, $sortkey ) {
global $wgContLang;
$this->gallery->add( $title );
}
} else {
- $this->imgsNoGallery[] = $isRedirect
- ? '<span class="redirect-in-category">' .
- $this->getSkin()->link(
- $title,
- null,
- array(),
- array(),
- array( 'known', 'noclasses' )
- ) . '</span>'
- : $this->getSkin()->link( $title );
+ $link = $this->getSkin()->link( $title );
+ if ( $isRedirect ) {
+ // This seems kind of pointless given 'mw-redirect' class,
+ // but keeping for back-compatibility with user css.
+ $link = '<span class="redirect-in-category">' . $link . '</span>';
+ }
+ $this->imgsNoGallery[] = $link;
$this->imgsNoGallery_start_char[] = $wgContLang->convert(
$this->collation->getFirstLetter( $sortkey ) );
*/
function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) {
global $wgContLang;
- $this->articles[] = $isRedirect
- ? '<span class="redirect-in-category">' .
- $this->getSkin()->link(
- $title,
- null,
- array(),
- array(),
- array( 'known', 'noclasses' )
- ) . '</span>'
- : $this->getSkin()->link( $title );
+
+ $link = $this->getSkin()->link( $title );
+ if ( $isRedirect ) {
+ // This seems kind of pointless given 'mw-redirect' class,
+ // but keeping for back-compatiability with user css.
+ $link = '<span class="redirect-in-category">' . $link . '</span>';
+ }
+ $this->articles[] = $link;
$this->articles_start_char[] = $wgContLang->convert(
$this->collation->getFirstLetter( $sortkey ) );
array( 'page_id', 'page_title', 'page_namespace', 'page_len',
'page_is_redirect', 'cl_sortkey', 'cat_id', 'cat_title',
'cat_subcats', 'cat_pages', 'cat_files', 'cl_sortkey_prefix' ),
- array( 'cl_to' => $this->title->getDBkey() ) + $extraConds,
+ array_merge( array( 'cl_to' => $this->title->getDBkey() ), $extraConds ),
__METHOD__,
array(
'USE INDEX' => array( 'categorylinks' => 'cl_sortkey' ),
$count = 0;
foreach ( $res as $row ) {
$title = Title::newFromRow( $row );
- $rawSortkey = $title->getCategorySortkey( $row->cl_sortkey_prefix );
+ $rawSortkey = $row->cl_sortkey;
if ( ++$count > $this->limit ) {
# We've reached the one extra which shows that there
static function shortList( $articles, $articles_start_char ) {
$r = '<h3>' . htmlspecialchars( $articles_start_char[0] ) . "</h3>\n";
$r .= '<ul><li>' . $articles[0] . '</li>';
- for ( $index = 1; $index < count( $articles ); $index++ )
- {
- if ( $articles_start_char[$index] != $articles_start_char[$index - 1] )
- {
+ for ( $index = 1; $index < count( $articles ); $index++ ) {
+ if ( $articles_start_char[$index] != $articles_start_char[$index - 1] ) {
$r .= "</ul><h3>" . htmlspecialchars( $articles_start_char[$index] ) . "</h3>\n<ul>";
}
}
if ( $dbcnt == $rescnt || ( ( $rescnt == $this->limit || $fromOrUntil )
- && $dbcnt > $rescnt ) )
- {
+ && $dbcnt > $rescnt ) ) {
# Case 1: seems sane.
$totalcnt = $dbcnt;
} elseif ( $rescnt < $this->limit && !$fromOrUntil ) {