User:Subfader/ReplaceText ns selector

From MediaWiki.org
Jump to navigation Jump to search

In SpecialReplaceText.php give the form a name: Replace

		Xml::openElement( 'form', array( 'action' => $this->getTitle()->getFullUrl(), 'method' => 'post' ) ) .

with

		Xml::openElement( 'form', array( 'action' => $this->getTitle()->getFullUrl(), 'method' => 'post', 'name' => 'RT' ) ) .

Then add some javascript and the links. Assuming you fixed the fieldset legends, replace

		$tables = $this->namespaceTables( $namespaces );
		$wgOut->addHTML( "<fieldset>\n<legend>$search_label</legend>\n$tables\n</fieldset>" );

with

		$tables = $this->namespaceTables( $namespaces );

$wgOut->addHTML( "<script type='text/javascript'> function RTselDefault() { document.RT.ns0.checked = true; document.RT.ns1.checked = false; document.RT.ns2.checked = false; document.RT.ns3.checked = false; document.RT.ns4.checked = false; document.RT.ns5.checked = false; document.RT.ns6.checked = false; document.RT.ns7.checked = false; document.RT.ns8.checked = false; document.RT.ns9.checked = false; document.RT.ns10.checked = false; document.RT.ns11.checked = false; document.RT.ns12.checked = false; document.RT.ns13.checked = false; document.RT.ns14.checked = false; document.RT.ns15.checked = false; } function RTselContent() { document.RT.ns0.checked = true; document.RT.ns1.checked = false; document.RT.ns2.checked = false; document.RT.ns3.checked = false; document.RT.ns4.checked = true; document.RT.ns5.checked = false; document.RT.ns6.checked = true; document.RT.ns7.checked = false; document.RT.ns8.checked = false; document.RT.ns9.checked = false; document.RT.ns10.checked = false; document.RT.ns11.checked = false; document.RT.ns12.checked = true; document.RT.ns13.checked = false; document.RT.ns14.checked = true; document.RT.ns15.checked = false; } function RTselSystem() { document.RT.ns0.checked = false; document.RT.ns1.checked = false; document.RT.ns2.checked = false; document.RT.ns3.checked = false; document.RT.ns4.checked = true; document.RT.ns5.checked = false; document.RT.ns6.checked = false; document.RT.ns7.checked = false; document.RT.ns8.checked = true; document.RT.ns9.checked = false; document.RT.ns10.checked = true; document.RT.ns11.checked = false; document.RT.ns12.checked = false; document.RT.ns13.checked = false; document.RT.ns14.checked = false; document.RT.ns15.checked = false; } function RTselNone() { document.RT.ns0.checked = false; document.RT.ns1.checked = false; document.RT.ns2.checked = false; document.RT.ns3.checked = false; document.RT.ns4.checked = false; document.RT.ns5.checked = false; document.RT.ns6.checked = false; document.RT.ns7.checked = false; document.RT.ns8.checked = false; document.RT.ns9.checked = false; document.RT.ns10.checked = false; document.RT.ns11.checked = false; document.RT.ns12.checked = false; document.RT.ns13.checked = false; document.RT.ns14.checked = false; document.RT.ns15.checked = false; } function RTselAll() { document.RT.ns0.checked = true; document.RT.ns1.checked = true; document.RT.ns2.checked = true; document.RT.ns3.checked = true; document.RT.ns4.checked = true; document.RT.ns5.checked = true; document.RT.ns6.checked = true; document.RT.ns7.checked = true; document.RT.ns8.checked = true; document.RT.ns9.checked = true; document.RT.ns10.checked = true; document.RT.ns11.checked = true; document.RT.ns12.checked = true; document.RT.ns13.checked = true; document.RT.ns14.checked = true; document.RT.ns15.checked = true; } </script> <fieldset>\n<legend>$search_label</legend><table cellspacing=0 cellpadding=0><tr> <td style='padding-right:15px;line-height:1.4em'> <a href='javascript:;' onclick='RTselDefault()'>Default</a><br /> <a href='javascript:;' onclick='RTselContent()'>Content</a><br /> <a href='javascript:;' onclick='RTselSystem()'>System</a><br /> <a href='javascript:;' onclick='RTselNone()'>None</a> / <a href='javascript:;' onclick='RTselAll()'>All</a> </td> <td>\n$tables\n</td> </tr></table>

</fieldset>" );

Adjust to your needs.