3 * Implements Special:Uncategorizedcategories
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
25 * A special page that lists uncategorized categories
27 * @ingroup SpecialPage
29 class UncategorizedCategoriesPage
extends UncategorizedPagesPage
{
31 * Holds a list of categories, which shouldn't be listed on this special page,
32 * even if it is uncategorized.
35 private $exceptionList = null;
37 function __construct( $name = 'Uncategorizedcategories' ) {
38 parent
::__construct( $name );
39 $this->requestedNamespace
= NS_CATEGORY
;
43 * Returns an array of category titles (usually without the namespace), which
44 * shouldn't be listed on this page, even if they're uncategorized.
48 private function getExceptionList() {
49 if ( $this->exceptionList
=== null ) {
50 $exList = $this->msg( 'uncategorized-categories-exceptionlist' )
51 ->inContentLanguage()->plain();
52 $proposedTitles = explode( "\n", $exList );
53 foreach ( $proposedTitles as $count => $titleStr ) {
54 if ( strpos( $titleStr, '*' ) !== 0 ) {
57 $titleStr = preg_replace( "/^\\*\\s*/", '', $titleStr );
58 $title = Title
::newFromText( $titleStr, NS_CATEGORY
);
59 if ( $title && $title->getNamespace() !== NS_CATEGORY
) {
60 $title = Title
::makeTitleSafe( NS_CATEGORY
, $titleStr );
63 $this->exceptionList
[] = $title->getDBKey();
67 return $this->exceptionList
;
70 public function getQueryInfo() {
71 $dbr = wfGetDB( DB_SLAVE
);
72 $query = parent
::getQueryInfo();
73 $exceptionList = $this->getExceptionList();
74 if ( $exceptionList ) {
75 $query['conds'][] = 'page_title not in ( ' . $dbr->makeList( $exceptionList ) . ' )';
83 * @param Skin $skin The current skin
84 * @param object $result The query result
85 * @return string The category link
87 function formatResult( $skin, $result ) {
88 $title = Title
::makeTitle( NS_CATEGORY
, $result->title
);
89 $text = $title->getText();
91 return $this->getLinkRenderer()->makeKnownLink( $title, $text );