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


PHP ApiBase类代码示例

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


在下文中一共展示了ApiBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;未经允许,请勿转载。