From 7ff30fcab38cda24dc7a5f598529ba0c78b9fea3 Mon Sep 17 00:00:00 2001 From: Robert Leverington Date: Mon, 28 Jul 2008 19:02:40 +0000 Subject: [PATCH] * (bug 14923) Add method for getting a TitleArray for a particular category. --- includes/Category.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/includes/Category.php b/includes/Category.php index acafc47a70..dcb44609b1 100644 --- a/includes/Category.php +++ b/includes/Category.php @@ -192,6 +192,33 @@ class Category { return $this->mTitle; } + /** + * Fetch a TitleArray of up to $limit category members, beginning after the + * category sort key $offset. + * @param $limit integer + * @param $offset string + * @return TitleArray object for category members. + */ + public function getMembers( $limit = false, $offset = '' ) { + $dbr = wfGetDB( DB_SLAVE ); + + $conds = array( 'cl_to' => $this->getName(), 'cl_from = page_id' ); + $options = array( 'ORDER BY' => 'cl_sortkey' ); + if( $limit ) $options[ 'LIMIT' ] = $limit; + if( $offset !== '' ) $conds[] = 'cl_sortkey > ' . $dbr->addQuotes( $offset ); + + return TitleArray::newFromResult( + $dbr->select( + array( 'page', 'categorylinks' ), + array( 'page_id', 'page_namespace','page_title', 'page_len', + 'page_is_redirect', 'page_latest' ), + $conds, + __METHOD__, + $options + ) + ); + } + /** Generic accessor */ private function getX( $key ) { if( !$this->initialize() ) { -- 2.20.1