انتقل إلى المحتوى

وحدة:بطاقة/قالب/عتاد الحاسوب

من ويكيبيديا، الموسوعة الحرة

local generic = require( 'وحدة:بطاقة/أدوات' )

function getViaId(localdata,conn,via,viaId)
	if (type(localdata[conn..viaId]) ~= 'string') then return '' end
	local via_Id = {}
	local i = 1 
	local outp =''
	
	while type(localdata[via..viaId.."_" .. i]) == 'string' do
		mw.log(via..viaId.."_" .. i ..mw.dumpObject(localdata[via..viaId.."_" .. i]))
		via_Id[i] = localdata[via..viaId.."_" .. i]
		i = i + 1
	end
	outp = "\n'''" .. localdata[conn..viaId] .."'''"
	if(#via_Id > 0) then
		outp = outp .. " عبر <span>:</span>\n* " .. mw.text.listToText(via_Id, "\n* ", "\n* ")
	end
	return outp;
end

function getItems(localdata,Id)
	local items = {}
	local i = 1 
	local outp =''
	while type(localdata[Id .. i]) == 'string' do
	   items[i] = localdata[Id .. i]
	   i = i + 1
	end
	if( #items > 0) then
	    return mw.text.listToText(items, "<br />", "<br />")
	end
	return nil
end

return  {
    maincolor = '#CEDEFF' -- اللون المستعمل لعنوان البطاقة
    --,wikimod = 'Wikidata.Ca'
    ,parts = { -- محتويات البطاقة
        generic.title(),
        generic.logo(),
        generic.mainimage(),

        {type = 'table' , title ='معلومات عامة' ,rows = {
        {type = 'row' 
                , label = 'تاريخ الاختراع'
                , value = {'تاريخ الاختراع','invent-date',}
                , wikidata = {property='P575'}
        },
        {type = 'row' 
                , label = 'المخترع'
                , value = {'مخترع','invent-name','inventor'}
                , wikidata = {property = "P61"}
        },
        {type = 'row' 
                , label = 'موصل ومرتبط بـ'
                , value = function (localdata)
                	local data = getViaId(localdata,'conn','via',"1") .. getViaId(localdata,'وصل','عبر',"1")
						.. getViaId(localdata,'conn','via',"2") .. getViaId(localdata,'وصل','عبر',"2")
						.. getViaId(localdata,'conn','via',"3") .. getViaId(localdata,'وصل','عبر',"3") 
						.. getViaId(localdata,'conn','via',"4") .. getViaId(localdata,'وصل','عبر',"4")
						if(data =='') then return nil end
						return data
                	end
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = {'class-name','اسم تقسيم'}, defaultlabel = 'تقسيم الاستعمال'
                , value = function (localdata) return getItems(localdata,'class') or getItems(localdata,'قسم') end               
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'أهم المصنّعين'
                , value = function (localdata) return getItems(localdata,'manuf') or getItems(localdata,'صنع') end
                , wikidata = {property='P176'}
        },
        {type = 'row' 
                , label = 'المصمم'
                , value = {'مصمم','designfirm','designer'}
                , wikidata = {property='P287'}
        },
        {type = 'row' 
                , label = 'المصنّع'
                , value = {'manufacturer','مصنع'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'بداية الإنتاج'
                , value = {'introduced','بداية'}
                , wikidata = {property='P571'}
        },
        {type = 'row' 
                , label = 'توقف  الإنتاج'
                , value = {'discontinued','توقف'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'السعر'
                , value = {'سعر','cost','price'}
                --, wikidata = {property='P2284'}
        },
        {type = 'row' 
                , label = 'النوع'
                , value = {'type','نوع'}
                , wikidata = {property='P279'}
        },
        {type = 'row' 
                , label = 'الوظيفة'
                , value = {'وظيفة','usage'}
                , wikidata = {property='P366'}
        },
        {type = 'row' 
                , label = 'جزء من'
                , value = {'جزء من','part of'}
                , wikidata = {property='P361'}
        },
        {type = 'row' 
                , label = 'الأجزاء'
                , value = {'أجزاء','parts'}
                , wikidata = {property='P527'}
        },
        {type = 'row' 
                , label = 'المعالج'
                , value = {'معالج','processor'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'السرعة'
                , value = {'سرعة','frequency'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'الذاكرة'
                , value = {'ذاكرة','memory'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'المعالج المساعد'
                , value = {'coprocessor','مساعد'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'الاتصالات'
                , value = {'connection','اتصالات'}
                , wikidata = {property='2789'}
        },
        {type = 'row' 
                , label = 'المداخل'
                , value = {'ports','مداخل'}
                --, wikidata = {property='P2935'}
        },
        {type = 'row' 
                , label = 'الطاقة المستهلكة'
                , value = {'power','طاقة'}
                --, wikidata = {property='P'}
        },
        {type = 'row' 
                , label = 'الوزن'
                , value = {'وزن','weight'}
                , wikidata={ property = "P2067", formatting='unitcode'}
        },
        generic.dimensions(),
        generic.website(),
        }}
 }
}