MediaWiki  1.27.2
Category Class Reference

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

Collaboration diagram for Category:

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

 $mFiles = null
 
 $mSubcats = null
 

Protected Member Functions

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

Private Member Functions

 __construct ()
 
 getX ($key)
 Generic accessor. More...
 

Private Attributes

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

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.

Definition at line 31 of file Category.php.

Constructor & Destructor Documentation

Category::__construct ( )
private

Definition at line 43 of file Category.php.

Member Function Documentation

Category::getFileCount ( )
Returns
mixed Number of member files, or false on failure

Definition at line 229 of file Category.php.

References getX().

Category::getID ( )
Returns
mixed Category ID, or false on failure

Definition at line 208 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
int$limit
string$offset
Returns
TitleArray TitleArray object for category members.

Definition at line 256 of file Category.php.

References $dbr, $limit, $options, DB_SLAVE, getName(), TitleArray\newFromResult(), and wfGetDB().

Category::getName ( )
Returns
mixed DB key name, or false on failure

Definition at line 201 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 215 of file Category.php.

References getX().

Category::getSubcatCount ( )
Returns
mixed Number of subcategories, or false on failure

Definition at line 222 of file Category.php.

References getX().

Category::getTitle ( )
Returns
Title|bool Title for this category, or false on failure.

Definition at line 236 of file Category.php.

References $mTitle, initialize(), Title\makeTitleSafe(), and NS_CATEGORY.

Referenced by CategoryViewer\addSubcategoryObject().

Category::getX (   $key)
private

Generic accessor.

Parameters
string$key
Returns
bool

Definition at line 290 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.

Exceptions
MWException
Returns
bool True on success, false on failure.

Definition at line 51 of file Category.php.

References $dbr, $mID, $mName, DB_SLAVE, refreshCounts(), and wfGetDB().

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

static Category::newFromID (   $id)
static

Factory function.

Parameters
int$idA category id
Returns
Category

Definition at line 146 of file Category.php.

static Category::newFromName (   $name)
static

Factory function.

Parameters
array$nameA 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 111 of file Category.php.

References $name, $title, Title\makeTitleSafe(), and NS_CATEGORY.

Referenced by PopulateCategory\execute(), and WikiPage\updateCategoryCounts().

static Category::newFromRow (   $row,
  $title = null 
)
static

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

Parameters
object$rowResult 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$titleOptional 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 164 of file Category.php.

References $title.

Referenced by CategoryViewer\doCategoryQuery().

static Category::newFromTitle (   $title)
static

Factory function.

Parameters
Title$titleTitle for the category page
Returns
Category|bool On a totally invalid name

Definition at line 131 of file Category.php.

References $title.

Referenced by CategoryViewer\__construct(), WikiCategoryPage\hasViewableContent(), InfoAction\pageInfo(), CoreParserFunctions\pagesincategory(), and SpecialSearch\showHit().

Category::refreshCounts ( )

Refresh the counts for this category.

Returns
bool True on success, false on failure

Definition at line 302 of file Category.php.

References DB_MASTER, initialize(), NS_CATEGORY, NS_FILE, wfGetDB(), and wfReadOnly().

Referenced by initialize().

Member Data Documentation

Category::$mFiles = null

Definition at line 41 of file Category.php.

Category::$mID = null
private

Definition at line 34 of file Category.php.

Referenced by initialize().

Category::$mName = null
private

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

Definition at line 33 of file Category.php.

Referenced by initialize().

Category::$mPages = null
private

Counts of membership (cat_pages, cat_subcats, cat_files)

Definition at line 41 of file Category.php.

Category::$mSubcats = null

Definition at line 41 of file Category.php.

Title Category::$mTitle = null
private

Category page title.

Definition at line 39 of file Category.php.

Referenced by getTitle().


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