/** * Delivers all subpages of a given page. * * @param Title $page The page to get the subpages from. * @param int $depth Depth of the deepest subpage level to be counted relative from the given * page. null means no limit. * * @return Title[] All subpages of the given page. */ static function getSubpages( Title $page, $depth = null ) { if( $depth === 0 ) return array(); $subpages = $page->getSubpages( -1 ); $allSubpages = array(); if( $depth !== null ) { $maxSubpageLevel = SubpageInfo::getSubpageLevel( $page ) + $depth; } if( ! empty( $subpages ) ) { while( $subpages->valid() ) { $curSub = $subpages->current(); if( $depth !== null ) { if( SubpageInfo::getSubpageLevel( $curSub ) <= $maxSubpageLevel ) { $allSubpages[] = $curSub; } } else { $allSubpages[] = $curSub; } $subpages->next(); } } return $allSubpages; }
static function pf_subpagelevel( &$parser /* , $title = null */ ) { $t = self::newTitleObject( $parser, func_get_args() ); if( $t === null ) { return ''; // invalid title given } return SubpageInfo::getSubpageLevel( $t ); }