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

وحدة:Cite

صفحة محمية جزئيًّا (سماح للمحررين)
من ويكيبيديا، الموسوعة الحرة

localp={}

ifnil~=string.find(mw.getCurrentFrame():getTitle(),"ملعب",1,true)then-- did the {{#invoke:}} use sandbox version?
wikidata=require("وحدة:Wikidata2/ملعب").formatStatementsFromLua
else-- otherwise
wikidata=require("وحدة:Wikidata2").formatStatementsFromLua
end

localquall=require("Module:Cite/quall")
localfunctions=require("Module:Cite/functions")

localOptions={}

localfunctiongetentityprop(entity,p,pattern)
-- get automatically url
localaddTracking=""
localPattern=patternor"autourl4"--autourl3
ifp=="P345"then
Pattern=""
addTracking=""
end

localtot=wikidata({textformat="text",property=p,pattern=Pattern,numval=5,noref="true",conjunction="&",enlabelcate="true",addTrackingCat=addTracking,noicon="t",raw2=Options.rawor""})
ifnottotortot==""then
tot=wikidata({textformat="text",entityId=entity,property=p,pattern=Pattern,noref="true",conjunction="&",enlabelcate="true",addTrackingCat=addTracking,noicon="t",raw2=Options.rawor"",numval=5})
end

localtot2=""
ifp=="P345"then
tot2=functions.make_P345_link_o(tot)
end
iftot2andtot2~=""then
tot="["..tot2..""..tot2.."]"
end
iftotandtot~=""then
tot="وصلة:"..tot
end
returntot
end

--[[
يجلب خواص معينة عند وجود مراجع محددة مسبقاً
--]]
localfunctiongetsomequall(entity,snak,property)
if
snak[property]andsnak[property][1]andsnak[property][1].datavalueand
snak[property][1].datavalue.value["numeric-id"]
then
id=snak[property][1].datavalue.value["numeric-id"]
locall10n=quall[id]
ifl10nthen
localq={}
for_,vinpairs(l10n)do
mw.log("Module:Cite finding"..v[1]..",id:"..id..",3:"..(v[3]or""))
b=getentityprop(entity,v[1],v[3])
ifbandb~=""then
table.insert(q,b)
mw.log("Module:Cite b"..b)
end
end
t=table.concat(q)
iftandt~=""then
returnt
end
end
end
end

localfunctionValueFromItem(items,property,firstvalue)
localpattern="autourl"
ifproperty=="P212"orproperty=="P957"then
pattern=nil
end-- no automatic link for ISBN
fori,iteminpairs(items)do
ednumber=wikidata({textformat="text",entityId=item,property=property,firstvalue=firstvalue,pattern=pattern,noref="true",modifytime="longdate",enlabelcate="true",numval=5})
end
returnednumber
end

localfunctionValueFromEntityId(entity,property,firstvalue)
localpattern="autourl"
val=wikidata({textformat="text",entityId=entity,property=property,firstvalue=firstvalue,pattern=pattern,noref="true",modifytime="longdate",enlabelcate="true",numval=5})
ifvalthen
returnval
end
end

--local function GetValueFromEntityId(snak,entity, property, firstvalue)
localfunctionGetValueFromEntityId(snak,property,firstvalue)
--local A = wikidata({ textformat = "text",property = "P1629", entityId=property,enlabelcate= "true", firstvalue= "true", noref= "true", label = functions.get_property_label( property )})
localA=functions.get_property_label(property)
localPattern="autourl"
ifproperty=="P345"then
Pattern=""
end
localprop=wikidata({textformat="text",property=property,firstvalue=firstvalue,noref="true",pattern=Pattern,modifytime="longdate",numval=5},snak)
--mw.log( "prop".. prop )
ifproperty=="P345"then
url=functions.make_P345_link_o(prop)
ifurlandurl~=""then
prop="["..url..""..url.."]"
end
end
--mw.log('Module:Cite property: "'.. property.. '" ' )
--mw.log('Module:Cite prop: "'.. prop.. '" ' )
--if not prop then prop = ValueFromEntityId(entity, property,firstvalue) end
ifpropandprop~=""then
ifAandA~=""then
returnA..":"..prop
else
returnprop
end
end
end

localfunctionGetValueFromItem(items,snak,property,text,firstvalue)
ifproperty=="P50"then
fori,iteminpairs(items)do
ifitem=="Q36578"then
return""
end
end
end

localpattern="autourl"
ifproperty=="P212"orproperty=="P957"then
pattern=nil
end-- no automatic link for ISBN
localprop=wikidata({textformat="text",property=property,firstvalue=firstvalue,pattern=pattern,numval=5,noref="true",modifytime="longdate",enlabelcate="true"},snak)
ifnotpropthen
prop=ValueFromItem(items,property,firstvalue)
end
ifpropandprop~=""then
iftextandtext~=""then
prop=text..":"..prop
end
end
returnprop
end

localfunctionget_number_from_item(items,property)
fori,iteminpairs(items)do
ednumber=wikidata({textformat="text",entityId=item,property=property,firstvalue="yes",enlabelcate="true",numval=5})
ifednumberthen
returnednumber
end
end
end

localfunctiongetnumber(items,snak,property,text)
localtex=functions.get_property_label(property)

localnumber=wikidata({textformat="text",property=property,firstvalue="true",enlabelcate="true",numval=5},snak)
ifnotnumberthen
number=get_number_from_item(items,property)
end
ifnottextthen
text=tex
else
end

ifnumberandnumber~=""then
iftextthen
returntext..":"..number
else
returnnumber
end
end
end

localfunctionGetItemValue(items,snak,property,text,firstvalue)
localpattern="autourl"
-- if property == "P212" or property == "P957" then pattern = nil end -- no automatic link for ISBN
localprop=wikidata({textformat="text",property=property,firstvalue=(firstvalueor""),pattern=pattern,noref="true",modifytime="longdate",separator="، و",conjunction="، و",numval=5},snak)
ifnotpropthen
prop=ValueFromItem(items,property,(firstvalueor""))
end

ifpropandprop~=""then
iftextandtext~=""then
prop=text..":"..prop
end
end
returnprop
end

localfunctionGetNumberFromItem(items,snak,property,text,firstvalue)
localprop=wikidata({textformat="text",property=property,firstvalue="t",numval=5},snak)
fori,iteminpairs(items)do
ednumber=wikidata({textformat="text",entityId=item,property=property,firstvalue="true",noref="true",numval=5}
)
end
ifnotpropthen
prop=ednumber
end
ifpropandprop~=""then
iftextandtext~=""then
prop=text..prop
end
end
returnprop
end

--[[
جلب أي وصلة مرجع من الخواص مثل
P1065,P854
--]]
localfunctiongetLink(items,snak,property,text)
-- local tex = functions.labeel(property,text)
locallinks=wikidata({textformat="text",property=property,pattern="true",noref="true",firstvalue="true",numval=5},snak)
iflinksandlinks~=""then
iftextandtext~=""then
returnfunctions.geturl(links,text)
else
returnlinks
end
end
end
localfunctionget_Link_from_item(items,snak,property,text)
locallinks=ValueFromItem(items,property,"true")
localtex=functions.labeel(property,text)
iflinksandlinks~=""then
iftexandtex~=""then
returntex..":"..links
else
returnlinks
end
end
end
--[[
جلب أي تاريخ من الخواص مثل
P813,P577
--]]
localfunctiongetdate(snak,property,text)
-- local tex = functions.labeel(property,text)
ifsnak[property]then
localdat=wikidata({textformat="text",property=property,pattern="true",noref="true",modifytime="longdate",numval=5},snak)
ifdatanddat~=""then
iftextandtext~=""then
returntext..":"..dat
else
returndat
end
end
end
end

localfunctiongetdate1(items,snak,property,text)
fori,iteminpairs(items)do
localdatetime1=wikidata({textformat="text",entityId=item,property=property,noref="true",enlabelcate="true",modifytime="longdate",numval=5})
end
iftextthen
returntext..":"..datetime1
else
returndatetime1
end
end

localfunctiongetedition(items,snak)
fori,iteminpairs(items)do
ifitem=="Q36578"then
return""
end
end
localordning={
"الأول",
"الثاني",
"الثالث",
"الرابع",
"الخامس",
"السادس",
"السابع",
"الثامن",
"التاسع",
"العاشر",
"الحادي عشر",
"الثاني عشر"
}
localednumber
ifsnak["P393"]then
ednumber=wikidata({textformat="text",property="P393",firstvalue="true",enlabelcate="true",numval=5},snak)
else
ednumber=get_number_from_item(items,"P393")
end
ifnotednumberthen
returnnil
end
ifnottonumber(ednumber)then
return"الاصدار"..ednumber
end
ifordning[tonumber(ednumber)]then
return"الاصدار"..ordning[tonumber(ednumber)]
end
localsist=string.sub(ednumber,string.len(ednumber))
ifsist=="1"orsist=="2"then
return":الاصدار"..ednumber
else
return":الاصدار"..ednumber
end
end

localfunctiongetsubtitle(items,snak)-- needs i18n some languages do not use this format
locals={}
ifsnak["P1680"]then
dd=wikidata({textformat="text",property="P1680",firstvalue="true",enlabelcate="true",numval=5},snak)
table.insert(s,dd)
else
fori,iteminpairs(items)do
locallab=wikidata({textformat="text",property="P1680",enlabelcate="true",entityId=item,firstvalue="true",noref="true",numval=5})
localsitelink=mw.wikibase.sitelink(item)
ifsitelinkandlabthen
table.insert(s,"[[:"..sitelink.."|"..lab.."]]")
elseifsitelinkthen
table.insert(s,"[[:"..sitelink.."]]")
elseiflabthen
table.insert(s,lab)
end
end
end
tot=table.concat(s,"—")
iftotandtot~=""then
returntot
else
returnnil
end
end

localfunctiongettitle(items,snak)
locallink=getLink(items,snak,"P854")orgetLink(items,snak,"P1065","")-- the title will be with the link
localtitle=GetItemValue(items,snak,"P1476","العنوان","")
localsubtitle=GetItemValue(items,snak,"P1680","العنوان","")
ifnottitleortitle==""then
title=subtitle
end
iflinkandlink~=""then
return""
else
returntitle
end
end

localfunctiongetwhatever(snak,property)
ifsnak[property]then
--mw.log( "Module:Cite getwhatever property".. property)
locala=functions.get_property_label(property)
--local a = wikidata({ textformat = "text",property = "P1629", entityId=property, firstvalue= "true", noref= "true", enlabelcate= "true", label = functions.get_property_label(property)})

locals={}
--local items = {}
--mw.log( "Module:Cite find snak.property".. property)
forj,propinpairs(snak[property])do
ifprop.snaktype=="value"then
item="Q"..prop.datavalue.value["numeric-id"]
--table.insert(items, item)
faso=wikidata({textformat="text",entityId=item,property=property,noref="true",conjunction=",",enlabelcate="true",numval=5})
table.insert(s,faso)
end
end
ifproperty=="P143"then
a="مستورد من"
end
ifproperty=="P248"then
a="'''مذكور في'''"
end
--table.insert(s, wikidata({textformat = "text",property=property, conjunction=', ', enlabelcate= "true" }, snak))
if#s>0then
return(aor"").."''':'''"..table.concat(s,",")
end
end
end

--local function gettherest(snak, entity)
localfunctiongettherest(snak)
locals={}
forproperty,jinpairs(snak)do
Known=false
fork,linpairs(functions.Known_properties)do
ifproperty==lthen
Known=true
end
end
ifnotKnownthen
localentity1=mw.wikibase.getEntityObject(property)
ifentity1.claimsand(entity1.datatype=="string"orentity1.datatype=="external-id")then
--local vaa = GetValueFromEntityId(snak, entity, property, "true" )
localvaa=GetValueFromEntityId(snak,property,"true")
--mw.log( "Module:Cite gettherest property:".. property )
table.insert(s,vaa)
end
end
end
if#s>0then
returntable.concat(s,"—")
end
end

functionnumbers(items,snak)
localsection=GetNumberFromItem(items,snak,"P958","الباب:")
localvolume=GetNumberFromItem(items,snak,"P478","المجلد:")
localpage=GetNumberFromItem(items,snak,"P304","الصفحة:")
localissue=GetNumberFromItem(items,snak,"P433","العدد:")

field={}
ifsectionandsection~=""then
table.insert(field,section)
end
ifvolumeandvolume~=""then
table.insert(field,volume)
end
ifpageandpage~=""then
table.insert(field,page)
end
ifissueandissue~=""then
table.insert(field,issue)
end
returntable.concat(field,"—")
end

localfunctiongetISBN(items,snak)
localISBN13=GetNumberFromItem(items,snak,"P212","ISBN","yes")--ISBN 13
localISBN10=GetNumberFromItem(items,snak,"P957","ISBN","yes")--ISBN 10
ifnotISBN13orISBN13==""then
ISBN13=ISBN10
end
returnISBN13
end

functiondoipmid(items,snak)
localdoi=GetValueFromItem(items,snak,"P356")
-- Digital Object Identifier
localpmid=GetValueFromItem(items,snak,"P698")
-- Identifier for journal
localpmc=GetValueFromItem(items,snak,"P932")
-- identifier issued by PubMed Central
field={}
ifdoianddoi~=""then
table.insert(field,doi)
end
ifpmidandpmid~=""then
table.insert(field,pmid)
end
ifpmcandpmc~=""then
table.insert(field,pmc)
end
returntable.concat(field,"—")
end

localfunctionGetquall(snak,entity)
localquall=getsomequall(entity,snak,"P143")
localquall1=getsomequall(entity,snak,"P248")
ifnotquallorquall==""then
quall=quall1
end
returnquall
end

functiongetMultiLink(items,snak,entity)
localtitle=GetItemValue(items,snak,"P1476","","")
locallink=getLink(items,snak,"P854",title)
--, "وصلة مرجع"
locallink1=get_Link_from_item(items,snak,"P854")--
--local therest = gettherest(snak, entity)
localtherest=gettherest(snak)
localquall=Getquall(snak,entity)
localfulltext=get_Link_from_item(items,snak,"P953")--
localaccessdate=getdate(snak,"P813","تاريخ الاطلاع")
localarchive=getLink(items,snak,"P1065","")
field={}
iflinkandlink~=""then
newtab=link--We don't need to search for some links if they here already
elseiftherestandtherest~=""then
newtab=therest
elseifquallandquall~=""then
newtab=quall
elseiflink1andlink1~=""then
newtab=link1-- last thing we want to see
elseiffulltextandfulltext~=""then
newtab=fulltext
end
iflinkandlink~=""then
ifarchiveandarchive~=""then
archiveandlink="t"
end
end
ifnewtabandnewtab~=""then
table.insert(field,newtab)
ifaccessdateandaccessdate~=""then
table.insert(field,accessdate)
end
end
ifarchiveandlinkandarchiveandlink~=""then
return""
else
returntable.concat(field,"—")
end
end

functiongetarchiveLink(items,snak,entity)
localtitle=GetItemValue(items,snak,"P1476","","")
locallink=getLink(items,snak,"P854","")

localarchive=getLink(items,snak,"P1065","")
localarchive1=getLink(items,snak,"P1065","وصلة ارشيفية")
localarchivedate=getdate(snak,"P2960","")
-- تاريخ الأرشفة
localaccessdate=getdate(snak,"P813","تاريخ الاطلاع")
localaa=functions.geturl((archiveorlink),title)

field={}
ifarchiveandarchive~=""then
ifaaandaa~=""then
table.insert(field,aa)
end
iflinkandlink~=""then
org=functions.geturl(link,"الأصل")
ifaccessdateandaccessdate~=""then
table.insert(field,accessdate)
end
end
a="مؤرشف من"..(orgor"الأصل")
ifarchivedateandarchivedate~=""then
a=a.."في"..archivedate
end
table.insert(field,a)
end
returntable.concat(field,"—")
end

functiongetreftable(items,snak,hash,options)
localentity=options.entityId
localrows={
GetValueFromItem(items,snak,"P50","المؤلف"),--author
GetValueFromItem(items,snak,"P98","المحرر"),--editor
gettitle(items,snak),--title
GetValueFromItem(items,snak,"P123","الناشر"),--publisher
GetValueFromItem(items,snak,"P170","المخترع"),--creator
GetValueFromItem(items,snak,"P1433","نشر في"),--publishedin
getdate(snak,"P577","تاريخ النشر"),--publishdate
getedition(items,snak),--edition
numbers(items,snak),--number
doipmid(items,snak),--doipmid
getISBN(items,snak),--isbn
(getwhatever(snak,"P143")orgetwhatever(snak,"P248")),--import
getMultiLink(items,snak,entity),--MultiLink
getarchiveLink(items,snak,entity),--archiveLink
GetItemValue(items,snak,"P1683","إقتباس","")--quote
}

localfield={}

for_,lineinpairs(rows)do
iflineandline~=""then
table.insert(field,line)
end
end

locallicense=GetItemValue(items,snak,"P275","الرخصة")
iflicenseandlicense~=""and#field>0then
table.insert(field,license)
end

localdoo=table.concat(field,"—")

ifdooanddoo~=""then
returndoo--mw.getCurrentFrame():extensionTag( "ref", doo, {name = hash} )
end
end

localfunctionfindblacklist(items)
-- function to ignore Sister projects
localval="false"
locals={}
fori,iteminpairs(items)do
functionqoo(item,property)
returnwikidata({textformat="text",entityId=item,property=property,noref="true",firstvalue="1",formatting="raw",numval=5})
end
localwiki=qoo(item,"P1800")orqoo(item,"P1566")orqoo(item,"P21")-- all wikimedia site, GeoNames,gender
localwik2=qoo(item,"P31")
localblackk={
"Q20651139",
"Q465",
"Q15241312",
"Q30069253",-- ظهور مشكلة غير معروفة السبب في كريستوفر_تولكين [[موضوع:Veus9rhajrejwaho]]
"Q52"-- Wikipedia
}
fork,binpairs(blackk)do
ifitem==bthen
val="true"
end
end
ifwikiandwiki~=""then
val="true"
elseif
wik2=="Q5"or-- Human is not a direct reference
wik2=="Q184188"or-- Also Canton
wik2=="Q1250464"
then
val="true"-- Also places
end
end
returnval
end

localref_cash={}

functionp.citeitem(items,snak,hash,options,notag)
Options=options
ifhashandhash~=""andref_cash[hash]then
--mw.log( "Module:Cite ref_cash[hash] =".. hash)
returnref_cash[hash]
end
ifnotitemsandnotsnakthen
returnnil
end
iftype(items)=="string"then
items={items}
end
items={}
ifsnak.P248then
forj,propinpairs(snak.P248)do
ifprop.snaktype=="value"then
table.insert(items,"Q"..prop.datavalue.value["numeric-id"])
end
end
elseifsnak.P143then
forj,propinpairs(snak.P143)do
ifprop.snaktype=="value"then
table.insert(items,"Q"..prop.datavalue.value["numeric-id"])
end
end
end
localblacklist1=findblacklist(items)
ifblacklist1=="true"then
returnnil
end
--local findtype = FindTypeOfRefrence(items, snak, options)
localrefrence=getreftable(items,snak,hash,options)
ifrefrenceandrefrence~=""then
ifnotagandnotag~=""then
refrence=refrence
else
refrence=mw.getCurrentFrame():extensionTag("ref",refrence,{name=hash})
end
end
ifhashandhash~=""then
ref_cash[hash]=refrence
end
returnrefrence
end

functionp.citeitem2(ref,options,notag)
Options=options
ifnotrefthen
returnnil
end
localhash=ref.hash
localsnak=ref.snaks
localsnnaks=""
ifhashandhash~=""andref_cash[hash]then
--mw.log( "Module:Cite ref_cash[hash] =".. hash)
returnref_cash[hash]
end
forPx,propeinpairs(snak)do
snnaks=snnaks..","..Px
end
--mw.log( "Module:Cite Citeitem2 hash:".. hash )
--mw.log( "Module:Cite *snnaks:".. snnaks )
items={}
ifsnak.P248then
forj,propinpairs(snak.P248)do
ifprop.snaktype=="value"then
table.insert(items,"Q"..prop.datavalue.value["numeric-id"])
end
end
elseifsnak.P143then
forj,propinpairs(snak.P143)do
ifprop.snaktype=="value"then
table.insert(items,"Q"..prop.datavalue.value["numeric-id"])
end
end
end
localblacklist1=findblacklist(items)
ifblacklist1=="true"then
returnnil
end
--local findtype = FindTypeOfRefrence(items, snak, options)
localrefrence=getreftable(items,snak,hash,options)
ifrefrenceandrefrence~=""then
ifnotagandnotag~=""then
refrence=refrence
else
refrence=mw.getCurrentFrame():extensionTag("ref",refrence,{name=hash})
end
end
ifhashandhash~=""then
ref_cash[hash]=refrence
end
returnrefrence
end

functionp.reflist(frame)
locallist=mw.text.split(frame.args.item,"")
locals={}
fori,jinpairs(list)do
localitem=mw.wikibase.getEntityObject(mw.text.trim(j))
localstr=p.citeitem({mw.text.trim(j)},item.claims,mw.text.trim(j)..i,frame.args,"t")
ifstrthen
table.insert(s,"*"..str)
end
end
returntable.concat(s,"\n")
end

functionp.cite(frame)
localitem=mw.wikibase.getEntityObject(frame.args.item)
ifnotitemthen
return"no item"
end
returnp.citeitem({frame.args.item},item.claims,frame.args.item,frame.args,"t")
end

returnp