Jump to content

Extensões - Perguntas Mais Frequentes

From mediawiki.org
This page is a translated version of the page Extensions FAQ and the translation is 41% complete.
Extensões do MediaWiki

Onde é que eu posso encontrar uma lista de extensões instaladas?

The Special:Version page on each wiki contains a list of extensions that have registered themselves with the MediaWiki software. Todas as extensões podem ser instaladas sem aparecer em Special:Version, se o programador não incluir o código correto para listá-lo lá.

Como é que eu ativo uma extensão?

For most extensions, copy the extension PHP file (or directory) to your extensions/ folder and add the following statement to your LocalSettings.php , with ExtensionName being the filename of your extension, such as MyExtension.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. O equivalente para a extensão acima seria:

wfLoadExtension('ExtensionName');

Algumas extensões, no entanto, possuem etapas adicionais e/ou procedimentos de instalação diferentes. Some extensions will contain a text-file named README (sometimes INSTALL) that will have more detailed information about that extension.

Consulte também: Manual:Extensions#Installing an extension

Como é que eu escrevo a minha própria extensão?

Consulte Manual:Desenvolver Extensões .

Como é que eu desativo a colocação em cache para as páginas que utilizam a minha extensão?

Se estiver a escrever, por exemplo, página especial:

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

Para hooks de etiqueta do analisador:

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.

Como é que eu renderizo texto wiki na minha extensão?

Páginas especiais

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.

Hooks de Analisador

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?

Extensões e Modelos

See Manual:Tag extensions#Extensions and Templates

"NaodW..." ou "UNIQ..."

Your extension (or another one installed) might be using parse() function instead of recursiveTagParse(). Then change it to recursiveTagParse.


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.

Como é que eu faço para que minha extensão apareça em 'Especial:Versão'?

See Manual:Developing extensions#Registering features with MediaWiki