r81351 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81350‎ | r81351 | r81352 >
Date:23:23, 1 February 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
popup forms limited to MW 1.16+
MW did not load in iframes in earlier versions
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php
@@ -107,6 +107,9 @@
108108 static $num_autocompletion_inputs = 0;
109109
110110 static function registerFunctions( &$parser ) {
 111+
 112+ global $wgOut;
 113+
111114 $parser->setFunctionHook( 'forminput', array( 'SFParserFunctions', 'renderFormInput' ) );
112115 $parser->setFunctionHook( 'formlink', array( 'SFParserFunctions', 'renderFormLink' ) );
113116 if ( defined( get_class( $parser ) . '::SFH_OBJECT_ARGS' ) ) {
@@ -117,11 +120,9 @@
118121 $parser->setFunctionHook( 'arraymaptemplate', array( 'SFParserFunctions', 'renderArrayMapTemplate' ) );
119122 }
120123
121 - // load jQuery
122 - // only necessary in MW 1.16, does nothing in MW 1.17+
123 - global $wgVersion, $wgOut;
124 - if ( version_compare( $wgVersion, '1.17', '<=' ) && is_callable( array( $wgOut, 'includeJQuery' ) ) ) {
125 - $wgOut->includeJQuery(); // Fixme: this is including jQuery on every page load
 124+ // load jQuery on MW 1.16
 125+ if ( is_callable( array( $wgOut, 'includeJQuery' ) ) ) {
 126+ $wgOut -> includeJQuery();
126127 }
127128
128129 return true;
@@ -140,6 +141,9 @@
141142 }
142143
143144 static function renderFormLink ( &$parser ) {
 145+
 146+ global $wgVersion;
 147+
144148 $params = func_get_args();
145149 array_shift( $params ); // don't need the parser
146150 // set defaults
@@ -164,7 +168,8 @@
165169 $inQueryStr = $value;
166170 elseif ( $param_name == 'target' )
167171 $inTargetName = $value;
168 - elseif ( $param_name == null && $value == 'popup' ) {
 172+ elseif ( $param_name == null && $value == 'popup'
 173+ && version_compare( $wgVersion, '1.16', '>=' )) {
169174 self::loadScriptsForPopupForm( $parser );
170175 $popupClassString = 'class="popupformlink"';
171176 }
@@ -259,7 +264,8 @@
260265 } elseif ( $param_name == 'autocomplete on namespace' ) {
261266 $inAutocompletionSource = $value;
262267 $autocompletion_type = 'namespace';
263 - } elseif ( $param_name == null && $value == 'popup' ) {
 268+ } elseif ( $param_name == null && $value == 'popup'
 269+ && version_compare( $wgVersion, '1.16', '>=' )) {
264270 self::loadScriptsForPopupForm( $parser );
265271 $popupClassString = 'class="popupforminput"';
266272 }