jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/367342 )

Change subject: Applied the Inclumedia changes
......................................................................


Applied the Inclumedia changes

From https://github.com/Inclumedia/RandomSelection

Adds a "surround by template" feature which requires the end-user to use
<choicetemplate> tags.

Change-Id: I1c95d72cdcaa692b2a38c20f3d2e208eec5df98f
---
M RandomSelection.class.php
1 file changed, 22 insertions(+), 0 deletions(-)

Approvals:
  SamanthaNguyen: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RandomSelection.class.php b/RandomSelection.class.php
index 7dee590..5abeb18 100644
--- a/RandomSelection.class.php
+++ b/RandomSelection.class.php
@@ -41,6 +41,15 @@
                        $input,
                        $out
                );
+
+               # Find any references to a surrounding template
+               preg_match_all(
+                       
"/<choicetemplate(?:(?:\\s[^>]*?)?\\sweight=[\"']?([^\\s>]+))?"
+                               . 
"(?:\\s[^>]*)?>([\\s\\S]*?)<\\/choicetemplate>/",
+                       $input,
+                       $outTemplate
+               );
+
                $r = 0;
                for ( $i = 0; $i < $len; $i++ ) {
                        if ( strlen( $out[1][$i] ) == 0 ) {
@@ -64,6 +73,19 @@
                        }
                }
 
+               # Surround by template if applicable
+               if ( isset( $outTemplate[2][0] ) ) {
+                       $input = '{{' . $outTemplate[2][0] . '|' . $input . 
'}}';
+               }
+
+               # Parse tags and return
+               if ( isset( $argv['before'] ) ) {
+                       $input = $argv['before'] . $input;
+               }
+               if ( isset( $argv['after'] ) ) {
+                       $input .= $argv['after'];
+               }
+
                return $parser->recursiveTagParse( $input );
        }
 }
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/367342
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1c95d72cdcaa692b2a38c20f3d2e208eec5df98f
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/RandomSelection
Gerrit-Branch: master
Gerrit-Owner: Jack Phoenix <j...@countervandalism.net>
Gerrit-Reviewer: Kghbln <mediaw...@kghoffmeyer.de>
Gerrit-Reviewer: SamanthaNguyen <samanthanguyen1...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to