Extension:Semantic Forms Select/ja
Semantic Forms Select リリースの状態: 安定 |
|
---|---|
実装 | ユーザー インターフェイス, Ajax |
説明 | Allows to generate a selectable form element inside forms from semantic queries |
作者 | Jason Zhang, James Hong Kong, Toni Hermoso Pulido |
メンテナー | gesinn.it and others |
最新バージョン | 4.0.0-beta (2022-04-28) |
MediaWiki | 1.35+ |
PHP | 7.3+ |
データベースの変更 | いいえ |
Composer | mediawiki/semantic-forms-select |
ライセンス | GNU 一般公衆利用許諾書 2.0 以降 |
ダウンロード | |
例 | sandbox.semantic-mediawiki.org |
Compatibility
|
|
Quarterly downloads | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Public wikis using | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Semantic Forms Select 拡張機能の翻訳にご協力ください |
The Semantic Forms Select extension generates a select form element which option values are from semantic query or parser function. Page Forms (originally Semantic Forms) provides useful input type for select elements such as dropdown, combobox, and listbox. Their option values can be derived from a static list, pages in a category, concept, property's allowed values, etc. However, it is still limited.
This extension provides these features
- The option values for select element is from an SMW query or parser function.
- If the SMW query or parser function is not parametrized, its optioned values are loaded at form generation time.
- If the SMW query or parser function is parametrized, in another word, its values depend on another form field. Its values are loaded through ajax call when trigger field changes.
使用法
Two form fields are involved. The first one is the form field we are trying to define. It is termed as Select field. The second one is the field the Select field depends on. It is termed as Value field. A change of Value field will trigger the loading of Select field.
Query And Function parameters
The input type from this extension is SF_Select. Field parameters are shown in the table below.
Name | Required | Description | Note |
---|---|---|---|
query=x | <translate> Yes</translate> | Semantic Query | Either query or function must be present. More information. |
function=x | <translate> Yes</translate> | Parser Function | Either query or function must be present. 詳細情報。 |
template=x | <translate> No</translate> | The template the Value field in | Use either template or sametemplate |
sametemplate | <translate> No</translate> | The Value field is in the same template as the Select field | Use either template or sametemplate |
field=x | <translate> No</translate> | the Value field name | Value field has to be pure text field or html select field. Fields with Autocomplete feature are not supported |
rmdiv | <translate> No</translate> | remove current instance when Select field's value is not valid anymore | 詳細情報。 |
list | <translate> No</translate> | As it is defined in Page Forms | |
size=x | <translate> No</translate> | As it is defined in Page Forms | |
label | <translate> No</translate> | Query properties shown in queries as labels and page names as values | EXPERIMENTAL. Check example 3 below. |
mandatory | <translate> No</translate> | Whether input is mandatory. |
Query And Function format
{{{field|AllProtocols|input type=SF_Select|query=((Category:Protocol));format~list;sep~,;link~none;headers~hide;limit~500}}}
In the above example, the query is [[Category:Protocol]]|format=list|sep=,|link=none|headers=hide|limit=5000. To avoid parsing and text transform, we have to convert [ to (, = to ~ and | to ; in the query.
{{{field|AllProtocols1|input type=SF_Select|function=ask:((Category:Protocol));format~list;sep~,;link~none;headers~hide;limit~500}}}
Parser function follows the same rule. The parser function is ask in example above. We can of course use other valid parser function. To fit a parser function into field definition, Strip the {{# and }} at the beginning and the end of normal parser function format.
The result from query or parser function should be a list of string separated by comma.
例
Example 1: Static query
Values are retrieved when the form is loaded.
{{{field|AllProtocols|input type=SF_Select|query=((Category:Protocol));format~list;sep~,;link~none;headers~hide;limit~500}}}
Example 2: Static function
Values are retrieved when the form is loaded.
{{{field|Users|input type=SF_Select|function=getallusers}}}
Here the getallusers is a custom parser function which gives all users in current installation.
Example 3: Parametrized query/function
{{{field|P2Protocols3|input type=SF_Select|query=((Category:Protocol))((Protocol Belongs to Project::@@@@));format~list;sep~,;link~none;headers~hide;limit~ 200|sametemplate|field=Project1}}}
The parameter is the special character string @@@@. In this example, the Select field is P2Protocols3. The Value field is Project1. Both Select field and Value field are in the same template since we have sametemplate in field definition. If Value field is from another template, the template parameter should be used. When Project1 field changes, the @@@@ will be replaced by the value of Project1's value. The query is then sent to server through ajax call. The results will be the option values for P2Protocols3 field. If the current template is multiple, the P2Protocols3 only depends on the Project1 in the same instance.
{{{field|P2Protocols3|input type=SF_Select|query=((Category:Protocol))((Protocol Belongs to Project::@@@@));?Has Name;format~list;sep~,;link~none;headers~hide;limit~ 200|sametemplate|field=Project1|label}}}
In this case above, when adding a property to be shown (Has Name) and an extra label
parameter, the property value is shown instead of the resulting page name.
Parser functions can be parametrized in the same way.
{{{field|UserInGroup|input type=SF_Select|function=getallusersInGroup:@@@@|sametemplate|field=Group}}}
In this example, we list all users in the selected group of Group field.
In case the queried results contain a comma (,) as a separator one has to choose another separator like e.g. an asterisk (*). Use it both in the query and in the parser function.
{{{field|Protocol1|input type=SF_Select|query=((Category:Protocol))((Protocol Belongs to Project::@@@@));format~list;sep~*;link~none;headers~hide;limit~200|sametemplate|field=Project1|sep=*}}}
Example 4: rmdiv
{{{for template|StudyProtocolMultiple3|label=Demonstrate External Dependency multiple, rmove|multiple}}} {| !Depends on Protocols 5 on Study template |{{{field|Endpoint|input type=SF_Select|list|size=2|query=((Is a Protocol Endpoint::@@@@));mainlabel~-;?Endpoint Name;format~list;sep~,;headers~hide;limit~5 0|list|size=5|template=Study|field=P2Protocols4|rmdiv}}} |} {{{end template}}}
In this example, the Endpoint field depends on P2Protocols4 field in study template. The current template is also a multiple template. Endpoint's value is reloaded after P2Protocols4 changes. After reloading, Endpoint may not have any selected values and it is left in an invalid state. In this case, we may want to automatically remove the current instance. This is what rmdir parameter is for.
インストール
File:OOjs UI icon lightbulb-yellow.svg <translate> Note:</translate> The extensions Semantic MediaWiki and Page Forms are required and should be included before this extension in order to work.
- To install this extension
- Use composer :
php composer.phar require mediawiki/semantic-forms-select "~4.0"
- Add the following line to your "LocalSettings.php" file after invoking the extensions Semantic MediaWiki and Page Forms:
wfLoadExtension( 'SemanticFormsSelect' );
- Done!
謝辞
This project was sponsored by BioTeam and flexdms.
For support, please send email to the user mailing list of Semantic MediaWiki.
File:OOjs UI icon information-progressive.svg | <translate> This extension is included in the following wiki farms/hosts and/or packages:</translate>
<translate> This is not an authoritative list.</translate> <translate> Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here.</translate> <translate> Always check with your wiki farms/hosts or bundle to confirm.</translate> |
- Pages with script errors
- Pages with broken file links
- Stable extensions/ja
- User interface extensions/ja
- Ajax extensions/ja
- Extensions with manual MediaWiki version
- Extensions supporting Composer/ja
- GPL licensed extensions/ja
- Extensions in GitHub version control/ja
- All extensions/ja
- Extensions not in ExtensionJson
- Semantic MediaWiki extensions/ja