扩展:无目录
Appearance
此扩展存储其源代码在某個可編輯的wiki页面上、而不是在代码存储库之內。 此結果造成,此代码有可能被恶意修改。 它可能存在安全性漏洞,且不會收到來自translatewiki.net的本地化更新。 強烈建議開發者將程式碼存放於程式碼儲存庫,而非維基頁面,如此方能妥善維護、審查擴充功能並確保其安全性。 |
此扩展目前不再積極维护! 尽管它可能仍然工作,但任何错误报告或功能请求将很可能被忽略。 |
发行状态: 不再維護 |
|
|---|---|
| 实现 | 解析器扩展 |
| 描述 | 默认情况下,在所有页面上关闭目录。 |
| 作者 | Andrew Fitzgerald (Frantik留言) |
| 最新版本 | 0.1.1 (2013-12-11) |
| MediaWiki | |
| 数据库更改 | 否 |
| 许可协议 | GNU通用公眾授權條款2.0或更新版本 |
| 下載 | 请查阅代码部分 |
NoTOC扩展默认将目录隐藏。 魔术字__TOC__仍然可以正常使用。
安裝
- 将代码复制到文件中文件,并将其放置在您
extensions/文件夹中的NoTOC目录内。 - 請新增下列代码到您的LocalSettings.php文件的底部:
require_once "$IP/extensions/NoTOC/NoTOC.php";
完成 – 請导航至您的wiki上的Special:Version,以验证此扩展已成功安装。
代码
- NoTOC.php
<?php
/**
* NoTOC extension - Turns off the Table of Contents (TOC) by default on all pages
* @version 0.1.1 - 2013/12/11
*
* @link https://www.mediawiki.org/wiki/Extension:NoTOC Documentation
* @link https://www.mediawiki.org/wiki/Extension_talk:NoTOC Support
*
* @ingroup Extensions
* @package MediaWiki
* @author Andrew Fitzgerald (Frantik)
* @author Karsten Hoffmeyer (Kghbln)
* @copyright (C) 2010 Andrew Fitzgerald
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
*/
// check the call
if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This file is a MediaWiki extension and thus not a valid entry point.' );
}
// provide information
$wgExtensionCredits['parserhook'][] = array(
'path' => __FILE__,
'name' => 'NoTOC',
'author' => array(
'Andrew Fitzgerald', '...'
),
'url' => 'https://www.mediawiki.org/wiki/Extension:NoTOC',
'descriptionmsg' => 'notoc-desc',
'version' => '0.1.1'
);
// show way to files
$wgExtensionMessagesFiles['NoTOC'] = dirname( __FILE__ ) . '/NoTOC.i18n.php';
// register hooks
$wgHooks['ParserClearState'][] = 'efMWNoTOC';
// perform purpose
function efMWNoTOC($parser) {
$parser->mShowToc = false;
return true;
}
- NoTOC.i18n.php
<?php
/**
* Internationalization file for the NoTOC extension.
*
* @licence GNU GPL v2+
* @author Karsten Hoffmeyer (Kghbln)
*/
$messages = array();
/** English
* @author Frantik
* @author Kghbln
*/
$messages['en'] = array(
'notoc-desc' => 'Turns off the Table of Contents (TOC) by default on all pages',
);
/** Message documentation (Message documentation)
* @author Kghbln
*/
$messages['qqq'] = array(
'notoc-desc' => '{{desc|name=NoTOC|url=https://www.mediawiki.org/wiki/Extension:NoTOC}}',
);
/** German (Deutsch)
* @author Kghbln
*/
$messages['de'] = array(
'notoc-desc' => 'Unterdrückt die automatische Generierung des Inhaltsverzeichnisses',
);
参阅
- 扩展:ForceTocOnEveryPage
- Extension:DeToc - This can be used to extract TOC HTML and to remove it or put it in some other section of the page.
