ماڈیول:Uses Wikidata
ظاہری ہیئت
| شاید آپ اس اسکریبنٹو ماڈیول کا دستاویزی صفحہ تخلیق کرنا چاہتے ہیں۔ صارفین ماڈیول کے تختہ مشق (تخلیق | آئینہ) اور ثابتات (تخلیق) میں تجربات کرسکتے ہیں۔ براہ کرم /دستاویز کے ذیلی صفحہ پر زمرہ جات شامل فرمائیں۔ اس ماڈیول کے ذیلی صفحات۔ |
local p = {}
local wd2 = require('Module:Wikidata2').formatStatementsFromLua
local gett = require('Module:Uses_Wikidata/datatype').gettype
function p.usesProperty(frame)
local parent = frame.getParent(frame)
local result = ''
local ii = 1
while true do
local p_num = parent.args[ii] or ''
if p_num ~= '' then
p_num = mw.text.trim( p_num )
if mw.ustring.gsub( p_num, '%d', '' ) == 'P' then
local label = mw.wikibase.label(p_num) or "بغیر خاصیت کے"
result = result .. "<li><b><i>[[d:Property:" .. p_num .. "|" .. label .. " <small>(" .. string.upper(p_num) .. ")</small>]]</i></b> (دیکھیے [[d:Special:WhatLinksHere/Property:" .. p_num .. "|استعمالات]])</li>"
end
else break
end
ii = ii + 1
end
return result
end
Type = {
["wikibase-item"]= "ویکی بیس آئٹم",
["wikibase-property"]= "خاصیت ویکی بیس",
["commonsMedia"]= "کومنز میڈیا",
["math"]= "ریاضی",
["time"]= "وقت",
["external-id"]= "بیرونی آئی ڈی",
["string"]= "نص",
["globe-coordinate"]= "متناسقات",
["quantity"]= "مقدار",
["geo-shape"]= "شکل جغرافیہ",
["url"]= "یو آر ایل",
["monolingualtext"]= "ایک ہی زبان میں متن",
}
local function getpropertytype(id)
local ca = ""
local mo = gett(id)
if mo and mo ~= "" then
if Type[mo] then
ca = Type[mo]
end
else
local entity = mw.wikibase.getEntityObject(id)
if entity
and entity['datatype']
and Type[entity['datatype']]
then
ca = Type[entity['datatype']]
else ca =''
end
end
if ca and ca ~= '' then
return '<small> (' .. ca .. ')</small>'
end
return ''
end
local function LabelOrDes(langcode , id , lab , args)
if lab == 'labels'
then cas = 'lab'
elseif lab == 'descriptions'
then cas = 'des'
end
----------------------
local arg = args[id .. cas] or ''
local lan = langcode or 'ur'
local entity = mw.wikibase.getEntityObject(id)
----------------------
if arg and arg ~= ''
then
return arg
else
if entity
and entity[''..lab ..'']
and entity[''..lab ..''][''..lan..'']
and entity[''..lab ..''][''..lan..''].value
then
local lang = entity[''..lab ..''][''..lan..'']
if lang['language'] == lan
then
return entity[''..lab ..''][''..lan..''].value
else
return nil
end
end
end
end
local function makecat(P, name)
PO = ''
----------------------
if P and P ~='' then
local cat = mw.ustring.gsub(P, 'زمرہ:' , '')
local catname = mw.ustring.gsub(cat, 'خاصیت کا استعمال کرنے والے صفحات' , 'استعمال صفحات')
if name and name ~= '' then catname = name end
PO = "[[:" .. P .. "|" .. catname .. "]] (<abbr title='استعمال کی تعداد'>میں</abbr> " .. mw.site.stats.pagesInCategory(cat, 'all') .. " صفحہ)"
end
----------------------
return PO
end
local function getprop(id , prop , args , name)
local PO = ''
local Property = wd2({entityId = id , property = prop ,formatting ='sitelink', addTrackingCat ='',noicon='t',nolink ='t', firstvalue='s'}) or ''
--if Property and Property ~='' then Property = '[[:' .. Property ...']] ({{PAGESINCAT:' .. mw.ustring.gsub(Property, 'زمرہ:' , '') .. '}} صفحہ)' end
----------------------
if args[id .. 'cat'] and args[id .. 'cat'] ~= ''
then
Property = args[id .. 'cat']
end
----------------------
newtrak = args['track'] or ""
if not Property or Property == "" then
if prop == "P2875" and newtrak ~= "" then
Property = "زمرہ:خاصیت استعمال کرنے والے صفحات " .. id
end
end
if Property and Property ~='' then
PO = makecat(Property , name)
end
----------------------
return PO
end
function p._usestable(args)
aaa = {}
aa = {}
local nott = "<abbr title='قدر ویکی ڈیٹا پر موجود نہیں'>ليست.</abbr>"
local same = "<abbr title='ویکی ڈیٹا کے مطابق قدر'>مطابقة.</abbr>"
local def ="<abbr title='ویکی ڈیٹا سے مختلف قدر'>مختلفة.</abbr>"
local r = '! data-sort-type="number" style="width: 20%;"| خاصیت'
r = r .. '!! style="width: 45%; " | وضاحت کریں۔'
r = r .. '!! style="width: 30%; " | استعمال سے باخبر رہنے کی درجہ بندی'
local r1 = r .. '\n|-\n'
r = r .. '!! style="width: 30%; " | ' .. nott
r = r .. '!! style="width: 30%; " | ' .. same
r = r .. '!! style="width: 30%; " | ' .. def
r = r .. '\n|-\n'
local temp = args['سانچہ'] or 'سانچہ'
local ii = 1
while true do
local p_num = args[ii] or ''
mw.log("Module:Uses Wikidata: " .. p_num)
if p_num ~= '' then
p_num = mw.text.trim( p_num )
if mw.ustring.gsub( p_num, '%d', '' ) == 'P' then
table.insert(aa, p_num)
--else
--if mw.ustring.gsub( p_num, 'سانچہ=', '' ) ~= p_num then
--temp = mw.ustring.gsub( p_num, 'سانچہ=', '' )
--end
end
else break
end
ii = ii + 1
end
if temp ~= 'سانچہ'
then temp = '[[سانچہ:' .. temp .. ']]'
end
local head_s = '{| class="wikitable sortable collapsible mw-collapsed" style="text-align:right; width: '
local head2 = '%; font-size: 95%;"\n|+خواص [[ویکی ڈیٹا]] استعمال در ' .. temp .. '\n'
local width = args['width'] or "75"
local head = head_s .. width .. head2
local result = ''
local result1 = ''
local FFF = ''
--table.sort(aa, function(a, b) return a < b end)
table.sort(aa)
for k, p_num in pairs(aa) do
local rr = " (دیکھیے [[d:Special:WhatLinksHere/Property:" .. p_num .. "|استعمالات]])"
local label = LabelOrDes('ur', p_num ,'labels' , args) or LabelOrDes('en', p_num ,'labels' , args) or "بغیر لیبل کے"
local description = LabelOrDes( 'ur', p_num ,'descriptions' , args) or "" --"بغیر خاصیت کے"
local P2875 = getprop(p_num , 'P2875' , args , '')
local P3713 = getprop(p_num , 'P3713' , args , 'ليست')
local P3734 = getprop(p_num , 'P3734' , args , 'مطابقة')
local P3709 = getprop(p_num , 'P3709' , args , 'مختلفة')
if P3713 ~='' or P3734 ~='' or P3709 ~='' then
FFF = 'sa'
end
--local pro = '<span style="font-family: monospace, monospace;">' .. string.upper(p_num) .. '</span>'
--local span= ' data-sort-value="' .. mw.ustring.gsub(p_num, 'P' , '').. '"| ' .. pro .. ''
--local name = "|" .. span .. "|| <b>[[d:Property:" .. p_num .. "|" .. label .. "]]</b> || "
local propertytype = getpropertytype(p_num)
local pro = ' (' .. string.upper(p_num) .. ')'
local span= '| data-sort-value="' .. mw.ustring.gsub(p_num, 'P' , '').. '"| '
--local name = span .. " <small>[[d:Property:" .. p_num .. "|" .. label .. pro .. "]]</small>" .. propertytype.. " ||"
local name = span .. " <b>[[d:Property:" .. p_num .. "|" .. label .. pro .. "]]</b>" .. propertytype.. " ||"
result = result .. name .. description
result1 = result1 .. name .. description .. "|| " .. P2875 .. "\n|-\n"
result = result .. "|| " .. P2875
result = result .. "|| " .. P3713
result = result .. "|| " .. P3734
result = result .. "|| " .. P3709
result = result .. "\n|-\n"
end
div1 = '<div style="max-height:650px; width:'..width..'%; overflow:auto; padding:3px; border:solid 1px;">\n'
down2 = mw.getCurrentFrame():preprocess('{{#منتقل:{{SUBPAGENAME}}|تختہ مشق|doc|مختبر|نسخة|تجربة|دستاویز=|#default=[[زمرہ:سانچے مع استعمال ڈیٹا از ویکی ڈیٹا]]}}' )
down = '|}' .. down2
if ii > 20 then
head = div1 .. head_s .. "100" .. head2
down = down .. "</div>"
end
final = head .. r .. result .. down
final1 = head .. r1 .. result1 .. down
--######################
if FFF ~= '' then
return final
else
return final1
end
--######################
end
function p.usestable(frame)
local parent = frame.getParent(frame)
return p._usestable(parent.args)
end
return p