وحدة:بطاقة/ويكي.بيانات
< وحدة:بطاقة
اذهب إلى التنقل
اذهب إلى البحث
مراجعة 02:57، 3 أبريل 2021 بواسطة Ahmad A Najar (نقاش | مساهمات) (أنشأ الصفحة ب'local infowd = {} local function WikidataCa(id,query) local wd = require("Module:Wikidata.Ca") if not query.item then query.item = id end query.shownovalue =...')
يمكن إنشاء صفحة توثيق الوحدة في وحدة:بطاقة/ويكي.بيانات/شرح
local infowd = {} local function WikidataCa(id,query) local wd = require("Module:Wikidata.Ca") if not query.item then query.item = id end query.shownovalue = query.shownovalue or "false" if not query.conjtype and not query.conjunction then query.conjunction = ' — ' else query.conjunction = query.conjtype or query.conjunction end if (query.conjunction == '*' and query.formatting == nil) then query.conjunction = "LF" query.separator = "LF" query.formatting = "* $1" elseif (query.conjunction == '#' and query.formatting) then query.conjunction = "LF" ; query.separator = "LF"; query.formatting = "# $1" elseif query.conjunction == 'new line' then query.conjunction = "<br />" elseif query.conjunction == 'comma' then query.conjunction = "، " elseif query.conjunction == 'and' then query.conjunction = " و" elseif query.conjunction == 'or' then query.conjunction = " أو " end query.separator = query.separator or query.conjunction query.query='num' if type(query.property) == 'table' then query.property = mw.text.listToText(query.property , ' or ' ,' or ') end if query.references == nil then query.references = true end return wd.claim(query) end local function WikidataFr(item,query) local wd = require("Module:Wikidata/fr") local value, number -- valeur à retourner, nombre de valeurs pour accorder le libellé if not query.entity then query.entity = item end if not query.conjtype then query.conjtype = 'comma' end local claims = wd.getClaims(query) if (not claims) then return nil end return wd.formatAndCat(query), #claims end local function Wikidata2(item,query) local wd = require('وحدة:Wikidata2') local wd2formatStatements = wd.formatStatementsFromLua local function addLinkBack(str, id, property) if id == '-' then return str -- تعطيل wikidata end if not id then id = mw.wikibase.getEntityIdForCurrentPage() end if not id then return str end if type(property) == 'table' then property = property[1] end if type(id) == 'table' then id = id.id end local class = '' if property then class = 'wd_' .. string.lower(property) end local icon = '[[File:Blue pencil.svg|%s|10px|baseline|class=noviewer|link=%s]]' local title = wd.translate('see-wikidata-value') local url = mw.uri.fullUrl('d:' .. id, '') url.fragment = property -- ajoute une #ancre si paramètre "property" défini url = tostring(url) local v = mw.html.create('span') :addClass(class) :wikitext(str) :tag('span') :addClass('noprint wikidata-linkback') :css('padding-left', '0.5em') :wikitext(icon:format(title, url)) :allDone() return tostring(v) end local function addTrackingCat(prop, cat) -- doit parfois être appelé par d'autres modules if type(prop) == 'table' then prop = prop[1] -- devrait logiquement toutes les ajouter end if not prop and not cat then return '[[Category:Error-property-param-not-provided]]' end if not cat then cat = wd.translate('trackingcat', prop or 'P??') end if mw.title.getCurrentTitle().namespace ==0 then return '[[Category:' .. cat .. ']]' else return '' end end local function formatAndCat(args) if not args then return nil end args.linkback = args.linkback or true args.addcat = true if args.value then -- do not ignore linkback and addcat, as formatStatements do if args.value == '-' then return nil end local val = args.value --.. addTrackingCat(args.property) val = addLinkBack(val, args.entity, args.property) return val end return wd2formatStatements( args ) end if not query.rank then query.rank = "all" end shownovalue=false if not query.entity then query.entityId = item.id end if not query.conjtype and not query.conjunction then query.conjunction = ' — ' query.separator = query.conjunction else query.conjunction = query.conjtype query.separator = query.conjunction end if query.conjunction == 'new line' then query.conjunction = "\n" query.separator = query.conjunction elseif query.conjunction == 'comma' then query.conjunction = "، " query.separator = query.conjunction elseif query.conjunction == 'and' then query.conjunction = " و" query.separator = query.conjunction elseif query.conjunction == 'or' then query.conjunction = " أو " query.separator = query.conjunction end if query.isinlang then query.langpref = query.isinlang end local qualifiers if query.showqualifiers then if type(query.showqualifiers)=='table' then qualifiers = query.showqualifiers elseif type(query.showqualifiers)=='string' then qualifiers = mw.text.split(query.showqualifiers, ",") end if type(qualifiers)=='table' then if #qualifiers >=1 then query.qual1 = qualifiers[1] end if #qualifiers >=2 then query.qual2 = qualifiers[2] end if #qualifiers >=3 then query.qual3 = qualifiers[3] end if #qualifiers >=4 then query.qual4 = qualifiers[4] end if #qualifiers >=5 then query.qual5 = qualifiers[5] end else query.qual1 = query.qualifier end end query.preferqualifier =query.preferqualifier or query.qualifier query.justthisqual = query.justthisqual or query.showonlyqualifier query.preferqualifiervalue = query.preferqualifiervalue or query.qualifiervalue query.avoidqualifier = query.avoidqualifier or query.excludequalifier --query. = query.excludequalifiervalue query.avoidvalue = query.avoidvalue or query.excludevalues if query.urlpattern then query.pattern = query.urlpattern end if query.sorttype then query.sortbytime = query.sorttype if not query.rank then query.rank=all end end if query.showdate then query.withdate = query.showdate query.bothdates = query.showdate end if query.text and displayformat and displayformat=='weblink' then query.urllabel = query.text end if not query.numberofreferences then query.numberofreferences = 3 end if type(query.property) == 'table' then query.property = query.property[1] end local claims =wd2formatStatements(query) --wd.getClaims(query) if (not claims) then return nil end query.numberofclaims = 'y' local nbres = wd2formatStatements(query) return formatAndCat({value=claims, property = query.property, entity = query.entity}),nbres end function infowd.expandQuery(item,wikimod,query) local value, number -- نتيجة ، عدد النتائج للضبط الصرفي للعنوان if(type(query) ~= 'table') then return nil end if(type(item) ~= 'table' or type(item.id)~= 'string') then return nil end -- الوحدات المستعملة if wikimod == 'Wikidata.Ca' then if(type(item) == 'table') then return WikidataCa(item.id,query) else WikidataCa(item,query) end end if wikimod == 'Wikidata/fr' then return WikidataFr(item,query) end --- else -- wikimod == 'Wikidata2' then return Wikidata2(item,query) end return infowd