Manual:Special pages/pt-br

Páginas especiais são páginas que são criadas pelo software sob demanda para executar uma função específica. Por exemplo, uma página especial pode mostrar todas as páginas que têm um ou mais links para um site externo ou pode criar um formulário que fornece feedback enviado pelo usuário. Páginas especiais estão localizadas na sua própria Special:MyLanguage/Manual:Namespace (Especial:) e não são editáveis diretamente como outras páginas. também pode criar novas páginas especiais. Essas páginas podem ser acessíveis ao usuário e geralmente aparecerão na lista de todas as páginas especiais em Special:SpecialPages. Algumas páginas especiais só são acessíveis aos usuários com determinadas permissões e acessos. Outras páginas especiais não aparecem na lista de páginas especiais e são usadas apenas pelo wiki internamente.

Informações Gerais
As páginas especiais integradas que vêm com o MediaWiki são chamadas de  e estão localizadas na diretoria. Páginas especiais centrais são registradas na lista central localizada em  em ordem de carregamento pelo Mediawiki. Páginas especiais são criadas por desenvolvedores terceiros são geralmente armazenadas no diretório  (extensões) na raiz do seu servidor com seus arquivos para seu devido funcionamento. Todas as páginas especiais herdam a classe de página especial e são declaradas na página de Páginas Especiais. Quando uma nova página especial é criadas, os direitos do usuário são necessários para que esta seja definida. Esses direitos específicos, entre outras coisas, se a página será mostrada em Special:SpecialPages (Páginas Especiais) e se a página será incluída em outras páginas.

As páginas especiais devem possuir nomes únicos que possam ser customizados na Wiki. De forma geral o "Especial:Nome da Página", onde "Especial" e "Nome da Página" podem ser customizavéis. O pseudo-manual especial podem ser traduzido para outras línguas. This translated namespace can be produced with the wikitext    , on this wiki giving "    ". O nome da página especial também pode ser redefinido em uma mensagem do sistema, para o idioma do site, com o nome genérico da página especial como o ID.

A special page may or may not allow input. For example, Special:Export allows a user to define a specific page to export by calling Special:Export/Sun. If the special page allows complex input, additional parameters will be sent to the query string component of the URL for processing, e.g. https://www.mediawiki.org/w/index.php?title=Special:Recentchanges&days=3&limit=250.

Modelo básico de página especial
Most special page extensions require three files:


 * Small setup file, which loads every time MediaWiki starts.
 * File with the bulk of the code.
 * Localisation file

MediaWiki coding conventions define the three files like this:


 * - The setup file.
 * - The special page code.
 * - The.

Place all of the files in a new directory inside your MediaWiki  directory.

You should name the special page file after the extension. For example, the Gadgets extension contains the file. If your extension uses more than one special page, you'll need more names.

In the example below, the special page's name is MyExtension.

After creating the files listed below, adding the following line to LocalSettings.php enables the extension:

The setup file
Example setup file for :

This file registers several important and mandatory things:


 * The location of the MediaWiki\Extension\MyExtension\Special class;
 * The location of the localisation files;
 * The new special page and its class name.

The special page file
The body file should contain a subclass of   or one of its subclasses. This file loads automatically when someone requests the special page. The example below implements the subclass SpecialMyExtension.

You need the  constructor because its first parameter names your special page.

is the main function called when a special page is accessed. This function overrides the function. It passes the single parameter, the subpage component of the current title. For example, if someone follows a link to Special:MyExtension/blah,  contains "blah".

You should run Wikitext and HTML output through. Do not use 'print' or 'echo' directly when working within the wiki's user interface.

However, if you use your special page as an access point to custom XML or binary output, see.

The localisation file

 *  See for how to get them translated. 

All special pages specify a title, like.


 * The title is used in the  and  elements of the extension's page and on Special:SpecialPages.
 * It can be anything, but should describe the special page and extension.
 * It's specified through a message. The structure of the message is a key-value pair. The key,, must be all lowercase.

An example of a localisation file in :

In, the message documentation:

Note that IDs should not start with an uppercase letter, and that a space in the ID should be written in the code as an underscore.

The -summary message is optional. It's created automatically by the parent class and shown on top of the special page, usually for a concise description of what the user can do on it. If you don't define its content, it will only be used when wiki administrators customize it on the wiki.

The aliases file
You can also internationalize the name of the special page by creating aliases for it. The example below uses the file "MyExtension.i18n.alias.php". In this example, the special page  registers an alias so the page becomes accessible at   and   in German.

Add your alias file to :

Add special page aliases to :

Again, you should write a space in the ID and an underscore in the code.

Para o cabeçalho da página e links, as regras usuais para nomes de página se aplicam.

If  is true, a lowercase letter is converted to uppercase, and an underscore is displayed as a space.

For example, instead of the above, we could use, assuming we consistently identified the extension as   elsewhere.

Note that in the associative array for the English language, the string identifying our SpecialPage ( in the example) is also a valid title.

Also note, the first element of  must be the same as the key ! Otherwise Special:Specialpages will not list the page.

Special page group
You can set which group your special page appears under on Special:SpecialPages by overriding  in your subclass.

system interface message, which translates to 'Media reports and uploads' in English; *     * @return string */   function getGroupName { return 'media'; }

Some common values are 'login', 'maintenance', 'media', 'other', 'pagetools', 'redirects', 'users'. You can see the accepted values at Special:AllMessages (search for specialpages-group) or browse the wiki using the pseudo language 'qqx' by going to Special:SpecialPages?uselang=qqx ) and looking at the headings.  Specify the word 'media' to use the interface message 'specialpages-group-media'.

If your special page doesn't fit into any of the preconfigured headings, you can add a new heading by adding it to your localisation file, see The localisation file).

The standard page groups that come with MediaWiki are listed in the localisation file. For example, the English messages are in  and begin with. If you want to categorize your special page under, then the message is. The value for this key is the text that appears as the name of that category, for example,.

If your special page does not seem to fit under any of the existing categories, you can always make a new one. In your extension's localisation file simply insert a new key for the  array. In this example, we define the  group:

Now, assuming you set the return value for the method  as   in your class definition, reload Special:SpecialPages to see your new category.

Construtor
You can overload the constructor to initialize your own data, but the main reason you would want to do it is to change the behavior of the SpecialPage class itself. When you call the base class constructor from your child class, the following parameters are available:


 * string  Nome da página especial, conforme visto em links e URLs
 * string  User right required, e.g. "block" or "delete"; also see Restricting page access
 * boolean  Whether the page is listed in Special:Specialpages

This initialises the OutputPage object  with the name and description of your special page. It should always be called from your execute method.

This method returns an OutputPage object which can be accessed as described below. As in the example code, use

instead of the deprecated  global variable

This method returns a WebRequest object which can be accessed as described below. As in the example code, use

instead of the deprecated global variable

Some special pages can be included from within another page. For example, if you add to the wikitext of a page, it will insert a listing of recent changes within the existing content of the page.

Including a special page from another web page is only possible if you declared the page to be includable in the constructor. You can do this by adding the following in the  method after the parent class initialization:

You can also define your special page class as extending the IncludableSpecialPage class.

The SpecialPage->including function returns a boolean value telling you what context the special page is being called from: false if it is a separate web page, and true if it is being included from within another web page. Usually you will want to strip down the presentation somewhat if the page is being included.

This is the function which your child class should overload. It passes a single parameter, usually referred to cryptically as  (short for $parameter, as it is the parameter the users can feed to your special page). This parameter is the subpage component of the current title. For example, if someone follows a link to Special:MyExtension/blah,  will contain "blah".

Página de ajuda
It's useful to add help pages on MediaWiki.org, where they'll be translatable. To make sure users find your help page, it's advisable and very simple for your special page to link the help page in question:

OutputPage.php
OutputPage.php contains the class definition for objects of type. You can get an object of this class from your SpecialPage using

The variablename $output is, of course, arbitrary. Whatever you call it, this is the variable you will use the most, because it is the way to send output to the browser (no, you don't use  or  ). If you want to use it somewhere, declare the variable global:

If you want to, you can create multiple OutputPage objects in different methods in your SpecialPage extension. They will add to the output in the order they are executed.

You can inspect the OutputPage class by viewing  (indeed, all of these can be inspected), but there are a few methods you should definitely know about.

Essentially the quick and dirty substitute for. It takes your input and adds it to the buffer: no questions asked. In the below action, if  contains user-data, it could easily have XSS, evil stuff, or the spawn of Satan injected in. You're better off using escaping (such as with the php function htmlentities) or the XML builders class to build trusted output.

For most output, you should be using this function. It's a bit of a black magic function: wikitext goes in, HTML comes out, and a whole lotta arcane code and demon summonings happen in between.

What's worth noting is that the parser will view your chunks as cohesive wholes and paragraph accordingly. That is...

Will output three lists with one item each, which probably wasn't intended.

Note however, if you just want to insert a system message and have it treated like parsed wikitext, you can use code like. This will not have the issue with nested parser calls mentioned above.

workaround #1
Important: these work arounds are only needed if you are making a transcludable special page. Normal special pages do not need these.

As a workaround, you can have your extensions convert Wikitext to HTML using a separate Parser object and then use. Exemplo:

alternativa #2
Tentei o procedimento acima e descobri que o mesmo problema agora se aplicava a quaisquer marcas no texto transcluído. Isso não será um problema para muitas extensões, mas a extensão que eu estava escrevendo tinha a intenção de mostrar o wikitexto de outra página como parte de sua funcionalidade, então isso era um problema.

O processo de análise de uma página que transclui uma página especial parece ser este:


 * 1) Replace  with a UNIQ-QINU marker (because SpecialPage output is expected to be ready-to-output HTML)
 * 2) Replace any tags with QINU markers as above
 * 3) Parse everything else from wikitext to HTML
 * 4) Replace all QINU markers with their respective stored values, in a single pass

The process for parsing a page which transcludes a non-special page, though, is apparently like this:


 * 1) Replace  or  with contents of transcluded page (because transcluded pages contain unparsed wikitext)
 * 2) Replace any tags with QINU markers as above
 * 3) Parse everything else from wikitext to HTML
 * 4) Replace all QINU markers with their respective stored values, in a single pass

The problem is apparently that in the earlier case, the parsing of the SpecialPage's wiki text is lacking the final QINU decoding step (why?), so all the QINU markers are left undecoded. (This may be a leftover from using the same syntax to invoke transclusion of a wikitext page, which is just pasted straight into the host page's wikitext contents and parsed, as is used to invoke transclusion of a SpecialPage, which must not be parsed at all. Wherever the code is that decides "wait, this is a special page -- replace it with a QINU", it should be doing the extra unstripGeneral before doing the QINU substitution.)

So I just did the following -- after this line: ...I added these lines (the second one is only because the function definition for the first one recommends it): Since I have now documented this, of course, I will now find a tragic flaw with it and feel really stupid... but as long as it seems to be working, I had to note it here. (It is also important to note the problem with work-around #1.) Also, I have only tested this with MediaWiki 1.10.1. O problema ainda existe em MW 1.14, mas esta solução pode ou não funcionar. -- 18:26, 9 de abril de 2009 (UTC)

Uma página de erro é mostrada. The arguments  and   specify keys into $this->msg, not text. Um exemplo:


 * 'error' refere-se ao texto "Erro".
 * 'badarticleerror' refere-se ao texto "Esta ação não pode ser realizada nesta página."

Você também pode especificar mensagens ou adicionar parâmetros:

WebRequest.php
The class is used to obtain information from the GET and POST arrays. Using this is recommended over directly accessing the superglobals. The WebRequest object is accessible from extensions by using the.

Database.php
MediaWiki has a load of convenience functions and wrappers for interacting with the database, using the class. It also has an interesting load balancing scheme in place. It's recommended you use these wrappers. Check out  for a complete listing of all the convenience functions, because these docs will only tell you about the non-obvious caveats. See.

User.php
The class is used to represent users on the system. SpecialPage->getUser should be used to obtain a User object for the currently logged in user. The use of the global  is deprecated

Title.php
Title represents the name of a page in the wiki. This is useful because MediaWiki does all sorts of fun escaping and special case logic to page names, so instead of rolling your own convert title to URL function, you create a Title object with your page name, and then use  to get a URL to that page.

To get a title object for your special page from outside of the special page class, you can use. It will give you a localised title in the wiki's language.

Páginas especiais personalizadas
Existem várias maneiras de fornecer suas próprias páginas especiais não agrupadas no MediaWiki:


 * One method is to install an extension that generates a form to create or edit an article. A list of extensions currently available, can be found at.
 * You can also write an extension which provides your own special page. Writing your own extension requires PHP coding skill and comfort with object oriented design and databases also is helpful.  You will also need to know how to use code to create and edit MediaWiki articles. For more information, please see this discussion.
 * You can also display a custom page through JavaScript, in place of the default error message "Unknown special page" (or the "This page is intentionally left blank." message, if using a subpage of Special:BlankPage). In MediaWiki:Common.js, check for, then hide the MediaWiki-generated content (just appendCSS  ), and inject custom HTML  into the   or  . For an example, see meta:User:Krinkle/Tools/Real-Time Recent Changes.

Definir um título para extensão
O MediaWiki não define o título da extensão, que é trabalho do desenvolvedor. Ele irá procurar pelo nome da extensão quando Special:Specialpages for chamado ou a página especial for carregada. In the function execute( $par ) section, use OutputPage methods to title the extension like:

The place where the extension can be found (as specified by what is passed into the SpecialPage constructor) is the key--except that it is not capitalized because of, the internally used function that finds out the title (or, what they call description) of the special page,   the name. "ThisIsACoolSpecialPage"'s key would be "thisisacoolspecialpage."

Theoretically,  can be overloaded in order to avoid interacting with the message cache but, as the source code states: "Derived classes can override this, but usually it is easier to keep the default behavior.  Furthermore, this prevents the MediaWiki namespace from overloading the message, as below.

Localizing the Extension Name
So you've just installed a shiny new MediaWiki extension and realize: "Oh no, my wiki is in French, but the page is showing up as English!" Most people wouldn't care, but it's actually a quite simple task to fix (as long as the developer used the method explained on this page). No noodling around in source code. Let's say the name of the page is  and the name comes out to "List of Dirty Pages" but you want it to be (and excuse my poor French) "Liste de Pages Sales". Well, it's as simple as this:


 * 1) Navigate to MediaWiki:DirtyPages, this page may not exist, but edit it anyway
 * 2) Insert "Liste de Pages Sales" and save

And voilà (pardon the pun), the change is applied.

This is also useful for customizing the title for your wiki within your language: for instance, the developer called it "List of Dirty Pages" but you don't like that name, so you rename it "List of Pages needing Cleanup". Check out Special:Allmessages to learn more.

Also, if your extension has a large block of text that does change, like a warning, don't directly output the text. Instead, add it to the message cache and when the time comes to output the text in your code, do this:

Then this message too can be customized at MediaWiki:Dirtypageshelp.

See also Help:System message.

Do not display your Special Page on Special:SpecialPages
Sometimes you may want to limit the visibility of your Special Page by removing it from Special:SpecialPages and making it visible to only those users with a particular right. You can do this in the constructor by passing in a  parameter; e.g., “editinterface”, a right only assigned to sysops by default; see the User rights manual for other available user rights.

Or you can create your own right in the setup file and assign it to sysops, e.g.:

and then call the constructor with your right:

Prevent access to your Special Page
Even if you restrict your page in the constructor, as mentioned above, it will still be viewable directly via the URL, e.g. at Special:MySpecialPage. In order to actually limit access to your SpecialPage you must call  in the   method.

If you need more fine-grained control over permissions, you can override, and/or add whatever permissions-checking is required for your extension.

Disabling Special:UserLogin and Special:UserLogout pages
In LocalSettings.php you can use the to unset unwanted built-in special pages. See "making a few SpecialPages restricted" if you need conditional unsetting of special pages for example for certain user groups. The general message "You have requested an invalid special page." is shown if users try to access such unset special pages.

A different approach would be to use the DisabledSpecialPage callback. This approach may be preferred if you're only disabling the special page "temporarily", because the default message in this case would say: "" instead of pretending the page does not exist at all. This gives clear hint that the page maybe activated at a later time.

It is also possible to add custom lengthy explanation of why you're disabling the special page, by giving a message key as the second argument of the callback. To do so first create a system message "MediaWiki:Userlogout-disable-reason" and write all the explanation there. The message will be parsed in a block format. Then in LocalSettings.php add:

Adicionando logs
No MediaWiki, todas as ações dos usuários são rastreadas para transparência e colaboração. Veja para saber como fazer.

Changing the groups on Special:Specialpages
If you're an extension developer, you have to implement the  method as described in the Special page group section of this page.

Since MediaWiki 1.21, the special page group can be overridden by editing a system message. Este método não se destina a ser usado por desenvolvedores de extensões, mas por administradores de sites. The group name must be placed in the  message, where   is the canonical name (in english) of the special page in lowercase. For example, if you want to set the group under which "Special:MyLittlePage" is displayed on Special:Specialpages to "MyLittleGroup", you just have to create "MediaWiki:Specialpages-specialpagegroup-mylittlepage" with content "MyLittleGroup". "Special:MyLittlePage" will then show up under the group "MyLittleGroup", which you can name under "MediaWiki:Specialpages-group-mylittlegroup".

Se você quiser mudar o grupo de páginas especiais existentes, dê uma olhada em Special:SpecialPages&uselang=qqx e use esses nomes ao invés de "mylittlepage".

Ver também

 * HTMLForm – Tutorial on creating checkboxes, text areas, radio buttons, etc. in special pages