当前位置: 首页>>代码示例>>PHP>>正文


PHP ApiResult::setIndexedTagName方法代码示例

本文整理汇总了PHP中ApiResult::setIndexedTagName方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiResult::setIndexedTagName方法的具体用法?PHP ApiResult::setIndexedTagName怎么用?PHP ApiResult::setIndexedTagName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ApiResult的用法示例。


在下文中一共展示了ApiResult::setIndexedTagName方法的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}");
         }
     }
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:33,代码来源:ApiQuerySiteinfo.php

示例2: execute

 public function execute()
 {
     if (!$this->hasAnyRoutes()) {
         $this->dieUsage('No password reset routes are available.', 'moduledisabled');
     }
     $params = $this->extractRequestParams() + ['user' => null, 'email' => null];
     $this->requireOnlyOneParameter($params, 'user', 'email');
     $passwordReset = new PasswordReset($this->getConfig(), AuthManager::singleton());
     $status = $passwordReset->isAllowed($this->getUser(), $params['capture']);
     if (!$status->isOK()) {
         $this->dieStatus(Status::wrap($status));
     }
     $status = $passwordReset->execute($this->getUser(), $params['user'], $params['email'], $params['capture']);
     if (!$status->isOK()) {
         $status->value = null;
         $this->dieStatus(Status::wrap($status));
     }
     $result = $this->getResult();
     $result->addValue(['resetpassword'], 'status', 'success');
     if ($params['capture']) {
         $passwords = $status->getValue() ?: [];
         ApiResult::setArrayType($passwords, 'kvp', 'user');
         ApiResult::setIndexedTagName($passwords, 'p');
         $result->addValue(['resetpassword'], 'passwords', $passwords);
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:26,代码来源:ApiResetPassword.php

示例3: execute

 /**
  * Purges the cache of a page
  */
 public function execute()
 {
     $params = $this->extractRequestParams();
     $continuationManager = new ApiContinuationManager($this, array(), array());
     $this->setContinuationManager($continuationManager);
     $forceLinkUpdate = $params['forcelinkupdate'];
     $forceRecursiveLinkUpdate = $params['forcerecursivelinkupdate'];
     $pageSet = $this->getPageSet();
     $pageSet->execute();
     $result = $pageSet->getInvalidTitlesAndRevisions();
     foreach ($pageSet->getGoodTitles() as $title) {
         $r = array();
         ApiQueryBase::addTitleInfo($r, $title);
         $page = WikiPage::factory($title);
         $page->doPurge();
         // Directly purge and skip the UI part of purge().
         $r['purged'] = true;
         if ($forceLinkUpdate || $forceRecursiveLinkUpdate) {
             if (!$this->getUser()->pingLimiter('linkpurge')) {
                 $popts = $page->makeParserOptions('canonical');
                 # Parse content; note that HTML generation is only needed if we want to cache the result.
                 $content = $page->getContent(Revision::RAW);
                 $enableParserCache = $this->getConfig()->get('EnableParserCache');
                 $p_result = $content->getParserOutput($title, $page->getLatest(), $popts, $enableParserCache);
                 # Update the links tables
                 $updates = $content->getSecondaryDataUpdates($title, null, $forceRecursiveLinkUpdate, $p_result);
                 DataUpdate::runUpdates($updates);
                 $r['linkupdate'] = true;
                 if ($enableParserCache) {
                     $pcache = ParserCache::singleton();
                     $pcache->save($p_result, $page, $popts);
                 }
             } else {
                 $error = $this->parseMsg(array('actionthrottledtext'));
                 $this->setWarning($error['info']);
                 $forceLinkUpdate = false;
             }
         }
         $result[] = $r;
     }
     $apiResult = $this->getResult();
     ApiResult::setIndexedTagName($result, 'page');
     $apiResult->addValue(null, $this->getModuleName(), $result);
     $values = $pageSet->getNormalizedTitlesAsResult($apiResult);
     if ($values) {
         $apiResult->addValue(null, 'normalized', $values);
     }
     $values = $pageSet->getConvertedTitlesAsResult($apiResult);
     if ($values) {
         $apiResult->addValue(null, 'converted', $values);
     }
     $values = $pageSet->getRedirectTitlesAsResult($apiResult);
     if ($values) {
         $apiResult->addValue(null, 'redirects', $values);
     }
     $this->setContinuationManager(null);
     $continuationManager->setContinuationIntoResult($apiResult);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:61,代码来源:ApiPurge.php

示例4: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $user = $this->getUrUser($params);
     $form = $this->getUserRightsPage();
     $form->setContext($this->getContext());
     $r['user'] = $user->getName();
     $r['userid'] = $user->getId();
     list($r['added'], $r['removed']) = $form->doSaveUserGroups($user, (array) $params['add'], (array) $params['remove'], $params['reason']);
     $result = $this->getResult();
     ApiResult::setIndexedTagName($r['added'], 'group');
     ApiResult::setIndexedTagName($r['removed'], 'group');
     $result->addValue(null, $this->getModuleName(), $r);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:14,代码来源:ApiUserrights.php

示例5: execute

 public function execute()
 {
     $user = $this->getUser();
     if (!$user->isLoggedIn()) {
         $this->dieUsage('You must be logged-in to have a watchlist', 'notloggedin');
     }
     if (!$user->isAllowed('editmywatchlist')) {
         $this->dieUsage('You don\'t have permission to edit your watchlist', 'permissiondenied');
     }
     $params = $this->extractRequestParams();
     $continuationManager = new ApiContinuationManager($this, array(), array());
     $this->setContinuationManager($continuationManager);
     $pageSet = $this->getPageSet();
     // by default we use pageset to extract the page to work on.
     // title is still supported for backward compatibility
     if (!isset($params['title'])) {
         $pageSet->execute();
         $res = $pageSet->getInvalidTitlesAndRevisions(array('invalidTitles', 'special', 'missingIds', 'missingRevIds', 'interwikiTitles'));
         foreach ($pageSet->getMissingTitles() as $title) {
             $r = $this->watchTitle($title, $user, $params);
             $r['missing'] = 1;
             $res[] = $r;
         }
         foreach ($pageSet->getGoodTitles() as $title) {
             $r = $this->watchTitle($title, $user, $params);
             $res[] = $r;
         }
         ApiResult::setIndexedTagName($res, 'w');
     } else {
         // dont allow use of old title parameter with new pageset parameters.
         $extraParams = array_keys(array_filter($pageSet->extractRequestParams(), function ($x) {
             return $x !== null && $x !== false;
         }));
         if ($extraParams) {
             $p = $this->getModulePrefix();
             $this->dieUsage("The parameter {$p}title can not be used with " . implode(", ", $extraParams), 'invalidparammix');
         }
         $this->logFeatureUsage('action=watch&title');
         $title = Title::newFromText($params['title']);
         if (!$title || !$title->isWatchable()) {
             $this->dieUsageMsg(array('invalidtitle', $params['title']));
         }
         $res = $this->watchTitle($title, $user, $params, true);
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
     $this->setContinuationManager(null);
     $continuationManager->setContinuationIntoResult($this->getResult());
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:48,代码来源:ApiWatch.php

示例6: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $props = array_flip($params['prop']);
     $repos = array();
     $repoGroup = $this->getInitialisedRepoGroup();
     $repoGroup->forEachForeignRepo(function ($repo) use(&$repos, $props) {
         $repos[] = array_intersect_key($repo->getInfo(), $props);
     });
     $repos[] = array_intersect_key($repoGroup->getLocalRepo()->getInfo(), $props);
     $result = $this->getResult();
     ApiResult::setIndexedTagName($repos, 'repo');
     ApiResult::setArrayTypeRecursive($repos, 'assoc');
     ApiResult::setArrayType($repos, 'array');
     $result->addValue(array('query'), 'repos', $repos);
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:16,代码来源:ApiQueryFileRepoInfo.php

示例7: execute

 public function execute()
 {
     $this->useTransactionalTimeLimit();
     $user = $this->getUser();
     $params = $this->extractRequestParams();
     $this->requireMaxOneParameter($params, 'namespace', 'rootpage');
     $isUpload = false;
     if (isset($params['interwikisource'])) {
         if (!$user->isAllowed('import')) {
             $this->dieUsageMsg('cantimport');
         }
         if (!isset($params['interwikipage'])) {
             $this->dieUsageMsg(array('missingparam', 'interwikipage'));
         }
         $source = ImportStreamSource::newFromInterwiki($params['interwikisource'], $params['interwikipage'], $params['fullhistory'], $params['templates']);
     } else {
         $isUpload = true;
         if (!$user->isAllowed('importupload')) {
             $this->dieUsageMsg('cantimport-upload');
         }
         $source = ImportStreamSource::newFromUpload('xml');
     }
     if (!$source->isOK()) {
         $this->dieStatus($source);
     }
     $importer = new WikiImporter($source->value, $this->getConfig());
     if (isset($params['namespace'])) {
         $importer->setTargetNamespace($params['namespace']);
     } elseif (isset($params['rootpage'])) {
         $statusRootPage = $importer->setTargetRootPage($params['rootpage']);
         if (!$statusRootPage->isGood()) {
             $this->dieStatus($statusRootPage);
         }
     }
     $reporter = new ApiImportReporter($importer, $isUpload, $params['interwikisource'], $params['summary']);
     try {
         $importer->doImport();
     } catch (Exception $e) {
         $this->dieUsageMsg(array('import-unknownerror', $e->getMessage()));
     }
     $resultData = $reporter->getData();
     $result = $this->getResult();
     ApiResult::setIndexedTagName($resultData, 'page');
     $result->addValue(null, $this->getModuleName(), $resultData);
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:45,代码来源:ApiImport.php

示例8: formatMessage

 /**
  * Format a message for output
  * @param array &$res Result array
  * @param string $key Result key
  * @param Message $message
  */
 private function formatMessage(array &$res, $key, Message $message)
 {
     switch ($this->messageFormat) {
         case 'none':
             break;
         case 'wikitext':
             $res[$key] = $message->setContext($this->module)->text();
             break;
         case 'html':
             $res[$key] = $message->setContext($this->module)->parseAsBlock();
             $res[$key] = Parser::stripOuterParagraph($res[$key]);
             break;
         case 'raw':
             $res[$key] = ['key' => $message->getKey(), 'params' => $message->getParams()];
             ApiResult::setIndexedTagName($res[$key]['params'], 'param');
             break;
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:24,代码来源:ApiAuthManagerHelper.php

示例9: execute

 public function execute()
 {
     $pUser = $this->getUser();
     // Deny if the user is blocked and doesn't have the full 'userrights' permission.
     // This matches what Special:UserRights does for the web UI.
     if ($pUser->isBlocked() && !$pUser->isAllowed('userrights')) {
         $this->dieBlocked($pUser->getBlock());
     }
     $params = $this->extractRequestParams();
     $user = $this->getUrUser($params);
     $form = $this->getUserRightsPage();
     $form->setContext($this->getContext());
     $r['user'] = $user->getName();
     $r['userid'] = $user->getId();
     list($r['added'], $r['removed']) = $form->doSaveUserGroups($user, (array) $params['add'], (array) $params['remove'], $params['reason']);
     $result = $this->getResult();
     ApiResult::setIndexedTagName($r['added'], 'group');
     ApiResult::setIndexedTagName($r['removed'], 'group');
     $result->addValue(null, $this->getModuleName(), $r);
 }
开发者ID:xiestar,项目名称:mediawiki,代码行数:20,代码来源:ApiUserrights.php

示例10: execute

 public function execute()
 {
     $conf = $this->getConfig();
     $params = $this->extractRequestParams();
     $props = array_flip($params['prop']);
     $repos = [];
     $repoGroup = $this->getInitialisedRepoGroup();
     $foreignTargets = $conf->get('ForeignUploadTargets');
     $repoGroup->forEachForeignRepo(function ($repo) use(&$repos, $props, $foreignTargets) {
         $repoProps = $repo->getInfo();
         $repoProps['canUpload'] = in_array($repoProps['name'], $foreignTargets);
         $repos[] = array_intersect_key($repoProps, $props);
     });
     $localInfo = $repoGroup->getLocalRepo()->getInfo();
     $localInfo['canUpload'] = $conf->get('EnableUploads');
     $repos[] = array_intersect_key($localInfo, $props);
     $result = $this->getResult();
     ApiResult::setIndexedTagName($repos, 'repo');
     ApiResult::setArrayTypeRecursive($repos, 'assoc');
     ApiResult::setArrayType($repos, 'array');
     $result->addValue(['query'], 'repos', $repos);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:22,代码来源:ApiQueryFileRepoInfo.php

示例11: processMetaData

 /**
  *
  * @param array $metadata
  * @param ApiResult $result
  * @return array
  */
 public static function processMetaData($metadata, $result)
 {
     $retval = array();
     if (is_array($metadata)) {
         foreach ($metadata as $key => $value) {
             $r = array('name' => $key);
             if (is_array($value)) {
                 $r['value'] = self::processMetaData($value, $result);
             } else {
                 $r['value'] = $value;
             }
             $retval[] = $r;
         }
     }
     ApiResult::setIndexedTagName($retval, 'metadata');
     return $retval;
 }
开发者ID:sukesan1984,项目名称:agrarian-wiki,代码行数:23,代码来源:ApiQueryImageInfo.php

示例12: execute

 public function execute()
 {
     $this->useTransactionalTimeLimit();
     $params = $this->extractRequestParams();
     $rotation = $params['rotation'];
     $continuationManager = new ApiContinuationManager($this, [], []);
     $this->setContinuationManager($continuationManager);
     $pageSet = $this->getPageSet();
     $pageSet->execute();
     $result = [];
     $result = $pageSet->getInvalidTitlesAndRevisions(['invalidTitles', 'special', 'missingIds', 'missingRevIds', 'interwikiTitles']);
     foreach ($pageSet->getTitles() as $title) {
         $r = [];
         $r['id'] = $title->getArticleID();
         ApiQueryBase::addTitleInfo($r, $title);
         if (!$title->exists()) {
             $r['missing'] = true;
             if ($title->isKnown()) {
                 $r['known'] = true;
             }
         }
         $file = wfFindFile($title, ['latest' => true]);
         if (!$file) {
             $r['result'] = 'Failure';
             $r['errormessage'] = 'File does not exist';
             $result[] = $r;
             continue;
         }
         $handler = $file->getHandler();
         if (!$handler || !$handler->canRotate()) {
             $r['result'] = 'Failure';
             $r['errormessage'] = 'File type cannot be rotated';
             $result[] = $r;
             continue;
         }
         // Check whether we're allowed to rotate this file
         $permError = $this->checkPermissions($this->getUser(), $file->getTitle());
         if ($permError !== null) {
             $r['result'] = 'Failure';
             $r['errormessage'] = $permError;
             $result[] = $r;
             continue;
         }
         $srcPath = $file->getLocalRefPath();
         if ($srcPath === false) {
             $r['result'] = 'Failure';
             $r['errormessage'] = 'Cannot get local file path';
             $result[] = $r;
             continue;
         }
         $ext = strtolower(pathinfo("{$srcPath}", PATHINFO_EXTENSION));
         $tmpFile = TempFSFile::factory('rotate_', $ext, wfTempDir());
         $dstPath = $tmpFile->getPath();
         $err = $handler->rotate($file, ['srcPath' => $srcPath, 'dstPath' => $dstPath, 'rotation' => $rotation]);
         if (!$err) {
             $comment = wfMessage('rotate-comment')->numParams($rotation)->inContentLanguage()->text();
             $status = $file->upload($dstPath, $comment, $comment, 0, false, false, $this->getUser());
             if ($status->isGood()) {
                 $r['result'] = 'Success';
             } else {
                 $r['result'] = 'Failure';
                 $r['errormessage'] = $this->getErrorFormatter()->arrayFromStatus($status);
             }
         } else {
             $r['result'] = 'Failure';
             $r['errormessage'] = $err->toText();
         }
         $result[] = $r;
     }
     $apiResult = $this->getResult();
     ApiResult::setIndexedTagName($result, 'page');
     $apiResult->addValue(null, $this->getModuleName(), $result);
     $this->setContinuationManager(null);
     $continuationManager->setContinuationIntoResult($apiResult);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:75,代码来源:ApiImageRotate.php

示例13: execute


//.........这里部分代码省略.........
             if (isset($this->prop['groups'])) {
                 $data[$name]['groups'] = $user->getEffectiveGroups();
             }
             if (isset($this->prop['implicitgroups'])) {
                 $data[$name]['implicitgroups'] = $user->getAutomaticGroups();
             }
             if (isset($this->prop['rights'])) {
                 $data[$name]['rights'] = $user->getRights();
             }
             if ($row->ipb_deleted) {
                 $data[$name]['hidden'] = true;
             }
             if (isset($this->prop['blockinfo']) && !is_null($row->ipb_by_text)) {
                 $data[$name]['blockid'] = (int) $row->ipb_id;
                 $data[$name]['blockedby'] = $row->ipb_by_text;
                 $data[$name]['blockedbyid'] = (int) $row->ipb_by;
                 $data[$name]['blockedtimestamp'] = wfTimestamp(TS_ISO_8601, $row->ipb_timestamp);
                 $data[$name]['blockreason'] = $row->ipb_reason;
                 $data[$name]['blockexpiry'] = $row->ipb_expiry;
             }
             if (isset($this->prop['emailable'])) {
                 $data[$name]['emailable'] = $user->canReceiveEmail();
             }
             if (isset($this->prop['gender'])) {
                 $gender = $user->getOption('gender');
                 if (strval($gender) === '') {
                     $gender = 'unknown';
                 }
                 $data[$name]['gender'] = $gender;
             }
             if (isset($this->prop['centralids'])) {
                 $data[$name] += ApiQueryUserInfo::getCentralUserInfo($this->getConfig(), $user, $params['attachedwiki']);
             }
             if (!is_null($params['token'])) {
                 $tokenFunctions = $this->getTokenFunctions();
                 foreach ($params['token'] as $t) {
                     $val = call_user_func($tokenFunctions[$t], $user);
                     if ($val === false) {
                         $this->setWarning("Action '{$t}' is not allowed for the current user");
                     } else {
                         $data[$name][$t . 'token'] = $val;
                     }
                 }
             }
         }
     }
     $context = $this->getContext();
     // Second pass: add result data to $retval
     foreach ($goodNames as $u) {
         if (!isset($data[$u])) {
             $data[$u] = ['name' => $u];
             $urPage = new UserrightsPage();
             $urPage->setContext($context);
             $iwUser = $urPage->fetchUser($u);
             if ($iwUser instanceof UserRightsProxy) {
                 $data[$u]['interwiki'] = true;
                 if (!is_null($params['token'])) {
                     $tokenFunctions = $this->getTokenFunctions();
                     foreach ($params['token'] as $t) {
                         $val = call_user_func($tokenFunctions[$t], $iwUser);
                         if ($val === false) {
                             $this->setWarning("Action '{$t}' is not allowed for the current user");
                         } else {
                             $data[$u][$t . 'token'] = $val;
                         }
                     }
                 }
             } else {
                 $data[$u]['missing'] = true;
                 if (isset($this->prop['cancreate'])) {
                     $status = MediaWiki\Auth\AuthManager::singleton()->canCreateAccount($u);
                     $data[$u]['cancreate'] = $status->isGood();
                     if (!$status->isGood()) {
                         $data[$u]['cancreateerror'] = $this->getErrorFormatter()->arrayFromStatus($status);
                     }
                 }
             }
         } else {
             if (isset($this->prop['groups']) && isset($data[$u]['groups'])) {
                 ApiResult::setArrayType($data[$u]['groups'], 'array');
                 ApiResult::setIndexedTagName($data[$u]['groups'], 'g');
             }
             if (isset($this->prop['implicitgroups']) && isset($data[$u]['implicitgroups'])) {
                 ApiResult::setArrayType($data[$u]['implicitgroups'], 'array');
                 ApiResult::setIndexedTagName($data[$u]['implicitgroups'], 'g');
             }
             if (isset($this->prop['rights']) && isset($data[$u]['rights'])) {
                 ApiResult::setArrayType($data[$u]['rights'], 'array');
                 ApiResult::setIndexedTagName($data[$u]['rights'], 'r');
             }
         }
         $fit = $result->addValue(['query', $this->getModuleName()], null, $data[$u]);
         if (!$fit) {
             $this->setContinueEnumParameter('users', implode('|', array_diff($users, $done)));
             break;
         }
         $done[] = $u;
     }
     $result->addIndexedTagName(['query', $this->getModuleName()], 'user');
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:101,代码来源:ApiQueryUsers.php

示例14: run


//.........这里部分代码省略.........
             $this->dieContinueUsageIf(strval($ar_id) !== $cont[3]);
             $this->addWhere("ar_namespace {$op} {$ns} OR " . "(ar_namespace = {$ns} AND " . "(ar_title {$op} {$title} OR " . "(ar_title = {$title} AND " . "(ar_timestamp {$op} {$ts} OR " . "(ar_timestamp = {$ts} AND " . "ar_id {$op}= {$ar_id})))))");
         } else {
             $this->dieContinueUsageIf(count($cont) != 2);
             $ts = $db->addQuotes($db->timestamp($cont[0]));
             $ar_id = (int) $cont[1];
             $this->dieContinueUsageIf(strval($ar_id) !== $cont[1]);
             $this->addWhere("ar_timestamp {$op} {$ts} OR " . "(ar_timestamp = {$ts} AND " . "ar_id {$op}= {$ar_id})");
         }
     }
     $this->addOption('LIMIT', $this->limit + 1);
     $sort = $dir == 'newer' ? '' : ' DESC';
     $orderby = [];
     if ($optimizeGenerateTitles) {
         // Targeting index name_title_timestamp
         if ($params['namespace'] === null || count(array_unique($params['namespace'])) > 1) {
             $orderby[] = "ar_namespace {$sort}";
         }
         $orderby[] = "ar_title {$sort}";
     } elseif ($mode == 'all') {
         // Targeting index name_title_timestamp
         if ($params['namespace'] === null || count(array_unique($params['namespace'])) > 1) {
             $orderby[] = "ar_namespace {$sort}";
         }
         $orderby[] = "ar_title {$sort}";
         $orderby[] = "ar_timestamp {$sort}";
         $orderby[] = "ar_id {$sort}";
     } else {
         // Targeting index usertext_timestamp
         // 'user' is always constant.
         $orderby[] = "ar_timestamp {$sort}";
         $orderby[] = "ar_id {$sort}";
     }
     $this->addOption('ORDER BY', $orderby);
     $res = $this->select(__METHOD__);
     $pageMap = [];
     // Maps ns&title to array index
     $count = 0;
     $nextIndex = 0;
     $generated = [];
     foreach ($res as $row) {
         if (++$count > $this->limit) {
             // We've had enough
             if ($optimizeGenerateTitles) {
                 $this->setContinueEnumParameter('continue', "{$row->ar_namespace}|{$row->ar_title}");
             } elseif ($mode == 'all') {
                 $this->setContinueEnumParameter('continue', "{$row->ar_namespace}|{$row->ar_title}|{$row->ar_timestamp}|{$row->ar_id}");
             } else {
                 $this->setContinueEnumParameter('continue', "{$row->ar_timestamp}|{$row->ar_id}");
             }
             break;
         }
         // Miser mode namespace check
         if ($miser_ns !== null && !in_array($row->ar_namespace, $miser_ns)) {
             continue;
         }
         if ($resultPageSet !== null) {
             if ($params['generatetitles']) {
                 $key = "{$row->ar_namespace}:{$row->ar_title}";
                 if (!isset($generated[$key])) {
                     $generated[$key] = Title::makeTitle($row->ar_namespace, $row->ar_title);
                 }
             } else {
                 $generated[] = $row->ar_rev_id;
             }
         } else {
             $revision = Revision::newFromArchiveRow($row);
             $rev = $this->extractRevisionInfo($revision, $row);
             if (!isset($pageMap[$row->ar_namespace][$row->ar_title])) {
                 $index = $nextIndex++;
                 $pageMap[$row->ar_namespace][$row->ar_title] = $index;
                 $title = $revision->getTitle();
                 $a = ['pageid' => $title->getArticleID(), 'revisions' => [$rev]];
                 ApiResult::setIndexedTagName($a['revisions'], 'rev');
                 ApiQueryBase::addTitleInfo($a, $title);
                 $fit = $result->addValue(['query', $this->getModuleName()], $index, $a);
             } else {
                 $index = $pageMap[$row->ar_namespace][$row->ar_title];
                 $fit = $result->addValue(['query', $this->getModuleName(), $index, 'revisions'], null, $rev);
             }
             if (!$fit) {
                 if ($mode == 'all') {
                     $this->setContinueEnumParameter('continue', "{$row->ar_namespace}|{$row->ar_title}|{$row->ar_timestamp}|{$row->ar_id}");
                 } else {
                     $this->setContinueEnumParameter('continue', "{$row->ar_timestamp}|{$row->ar_id}");
                 }
                 break;
             }
         }
     }
     if ($resultPageSet !== null) {
         if ($params['generatetitles']) {
             $resultPageSet->populateFromTitles($generated);
         } else {
             $resultPageSet->populateFromRevisionIDs($generated);
         }
     } else {
         $result->addIndexedTagName(['query', $this->getModuleName()], 'page');
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:101,代码来源:ApiQueryAllDeletedRevisions.php

示例15: arrayFromStatus

 public function arrayFromStatus(Status $status, $type = 'error', $format = null)
 {
     if ($status->isGood() || !$status->errors) {
         return [];
     }
     $result = [];
     foreach ($status->getErrorsByType($type) as $error) {
         if ($error['message'] instanceof Message) {
             $error = ['message' => $error['message']->getKey(), 'params' => $error['message']->getParams()] + $error;
         }
         ApiResult::setIndexedTagName($error['params'], 'param');
         $result[] = $error;
     }
     ApiResult::setIndexedTagName($result, $type);
     return $result;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:16,代码来源:ApiErrorFormatter.php


注:本文中的ApiResult::setIndexedTagName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。