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:11, 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 = 32

-- STEP 3: Replace the example template text with the template text that you wish to increment.
local templatetext = [==========[
| header33 = {{#if:{{{part2|}}}{{{part3|}}}{{{part4|}}}{{{part5|}}}<!-- Secció, si la peça en més d'un museu, crea secció -->
                   {{#ifexpr:{{str find|{{#invoke:Wikidata | claim | property=P195 | list=firstrank |separator=<br/> |conjunction=<br/>}}|<br/>}} >1|true}}
               | Ubicació<!-- 
            -->| {{#if:{{#Property:P195|from={{{item|}}}}}{{{museu|{{{museu1|}}} }}}|<!-- no tinc museu, però hi ha ubicació, també crea secció 
                -->|{{#if:{{{ubicacio|}}}{{{ciutat|}}}{{#Property:P131|from={{{item|}}}}} {{#Property:P969|from={{{item|}}} }}{{#Property:P669|from={{{item|}}} }}
                       | Ubicació}}
                 }}
             }} 
| label34 =  {{#if: {{both|{{#Property:P195|from={{{item|}}}}}  <!-- És museu i només hi ha un  -->
                          |{{#ifeq:{{str find|{{#invoke:Wikidata | claim | property=P195 | list=firstrank |separator=<br/> |conjunction=<br/>}}|<br/>}}|0|true}}
                  }} {{{museu|{{{museu1|}}}}}} <!-- És només 1 museu manual  -->  
               |{{#if:{{{part2|}}}{{{part3|}}}{{{part4|}}}{{{part5|}}}|<!--Si hi ha més d'una ubuicació, no posar el valor d'etiqueta   -->|Col·lecció}}
             }} 


| data34 = {{#if:{{#Property:P195|from={{{item|}}}}}{{{museu|{{{museu1|}}}}}}<!--
 en museu -->|{{#if:{{#ifexpr:{{str find|{{#invoke:Wikidata | claim | property=P195 <!-- 
                                               -->| list=firstrank |separator=<br/> |conjunction=<br/>}}|<br/>}} >1|true}}<!--
                 -->{{{part2|}}}{{{part3|}}}{{{part4|}}}{{{part5|}}}
  <!-- multi -->|{{#if:{{{part2|}}}{{{part3|}}}{{{part4|}}}{{{part5|}}}
                   |<center>{{Infotaula d'obra artística/format taula| {{{part1|}}} | {{{museu|{{{museu1|}}}}}} 
                                                                                    | {{{ciutat|{{{ciutat1|}}}}}}  

                                                                     | {{{part2|}}} | {{{museu2|}}} | {{{ciutat2|}}}   
                                                                     | {{{part3|}}} | {{{museu3|}}} | {{{ciutat3|}}}   
                                                                     | {{{part4|}}} | {{{museu4|}}} | {{{ciutat4|}}}  
                                                                     | {{{part5|}}} | {{{museu5|}}} | {{{ciutat5|}}} }} </center>
                   |{{#if:{{#Property:P527|from={{{item|}}}}}
                      |{{#invoke:Wikidata | claim | property=P527  | formatting=table |list=firstrank |separator=</td></tr> 
                                 |qualifier=P518  | qualifier2=P195| qualifier3=P195/P131
                                 |qualifier4=P527/P18 |qualifier5=P527/P217

                                 |colformat1=label | rowsubformat4=[[file:$4|60px|link=]]  
                                 |rowformat= <tr><td style="background:#eeeeee;">$4</td><!--
                                              --><td>$1<br/>''$0''<!--
                                              --><br/>$2, $3 |rowsubformat3=($3)<!--
                                              --><br/>Inv:$5
                        }}
                       |{{#invoke:Wikidata | claim | property=P195 | formatting=table |list=firstrank |separator=</td></tr> 
                                 | qualifier=P518 | qualifier2=P195/P131 |rowsubformat2=($2) 
                                 |rowformat= <tr><td style="background:#eeeeee;">$1</td><td>$0 $2
                        }}
                     }}
                 }}<!-- fi multi en manual --><!--
  mono museu -->|{{#if:{{{museu|{{{museu1|}}}}}} |{{Entrades separades per comes|{{{museu|{{{museu1|}}}}}} | {{{ciutat|{{{ciutat1|}}}}}}}} <!-- Manual
             WD -->|{{#invoke:Wikidata | claim | property=P195 | formatting=table |list=firstrank |separator=<br/> |conjunction=<br/>
                                       | qualifier=P518 | qualifier2=P195/P131 |rowsubformat2=($2)
                                       |rowformat= $0 $2
                 }} }}
              }}
<!--
 NO museu -->|{{#if:{{{ubicacio|}}} <!-- Ubicació fora institució (estàtues, etc.)
             -->|{{{ubicacio|}}}{{#if:{{{ciutat|}}}|,&#32;{{{ciutat|}}} }}<!--
             -->| {{infotaula|child=yes 
                     |bodyclass  = vcard | titleclass = fn org
                     |labelstyle = background-color:#eeeeee; |datastyle = text-align:left;
                     |header1 = 
                     |data3   ={{#invoke:Wikidata|getParentValues
                                    | item={{{item|}}} | sorting=-1 
                                    |upto=estat  |separator=</td></tr>
                                    |rowformat=<tr><td style="background:#eeeeee;">$0</td><td>$1 }} 
                     |label10   = Localització  
                     |data10   = {{If empty|{{{localitzacio|}}}
                                             |{{#invoke:Wikidata | claim | property=P969 |list=false }} 
                                             |{{#invoke:Wikidata | claim | property=P669 |qualifier=P670 |qualifier2=P281 | formatting=table
                                             |rowformat=$0$1 $2 |rowsubformat1=, $1 |rowsubformat2=($2) }}   

                                  }}  
                     |data20  = {{#if:{{{imatge_mapa|}}}
                                  | {{#invoke:InfoboxImage|InfoboxImage|image={{{imatge_mapa|}}} |size=225px
                                                    |sizedefault=frameless|upright=1|alt= |title={{{peu_mapa|}}}
                                                    |suppressplaceholder=yes}} 
                                  | {{#if:{{{draw_mapa|}}}
                                      | {{{draw_mapa|}}}
                                      | {{#ifeq:{{{mapaWD|}}}|no|<!--no es vol mapa -->|
                     <!--coordenades?-->{{#if:{{both|{{if empty|{{{lat_dec|}}} | {{lat wd|item={{{item|}}} }} }}
                                                    |{{if empty|{{{long_dec|}}} | {{lon wd|item={{{item|}}} }} }}
                                              }}
                                            |{{mapes localització| item = {{{item|}}}
                                                       |lat_dec={{{lat_dec|}}}  |long_dec={{{long_dec|{{{lon_dec|}}}}}}
                                                        |mapa_localitzador={{{mapa_localitzador|}}} |zoom={{{zoom|16}}}
                                                        |nom_marcador= {{if empty|{{{nom_marcador|}}}| {{{nom|{{PAGENAME}} }}} }}
                                                        |marcador={{{marcador|}}} |marcador_color={{if empty|{{{marcador_color|}}} | FF0000}}
                                                        |marcador_mida={{{marcador_mida|small}}} |mapa_mida={{{mapa_mida|}}}
                                                        |superficie=  }}
                                     }}<!--fi no es vol mapa -->    
                                    }}<!--fi no hi ha coordenades  -->    
                                  }}<!--fi draw_mapa -->    
                                }}<!--fi mapa en imatge -->    
                }}
              }}
           }}

| header50 = {{#if:{{#invoke:Wikidata | claim | property=P793 | list=firstrank}} | Història}}

| label51 =  {{#if:{{#invoke:Wikidata | claim | property=P793 | list=firstrank}} |Data}}
| data51  =  {{#if:{{#invoke:Wikidata | claim | property=P793 | list=firstrank}} |'''Fet destacat'''}}
| data53  =  {{#if:{{#property:P793 |from={{{item|}}} }} |<tr>{{#invoke:Wikidata |claim |formatting=table 
                      |property=P793 |qualifier=P585 | qualifier2=P580 |qualifier3=P276 |qualifier4=P528 |qualifier5=P582
                      |rowformat=<td style="background: #eeeeee;">$1 $2</td><td style="text-align:left">$0$3 $4</td>
                       |rowsubformat2=$2-$5 |rowsubformat3=, $3 |rowsubformat4= (catàleg:$4) 
                      |colformat1=Y |colformat2=Y |colformat5=Y 

                      |separator=</tr><tr>|conjunction=</tr><tr>|tablesort=1 <!-- |sorting=-1 -->}}</tr>}}


| header59 = {{#if:{{#invoke:Wikidata | claim | property=P217 | value={{{codimuseu|}}}| list=false}} {{{catalog|}}}   {{{anterior|}}} {{{posterior|}}} | Catalogació}}

| label60 = Codi&nbsp;museu
| data60 = {{#if:{{{codimuseu|}}} | {{#if:{{{enllaç_museu|}}}|[{{{enllaç_museu|}}} {{{codimuseu|}}}] | {{{codimuseu|}}} }} <!-- dades manuals  -->
             |{{#if:{{#Property:P217|from={{{item|}}}}}
                |{{#if:{{#Property:P973|from={{{item|}}}}}
                   | [{{#invoke:Wikidata | claim | property=P973 |list=false}} &nbsp;{{#invoke:Wikidata | claim | property=P217 | list=false}}]
                   | {{#invoke:Wikidata | claim | property=P217 |list=false}}
                 }}   
              }}
           }}   

| label61 = Catàleg 
| data61  = {{#if:{{{cataleg|}}} | {{{cataleg|}}}
              | {{#invoke:Wikidata | claim | property=P528 |qualifier=P972 |formatting = table
                          |rowformat= $1<small>:($0)</small> }}
            }}

| label62 = Anterior
|  data62 = {{#invoke:Wikidata | claim | property=P155 | value={{{anterior|}}} }}

| label63 = Posterior
|  data63 = {{#invoke:Wikidata | claim | property=P156 | value={{{posterior|}}} }}


<!-- PENDENT analitzar format i condició d sortida. Si hi ha codi_inventari, ja s'ha mostrat com a link del codi

| label70 = Descrit
|  data63 = {{#invoke:Wikidata | claim | property=P973 | value={{{posterior|}}} | list=firstrank}}

 -->
<!-- Segona imatge -->
| data78  = {{#if:{{{imatge2|}}}|{{#invoke:InfoboxImage|InfoboxImage|image={{{imatge2|}}} |size={{{mida_imatge2|250px}}}|sizedefault=frameless|upright={{#if:{{{image_upright|}}}|{{{image_upright}}}|1.36}}|alt={{{alt|}}} }} 
}}
| data79  = {{{peu2|}}}

| label80 = Lloc web
| data80  = {{#invoke:Wikidata | claim | property=P856 | value={{{lloc_web|}}} | list=false | formatting=[$1 Lloc web] }}

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

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