* @return string
*/
static function cleanSignature( $signature, $alldata, $form ) {
- global $wgParser;
if ( isset( $alldata['fancysig'] ) && $alldata['fancysig'] ) {
+ global $wgParser;
$signature = $wgParser->cleanSig( $signature );
} else {
// When no fancy sig used, make sure ~{3,5} get removed.
- $signature = $wgParser->cleanSigInSig( $signature );
+ $signature = Parser::cleanSigInSig( $signature );
}
return $signature;
}
# Make sure nickname doesnt get a sig in a sig
- $nickname = $this->cleanSigInSig( $nickname );
+ $nickname = self::cleanSigInSig( $nickname );
# If we're still here, make it a link to the user page
$userText = wfEscapeWikiText( $username );
* @param $parsing bool Whether we're cleaning (preferences save) or parsing
* @return String: signature text
*/
- function cleanSig( $text, $parsing = false ) {
+ public function cleanSig( $text, $parsing = false ) {
if ( !$parsing ) {
global $wgTitle;
$this->startParse( $wgTitle, new ParserOptions, self::OT_PREPROCESS, true );
$substText = '{{' . $substWord->getSynonym( 0 );
$text = preg_replace( $substRegex, $substText, $text );
- $text = $this->cleanSigInSig( $text );
+ $text = self::cleanSigInSig( $text );
$dom = $this->preprocessToDom( $text );
$frame = $this->getPreprocessor()->newFrame();
$text = $frame->expand( $dom );
* @param $text String
* @return String: signature text with /~{3,5}/ removed
*/
- function cleanSigInSig( $text ) {
+ public static function cleanSigInSig( $text ) {
$text = preg_replace( '/~{3,5}/', '', $text );
return $text;
}
/**
* cleanSigInSig() just removes tildes
+ * @dataProvider provideStringsForCleanSigInSig
*/
- function testCleanSigInSig() {
- $title = Title::newFromText( __FUNCTION__ );
- $outputText = $this->parser->cleanSigInSig( "{{Foo}} ~~~~" );
-
- $this->assertEquals( "{{Foo}} ", $outputText );
+ function testCleanSigInSig( $in, $out ) {
+ $this->assertEquals( Parser::cleanSigInSig( $in), $out );
+ }
+
+ function provideStringsForCleanSigInSig() {
+ return array(
+ array( "{{Foo}} ~~~~", "{{Foo}} " ),
+ array( "~~~", "" ),
+ array( "~~~~~", "" ),
+ );
}
function testGetSection() {