本文整理汇总了PHP中ApiBase::dieDebug方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiBase::dieDebug方法的具体用法?PHP ApiBase::dieDebug怎么用?PHP ApiBase::dieDebug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiBase
的用法示例。
在下文中一共展示了ApiBase::dieDebug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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}");
}
}
}
示例2: 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;
}
示例3: 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);
}
示例4: __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);
}
示例5: 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);
}
示例6: 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']);
}
示例7: 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;
}
}
示例8: 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');
}
}
示例9: execute
public function execute()
{
global $wgUser;
// Before doing anything at all, let's check permissions
if (!$wgUser->isAllowed('codereview-use')) {
$this->dieUsage('You don\'t have permission to update code', 'permissiondenied');
}
$params = $this->extractRequestParams();
$repo = CodeRepository::newFromName($params['repo']);
if (!$repo) {
$this->dieUsage("Invalid repo ``{$params['repo']}''", 'invalidrepo');
}
$svn = SubversionAdaptor::newFromRepo($repo->getPath());
$lastStoredRev = $repo->getLastStoredRev();
if ($lastStoredRev >= $params['rev']) {
// Nothing to do, we're up to date.
// Return an empty result
$this->getResult()->addValue(null, $this->getModuleName(), array());
return;
}
// FIXME: this could be a lot?
$log = $svn->getLog('', $lastStoredRev + 1, $params['rev']);
if (!$log) {
// FIXME: When and how often does this happen?
// Should we use dieUsage() here instead?
ApiBase::dieDebug(__METHOD__, 'Something awry...');
}
$result = array();
$revs = array();
foreach ($log as $data) {
$codeRev = CodeRevision::newFromSvn($repo, $data);
$codeRev->save();
$result[] = array('id' => $codeRev->getId(), 'author' => $codeRev->getAuthor(), 'timestamp' => wfTimestamp(TS_ISO_8601, $codeRev->getTimestamp()), 'message' => $codeRev->getMessage());
$revs[] = $codeRev;
}
// Cache the diffs if there are a only a few.
// Mainly for WMF post-commit ping hook...
if (count($revs) <= 2) {
foreach ($revs as $codeRev) {
$repo->setDiffCache($codeRev);
// trigger caching
}
}
$this->getResult()->setIndexedTagName($result, 'rev');
$this->getResult()->addValue(null, $this->getModuleName(), $result);
}
示例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);
}
示例11: execute
public function execute() {
$params = $this->extractRequestParams();
$result = array();
switch ( $params['field'] ) {
case "username":
$mUser = User::newFromName( $params['inputVal'], 'creatable' );
if ( !is_object( $mUser ) ) {
$result['result'] = wfMsg( 'signupapi-noname' );
$result['icon'] = 'MW-Icon-AlertMark.png';
}
if ( 0 != $mUser->idForName() ) {
$result['result'] = wfMsg( 'signupapi-userexists' );
$result['icon'] = "MW-Icon-NoMark.png";
} else {
$result['result'] = wfMsg( 'signupapi-ok' );
$result['icon'] = "MW-Icon-CheckMark.png";
}
break;
case "email" :
$valid = User::isValidEmailAddr( $params['inputVal'] );
if ( $valid ) {
$result['result']= wfMsg( 'signupapi-ok' );
$result['icon'] = "MW-Icon-CheckMark.png";
} else {
$result['result']= wfMsg( 'signupapi-invalidemailaddress' );
$result['icon'] = "MW-Icon-NoMark.png";
}
break;
case "passwordlength" :
global $wgMinimalPasswordLength;
$result['result'] = $wgMinimalPasswordLength;
break;
default :
ApiBase::dieDebug( __METHOD__, "Unhandled case value: {$params['field']}" );
}
$this->getResult()->addValue( null, 'signup', $result );
}
示例12: __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);
}
示例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);
}
示例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);
}
示例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);
}