https://de.wikipedia.org/w/index.php?action=history&feed=atom&title=Modul%3ABenutzer%3AFelixReimann%2FTB
Modul:Benutzer:FelixReimann/TB - Versionsgeschichte
2025-06-05T08:17:30Z
Versionsgeschichte dieser Seite in Wikipedia
MediaWiki 1.45.0-wmf.3
https://de.wikipedia.org/w/index.php?title=Modul:Benutzer:FelixReimann/TB&diff=132389078&oldid=prev
FelixReimann am 22. Juli 2014 um 18:53 Uhr
2014-07-22T18:53:50Z
<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="de">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 22. Juli 2014, 20:53 Uhr</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Zeile 23:</td>
<td colspan="2" class="diff-lineno">Zeile 23:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>function p.createbox(count)</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>function p.createbox(count)</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> local item = mw.wikibase.getEntityObject()</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> local item = mw.wikibase.getEntityObject(<ins style="font-weight: bold; text-decoration: none;">'Q192056'</ins>)</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if not item then</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if not item then</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> return mw.text.tag( 'b', {}, 'no Wikibase item found')</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> return mw.text.tag( 'b', {}, 'no Wikibase item found')</div></td>
</tr>
</table>
FelixReimann
https://de.wikipedia.org/w/index.php?title=Modul:Benutzer:FelixReimann/TB&diff=132389036&oldid=prev
FelixReimann: cp from testwiki
2014-07-22T18:52:04Z
<p>cp from testwiki</p>
<p><b>Neue Seite</b></p><div>local p = {}<br />
local initialitem<br />
local lang<br />
local usereferences = {}<br />
local taxondetails = ''<br />
local code = false<br />
-- ICZN ICNafp ICNCP BC/ICNP ICVCN<br />
local colors = {[false]='#d3d3d3', [13011]='#d3d3a4', [693148]='#9bcd9b', [764]='#a4d3d3', [743780]='#d3a4d3', [10892]='#2f6fab'} -- background colors for each code<br />
<br />
function p.taxobox(frame)<br />
local config = frame.args<br />
<br />
local count = 5 <br />
lang = 'en'<br />
<br />
if config.references then<br />
for word in string.gmatch(references, "%w+") do<br />
table.insert(usereferences, tonumber(string.sub(word, 2)))<br />
end<br />
end<br />
return p.createbox(count)<br />
end<br />
<br />
function p.createbox(count)<br />
local item = mw.wikibase.getEntityObject()<br />
if not item then<br />
return mw.text.tag( 'b', {}, 'no Wikibase item found')<br />
end<br />
<br />
local content, references = p.iterate(item, count, true, true)<br />
<br />
local header = mw.text.tag( 'tr', {}, mw.text.tag( 'th', { colspan='2', style='text-align: center; background-color: ' .. colors[code] }, 'Vipera berus'))<br />
<br />
local image = p.targetStr(initialitem, 'P18')<br />
if image then<br />
header = header .. mw.text.tag( 'tr', {}, mw.text.tag( 'td', {colspan='2'}, '[[File:' .. image .. '|220px|.]]'))<br />
end<br />
<br />
local refstr = p.references(references)<br />
header = header .. mw.text.tag( 'tr', {}, mw.text.tag( 'th', { colspan='2', style='text-align: center; background-color: ' .. colors[code] }, '[[' .. mw.wikibase.sitelink('Q3516404') .. ']]' .. refstr))<br />
mw.log('header', header)<br />
mw.log('hierarchy', content)<br />
content = header .. content<br />
<br />
content = content .. taxondetails<br />
mw.log('nomenclature', taxondetails)<br />
<br />
footer = p.map(item) -- .. p.iucn(item)<br />
mw.log('footer', footer)<br />
content = content .. footer<br />
<br />
return mw.text.tag( 'table', { style = "width: 200px; border-width: 1px; border-style: solid; background-color: #f9f9f9; float: right;" }, content )<br />
end<br />
<br />
-- performs the loop up the hierarchy using p171 (parent taxon)<br />
function p.iterate(item, count, first, showtaxoname )<br />
local nextid, references = p.chooseparent(item)<br />
<br />
if not code then<br />
codeid = next(p.targetId(item, 'P944')) -- code of nomenclature<br />
if codeid and colors[codeid] then<br />
code = codeid<br />
end<br />
end<br />
<br />
local showtaxoname = first or (showtaxoname and next(p.targetId(item, 'P31')) == 'Q310890')<br />
local content = ' '<br />
if nextid and count > 0 then<br />
output, refs = p.iterate(mw.wikibase.getEntity('Q' .. nextid), count - 1 , false, showtaxoname)<br />
for ref,_ in pairs(refs) do<br />
references[ref] = true<br />
end<br />
content = content .. output<br />
end<br />
content = content .. p.itemOutput(item, first, showtaxoname)<br />
return content, references<br />
end<br />
<br />
-- choose target according to the references selected by usereferences<br />
function p.chooseparent(item)<br />
local nextid = {} -- list of targets from which the first one will be used<br />
local references = {}<br />
local candnextid, candreferences<br />
mw.log(item)<br />
for i,j in pairs(usereferences) do<br />
mw.log('usereferences', i, j)<br />
end<br />
for id,refs in pairs(p.targetId(item, 'P171')) do<br />
if refs then<br />
for i,r in pairs(usereferences) do<br />
mw.log('testing',r,'as reference')<br />
if refs[r] then<br />
mw.log('found',r)<br />
nextid[i] = id<br />
references[i] = refs<br />
end<br />
end<br />
candnextid = id<br />
candreferences = refs<br />
end<br />
if not candnextid then -- if no item had references yet<br />
candnextid = id -- use this<br />
end<br />
end<br />
if next(nextid) then<br />
_,candnextid = next(nextid)<br />
end<br />
if next(references) then<br />
_,candreferences = next(references)<br />
else -- a new reference is used, append it to usereferences for further usage<br />
if candreferences then<br />
for targetid,_ in pairs(candreferences) do<br />
table.insert(usereferences, targetid)<br />
end<br />
end<br />
end<br />
return candnextid, candreferences or {}<br />
end<br />
<br />
-- formats each item in the taxon hierarchy by using p105 (taxon rank) and p225 (scientific name)<br />
function p.itemOutput(item, first, showtaxonname)<br />
local rankid<br />
rankid = next(p.targetId(item, 'P105'))<br />
<br />
-- format rank<br />
local rankstr = mw.text.tag( 'td', {}, 'unknown rank')<br />
local ranklink = 'taxon'<br />
if rankid then<br />
if rankid == 'novalue' then<br />
rankstr = mw.text.tag( 'td', {}, '')<br />
else<br />
if rankid == 713623 then<br />
rankstr = mw.text.tag( 'td', {}, '')<br />
else<br />
ranklink = mw.wikibase.sitelink('Q' .. rankid)<br />
rankstr = mw.text.tag( 'td', {}, ranklink)<br />
end <br />
end<br />
end<br />
<br />
-- format common and scientific names<br />
local taxonname = 'taxonname'<br />
local itemlabel = mw.wikibase.label(item.id) -- common name<br />
local name, namequalifiers = p.targetStr(item, 'P225') -- scientific name<br />
local taxonname = name or 'no scientific name'<br />
if itemlabel == name then -- print only one if common name is same as scientific name<br />
if rankid == 7432 or rankid == 34740 then -- italic in case of species (7432) or subspecies (34740) rank<br />
taxonname = mw.text.tag( 'i', {}, '[[' .. mw.wikibase.sitelink(item.id) .. '|' .. name .. ']]')<br />
end<br />
namestr = mw.text.tag( 'td', {}, taxonname)<br />
else<br />
if rankid == 7432 or rankid == 34740 then -- italic in case of species (7432) or subspecies (34740) rank<br />
taxonname = mw.text.tag( 'i', {}, name)<br />
end<br />
namestr = mw.text.tag( 'td', {}, '[[' .. mw.wikibase.sitelink(item.id) .. '|' .. itemlabel .. ']] (' .. taxonname .. ')' )<br />
end<br />
<br />
if first then<br />
initialname = taxonname<br />
initialitem = item<br />
end<br />
<br />
if showtaxonname then<br />
p.taxondetails(item, taxonname, ranklink, namequalifiers)<br />
end<br />
return mw.text.tag( 'tr', {}, rankstr .. namestr)<br />
end<br />
<br />
-- shows detailed information for current and all next monotypic taxa<br />
function p.taxondetails(item, name, rank, namequalifiers)<br />
mw.log('show details for', name, rank, code)<br />
taxondetails = taxondetails .. mw.text.tag( 'tr', {}, mw.text.tag( 'th', { colspan="2", style='text-align: center; background-color: ' .. colors[code] }, 'scientific name of ' .. rank))<br />
taxondetails = taxondetails .. mw.text.tag( 'td', {colspan="2", style="text-align: center"}, name)<br />
<br />
--local year = p.qualifierTargetTime(namequalifiers, 'P574') or p.targetTime(item, 'P574')<br />
local year = p.targetTime(item, 'P574')<br />
if year then<br />
year = string.sub(year, 9, 12)<br />
else<br />
year = '????'<br />
end<br />
<br />
-- parentheses needed if instance of recombination<br />
--local recombination = false<br />
--for tid in pairs(p.qualifierTargetId(namequalifiers, 31)) do<br />
-- if tid == 14594740 then<br />
-- recombination = true<br />
-- end<br />
--end<br />
<br />
local authors = p.authorString(item, namequalifiers)<br />
local authorsstr = ''<br />
if authors or not year == '????' then<br />
authorsstr = authors .. ', ' .. year<br />
if recombination then<br />
authorsstr = '(' .. authorsstr .. ')'<br />
end<br />
taxondetails = taxondetails .. mw.text.tag( 'tr', {}, mw.text.tag( 'td', {colspan="2", style="text-align: center; font-variant:small-caps"}, authorsstr))<br />
end<br />
end<br />
<br />
function p.authorString(item, namequalifiers, pid)<br />
if not pid then<br />
pid = 'P405' -- property<br />
end<br />
mw.log('pid',pid)<br />
--local authorids = p.qualifierTargetId(namequalifiers, pid)<br />
--if not next(authorids) then<br />
authorids = p.targetId(item, pid)<br />
--end<br />
local authors = p.createLinks(authorids, true)<br />
if next(authors) then<br />
local concatstr = ', '<br />
if #authors == 2 then<br />
concatstr = ' & '<br />
end<br />
return table.concat(authors, concatstr)<br />
end<br />
end<br />
<br />
-- check if International Code of Nomenclature for algae, fungi, and plants (ICNafp) applies<br />
function p.icnafpApplies()<br />
return code == 693148<br />
end<br />
<br />
-- returns the target value of the property with the given integer id<br />
-- use only if the data type of the property is item<br />
function p.targetId(item, propertyid)<br />
local claims = {}<br />
if item and item.claims and item.claims[propertyid] then<br />
for i = 0, #item.claims[propertyid] do<br />
claim = item.claims[propertyid][i]<br />
if claim.mainsnak and claim.mainsnak.datavalue then<br />
if claim.mainsnak.datavalue.value then<br />
local valueid = claim.mainsnak.datavalue.value['numeric-id'] <br />
local refids = {}<br />
if claim.references then<br />
for _,ref in pairs(claim.references) do<br />
if ref.snaks and ref.snaks['P248'] then<br />
refids[ref.snaks['P248'][0].datavalue.value['numeric-id']] = true<br />
end<br />
end<br />
end<br />
claims[valueid] = refids<br />
else<br />
claims['novalue'] = true -- snaktype not value<br />
end<br />
end<br />
end<br />
end <br />
return claims<br />
end<br />
<br />
-- Use only if the data type of the property is string<br />
function p.targetStr(item, propertyid)<br />
choosenclaim = {}<br />
choosenqualifiers = {}<br />
if item and item.claims and item.claims[propertyid] then<br />
for i = 0, #item.claims[propertyid] do<br />
claim = item.claims[propertyid][i]<br />
if claim.mainsnak and claim.mainsnak.datavalue and claim.mainsnak.datavalue.value then<br />
local valueid = claim.mainsnak.datavalue.value<br />
return valueid, nil<br />
end<br />
end<br />
end<br />
end<br />
<br />
-- Use only if the data type of the property is time<br />
function p.targetTime(item, propertyid )<br />
if item and item.claims and item.claims[propertyid] then<br />
for i = 0, #item.claims[propertyid] do<br />
claim = item.claims[propertyid][i]<br />
if claim.mainsnak and claim.mainsnak.datavalue and claim.mainsnak.datavalue.value and claim.mainsnak.datavalue.value.time then<br />
return claim.mainsnak.datavalue.value.time<br />
end<br />
end<br />
end<br />
end<br />
<br />
-- same as targetId but for qualifiers<br />
-- TODO merge<br />
function p.qualifierTargetId( qualifiers, propertyid )<br />
local claims = {}<br />
<br />
if qualifiers then<br />
for _,claim in pairs( qualifiers ) do<br />
if claim[2] == propertyid then<br />
local valueid = claim[4]['numeric-id'] <br />
claims[valueid] = true<br />
end <br />
end<br />
end<br />
return claims<br />
end<br />
<br />
-- same as targetTime but for qualifiers<br />
-- TODO merge<br />
function p.qualifierTargetTime(qualifiers, propertyid )<br />
local claims = {}<br />
if qualifiers then<br />
for _,claim in pairs( qualifiers ) do<br />
if claim[2] == propertyid then<br />
local value = claim[4]<br />
return value.time<br />
end<br />
end<br />
end<br />
end<br />
<br />
-- returns html for the given refids set<br />
function p.references(refids)<br />
local frame = mw.getCurrentFrame()<br />
local refstr = ''<br />
if refids then<br />
for id,_ in pairs(refids) do<br />
local ref = p.reference(id, last)<br />
if not ref then<br />
ref = 'reference [[d:Q' .. id .. ']]'<br />
end<br />
refstr = refstr .. frame:extensionTag('ref', ref, {name='Q'.. id})<br />
end<br />
end<br />
return refstr<br />
end<br />
<br />
function p.reference(id, last)<br />
return mw.wikibase.sitelink('Q' .. id)<br />
end<br />
<br />
-- takes a set of item ids (the keys of the given table) and creates wikilinks based on their labels<br />
function p.createLinks(set, authorAbbreviation)<br />
local authors = {}<br />
for authorid,_ in pairs(set) do<br />
if authorid then<br />
local label = mw.wikibase.label('Q' .. authorid)<br />
if authorAbbreviation then<br />
if label ~= 'no label' then<br />
for word in mw.ustring.gmatch(label, "%w+") do<br />
label = word<br />
end<br />
end<br />
end<br />
table.insert(authors, '[[' .. mw.wikibase.sitelink('Q' .. authorid) .. '|' .. label .. ']]')<br />
end<br />
end<br />
return authors<br />
end<br />
<br />
function p.map(item)<br />
local map = p.targetStr(item, 'P181')<br />
if map then<br />
return mw.text.tag( 'tr', {}, mw.text.tag( 'th', { colspan='2', style='text-align: center; background-color: ' .. colors[code] }, 'range map')) .. mw.text.tag( 'tr', {}, mw.text.tag( 'td', {colspan='2'}, '[[File:' .. map .. '|220px|.]]'))<br />
end<br />
<br />
return ''<br />
end<br />
<br />
return p</div>
FelixReimann