User:Happy-melon/sandbox5

[[Template:Imbox|imbox]]

{{#ifeq:{{{image|}}}|none

|

|

}}

{{#if:{{{imageright|}}}

|

}}

{{#if:{{{below|}}}

|

}}

{{#switch:{{{type|}}}

|

| speedy

| delete

| content

| style

| move

| protection

| license

| featured

| notice =

| #default =

This message box is using an invalid "type={{{type|}}}" parameter and needs fixing.
Category:Wikipedia message box parameter needs fixing

}}{{#ifeq:{{BASEPAGENAME}}|{{SUBPAGENAME}}|{{#ifeq:{{NAMESPACE}}|Template|{{PAGENAME}}}}}}

----

types = { 'speedy' : [ 'speedy', Imbox speedy deletion.png ],

'delete' : [ 'delete', Imbox deletion.png ],

'content' : [ 'content', Imbox content.png ],

'style' : [ 'style', Imbox style.png ],

'move' : [ 'move', Imbox move.png ],

'protection' : [ 'protection', Imbox protection.png ],

'license' : [ 'license', Imbox license.png ],

'featured' : [ 'featured', Imbox featured.png ],

'notice' : [ 'notice', Imbox notice.png ], # 'notice' is the default

}

def main():

params = getAllParams() # This returns a dictionary of all parameters passed to the template

if getParam( 'small', '' ): # This gets a single parameter value, or a defined default

params['small'] = 'mbox-small'

t = getParam( 'type', 'notice' )

if t in types:

params['type'] = t

else:

params['type'] = 'notice'

print "

" % params

if params['image'] == 'none':

# No image. Cell with some width or padding necessary for text cell to have 100% width.

print "

"

else:

print '

'

print "

" % params

if params['imageright']:

print "

" % params

print '

'

if params['below']:

if params['imageright']:

params['cols'] = 3

else:

params['cols'] = 2

print "

" % params

print '

'

# Detect and report usage with faulty "type" parameter

if getParam( 'type', 'notice' ) not in types and getParam( 'type' ):

print """

This message box is using an invalid "type=%s" parameter and needs fixing.

Category:Wikipedia message box parameter needs fixing

""" % getParam( 'type' )

# Magic words are implemented as constants?

if BASEPAGENAME == SUBPAGENAME and NAMEPACE == 'Template':

print "%s" % PAGENAME

[[Template:Navbox|navbox]]

{{#switch:{{{border|{{{1|}}}}}}|subgroup|child=

|none=|#default=

-->style="{{{bodystyle|}}};{{{style|}}}">

}}

----

  1. Please do not edit without discussion first as this is a VERY complex template ##

def main():

params = getAllParams( { 'bodystyle' : '',

'style' : '',

'listpadding' : '0em 0.25em' } )

params['border'] = getParam( 'border', getParam( '1', '' ) )

if params['border'] in ['subgroup','child']:

print '

'

elif params['border'] == 'none':

pass

else:

print "

"

  1. Do a group/list block

def doGroup(count, params):

i = str(count)

if params['list'+i]:

if params['title'] or params['above'] or params['list1']:

print ""

print ''

if params['group'+i]:

params['~groupstyle'] = params['group'+i+'style']

params['~group'] = params['group'+i]

print """

style='%(basestyle)s;%(groupstyle)s;%(~groupstyle)s'>

%(~group)s

else:

params['~eostyle'] = params['evenstyle']

if params['evenodd'] == 'swap':

if count % 2:

params['~evenodd'] = 'even'

else:

params['~evenodd'] = 'odd'

else:

if count % 2:

params['~evenodd'] = getParam( 'evenodd', 'odd' )

else:

params['~evenodd'] = getParam( 'evenodd', 'even' )

params['~liststyle'] = params['list'+i+'style']

params['~list'] = params['list'+i]

print """width:100%;padding:0px;%(liststyle)s;%(~eostyle)s;%(~liststyle)s'

class='navbox-list navbox-%(~evenodd)s">

style='padding:%(listpadding)s">%(~list)s

""" % params