$msg .= "\nThis module only accepts POST requests";
}
if ( $this->isReadMode() || $this->isWriteMode() ||
- $this->mustBePosted() )
- {
+ $this->mustBePosted() ) {
$msg .= "\n";
}
$msg .= "Parameters:\n$paramsMsg";
}
- // Examples
- $examples = $this->getExamples();
- if ( $examples !== false ) {
- if ( !is_array( $examples ) ) {
- $examples = array(
- $examples
- );
- }
-
- if ( count( $examples ) > 0 ) {
- $msg .= 'Example' . ( count( $examples ) > 1 ? 's' : '' ) . ":\n ";
- $msg .= implode( $lnPrfx, $examples ) . "\n";
- }
- }
+ $msg .= $this->makeHelpArrayToString( $lnPrfx, "Example", $this->getExamples() );
+ $msg .= $this->makeHelpArrayToString( $lnPrfx, "Help page", $this->getHelpUrl() );
if ( $this->getMain()->getShowVersions() ) {
$versions = $this->getVersion();
return $msg;
}
+ /**
+ * @param $prefix string Text to split output items
+ * @param $title string What is being output
+ * @param $input string|array
+ * @return string
+ */
+ protected function makeHelpArrayToString( $prefix, $title, $input ) {
+ if ( $input !== false ) {
+ return '';
+ }
+ if ( !is_array( $input ) ) {
+ $input = array(
+ $input
+ );
+ }
+
+ if ( count( $input ) > 0 ) {
+ $msg = $title . ( count( $input ) > 1 ? 's' : '' ) . ":\n ";
+ $msg .= implode( $prefix, $input ) . "\n";
+ return $msg;
+ }
+ return '';
+ }
+
/**
* Generates the parameter descriptions for this module, to be displayed in the
* module's help.
}
/**
- * Returns usage examples for this module. Return null if no examples are available.
- * @return mixed string or array of strings
+ * Returns usage examples for this module. Return false if no examples are available.
+ * @return false|string|array
*/
protected function getExamples() {
return false;
return $user;
}
+ /**
+ * @return false|string|array Returns a false if the module has no help url, else returns a (array of) string
+ */
+ public function getHelpUrl() {
+ return false;
+ }
+
/**
* Returns a list of all possible errors returned by the module
* @return array in the format of array( key, param1, param2, ... ) or array( 'code' => ..., 'info' => ... )
$retval['classname'] = get_class( $obj );
$retval['description'] = implode( "\n", (array)$obj->getDescription() );
$retval['examples'] = implode( "\n", (array)$obj->getExamples() );
+ $retval['helpurl'] = implode( "\n", (array)$obj->getHelpUrl() );
$retval['version'] = implode( "\n", (array)$obj->getVersion() );
$retval['prefix'] = $obj->getModulePrefix();
);
}
+ public function getHelpUrl() {
+ return 'http://www.mediawiki.org/wiki/API:Parameter_information';
+ }
+
public function getVersion() {
return __CLASS__ . ': $Id$';
}