تعديل وحدة:Wikibase

اذهب إلى التنقل اذهب إلى البحث

تحذير: أنت غير مسجل الدخول. عنوان الأيبي الخاص بك سيكون معروضا بشكل علني لو قمت بأي تعديلات. لو أنك سجلت الدخول أو أنشأت حسابا، فتعديلاتك ستنسب لاسم المستخدم الخاص بك، بالإضافة إلى فوائد أخرى.

يمكن استرجاع التعديل. تحقق من المقارنة بالأسفل للتأكد من أن هذا هو ما تريد أن تفعله، ثم احفظ التغييرات بالأسفل للانتهاء من استرجاع التعديل.

المراجعة الحالية نصك
سطر 1: سطر 1:
---------- Module:Wikibase ----------------
 
 
local p = {}
 
local p = {}
function p.getEntityObject(id)
 
if not mw.wikibase then return nil end
 
entity = mw.wikibase.getEntityObject(id)
 
return entity
 
end
 
  
-- Return the item ID of the item linked to the current page.
+
function p.wikidatacheck(frame)
function p.id(frame)
+
local pframe = frame:getParent()
if not mw.wikibase then return nil end
+
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
entity = mw.wikibase.getEntityObject()
+
local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template
if entity == nil then
+
 
return "no entity"
+
local property = config.property
 +
local value = config.value or ""
 +
local catbase = config.category
 +
local namespaces = config.namespaces
 +
local nocatsame = config.nocatsame or ""
 +
local ok = false -- one-way flag to check if we're in a good namespace
 +
local ns = mw.title.getCurrentTitle().namespace
 +
for v in mw.text.gsplit( namespaces, ",", true) do
 +
if tonumber(v) == ns then
 +
ok = true
 +
end
 +
end
 +
if not ok then -- not in one of the approved namespaces
 +
return ""
 
end
 
end
return entity.id
+
local entity = mw.wikibase.getEntityObject()
end
+
if not entity then -- no Wikidata item
 
+
return "[[Category:" .. catbase .. " not in Wikidata]]"
-- Return the label of a given data item, or of connected page
 
-- if no argument is provided to this method.
 
function p.label(frame)
 
if not mw.wikibase then return nil end
 
if frame.args[1] == nil then
 
entity = mw.wikibase.getEntityObject()
 
if not entity then return nil end
 
id = entity.id
 
else
 
id = mw.text.trim(frame.args[1])
 
 
end
 
end
return mw.wikibase.label( id )
+
if value == "" then
end
+
return nil -- Using Wikidata
 
 
-- Return the description of a given data item, or of connected page
 
-- if no argument is provided to this method.
 
function p.description(frame)
 
if not mw.wikibase then return nil end
 
if frame.args[1] == nil then
 
entity = mw.wikibase.getEntityObject()
 
if not entity then return nil end
 
id = entity.id
 
else
 
id = mw.text.trim(frame.args[1])
 
 
end
 
end
return mw.wikibase.description( id )
+
local claims = entity.claims or {}
end
+
local hasProp = claims[property]
 
+
if not hasProp then -- no claim of that property
-- Return the local page about a given data item, or of connected page
+
return "[[Category:" .. catbase .. " not in Wikidata]]" -- bad. Bot needs to add the property
-- if id is not specified.
 
function p.page(frame)
 
if not mw.wikibase then return nil end
 
if frame.args[1] == nil then
 
entity = mw.wikibase.getEntityObject()
 
if not entity then return nil end
 
id = entity.id
 
else
 
id = mw.text.trim(frame.args[1])
 
 
end
 
end
return mw.wikibase.sitelink( id )
+
for i, v in ipairs(hasProp) do -- Now we try to iterate over all possible values?
end
+
propValue = (v.mainsnak.datavalue or {}).value
 
+
if propValue == value then
-- Return the data type of a property
+
if nocatsame == "" then
function p.datatype(frame)
+
return "[[Category:" .. catbase .. " same as Wikidata]]" -- yay!
if not mw.wikibase then return nil end
+
else
if frame.args[1] and string.find(frame.args[1], "Property:P") then
+
return nil -- if nocatsame, the "same as" category is not added
if mw.wikibase.getEntityObject(string.gsub(frame.args[1], "Property:P", "P"))  then
+
end
return mw.wikibase.getEntityObject(string.gsub(frame.args[1], "Property:P", "P") ).datatype
 
end
 
elseif frame.args[1] and string.find(frame.args[1], "P") then
 
if mw.wikibase.getEntityObject(frame.args[1])  then
 
return mw.wikibase.getEntityObject(frame.args[1]).datatype
 
 
end
 
end
 
end
 
end
 +
return "[[Category:" .. catbase .. " different from Wikidata]]" -- needs human review :(
 
end
 
end
  
 
return p
 
return p

من فضلك لاحظ أن جميع المساهمات في موسوعة المزرعة يمكن أن تعدل أو تتغير أو تزال من قبل المساهمين الآخرين. إذا لم تكن ترغب أن تعدل مشاركاتك بهذا الشكل، لا تضعها هنا.
أنت تقر أيضا أنك كتبت هذا بنفسك، أو نسخته من مصدر يخضع للملكية العامة، أو مصدر حر آخر (انظر المزرعة:حقوق التأليف والنشر للتفاصيل). لا تضف أي عمل ذي حقوق محفوظة بدون تصريح!

ألغ مساعدة التحرير (تفتح في نافذة جديدة)