Page protected

وحدة:Identifiers

من ويكيبيديا، الموسوعة الحرة
اذهب إلى التنقل اذهب إلى البحث


هذه الوحدة يتم إستخدامها من قبل:

local p = {}
local wd = require('Module:Wikidata2').formatStatementsFromLua
local wd2 = require('Module:Wikidata2').formatEntityId
local Navbox = require('Module:Navbox')
local Uses_Wikidata = require('Module:Uses_Wikidata')._usestable

local props ={
	--'P685'
	}
local props2 ={
	--'P685'
	}

local propslabel ={
	--['P685'] = 'NCBI'
	}
	
local patterns ={
	--['P2752'] = '[http://www.nzor.org.nz/names/$1 NZOR ID]'  ,
	}
	
local url_labels ={
	--['P1421'] = 'GRIN Taxonomy ID'
	}
	
local i8 = {
	["tracking"]='[[تصنيف:معرفات الأصنوفة]]',
	["without"]= "[[تصنيف:معرفات الأصنوفة غير موجودة]]",
	["g1"]=  '[[d:Wikidata:WikiProject_Taxonomy|معرفات الأصنوفة]]',
	["g2"]=  '',
	["name"]=  'Taxonomy bar',
	}

function make_link( label, link )
    if link then
        if label then
            --return '* ' .. label .. ': <span class="uid">' .. link .. '</span>\n'
            return '* <span style="font-style: italic;"><b>' .. label .. '</b></span>: ' .. link .. '\n'
        else
            return "* " .. link .. "\n"
        end
    else
    end
end

function P1629(property)
	local la = propslabel[property] or labelIn('en', property )
	local text = wd({property = 'P1629', nolink = '', entityId = property, firstvalue= 'true', noref = 'true',enlabelcate ='true'
		, label = (la or '') , separator= ", ", conjunction= ", "}) 
	if not text or text == '' then text = la end 
	if text then 
		return text
	end
end

function labelIn(langcode,id) -- returns item label for a given language
	local langcode = langcode --or 'ar'
	local label, lange = mw.wikibase.getLabelWithLang( id )
	if lange == langcode
	then
		return label
	--else
		--return ""
	--return str
	end
	--[[local entity = mw.wikibase.getEntityObject(id)
		if entity
		and entity.labels 
		and entity.labels[''..langcode..'']
		and entity.labels[''..langcode..''].value 
		then
			local lang = entity.labels[''..langcode..'']
				if lang['language'] == langcode then
				return entity.labels[''..langcode..''].value
				else return nil end
		end
	]]
end

function doo( prop, entityclaims, args , taxo )
	pa, pattern, urllabel = '', nil, nil
	if args.noref then ref = '' else ref = '' end
	if args.noquall and  args.noquall ~='' then quall = '' else quall = 't' end
	--pa = labelIn('en' ,prop )
	pa = P1629(prop )
	--paa = mw.wikibase.label( prop ) --wd2(prop, {nolink = 'true',enlabelcate ='t'}).value
	-- pe =  wd({property = 'P1629', entityId = prop , firstvalue= 'true', noref = 'true', label = wd2(prop, {nolink = 'true'}).value})
	if patterns[prop]  then
			pattern = patterns[prop]
			pa = nil
	end
	if url_labels[prop]  then
			urllabel = patterns[prop]
			pa = nil
	end
	po = wd( {property = prop, urllabel=urllabel or '' ,pattern =pattern or 'autourl2', stringpattern = pattern or "",addTrackingCat ='t',noicon='t', separator= ", ", conjunction= ", " }, entityclaims ) --formatStatement( statement, args )
		if po and po ~='' then
			vaa = make_link(pa,po)
		end
	return vaa
end

function barexternal( entity, args , Table )
	local external = {}
	for i, ss in pairs( entity.claims ) do 
		finns = true
		for k, l in pairs(Table) do
			if i == l  then 
				finns = false
			end
		end
		if not finns then
			local entity1 = mw.wikibase.getEntityObject( i )
			--if entity1.datatype == 'external-id' 
				--then
					if args[1] and args[1] ~= ''
					then
						if i == args[1] then vaa = doo( i, entity.claims, args ) else  vaa = ''  end
					else
						vaa = doo( i, entity.claims, args )	
					end
					table.insert( external, vaa )
				end
			--end
		end
	final = table.concat(external)
	if #final ~= 0 then
		final = final .. i8.tracking
	end
	return final 
end

function taxStatement( options )
	local bar2 = ""
	local id = options.entityId or options.id or options['صفحة']
    if id and id ~= '' then
		entity =  mw.wikibase.getEntityObject( id )
	else
		entity =  mw.wikibase.getEntityObject() 
	end
	if not entity then return '' end --TODO error? 
	if not entity.claims then return '' end 
	local bar = barexternal( entity, options  , props ) or ''
	if props2 and props2 ~= {} then 
		bar2 = barexternal( entity, options , props2 ) or ''
	end
	local params = {
		name  =  i8.name ,
		bodyclass = 'hlist',
		list1style  = 'text-align:left;', 
		list2style  = 'text-align:left;', 
		group1 = i8.g1 ,
		group2 = i8.g2
		}
	if (bar and bar ~='') or (bar2 and bar2 ~= "") then
		if bar and bar ~= "" then 
		    if options.list and options.list ~= '' then
				bar = bar .. options.list
			end
			params.list1 = bar
		end
		if bar2 and bar2 ~= "" then 
			params.list2 = bar2
		end
		fi =  Navbox._navbox( params )
	else
		fi =  i8.without
	end
	return fi
end

function p.t( frame )
    local args = frame.args
	return taxStatement( args )
end

function p.Statement_from_lua( options , t )
	i8 = t.I8
	props = t.Props
	url_labels = t.Url_labels
	if t.props2 then 
		props2 = t.props2
	end
	patterns = t.Patterns
	propslabel = t.Propslabel
	return taxStatement( options )
end

function p.make_list2( props )
	local list = mw.html.create("table")
	list:addClass("wikitable sortable collapsible")
	local head = list:tag("tr")
	head:tag("th"):wikitext("الخاصية")
	head:tag("th"):wikitext("الاسم بالإنجليزية")
	head:tag("th"):wikitext("الموضوع")
	for v, o in pairs(props) do 
		local va = P1629( o )
		--local va = wd({property = 'P1629', entityId = o, firstvalue= 'true', noref = 'true'})
		local row = list:tag("tr")
		local rr = row:tag("td")
		local rrr = row:tag("td")
		local rrrr = row:tag("td")
		local yu = labelIn('ar', o ) or labelIn('en', o ) or ""
		rr:tag("span"):wikitext( '[[d:Property:' .. o .. '|' .. '(' .. o .. ') ' .. yu .. ']]' )
		rrr:tag("span"):wikitext(  propslabel[o] or labelIn('en', o ) )
		rrrr:tag("span"):wikitext(  va  ) 
	end
	return list
end
function p.make_list( props )
	props.newtrak  = "s"
	props["newtrak"]  = "s"
	return Uses_Wikidata(props)
end

function p.list( frame )
	return p.make_list( props )
end
return p