MediaWiki  1.23.8
Categoryfinder Class Reference

The "Categoryfinder" class takes a list of articles, creates an internal representation of all their parent categories (as well as parents of parents etc.). More...

Collaboration diagram for Categoryfinder:

Public Member Functions

 __construct ()
 Constructor (currently empty). More...
 
 check ( $id, &$conds, $path=array())
 This functions recurses through the parent representation, trying to match the conditions. More...
 
 run ()
 Iterates through the parent tree starting with the seed values, then checks the articles if they match the conditions. More...
 
 scan_next_layer ()
 Scans a "parent layer" of the articles/categories in $this->next. More...
 
 seed ( $article_ids, $categories, $mode='AND')
 Initializes the instance. More...
 

Public Attributes

 $articles = array()
 
DatabaseBase $dbr
 
 $deadend = array()
 
 $mode
 
 $name2id = array()
 
 $next = array()
 
 $parents = array()
 
 $targets = array()
 

Detailed Description

The "Categoryfinder" class takes a list of articles, creates an internal representation of all their parent categories (as well as parents of parents etc.).

From this representation, it determines which of these articles are in one or all of a given subset of categories.

Example use :

Determines whether the article with the page_id 12345 is in both

"Category 1" and "Category 2" or their subcategories, respectively

$cf = new Categoryfinder; $cf->seed( array( 12345 ), array( 'Category 1', 'Category 2' ), 'AND' ); $a = $cf->run(); print implode( ',' , $a );

Definition at line 45 of file Categoryfinder.php.

Constructor & Destructor Documentation

◆ __construct()

Categoryfinder::__construct ( )

Constructor (currently empty).

Definition at line 61 of file Categoryfinder.php.

Member Function Documentation

◆ check()

Categoryfinder::check (   $id,
$conds,
  $path = array() 
)

This functions recurses through the parent representation, trying to match the conditions.

Parameters
int$idThe article/category to check
array$condsThe array of categories to match
array$pathused to check for recursion loops
Returns
bool Does this match the conditions?

Definition at line 118 of file Categoryfinder.php.

◆ run()

Categoryfinder::run ( )

Iterates through the parent tree starting with the seed values, then checks the articles if they match the conditions.

Returns
array of page_ids (those given to seed() that match the conditions)

Definition at line 92 of file Categoryfinder.php.

◆ scan_next_layer()

Categoryfinder::scan_next_layer ( )

Scans a "parent layer" of the articles/categories in $this->next.

Definition at line 173 of file Categoryfinder.php.

References $name, $res, array(), as, NS_CATEGORY, wfProfileIn(), and wfProfileOut().

◆ seed()

Categoryfinder::seed (   $article_ids,
  $categories,
  $mode = 'AND' 
)

Initializes the instance.

Do this prior to calling run().

Parameters
$article_idsArray of article IDs
$categoriesFIXME
string$modeFIXME, default 'AND'.
Todo:
FIXME: $categories/$mode

Definition at line 71 of file Categoryfinder.php.

Referenced by SpecialRecentChanges\filterByCategories().

Member Data Documentation

◆ $articles

Categoryfinder::$articles = array()

Definition at line 46 of file Categoryfinder.php.

◆ $dbr

DatabaseBase Categoryfinder::$dbr

Definition at line 56 of file Categoryfinder.php.

◆ $deadend

Categoryfinder::$deadend = array()

Definition at line 47 of file Categoryfinder.php.

◆ $mode

Categoryfinder::$mode

Definition at line 52 of file Categoryfinder.php.

◆ $name2id

Categoryfinder::$name2id = array()

Definition at line 51 of file Categoryfinder.php.

◆ $next

Categoryfinder::$next = array()

Definition at line 49 of file Categoryfinder.php.

◆ $parents

Categoryfinder::$parents = array()

Definition at line 48 of file Categoryfinder.php.

◆ $targets

Categoryfinder::$targets = array()

Definition at line 50 of file Categoryfinder.php.


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