based on QueryPage, fixed query to really return all categories
This commit is contained in:
parent
aa5137c826
commit
a8b64191b1
1 changed files with 34 additions and 36 deletions
|
|
@ -1,45 +1,43 @@
|
|||
<?php
|
||||
|
||||
require_once("QueryPage.php");
|
||||
|
||||
class CategoriesPage extends QueryPage {
|
||||
|
||||
function getName() {
|
||||
return "Categories";
|
||||
}
|
||||
|
||||
function isExpensive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function getSQL() {
|
||||
$NScat = Namespace::getCategory();
|
||||
return "SELECT DISTINCT 'Categories' as type,
|
||||
{$NScat} as namespace,
|
||||
cl_to as title,
|
||||
1 as value
|
||||
FROM categorylinks";
|
||||
}
|
||||
|
||||
function sortDescending() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function formatResult( $skin, $result ) {
|
||||
global $wgLang;
|
||||
return $skin->makeLink( $wgLang->getNsText( NS_CATEGORY ).":".$result->title, $result->title );
|
||||
}
|
||||
}
|
||||
|
||||
function wfSpecialCategories()
|
||||
{
|
||||
global $wgUser, $wgOut , $wgLang;
|
||||
list( $limit, $offset ) = wfCheckLimits();
|
||||
|
||||
$sk = $wgUser->getSkin() ;
|
||||
$sc = "Special:Categories" ;
|
||||
$cap = new CategoriesPage();
|
||||
|
||||
# List all existant categories.
|
||||
# Note: this list could become *very large*
|
||||
$r = "<ol>\n" ;
|
||||
$sql = "SELECT cur_title FROM cur WHERE cur_namespace=".Namespace::getCategory() ;
|
||||
$res = wfQuery ( $sql, DB_READ ) ;
|
||||
while ( $x = wfFetchObject ( $res ) ) {
|
||||
$title =& Title::makeTitle( NS_CATEGORY, $x->cur_title );
|
||||
$r .= "<li>" ;
|
||||
$r .= $sk->makeKnownLinkObj ( $title, $title->getText() ) ;
|
||||
$r .= "</li>\n" ;
|
||||
}
|
||||
wfFreeResult ( $res ) ;
|
||||
$r .= "</ol>\n" ;
|
||||
|
||||
$r .= "<hr />\n" ;
|
||||
|
||||
# Links to category pages that haven't been created.
|
||||
# FIXME: This could be slow if there are a lot, but the title index should
|
||||
# make it reasonably snappy since we're using an index.
|
||||
$cat = wfStrencode( $wgLang->getNsText( NS_CATEGORY ) );
|
||||
$sql = "SELECT DISTINCT bl_to FROM brokenlinks WHERE bl_to LIKE \"{$cat}:%\"" ;
|
||||
$res = wfQuery ( $sql, DB_READ ) ;
|
||||
$r .= "<ol>\n" ;
|
||||
while ( $x = wfFetchObject ( $res ) ) {
|
||||
$title = Title::newFromDBkey( $x->bl_to );
|
||||
$r .= "<li>" ;
|
||||
$r .= $sk->makeBrokenLinkObj( $title, $title->getText() ) ;
|
||||
$r .= "</li>\n" ;
|
||||
}
|
||||
wfFreeResult ( $res ) ;
|
||||
$r .= "</ol>\n" ;
|
||||
|
||||
$wgOut->addHTML ( $r ) ;
|
||||
return $cap->doQuery( $offset, $limit );
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue