本文整理汇总了PHP中Linker::generateTOC方法的典型用法代码示例。如果您正苦于以下问题:PHP Linker::generateTOC方法的具体用法?PHP Linker::generateTOC怎么用?PHP Linker::generateTOC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Linker
的用法示例。
在下文中一共展示了Linker::generateTOC方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHelp
/**
* Generate help for the specified modules
*
* Help is placed into the OutputPage object returned by
* $context->getOutput().
*
* Recognized options include:
* - headerlevel: (int) Header tag level
* - nolead: (bool) Skip the inclusion of api-help-lead
* - noheader: (bool) Skip the inclusion of the top-level section headers
* - submodules: (bool) Include help for submodules of the current module
* - recursivesubmodules: (bool) Include help for submodules recursively
* - helptitle: (string) Title to link for additional modules' help. Should contain $1.
* - toc: (bool) Include a table of contents
*
* @param IContextSource $context
* @param ApiBase[]|ApiBase $modules
* @param array $options Formatting options (described above)
* @return string
*/
public static function getHelp(IContextSource $context, $modules, array $options)
{
global $wgContLang;
if (!is_array($modules)) {
$modules = array($modules);
}
$out = $context->getOutput();
$out->addModuleStyles('mediawiki.hlist');
$out->addModuleStyles('mediawiki.apihelp');
if (!empty($options['toc'])) {
$out->addModules('mediawiki.toc');
}
$out->setPageTitle($context->msg('api-help-title'));
$cache = ObjectCache::getMainWANInstance();
$cacheKey = null;
if (count($modules) == 1 && $modules[0] instanceof ApiMain && $options['recursivesubmodules'] && $context->getLanguage() === $wgContLang) {
$cacheHelpTimeout = $context->getConfig()->get('APICacheHelpTimeout');
if ($cacheHelpTimeout > 0) {
// Get help text from cache if present
$cacheKey = wfMemcKey('apihelp', $modules[0]->getModulePath(), (int) (!empty($options['toc'])), str_replace(' ', '_', SpecialVersion::getVersion('nodb')));
$cached = $cache->get($cacheKey);
if ($cached) {
$out->addHTML($cached);
return;
}
}
}
if ($out->getHTML() !== '') {
// Don't save to cache, there's someone else's content in the page
// already
$cacheKey = null;
}
$options['recursivesubmodules'] = !empty($options['recursivesubmodules']);
$options['submodules'] = $options['recursivesubmodules'] || !empty($options['submodules']);
// Prepend lead
if (empty($options['nolead'])) {
$msg = $context->msg('api-help-lead');
if (!$msg->isDisabled()) {
$out->addHTML($msg->parseAsBlock());
}
}
$haveModules = array();
$html = self::getHelpInternal($context, $modules, $options, $haveModules);
if (!empty($options['toc']) && $haveModules) {
$out->addHTML(Linker::generateTOC($haveModules, $context->getLanguage()));
}
$out->addHTML($html);
$helptitle = isset($options['helptitle']) ? $options['helptitle'] : null;
$html = self::fixHelpLinks($out->getHTML(), $helptitle, $haveModules);
$out->clearHTML();
$out->addHTML($html);
if ($cacheKey !== null) {
$cache->set($cacheKey, $out->getHTML(), $cacheHelpTimeout);
}
}
示例2: generateTOC
public function generateTOC($tree, $lang = false)
{
return Linker::generateTOC($tree, $lang);
}