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 20: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 = 10

-- STEP 3: Replace the example template text with the template text that you wish to increment.
local templatetext = [==========[
| label9  = Data creació
| data9   = {{if empty|{{{year|}}} | {{{any|}}} | {{{completion_date|}}} | {{{data|}}} | {{{created|}}}  
                       | {{circa|P571 |list=false }} 
             }}  

| label10  = Comitent
| data10   = {{#invoke:Wikidata | claim | property=P88 | value={{{comitent|}}}| list=firstrank}} 

| label11  = Data descoberta
| data11   = {{#invoke:Wikidata | claim | property=P575 | value={{{discovered|{{{descobert|}}}}}} }}



<!--Lloc de creació o de descoberta-->
| label12  = Lloc original
| data12   = {{#invoke:Wikidata | claim | property=P189 | value={{{place|{{{lloc original|{{{lloc_original|}}}}}}}}} }}

| label13 = Tècnica
| data13  = {{#invoke:Wikidata | claim | property=P2079 | value={{{type|{{{tècnica|{{{tecnica|}}} }}} }}} }}

| label14 = Període
| data14  = {{#invoke:Wikidata | claim | property=P2348 | value={{{period|{{{periode|}}}}}} }}

| label15 = Gènere
| data15  = {{#invoke:Wikidata | claim | property=P136 | value={{{genere|}}}| list=firstrank }}

| label16 = Estil
| data16  = {{#invoke:Wikidata | claim | property=P135 | value={{{style|{{{estil|}}}}}} | list=firstrank}}

| label17 = Material
| class17 = category  <!--Condicionat a que no existeixi "tècnica". Cas "pintura a l'oli" com material a WD-->
| data17  = {{#if: {{{type|{{{tècnica|{{{tecnica|}}}}}}}}} |<!-- buit -->| {{#invoke:Wikidata | claim | property=P186 | value={{{material|}}} }} }}

| label18 = Subjecte&nbsp;representat
| data18 = {{{subjecte|}}}

| label19 = Encàrrec
| data19  = {{{dades_encarrec|}}} 

| label20 = Dimensions
| data20  = {{Bloc dimensions | item ={{{item|}}} | dimensions  = {{{dimensions|}}} 
                              | amplada = {{{width_metric|{{{amplada|}}} }}}  
                               | llargada = {{{length_metric|{{{llargada|{{{longitud|}}}}}} }}} 
                              | alçada = {{{height_metric|{{{alçada|}}} }}} 
                              | diametre = {{{diameter_metric|{{{diametre|}}}}}}  
                  | unitat_mida = {{{metric_unit|{{{unitat mida|{{{unitat_mida|cm}}} }}} }}}
           }}

| label21 = Pes
| data21  = {{#invoke:Wikidata | claim | property=P2067 | value={{{weight|{{{pes|}}}}}} }}

| label22 = Condicions
| data22  = {{{condicions|}}}

| label23 = Propietari
| data23  =  {{#invoke:Wikidata | claim |value={{{owner|{{{propietari|}}} }}} | property=P127 |qualifier=P580|qualifier2=P582
                           |formatting = table| rowformat = $0 <small>{{((}}Mostra inici fi{{!}}inici{{=}}$1{{!}}fi{{=}}$2{{))}}</small> 
                           |tablesort=1 |colformat1=Y |colformat2=Y}} 

]==========]

-- 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