Merge "Make sure that SQLite uses no prefix"
[lhc/web/wiklou.git] / includes / content / AbstractContent.php
index 495711a..386f55a 100644 (file)
@@ -381,8 +381,8 @@ abstract class AbstractContent implements Content {
         *
         * @since 1.21
         *
-        * @param $page \WikiPage the deleted page
-        * @param $parserOutput null|\ParserOutput optional parser output object
+        * @param $page WikiPage the deleted page
+        * @param $parserOutput null|ParserOutput optional parser output object
         *    for efficient access to meta-information about the content object.
         *    Provide if you have one handy.
         *
@@ -411,4 +411,30 @@ abstract class AbstractContent implements Content {
        public function matchMagicWord( MagicWord $word ) {
                return false;
        }
+
+       /**
+        * @see Content::convert()
+        *
+        * This base implementation calls the hook ConvertContent to enable custom conversions.
+        * Subclasses may override this to implement conversion for "their" content model.
+        *
+        * @param String  $toModel the desired content model, use the CONTENT_MODEL_XXX flags.
+        * @param String  $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is
+        * not allowed, full round-trip conversion is expected to work without losing information.
+        *
+        * @return Content|bool A content object with the content model $toModel, or false if
+        * that conversion is not supported.
+        */
+       public function convert( $toModel, $lossy = '' ) {
+               if ( $this->getModel() === $toModel ) {
+                       //nothing to do, shorten out.
+                       return $this;
+               }
+
+               $lossy = ( $lossy === 'lossy' ); // string flag, convert to boolean for convenience
+               $result = false;
+
+               wfRunHooks( 'ConvertContent', array( $this, $toModel, $lossy, &$result ) );
+               return $result;
+       }
 }