public function getDeletionUpdates( Title $title,
ParserOutput $parserOutput = null );
+ /**
+ * Returns true if this Content object matches the given magic word.
+ *
+ * @param MagicWord $word the magic word to match
+ *
+ * @return bool whether this Content object matches the given magic word.
+ */
+ public function matchMagicWord( MagicWord $word );
+
# TODO: handle ImagePage and CategoryPage
# TODO: make sure we cover lucene search / wikisearch.
# TODO: make sure ReplaceTemplates still works
}
/**
- * Returns a list of updates to perform when this content is deleted.
- * The necessary updates may be taken from the Content object, or depend on
- * the current state of the database.
+ * @see Content::getDeletionUpdates()
*
* @since WD.1
*
new LinksDeletionUpdate( $title ),
);
}
+
+ /**
+ * @see Content::matchMagicWord()
+ *
+ * This default implementation always returns false. Subclasses may override this to supply matching logic.
+ *
+ * @param MagicWord $word
+ *
+ * @return bool
+ */
+ public function matchMagicWord( MagicWord $word ) {
+ return false;
+ }
}
/**
# TODO: make Highlighter interface, use highlighter here, if available
return htmlspecialchars( $this->getNativeData() );
}
-
}
/**
);
}
-
+ /**
+ * @see Content::matchMagicWord()
+ *
+ * This implementation calls $word->match() on the this TextContent object's text.
+ *
+ * @param MagicWord $word
+ *
+ * @return bool whether this Content object matches the given magic word.
+ */
+ public function matchMagicWord( MagicWord $word ) {
+ return $word->match( $this->getNativeData() );
+ }
}
/**
}
# Check for a suppression tag (used e.g. in periodically archived discussions)
- $text = ContentHandler::getContentText( $content );
$mw = MagicWord::get( 'staticredirect' );
- if ( $mw->match( $text ) ) { #FIXME: add support for this to ContentHandler/Content
+ if ( $content->matchMagicWord( $mw ) ) {
wfDebug( __METHOD__.": skipping: suppressed with __STATICREDIRECT__\n" );
return true;
}
$newTitle = Title::makeTitle( $newTitle->getNamespace(), $newTitle->getDBkey(),
$currentDest->getFragment() );
+ $text = ContentHandler::getContentText( $content ); #FIXME: get rid of this!
+
# Fix the text
# Remember that redirect pages can have categories, templates, etc.,
# so the regex has to be fairly general
);
}
+ public function testMatchMagicWord( ) {
+ $mw = MagicWord::get( "staticredirect" );
+
+ $content = $this->newContent( "#REDIRECT [[FOO]]\n__STATICREDIRECT__" );
+ $this->assertFalse( $content->matchMagicWord( $mw ), "should not have matched magic word, since it's not wikitext" );
+ }
+
# =================================================================================================================
public function testGetModel() {
$this->assertEquals( "hello world.", $content->getWikitextForTransclusion() );
}
+ public function testMatchMagicWord( ) {
+ $mw = MagicWord::get( "staticredirect" );
+
+ $content = $this->newContent( "#REDIRECT [[FOO]]\n__STATICREDIRECT__" );
+ $this->assertTrue( $content->matchMagicWord( $mw ), "should have matched magic word" );
+
+ $content = $this->newContent( "#REDIRECT [[FOO]]" );
+ $this->assertFalse( $content->matchMagicWord( $mw ), "should not have matched magic word" );
+ }
+
# =================================================================================================================
public function testGetModel() {