Jump to content

Module:IncrementParams

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Amadalvarez (talk | contribs) at 21:04, 12 March 2019. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- STEP 1: Click on the "edit" tab at the top of the page to edit this module.

-- STEP 2: if you want to increment by a number other than 1, put that number below, after the equals sign. 
local increment = 20

-- STEP 3: Replace the example template text with the template text that you wish to increment.
local templatetext = [==========[
| label14 = Artista 
| data14  = {{#if:{{{artista|}}}
            | {{#ifeq:{{textnet|{{{artista|}}} }}|anònim|Anònim|{{#ifexist: {{{artista|}}}|[[{{{artista|}}}]]|{{{artista|}}} }} }}
              {{#if:{{{artista2|}}}| i {{#ifexist: {{{artista2|}}}|[[{{{artista2|}}}]]|{{{artista2|}}} }} }}
            | {{#ifeq:{{#invoke:Wikidata | claim | property=P170 |formatting= raw}}|Q4233718<!-- anònim
            -->|{{#invoke:Wikidata | claim | property=P170| item={{{item|}}} | formatting=table |separator=<br/>
                         | qualifier=P1773  | rowsubformat1=atribuït a $1     | qualifier2=P1774 | rowsubformat2=taller de $2
                         | qualifier3=P1775 | rowsubformat3=seguidor de $3    | qualifier4=P1776 | rowsubformat4=cercle de $4  
                         | qualifier5=P1777 | rowsubformat5=anònim amb l'estil de $5 
                         | qualifier6=P1778 | rowsubformat6=falsificació de $6 
                         | qualifier7=P1779 | rowsubformat7=possible creador: $7 | qualifier8=P1780 | rowsubformat8=escola de $8  
                         | qualifier9=P1877 | rowsubformat9=inspirat en l'obra de $9 
                         | rowformat= $1$2$3$4$5$6$7$8$9 
                }}<!-- fi tractament anònim
            -->|{{#invoke:Wikidata | claim | property=P170 |formatting= table
                          | qualifier=P1810 | qualifier2=P518 | qualifier3=P1480 | rowformat=$3$0$1$2  
                          | rowsubformat1 =, anomenat com $1 | rowsubformat2 = <small>&nbsp;($2)</small> | rowsubformat3 =$3,&nbsp; }} }} }}

| label15 = Dissenyador
| data15  = {{#invoke:Wikidata | claim | property=P287 | value={{{dissenyador|}}} }}

| label16  = Data&nbsp;creació
| data16   = {{if empty| {{{data_creacio|}}}  
                       | {{circa|P571 |list=false|item={{{item|}}} }} 
                       | {{circa|P580 |list=false|item={{{item|}}} }} 
             }}  
| label18 = Primera menció
| data18  = {{#invoke:Wikidata | claim | property=P1249 | value={{{primera_mencio|}}}| list=firstrank}} 

| label19 = Basat en
| data19  = {{#invoke:Wikidata | claim | property=P144 | value={{{basat_en|}}}| list=firstrank}} 




<!--Dates-->

| label20  = Descobert per
| data20   = {{if empty| {{{descobridor|}}}  
                       | {{#invoke:Wikidata | claim | property=P61 | list=firstrank }}
             }}
| label21  = Descobriment
| data21   = {{if empty| {{{descobriment|}}}  
                       | {{circa|P575 |list=false|item={{{item|}}} }}{{If then show|{{#invoke:Wikidata|claim|property=P189}}||&nbsp;(|)}} 
             }}
]==========]

-- STEP 4: Save this module.

-- STEP 5: You can now output the incremented text with the following code:
--                {{subst:#invoke:IncrementParams|main}}
-- Or you can simply copy and paste the text from this module's documentation.

-- STEP 6: Check the output! In rare cases this module might produce false positives.
-- For example, it will change the text "[[Some link|foo3=bar]]" to "[[Some link|foo4=bar]]".
-- You can use the "show changes" function in the edit window of the template you are editing
-- to find any false positives.

-- STEP 7: When you are finished, undo your changes to this page, so that the next person
-- won't be confused by seeing any non-default values. Thanks for using this module!

local p = {}
 
local function replace(prefix, num, suffix)
    return '|' .. prefix .. tostring(tonumber(num) + increment) .. suffix .. '='
end
 
function p.main(frame)
    -- Increment the template text.
    templatetext = mw.ustring.gsub(templatetext, '|(%s*%a?[%a_%-]-%s*)([1-9]%d*)(%s*[%a_%-]-%a?%s*)=', replace)
    -- Add pre tags and escape html etc. if the pre option is set.
    if frame and frame.args and frame.args.pre and frame.args.pre ~= '' then
        templatetext = mw.text.nowiki(templatetext)
        templatetext = '<pre style="white-space:-moz-pre-wrap; white-space:-pre-wrap; '
            .. 'white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word;">' 
            .. templatetext .. '</pre>'
    end
    return templatetext
end
 
return p