Marvel Wiki
Advertisement

Bu modül için bir Modül:Design/belge belgelendirmesi oluşturabilirsiniz

local p = {}
local h = require("Modül:HF")
local getArgs = require('Dev:Arguments').getArgs


--------------------------------------------------------------------------------
--[[
function p.get_main_border_color()
	return '#B5B7CF'
end

function p.get_main_background_color()
	return '#EFF0FF'
end
]]--


--------------------------------------------------------------------------------------------
-- used in Template:Navigation Gallery
function p.create_navigation_gallery(frame)
	local args = getArgs(frame)
	local list = args.list
	local image_size = args.size or '150'
	local noimage = args.noimage or 'No Image Available.png'
	local orientation = args.orientation or 'square' -- none/landscape/portrait/square 
	local spacing = args.spacing or 'medium' -- small/medium/large
	local crop = args.crop
	local image
	local text
	local link1
	local link2 
	local i
	local div = mw.html.create('div'):attr('class', 'navfaces')
	local output = ''
	
	if not h.isempty(list)
		then
			list = mw.text.split(list, '\n')
			output = {}
			for i = 1, #list do
				if string.find(list[i], ';') ~= nil
					then text, image = string.match(list[i], '(.+);(.+)')
					else 
						text = list[i]
						image = noimage
				end
				link1 = string.match(text, '%[%[(.-)%]%]')
				link2 = string.match(text, '%[%[(.-)%|.-%]%]')
				if link2 ~= nil
					then link1 = link2
				end
				table.insert(output, '\n'..image..'|'..text..'|link='..link1)
			end
			output =	frame:extensionTag{ 
							name = 'gallery', 
							content = table.concat(output), 
							args =	{ 
										widths = image_size, 
										orientation = orientation, 
										spacing = spacing,
										position = 'center',
										captionalign = 'center',
										captionsize = 'large',
										navigation = 'true'
									} 
						}
			if h.isempty(crop) -- used to prevent cropping of images and focus on the top of the image
				then output = tostring( div:wikitext(output) )
			end
	end

	return output
end


--------------------------------------------------------------------------------
-- used in Template:Power Link
function p.power_link(frame)
	local args = getArgs (frame)
	local link = args[1]
	local text = args[2]
	local output_category = ''
	local output = ''
	
	if not h.isempty(link)
		then
			if h.isempty(text)
				then text = link
			end
			
			if h.exists('Sözlük:'..link)
				then output = h.Link('Sözlük:'..link, text)
				elseif h.exists(link)
					then output = h.Link(link, text)
				elseif h.exists('Kategori:'..link)
					then output = h.LinkToCategory(link, text)
				else output = text
			end
			
			output_category = h.Category(link)
	end
	
	return output..output_category
end


--------------------------------------------------------------------------------
function p.green(text)
	local output = ''
	if not h.isempty(text)
		then 
			output = mw.html.create( 'span' )
				:addClass('green_text')
				:wikitext('('..text..')')
				:done()
			output = tostring(output)
	end
	return output
end


--------------------------------------------------------------------------------
function p.span(text)
	local italic = mw.html.create( 'span' ):css( 'font-style', 'italic' )
	local bold = mw.html.create( 'span' ):css( 'font-weight', 'bold' )
	local both = mw.html.create( 'span' ):css( 'font-weight', 'bold' ):css( 'font-style', 'italic' )
	local output = { italic = '', bold = '', both = '' }
	
	if not h.isempty(text)
		then
			output = {
				italic  = tostring(italic:wikitext(text):done()),
				bold	= tostring(bold:wikitext(text):done()),
				both	= tostring(both:wikitext(text):done()),
			}
	end

	return output
end


--------------------------------------------------------------------------------
-- creates message box
function p.messagebox(frame)
	local args = getArgs (frame)
	local width = args['width'] or '95%'
	local textalign = args['text-align'] or 'center'
	local fontsize = args['font-size'] or '100%'
	local border = args['border']
	local background = args['background']
	local margin = args['margin'] or '1em'
	local clear = args['clear'] or 'none'
	local padding = args['padding'] or '5px'
	local extrastyle = args['extrastyle'] or ''
	local message = args[1] or args['mesaj'] or ''
	
	local tag = mw.html.create( 'div' )
				:attr( 'id', 'messageBox' )
				:attr( 'align', 'center' )
				:css( 'width', width )
				:css( 'text-align', textalign )
				:css( 'font-size', fontsize )
				:css( 'border', '1px solid' )
				:css( 'border-radius', '10px' )
				:css( 'margin', margin )
				:css( 'clear', clear )
				:css( 'padding', padding )
				:wikitext( message )
				:done()
	if not h.isempty(background)
		then tag:css('background-color', background)
		else tag:addClass('main_background_color')
	end
	
	if not h.isempty(border)
		then tag:css('border-color', border)
		else tag:addClass('main_border_color')
	end
				
	if not h.isempty(extrastyle)
		then tag:cssText (extrastyle):done()
	end
	
	return tostring(tag)
end


--------------------------------------------------------------------------------
-- creates message box with spoiler warning 
function p.spoiler_warning()
	local background = 'rgb(142,17,22,255)'
	local border = 'rgb(255,102,102,255)'
	local extrastyle = 'color: white; clear: both;'
	local header = p.span('Spoiler Warning!').bold
	local message = '<br>Bu sayfa, henüz yayınlanmış içeriklerin hikayesine veya bitiş detaylarına dair spoiler içermektedir.<br>'
	message = message..'[[Marvel Wiki:Spoiler|Spoiler Politikası]]'

	return p.messagebox( {mesaj = header..message, background = background, border = border, extrastyle = extrastyle}) 
end


--------------------------------------------------------------------------------
-- creates table with "previous" and "next" sections
function p.table_previous_and_next(message, link_to_previous, link_to_next)
	local td_left = mw.html.create('td')
					:css('width', '10%')
					:css('max-width', '20%')
					:css('text-align', 'left')
	local td_right = mw.html.create('td')
					:css('width', '10%')
					:css('max-width', '20%')
					:css('text-align', 'right')
	local td_left_arrow = mw.html.create('td')
					:css('vertical-align', 'middle')
					:css('font-size', '18px')
					:css('width', '1%')
					:wikitext('←')
	local td_right_arrow = mw.html.create('td')
					:css('vertical-align', 'middle')
					:css('font-size', '18px')
					:css('width', '1%')
					:wikitext('→')
	local td_empty = mw.html.create('td')
					:css('width', '11%')
	local tr = mw.html.create('tr')
	local left = ''
	local right = ''
	local output = mw.html.create('table')
					:css('width', '100%')
			
	if h.isempty(message)
		then message = ''
	end
	message = tostring( mw.html.create('td'):wikitext(message) )
	
	if h.isempty(link_to_previous)
		then left = tostring(td_empty)
		else left = tostring(td_left_arrow)..tostring(td_left:wikitext(link_to_previous))
	end
	if h.isempty(link_to_next)
		then right = tostring(td_empty)
		else right = tostring(td_right:wikitext(link_to_next))..tostring(td_right_arrow)
	end
	tr = tostring( tr:wikitext(left..message..right) )
	output = tostring( output:wikitext(tr) )
			
	return output
end

--------------------------------------------------------------------------------
function p.show_hide(frame)
	local args = getArgs (frame)
	local title = args['title'] or args['header'] or ' '
	local body = args['body'] or args['text'] or ''
	local collapsed = args['collapsed']
	local clear = args['clear'] or 'both'
	local border = args['border']
	local extrastyle = args['extrastyle'] or ''
	local extrastyle2 = args['extrastyle2'] or ''
	local titlestyle = args['titlestyle'] or ''
	local width = args['width'] or '100%'
	local background = args['background']
	local expandtext = args['expandtext'] or 'Genişlet'
	local collapsetext = args['collapsetext'] or 'Daralt'

	if h.isempty(collapsed) or collapsed == 'true' or collapsed == true
		then collapsed = ' mw-collapsed'
		else collapsed = ''
	end

	body = mw.html.create( 'div' )
			:addClass('mw-collapsible-content')
			:css('background-color', 'transparent')
			:wikitext(body)
			:done()
	body = tostring(body)

	title = mw.html.create( 'div' )
			:css('font-weight', 'bold')
			:wikitext(title)
			:done()
	if not h.isempty(background)
		then title:css('background-color', background)
		else title:addClass('main_background_color')
	end
	if not h.isempty(titlestyle)
		then title:cssText (titlestyle):done()
	end
	title = tostring(title)
	
	body = mw.html.create( 'div' )
			:addClass('mw-collapsible'..collapsed)
			:attr('data-expandtext', expandtext)
			:attr('data-collapsetext', collapsetext)
			:css( 'width', width )
			:css( 'border', '1px solid' )
			:css( 'font-size', '12px' )
			:css( 'clear', clear )
			:wikitext(title..body)
			:done()
	if not h.isempty(border)
		then body:css('border-color', border)
		else body:addClass('main_border_color')
	end
	if not h.isempty(extrastyle)
		then body:cssText (extrastyle):done()
	end

	return tostring(body)
end


--------------------------------------------------------------------------------
function p.add_header(text, level, align)
	local output = ''
	level = level or '2'
	align = align or 'left'
	
	if not h.isempty(text)
		then output = '\n'..tostring( mw.html.create( 'h'..level ):css('text-align', align):wikitext( text ) )
	end
	
	return output
end


--------------------------------------------------------------------------------
function p.lua_add_tooltip(text, tooltip)
	local output = mw.html.create('span')
					:css('border-bottom', '1px dotted')
					:css('cursor', 'help')
					:attr('title', tooltip)
					:wikitext(text)
	return tostring(output)
end



--*******************************************************************************************
-- ************* functions for related sites *************
local list_of_sites = {
	['Marvel']		= {'http://www.marvel.com', 'Marvel.com', 'http://www.marvel.com/characters/'},
	['Wikipedia']	= {'Wikipedia', 'Wikipedia.org'},
	['IMDB']		= {'http://www.imdb.com', 'IMDB.com', 'http://www.imdb.com/title/tt'},
	['AM']			= {'http://www.allmovie.com', 'AllMovie.com', 'http://www.allmovie.com/movie/'},
	['MCU'] 		= {'w:c:marvelcinematicuniverse', 'Marvel Cinematic Universe wiki'}, -- https://marvelcinematicuniverse.fandom.com/wiki/
	['MM']			= {'w:c:marvel-movies', 'Marvel Movies wiki'}, -- https://marvel-movies.fandom.com/wiki/
	['SMF'] 		= {'w:c:spiderman-films', 'Spider-Man Films wiki'}, -- https://spiderman-films.fandom.com/wiki/
	['XM']			= {'w:c:xmenmovies', 'X-Men Movies wiki'}, -- https://xmenmovies.fandom.com/wiki/
}

--------------------------------------------------------------------------------
-- used in Marvel Database:Film Template
function p.get_related_site_label(frame)
	local args = getArgs(frame)
	local site = args[1]
	local info = list_of_sites[site]
	
	if h.in_list({'IMDB', 'AM', 'Marvel'}, site)
		then output = '- ['..info[1]..' '..info[2]..']'
		elseif site == 'Wikipedia'
			then output = '- '..h.Link(info[1]..':', info[2])
		else output = '- '..h.Link(info[1], info[2])
	end
	
	return output
end


--------------------------------------------------------------------------------
-- used in Marvel Database:Film Template
function p.get_related_site_link(frame)
	local args = getArgs(frame)
	local site = args[1]
	local link = args[2]
	local text = args[3]
	local info = list_of_sites[site]
	local output = ''

	if not h.isempty(link)
		then 
			if h.isempty(text)
				then text = link
			end
			if h.in_list({'IMDB', 'AM', 'Marvel'}, site)
				then output = '['..info[3]..link..' '..text..']'
				else output = h.Link(info[1]..':'..link, text)
			end
	end
	
	return output
end


--*******************************************************************************************
-- *************   functions for INFOBOX templates (most of them are called from 'Marvel Database:__' templates, like 'Marvel Database:Character Template')  *************
--------------------------------------------------------------------------------
-- puts text into collapsible div - for fields with a lot of text
function p.add_infobox_row_collapsible(frame)
	local args = getArgs (frame)
	local value = args[1]
	local i
	local j
	local output = ''

	if not h.isempty(value)
		then
			i, j = string.find(string.lower(value), '; eskiden ') 
			if i ~= nil 
				then output = string.sub(value, 1, i-1) .. '<br>' .. p.show_hide( { title = 'Eskiden',  body = string.sub(value, j+1, #value) } )
				elseif #value > 500
					then 
						output = p.show_hide( {
						title = '', 
						body = value, 
						collapsed = 'true',
						extrastyle = 'border: none;',
						} )
				else
					output = value
			end
	end

	return output
end


--------------------------------------------------------------------------------
function p.add_infobox_page_title(frame)
	local standard = require("Modül:StandardizedName")
	local pagename = mw.title.getCurrentTitle().text
	local sortname = ''
	local args = getArgs (frame)
	local page_type = args.page_type
	local title = args.Title or args.EpisodeTitle
	local alias = args.CurrentAlias
	local name = args.Name
	local image = args.Image
	local noimage = args.NoImage
	local info
	local output_categories = {}
	local output = ''

	if not h.isempty(title)
		then output = title
		elseif not h.isempty(alias)
			then output = alias
		elseif not h.isempty(name)
			then output = name
		else output = string.gsub(pagename, ' %(.+%)', '')
	end

	if not h.is_link(output) and h.exists(output)
		then output = h.Link(output)
	end
	
	if page_type == 'Bölüm'
		then output = '"'..string.gsub(output, '"', '')..'"'
	end
	
	-- add default sort name
	if page_type == 'Gerçeklik'
		then 
			table.insert(output_categories, 'Gerçeklikler')
			sortname = '{{DEFAULTSORT:'..require("Modül:Reality").get_reality_info({pagename}).padded_number..'|noerror}}'
		elseif page_type == 'Dizi'
			then 
				sortname = '{{DEFAULTSORT:'..standard.lua_remove_the(pagename)..'|noerror}}'
		elseif h.in_list({'Film', 'Roman', 'Video oyunu'}, page_type) 
			then
				table.insert(output_categories, page_type..'ler')
				sortname = '{{DEFAULTSORT:'..standard.lua_remove_the(pagename)..'|noerror}}'
		elseif h.in_list({'Bölüm', 'Çizgi roman'}, page_type) 
			then
				if page_type == 'Bölüm'
					then info = standard.lua_get_title_volume_issue(pagename, 'Sezon')
					else info = standard.lua_get_title_volume_issue(pagename, 'Vol')
				end
				if not h.isempty(info.title)
					then sortname = info.sortname.all
					else sortname = standard.lua_remove_the(pagename)
				end
				sortname = '{{DEFAULTSORT:'..sortname..'|noerror}}__NOTOC__'
				table.insert(output_categories, page_type..'ler')
				table.insert(output_categories, info.noissue)
		elseif page_type == 'Personel'
			then
				table.insert(output_categories, 'Marvel personelleri')
				sortname = '{{DEFAULTSORT:'..pagename..'|noerror}}'
		else
			table.insert(output_categories, page_type..'ler')
			sortname = '{{DEFAULTSORT:'..standard.name_for_sorting({pagename})..'|noerror}}'
	end
	
	-- add categories for main image
	if not h.isempty(image)
		then 
			image = string.gsub(image, 'Dosya:', '')
			if not h.exists('Dosya:'..image) -- 'Image' field is filled, but such image doesn't exist on wiki
				then table.insert(output_categories, page_type..' Resim Doğrulaması Gerekli')
			end
			if h.in_list({'None.jpg', 'Needed.png'}, image) 
				then table.insert(output_categories, page_type..' Resim Gerekli')
			end
		elseif not h.isempty(noimage) and string.lower(noimage) == 'yes'
			then table.insert(output_categories, 'Görülmeyen '..h.get_plural_page_type(page_type) )
		else table.insert(output_categories, page_type..' Image Needed')
	end

	return frame:preprocess(output..sortname)..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------
function p.add_infobox_gallery(frame)
	local pagename = mw.title.getCurrentTitle().text
	local args = getArgs (frame)
	local page_type = args.page_type
	local noimage = args.NoImage
	local image = args.Image
	local image_text = args.ImageText
	local output_categories = {}
	local output = ''

	if page_type ~= 'Personel' 
		then
			if h.exists(pagename..'/galeri')
				then output = h.Link(pagename..'/galeri', 'Galeri')
				elseif h.isempty(noimage) and page_type ~= 'Kullanıcı'
					then
						output = h.Link(pagename..'/galeri', 'Galeri')
						table.insert(output_categories,  page_type..' Galeri Sayfası Gerekli')
			end
		elseif not h.isempty(image_text)
			then output = tostring(image_text)			
	end

	return output..h.add_categories(output_categories)
end


-------------------------------------------------------------------------------
function p.add_infobox_official_name(frame)
	local args = getArgs (frame)
	--local page_type = args.page_type
	local name = args.Name
	local name2 = args.Name2
	local ref = args.NameRef
	local output = ''
	
	if not h.isempty(args.Name)
		then 
			name = args.Name
			name2 = args.Name2
			ref = args.NameRef
		elseif not h.isempty(args.OfficialName)
			then
				name = args.OfficialName
				name2 = args.OfficialName2
				ref = args.OfficialNameRef
		elseif not h.isempty(args.RealName)
			then
				name = args.RealName
				name2 = args.RealName2
				ref = args.RealNameRef	
	end
	
	if h.isempty(name)
		then output = 'Bilinmiyor'
		else 
			output = name
			if not h.is_link(output) and h.exists(output)
				then output = h.Link(output)
			end
	end
	if not h.isempty(name2)
		then output = output..' '..name2
	end
	if not h.isempty(ref)
		then output = output..ref
	end

	return output
end


--------------------------------------------------------------------------------
function p.add_infobox_first_appearance(frame)
	local standard = require("Modül:StandardizedName")
	local args = getArgs(frame)
	local page_type = args.page_type
	local value = args.First
	local value2 = args.First2
	local no_wiki_value
	local debut
	local output_categories = {}
	local output = ''

	if not h.isempty(value)
		then 
			no_wiki_value = mw.text.nowiki(value)
			if mw.ustring.find(no_wiki_value, '&#91;&#91;', 1, true) ~= nil
				then 
					debut = string.match(no_wiki_value, '(%d%d%d%d)&#93;&#93;%)') or string.match(no_wiki_value, '(%d%d%d%d)%)')
					output = value
				else
					output, debut = standard.lua_get_link_and_release_date(value)
					if not h.isempty(debut)
						then debut = string.match(debut, '(%d%d%d%d)')
					end
			end
			if not h.isempty(debut)
				then
					if not h.isempty(page_type)
						then table.insert(output_categories, debut..' '..page_type..' çıkışları')
						else table.insert(output_categories, debut..' çıkışları')
					end
			end	
		elseif h.isempty(value2)
			then
				if not h.isempty(page_type)
					then value = page_type..' İlk Görünüm Gerekli'
					else value = 'İlk Görünüm Gerekli'
				end
				table.insert(output_categories, value)
				output = h.LinkToCategory(value, 'Bilinmiyor')
	end
	if not h.isempty(value2)
		then output = output..value2
	end

	return output..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------
function p.add_infobox_last_appearance(frame)
	local standard = require("Modül:StandardizedName")
	local args = getArgs(frame)
	local last_appearance
	local last_appearance2
	local output = ''

	if not h.isempty(args.Death) or not h.isempty(args.Death2)
		then -- for 'Character Template'
			last_appearance = args.Death
			last_appearance2 = args.Death2
	elseif not h.isempty(args.Destruction) or not h.isempty(args.Destruction2)
		then -- for 'Item Template', 'Vehicle Template', 'Location Template', 'Reality Template'
			last_appearance = args.Destruction
			last_appearance2 = args.Destruction2
		else -- for 'Team Template', 'Organization Template', 'Race Template'
			last_appearance = args.Last
			last_appearance2 = args.Last2	
	end

	if not h.isempty(last_appearance)
		then output = standard.lua_get_link_and_release_date(last_appearance)
	end
	
	if not h.isempty(last_appearance2)
		then output = output..last_appearance2
	end

	return output
end


--------------------------------------------------------------------------------
function p.add_infobox_creators(frame)
	local SC = require("Modül:StaffCorrection")
	local args = getArgs(frame)
	local page_type = args.page_type
	local creators = args.Creators
	local creators2 = args.Creators2
	local output_categories = {}
	local output = ''
	
	if not h.isempty(creators)
		then output, output_categories = SC.lua_get_creators(creators)
		elseif not h.isempty(creators2)
			then output = output..creators2
		else table.insert(output_categories, page_type..' Yaratıcıları Gerekli')
	end
	
	return output..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------------------------
function p.add_infobox_identity(frame)
	local args = getArgs (frame)
	local page_type = args.page_type
	local value = args.Identity
	local category = ''
	
	if not h.isempty(value)
		then 
			category = value..' kimlikli '..page_type..'ler'
			value = h.LinkToCategory(category, value)
			category = h.Category(category)
		else value = ''
	end
	if not h.isempty(args.Identity2)
		then value = value..' '..args.Identity2
	end
	
	return value..category
end


--------------------------------------------------------------------------------------------------
function p.add_infobox_status(frame)
	local args = getArgs (frame)
	local value = args.Status
	local page_type = h.get_plural_page_type(args.page_type)

	local output_category = h.Category(value..' '..page_type)
	local output = h.LinkToCategory(value..' '..page_type, value)

	return output..output_category
end


--------------------------------------------------------------------------------------------------
function p.add_infobox_members_group_header(frame)
	local pagename = mw.title.getCurrentTitle().text
	local category = pagename..'/üyeler'
	local n = h.pages_in_category(category, 'pages')
	local output = 'Üyeler'
	
	if n > 0
		then output = h.LinkToCategory(category, output)
	end
	
	return output	
end


--------------------------------------------------------------------------------
function p.add_infobox_reality(frame)
	local module_reality = require("Modül:Reality")
	local args = getArgs (frame)
	local page_type = args.page_type
	local pagename = mw.title.getCurrentTitle().text
	local i
	local reality1 = args.Universe or args.Reality
	local reality2 = args.Universe2 or args.Reality2
	local value
	local category
	local output_categories = {}
	local output = {}

	if h.isempty(reality1) and h.isempty(reality2) 
		then 
			if h.in_list({'/karakterler', '/takımlar', '/organizasyonlar'}, page_type)
				then table.insert(output_categories, 'Belirtilmemiş gerçeklikler')
			end
			if string.find(pagename, '(', 1, true) ~= nil
				then
					_, reality1 = module_reality.lua_get_name_and_reality(pagename)
					reality1 = reality1.name
			end
	end
	
	if not h.isempty(reality1)
		then 
			if string.find(reality1, ';') ~= nil
				then 
					reality1  = mw.text.split(reality1, ';')
					for i = 1, #reality1 do
						value = reality1[i]
						value = module_reality.get_reality_info({value, 1})
						if value ~= nil
							then
								table.insert(output, h.Link(value))
								table.insert(output_categories, value..page_type)
						end
					end
				else
					value = module_reality.get_reality_info({reality1, 1})
					if value ~= nil
						then
							table.insert(output, h.Link(value))
							table.insert(output_categories, value..page_type)
					end
			end
	end
	
	if not h.isempty(reality2)
		then 
			value = module_reality.get_reality_info({reality2, 1})
			if value ~= nil
				then
					table.insert(output, h.Link(value))
					table.insert(output_categories, value..page_type)
				else
					table.insert(output, reality2)
			end
	end
	
	output = mw.text.listToText(output, ', ', ', ')
	
	return output..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------------------------
-- used for 'ProductionCompanies' and 'Network' fields in 'Film Template' and 'Series Template'
function p.get_value_and_category_from_field(frame)
	local args = getArgs(frame)
	local field = args.field
	local i
	local value = ''
	local output_categories = {}
	local output = ''
	
	if not h.isempty(field)
		then
			field = h.explode(";", field)
			output = {}
			for i = 1, #field do
				value = h.trim(field[i])
				if h.exists('Kategori:'..value)
					then
						table.insert(output_categories, value)
						value = h.LinkToCategory(value, value)
				end
				table.insert(output, value)
			end
			output = mw.text.listToText(output, ', ', ', ')
	end
	
	return output..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------
function p.add_overview_and_toc(overview)
	local output = '__TOC__'
	
	if not h.isempty(overview)
		then output = '\n'..overview..'<br>'..output
	end
	
	return output
end


--------------------------------------------------------------------------------
function p.add_quote(args, speaker_needed, source_needed)
	local output_categories = {}
	local output = ''
	
	if not h.isempty(args.Quotation)
		then output, output_categories = require("Modül:Quote").main(args.Quotation, args.Speaker, args.QuoteSource, speaker_needed, source_needed)
	end
	if not h.isempty(args.BlockQuote)
		then 
			output = args.BlockQuote
			table.insert(output_categories, 'BlockQuotes')
	end
	
	return output, output_categories
end

--------------------------------------------------------------------------------
-- used to add sections like "Notes", "Trivia", etc.
function p.add_section(header, section, header_level)
	local output = ''
	
	header_level = header_level or 2
	
	if not h.isempty(section)
		then output = p.add_header(header, header_level)..'\n'..section
	end
	
	return output
end


--------------------------------------------------------------------------------
function p.add_history_section(args, page_type)
    local value = args.History or args.HistoryText
    local category = ''
    local output = ''
    
    if page_type == 'Karakter'
    	then output = p.add_section('Biyografi', value, 2)
    else
    	output = p.add_section('Tarihçe', value, 2)
    			category = page_type .. ' ' .. 'Tarihçe' .. ' Gerekli'
    	end
    
    return output, category
end


--------------------------------------------------------------------------------
-- one function to add 'Quote', 'Overview' section, 'TOC' and 'History' section at the same time
function p.add_quote_overview_toc_history(args, page_type)
	local value
	local categories = {}
	local output_categories = {}
	local output = {}

	value, categories = p.add_quote(args)
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)

	table.insert( output, p.add_overview_and_toc(args.Overview) )
	
	value, categories = p.add_history_section(args, page_type)
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)

	return output, output_categories
end


--------------------------------------------------------------------------------
-- one function to add 'Notes', 'Trivia', 'See Also', 'Recommended Reading' and 'Links and References' sections  at the same time
function p.add_notes_trivia_see_also_recommended_links_references(args, page_type, pagename)
	local value
	local categories = {}
	local output_categories = {}
	local output = {}

	table.insert( output, p.add_section('Notlar', args.Notes, 2) )
	table.insert( output, p.add_section('Diğer', args.Trivia, 2) )

	table.insert( output, p.add_header('Ayrıca bakınız', 2) )
	--add links to standard sub-pages/categories - "Appearances", "Minor Appearances", Mentions", "Images", "Quotes"
	value, categories = p.add_links_to_standard_subpages(pagename, page_type)
	output_categories = h.join_tables(output_categories, categories)
	output = h.join_tables(output, value)
	
	table.insert( output, p.add_section('Tavsiye edilen okuma', args.Recommended, 2) )
	
	table.insert( output, p.add_links_and_references(args, pagename) )

	return output, output_categories
end


--------------------------------------------------------------------------------
-- used to add links to standard sub-pages/categories - "Appearances", "Minor Appearances", Mentions", "Images", "Quotes" 
function p.add_links_to_standard_subpages(pagename, page_type)
	local list_for_reality = {'Karakterler', 'Takımlar', 'Organizasyonlar', 'Konumlar', 'Eşyalar', 'Araçlar', 'Irklar'}
	local s = ''
	local value
	local category
	local output_categories = {}
	local output = {}
	
	value, categories = p.links_to_subcategories(pagename..'/görünümler', 'pages', pagename, ' görünüm ', page_type..' Görünümler Kategorisi Gerekli')
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)
	
	value, categories = p.links_to_subcategories(pagename..'/el kitabı görünümleri', 'pages', pagename, ' el kitabı görünümü ', page_type..' Görünümler Kategorisi Gerekli')
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)
	
	value, categories = p.links_to_subcategories(pagename..'/küçük görünümler', 'pages', pagename, ' küçük görünüm ', page_type..' Küçük Görünümler Kategorisi Gerekli')
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)
	
	value, categories = p.links_to_subcategories(pagename..'/bahsedilmeler', 'pages', pagename, ' bahsedilme ', page_type..' Bahsedilmeler Kategorisi Gerekli')
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)
	
	value, categories = p.links_to_subcategories(pagename..'/el kitabı bahsedilmeleri', 'pages', pagename, ' el kitabı bahsedilmesi ', page_type..' Bahsedilmeler Kategorisi Gerekli')
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)
	
	value, categories = p.links_to_subcategories(pagename..'/yakarışlar', 'pages', pagename, ' yakarış ', page_type..' Bahsedilmeler Kategorisi Gerekli')
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)

	if h.in_list({'Film', 'Dizi', 'Bölüm', 'Video oyunu', 'Kutu oyunu', 'Roman'}, page_type)
		then value, categories = p.links_to_subcategories(pagename..'/resimler', 'files', pagename, ' resim ', page_type..' Resimler Kategorisi Gerekli')
		else value, categories = p.links_to_subcategories(pagename..'/resimler', 'files', pagename, ' resim ', page_type..' Resimler Kategorisi Gerekli')
	end
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)

	value, categories = p.links_to_subcategories(pagename..'/alıntılar', 'pages', pagename, ' alıntı ', 'Alıntılar Kategorisi Gerekli')
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)

	value, categories = p.links_to_subcategories(pagename..' tarafından öldürülür', 'pages', pagename, ' kurban ', 'Kurban Kategorisi Gerekli')
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)

	if page_type == 'Takım' or page_type == 'Organizasyon'
		then
			value, categories = p.links_to_subcategories(pagename..'/üyeler', 'pages', pagename, ' üye ', 'Üyeler Kategorisi Gerekli')
			output_categories = h.join_tables(output_categories, categories)
			table.insert(output, value)
	end
	
	if page_type == 'Irk' 
		then
			value, categories = p.links_to_subcategories(string.gsub(pagename, '%(Irk%)', ''), 'pages', pagename, ' temsilci ', 'Irk Kategorisi Gerekli')
			output_categories = h.join_tables(output_categories, categories)
			table.insert(output, value)
	end
	
	if h.in_list({'Konum', 'Olay', 'Hikaye', 'Hikaye örgüsü'}, page_type)
		then 
			value, categories = p.links_to_subcategories(pagename, 'pages', pagename, ' alakalı makale ', page_type..' Kategorisi Gerekli')
			output_categories = h.join_tables(output_categories, categories)
			table.insert(output, value)	
	end

	if page_type ~= 'Gerçeklik'
		then
			value, categories = p.links_to_subcategories(pagename..'/eşyalar', 'pages', pagename, ' eşya ', 'Eşyalar Kategorisi Gerekli')
			output_categories = h.join_tables(output_categories, categories)
			table.insert(output, value)
		else
			for i = 1, #list_for_reality do
				s = ' '..string.lower(list_for_reality[i])
				value, categories = p.links_to_subcategories(pagename..'/'..list_for_reality[i], 'pages', pagename, s..' kökenli ', list_for_reality[i]..' Kategorisi Gerekli')
				output_categories = h.join_tables(output_categories, categories)
				table.insert(output, value)
			end
	end
	
	if page_type ~= 'Staff' and table.concat(output) == ''
		then table.insert(output_categories, page_type..' altkategorisi olmayan sayfalar')
	end
	
	return output, output_categories
end


function p.links_to_subcategories(category, page_types, pagename, text, needed)
	local n = h.pages_in_category(category, page_types)
	local output_category = ''
	local output = ''

	if n > 0
		then 
			output = '\n* '..h.LinkToCategory(category, n..text..pagename)
			if not h.exists('Kategori:'..category)
				then output_category = needed
			end
	end

	return output, output_category
end


--------------------------------------------------------------------------------
function p.add_links_and_references(args, pagename)
	local list_of_links1 = {"Marvel", "Wikipedia", "IMDB ID", "AM ID", "MCU", "Marvel Movies", "X-Men Movies", "Spider-Man Films"}
	local list_of_links2 = {"Marvel", "Wikipedia", "IMDB", "AM", "MCU", "MM", "XM", "SMF"}
	local i
	local value
	local output = {}
	
	table.insert(output, p.add_header('Bağlantılar ve kaynaklar', 2) )

	for i = 1, #list_of_links1 do
		value = list_of_links1[i]
		if not h.isempty(args[value])
			then 
				value = p.get_related_site_link({list_of_links2[i], args[value], pagename})..' '..p.get_related_site_label({list_of_links2[i]})
				table.insert(output, '\n*'..value)
		end
	end
	
	value = args.OfficialWebsite
	if not h.isempty(value)
		then 
			--value = '<span class="plainlinks">['..value..' Official website of '..pagename..']</span>'
			table.insert(output, '\n'..value)
	end

	value = args.Links
	if not h.isempty(value)
		then table.insert(output, '\n'..value)
	end

	table.insert(output, p.add_list_of_references() )
	table.insert(output, p.add_link_to_twitter())

	return table.concat(output)
end


--------------------------------------------------------------------------------
function p.add_list_of_references()
	local output = mw.html.create('div')
	:css('overflow', 'auto')
	:css('height', 'auto')
	:css('max-height', '250px')
	:css('width', '99%')
	:css('font-size', '12px')
	:css('border', '1px solid #AAAAAA')
	:wikitext('<references group="note" /><references />')

	return p.add_header('Kaynaklar', 3)..'\n'..tostring(output)
end



--------------------------------------------------------------------------------
function p.add_link_to_twitter()
	local output = 	tostring( mw.html.create('span'):attr('id', 'twitter-button') )
	output = mw.html.create('div')
			:css('width', '99%')
			:css('padding', '5px')
			:css('text-align', 'center')
			:css('font-weight', 'bold')
			:css('border-top', '1px solid #AAAAAA')
			:css('border-bottom', '1px solid #AAAAAA')
			:wikitext('Beğendiniz mi? Bizimle paylaşın!   '..output)

	return tostring(output)
end


--------------------------------------------------------------------------------
function p.add_message_for_trn_articles(frame)
	local pagename = mw.title.getCurrentTitle().text
	local link_to_trn = h.Link('Geçici Gerçeklik Numaraları', 'bu')
	local help_text = ''
	local output = ''
	
	if string.find(pagename, 'Dünya-TRN', 1, true) ~= nil
		then 
			help_text = mw.html.create('span'):addClass('messagebox__help'):wikitext('(TRNler hakkında daha fazla bilgi için '..link_to_trn..' sayfayı ziyaret ediniz).')
			output = 'Bu sayfanın teması, resmi birer ada sahip olmayan bir gerçekliğe aittir ve bu yüzden Geçici Gerçeklik Numarası atanmıştır.<br>'
			output = p.messagebox( {mesaj = output..tostring(help_text)})
	end
	
	return output
end


return p
Advertisement