Category Class Reference

Category objects are immutable, strictly speaking. More...

List of all members.

Public Member Functions

 getName ()
 getID ()
 getPageCount ()
 getSubcatCount ()
 getFileCount ()
 getTitle ()
 getMembers ($limit=false, $offset= '')
 Fetch a TitleArray of up to $limit category members, beginning after the category sort key $offset.
 refreshCounts ()
 Refresh the counts for this category.

Static Public Member Functions

static newFromName ($name)
 Factory function.
static newFromTitle ($title)
 Factory function.
static newFromID ($id)
 Factory function.
static newFromRow ($row, $title=null)
 Factory function, for constructing a Category object from a result set.

Protected Member Functions

 initialize ()
 Set up all member variables using a database query.

Private Member Functions

 __construct ()
 getX ($key)
 Generic accessor.

Private Attributes

 $mName = null
 Name of the category, normalized to DB-key form.
 $mID = null
 $mTitle = null
 Category page title.
 $mPages = null
 Counts of membership (cat_pages, cat_subcats, cat_files).
 $mSubcats = null
 $mFiles = null


Detailed Description

Category objects are immutable, strictly speaking.

If you call methods that change the database, like to refresh link counts, the objects will be appropriately reinitialized. Member variables are lazy-initialized.

TODO: Move some stuff from CategoryPage.php to here, and use that.

Author:
Simetrical

Definition at line 12 of file Category.php.


Constructor & Destructor Documentation

Category::__construct (  )  [private]

Definition at line 21 of file Category.php.


Member Function Documentation

Category::getFileCount (  ) 

Returns:
mixed Number of member files, or false on failure

Definition at line 179 of file Category.php.

References getX().

Category::getID (  ) 

Returns:
mixed Category ID, or false on failure

Definition at line 173 of file Category.php.

References getX().

Category::getMembers ( limit = false,
offset = '' 
)

Fetch a TitleArray of up to $limit category members, beginning after the category sort key $offset.

Parameters:
$limit integer
$offset string
Returns:
TitleArray object for category members.

Definition at line 202 of file Category.php.

References $conds, $dbr, $offset, $options, getName(), TitleArray::newFromResult(), and wfGetDB().

Category::getName (  ) 

Returns:
mixed DB key name, or false on failure

Definition at line 171 of file Category.php.

References getX().

Referenced by getMembers().

Category::getPageCount (  ) 

Returns:
mixed Total number of member pages, or false on failure

Definition at line 175 of file Category.php.

References getX().

Category::getSubcatCount (  ) 

Returns:
mixed Number of subcategories, or false on failure

Definition at line 177 of file Category.php.

References getX().

Category::getTitle (  ) 

Returns:
mixed The Title for this category, or false on failure.

Definition at line 184 of file Category.php.

References initialize(), and Title::makeTitleSafe().

Category::getX ( key  )  [private]

Generic accessor.

Definition at line 223 of file Category.php.

References $key, and initialize().

Referenced by getFileCount(), getID(), getName(), getPageCount(), and getSubcatCount().

Category::initialize (  )  [protected]

Set up all member variables using a database query.

Returns:
bool True on success, false on failure.

Definition at line 27 of file Category.php.

References $dbr, $row, $title, refreshCounts(), and wfGetDB().

Referenced by getTitle(), getX(), and refreshCounts().

static Category::newFromID ( id  )  [static]

Factory function.

Parameters:
$id Integer: a category id
Returns:
Category

Definition at line 120 of file Category.php.

static Category::newFromName ( name  )  [static]

Factory function.

Parameters:
$name Array: A category name (no "Category:" prefix). It need not be normalized, with spaces replaced by underscores.
Returns:
mixed Category, or false on a totally invalid name

Definition at line 86 of file Category.php.

References $name, $title, and Title::makeTitleSafe().

Referenced by CoreParserFunctions::pagesincategory(), and populateCategory().

static Category::newFromRow ( row,
title = null 
) [static]

Factory function, for constructing a Category object from a result set.

Parameters:
$row result set row, must contain the cat_xxx fields. If the fields are null, the resulting Category object will represent an empty category if a title object was given. If the fields are null and no title was given, this method fails and returns false.
$title optional title object for the category represented by the given row. May be provided if it is already known, to avoid having to re-create a title object later.
Returns:
Category

Definition at line 136 of file Category.php.

References $row, and $title.

Referenced by CategoryViewer::doCategoryQuery().

static Category::newFromTitle ( title  )  [static]

Factory function.

Parameters:
$title Title for the category page
Returns:
Mixed: category, or false on a totally invalid name

Definition at line 105 of file Category.php.

References $title.

Referenced by CategoryViewer::__construct(), and CategoryPage::hasViewableContent().

Category::refreshCounts (  ) 

Refresh the counts for this category.

Returns:
bool True on success, false on failure

Definition at line 235 of file Category.php.

References $dbw, $result, initialize(), wfGetDB(), and wfReadOnly().

Referenced by initialize().


Member Data Documentation

Category::$mFiles = null [private]

Definition at line 19 of file Category.php.

Category::$mID = null [private]

Definition at line 15 of file Category.php.

Category::$mName = null [private]

Name of the category, normalized to DB-key form.

Definition at line 14 of file Category.php.

Category::$mPages = null [private]

Counts of membership (cat_pages, cat_subcats, cat_files).

Definition at line 19 of file Category.php.

Category::$mSubcats = null [private]

Definition at line 19 of file Category.php.

Category::$mTitle = null [private]

Category page title.

Definition at line 17 of file Category.php.


The documentation for this class was generated from the following file:

Generated on Sat Sep 5 02:08:33 2009 for MediaWiki by  doxygen 1.5.9