Extension:Page Forms/Linking to forms/tr

Kullanıcıları formlara nasıl yönlendirirsiniz? Standart yol, kullanıcıların bir sayfanın adını girmesi için tek bir girdi görüntüleyen  ayrıştırıcı işlev çağrısı yoluyladır; böyle bir ad girerler ve düğmeyi tıklarlarsa, o sayfayı oluşturmak için bir forma gönderilirler. Bu adda bir sayfa zaten mevcut değilse, bu durumda mevcut sayfayı düzenlemek için bir forma gönderilirler. Bu, "iki aşamalı süreç" olarak bilinen şeydir. İlk adımın, yani kullanıcının ilk olarak sayfa adını girmesinin nedeni, kullanıcıların yanlışlıkla mevcut sayfaların üzerine yazmamasını sağlamaktır. Bu işlem o kadar standarttır ki, Page Forms'un "Special:CreateForm" ve "Special:CreateClass" yardımcı sayfaları tarafından üretilen varsayılan formlarda yerleşiktir: Page Forms tarafından oluşturulan herhangi bir form tanımlama sayfası, en üstte, böylece bu form sayfasına giden kullanıcılar otomatik olarak formu kullanmaya başlayabilir.

Bununla birlikte, kullanıcıların sayfa adını girmenin ilk adımını atlaması da mümkündür. Form, kullanıcı girdisine dayalı olarak sayfa başlığını ayarlamak için bir formül içeriyorsa yapmanız gereken budur. Bu "tek adımlı süreçtir" ve  yerine   ayrıştırıcı işlevini kullanır.

Special:RunQuery kullanan sorgu formları,  ayrıştırıcı işlevini kullanan kendi bağlama yöntemlerine sahiptir.



İki aşamalı süreç
İki aşamalı süreç, yani kullanıcıları formlara ulaştırmanın standart yolu,  ayrıştırıcı işlevi kullanılarak yapılır.



#forminput kullanma

 * 1) forminput ayrıştırıcı işlevinin sözdizimi şöyledir:



Tüm bağımsız değişkenler isteğe bağlıdır. Parametrelerin açıklaması:

Adding pages of a specific namespace
You can have a page-input form create pages within a specific namespace (like 'User:') by default, without forcing users to type in that namespace every time. To do that, add "" to the "query string=" parameter.

An example call to  would be:



(Note that, if you want to use SMW on a custom namespace, you need to add the namespace to $smwgNamespacesWithSemanticLinks.)

Adding sub-pages
In MediaWiki, you can create subpages by including a slash in the page name. To have the page that's added automatically be a subpage, you can add a value for "super_page=" in the query string. To make it a subpage of the current page, you can set this value to "super_page=". This will prepend a "" at the beginning of the page name that the user types in.

The one-step process
You can have the name of the page created by the form be set automatically, by adding a  parameter within the form definition's  tag. There are two types of "variables" one can include in the value for this parameter:


 * - gets replaced with the value for the specified field field-name in the specified template template-name. Note: this will not work when the  tag is declared as.
 * - by default, gets replaced by the lowest number for which the page title that's generated is unique. Normally, this value starts out as blank, then goes to 2, then 3, etc. However, one can manually set the starting number for this value, by adding a  parameter; this number must be 0 or higher. For instance, to have the number start at 1 and go upward, you should set the tag to be " ". You can also instead set it to be a random six-digit number, by adding the "random" parameter, so that the tag looks like " ". You can also set the number of digits to be something other than 6, by adding a number after "random", like " ". Note that the parameters in all these cases are delimited by semicolons.
 * Note that the  value cannot contain the character , because MediaWiki does not allow that character in page titles.

See here for an example of a form that uses a page name formula.

As another example, imagine a form for storing notable quotes. Its  tag could have a parameter of "page name=&lt;Quote[Author name]> quote &lt;unique number;start=1>". This would include the author's name in the name of every quote page, as well as a number to guarantee the uniqueness of every opinion-item page added. A user could then go to the URL  and fill out the form; if they set the author to be , and no other quotes in the wiki had him as an author, then hitting the "Save page" button would result in a new page called.

The  value can have leading zeroes; a value of , for instance, would lead to pages that had the value  , then  , etc.

The  value gets parsed by the MediaWiki parser, so you can also add parser functions, pre-defined variables, etc. into the value. Bu otomatik sayfa ayarının çalışması için kullanıcıların " " sayfasına gönderilmesi gerektiğini unutmayın; eğer bir şekilde bir  çağrısıyla sonuçlanırsa ve bir sayfa adı istenirse, bu ad otomatik sayfa adı ne olursa olsun geçersiz kılar.



#formlink kullanma
İsterseniz, URL'yi doğrudan oluşturmak yerine  ayrıştırıcı işlevini kullanarak bu bağlantıyı oluşturabilirsiniz. Bu işlev şu şekilde adlandırılır:



An explanation of the parameters:

An example call to  would be:



This will link from the page, via a button, to a form for adding a quote, with the "Author" field filled in with the current page name. If there are multiple values, they should be separated by "&".



Note that if any part of your query string — such as a page name or anything else — contains characters such as apostrophes, ampersands , or plus signs , you will need to URL-encode that value. For that, you can use the  function from the ParserFunctions extension. The example above, for instance, would need to change to:.

You may want to have the link to the form be an image, instead of text or a button. For that, you could call something like:



Linking to query forms
You can link to query forms, i.e. forms run within the page Special:RunQuery, by using the  parser function. This is called in the same way as, except that there's no "target" parameter. For a more complete explanation, see.



Kırmızı bağlantıları bir forma işaret etme
MediaWiki'de, var olmayan sayfalara giden bağlantılar, genellikle kırmızı renkte oldukları için 'kırmızı bağlantılar' olarak adlandırılır. Varsayılan olarak, bu bağlantılar, standart düzenleme arayüzünü kullanarak maddeyi vikiye eklemek için bir sayfaya gider. Ancak, bunun yerine, doğru form önceden biliniyorsa, o sayfayı oluşturmak için doğrudan bir forma bağlanmak için kırmızı bağlantılar ayarlayabilirsiniz; ve ek olarak, diğer tüm kırmızı bağlantıların, kullanıcının viki formlarından (varsa) hangisini kullanacağını seçmesine olanak tanıyan bir yardımcı sayfaya işaret etmesini sağlayabilirsiniz.



#formredlink kullanma
Belirli bir bağlantının (kendi başına veya bir şablon içinde) işaret ettiği sayfa yoksa, bir forma işaret etmesini sağlamak için #formredlink ayrıştırıcı işlevini kullanın. Tipik bir #formredlink çağrısı bir şablonun içine girecek ve şöyle görünecektir: A typical call to  will go inside a template, and will look like:

The overall syntax of  is:



These parameters are very similar to those of  (see above). It has two additional parameters:


 * "existing page link text=" - sets the text of the link when the target page being pointed to exists already (the " " parameter takes effect only when the target does not exist).
 * "create page" - causes red-linked pages to get automatically created by the system. It should be noted that it may take a while for each page to be created, since page creation is done through MediaWiki "", which can take anywhere from a few seconds to several hours or more to run, depending on the length of the job queue. Pages created with this method will be associated with user ID 1 (the first user created on the wiki), unless you set   to another username.

There may be times when you are not sure which form a linked-to page will use; it could be one of a number of choices. You can set it so that the user gets other possibilities when they click on the red link, by adding one or more "alt_form" query string parameters to the #formredlink call, each with its own number.

As an example, see this page. Both the author and the source are red-linked, but the links take you to forms for adding these two pages (please do not actually fill out and submit these forms, because that would ruin the example). When you get to the forms for each page, you can see, at the top, that there are alternative forms that you can select for adding each page. That is enabled by the following two calls to #formredlink in the template where those links are defined:

For the source:

For the author:

In the example page, the "source" call creates a link to. Note that no main/default form is specified; only alternate forms.

The "author" call is more complex because that field can hold a list of values. is used to put in a call to  for each individual value; as well as to store each individual value using an SMW property.

Note that the internal "variable" used for this  call is "xx", not "x" - "x" could have been used here too, but if the   call had used its "link text=" or "existing link text=" parameters, those would have failed, because they contain the letter "x"; "xx" is safer here.

Form-associated namespaces
If you've, red-links that go to a page within that namespace will also go to the right 'add data' form, without any extra work needed.

Pointing red links to a "form chooser"
For red links not defined by  and not pointing to a form-associated namespace, you can have every such link point to a helper page, that lets the user choose which of the wiki's forms to use to create this page - or to use no form at all. You can enable this functionality simply by adding the following to LocalSettings.php, below the inclusion of PF:

You can see an example of this interface by clicking on the red link here (please do not create this page).

Preloading data
You may want a form to already contain some data when the user goes to it. ( Note that this only applies to adding new data, or to query forms; for editing an existing page, there is no way to set the contents of the form to anything other than the current contents of that page. ) There are various ways to do this:

The function registered with this hook should have a header like.
 * Specify a "default" value for whatever fields you want to have a value for in the form.
 * Specify a "preload" page for the "free text" input, which will preload the free text field with the contents of that page.
 * Add to the query string value in the 'forminput' call; this will preload the entire form with the contents of that page.
 * Similarly, you can add a "preload=..." value to the query string for a 'FormStart' or 'FormEdit' URL.
 * Add to the query string value in the 'forminput' call, to set the value for a specific field. To preload values for more than one field use "&":
 * To preload values for multiple-instance templates, add the instance number after the template name. So you could have something like for two instances.
 * Similarly, you can add a value for a specific field to the URL query string for 'FormStart' or 'FormEdit'.
 * Finally, you can create your own custom handling, using the 'sfEditFormPreloadText' hook. If another extension calls this hook, it can preload data however it wants.

Passing in a "context"
A call to #forminput or #formlink can include arbitrary query string parameters, which the form can then use to modify aspects like the display, autocomplete values, etc. This can be done with the UrlGetParameter extension, which provides a parser function, #urlget, that can read the query string parameter(s) in question.

For example, let's say there is a form called "Document" that contains a field, "Owner", which you want to have autocomplete with different names depending on the company department for which the form is being called. A call to  or   for that form could then contain the parameter. If you are using the Cargo extension, the tag for that field in the form could then look like:

If you are using this approach, it is probably best not to have an "Edit with form" tab for pages created with this form; instead, each page should display (via its template) a set of  calls to edit the page, one for each possible value (in this case, each department).



Using #autoedit
ayrıştırıcı işlevini kullanarak, tıklandığında, önceden yüklenmiş değerler kümesiyle arka planda otomatik olarak sayfalar oluşturan veya düzenleyen bağlantılar oluşturabilirsiniz. Bu işlev,  ile çok benzer bir şekilde çağrılır ve görüntülenir. Aradaki fark, bağlantının kullanıcıyı bir forma getirmek yerine yalnızca arka planda bir eylem gerçekleştirmesidir. için sözdizimi şöyledir:



All these parameters work in the same way as they do in, with four exceptions:


 * - if added to the call, marks any edit made with this link as a minor edit.
 * - if added to the call, reloads the current page after the link is clicked.
 * - if added to the call, pops up a confirmation window for the user before doing the actual edit.
 * Like with,   sets the type of display and can be set to "link" or "button" ("post button" is not an option). However, for  , a missing value for "link type" is the same as setting the value to "link"; while for  , the two are different. In  , a missing value for "link type" will display the text as text, without a link, while setting " " will display it as a link.

Example
As an example, let's say you want to create a simple voting scheme, letting users vote between "Vanilla", "Chocolate" and "Strawberry". You have a page for each, and each one contains a template called "Flavor", with a field called "Num votes" - that field, in turn, sets a Cargo field called "Num_votes". And there is also a form, also called "Flavor", to edit such pages. To create a link that, when clicked, increments the number of votes in the "Vanilla" page by one, you could place the following call on the page:



Modifying a list of values
You can add, or remove, a value from a list of values, for fields that hold a list of values (such as fields editable with the  or   input types). To add a value to such a list, instead of having a call like in the query string, use a call like. And to remove a value, use a call like.

Unfortunately, this functionality currently only works for fields whose delimiter is a comma.

If, when adding a value to a list, that value was already there; or when removing a value, that value was not there, this call will have no effect.

Modifying multiple-instance templates
You can use  to modify existing, or create new, instances of a multiple-instance template. To do that, instead of putting in the query string something like, put in something like , where instance number is an integer that's 0 or higher. If the instance number corresponds to an instance that is already on the page, the existing template instance will be modified; if it's higher than that, a new instance will be created, with that value for that field.

For additional namespaces
By default, autoedit functionality is only available for any of the so-called 'content namespaces', which by default is just the main namespace. However, this can be changed by modifying the global variable $wgPageFormsAutoeditNamespaces in LocalSettings.php. For instance, to let autoedit also apply to pages in the "User:" namespace, you should add the following line:

Using #autoedit_rating
Another parser function that works similarly to #autoedit is  - although, instead of displaying a link or button, it displays a rating-style row of stars; and the number of stars the user selects is what is sent to populate or update the target page. A listing of the allowed parameters for :


 * - the form to be used
 * - the target page to be modified
 * - the field to be modified in the target page; its name should follow the syntax
 * - the number of stars to show (default is 5)
 * - if added to the call, allows the user to select half-star values
 * - the width of each star, in pixels (default is 24)
 * - the edit summary for any such edit
 * - if added to the call, marks any edit made with this link as a minor edit.
 * - if added to the call, pops up a confirmation window for the user before doing the actual edit.

API
Autoedit functionality is also available via the MediaWiki API, as the  action - this enables outside scripts, and bots, to easily modify template calls within wiki pages. You can read the full documentation on this here.