From: daniel Date: Tue, 15 May 2012 06:59:19 +0000 (+0200) Subject: no generic edit page X-Git-Tag: 1.31.0-rc.0~22097^2^2~169 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=1280c5e80c8a1e4400920a0391415baeb684ec9b;p=lhc%2Fweb%2Fwiklou.git no generic edit page --- diff --git a/includes/ContentHandler.php b/includes/ContentHandler.php index b3cf15ca22..95a86f8886 100644 --- a/includes/ContentHandler.php +++ b/includes/ContentHandler.php @@ -496,7 +496,9 @@ abstract class ContentHandler { } /** - * Return an EditPage object suitable for editing the given object + * Return an EditPage object suitable for editing the given object. + * This default implementation always fails with an MWException, because there is no + * generic edit page implementation suitable for all content models. * * @since WD.1 * @@ -504,10 +506,7 @@ abstract class ContentHandler { * @return EditPage */ public function createEditPage( Article $article ) { - $this->checkModelID( $article->getPage()->getContentModel() ); - - $editPage = new EditPage( $article ); - return $editPage; + throw new MWException( "ContentHandler class " . get_classs( $this ) . " does not provide an EditPage." ); } /** @@ -805,11 +804,33 @@ abstract class TextContentHandler extends ContentHandler { parent::__construct( $modelId, $formats ); } + /** + * Returns the content's text as-is. + * + * @param Content $content + * @param String|null $format + * @return mixed + */ public function serializeContent( Content $content, $format = null ) { $this->checkFormat( $format ); return $content->getNativeData(); } + /** + * Return an EditPage object for editing the given object + * + * @since WD.1 + * + * @param Article $article + * @return EditPage + */ + public function createEditPage( Article $article ) { + $this->checkModelID( $article->getPage()->getContentModel() ); + + $editPage = new EditPage( $article ); + return $editPage; + } + /** * attempts to merge differences between three versions. * Returns a new Content object for a clean merge and false for failure or a conflict.