Modul:kurterê

Ji Wîkîferhengê
Belgekirina modulê[nîşan bide] [biguhêre] [rojane bike]
Ev belge ji Modul:kurterê/belge hatiye girtin.

Binêre[biguhêre]

local export = {}

function export.raber(frame)--show
	local output = {}
	-- Hacky way to allow function to be called from other modules.
	local args = (frame.getParent and frame:getParent().args) or frame
	local demo = false

	local FULLPAGENAME = mw.title.getCurrentTitle().fullText
	local BASEPAGENAME, SUBPAGENAME = FULLPAGENAME:match("^(.-)/([^/]-)$")
	-- BASEPAGENAME = BASEPAGENAME or FULLPAGENAME
	
	if frame.getParent and FULLPAGENAME == frame:getParent():getTitle() then
		demo = true
	end
	output[#output + 1] = '<table class="noprint plainlinks shortcutbox" style="float: right; border: 1px solid #aaa; background: #fff; margin: .3em .3em .3em 1em; padding: 3px; text-align: center;"><tr><th style="border: none; background: transparent;"><small>'

	if args.temp then
		output[#output + 1] = "[[kurterê|Kurterêya Demkî" .. (args[2] and 's' or '') .. "]]:<br/>"
	else
		output[#output + 1] = "[[kurterê|Kurterê" .. (args[2] and '' or '') .. "]]:<br/>"
	end
	
	local attn = false

	for i, shortcut in ipairs(args) do
		local title = mw.title.new(shortcut)
		
		if not title then
			output[#output + 1] = '<span class="attentionseeking">(<code>' .. mw.text.nowiki(shortcut) .. '</code>)</span><br/>'
			attn = true
		else
			local iattn = false

			local item

			if not title.exists then
				attn = true --preload naxebite nizanim çima. Kes dizane?
				local query = 'action=edit&redlink=1&preloadtext=' .. mw.uri.encode('#BERALÎKIRIN [[' .. FULLPAGENAME .. ']]')
				if title.nsText == "Şablon" then
					item = '<code>{{[' .. tostring(mw.uri.fullUrl(shortcut, query)) .. ' <span style="color:#c20;">' .. title.text .. '</span>]}}</code>'
				else
					item = '[' .. tostring(mw.uri.fullUrl(shortcut, query)) .. ' <span style="color:#c20;">' .. shortcut .. '</span>]'
				end
			else
				if title.nsText == "Şablon" then
					item = '<code>{{[' .. tostring(mw.uri.fullUrl(shortcut, 'redirect=no')) .. ' ' .. title.text .. ']}}</code>'
				else
					item = '[' .. tostring(mw.uri.fullUrl(shortcut, 'redirect=no')) .. ' ' .. shortcut .. ']'
				end
				
				if not demo then
					local redirectTarget = title.redirectTarget
					if redirectTarget then
						redirectTarget.fragment = '' -- remove fragment, if present
						local targetText = redirectTarget.fullText
						if title.nsText == "Şablon" then
							if SUBPAGENAME == 'belge' then
								iattn = (targetText ~= BASEPAGENAME)
							else
								iattn = (targetText ~= FULLPAGENAME)
							end
						else
							if SUBPAGENAME == 'belge' then
								iattn = not (targetText == BASEPAGENAME
									or targetText == FULLPAGENAME)
							else
								iattn = not (targetText == FULLPAGENAME
									or targetText == FULLPAGENAME .. '/belge')
							end
						end
					end
					
					if not (redirectTarget and redirectTarget.exists) then
						iattn = true
					end
				end
			end

			if iattn then
				item = '<span class="attentionseeking">' .. item .. '</span>'
			end

			output[#output + 1] = item .. '<br/>'
			
			attn = attn or iattn
		end
	end

	if not args.nocat then
		if attn then
			output[#output + 1] = '[[Kategorî:Daxwazên lênêrîna kurterêyan]]'	
		end
		if SUBPAGENAME ~= 'belge' then
			output[#output + 1] = '[[Kategorî:Rûpelên Wîkîferhengê bi kurterêyan]]'
		end
	end

	output[#output + 1] = '</small></th></tr></table>'
	
	return table.concat(output)
end

return export