Added "ApiGetDescription" hook
authorSam Reed <reedy@users.mediawiki.org>
Mon, 28 Nov 2011 15:33:28 +0000 (15:33 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Mon, 28 Nov 2011 15:33:28 +0000 (15:33 +0000)
RELEASE-NOTES-1.19
docs/hooks.txt
includes/api/ApiBase.php
includes/api/ApiParamInfo.php

index 265617b..7620f2b 100644 (file)
@@ -184,6 +184,7 @@ production.
   up as a redirect to the linked page on Special:Whatlinkshere.
 * (bug 32609) API: Move captchaid/captchaword of action=edit from core
   to Captcha extension(s)
+* Added 'ApiGetDescription' hook.
 
 === Languages updated in 1.19 ===
 
index 6c7c48e..8223ef1 100644 (file)
@@ -319,12 +319,16 @@ $text : the new text of the article (has yet to be saved)
 &$resultArr : data in this array will be added to the API result
 
 'APIGetAllowedParams': use this hook to modify a module's parameters.
-&$module: Module object
+&$module: ApiBase Module object
 &$params: Array of parameters
 
+'APIGetDescription': use this hook to modify a module's description
+&$module: ApiBase Module object
+&$desc: Array of descriptions
+
 'APIGetParamDescription': use this hook to modify a module's parameter
 descriptions.
-&$module: Module object
+&$module: ApiBase Module object
 &$desc: Array of parameter descriptions
 
 'APIQueryAfterExecute': after calling the execute() method of an
index 3613a6c..cbf79d2 100644 (file)
@@ -235,7 +235,7 @@ abstract class ApiBase extends ContextSource {
        public function makeHelpMsg() {
                static $lnPrfx = "\n  ";
 
-               $msg = $this->getDescription();
+               $msg = $this->getFinalDescription();
 
                if ( $msg !== false ) {
 
@@ -510,6 +510,7 @@ abstract class ApiBase extends ContextSource {
        /**
         * Get final list of parameters, after hooks have had a chance to
         * tweak it as needed.
+        *
         * @return array or false
         */
        public function getFinalParams() {
@@ -519,8 +520,9 @@ abstract class ApiBase extends ContextSource {
        }
 
        /**
-        * Get final description, after hooks have had a chance to tweak it as
+        * Get final parameter descriptions, after hooks have had a chance to tweak it as
         * needed.
+        *
         * @return array
         */
        public function getFinalParamDescription() {
@@ -529,6 +531,18 @@ abstract class ApiBase extends ContextSource {
                return $desc;
        }
 
+       /**
+        * Get final module description, after hooks have had a chance to tweak it as
+        * needed.
+        *
+        * @return array
+        */
+       public function getFinalDescription() {
+               $desc = $this->getDescription();
+               wfRunHooks( 'ApiGetDescription', array( &$this, &$desc ) );
+               return $desc;
+       }
+
        /**
         * This method mangles parameter name based on the prefix supplied to the constructor.
         * Override this method to change parameter name during runtime
index 72d4249..8686ea9 100644 (file)
@@ -113,7 +113,7 @@ class ApiParamInfo extends ApiBase {
        function getClassInfo( $obj ) {
                $result = $this->getResult();
                $retval['classname'] = get_class( $obj );
-               $retval['description'] = implode( "\n", (array)$obj->getDescription() );
+               $retval['description'] = implode( "\n", (array)$obj->getFinalDescription() );
                $examples = (array)$obj->getExamples();
                $retval['examples'] = implode( "\n", $examples );
                $retval['version'] = implode( "\n", (array)$obj->getVersion() );