本文整理汇总了PHP中ApiMain::Modules方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiMain::Modules方法的具体用法?PHP ApiMain::Modules怎么用?PHP ApiMain::Modules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiMain
的用法示例。
在下文中一共展示了ApiMain::Modules方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructs an instance of ApiMain that utilizes the module and format specified by $request.
*
* @param $request object - if this is an instance of FauxRequest, errors are thrown and no printing occurs
* @param $enableWrite bool should be set to true if the api may modify data
*/
public function __construct($request, $enableWrite = false)
{
$this->mInternalMode = $request instanceof FauxRequest;
// Special handling for the main module: $parent === $this
parent::__construct($this, $this->mInternalMode ? 'main_int' : 'main');
if (!$this->mInternalMode) {
// Impose module restrictions.
// If the current user cannot read,
// Remove all modules other than login
global $wgUser;
if (!$wgUser->isAllowed('read')) {
self::$Modules = array('login' => self::$Modules['login'], 'help' => self::$Modules['help']);
}
}
$this->mModules = self::$Modules;
$this->mModuleNames = array_keys($this->mModules);
// todo: optimize
$this->mFormats = self::$Formats;
$this->mFormatNames = array_keys($this->mFormats);
// todo: optimize
$this->mResult = new ApiResult($this);
$this->mShowVersions = false;
$this->mEnableWrite = $enableWrite;
$this->mRequest =& $request;
$this->mSquidMaxage = 0;
}
示例2: __construct
/**
* Constructs an instance of ApiMain that utilizes the module and format specified by $request.
*
* @param $request object - if this is an instance of FauxRequest, errors are thrown and no printing occurs
* @param $enableWrite bool should be set to true if the api may modify data
*/
public function __construct($request, $enableWrite = false)
{
$this->mInternalMode = $request instanceof FauxRequest;
// Special handling for the main module: $parent === $this
parent::__construct($this, $this->mInternalMode ? 'main_int' : 'main');
if (!$this->mInternalMode) {
// Impose module restrictions.
// If the current user cannot read,
// Remove all modules other than login
global $wgUser;
if ($request->getVal('callback') !== null) {
// JSON callback allows cross-site reads.
// For safety, strip user credentials.
wfDebug("API: stripping user credentials for JSON callback\n");
$wgUser = new User();
}
if (!$wgUser->isAllowed('read')) {
self::$Modules = array('login' => self::$Modules['login'], 'logout' => self::$Modules['logout'], 'help' => self::$Modules['help']);
}
}
global $wgAPIModules, $wgEnableWriteAPI;
// extension modules
$this->mModules = $wgAPIModules + self::$Modules;
if ($wgEnableWriteAPI) {
$this->mModules += self::$WriteModules;
}
$this->mModuleNames = array_keys($this->mModules);
// todo: optimize
$this->mFormats = self::$Formats;
$this->mFormatNames = array_keys($this->mFormats);
// todo: optimize
$this->mResult = new ApiResult($this);
$this->mShowVersions = false;
$this->mEnableWrite = $enableWrite;
$this->mRequest =& $request;
$this->mSquidMaxage = 0;
}