Wikia code/includes/ProtectionForm.php

--- D:\Programming\SVN\mediawiki\branches\REL1_16\phase3\includes\ProtectionForm.php	2011-07-18 22:31:27.980468800 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\ProtectionForm.php	2011-08-17 15:28:46.342773400 +0100
@@ -487,8 +487,13 @@
 		}
 
 		if ( !$this->disabled ) {
-			$out .= Xml::closeElement( 'form' ) .
-				$this->buildCleanupScript();
+			$out .= Xml::closeElement( 'form' );
+
+			/* Wikia change begin - @author: Macbre */
+			/* Add a script to $wgOut instead of emiting it directly to HTML (BugId:7178) */
+			global $wgHooks;
+			$wgHooks['SkinAfterBottomScripts'][] = array($this, 'onSkinAfterBottomScripts');
+			/* Wikia change end */
 		}
 
 		return $out;
@@ -546,10 +551,13 @@
 	}
 
 	function buildScript() {
-		global $wgStylePath, $wgStyleVersion;
-		return Xml::tags( 'script', array(
-			'type' => 'text/javascript',
-			'src' => $wgStylePath . "/common/protect.js?$wgStyleVersion.1" ), '' );
+		/* Wikia change begin - @author: Macbre */
+		/* Add a script to $wgOut instead of emiting it directly to HTML (BugId:7178) */
+		global $wgOut;
+		$wgOut->addScriptFile('protect.js');
+
+		return '';
+		/* Wikia change end */
 	}
 
 	function buildCleanupScript() {
@@ -574,6 +582,14 @@
 		return Xml::tags( 'script', array( 'type' => 'text/javascript' ), $script );
 	}
 
+	/* Wikia change begin - @author: Macbre */
+	/* Add a script to $wgOut instead of emiting it directly to HTML (BugId:7178) */
+	function onSkinAfterBottomScripts($skin, &$bottomScriptText) {
+		$bottomScriptText .= $this->buildCleanupScript();
+		return true;
+	}
+	/* Wikia change end */
+
 	/**
 	 * @param OutputPage $out
 	 * @access private