no generic edit page
authordaniel <daniel.kinzler@wikimedia.de>
Tue, 15 May 2012 06:59:19 +0000 (08:59 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Tue, 15 May 2012 06:59:19 +0000 (08:59 +0200)
includes/ContentHandler.php

index b3cf15c..95a86f8 100644 (file)
@@ -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.