'AbstractContent' => 'includes/content/AbstractContent.php',
'ContentHandler' => 'includes/content/ContentHandler.php',
'Content' => 'includes/content/Content.php',
- 'CssContentHandler' => 'includes/content/ContentHandler.php',
+ 'CssContentHandler' => 'includes/content/CssContentHandler.php',
'CssContent' => 'includes/content/CssContent.php',
- 'JavaScriptContentHandler' => 'includes/content/ContentHandler.php',
+ 'JavaScriptContentHandler' => 'includes/content/JavaScriptContentHandler.php',
'JavaScriptContent' => 'includes/content/JavaScriptContent.php',
'MessageContent' => 'includes/content/MessageContent.php',
- 'TextContentHandler' => 'includes/content/ContentHandler.php',
+ 'TextContentHandler' => 'includes/content/TextContentHandler.php',
'TextContent' => 'includes/content/TextContent.php',
- 'WikitextContentHandler' => 'includes/content/ContentHandler.php',
+ 'WikitextContentHandler' => 'includes/content/WikitextContentHandler.php',
'WikitextContent' => 'includes/content/WikitextContent.php',
# includes/actions
}
}
-/**
- * @since 1.21
- */
-class TextContentHandler extends ContentHandler {
-
- public function __construct( $modelId = CONTENT_MODEL_TEXT, $formats = array( CONTENT_FORMAT_TEXT ) ) {
- parent::__construct( $modelId, $formats );
- }
-
- /**
- * Returns the content's text as-is.
- *
- * @param $content Content
- * @param $format string|null
- * @return mixed
- */
- public function serializeContent( Content $content, $format = null ) {
- $this->checkFormat( $format );
- return $content->getNativeData();
- }
-
- /**
- * Attempts to merge differences between three versions. Returns a new
- * Content object for a clean merge and false for failure or a conflict.
- *
- * All three Content objects passed as parameters must have the same
- * content model.
- *
- * This text-based implementation uses wfMerge().
- *
- * @param $oldContent \Content|string String
- * @param $myContent \Content|string String
- * @param $yourContent \Content|string String
- *
- * @return Content|Bool
- */
- public function merge3( Content $oldContent, Content $myContent, Content $yourContent ) {
- $this->checkModelID( $oldContent->getModel() );
- $this->checkModelID( $myContent->getModel() );
- $this->checkModelID( $yourContent->getModel() );
-
- $format = $this->getDefaultFormat();
-
- $old = $this->serializeContent( $oldContent, $format );
- $mine = $this->serializeContent( $myContent, $format );
- $yours = $this->serializeContent( $yourContent, $format );
-
- $ok = wfMerge( $old, $mine, $yours, $result );
-
- if ( !$ok ) {
- return false;
- }
-
- if ( !$result ) {
- return $this->makeEmptyContent();
- }
-
- $mergedContent = $this->unserializeContent( $result, $format );
- return $mergedContent;
- }
-
- /**
- * Unserializes a Content object of the type supported by this ContentHandler.
- *
- * @since 1.21
- *
- * @param $text string serialized form of the content
- * @param $format null|String the format used for serialization
- *
- * @return Content the TextContent object wrapping $text
- */
- public function unserializeContent( $text, $format = null ) {
- $this->checkFormat( $format );
-
- return new TextContent( $text );
- }
-
- /**
- * Creates an empty TextContent object.
- *
- * @since 1.21
- *
- * @return Content
- */
- public function makeEmptyContent() {
- return new TextContent( '' );
- }
-}
-
-/**
- * @since 1.21
- */
-class WikitextContentHandler extends TextContentHandler {
-
- public function __construct( $modelId = CONTENT_MODEL_WIKITEXT ) {
- parent::__construct( $modelId, array( CONTENT_FORMAT_WIKITEXT ) );
- }
-
- public function unserializeContent( $text, $format = null ) {
- $this->checkFormat( $format );
-
- return new WikitextContent( $text );
- }
-
- /**
- * @see ContentHandler::makeEmptyContent
- *
- * @return Content
- */
- public function makeEmptyContent() {
- return new WikitextContent( '' );
- }
-
-
- /**
- * Returns a WikitextContent object representing a redirect to the given destination page.
- *
- * @see ContentHandler::makeRedirectContent
- *
- * @param Title $destination the page to redirect to.
- *
- * @return Content
- */
- public function makeRedirectContent( Title $destination ) {
- $mwRedir = MagicWord::get( 'redirect' );
- $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $destination->getPrefixedText() . "]]\n";
-
- return new WikitextContent( $redirectText );
- }
-
- /**
- * Returns true because wikitext supports sections.
- *
- * @return boolean whether sections are supported.
- */
- public function supportsSections() {
- return true;
- }
-
- /**
- * Returns true, because wikitext supports caching using the
- * ParserCache mechanism.
- *
- * @since 1.21
- * @return bool
- */
- public function isParserCacheSupported() {
- return true;
- }
-}
-
-# XXX: make ScriptContentHandler base class, do highlighting stuff there?
-
-/**
- * @since 1.21
- */
-class JavaScriptContentHandler extends TextContentHandler {
-
- public function __construct( $modelId = CONTENT_MODEL_JAVASCRIPT ) {
- parent::__construct( $modelId, array( CONTENT_FORMAT_JAVASCRIPT ) );
- }
-
- public function unserializeContent( $text, $format = null ) {
- $this->checkFormat( $format );
-
- return new JavaScriptContent( $text );
- }
-
- public function makeEmptyContent() {
- return new JavaScriptContent( '' );
- }
-
- /**
- * Returns the english language, because JS is english, and should be handled as such.
- *
- * @return Language wfGetLangObj( 'en' )
- *
- * @see ContentHandler::getPageLanguage()
- */
- public function getPageLanguage( Title $title, Content $content = null ) {
- return wfGetLangObj( 'en' );
- }
-
- /**
- * Returns the english language, because CSS is english, and should be handled as such.
- *
- * @return Language wfGetLangObj( 'en' )
- *
- * @see ContentHandler::getPageViewLanguage()
- */
- public function getPageViewLanguage( Title $title, Content $content = null ) {
- return wfGetLangObj( 'en' );
- }
-}
-
-/**
- * @since 1.21
- */
-class CssContentHandler extends TextContentHandler {
-
- public function __construct( $modelId = CONTENT_MODEL_CSS ) {
- parent::__construct( $modelId, array( CONTENT_FORMAT_CSS ) );
- }
-
- public function unserializeContent( $text, $format = null ) {
- $this->checkFormat( $format );
-
- return new CssContent( $text );
- }
-
- public function makeEmptyContent() {
- return new CssContent( '' );
- }
-
- /**
- * Returns the english language, because CSS is english, and should be handled as such.
- *
- * @return Language wfGetLangObj( 'en' )
- *
- * @see ContentHandler::getPageLanguage()
- */
- public function getPageLanguage( Title $title, Content $content = null ) {
- return wfGetLangObj( 'en' );
- }
-
- /**
- * Returns the english language, because CSS is english, and should be handled as such.
- *
- * @return Language wfGetLangObj( 'en' )
- *
- * @see ContentHandler::getPageViewLanguage()
- */
- public function getPageViewLanguage( Title $title, Content $content = null ) {
- return wfGetLangObj( 'en' );
- }
-}
--- /dev/null
+<?php
+
+/**
+ * @since 1.21
+ */
+class CssContentHandler extends TextContentHandler {
+
+ public function __construct( $modelId = CONTENT_MODEL_CSS ) {
+ parent::__construct( $modelId, array( CONTENT_FORMAT_CSS ) );
+ }
+
+ public function unserializeContent( $text, $format = null ) {
+ $this->checkFormat( $format );
+
+ return new CssContent( $text );
+ }
+
+ public function makeEmptyContent() {
+ return new CssContent( '' );
+ }
+
+ /**
+ * Returns the english language, because CSS is english, and should be handled as such.
+ *
+ * @return Language wfGetLangObj( 'en' )
+ *
+ * @see ContentHandler::getPageLanguage()
+ */
+ public function getPageLanguage( Title $title, Content $content = null ) {
+ return wfGetLangObj( 'en' );
+ }
+
+ /**
+ * Returns the english language, because CSS is english, and should be handled as such.
+ *
+ * @return Language wfGetLangObj( 'en' )
+ *
+ * @see ContentHandler::getPageViewLanguage()
+ */
+ public function getPageViewLanguage( Title $title, Content $content = null ) {
+ return wfGetLangObj( 'en' );
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+# XXX: make ScriptContentHandler base class, do highlighting stuff there?
+
+/**
+ * @since 1.21
+ */
+class JavaScriptContentHandler extends TextContentHandler {
+
+ public function __construct( $modelId = CONTENT_MODEL_JAVASCRIPT ) {
+ parent::__construct( $modelId, array( CONTENT_FORMAT_JAVASCRIPT ) );
+ }
+
+ public function unserializeContent( $text, $format = null ) {
+ $this->checkFormat( $format );
+
+ return new JavaScriptContent( $text );
+ }
+
+ public function makeEmptyContent() {
+ return new JavaScriptContent( '' );
+ }
+
+ /**
+ * Returns the english language, because JS is english, and should be handled as such.
+ *
+ * @return Language wfGetLangObj( 'en' )
+ *
+ * @see ContentHandler::getPageLanguage()
+ */
+ public function getPageLanguage( Title $title, Content $content = null ) {
+ return wfGetLangObj( 'en' );
+ }
+
+ /**
+ * Returns the english language, because CSS is english, and should be handled as such.
+ *
+ * @return Language wfGetLangObj( 'en' )
+ *
+ * @see ContentHandler::getPageViewLanguage()
+ */
+ public function getPageViewLanguage( Title $title, Content $content = null ) {
+ return wfGetLangObj( 'en' );
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/**
+ * @since 1.21
+ */
+class TextContentHandler extends ContentHandler {
+
+ public function __construct( $modelId = CONTENT_MODEL_TEXT, $formats = array( CONTENT_FORMAT_TEXT ) ) {
+ parent::__construct( $modelId, $formats );
+ }
+
+ /**
+ * Returns the content's text as-is.
+ *
+ * @param $content Content
+ * @param $format string|null
+ * @return mixed
+ */
+ public function serializeContent( Content $content, $format = null ) {
+ $this->checkFormat( $format );
+ return $content->getNativeData();
+ }
+
+ /**
+ * Attempts to merge differences between three versions. Returns a new
+ * Content object for a clean merge and false for failure or a conflict.
+ *
+ * All three Content objects passed as parameters must have the same
+ * content model.
+ *
+ * This text-based implementation uses wfMerge().
+ *
+ * @param $oldContent \Content|string String
+ * @param $myContent \Content|string String
+ * @param $yourContent \Content|string String
+ *
+ * @return Content|Bool
+ */
+ public function merge3( Content $oldContent, Content $myContent, Content $yourContent ) {
+ $this->checkModelID( $oldContent->getModel() );
+ $this->checkModelID( $myContent->getModel() );
+ $this->checkModelID( $yourContent->getModel() );
+
+ $format = $this->getDefaultFormat();
+
+ $old = $this->serializeContent( $oldContent, $format );
+ $mine = $this->serializeContent( $myContent, $format );
+ $yours = $this->serializeContent( $yourContent, $format );
+
+ $ok = wfMerge( $old, $mine, $yours, $result );
+
+ if ( !$ok ) {
+ return false;
+ }
+
+ if ( !$result ) {
+ return $this->makeEmptyContent();
+ }
+
+ $mergedContent = $this->unserializeContent( $result, $format );
+ return $mergedContent;
+ }
+
+ /**
+ * Unserializes a Content object of the type supported by this ContentHandler.
+ *
+ * @since 1.21
+ *
+ * @param $text string serialized form of the content
+ * @param $format null|String the format used for serialization
+ *
+ * @return Content the TextContent object wrapping $text
+ */
+ public function unserializeContent( $text, $format = null ) {
+ $this->checkFormat( $format );
+
+ return new TextContent( $text );
+ }
+
+ /**
+ * Creates an empty TextContent object.
+ *
+ * @since 1.21
+ *
+ * @return Content
+ */
+ public function makeEmptyContent() {
+ return new TextContent( '' );
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/**
+ * @since 1.21
+ */
+class WikitextContentHandler extends TextContentHandler {
+
+ public function __construct( $modelId = CONTENT_MODEL_WIKITEXT ) {
+ parent::__construct( $modelId, array( CONTENT_FORMAT_WIKITEXT ) );
+ }
+
+ public function unserializeContent( $text, $format = null ) {
+ $this->checkFormat( $format );
+
+ return new WikitextContent( $text );
+ }
+
+ /**
+ * @see ContentHandler::makeEmptyContent
+ *
+ * @return Content
+ */
+ public function makeEmptyContent() {
+ return new WikitextContent( '' );
+ }
+
+
+ /**
+ * Returns a WikitextContent object representing a redirect to the given destination page.
+ *
+ * @see ContentHandler::makeRedirectContent
+ *
+ * @param Title $destination the page to redirect to.
+ *
+ * @return Content
+ */
+ public function makeRedirectContent( Title $destination ) {
+ $mwRedir = MagicWord::get( 'redirect' );
+ $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $destination->getPrefixedText() . "]]\n";
+
+ return new WikitextContent( $redirectText );
+ }
+
+ /**
+ * Returns true because wikitext supports sections.
+ *
+ * @return boolean whether sections are supported.
+ */
+ public function supportsSections() {
+ return true;
+ }
+
+ /**
+ * Returns true, because wikitext supports caching using the
+ * ParserCache mechanism.
+ *
+ * @since 1.21
+ * @return bool
+ */
+ public function isParserCacheSupported() {
+ return true;
+ }
+}
\ No newline at end of file