public function mustBePosted() { return true; }
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'user' => null,
'token' => null,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'user' => 'Username, IP address or IP range you want to block',
'token' => 'A block token previously obtained through the gettoken parameter',
);
}
- protected function getDescription() {
+ public function getDescription() {
return array(
'Block a user.'
);
$this->getResult()->addValue(null, $this->getModuleName(), $res);
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'user' => null,
'token' => null,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'user' => 'The user you want to add to or remove from groups.',
'token' => 'A changerights token previously obtained through the gettoken parameter.',
);
}
- protected function getDescription() {
+ public function getDescription() {
return array(
'Add or remove a user from certain groups.'
);
public function mustBePosted() { return true; }
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'title' => null,
'token' => null,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'title' => 'Title of the page you want to delete.',
'token' => 'A delete token previously retrieved through prop=info',
);
}
- protected function getDescription() {
+ public function getDescription() {
return array(
'Deletes a page. You need to be logged in as a sysop to use this function, see also action=login.'
);
$result->addValue( null, $this->getModuleName(), $retval_array );
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'title' => array(
ApiBase :: PARAM_DFLT => 'API',
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'text' => 'Wikitext to convert',
'title' => 'Title of page',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'This module expand all templates in wikitext';
}
return new FeedItem($titleStr, $completeText, $titleUrl, $timestamp, $user);
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
global $wgFeedClasses;
$feedFormatNames = array_keys($wgFeedClasses);
return array (
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'feedformat' => 'The format of the feed',
'hours' => 'List pages modified within this many hours from now',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'This module returns a watchlist feed';
}
return 'api.php?action=query&meta=siteinfo&siprop=namespaces&format=' . $this->getModuleName();
}
- protected function getDescription() {
+ public function getDescription() {
return $this->getIsHtml() ? ' (pretty-print in HTML)' : '';
}
-<?php\r
-\r
-/*\r
- * Created on Oct 22, 2006\r
- *\r
- * API for MediaWiki 1.8+\r
- *\r
- * Copyright (C) 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License along\r
- * with this program; if not, write to the Free Software Foundation, Inc.,\r
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
- * http://www.gnu.org/copyleft/gpl.html\r
- */\r
-\r
-if (!defined('MEDIAWIKI')) {\r
- // Eclipse helper - will be ignored in production\r
- require_once ('ApiFormatBase.php');\r
-}\r
-\r
-/**\r
- * @addtogroup API\r
- */\r
-class ApiFormatDbg extends ApiFormatBase {\r
-\r
- public function __construct($main, $format) {\r
- parent :: __construct($main, $format);\r
- }\r
-\r
- public function getMimeType() {\r
- # This looks like it should be text/plain, but IE7 is so\r
- # brain-damaged it tries to parse text/plain as HTML if it\r
- # contains HTML tags. Using MIME text/text works around this bug\r
- return 'text/text';\r
- }\r
-\r
- public function execute() {\r
- $this->printText(var_export($this->getResultData(), true));\r
- }\r
-\r
- protected function getDescription() {\r
- return 'Output data in PHP\'s var_export() format' . parent :: getDescription();\r
- }\r
-\r
- public function getVersion() {\r
- return __CLASS__ . ': $Id: ApiFormatPhp.php 23531 2007-06-29 01:19:14Z simetrical $';\r
- }\r
-}\r
-\r
+<?php
+
+/*
+ * Created on Oct 22, 2006
+ *
+ * API for MediaWiki 1.8+
+ *
+ * Copyright (C) 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+if (!defined('MEDIAWIKI')) {
+ // Eclipse helper - will be ignored in production
+ require_once ('ApiFormatBase.php');
+}
+
+/**
+ * @addtogroup API
+ */
+class ApiFormatDbg extends ApiFormatBase {
+
+ public function __construct($main, $format) {
+ parent :: __construct($main, $format);
+ }
+
+ public function getMimeType() {
+ # This looks like it should be text/plain, but IE7 is so
+ # brain-damaged it tries to parse text/plain as HTML if it
+ # contains HTML tags. Using MIME text/text works around this bug
+ return 'text/text';
+ }
+
+ public function execute() {
+ $this->printText(var_export($this->getResultData(), true));
+ }
+
+ public function getDescription() {
+ return 'Output data in PHP\'s var_export() format' . parent :: getDescription();
+ }
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id: ApiFormatPhp.php 23531 2007-06-29 01:19:14Z simetrical $';
+ }
+}
+
}
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'callback' => null
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'callback' => 'If specified, wraps the output into a given function call',
);
}
- protected function getDescription() {
+ public function getDescription() {
if ($this->mIsRaw)
return 'Output data with the debuging elements in JSON format' . parent :: getDescription();
else
$this->printText(serialize($this->getResultData()));
}
- protected function getDescription() {
+ public function getDescription() {
return 'Output data in serialized PHP format' . parent :: getDescription();
}
-<?php\r
-\r
-/*\r
- * Created on Oct 22, 2006\r
- *\r
- * API for MediaWiki 1.8+\r
- *\r
- * Copyright (C) 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License along\r
- * with this program; if not, write to the Free Software Foundation, Inc.,\r
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
- * http://www.gnu.org/copyleft/gpl.html\r
- */\r
-\r
-if (!defined('MEDIAWIKI')) {\r
- // Eclipse helper - will be ignored in production\r
- require_once ('ApiFormatBase.php');\r
-}\r
-\r
-/**\r
- * @addtogroup API\r
- */\r
-class ApiFormatTxt extends ApiFormatBase {\r
-\r
- public function __construct($main, $format) {\r
- parent :: __construct($main, $format);\r
- }\r
-\r
- public function getMimeType() {\r
- # This looks like it should be text/plain, but IE7 is so\r
- # brain-damaged it tries to parse text/plain as HTML if it\r
- # contains HTML tags. Using MIME text/text works around this bug\r
- return 'text/text';\r
- }\r
-\r
- public function execute() {\r
- $this->printText(print_r($this->getResultData(), true));\r
- }\r
-\r
- protected function getDescription() {\r
- return 'Output data in PHP\'s print_r() format' . parent :: getDescription();\r
- }\r
-\r
- public function getVersion() {\r
- return __CLASS__ . ': $Id: ApiFormatPhp.php 23531 2007-06-29 01:19:14Z simetrical $';\r
- }\r
-}\r
-\r
+<?php
+
+/*
+ * Created on Oct 22, 2006
+ *
+ * API for MediaWiki 1.8+
+ *
+ * Copyright (C) 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+if (!defined('MEDIAWIKI')) {
+ // Eclipse helper - will be ignored in production
+ require_once ('ApiFormatBase.php');
+}
+
+/**
+ * @addtogroup API
+ */
+class ApiFormatTxt extends ApiFormatBase {
+
+ public function __construct($main, $format) {
+ parent :: __construct($main, $format);
+ }
+
+ public function getMimeType() {
+ # This looks like it should be text/plain, but IE7 is so
+ # brain-damaged it tries to parse text/plain as HTML if it
+ # contains HTML tags. Using MIME text/text works around this bug
+ return 'text/text';
+ }
+
+ public function execute() {
+ $this->printText(print_r($this->getResultData(), true));
+ }
+
+ public function getDescription() {
+ return 'Output data in PHP\'s print_r() format' . parent :: getDescription();
+ }
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id: ApiFormatPhp.php 23531 2007-06-29 01:19:14Z simetrical $';
+ }
+}
+
}
}
- protected function getDescription() {
+ public function getDescription() {
return 'Output data in WDDX format' . parent :: getDescription();
}
break;
}
}
- protected function getDescription() {
+ public function getDescription() {
return 'Output data in XML format' . parent :: getDescription();
}
$this->printText(Spyc :: YAMLDump($this->getResultData()));
}
- protected function getDescription() {
+ public function getDescription() {
return 'Output data in YAML format' . parent :: getDescription();
}
return false;
}
- protected function getDescription() {
+ public function getDescription() {
return array (
'Display this help screen.'
);
public function mustBePosted() { return true; }
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'name' => null,
'password' => null,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'name' => 'User Name',
'password' => 'Password',
);
}
- protected function getDescription() {
+ public function getDescription() {
return array (
'This module is used to login and get the authentication tokens. ',
'In the event of a successful log-in, a cookie will be attached',
$wgUser->logout();
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array ();
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array ();
}
- protected function getDescription() {
+ public function getDescription() {
return array (
'This module is used to logout and clear session data'
);
/**
* See ApiBase for description.
*/
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'format' => array (
ApiBase :: PARAM_DFLT => ApiMain :: API_DEFAULT_FORMAT,
/**
* See ApiBase for description.
*/
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'format' => 'The format of the output',
'action' => 'What action you would like to perform',
/**
* See ApiBase for description.
*/
- protected function getDescription() {
+ public function getDescription() {
return array (
'',
'',
public function mustBePosted() { return true; }
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'from' => null,
'to' => null,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'from' => 'Title of the page you want to move.',
'to' => 'Title you want to rename the page to.',
);
}
- protected function getDescription() {
+ public function getDescription() {
return array(
'Moves a page.'
);
$result->addValue(null, 1, $srchres);
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'search' => null,
'limit' => array (
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'search' => 'Search string',
'limit' => 'Maximum amount of results to return'
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'This module implements OpenSearch protocol';
}
-<?php\r
-\r
-/*\r
- * Created on Dec 01, 2007\r
- *\r
- * API for MediaWiki 1.8+\r
- *\r
- * Copyright (C) 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License along\r
- * with this program; if not, write to the Free Software Foundation, Inc.,\r
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
- * http://www.gnu.org/copyleft/gpl.html\r
- */\r
-\r
-if (!defined('MEDIAWIKI')) {\r
- // Eclipse helper - will be ignored in production\r
- require_once ("ApiBase.php");\r
-}\r
-\r
-/**\r
- * @addtogroup API\r
- */\r
-class ApiParamInfo extends ApiBase {\r
-\r
- public function __construct($main, $action) {\r
- parent :: __construct($main, $action);\r
- }\r
-\r
- public function execute() {\r
- // Get parameters\r
- $params = $this->extractRequestParams();\r
- $result = $this->getResult();\r
- $r = array();\r
- if(is_array($params['modules']))\r
- {\r
- $modArr = $this->getMain()->getModules();\r
- foreach($params['modules'] as $m)\r
- {\r
- if(!isset($modArr[$m]))\r
- {\r
- $r['modules'][] = array('name' => $m, 'missing' => '');\r
- continue;\r
- }\r
- $obj = new $modArr[$m]($this->getMain(), $m);\r
- $a = $this->getClassInfo($obj);\r
- $a['name'] = $m;\r
- $r['modules'][] = $a; \r
- }\r
- $result->setIndexedTagName($r['modules'], 'module');\r
- }\r
- if(is_array($params['querymodules']))\r
- {\r
- $queryObj = new ApiQuery($this->getMain(), 'query');\r
- $qmodArr = $queryObj->getModules();\r
- foreach($params['querymodules'] as $qm)\r
- {\r
- if(!isset($qmodArr[$qm]))\r
- {\r
- $r['querymodules'][] = array('name' => $qm, 'missing' => '');\r
- continue;\r
- }\r
- $obj = new $qmodArr[$qm]($this, $qm);\r
- $a = $this->getClassInfo($obj);\r
- $a['name'] = $qm;\r
- $r['querymodules'][] = $a;\r
- }\r
- $result->setIndexedTagName($r['querymodules'], 'module');\r
- }\r
- $result->addValue(null, $this->getModuleName(), $r);\r
- }\r
-\r
- function getClassInfo($obj)\r
- {\r
- $result = $this->getResult();\r
- $retval['classname'] = get_class($obj);\r
- $retval['description'] = (is_array($obj->getDescription()) ? implode("\n", $obj->getDescription()) : $obj->getDescription());\r
- $retval['prefix'] = $obj->getModulePrefix();\r
- $allowedParams = $obj->getAllowedParams();\r
- if(!is_array($allowedParams))\r
- return $retval;\r
- $retval['parameters'] = array();\r
- $paramDesc = $obj->getParamDescription();\r
- foreach($obj->getAllowedParams() as $n => $p)\r
- {\r
- $a = array('name' => $n);\r
- if(!is_array($p))\r
- {\r
- if(is_bool($p))\r
- {\r
- $a['type'] = 'bool';\r
- $a['default'] = ($p ? 'true' : 'false');\r
- }\r
- if(is_string($p))\r
- $a['default'] = $p;\r
- $retval['parameters'][] = $a;\r
- continue;\r
- }\r
- \r
- if(isset($p[ApiBase::PARAM_DFLT]))\r
- $a['default'] = $p[ApiBase::PARAM_DFLT];\r
- if(isset($p[ApiBase::PARAM_ISMULTI]))\r
- if($p[ApiBase::PARAM_ISMULTI])\r
- $a['multi'] = '';\r
- if(isset($p[ApiBase::PARAM_TYPE]))\r
- {\r
- $a['type'] = $p[ApiBase::PARAM_TYPE];\r
- if(is_array($a['type']))\r
- $result->setIndexedTagName($a['type'], 't');\r
- }\r
- if(isset($p[ApiBase::PARAM_MAX]))\r
- $a['max'] = $p[ApiBase::PARAM_MAX];\r
- if(isset($p[ApiBase::PARAM_MAX2]))\r
- $a['highmax'] = $p[ApiBase::PARAM_MAX2];\r
- if(isset($p[ApiBase::PARAM_MIN]))\r
- $a['min'] = $p[ApiBase::PARAM_MIN];\r
- if(isset($paramDesc[$n]))\r
- $a['description'] = (is_array($paramDesc[$n]) ? implode("\n", $paramDesc[$n]) : $paramDesc[$n]);\r
- $retval['parameters'][] = $a;\r
- }\r
- $result->setIndexedTagName($retval['parameters'], 'param');\r
- return $retval;\r
- }\r
- \r
- protected function getAllowedParams() {\r
- return array (\r
- 'modules' => array(\r
- ApiBase :: PARAM_ISMULTI => true\r
- ),\r
- 'querymodules' => array(\r
- ApiBase :: PARAM_ISMULTI => true\r
- )\r
- );\r
- }\r
-\r
- protected function getParamDescription() {\r
- return array (\r
- 'modules' => 'List of module names (value of the action= parameter)',\r
- 'querymodules' => 'List of query module names (value of prop=, meta= or list= parameter)',\r
- );\r
- }\r
-\r
- protected function getDescription() {\r
- return 'Obtain information about certain API parameters';\r
- }\r
-\r
- protected function getExamples() {\r
- return array (\r
- 'api.php?action=paraminfo&modules=parse&querymodules=allpages|siteinfo'\r
- );\r
- }\r
-\r
- public function getVersion() {\r
- return __CLASS__ . ': $Id: ApiParse.php 29810 2008-01-15 21:33:08Z catrope $';\r
- }\r
-}\r
-\r
+<?php
+
+/*
+ * Created on Dec 01, 2007
+ *
+ * API for MediaWiki 1.8+
+ *
+ * Copyright (C) 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+if (!defined('MEDIAWIKI')) {
+ // Eclipse helper - will be ignored in production
+ require_once ("ApiBase.php");
+}
+
+/**
+ * @addtogroup API
+ */
+class ApiParamInfo extends ApiBase {
+
+ public function __construct($main, $action) {
+ parent :: __construct($main, $action);
+ }
+
+ public function execute() {
+ // Get parameters
+ $params = $this->extractRequestParams();
+ $result = $this->getResult();
+ $r = array();
+ if(is_array($params['modules']))
+ {
+ $modArr = $this->getMain()->getModules();
+ foreach($params['modules'] as $m)
+ {
+ if(!isset($modArr[$m]))
+ {
+ $r['modules'][] = array('name' => $m, 'missing' => '');
+ continue;
+ }
+ $obj = new $modArr[$m]($this->getMain(), $m);
+ $a = $this->getClassInfo($obj);
+ $a['name'] = $m;
+ $r['modules'][] = $a;
+ }
+ $result->setIndexedTagName($r['modules'], 'module');
+ }
+ if(is_array($params['querymodules']))
+ {
+ $queryObj = new ApiQuery($this->getMain(), 'query');
+ $qmodArr = $queryObj->getModules();
+ foreach($params['querymodules'] as $qm)
+ {
+ if(!isset($qmodArr[$qm]))
+ {
+ $r['querymodules'][] = array('name' => $qm, 'missing' => '');
+ continue;
+ }
+ $obj = new $qmodArr[$qm]($this, $qm);
+ $a = $this->getClassInfo($obj);
+ $a['name'] = $qm;
+ $r['querymodules'][] = $a;
+ }
+ $result->setIndexedTagName($r['querymodules'], 'module');
+ }
+ $result->addValue(null, $this->getModuleName(), $r);
+ }
+
+ function getClassInfo($obj)
+ {
+ $result = $this->getResult();
+ $retval['classname'] = get_class($obj);
+ $retval['description'] = (is_array($obj->getDescription()) ? implode("\n", $obj->getDescription()) : $obj->getDescription());
+ $retval['prefix'] = $obj->getModulePrefix();
+ $allowedParams = $obj->getAllowedParams();
+ if(!is_array($allowedParams))
+ return $retval;
+ $retval['parameters'] = array();
+ $paramDesc = $obj->getParamDescription();
+ foreach($obj->getAllowedParams() as $n => $p)
+ {
+ $a = array('name' => $n);
+ if(!is_array($p))
+ {
+ if(is_bool($p))
+ {
+ $a['type'] = 'bool';
+ $a['default'] = ($p ? 'true' : 'false');
+ }
+ if(is_string($p))
+ $a['default'] = $p;
+ $retval['parameters'][] = $a;
+ continue;
+ }
+
+ if(isset($p[ApiBase::PARAM_DFLT]))
+ $a['default'] = $p[ApiBase::PARAM_DFLT];
+ if(isset($p[ApiBase::PARAM_ISMULTI]))
+ if($p[ApiBase::PARAM_ISMULTI])
+ $a['multi'] = '';
+ if(isset($p[ApiBase::PARAM_TYPE]))
+ {
+ $a['type'] = $p[ApiBase::PARAM_TYPE];
+ if(is_array($a['type']))
+ $result->setIndexedTagName($a['type'], 't');
+ }
+ if(isset($p[ApiBase::PARAM_MAX]))
+ $a['max'] = $p[ApiBase::PARAM_MAX];
+ if(isset($p[ApiBase::PARAM_MAX2]))
+ $a['highmax'] = $p[ApiBase::PARAM_MAX2];
+ if(isset($p[ApiBase::PARAM_MIN]))
+ $a['min'] = $p[ApiBase::PARAM_MIN];
+ if(isset($paramDesc[$n]))
+ $a['description'] = (is_array($paramDesc[$n]) ? implode("\n", $paramDesc[$n]) : $paramDesc[$n]);
+ $retval['parameters'][] = $a;
+ }
+ $result->setIndexedTagName($retval['parameters'], 'param');
+ return $retval;
+ }
+
+ public function getAllowedParams() {
+ return array (
+ 'modules' => array(
+ ApiBase :: PARAM_ISMULTI => true
+ ),
+ 'querymodules' => array(
+ ApiBase :: PARAM_ISMULTI => true
+ )
+ );
+ }
+
+ public function getParamDescription() {
+ return array (
+ 'modules' => 'List of module names (value of the action= parameter)',
+ 'querymodules' => 'List of query module names (value of prop=, meta= or list= parameter)',
+ );
+ }
+
+ public function getDescription() {
+ return 'Obtain information about certain API parameters';
+ }
+
+ protected function getExamples() {
+ return array (
+ 'api.php?action=paraminfo&modules=parse&querymodules=allpages|siteinfo'
+ );
+ }
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id: ApiParse.php 29810 2008-01-15 21:33:08Z catrope $';
+ }
+}
+
}
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'title' => array(
ApiBase :: PARAM_DFLT => 'API',
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'text' => 'Wikitext to parse',
'title' => 'Title of page',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'This module parses wikitext and returns parser output';
}
public function mustBePosted() { return true; }
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'title' => null,
'token' => null,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'title' => 'Title of the page you want to restore.',
'token' => 'A protect token previously retrieved through prop=info',
);
}
- protected function getDescription() {
+ public function getDescription() {
return array(
'Change the protection level of a page.'
);
* Returns the list of allowed parameters for this module.
* Qurey module also lists all ApiPageSet parameters as its own.
*/
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'prop' => array (
ApiBase :: PARAM_ISMULTI => true,
return true;
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'prop' => 'Which properties to get for the titles/revisions/pageids',
'list' => 'Which lists to get',
);
}
- protected function getDescription() {
+ public function getDescription() {
return array (
'Query API module allows applications to get needed pieces of data from the MediaWiki databases,',
'and is loosely based on the Query API interface currently available on all MediaWiki servers.',
}
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'from' => null,
'prefix' => null,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'from' => 'The category to start enumerating from.',
'prefix' => 'Search for all category titles that begin with this value.',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Enumerate all categories';
}
}
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'from' => null,
'prefix' => null,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'from' => 'The page title to start enumerating from.',
'prefix' => 'Search for all page titles that begin with this value.',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Enumerate all links that point to a given namespace';
}
$result->addValue('query', $this->getModuleName(), $data);
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'from' => null,
'prefix' => null,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'from' => 'The user name to start enumerating from.',
'prefix' => 'Search for all page titles that begin with this value.',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Enumerate all registered users';
}
$result->addValue( 'query', $this->getModuleName(), $messages_out );
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'messages' => array (
ApiBase :: PARAM_DFLT => '*',
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'messages' => 'Which messages to output. "*" means all messages',
'filter' => 'Return only messages that contains specified string',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Return messages from this site.';
}
}
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
global $wgRestrictionTypes, $wgRestrictionLevels;
return array (
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'from' => 'The page title to start enumerating from.',
'prefix' => 'Search for all page titles that begin with this value.',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Enumerate all pages sequentially in a given namespace';
}
'|' . $lastPageID;
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'title' => null,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'title' => 'Title to search. If null, titles= parameter will be used instead, but will be obsolete soon.',
'continue' => 'When more results are available, use this to continue.',
);
}
- protected function getDescription() {
+ public function getDescription() {
switch ($this->getModuleName()) {
case 'backlinks' :
return 'Find all pages that link to the given page';
return implode('.', $parts);
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'start' => array(
ApiBase :: PARAM_TYPE => 'timestamp'
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'start' => 'The timestamp to start enumerating from',
'end' => 'The timestamp to stop enumerating at',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'List all blocked users and IP addresses.';
}
$db->freeResult($res);
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'prop' => array (
ApiBase :: PARAM_ISMULTI => true,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'prop' => 'Which additional properties to get for each category.',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'List all categories the page(s) belong to';
}
}
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'category' => null,
'prop' => array (
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'category' => 'Which category to enumerate (required)',
'prop' => 'What pieces of information to include',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'List all pages in a given category';
}
$result->addValue('query', $this->getModuleName(), $data);
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'start' => array(
ApiBase :: PARAM_TYPE => 'timestamp'
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'start' => 'The timestamp to start enumerating from',
'end' => 'The timestamp to stop enumerating at',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'List deleted revisions.';
}
}
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
global $wgUrlProtocols;
$protocols = array();
foreach ($wgUrlProtocols as $p) {
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'prop' => 'What pieces of information to include',
'offset' => 'Used for paging. Use the value returned for "continue"',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Enumerate pages that contain a given URL';
}
$db->freeResult($res);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Returns all external urls (not interwikies) from the given page(s)';
}
return $vals;
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'prop' => array (
ApiBase :: PARAM_ISMULTI => true,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'prop' => 'What image information to get.',
'limit' => 'How many image revisions to return',
);
}
- protected function getDescription() {
+ public function getDescription() {
return array (
'Returns image information and upload history'
);
$db->freeResult($res);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Returns all images contained on the given page(s)';
}
}
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'prop' => array (
ApiBase :: PARAM_DFLT => NULL,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'prop' => array (
'Which additional properties to get:',
}
- protected function getDescription() {
+ public function getDescription() {
return 'Get basic page information such as namespace, title, last touched date, ...';
}
$db->freeResult($res);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Returns all interlanguage links from the given page(s)';
}
$db->freeResult($res);
}
- protected function getAllowedParams()
+ public function getAllowedParams()
{
return array(
'namespace' => array(
);
}
- protected function getParamDescription()
+ public function getParamDescription()
{
return array(
'namespace' => "Show {$this->description}s in this namespace(s) only"
);
}
- protected function getDescription() {
+ public function getDescription() {
return "Returns all {$this->description}s from the given page(s)";
}
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
global $wgLogTypes;
return array (
'prop' => array (
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'prop' => 'Which properties to get',
'type' => 'Filter log entries to only this type(s)',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Get events from logs.';
}
-<?php\r
-\r
-/*\r
- * Created on Monday, January 28, 2008\r
- *\r
- * API for MediaWiki 1.8+\r
- *\r
- * Copyright (C) 2008 Brent Garber\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License along\r
- * with this program; if not, write to the Free Software Foundation, Inc.,\r
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
- * http://www.gnu.org/copyleft/gpl.html\r
- */\r
-\r
-if (!defined('MEDIAWIKI')) {\r
- // Eclipse helper - will be ignored in production\r
- require_once ('ApiQueryBase.php');\r
-}\r
-\r
-/**\r
- * Query module to get list of random pages\r
- * \r
- * @addtogroup API\r
- */\r
- \r
- class ApiQueryRandom extends ApiQueryGeneratorBase {\r
-\r
- public function __construct($query, $moduleName) {\r
- parent :: __construct($query, $moduleName, 'rn');\r
- }\r
- \r
- public function execute() {\r
- $this->run();\r
- }\r
- \r
- public function executeGenerator($resultPageSet) {\r
- $this->run($resultPageSet);\r
- }\r
-\r
- public function run($resultPageSet = null) {\r
- $params = $this->extractRequestParams();\r
- $result = $this->getResult();\r
- $randstr = wfRandom();\r
- $data = array();\r
-\r
- $this->addTables('page');\r
- $this->addOption('LIMIT', $params['limit']);\r
- $this->addWhereFld('page_namespace', $params['namespace']);\r
- $this->addWhereRange('page_random', 'newer', $randstr, null);\r
- $this->addWhere(array('page_is_redirect' => 0));\r
- $this->addOption('USE INDEX', 'page_random');\r
- if(is_null($resultPageSet))\r
- $this->addFields(array('page_id', 'page_title', 'page_namespace'));\r
- else\r
- $this->addFields($resultPageSet->getPageTableFields());\r
-\r
- $db = $this->getDB();\r
- $res = $this->select(__METHOD__);\r
- while($row = $db->fetchObject($res)) {\r
- if(is_null($resultPageSet))\r
- $data[] = $this->extractRowInfo($row);\r
- else\r
- $resultPageSet->processDbRow($row);\r
- }\r
- $db->freeResult($res);\r
-\r
- if(is_null($resultPageSet)) {\r
- $result->setIndexedTagName($data, 'page');\r
- $result->addValue('query', $this->getModuleName(), $data);\r
- } \r
- }\r
-\r
- private function extractRowInfo($row) {\r
- $title = Title::makeTitle($row->page_namespace, $row->page_title);\r
- $vals = array();\r
- $vals['title'] = $title->getPrefixedText();\r
- $vals['ns'] = $row->page_namespace;\r
- $vals['id'] = $row->page_id;\r
- return $vals;\r
- }\r
- \r
- protected function getAllowedParams() {\r
- return array (\r
- 'namespace' => array(\r
- ApiBase :: PARAM_TYPE => 'namespace',\r
- ApiBase :: PARAM_ISMULTI => true\r
- ),\r
- 'limit' => array (\r
- ApiBase :: PARAM_TYPE => 'limit',\r
- ApiBase :: PARAM_DFLT => 1,\r
- ApiBase :: PARAM_MIN => 1,\r
- ApiBase :: PARAM_MAX => 10,\r
- ApiBase :: PARAM_MAX2 => 20\r
- ),\r
- );\r
- }\r
-\r
- protected function getParamDescription() {\r
- return array (\r
- 'namespace' => 'Return pages in these namespaces only',\r
- 'limit' => 'Limit how many random pages will be returned'\r
- );\r
- }\r
-\r
- protected function getDescription() {\r
- return array( 'Get a set of random pages',\r
- 'NOTE: When using a namespace filter, this module may return an empty result. In that case, retry the request'\r
- );\r
- }\r
-\r
- protected function getExamples() {\r
- return 'api.php?action=query&list=random&rnnamespace=0&rnlimit=2';\r
- }\r
-\r
- public function getVersion() {\r
- return __CLASS__ . ': $Id: ApiQueryRandom.php overlordq$';\r
- }\r
-}\r
+<?php
+
+/*
+ * Created on Monday, January 28, 2008
+ *
+ * API for MediaWiki 1.8+
+ *
+ * Copyright (C) 2008 Brent Garber
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+if (!defined('MEDIAWIKI')) {
+ // Eclipse helper - will be ignored in production
+ require_once ('ApiQueryBase.php');
+}
+
+/**
+ * Query module to get list of random pages
+ *
+ * @addtogroup API
+ */
+
+ class ApiQueryRandom extends ApiQueryGeneratorBase {
+
+ public function __construct($query, $moduleName) {
+ parent :: __construct($query, $moduleName, 'rn');
+ }
+
+ public function execute() {
+ $this->run();
+ }
+
+ public function executeGenerator($resultPageSet) {
+ $this->run($resultPageSet);
+ }
+
+ public function run($resultPageSet = null) {
+ $params = $this->extractRequestParams();
+ $result = $this->getResult();
+ $randstr = wfRandom();
+ $data = array();
+
+ $this->addTables('page');
+ $this->addOption('LIMIT', $params['limit']);
+ $this->addWhereFld('page_namespace', $params['namespace']);
+ $this->addWhereRange('page_random', 'newer', $randstr, null);
+ $this->addWhere(array('page_is_redirect' => 0));
+ $this->addOption('USE INDEX', 'page_random');
+ if(is_null($resultPageSet))
+ $this->addFields(array('page_id', 'page_title', 'page_namespace'));
+ else
+ $this->addFields($resultPageSet->getPageTableFields());
+
+ $db = $this->getDB();
+ $res = $this->select(__METHOD__);
+ while($row = $db->fetchObject($res)) {
+ if(is_null($resultPageSet))
+ $data[] = $this->extractRowInfo($row);
+ else
+ $resultPageSet->processDbRow($row);
+ }
+ $db->freeResult($res);
+
+ if(is_null($resultPageSet)) {
+ $result->setIndexedTagName($data, 'page');
+ $result->addValue('query', $this->getModuleName(), $data);
+ }
+ }
+
+ private function extractRowInfo($row) {
+ $title = Title::makeTitle($row->page_namespace, $row->page_title);
+ $vals = array();
+ $vals['title'] = $title->getPrefixedText();
+ $vals['ns'] = $row->page_namespace;
+ $vals['id'] = $row->page_id;
+ return $vals;
+ }
+
+ public function getAllowedParams() {
+ return array (
+ 'namespace' => array(
+ ApiBase :: PARAM_TYPE => 'namespace',
+ ApiBase :: PARAM_ISMULTI => true
+ ),
+ 'limit' => array (
+ ApiBase :: PARAM_TYPE => 'limit',
+ ApiBase :: PARAM_DFLT => 1,
+ ApiBase :: PARAM_MIN => 1,
+ ApiBase :: PARAM_MAX => 10,
+ ApiBase :: PARAM_MAX2 => 20
+ ),
+ );
+ }
+
+ public function getParamDescription() {
+ return array (
+ 'namespace' => 'Return pages in these namespaces only',
+ 'limit' => 'Limit how many random pages will be returned'
+ );
+ }
+
+ public function getDescription() {
+ return array( 'Get a set of random pages',
+ 'NOTE: When using a namespace filter, this module may return an empty result. In that case, retry the request'
+ );
+ }
+
+ protected function getExamples() {
+ return 'api.php?action=query&list=random&rnnamespace=0&rnlimit=2';
+ }
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id: ApiQueryRandom.php overlordq$';
+ }
+}
}
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'start' => array (
ApiBase :: PARAM_TYPE => 'timestamp'
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'start' => 'The timestamp to start enumerating from.',
'end' => 'The timestamp to end enumerating.',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Enumerate recent changes';
}
return $vals;
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'prop' => array (
ApiBase :: PARAM_ISMULTI => true,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'prop' => 'Which properties to get for each revision.',
'limit' => 'limit how many revisions will be returned (enum)',
);
}
- protected function getDescription() {
+ public function getDescription() {
return array (
'Get revision information.',
'This module may be used in several ways:',
}
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'search' => null,
'namespace' => array (
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'search' => 'Search for all page titles (or content) that has this value.',
'namespace' => 'The namespace(s) to enumerate.',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Perform a full text search';
}
$this->getResult()->addValue('query', $property, $data);
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'prop' => array (
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'prop' => array (
'Which sysinfo properties to get:',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Return general information about the site.';
}
return $vals;
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'limit' => array (
ApiBase :: PARAM_DFLT => 10,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'limit' => 'The maximum number of contributions to return.',
'start' => 'The start timestamp to return from.',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Get all edits by a user';
}
return $vals;
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'prop' => array (
ApiBase :: PARAM_DFLT => NULL,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'prop' => array(
'What pieces of information to include',
);
}
- protected function getDescription() {
+ public function getDescription() {
return 'Get information about the current user';
}
-<?php\r
-\r
-/*\r
- * Created on July 30, 2007\r
- *\r
- * API for MediaWiki 1.8+\r
- *\r
- * Copyright (C) 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License along\r
- * with this program; if not, write to the Free Software Foundation, Inc.,\r
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
- * http://www.gnu.org/copyleft/gpl.html\r
- */\r
-\r
-if (!defined('MEDIAWIKI')) {\r
- // Eclipse helper - will be ignored in production\r
- require_once ('ApiQueryBase.php');\r
-}\r
-\r
-/**\r
- * Query module to get information about a list of users\r
- * \r
- * @addtogroup API\r
- */\r
- \r
- class ApiQueryUsers extends ApiQueryBase {\r
-\r
- public function __construct($query, $moduleName) {\r
- parent :: __construct($query, $moduleName, 'us');\r
- }\r
-\r
- public function execute() {\r
- $params = $this->extractRequestParams();\r
- $result = $this->getResult();\r
- $r = array();\r
-\r
- if (!is_null($params['prop'])) {\r
- $this->prop = array_flip($params['prop']);\r
- } else {\r
- $this->prop = array();\r
- }\r
- \r
- if(is_array($params['users'])) {\r
- $r = $this->getOtherUsersInfo($params['users']);\r
- $result->setIndexedTagName($r, 'user');\r
- }\r
- $result->addValue("query", $this->getModuleName(), $r);\r
- }\r
-\r
- protected function getOtherUsersInfo($users) {\r
- $goodNames = $retval = array();\r
- // Canonicalize user names\r
- foreach($users as $u) {\r
- $n = User::getCanonicalName($u);\r
- if($n === false) \r
- $retval[] = array('name' => $u, 'invalid' => '');\r
- else\r
- $goodNames[] = $n;\r
- }\r
-\r
- $db = $this->getDb();\r
- $userTable = $db->tableName('user');\r
- $tables = "$userTable AS u1";\r
- $this->addFields('u1.user_name');\r
- $this->addWhereFld('u1.user_name', $goodNames);\r
- $this->addFieldsIf('u1.user_editcount', isset($this->prop['editcount']));\r
- \r
- if(isset($this->prop['groups'])) {\r
- $ug = $db->tableName('user_groups');\r
- $tables = "$tables LEFT JOIN $ug ON ug_user=u1.user_id";\r
- $this->addFields('ug_group');\r
- }\r
- if(isset($this->prop['blockinfo'])) {\r
- $ipb = $db->tableName('ipblocks');\r
- $tables = "$tables LEFT JOIN $ipb ON ipb_user=u1.user_id";\r
- $tables = "$tables LEFT JOIN $userTable AS u2 ON ipb_by=u2.user_id";\r
- $this->addFields(array('ipb_reason', 'u2.user_name AS blocker_name'));\r
- }\r
- $this->addTables($tables);\r
- \r
- $data = array();\r
- $res = $this->select(__METHOD__);\r
- while(($r = $db->fetchObject($res))) {\r
- $data[$r->user_name]['name'] = $r->user_name;\r
- if(isset($this->prop['editcount']))\r
- $data[$r->user_name]['editcount'] = $r->user_editcount;\r
- if(isset($this->prop['groups']))\r
- // This row contains only one group, others will be added from other rows\r
- if(!is_null($r->ug_group))\r
- $data[$r->user_name]['groups'][] = $r->ug_group;\r
- if(isset($this->prop['blockinfo']))\r
- if(!is_null($r->blocker_name)) {\r
- $data[$r->user_name]['blockedby'] = $r->blocker_name;\r
- $data[$r->user_name]['blockreason'] = $r->ipb_reason;\r
- }\r
- }\r
- \r
- // Second pass: add result data to $retval\r
- foreach($goodNames as $u) {\r
- if(!isset($data[$u]))\r
- $retval[] = array('name' => $u, 'missing' => '');\r
- else {\r
- if(isset($this->prop['groups']) && isset($data[$u]['groups']))\r
- $this->getResult()->setIndexedTagName($data[$u]['groups'], 'g');\r
- $retval[] = $data[$u];\r
- }\r
- }\r
- return $retval; \r
- }\r
-\r
- protected function getAllowedParams() {\r
- return array (\r
- 'prop' => array (\r
- ApiBase :: PARAM_DFLT => NULL,\r
- ApiBase :: PARAM_ISMULTI => true,\r
- ApiBase :: PARAM_TYPE => array (\r
- 'blockinfo',\r
- 'groups',\r
- 'editcount'\r
- )\r
- ),\r
- 'users' => array(\r
- ApiBase :: PARAM_ISMULTI => true\r
- )\r
- );\r
- }\r
-\r
- protected function getParamDescription() {\r
- return array (\r
- 'prop' => array(\r
- 'What pieces of information to include',\r
- ' blockinfo - tags if the user is blocked, by whom, and for what reason',\r
- ' groups - lists all the groups the user belongs to',\r
- ' editcount - adds the user\'s edit count'\r
- ),\r
- 'users' => 'A list of users to obtain the same information for'\r
- );\r
- }\r
-\r
- protected function getDescription() {\r
- return 'Get information about a list of users';\r
- }\r
-\r
- protected function getExamples() {\r
- return 'api.php?action=query&list=users&ususers=brion|TimStarling&usprop=groups|editcount';\r
- }\r
-\r
- public function getVersion() {\r
- return __CLASS__ . ': $Id: ApiQueryUserInfo.php 30128 2008-01-24 17:59:07Z catrope $';\r
- }\r
-}\r
+<?php
+
+/*
+ * Created on July 30, 2007
+ *
+ * API for MediaWiki 1.8+
+ *
+ * Copyright (C) 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+if (!defined('MEDIAWIKI')) {
+ // Eclipse helper - will be ignored in production
+ require_once ('ApiQueryBase.php');
+}
+
+/**
+ * Query module to get information about a list of users
+ *
+ * @addtogroup API
+ */
+
+ class ApiQueryUsers extends ApiQueryBase {
+
+ public function __construct($query, $moduleName) {
+ parent :: __construct($query, $moduleName, 'us');
+ }
+
+ public function execute() {
+ $params = $this->extractRequestParams();
+ $result = $this->getResult();
+ $r = array();
+
+ if (!is_null($params['prop'])) {
+ $this->prop = array_flip($params['prop']);
+ } else {
+ $this->prop = array();
+ }
+
+ if(is_array($params['users'])) {
+ $r = $this->getOtherUsersInfo($params['users']);
+ $result->setIndexedTagName($r, 'user');
+ }
+ $result->addValue("query", $this->getModuleName(), $r);
+ }
+
+ protected function getOtherUsersInfo($users) {
+ $goodNames = $retval = array();
+ // Canonicalize user names
+ foreach($users as $u) {
+ $n = User::getCanonicalName($u);
+ if($n === false)
+ $retval[] = array('name' => $u, 'invalid' => '');
+ else
+ $goodNames[] = $n;
+ }
+
+ $db = $this->getDb();
+ $userTable = $db->tableName('user');
+ $tables = "$userTable AS u1";
+ $this->addFields('u1.user_name');
+ $this->addWhereFld('u1.user_name', $goodNames);
+ $this->addFieldsIf('u1.user_editcount', isset($this->prop['editcount']));
+
+ if(isset($this->prop['groups'])) {
+ $ug = $db->tableName('user_groups');
+ $tables = "$tables LEFT JOIN $ug ON ug_user=u1.user_id";
+ $this->addFields('ug_group');
+ }
+ if(isset($this->prop['blockinfo'])) {
+ $ipb = $db->tableName('ipblocks');
+ $tables = "$tables LEFT JOIN $ipb ON ipb_user=u1.user_id";
+ $tables = "$tables LEFT JOIN $userTable AS u2 ON ipb_by=u2.user_id";
+ $this->addFields(array('ipb_reason', 'u2.user_name AS blocker_name'));
+ }
+ $this->addTables($tables);
+
+ $data = array();
+ $res = $this->select(__METHOD__);
+ while(($r = $db->fetchObject($res))) {
+ $data[$r->user_name]['name'] = $r->user_name;
+ if(isset($this->prop['editcount']))
+ $data[$r->user_name]['editcount'] = $r->user_editcount;
+ if(isset($this->prop['groups']))
+ // This row contains only one group, others will be added from other rows
+ if(!is_null($r->ug_group))
+ $data[$r->user_name]['groups'][] = $r->ug_group;
+ if(isset($this->prop['blockinfo']))
+ if(!is_null($r->blocker_name)) {
+ $data[$r->user_name]['blockedby'] = $r->blocker_name;
+ $data[$r->user_name]['blockreason'] = $r->ipb_reason;
+ }
+ }
+
+ // Second pass: add result data to $retval
+ foreach($goodNames as $u) {
+ if(!isset($data[$u]))
+ $retval[] = array('name' => $u, 'missing' => '');
+ else {
+ if(isset($this->prop['groups']) && isset($data[$u]['groups']))
+ $this->getResult()->setIndexedTagName($data[$u]['groups'], 'g');
+ $retval[] = $data[$u];
+ }
+ }
+ return $retval;
+ }
+
+ public function getAllowedParams() {
+ return array (
+ 'prop' => array (
+ ApiBase :: PARAM_DFLT => NULL,
+ ApiBase :: PARAM_ISMULTI => true,
+ ApiBase :: PARAM_TYPE => array (
+ 'blockinfo',
+ 'groups',
+ 'editcount'
+ )
+ ),
+ 'users' => array(
+ ApiBase :: PARAM_ISMULTI => true
+ )
+ );
+ }
+
+ public function getParamDescription() {
+ return array (
+ 'prop' => array(
+ 'What pieces of information to include',
+ ' blockinfo - tags if the user is blocked, by whom, and for what reason',
+ ' groups - lists all the groups the user belongs to',
+ ' editcount - adds the user\'s edit count'
+ ),
+ 'users' => 'A list of users to obtain the same information for'
+ );
+ }
+
+ public function getDescription() {
+ return 'Get information about a list of users';
+ }
+
+ protected function getExamples() {
+ return 'api.php?action=query&list=users&ususers=brion|TimStarling&usprop=groups|editcount';
+ }
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id: ApiQueryUserInfo.php 30128 2008-01-24 17:59:07Z catrope $';
+ }
+}
return $vals;
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'allrev' => false,
'start' => array (
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'allrev' => 'Include multiple revisions of the same page within given timeframe.',
'start' => 'The timestamp to start enumerating from.',
);
}
- protected function getDescription() {
+ public function getDescription() {
return '';
}
public function mustBePosted() { return true; }
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'title' => null,
'user' => null,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'title' => 'Title of the page you want to rollback.',
'user' => 'Name of the user whose edits are to be rolled back. If set incorrectly, you\'ll get a badtoken error.',
);
}
- protected function getDescription() {
+ public function getDescription() {
return array(
'Undoes the last edit to the page. If the last user who edited the page made multiple edits in a row,',
'they will all be rolled back. You need to be logged in as a sysop to use this function, see also action=login.'
public function mustBePosted() { return true; }
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'id' => null,
'user' => null,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'id' => 'ID of the block you want to unblock (obtained through list=blocks). Cannot be used together with user',
'user' => 'Username, IP address or IP range you want to unblock. Cannot be used together with id',
);
}
- protected function getDescription() {
+ public function getDescription() {
return array(
'Unblock a user.'
);
public function mustBePosted() { return true; }
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'title' => null,
'token' => null,
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'title' => 'Title of the page you want to restore.',
'token' => 'An undelete token previously retrieved through list=deletedrevs',
);
}
- protected function getDescription() {
+ public function getDescription() {
return array(
'Restore certain revisions of a deleted page. A list of deleted revisions (including timestamps) can be',
'retrieved through list=deletedrevs'