本文整理汇总了PHP中ApiBase类的典型用法代码示例。如果您正苦于以下问题:PHP ApiBase类的具体用法?PHP ApiBase怎么用?PHP ApiBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ApiBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setGeneratorMode
/**
* Switch this module to generator mode. By default, generator mode is
* switched off and the module acts like a normal query module.
* @since 1.21 requires pageset parameter
* @param ApiPageSet $generatorPageSet ApiPageSet object that the module will get
* by calling getPageSet() when in generator mode.
*/
public function setGeneratorMode(ApiPageSet $generatorPageSet)
{
if ($generatorPageSet === null) {
ApiBase::dieDebug(__METHOD__, 'Required parameter missing - $generatorPageSet');
}
$this->mGeneratorPageSet = $generatorPageSet;
}
开发者ID:paladox,项目名称:mediawiki,代码行数:14,代码来源:ApiQueryGeneratorBase.php
示例2: execute
public function execute()
{
global $wgUser;
$this->checkPermission($wgUser);
$params = $this->extractRequestParams();
$res = array();
$concurrencyCheck = new ConcurrencyCheck($params['resourcetype'], $wgUser);
switch ($params['ccaction']) {
case 'checkout':
case 'checkin':
if ($concurrencyCheck->{$params}['ccaction']($params['record'])) {
$res['result'] = 'success';
} else {
$res['result'] = 'failure';
}
// data to be utilized by the caller for checkout
if ($params['ccaction'] === 'checkout') {
$lastCheckout = $concurrencyCheck->checkoutResult();
if ($res['result'] === 'success') {
$user = $wgUser;
} else {
$user = User::newFromId(intval($lastCheckout['userId']));
}
if (!$user->isAnon()) {
$res['userid'] = $user->getId();
$res['username'] = $user->getName();
}
$res['expiration'] = $lastCheckout['expiration'];
}
break;
default:
ApiBase::dieDebug(__METHOD__, "Unhandled concurrency action: {$params['ccaction']}");
}
$this->getResult()->addValue(null, $this->getModuleName(), $res);
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:35,代码来源:ApiConcurrency.php
示例3: execute
public function execute()
{
$prop = null;
extract($this->extractRequestParams());
foreach ($prop as $p) {
switch ($p) {
case 'general':
global $wgSitename, $wgVersion, $wgCapitalLinks;
$data = array();
$mainPage = Title::newFromText(wfMsgForContent('mainpage'));
$data['mainpage'] = $mainPage->getText();
$data['base'] = $mainPage->getFullUrl();
$data['sitename'] = $wgSitename;
$data['generator'] = "MediaWiki {$wgVersion}";
$data['case'] = $wgCapitalLinks ? 'first-letter' : 'case-sensitive';
// 'case-insensitive' option is reserved for future
$this->getResult()->addValue('query', $p, $data);
break;
case 'namespaces':
global $wgContLang;
$data = array();
foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
$data[$ns] = array('id' => $ns);
ApiResult::setContent($data[$ns], $title);
}
ApiResult::setIndexedTagName($data, 'ns');
$this->getResult()->addValue('query', $p, $data);
break;
default:
ApiBase::dieDebug(__METHOD__, "Unknown prop={$p}");
}
}
}
开发者ID:puring0815,项目名称:OpenKore,代码行数:33,代码来源:ApiQuerySiteinfo.php
示例4: getFinalDescription
public function getFinalDescription()
{
// A bit of a hack to append 'api-help-authmanager-general-usage'
$msgs = parent::getFinalDescription();
$msgs[] = ApiBase::makeMessage('api-help-authmanager-general-usage', $this->getContext(), [$this->getModulePrefix(), $this->getModuleName(), $this->getModulePath(), AuthManager::ACTION_LOGIN, self::needsToken()]);
return $msgs;
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:7,代码来源:ApiClientLogin.php
示例5: __construct
public function __construct($query, $moduleName)
{
switch ($moduleName) {
case 'alllinks':
$prefix = 'al';
$this->table = 'pagelinks';
$this->tablePrefix = 'pl_';
$this->dfltNamespace = NS_MAIN;
$this->indexTag = 'l';
$this->description = 'Enumerate all links that point to a given namespace';
$this->descriptionLink = 'link';
$this->descriptionLinked = 'linked';
$this->descriptionLinking = 'linking';
break;
case 'alltransclusions':
$prefix = 'at';
$this->table = 'templatelinks';
$this->tablePrefix = 'tl_';
$this->dfltNamespace = NS_TEMPLATE;
$this->indexTag = 't';
$this->description = 'List all transclusions (pages embedded using {{x}}), including non-existing';
$this->descriptionLink = 'transclusion';
$this->descriptionLinked = 'transcluded';
$this->descriptionLinking = 'transcluding';
break;
default:
ApiBase::dieDebug(__METHOD__, 'Unknown module name');
}
parent::__construct($query, $moduleName, $prefix);
}
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:30,代码来源:ApiQueryAllLinks.php
示例6: run
private function run($resultPageSet = null)
{
if ($this->getPageSet()->getGoodTitleCount() == 0) {
return;
}
// nothing to do
$params = $this->extractRequestParams();
$prop = $params['prop'];
$this->addFields(array('cl_from', 'cl_to'));
$fld_sortkey = false;
if (!is_null($prop)) {
foreach ($prop as $p) {
switch ($p) {
case 'sortkey':
$this->addFields('cl_sortkey');
$fld_sortkey = true;
break;
default:
ApiBase::dieDebug(__METHOD__, "Unknown prop={$p}");
}
}
}
$this->addTables('categorylinks');
$this->addWhereFld('cl_from', array_keys($this->getPageSet()->getGoodTitles()));
$this->addOption('ORDER BY', "cl_from, cl_to");
$db = $this->getDB();
$res = $this->select(__METHOD__);
if (is_null($resultPageSet)) {
$data = array();
$lastId = 0;
// database has no ID 0
while ($row = $db->fetchObject($res)) {
if ($lastId != $row->cl_from) {
if ($lastId != 0) {
$this->addPageSubItems($lastId, $data);
$data = array();
}
$lastId = $row->cl_from;
}
$title = Title::makeTitle(NS_CATEGORY, $row->cl_to);
$vals = array();
ApiQueryBase::addTitleInfo($vals, $title);
if ($fld_sortkey) {
$vals['sortkey'] = $row->cl_sortkey;
}
$data[] = $vals;
}
if ($lastId != 0) {
$this->addPageSubItems($lastId, $data);
}
} else {
$titles = array();
while ($row = $db->fetchObject($res)) {
$titles[] = Title::makeTitle(NS_CATEGORY, $row->cl_to);
}
$resultPageSet->populateFromTitles($titles);
}
$db->freeResult($res);
}
开发者ID:mediawiki-extensions,项目名称:bizzwiki,代码行数:59,代码来源:ApiQueryCategories.php
示例7: execute
public function execute()
{
$data = $this->getResultData();
if (isset($data['error'])) {
$this->mErrorFallback->execute();
return;
}
if (!isset($data['text'])) {
ApiBase::dieDebug(__METHOD__, 'No text given for raw formatter');
}
$this->printText($data['text']);
}
开发者ID:tuxmania87,项目名称:GalaxyAdventures,代码行数:12,代码来源:ApiFormatRaw.php
示例8: addTables
protected function addTables($tables, $alias = null)
{
if (is_array($tables)) {
if (!is_null($alias)) {
ApiBase::dieDebug(__METHOD__, 'Multiple table aliases not supported');
}
$this->tables = array_merge($this->tables, $tables);
} else {
if (!is_null($alias)) {
$tables = $this->getDB()->tableName($tables) . ' ' . $alias;
}
$this->tables[] = $tables;
}
}
开发者ID:ErdemA,项目名称:wikihow,代码行数:14,代码来源:ApiQueryBase.php
示例9: execute
public function execute()
{
$data = $this->getResult()->getResultData();
if (isset($data['error'])) {
$this->errorFallback->execute();
return;
}
if (isset($data['file'])) {
$this->file = $data['file'];
} elseif (isset($data['text'])) {
$this->printText($data['text']);
} else {
ApiBase::dieDebug(__METHOD__, 'No text or file given for file formatter');
}
}
开发者ID:saper,项目名称:organic-extensions,代码行数:15,代码来源:ApiFormatFile.php
示例10: __construct
public function __construct($query, $moduleName)
{
switch ($moduleName) {
case self::LINKS:
$this->table = 'pagelinks';
$this->prefix = 'pl';
$this->description = 'link';
break;
case self::TEMPLATES:
$this->table = 'templatelinks';
$this->prefix = 'tl';
$this->description = 'template';
break;
default:
ApiBase::dieDebug(__METHOD__, 'Unknown module name');
}
parent::__construct($query, $moduleName, $this->prefix);
}
开发者ID:josephdye,项目名称:wikireader,代码行数:18,代码来源:ApiQueryLinks.php
示例11: __construct
public function __construct(ApiQuery $query, $moduleName)
{
switch ($moduleName) {
case self::LINKS:
$this->table = 'pagelinks';
$this->prefix = 'pl';
$this->titlesParam = 'titles';
$this->helpUrl = 'https://www.mediawiki.org/wiki/API:Links';
break;
case self::TEMPLATES:
$this->table = 'templatelinks';
$this->prefix = 'tl';
$this->titlesParam = 'templates';
$this->helpUrl = 'https://www.mediawiki.org/wiki/API:Templates';
break;
default:
ApiBase::dieDebug(__METHOD__, 'Unknown module name');
}
parent::__construct($query, $moduleName, $this->prefix);
}
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:20,代码来源:ApiQueryLinks.php
示例12: Execute
public function Execute($method = null)
{
if ($method == null) {
$method = UrlUtils::RequestMethod();
if (UrlUtils::ExistRequestParam("method")) {
$method = strtolower(UrlUtils::GetRequestParam("method"));
}
}
$availableMethods = get_class_methods(get_class($this));
$function = "do" . $method;
try {
if (in_array($function, $availableMethods)) {
$this->{$function}();
} else {
ApiBase::ReturnError("Invalid method", 405);
}
} catch (Exception $ex) {
ApiBase::ReturnError($ex->getMessage(), 500);
}
}
开发者ID:roly445,项目名称:Php-Nuget-Server,代码行数:20,代码来源:apibase.php
示例13: execute
public function execute()
{
global $wgUser;
$this->checkPermission($wgUser);
$params = $this->extractRequestParams();
$res = array();
$concurrencyCheck = new ConcurrencyCheck($params['resourcetype'], $wgUser);
switch ($params['ccaction']) {
case 'checkout':
case 'checkin':
if ($concurrencyCheck->{$params}['ccaction']($params['record'])) {
$res['result'] = 'success';
} else {
$res['result'] = 'failure';
}
break;
default:
ApiBase::dieDebug(__METHOD__, "Unhandled concurrency action: {$params['ccaction']}");
}
$this->getResult()->addValue(null, $this->getModuleName(), $res);
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:21,代码来源:ApiConcurrency.php
示例14: execute
public function execute()
{
$name = $password = $domain = null;
extract($this->extractRequestParams());
$params = new FauxRequest(array('wpName' => $name, 'wpPassword' => $password, 'wpDomain' => $domain, 'wpRemember' => ''));
$result = array();
$loginForm = new LoginForm($params);
switch ($loginForm->authenticateUserData()) {
case LoginForm::SUCCESS:
global $wgUser;
$wgUser->setOption('rememberpassword', 1);
$wgUser->setCookies();
$result['result'] = 'Success';
$result['lguserid'] = $_SESSION['wsUserID'];
$result['lgusername'] = $_SESSION['wsUserName'];
$result['lgtoken'] = $_SESSION['wsToken'];
break;
case LoginForm::NO_NAME:
$result['result'] = 'NoName';
break;
case LoginForm::ILLEGAL:
$result['result'] = 'Illegal';
break;
case LoginForm::WRONG_PLUGIN_PASS:
$result['result'] = 'WrongPluginPass';
break;
case LoginForm::NOT_EXISTS:
$result['result'] = 'NotExists';
break;
case LoginForm::WRONG_PASS:
$result['result'] = 'WrongPass';
break;
case LoginForm::EMPTY_PASS:
$result['result'] = 'EmptyPass';
break;
default:
ApiBase::dieDebug(__METHOD__, 'Unhandled case value');
}
$this->getResult()->addValue(null, 'login', $result);
}
开发者ID:puring0815,项目名称:OpenKore,代码行数:40,代码来源:ApiLogin.php
示例15: __construct
public function __construct(ApiQuery $query, $moduleName)
{
switch ($moduleName) {
case 'alllinks':
$prefix = 'al';
$this->table = 'pagelinks';
$this->tablePrefix = 'pl_';
$this->useIndex = 'pl_namespace';
$this->indexTag = 'l';
break;
case 'alltransclusions':
$prefix = 'at';
$this->table = 'templatelinks';
$this->tablePrefix = 'tl_';
$this->dfltNamespace = NS_TEMPLATE;
$this->useIndex = 'tl_namespace';
$this->indexTag = 't';
break;
case 'allfileusages':
$prefix = 'af';
$this->table = 'imagelinks';
$this->tablePrefix = 'il_';
$this->fieldTitle = 'to';
$this->dfltNamespace = NS_FILE;
$this->hasNamespace = false;
$this->indexTag = 'f';
break;
case 'allredirects':
$prefix = 'ar';
$this->table = 'redirect';
$this->tablePrefix = 'rd_';
$this->indexTag = 'r';
$this->props = array('fragment' => 'rd_fragment', 'interwiki' => 'rd_interwiki');
break;
default:
ApiBase::dieDebug(__METHOD__, 'Unknown module name');
}
parent::__construct($query, $moduleName, $prefix);
}
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:39,代码来源:ApiQueryAllLinks.php
示例16: slowWddxPrinter
/**
* Recursivelly go through the object and output its data in WDDX format.
*/
function slowWddxPrinter($elemValue)
{
switch (gettype($elemValue)) {
case 'array':
$this->printText('<struct>');
foreach ($elemValue as $subElemName => $subElemValue) {
$this->printText(wfElement('var', array('name' => $subElemName), null));
$this->slowWddxPrinter($subElemValue);
$this->printText('</var>');
}
$this->printText('</struct>');
break;
case 'integer':
case 'double':
$this->printText(wfElement('number', null, $elemValue));
break;
case 'string':
$this->printText(wfElement('string', null, $elemValue));
break;
default:
ApiBase::dieDebug(__METHOD__, 'Unknown type ' . gettype($elemValue));
}
}
开发者ID:ErdemA,项目名称:wikihow,代码行数:26,代码来源:ApiFormatWddx.php
示例17: onAPIAfterExecute
/**
* APIAfterExecute hook handler
* @see: https://www.mediawiki.org/wiki/Manual:Hooks/
* @param ApiBase $module
* @return bool
*/
public static function onAPIAfterExecute(ApiBase &$module)
{
global $wgMFSpecialCaseMainPage;
if ($module->getModuleName() == 'parse') {
if (defined('ApiResult::META_CONTENT')) {
$data = $module->getResult()->getResultData();
} else {
$data = $module->getResultData();
}
$params = $module->extractRequestParams();
if (isset($data['parse']['text']) && $params['mobileformat']) {
$result = $module->getResult();
$result->reset();
$title = Title::newFromText($data['parse']['title']);
$text = $data['parse']['text'];
if (is_array($text)) {
if (defined('ApiResult::META_CONTENT') && isset($text[ApiResult::META_CONTENT])) {
$contentKey = $text[ApiResult::META_CONTENT];
} else {
$contentKey = '*';
}
$html = MobileFormatter::wrapHTML($text[$contentKey]);
} else {
$html = MobileFormatter::wrapHTML($text);
}
$mf = new MobileFormatter($html, $title);
$mf->setRemoveMedia($params['noimages']);
$mf->setIsMainPage($params['mainpage'] && $wgMFSpecialCaseMainPage);
$mf->enableExpandableSections(!$params['mainpage']);
// HACK: need a nice way to request a TOC- and edit link-free HTML in the first place
// FIXME: Should this be .mw-editsection?
$mf->remove(array('.toc', 'mw-editsection', '.mw-headline-anchor'));
$mf->filterContent();
if (is_array($text)) {
$text[$contentKey] = $mf->getText();
} else {
$text = $mf->getText();
}
$data['parse']['text'] = $text;
$result->addValue(null, $module->getModuleName(), $data['parse']);
}
}
return true;
}
开发者ID:negati-ve,项目名称:openshift-mediawiki,代码行数:50,代码来源:ApiParseExtender.php
示例18: __construct
public function __construct(ApiQuery $query, $moduleName)
{
switch ($moduleName) {
case self::LINKS:
$this->table = 'pagelinks';
$this->prefix = 'pl';
$this->description = 'link';
$this->titlesParam = 'titles';
$this->titlesParamDescription = 'Only list links to these titles. Useful ' . 'for checking whether a certain page links to a certain title.';
$this->helpUrl = 'https://www.mediawiki.org/wiki/API:Properties#links_.2F_pl';
break;
case self::TEMPLATES:
$this->table = 'templatelinks';
$this->prefix = 'tl';
$this->description = 'template';
$this->titlesParam = 'templates';
$this->titlesParamDescription = 'Only list these templates. Useful ' . 'for checking whether a certain page uses a certain template.';
$this->helpUrl = 'https://www.mediawiki.org/wiki/API:Properties#templates_.2F_tl';
break;
default:
ApiBase::dieDebug(__METHOD__, 'Unknown module name');
}
parent::__construct($query, $moduleName, $this->prefix);
}
开发者ID:whysasse,项目名称:kmwiki,代码行数:24,代码来源:ApiQueryLinks.php
示例19: run
/**
* Generates and outputs the result of this query based upon the provided parameters.
*
* @param ApiPageSet $resultPageSet
*/
public function run($resultPageSet = null)
{
$user = $this->getUser();
/* Get the parameters of the request. */
$params = $this->extractRequestParams();
/* Build our basic query. Namely, something along the lines of:
* SELECT * FROM recentchanges WHERE rc_timestamp > $start
* AND rc_timestamp < $end AND rc_namespace = $namespace
*/
$this->addTables('recentchanges');
$index = array('recentchanges' => 'rc_timestamp');
// May change
$this->addTimestampWhereRange('rc_timestamp', $params['dir'], $params['start'], $params['end']);
if (!is_null($params['continue'])) {
$cont = explode('|', $params['continue']);
$this->dieContinueUsageIf(count($cont) != 2);
$db = $this->getDB();
$timestamp = $db->addQuotes($db->timestamp($cont[0]));
$id = intval($cont[1]);
$this->dieContinueUsageIf($id != $cont[1]);
$op = $params['dir'] === 'older' ? '<' : '>';
$this->addWhere("rc_timestamp {$op} {$timestamp} OR " . "(rc_timestamp = {$timestamp} AND " . "rc_id {$op}= {$id})");
}
$order = $params['dir'] === 'older' ? 'DESC' : 'ASC';
$this->addOption('ORDER BY', array("rc_timestamp {$order}", "rc_id {$order}"));
$this->addWhereFld('rc_namespace', $params['namespace']);
if (!is_null($params['type'])) {
try {
$this->addWhereFld('rc_type', RecentChange::parseToRCType($params['type']));
} catch (Exception $e) {
ApiBase::dieDebug(__METHOD__, $e->getMessage());
}
}
if (!is_null($params['show'])) {
$show = array_flip($params['show']);
/* Check for conflicting parameters. */
if (isset($show['minor']) && isset($show['!minor']) || isset($show['bot']) && isset($show['!bot']) || isset($show['anon']) && isset($show['!anon']) || isset($show['redirect']) && isset($show['!redirect']) || isset($show['patrolled']) && isset($show['!patrolled']) || isset($show['patrolled']) && isset($show['unpatrolled']) || isset($show['!patrolled']) && isset($show['unpatrolled'])) {
$this->dieUsageMsg('show');
}
// Check permissions
if (isset($show['patrolled']) || isset($show['!patrolled']) || isset($show['unpatrolled'])) {
if (!$user->useRCPatrol() && !$user->useNPPatrol()) {
$this->dieUsage('You need the patrol right to request the patrolled flag', 'permissiondenied');
}
}
/* Add additional conditions to query depending upon parameters. */
$this->addWhereIf('rc_minor = 0', isset($show['!minor']));
$this->addWhereIf('rc_minor != 0', isset($show['minor']));
$this->addWhereIf('rc_bot = 0', isset($show['!bot']));
$this->addWhereIf('rc_bot != 0', isset($show['bot']));
$this->addWhereIf('rc_user = 0', isset($show['anon']));
$this->addWhereIf('rc_user != 0', isset($show['!anon']));
$this->addWhereIf('rc_patrolled = 0', isset($show['!patrolled']));
$this->addWhereIf('rc_patrolled != 0', isset($show['patrolled']));
$this->addWhereIf('page_is_redirect = 1', isset($show['redirect']));
if (isset($show['unpatrolled'])) {
// See ChangesList:isUnpatrolled
if ($user->useRCPatrol()) {
$this->addWhere('rc_patrolled = 0');
} elseif ($user->useNPPatrol()) {
$this->addWhere('rc_patrolled = 0');
$this->addWhereFld('rc_type', RC_NEW);
}
}
// Don't throw log entries out the window here
$this->addWhereIf('page_is_redirect = 0 OR page_is_redirect IS NULL', isset($show['!redirect']));
}
if (!is_null($params['user']) && !is_null($params['excludeuser'])) {
$this->dieUsage('user and excludeuser cannot be used together', 'user-excludeuser');
}
if (!is_null($params['user'])) {
$this->addWhereFld('rc_user_text', $params['user']);
$index['recentchanges'] = 'rc_user_text';
}
if (!is_null($params['excludeuser'])) {
// We don't use the rc_user_text index here because
// * it would require us to sort by rc_user_text before rc_timestamp
// * the != condition doesn't throw out too many rows anyway
$this->addWhere('rc_user_text != ' . $this->getDB()->addQuotes($params['excludeuser']));
}
/* Add the fields we're concerned with to our query. */
$this->addFields(array('rc_id', 'rc_timestamp', 'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_type', 'rc_deleted'));
$showRedirects = false;
/* Determine what properties we need to display. */
if (!is_null($params['prop'])) {
$prop = array_flip($params['prop']);
/* Set up internal members based upon params. */
$this->initProperties($prop);
if ($this->fld_patrolled && !$user->useRCPatrol() && !$user->useNPPatrol()) {
$this->dieUsage('You need the patrol right to request the patrolled flag', 'permissiondenied');
}
/* Add fields to our query if they are specified as a needed parameter. */
$this->addFieldsIf(array('rc_this_oldid', 'rc_last_oldid'), $this->fld_ids);
$this->addFieldsIf('rc_comment', $this->fld_comment || $this->fld_parsedcomment);
$this->addFieldsIf('rc_user', $this->fld_user || $this->fld_userid);
//.........这里部分代码省略.........
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:101,代码来源:ApiQueryRecentChanges.php
示例20: getDescriptionMessage
protected function getDescriptionMessage()
{
if (!$this->hasAnyRoutes()) {
return 'apihelp-resetpassword-description-noroutes';
}
return parent::getDescriptionMessage();
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:7,代码来源:ApiResetPassword.php
注:本文中的ApiBase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论