[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/ -> CategoryFinder.php (summary)

Recent changes filtering by category. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

File Size: 244 lines (6 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class

CategoryFinder:: (5 methods):
  seed()
  run()
  getParents()
  check()
  scanNextLayer()


Class: CategoryFinder  - X-Ref

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 :
<code>
# 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 );
</code>

seed( $articleIds, $categories, $mode = 'AND' )   X-Ref
Initializes the instance. Do this prior to calling run().

param: array $articleIds Array of article IDs
param: array $categories FIXME
param: string $mode FIXME, default 'AND'.

run()   X-Ref
Iterates through the parent tree starting with the seed values,
then checks the articles if they match the conditions

return: array Array of page_ids (those given to seed() that match the conditions)

getParents()   X-Ref
Get the parents. Only really useful if run() has been called already

return: array

check( $id, &$conds, $path = array()   X-Ref
This functions recurses through the parent representation, trying to match the conditions

param: int $id The article/category to check
param: array $conds The array of categories to match
param: array $path Used to check for recursion loops
return: bool Does this match the conditions?

scanNextLayer()   X-Ref
Scans a "parent layer" of the articles/categories in $this->next




Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1