FAQ Estensioni

From mediawiki.org
This page is a translated version of the page Extensions FAQ and the translation is 35% complete.
Estensioni di MediaWiki

Dove posso trovare la lista delle estensioni installate?

La pagina Special:Version di ogni wiki contiene una lista delle estensioni che si sono registrate con il software MediaWiki . È possibile che una estensione sia installata ma non compaia in Special:Version perché lo sviluppatore non ha inserito il codice corretto per inserirla nella lista.

Come abilito un'estensione?

Per la maggior parte delle estensioni, è sufficiente copiare il file PHP (o la directory) nella cartella extensions/ ed aggiungere questa istruzione a LocalSettings.php , dove ExtensionName è il nome del file dell'estensione, come ad esempio MyExtension.php.

require_once "extensions/ExtensionName/ExtensionName.php";

A partire dal 1.25 (2015), per le estensioni che supportano extension registration, è disponibile un nuovo metodo di installazione. L'equivalente per l'estensione di cui sopra sarebbe:

wfLoadExtension('ExtensionName');

Alcune estensioni, tuttavia, hanno ulteriori fasi e/o procedure di installazione diverse. Alcune estensioni contengono un file di testo denominato README (a volte INSTALL) che avrà informazioni più dettagliate su tale estensione.

See also: Manuale:Estenzioni#Installazione di un'estensione

Come posso scrivere una nuova estensione?

Vedi Manuale:Sviluppo estensioni .

Come disabilito il caching delle pagine che usano la mia estensione?

Se stai scrivendo, ad esempio, la pagina speciale:

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

Per i tag hook del parser:

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

In case your extension output is only dependent on some option or user context and not time, you can still let it get cached by the parser cache but make sure it's marked as one output variant (of many possible). 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.

How do I render wikitext in my extension?

Special pages

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.

Parser hooks

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

How do I enable searching in my extension's output (dynamic content)?

You can't. Dynamic content can not be included in a static index.

How can I avoid modification of my extension's HTML output?

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

How can I pass XML-style parameters in my extension tag?

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

Extensions and Templates

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).

How can I determine in my extension, if an article is protected or not?

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

function extensionFunction() {
   # Assume $title is the title object
   if( $title->isProtected( 'edit' ) ) {
      # Protected from editing, do things
   } else {
      # Not protected from editing
   }
}

What permissions do I apply to the extensions folder?

All the scripts in the /wiki structure need to be readable and executable by the user that PHP runs as. 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