Bücher online kostenlos Kostenlos Online Lesen
Working With MediaWiki

Working With MediaWiki

Titel: Working With MediaWiki Kostenlos Bücher Online Lesen
Autoren: Yaron Koren
Vom Netzwerk:
instead, you can add one or more ’Has alternate form’ special properties to the property page, so that the user gets other possibilities when they click on the red link. This is useful when a single property can point to pages that use different forms.
    Note also that, if you’ve defined a  namespace  as having a default form, red-links that go to a page within that namespace will also go to the right form, without any extra work needed.
    By default, Semantic Forms checks, for every red link, for the existence of properties across the wiki pointing to that page in order to find default forms. However, for pages with a large number of red links, this can slow down page loading. If that’s an issue for you, you can change the behavior so that SF only checks properties on the page in question, instead of throughout the whole wiki. To do that, add the following to LocalSettings.php, after the inclusion of Semantic Forms:
$sfgRedLinksCheckOnlyLocalProps = true;

Populating red-linked pages automatically
    It’s nice to have red links point to the right form for creating the page, but this still calls for work on the part of users — they have to click to the form, fill out the fields and save the page. This is especially bothersome when the form contains few or no fields, and/or if there are many such pages to be created. You can instead have such red-linked pages get automatically created by the system.
    To do this, instead of using "Has default form" (or "Has alternate form"), you should add the special property "Creates pages with form" to the property that you want pointing to those automatically-created pages. For instance, if you have pages that point with the property "Has country" to other pages, and you want those other pages to automatically be created using a form called "Country", you just need to add the following to the page at "Property:Has country":
[[Creates pages with form::Country]]
    It should be noted that it may take a while for each page to be created, since page creation is done through MediaWiki "jobs", which can take anywhere from a few seconds to several hours or more to run, depending on the length of the job queue.
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:
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 ’
preload= preload-page-name
’ 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 "
template-name [ field-name ]= field-value
" 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 "&": "
template1[field1]
=
val1&template1[field2]
=
val2
".
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. The function registered with this hook should have a header like:
function-name(&$page_contents, $page_title, $form_title)

Creating query forms
    Forms can also be used for querying, as opposed to adding or editing data. In other words, you can create a form that will not modify any pages, but will instead be used for searching existing data — in which a user enters values in different fields and then sees some set of pages that match those fields.
    To have query forms, you need to use the Special:RunQuery page, which displays a form in a manner similar to Special:FormEdit, but with no associated target page. Instead, when the user submits the form by hitting the "Run query" button, the user stays on the Special:RunQuery page, but now the page shows what the template looks like when displayed with the values they entered. The template that the form uses should most likely contain one or more Semantic MediaWiki inline queries, to query data using

Weitere Kostenlose Bücher