توضیحات این پودمان می‌تواند در ماژول:Wikidata2/otheruse/توضیحات قرار گیرد.

local p = {}
local help_functions = require("Module:Wikidata2/functions")

function ifd ( fii , opt )
	if opt and opt ~= '' then
			if opt == 'club' then
					if fii == 'Q476028' then  return fii end
			elseif opt == 'team' then
					if fii == 'Q6979593' or fii == 'Q23895910'  or fii == 'Q23847779'
					then  return fii end
			else return fii 
			end
	end 
--	return dd
end
function p.foot( claims2 , options)
   	local formattedStatements = {}
   	local statementsraw = {}
   	local claims = claims2
	if (options.sortingproperty and options.sortingproperty ~= "") and options.sortbynumber == 'chronological' or options.sortbynumber == 'inverted' then
			claims = help_functions.sortbyqualifiernumber(claims2, options)
	end
	if claims then
		for i, statement in pairs( claims ) do
			options.num = i
			local va = formatOneStatement( statement, nil , options )
			if va.v then
				table.insert( formattedStatements, va.v )
			end
			table.insert( statementsraw, va.raw )
		end
	end
	local tot = mw.text.listToText( formattedStatements, options.separator, options.conjunction )
	if tot == '' then tot = nil end
	if options.raw and options.raw ~= '' then
		return statementsraw
	end
	if options.numberofclaims and options.numberofclaims ~= '' then
		return #formattedStatements
	end
	return tot
end

function p.football( statement , options) -- used by قالب:معلومات صاحب منصب/منصب ويكي بيانات
		local value = statement.mainsnak.datavalue.value
   		local entit = value.id
    	local s = formatSnak( statement.mainsnak, options ).value
		--local s = formatEntityId( entit , options ).value
				local fii = formatStatements( {property ='P31', entityId = entit, noref ='true' ,rank='all'
				, firstvalue='true',separator='',conjunction='',formatting ='raw'})
		local fiind = ifd( fii , options.club )
      if fiind 	and fiind ~= '' then
		if s then
		        local entit = value.id
        		local caca = formatStatements( {property ='P17', entityId = entit
        			, noref ='true' ,rank='all'--,pattern =options.pattern
        			,size ='20',image ='image'
        			,propertyimage ='P41', firstvalue='true',separator='',conjunction=''})
        		
        		local asdf = formatEntityId( entit , options ).value
        			if asdf and asdf  ~= '' then
        		if caca and caca  ~= '' then  s =  caca .. ' '.. asdf   else  s = asdf   end
				end
		if statement.references then
			if options.reff and options.reff ~= ''  then
				reff  = formatReferences( statement, options )
				s = s..reff
			end 
		end
		if statement.qualifiers
			then
			if statement.qualifiers.P1350 or statement.qualifiers.P1351 or statement.qualifiers.P580 or statement.qualifiers.P582 then
					amatch = formatStatements({property = "P1350", firstvalue= 'true'}, statement.qualifiers) or ''
					goal = formatStatements({property = "P1351", firstvalue= 'true'}, statement.qualifiers) or ''
					start1 = formatStatements({property = "P580", firstvalue= 'true',modifytime = 'y'}, statement.qualifiers) or ' '
					finish1 = formatStatements({property = "P582", firstvalue= 'true',modifytime = 'y'}, statement.qualifiers) or ' '
			end
		end
		if options.football1 and options.football1 ~= '' then
					s =mw.getCurrentFrame():expandTemplate{ title = "صندوق معلومات سيرة كرة قدم/سطر فريق"
						, args ={(start1 or '') , (finish1 or '') , s, amatch , goal } }
				end
	
	end
	 return s 
end
end

function p.teams( statement , options)
		local value = statement.mainsnak.datavalue.value
   		local entit = value.id
    	local s = formatSnak( statement.mainsnak, options ).value
		if s then
		        local entit = value.id
        		local asdf = formatEntityId( entit , options ).value
        		 s = asdf 
		if statement.references then
			if options.reff and options.reff ~= ''  then
				reff  = formatReferences( statement, options )
				s = s..reff end 
		end
		if statement.qualifiers
			then
				function ww(p)
    				if p and p ~='' then return formatStatements({property =p, firstvalue= 'true'}, statement.qualifiers) end
				end
					Q1 = ww(options.Q1)
					Q2 = ww(options.Q2)
					Q3 =  ww(options.Q3)
					Q4 =  ww(options.Q4)
					Q5 =  ww(options.Q5)
					Q6 =  ww(options.Q6)
					Q7 =  ww(options.Q7)
					Q8 =  ww(options.Q8)
					Q9 =  ww(options.Q9)
					Q10 =  ww(options.Q10)
		end
		if options.template and options.template ~= '' then
				doo =mw.getCurrentFrame():expandTemplate{ title =options.template, args ={Q1,s,Q2,Q3,Q4,Q5,Q6,Q7,Q8,Q9,Q10} }
				end
	end
	 return doo..'\n'
end

function p.awards( datavalue, datatype, options ) -- used by template:ص.م/سطر جوائز ويكي بيانات
	if datatype == 'wikibase-item'  
		then
	        	local value= datavalue.value
	        local image = formatStatements( {property ='P2425' , entityId = value.id
	        	, noref =options.noref , size ='30', image ='yes', noref='true' , firstvalue='true'})
	        local image2 = formatStatements( {property ='P154' , entityId = value.id
	        	, noref =options.noref , size ='30', image ='yes', noref='true' , firstvalue='true'})
		local categoryid = formatStatements( {property ='P2517', entityId = value.id, noref ='true'
				, firstvalue='true',separator='',conjunction='',formatting ='raw'})
		local categoryid2 = formatStatements( {property ='P910', entityId = value.id, noref ='true'
				, firstvalue='true',separator='',conjunction='',formatting ='raw'})

		if not image or image == '' then image =image2 end
		if not categoryid or categoryid == '' then categoryid = categoryid2 end

			local category = mw.wikibase.sitelink( categoryid )
	        local s = formatEntityId( value.id, options ).value
		   if s and s  ~= '' then
		   			if image and image ~= '' then
		   				s = image ..' ' .. s
	   				end
		       	if category and category  ~= '' 
		       		then 
							return  s.. ' [[' ..category ..']]'
	  			else 
	  				return s 
		       	end
		end
	else  return ''
	end
end

function p.office3( statement , options) -- used by قالب:معلومات صاحب منصب/منصب ويكي بيانات
		local value = statement.mainsnak.datavalue.value
   		local entit = value.id
    	local s = formatSnak( statement.mainsnak, options ).value

		if s then
		        local entit = value.id
        		local ca1 = formatStatements( {property ='P154', entityId = entit
        			, noref ='true' ,rank='all'	,size ='35',image ='image', firstvalue='true',separator='',conjunction=''})
        		local ca2 = formatStatements( {property ='P41', entityId = entit
        			, noref ='true' ,rank='all'	,size ='35',image ='image', firstvalue='true',separator='',conjunction=''})
        		if ca1 and ca1 ~= '' then  caca  =  ca1  else  caca  = ca2 end

        		local asdf = formatEntityId( entit , options ).value
        			if asdf and asdf  ~= '' then
        		if caca and caca  ~= '' then  s =  caca .. ' '.. asdf   else  s = asdf   end
				end
		if statement.references then
			if options.reff and options.reff ~= ''  then
				reff  = formatReferences( statement, options )
				s = s..reff
			end 
		end
		if statement.qualifiers
			then
				if statement.qualifiers.P580 or statement.qualifiers.P582 or statement.qualifiers.P1365 or statement.qualifiers.P1366 then
					start	=	formatStatements({property = "P580", firstvalue= 'true',modifytime = 'longdate'}, statement.qualifiers) or ' '
					finish	=	formatStatements({property = "P582", firstvalue= 'true',modifytime = 'longdate'}, statement.qualifiers) or ' '
					before	=	formatStatements({property = "P1365", firstvalue= 'true'}, statement.qualifiers) or ' '
					after	=	formatStatements({property = "P1366", firstvalue= 'true'}, statement.qualifiers) or ' '
					constituency	=	formatStatements({property = "P768"}, statement.qualifiers) or ' '
					series	=	formatStatements({property = "P1545", firstvalue= 'true'}, statement.qualifiers) or ' '
					electedin	=	formatStatements({property = "P2715"}, statement.qualifiers) or ' '
					P1001	=	formatStatements({property = "P1001"}, statement.qualifiers) or ' '
					P108	=	formatStatements({property = "P108"}, statement.qualifiers) or ' '
					P642 = formatStatements({property = "P642"}, statement.qualifiers) or ' '
					president = formatStatements({property = "P325"}, statement.qualifiers) or ' '
					premier= formatStatements({property = "P6"}, statement.qualifiers) or ' '

			end
		end
		if options.office2 and options.office2 ~= '' then
							s = mw.getCurrentFrame():expandTemplate{ title = "معلومات صاحب منصب/منصب ويكي بيانات/نواة"	, 
				args = {office = s
						, termstart = start
						, termend = finish
						, constituency = constituency
						, predecessor = before
						, successor = after
						, president= president
						, premier = premier
						, series= series
						, electedin=electedin
						, jurisdiction=P1001
						, employer=P108
						, of=P642
						, entityId=options.entityId}
					} 
				end
	
	end
	 return s 
end



function p.formatI( datavalue, datatype, options )
	local value= datavalue.value
	local image = '[[File:' .. value
		if options['border'] and options['border'] ~= '' then 	image = image .. '|border' end
	    if options['size'] and options['size'] ~= '' then image = image .. '|' .. options['size']  end
	    if options['alt'] and options['alt'] ~= '' then image = image .. '|' .. options['alt'] end
	image = image .. ']]'
    return image
end


function p.rree( datavalue, datatype, options )
	if datatype  == 'wikibase-item'  then
    	local value= datavalue.value
 	return datavalue.value.id .. formatEntityId( datavalue.value.id, options ).value   	

 else  return 'datatype  isn\'t wikibase-item' 
	end
end

function p.rrrrrr( datavalue, datatype, options )
	if datatype  == 'wikibase-item'  then

	local label = labelIn('ar',datavalue.value.id)
	local link = mw.wikibase.sitelink( datavalue.value.id)

    if link and (not options.nolink or options.nolink == '') then
        if label and label ~= '' then
            return '[[:' .. link .. '|' .. formatcharacters(label, options) .. ']]' 
        else
            return '[[:' .. formatcharacters(link, options) .. ']]' 
        end
    else
    	if label and label ~= '' then
    		return formatcharacters(label, options) 
    	else return ''
end
    	return ''
    end
 else  return 'datatype  isn\'t wikibase-item' 
	end
end


function p.monolingualtext( datavalue, datatype, options )

	if datatype == 'monolingualtext' then
		
		if not options.langpref or options.langpref == '' then
			valu = mw.text.tag('span', {title = mw.language.fetchLanguageName(datavalue.value.language, 'ar')}, datavalue.value.text)
			lange = '('.. mw.language.fetchLanguageName(datavalue.value.language, 'ar')..')'

		else
			if options.langpref == datavalue.value.language then
				valu  = mw.text.tag('span', {title = mw.language.fetchLanguageName(datavalue.value.language, 'ar')}, datavalue.value.text)
				lange = '('.. mw.language.fetchLanguageName(datavalue.value.language, 'ar')..')'
			end
		end
		if options.showlang and options.showlang ~= '' 
		then return  valu  ..' '..lange
		else return valu
			end


    else
        return formatError( 'unknown-datatype' )
    end
 end
    
function p.rr( datavalue, datatype, options )
	if datatype  == 'wikibase-item'  then
    	local value= datavalue.value
 	return datavalue.value.id .. formatEntityId( datavalue.value.id, options ).value   	

 else  return 'datatype  isn\'t wikibase-item' 
	end
end

function p.getpropertyfromvalue( datavalue ,datatype , options)

	if datatype == 'wikibase-item'  
		then
	
	        		local value= datavalue.value
	        		local caca = formatStatements( {
	        			 property =options.prop2 , entityId = value.id
	        			, noref =options.noref , rank=options.rank	
	        			, size =options.size	, image =options.image
	        			, noref='true' , firstvalue='true'
	        			, propertyimage =options.prop3
	        			}
	        		)
	        		local asdf = formatEntityId( value.id, options ).value
		    if asdf and asdf  ~= '' then
		        	if caca and caca  ~= '' 
		        		then 
								return  caca ..' '.. asdf
		    			else return asdf  
		        	end
			end

		else  return 'datatype  isn\'t wikibase-item' 
	end
end


function p.formatCommonsCategory( datavalue, datatype, options )
	   if datatype == 'commonsMedia'  then

    local link = 'commons:Category:' .. datavalue.value
    local title = datavalue.value
    if ( options['text'] and options['text'] ~= '' ) then
    	title = options['text']
    end

	commons = '[[' .. link .. '|' .. title .. ']]'

	--Commons icon
    if ( not options['icon'] or options['icon'] ~= '-' ) then
    	local icon_size = '15px'
    	if ( options['icon_size'] and options['icon_size'] ~= '' ) then
    		icon_size = options['icon_size']
    	end
    	commons = '[[File:Commons-logo.svg|' .. icon_size .. '|link=' .. link .. ']] ' .. commons
    end

	--Text before and after link
    if ( options['text_before'] and options['text_before'] ~= '' ) then
    	if ( options['text_before'] ~= '-' ) then
	    	commons = options['text_before'] .. ' ' .. commons
	    end
	else
    	commons = '\'\'\' ' .. commons
    end

    if ( options['text_after'] and options['text_after'] ~= '' ) then
    	if ( options['text_after'] ~= '-' ) then
	    	commons =  commons .. ' ' .. options['text_after']
	    end
	else
		commons =  commons .. ' \'\'\' على [[كومنز]]'
    end
	
    return commons
end
end

--[[
	this is like p.formatPlaceWithQualifiers in ru:Модуль:Wikidata/Places
]]
function p.PlacesWithLocatedIn( datavalue, datatype, options )
	if datatype == 'wikibase-item'  
		then
			function P131 (id,formatting,p)
				st = formatStatements( {property =p or 'P131' , entityId = id, noref ='t', firstvalue='true',formatting=formatting})
				--if id == st then st = nil end
				return st
			end
		local value= datavalue.value
		local v = formatEntityId( value.id, options ).value
		local P1 = P131(value.id,'') 
		local P1id = P131(value.id,'raw')	
		local P2 = P131(P1id,'') 
		local P2id = P131(P1id,'raw')	
		local P3 = P131(P2id,'') 
		local P3id = P131(P2id,'raw')
		local P4 = P131(P3id,'') 
		--table.insert(tt , v)
			function dd (s1 ,s2 ,s3 )
				if s1 and s1 ~= '' then
					if s2 and s2 ~= '' 
						then 
							return  s1 .. '، '..  s2
						else 
							if s1 == s3 
								then return s1 
								else return s1 .. '، '..  s3
							end
					end
				end
			end
		    if v and v  ~= '' 
		    	then
					val = dd(v,dd(P1
									,dd(
										P2,dd(P3
												,P4
												, P131(P3id,'','P17')
											)
										, P131(P2id,'','P17')
										)
								, P131(P1id,'','P17')
								) 
							, P131(value.id,'','P17')
							) 
			end
		return val
		else
			return 'datatype  isn\'t wikibase-item' 
	end
end

return p