MtDu has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/326186 )
Change subject: Support %s as insertable parameters in the lib.reviews project ...................................................................... Support %s as insertable parameters in the lib.reviews project Bug: T150244 Change-Id: I82cd70bd492cc5cb881b63e807de12421ad3066b --- A groups/lib.reviews/LibReviewsInsertablesSuggester.php M groups/lib.reviews/lib.reviews.yaml 2 files changed, 35 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/translatewiki refs/changes/86/326186/1 diff --git a/groups/lib.reviews/LibReviewsInsertablesSuggester.php b/groups/lib.reviews/LibReviewsInsertablesSuggester.php new file mode 100644 index 0000000..68bc149 --- /dev/null +++ b/groups/lib.reviews/LibReviewsInsertablesSuggester.php @@ -0,0 +1,29 @@ +<?php +/** + * Similar to Wikimedia/CitationHuntInsertablesSuggester.php + * + * @file + * @author Justin Du + * @license GPL-2.0+ + */ + +class LibReviewsInsertablesSuggester { + public function getInsertables( $text ) { + $insertables = []; + + // %s + $matches = []; + preg_match_all( + '/\%s/', + $text, + $matches, + PREG_SET_ORDER + ); + $new = array_map( function( $match ) { + return new Insertable( $match[0], $match[0] ); + }, $matches ); + $insertables = array_merge( $insertables, $new ); + + return $insertables; + } +} diff --git a/groups/lib.reviews/lib.reviews.yaml b/groups/lib.reviews/lib.reviews.yaml index 2650482..01f1a5a 100644 --- a/groups/lib.reviews/lib.reviews.yaml +++ b/groups/lib.reviews/lib.reviews.yaml @@ -16,3 +16,9 @@ pt-br: pt zh-hans: zh zh-hant: zh-Hant + +INSERTABLES: + class: LibReviewsInsertablesSuggester + +AUTOLOAD: + LibReviewsInsertablesSuggester: LibReviewsInsertablesSuggester.php -- To view, visit https://gerrit.wikimedia.org/r/326186 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I82cd70bd492cc5cb881b63e807de12421ad3066b Gerrit-PatchSet: 1 Gerrit-Project: translatewiki Gerrit-Branch: master Gerrit-Owner: MtDu <justin.d...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits