jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/373294 )
Change subject: Add getSubpagesSorted function ...................................................................... Add getSubpagesSorted function When calling getSubpages on Title object it will return a list that is not sorted, pages with capital letter will be before lowercased even if letter itself should go later. Eg. "Beta" would go before "alpha". This helper method fixed that sorting issue and returns properly sorted array Change-Id: I73fe4a9a44babaf4c9afd257612436578233551e ERM: #7287 --- M includes/utility/ArticleHelper.class.php 1 file changed, 22 insertions(+), 0 deletions(-) Approvals: Pwirth: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/utility/ArticleHelper.class.php b/includes/utility/ArticleHelper.class.php index 4c6a611..d09ad1c 100644 --- a/includes/utility/ArticleHelper.class.php +++ b/includes/utility/ArticleHelper.class.php @@ -177,4 +177,26 @@ BsCacheHelper::invalidateCache( $sKey ); } + /** + * Retuns subpages of a title sorted by name + * + * @param Title $oTitle + * @param int $iLimit + * @return array + */ + public static function getSubpagesSorted( $oTitle, $iLimit ) { + $aSubpages = $oTitle->getSubpages( $iLimit ); + $aTitleArray = []; + foreach( $aSubpages as $oSubpage ) { + $aTitleArray[] = $oSubpage; + } + usort( $aTitleArray, array( 'BsArticleHelper', 'sortSubpagesInternal' ) ); + + return $aTitleArray; + } + + protected static function sortSubpagesInternal( $a, $b ) { + return strcmp( strtolower( $a->getFullText() ), strtolower( $b->getFullText() ) ); + } + } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/373294 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I73fe4a9a44babaf4c9afd257612436578233551e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation Gerrit-Branch: master Gerrit-Owner: ItSpiderman <d.savulje...@gmail.com> Gerrit-Reviewer: Ljonka <l.verhovs...@gmail.com> Gerrit-Reviewer: Mglaser <gla...@hallowelt.biz> Gerrit-Reviewer: Pwirth <wi...@hallowelt.biz> Gerrit-Reviewer: Robert Vogel <vo...@hallowelt.biz> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits