* Use *bold* and $italics$ highlighting only in API help. It completely breaks format...
authorVictor Vasiliev <vasilievvv@users.mediawiki.org>
Sat, 1 Dec 2007 17:37:08 +0000 (17:37 +0000)
committerVictor Vasiliev <vasilievvv@users.mediawiki.org>
Sat, 1 Dec 2007 17:37:08 +0000 (17:37 +0000)
RELEASE-NOTES
includes/api/ApiFormatBase.php
includes/api/ApiMain.php

index b6b036e..2975a27 100644 (file)
@@ -313,6 +313,7 @@ Full API documentation is available at http://www.mediawiki.org/wiki/API
 * Add action=parse to render parser output. Use it instead of action=render which is deprecated.
 * Add rvtoken=rollback to prop=revisions
 * Add meta=allmessages to get messages from site's messages cache.
+* Use bold and italics highlighting only in API help
 
 === Languages updated in 1.12 ===
 
index 5bfbd9e..78b3198 100644 (file)
@@ -35,7 +35,7 @@ if (!defined('MEDIAWIKI')) {
  */
 abstract class ApiFormatBase extends ApiBase {
 
-       private $mIsHtml, $mFormat, $mUnescapeAmps;
+       private $mIsHtml, $mFormat, $mUnescapeAmps, $mHelp;
 
        /**
        * Create a new instance of the formatter.
@@ -169,6 +169,13 @@ See <a href='http://www.mediawiki.org/wiki/API'>complete documentation</a>, or
                        echo $text;
        }
 
+       /**
+       * Says pretty-printer that it should use *bold* and $italics$ formatting
+       */
+       public function setHelp( $help = true ) {
+               $this->mHelp = true;
+       }
+       
        /**
        * Prety-print various elements in HTML format, such as xml tags and URLs.
        * This method also replaces any '<' with &lt;
@@ -184,10 +191,12 @@ See <a href='http://www.mediawiki.org/wiki/API'>complete documentation</a>, or
                $text = ereg_replace("($protos)://[^ \\'\"()<\n]+", '<a href="\\0">\\0</a>', $text);
                // identify requests to api.php
                $text = ereg_replace("api\\.php\\?[^ \\()<\n\t]+", '<a href="\\0">\\0</a>', $text);
-               // make strings inside * bold
-               $text = ereg_replace("\\*[^<>\n]+\\*", '<b>\\0</b>', $text);
-               // make strings inside $ italic
-               $text = ereg_replace("\\$[^<>\n]+\\$", '<b><i>\\0</i></b>', $text);
+               if( $this->mHelp ) {
+                       // make strings inside * bold
+                       $text = ereg_replace("\\*[^<>\n]+\\*", '<b>\\0</b>', $text);
+                       // make strings inside $ italic
+                       $text = ereg_replace("\\$[^<>\n]+\\$", '<b><i>\\0</i></b>', $text);
+               }
                
                /* Temporary fix for bad links in help messages. As a special case,
                 * XML-escaped metachars are de-escaped one level in the help message
index 6d81183..d8bc30e 100644 (file)
@@ -317,6 +317,9 @@ class ApiMain extends ApiBase {
 
                        if ($this->mPrinter->getNeedsRawData())
                                $this->getResult()->setRawMode();
+
+                       if( $this->mAction == 'help' )
+                               $this->mPrinter->setHelp();
                }
 
                // Execute