拡張機能のよくある質問

From mediawiki.org
This page is a translated version of the page Extensions FAQ and the translation is 57% complete.
MediaWiki 拡張機能

インストールされている拡張機能のリストはどこにありますか?

MediaWiki ソフトウェアに登録された拡張機能のリストは、それぞれのwikiの Special:Version ページで確認できます。 もし拡張機能の開発者が適切なコードを設定しなかった場合、全ての拡張機能は Special:Version ページにリストすることなくインストールされる可能性があります。

拡張機能を有効にするには?

ほとんどの拡張機能では、拡張機能の PHP ファイル (またはディレクトリ) を extensions/ フォルダにコピーし、MyExtension.php のようなファイル名や拡張機能名として ExtensionName を含む次の行を LocalSettings.php に追加します。

require_once "extensions/ExtensionName/ExtensionName.php";

Since 1.25 (2015), there is a new way of installing extensions, which works with extensions that support extension registration. The equivalent for the extension above would be:

wfLoadExtension('ExtensionName');

ただし、一部の拡張機能には、追加の手順や異なるインストール手順があります。 Some extensions will contain a text-file named README (sometimes INSTALL) that will have more detailed information about that extension.

関連項目: Manual:Extensions#Installing an extension

独自の拡張機能を書くには?

独自の拡張機能を使用してページのキャッシュを無効にするには?

あなたが書いている場合、例えば特別ページ:

global $wgOut;
$wgOut->enableClientCache(false);

パーサー タグ フックの場合:

function wfSomeHookFunction( $parser, $foo, $bar ) {
    $parser->getOutput()->updateCacheExpiry(0);
    ...
}

拡張機能の出力が時間ではなく特定のオプションまたはユーザーコンテキストのみに依存している場合でも、パーサーキャッシュによってキャッシュされるようにすることができますが、(多くの可能性のある)1つの出力バリアントとしてマークされていることを確認してください。 Use the PageRenderingHash hook to influence the cache hash accordingly.

In older versions of MediaWiki, you would use $parser->disableCache() to disable caching, but this was deprecated in MW 1.28 and removed altogether in MW 1.35.

独自の拡張機能でウィキテキストをレンダリングするには?

特別ページ

When rendering output that will not be subject to parser cache, such as on a special page

global $wgOut;
$wgOut->parse( $text );

where $text is the wikitext to be parsed.

パーサー フック

See Manual:Tag extensions#How do I render wikitext in my extension?

独自の拡張機能の出力 (動的なコンテンツ) で検索を有効にするには?

できません。動的なコンテンツを静的なインデックスに含めることはできません。

独自の拡張機能の HTML 出力の改変を回避するには?

See Manual:Tag extensions#How can I avoid modification of my extension's HTML output?

XML スタイルのパラメーターを独自の拡張機能に渡すには?

See Manual:Tag extensions#How can I pass XML-style parameters in my extension tag?

拡張機能とテンプレート

See Manual:Tag extensions#Extensions and Templates

"NaodW..." or "UNIQ..."

Your extension (or another one installed) might be using parse() function instead of recursiveTagParse(). Then change it to recursiveTagParse (using the parser given in parameter or $wgParser).

記事が保護されているかどうかを独自の拡張機能で判定するには?

Use the Title class and the isProtected( ) method, e.g.

function extensionFunction() {
   # $title が title オブジェクトであることを想定します
   if( $title->isProtected( 'edit' ) ) {
      # 編集保護されている場合の処理
   } else {
      # 編集保護されていない
   }
}

拡張機能フォルダーに適用するパーミッションは?

/wiki 配下のすべてのスクリプトは、PHP を実行するユーザーが読めて、実行可能である必要があります。 All perms are usually 755 and owner/group being a different user. The LocalSettings.php file is created by the script on setup and so will be an example to set the rest by.

How do I get my extension to show up on Special:Version?

See Manual:Developing extensions#Registering features with MediaWiki