allow CotentHandler to override actions
authordaniel <daniel.kinzler@wikimedia.de>
Mon, 16 Apr 2012 14:55:43 +0000 (16:55 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Mon, 16 Apr 2012 14:55:43 +0000 (16:55 +0200)
includes/ContentHandler.php
includes/WikiPage.php

index 607ec24..b1e5827 100644 (file)
@@ -358,6 +358,18 @@ abstract class ContentHandler {
         }
     }
 
+    /**
+     * Returns overrides for action handlers.
+     * Classes listed here will be used instead of the default one when
+     * (and only when) $wgActions[$action] === true. This allows subclasses
+     * to override the default actiuon handlers.
+     *
+     * @return Array
+     */
+    public function getActionOverrides() {
+        return array();
+    }
+
     /**
      * Return an Article object suitable for viewing the given object
      *
index b44db8d..4638546 100644 (file)
@@ -139,9 +139,21 @@ class WikiPage extends Page {
         * @return Array
         */
        public function getActionOverrides() {
-               return array();
+        $content_handler = $this->getContentHandler();
+               return $content_handler->getActionOverrides();
        }
 
+    /**
+     * Returns the ContentHandler instance to be used to deal with the content of this WikiPage.
+     *
+     * Shorthand for ContentHandler::getForModelName( $this->getContentModelName() );
+     *
+     * @return ContentHandler
+     */
+    public function getContentHandler() {
+        return ContentHandler::getForModelName( $this->getContentModelName() );
+    }
+
        /**
         * Get the title object of the article
         * @return Title object of this page