本文整理汇总了PHP中ApiBase::getResult方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiBase::getResult方法的具体用法?PHP ApiBase::getResult怎么用?PHP ApiBase::getResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiBase
的用法示例。
在下文中一共展示了ApiBase::getResult方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}