MediaWikiInsertablesSuggester.php

Go to the documentation of this file.
00001 <?php
00015 class MediaWikiInsertablesSuggester {
00016     public function getInsertables( $text ) {
00017         $insertables = array();
00018 
00019         $matches = array();
00020         preg_match_all( '/\$[0-9]+/', $text, $matches, PREG_SET_ORDER );
00021         $new = array_map( function( $match ) {
00022             return new Insertable( $match[0], $match[0] );
00023         }, $matches );
00024         $insertables = array_merge( $insertables, $new );
00025 
00026         $matches = array();
00027         preg_match_all(
00028             '/({{((?:PLURAL|GENDER|GRAMMAR):[^|]+)\|).*?(}})/i',
00029             $text,
00030             $matches,
00031             PREG_SET_ORDER
00032         );
00033         $new = array_map( function( $match ) {
00034             return new Insertable( $match[2], $match[1], $match[3] );
00035         }, $matches );
00036         $insertables = array_merge( $insertables, $new );
00037 
00038         return $insertables;
00039     }
00040 }
Generated on Tue Oct 29 00:00:24 2013 for MediaWiki Translate Extension by  doxygen 1.6.3