static function pf_numberofsubpages( &$parser ) { //get all possible arguments: $args = ExtSubpageFun::getFunctionArgsArray( func_get_args() ); $title = isset($args[1]) ? $args[1] : null; $depth = isset( $args['depth'] ) ? self::valDepth( $args['depth'] ) : null; $filter = isset( $args['filter'] ) ? $args['filter'] : null; // function logic: $t = self::newTitleObject( $parser, $title ); if( $t === null ) { return ''; // invalid title given } // get subpages: $subpages = SubpageInfo::getSubpages( $t, $depth ); // filter by filter criterion: $subpages = self::filterSiteList( $subpages, $filter ); return count( $subpages ); }
/** * Delivers all siblings of a given subpage (won't deliver siblings of top level pages, would be to much) * * @param Title $page The page to get the siblings from. * * @return Title[] All sibling pages of the given subpage. */ static function getSiblingPages( Title $page ) { $parent = SubpageInfo::getParentPage( $page ); if( empty ( $parent ) ) { return array(); } $siblingsAndMore = SubpageInfo::getSubpages( $parent ); $allSiblings = array(); foreach( $siblingsAndMore as &$potentialSibling ) { if( SubpageInfo::isSiblingOf( $page, $potentialSibling ) ) $allSiblings[] = $potentialSibling; } return $allSiblings; }