Idi na sadržaj

Modul:Main

S Wikipedije, slobodne enciklopedije
Dokumentacija modula[uredi] [historija] [osvježi keš]
Ova dokumentacija je prikazana uModul:Main/dok.

Ovaj modul implementira šablon {{Glavni}}. Pogledajte dokumentaciju šablona za više informacija.


--[[
-- This module produces a link to a main article or articles. It implements the
-- template {{main}}.
--
-- If the module is used in category or category talk space, it produces "The
-- main article for this category is xxx ". Otherwise, it produces
-- "Main article: xxx".
--]]

localmHatnote=require('Modul:Hatnote')
localmHatlist=require('Modul:Hatnote list')
localmArguments-- lazily initialise
localp={}

functionp.main(frame)
mArguments=require('Modul:Arguments')
localargs=mArguments.getArgs(frame,{parentOnly=true})
localpages={}
fork,vinpairs(args)do
iftype(k)=='number'then
localdisplay=args['oznaka '..k]orargs['o'..k]
localpage=displayand
string.format('%s|%s',string.gsub(v,'|.*$',''),display)orv
pages[#pages+1]=page
end
end
if#pages==0andmw.title.getCurrentTitle().namespace==0then
returnmHatnote.makeWikitextError(
'niste naveli stranice',
'Šablon:Glavni#Greške',
args.category
)
end
localoptions={
selfref=args.selfref
}
returnp._main(pages,options)
end

functionp._main(args,options)
-- Get the list of pages. If no first page was specified we use the current
-- page name.
localcurrentTitle=mw.title.getCurrentTitle()
if#args==0thenargs={currentTitle.text}end
localisPlural=#args>1
localfirstPage=string.gsub(args[1],'|.*$','')
-- Find the pagetype.
localpageType=isPluraland(mHatnote.findNamespaceId(firstPage)==0and'Glavni članci'or'Glavne stranice')or(mHatnote.findNamespaceId(firstPage)==0and'Glavni članak'or'Glavna stranica')
-- Make the formatted link text
list=mHatlist.andList(args,true)
-- Build the text.
localmainForm
localcurNs=currentTitle.namespace
if(curNs==14)or(curNs==15)then--category/talk namespaces
mainForm=isPluraland
'%s ove [[Wikipedia:Kategorije|kategorije]] su %s'
or
'%s ove [[Wikipedia:Kategorije|kategorije]] je %s'
else
mainForm=isPluraland'%s: %s'or'%s: %s'
end
localtext=string.format(mainForm,pageType,list)
-- Process the options and pass the text to the _rellink function in
-- [[Module:Hatnote]].
options=optionsor{}
localhnOptions={
selfref=options.selfref
}
returnmHatnote._hatnote(text,hnOptions)
end

returnp