Extension:CategoryToolbox

The CategoryToolbox extension allows to retrieve from Lua some informations about category/page relations.

Features

 * Discover if a certain page belongs to a certain category (also recursively!)
 * Discover the latest/oldest page added in a certain category

Installation
Don't install in production: this extension is in an experimental status.

You can install this extension as any other extension. Note that it requires Extension:Scribunto.

Manual
Note that the provided functions are expensive. See Manual:$wgExpensiveParserFunctionLimit.

The following documentation uses these terms:


 * : It means the category title eventually prefixed. E.g.  as well as just.
 * : It means the page title eventually prefixed. E.g..
 * : It means the namespace number. E.g..

mw.ext.cattools.categoryHasPage
Returns a boolean if the page belongs to that category. This is not recursive.

mw.ext.cattools.categoryNewestPage
Returns the page that is most recently added to the, eventually only from a certain.

It returns  or an object with some page informations. An example of result:

{ ns    = 6, title = 'Example.svg', date = '2017-10-28 23:59:59' }

mw.ext.cattools.categoryOldestPage
Exactly as above, but about the less recently added page to the.

mw.ext.cattools.isPageInCategoryRecursively
It returns a truly or falsy if the  belongs to the   or any other sub-category.

This function is truly expensive.

mw.ext.cattools.arePagesInCategoriesRecursively
For each page provided in the  table, it checks if it belongs to every category provided in the   table. This is the default, assuming  set to.

When  is set to , checks only if each page belongs at least in one category provided.

This function returns a table of booleans. They are indexed by the database page IDs of the provided. An example of result:

{ 123456: true, 123457: false }

This function is truly expensive.