<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://www.verzauberte-welten.de/index.php?action=history&amp;feed=atom&amp;title=Modul%3ASmwUtil%2Fdoc</id>
	<title>Modul:SmwUtil/doc - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://www.verzauberte-welten.de/index.php?action=history&amp;feed=atom&amp;title=Modul%3ASmwUtil%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://www.verzauberte-welten.de/index.php?title=Modul:SmwUtil/doc&amp;action=history"/>
	<updated>2026-04-06T02:15:11Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Verzauberte Welten e.V.</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://www.verzauberte-welten.de/index.php?title=Modul:SmwUtil/doc&amp;diff=4431&amp;oldid=prev</id>
		<title>imported&gt;Oetterer am 13. Februar 2017 um 08:28 Uhr</title>
		<link rel="alternate" type="text/html" href="https://www.verzauberte-welten.de/index.php?title=Modul:SmwUtil/doc&amp;diff=4431&amp;oldid=prev"/>
		<updated>2017-02-13T08:28:34Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{documentation subpage}}&lt;br /&gt;
{{module rating|protected}}&lt;br /&gt;
&amp;lt;!-- Categories go at the bottom of this page and interwikis go in Wikidata. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This module provides serveral useful function that can be used in other module to store or retrive data using semantic annotations.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
{{code|lang=lua|code=&lt;br /&gt;
local _SMW= require('Module:SmwUtil')&lt;br /&gt;
if dataStore == 'smw' and stash then&lt;br /&gt;
	_SMW.set(stash)&lt;br /&gt;
end&lt;br /&gt;
local query = {&lt;br /&gt;
	select = {'[[is public::yes]]', '[[is of type::datasheet]]', '[[has id::&amp;gt;&amp;gt;10]]'}&lt;br /&gt;
	fields = {'_CDAT=Create date', 'bears name=nickname', 'works as=occupation', 'has siblings'}&lt;br /&gt;
}&lt;br /&gt;
local attributes = {&lt;br /&gt;
	limit = 10,&lt;br /&gt;
	mainlabel ='-'&lt;br /&gt;
}&lt;br /&gt;
local result = _SMW.ask(query, attributes)&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
Provided functions are as follow:&lt;br /&gt;
&lt;br /&gt;
=== ask(query, attributes, retainBlanks) ===&lt;br /&gt;
Runs an ask query on the semantic mediawiki triple store according to the parameters provided and returns the result as a lua table. The first parameter (query) has the following fields:&lt;br /&gt;
;select&lt;br /&gt;
:table or string, mandatory&lt;br /&gt;
:the condition the query filters for. can be of string and arbitrarily complex or a table being either of format {{code snippet|lang=lua|code={ propertyname = 'value' } }}, {{code snippet|lang=lua|code={ '[[propertyname::value]]' } }} or a mix of both&lt;br /&gt;
;fields&lt;br /&gt;
:table or string, optional&lt;br /&gt;
:the fields, you want to get data from. format of values is ''fieldname'' or ''fieldname=headline'' (you can skip the preceeding ?). DO NOT USE AN ARRAY! All keys will be discarded! Please uses string only if you have just one field to display. If you want to format the fields and add a headline, please do it before the =, e.g. ''fieldname#km2=area''&lt;br /&gt;
Please keep in mind:&lt;br /&gt;
* attributes may contain any attribute you find in the documentation, but ''intro'' and ''outro'' will be NILed, ''default'' and ''more results text'' will be set to the empty string, and ''format'' will be overwritten&lt;br /&gt;
* per default, does only return fields that contain a value. that can result in an &amp;quot;unbalanced&amp;quot; result, where one row contains more elements than others. if you want to get all fields, set &amp;lt;code&amp;gt;retainBlanks&amp;lt;/code&amp;gt; to true&lt;br /&gt;
&lt;br /&gt;
;query&lt;br /&gt;
:table, mandatory&lt;br /&gt;
:the arguments to construct the query. see above for details&lt;br /&gt;
;attributes&lt;br /&gt;
:table, optional&lt;br /&gt;
:more attributes, you want to pass on to the ask query (like limit, for instance)&lt;br /&gt;
;retainBlanks&lt;br /&gt;
:boolean, optional&lt;br /&gt;
:if set to true, result can contain entries with empty values. per default, these entries will be deleted&lt;br /&gt;
;return&lt;br /&gt;
:table, query result as a lua table. see the following printout as example&lt;br /&gt;
&lt;br /&gt;
{{ombox|type=delete|text=In contrast to [[Module:CargoUtil]], SmwUtil's ''ask'' recognizes when a property holds a list of values and returns this as a lua table (see example below on property ''references''). CargoUtils would treat this as a comma separated list.}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- cut&lt;br /&gt;
1:&lt;br /&gt;
		2 = '7'&lt;br /&gt;
		3 = { '901', '821' }&lt;br /&gt;
		4 = 'Cargo provides a lightweight way to store and query the data contained within the calls to templates, such as infoboxes in mysql tables.'&lt;br /&gt;
2:&lt;br /&gt;
		2 = '6'&lt;br /&gt;
		3 = '911'&lt;br /&gt;
		4 = 'The SyntaxHighlight GeSHi extension provides rich formatting of source code using the &amp;quot;syntaxhighlight&amp;quot;-tag. ...'&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{code|lang=lua|code=&lt;br /&gt;
{&lt;br /&gt;
	1 = {&lt;br /&gt;
		1 = 'Extension:Cargo'&lt;br /&gt;
		has id = '7'&lt;br /&gt;
		references = { '901', '821' }&lt;br /&gt;
		description = 'Cargo provides a lightweight way to store and query the data contained within the calls to templates, such as infoboxes in mysql tables.'&lt;br /&gt;
		MainLabel = 'Extension:Cargo'&lt;br /&gt;
	}&lt;br /&gt;
	2 = {&lt;br /&gt;
		1 = 'Extension:SyntaxHighlight GeSHi'&lt;br /&gt;
		has id = '6'&lt;br /&gt;
		references = '911'&lt;br /&gt;
		description = 'The SyntaxHighlight GeSHi extension provides rich formatting of source code using the &amp;quot;syntaxhighlight&amp;quot;-tag. ...'&lt;br /&gt;
		MainLabel = 'Extension:SyntaxHighlight GeSHi'&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
As you can see, the data fields can be indexed either by number or by the provided headline in table ''fields''. (The headline is either the fieldname or a special string you provided via ''fieldname=headline''. The mainlabel always has number 1 and whatever you passed on to attribute ''mainlabel'' (if nothing, default is MainLabel).&lt;br /&gt;
&lt;br /&gt;
=== get(page, field) ===&lt;br /&gt;
A shortcut for [[#show(page, field)|show(page, field)]].&lt;br /&gt;
&lt;br /&gt;
=== lua(query, attributes, retainBlanks) ===&lt;br /&gt;
A shortcut for [[#ask(query, attributes, retainBlanks)|ask(query, attributes, retainBlanks)]].&lt;br /&gt;
&lt;br /&gt;
=== rawask(query, attributes) ===&lt;br /&gt;
Calls the parser function #ask according to the provided parameters and passes the result on directly. The format of the output is depending on attributes.format. The first parameter (query) has the following mandatory fields:&lt;br /&gt;
;select&lt;br /&gt;
:table or string, mandatory&lt;br /&gt;
:the condition the query filters for. can be of string and arbitrarily complex or a table being either of format {{code snippet|lang=lua|code={ propertyname : 'value' } }}, {{code snippet|lang=lua|code={ '[[propertyname::value]]' } }} or a mix of both&lt;br /&gt;
;fields&lt;br /&gt;
:table or string, optional&lt;br /&gt;
:the fields, you want to get data from. format is ''fieldname'' or ''fieldname=headline'' (you can skip the preceeding ?). Please uses string only if you have just one field to display. If you want to format the fields and add a headline, please do it before the =, e.g. ''fieldname#km2=area''&lt;br /&gt;
Please keep in mind:&lt;br /&gt;
* attributes may contain any attribute you find in the documentation, but ''intro'' and ''outro'' will be NILed, ''default'' and ''more results text'' will be set to the empty string, and ''format'' will be overwritten&lt;br /&gt;
* per default, does only return fields that contain a value. that can result in an &amp;quot;unbalanced&amp;quot; result, where one row contains more elements than others. if you want to get all fields, set &amp;lt;code&amp;gt;retainBlanks&amp;lt;/code&amp;gt; to true&lt;br /&gt;
&lt;br /&gt;
;query&lt;br /&gt;
:table, mandatory&lt;br /&gt;
:the arguments to construct the query. see above for details&lt;br /&gt;
;attributes&lt;br /&gt;
:table, optional&lt;br /&gt;
:more attributes, you want to pass on to the ask query (like limit, for instance)&lt;br /&gt;
;return&lt;br /&gt;
:string, the renderd output&lt;br /&gt;
&lt;br /&gt;
=== set(stash) ===&lt;br /&gt;
Stores provided ''stash'' in semantic triple stores.&lt;br /&gt;
&lt;br /&gt;
;stash&lt;br /&gt;
:string or table, mandatory&lt;br /&gt;
:data to store. if provided as string {{code snippet|lang=lua|code='has property=value' }}, one triple can be stores. if provided as table, you can either use {{code snippet|lang=lua|code={ has property = 'value' } }}, {{code snippet|lang=lua|code={ 'has propert=value' } }}, or a mix thereof. Even {{code snippet|lang=lua|code={ has property = {'value1', 'value2', 'value3' } }} is possible.&lt;br /&gt;
;return&lt;br /&gt;
:string, hopefully empty, result of set parser function&lt;br /&gt;
&lt;br /&gt;
=== show(page, field) ===&lt;br /&gt;
Returns contents of ''field'' stored on ''page''&lt;br /&gt;
;page&lt;br /&gt;
:string, mandatory&lt;br /&gt;
:name of page, to get the property contents from (please include namespace but explude brackets), e.g. 'Meta:Mail'&lt;br /&gt;
;field&lt;br /&gt;
:string, mandatory&lt;br /&gt;
:name of property, to get the contents from. You can skip the '?'&lt;br /&gt;
;return&lt;br /&gt;
:string, contents of property 'field' on ''page''&lt;br /&gt;
&lt;br /&gt;
=== subobject(stash, uid) ===&lt;br /&gt;
Stores provided ''stash'' as a subject. Contrary to [[#set(stash)|set(stash)]] the data is not stored directly on the page but in a separate entity called ''subobject''. These objects can be queried for separately.&lt;br /&gt;
&lt;br /&gt;
;stash&lt;br /&gt;
:string or table, mandatory&lt;br /&gt;
:data to store. if provided as string {{code snippet|lang=lua|code='has property=value' }}, one triple can be stores. if provided as table, you can either use {{code snippet|lang=lua|code={ has property = 'value' } }}, {{code snippet|lang=lua|code={ 'has propert=value' } }}, or a mix thereof. Even {{code snippet|lang=lua|code={ has property = {'value1', 'value2', 'value3' } }} is possible.&lt;br /&gt;
;uid&lt;br /&gt;
:string, optional&lt;br /&gt;
:You can supply a uid to identify the object by. Just make sure, it is unique. :)&lt;br /&gt;
;return&lt;br /&gt;
:string, hopefully empty, result of set parser function&lt;br /&gt;
&lt;br /&gt;
[[Category:Class engine]]&amp;lt;includeonly&amp;gt;{{#ifeq:{{SUBPAGENAME}}|sandbox||&lt;br /&gt;
&amp;lt;!-- Categories go here if you wish an additional category to that set in {{module rating}} above automatically. --&amp;gt;&lt;br /&gt;
[[Category:Lua metamodules]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Oetterer</name></author>
	</entry>
</feed>