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 = &#039;&#039;<br /> local code = false<br /> -- ICZN ICNafp ICNCP BC/ICNP ICVCN<br /> local colors = {[false]=&#039;#d3d3d3&#039;, [13011]=&#039;#d3d3a4&#039;, [693148]=&#039;#9bcd9b&#039;, [764]=&#039;#a4d3d3&#039;, [743780]=&#039;#d3a4d3&#039;, [10892]=&#039;#2f6fab&#039;} -- background colors for each code<br /> <br /> function p.taxobox(frame)<br /> local config = frame.args<br /> <br /> local count = 5 <br /> lang = &#039;en&#039;<br /> <br /> if config.references then<br /> for word in string.gmatch(references, &quot;%w+&quot;) 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( &#039;b&#039;, {}, &#039;no Wikibase item found&#039;)<br /> end<br /> <br /> local content, references = p.iterate(item, count, true, true)<br /> <br /> local header = mw.text.tag( &#039;tr&#039;, {}, mw.text.tag( &#039;th&#039;, { colspan=&#039;2&#039;, style=&#039;text-align: center; background-color: &#039; .. colors[code] }, &#039;Vipera berus&#039;))<br /> <br /> local image = p.targetStr(initialitem, &#039;P18&#039;)<br /> if image then<br /> header = header .. mw.text.tag( &#039;tr&#039;, {}, mw.text.tag( &#039;td&#039;, {colspan=&#039;2&#039;}, &#039;[[File:&#039; .. image .. &#039;|220px|.]]&#039;))<br /> end<br /> <br /> local refstr = p.references(references)<br /> header = header .. mw.text.tag( &#039;tr&#039;, {}, mw.text.tag( &#039;th&#039;, { colspan=&#039;2&#039;, style=&#039;text-align: center; background-color: &#039; .. colors[code] }, &#039;[[&#039; .. mw.wikibase.sitelink(&#039;Q3516404&#039;) .. &#039;]]&#039; .. refstr))<br /> mw.log(&#039;header&#039;, header)<br /> mw.log(&#039;hierarchy&#039;, content)<br /> content = header .. content<br /> <br /> content = content .. taxondetails<br /> mw.log(&#039;nomenclature&#039;, taxondetails)<br /> <br /> footer = p.map(item) -- .. p.iucn(item)<br /> mw.log(&#039;footer&#039;, footer)<br /> content = content .. footer<br /> <br /> return mw.text.tag( &#039;table&#039;, { style = &quot;width: 200px; border-width: 1px; border-style: solid; background-color: #f9f9f9; float: right;&quot; }, 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, &#039;P944&#039;)) -- 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, &#039;P31&#039;)) == &#039;Q310890&#039;)<br /> local content = &#039; &#039;<br /> if nextid and count &gt; 0 then<br /> output, refs = p.iterate(mw.wikibase.getEntity(&#039;Q&#039; .. 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(&#039;usereferences&#039;, i, j)<br /> end<br /> for id,refs in pairs(p.targetId(item, &#039;P171&#039;)) do<br /> if refs then<br /> for i,r in pairs(usereferences) do<br /> mw.log(&#039;testing&#039;,r,&#039;as reference&#039;)<br /> if refs[r] then<br /> mw.log(&#039;found&#039;,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, &#039;P105&#039;))<br /> <br /> -- format rank<br /> local rankstr = mw.text.tag( &#039;td&#039;, {}, &#039;unknown rank&#039;)<br /> local ranklink = &#039;taxon&#039;<br /> if rankid then<br /> if rankid == &#039;novalue&#039; then<br /> rankstr = mw.text.tag( &#039;td&#039;, {}, &#039;&#039;)<br /> else<br /> if rankid == 713623 then<br /> rankstr = mw.text.tag( &#039;td&#039;, {}, &#039;&#039;)<br /> else<br /> ranklink = mw.wikibase.sitelink(&#039;Q&#039; .. rankid)<br /> rankstr = mw.text.tag( &#039;td&#039;, {}, ranklink)<br /> end <br /> end<br /> end<br /> <br /> -- format common and scientific names<br /> local taxonname = &#039;taxonname&#039;<br /> local itemlabel = mw.wikibase.label(item.id) -- common name<br /> local name, namequalifiers = p.targetStr(item, &#039;P225&#039;) -- scientific name<br /> local taxonname = name or &#039;no scientific name&#039;<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( &#039;i&#039;, {}, &#039;[[&#039; .. mw.wikibase.sitelink(item.id) .. &#039;|&#039; .. name .. &#039;]]&#039;)<br /> end<br /> namestr = mw.text.tag( &#039;td&#039;, {}, 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( &#039;i&#039;, {}, name)<br /> end<br /> namestr = mw.text.tag( &#039;td&#039;, {}, &#039;[[&#039; .. mw.wikibase.sitelink(item.id) .. &#039;|&#039; .. itemlabel .. &#039;]] (&#039; .. taxonname .. &#039;)&#039; )<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( &#039;tr&#039;, {}, 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(&#039;show details for&#039;, name, rank, code)<br /> taxondetails = taxondetails .. mw.text.tag( &#039;tr&#039;, {}, mw.text.tag( &#039;th&#039;, { colspan=&quot;2&quot;, style=&#039;text-align: center; background-color: &#039; .. colors[code] }, &#039;scientific name of &#039; .. rank))<br /> taxondetails = taxondetails .. mw.text.tag( &#039;td&#039;, {colspan=&quot;2&quot;, style=&quot;text-align: center&quot;}, name)<br /> <br /> --local year = p.qualifierTargetTime(namequalifiers, &#039;P574&#039;) or p.targetTime(item, &#039;P574&#039;)<br /> local year = p.targetTime(item, &#039;P574&#039;)<br /> if year then<br /> year = string.sub(year, 9, 12)<br /> else<br /> year = &#039;????&#039;<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 = &#039;&#039;<br /> if authors or not year == &#039;????&#039; then<br /> authorsstr = authors .. &#039;, &#039; .. year<br /> if recombination then<br /> authorsstr = &#039;(&#039; .. authorsstr .. &#039;)&#039;<br /> end<br /> taxondetails = taxondetails .. mw.text.tag( &#039;tr&#039;, {}, mw.text.tag( &#039;td&#039;, {colspan=&quot;2&quot;, style=&quot;text-align: center; font-variant:small-caps&quot;}, authorsstr))<br /> end<br /> end<br /> <br /> function p.authorString(item, namequalifiers, pid)<br /> if not pid then<br /> pid = &#039;P405&#039; -- property<br /> end<br /> mw.log(&#039;pid&#039;,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 = &#039;, &#039;<br /> if #authors == 2 then<br /> concatstr = &#039; &amp; &#039;<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[&#039;numeric-id&#039;] <br /> local refids = {}<br /> if claim.references then<br /> for _,ref in pairs(claim.references) do<br /> if ref.snaks and ref.snaks[&#039;P248&#039;] then<br /> refids[ref.snaks[&#039;P248&#039;][0].datavalue.value[&#039;numeric-id&#039;]] = true<br /> end<br /> end<br /> end<br /> claims[valueid] = refids<br /> else<br /> claims[&#039;novalue&#039;] = 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][&#039;numeric-id&#039;] <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 = &#039;&#039;<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 = &#039;reference [[d:Q&#039; .. id .. &#039;]]&#039;<br /> end<br /> refstr = refstr .. frame:extensionTag(&#039;ref&#039;, ref, {name=&#039;Q&#039;.. id})<br /> end<br /> end<br /> return refstr<br /> end<br /> <br /> function p.reference(id, last)<br /> return mw.wikibase.sitelink(&#039;Q&#039; .. 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(&#039;Q&#039; .. authorid)<br /> if authorAbbreviation then<br /> if label ~= &#039;no label&#039; then<br /> for word in mw.ustring.gmatch(label, &quot;%w+&quot;) do<br /> label = word<br /> end<br /> end<br /> end<br /> table.insert(authors, &#039;[[&#039; .. mw.wikibase.sitelink(&#039;Q&#039; .. authorid) .. &#039;|&#039; .. label .. &#039;]]&#039;)<br /> end<br /> end<br /> return authors<br /> end<br /> <br /> function p.map(item)<br /> local map = p.targetStr(item, &#039;P181&#039;)<br /> if map then<br /> return mw.text.tag( &#039;tr&#039;, {}, mw.text.tag( &#039;th&#039;, { colspan=&#039;2&#039;, style=&#039;text-align: center; background-color: &#039; .. colors[code] }, &#039;range map&#039;)) .. mw.text.tag( &#039;tr&#039;, {}, mw.text.tag( &#039;td&#039;, {colspan=&#039;2&#039;}, &#039;[[File:&#039; .. map .. &#039;|220px|.]]&#039;))<br /> end<br /> <br /> return &#039;&#039;<br /> end<br /> <br /> return p</div> FelixReimann