「モジュール:Wd」の版間の差分

ナビゲーションに移動 検索に移動
en:Module:Wd 2017年8月29日 (火) 11:01(UTC)より
template>K-iczn
(en:Module:Wd 2017年8月28日 (月) 14:24(UTC)より)
template>K-iczn
(en:Module:Wd 2017年8月29日 (火) 11:01(UTC)より)
2,059行目: 2,059行目:
nextIndex = nextIndex + 1
nextIndex = nextIndex + 1
else
else
_.entityID = mw.wikibase.getEntityIdForCurrentPage()  -- no entity ID given, use item-entity connected to current page
-- no positional entity ID was given, so get entity ID from 'eid' if it was given
_.entity = mw.wikibase.getEntity() -- get the item-entity connected to the current page
if args["eid"] then
if args["eid"]:sub(1,1):upper() == "Q" then
_.entityID = args["eid"]:upper() 
elseif args["eid"]:sub(1,9):lower() == "property:" then
_.entityID = replaceAlias(mw.text.trim(args["eid"]:sub(10))):upper()
else
-- might be entity ID of a property, or a bogus entity ID that will fail later on
_.entityID = replaceAlias(args["eid"]):upper()
if _.entityID == "" then
-- explicitly return if value for 'eid' is empty
return ""
end
end
else
_.entityID = mw.wikibase.getEntityIdForCurrentPage()  -- by default, use item-entity connected to current page
end
_.entity = mw.wikibase.getEntity(_.entityID)
_.propertyID = nextArg  -- property ID
_.propertyID = nextArg  -- property ID
end
end
2,257行目: 2,275行目:
if nextArg then
if nextArg then
ID = mw.text.trim(nextArg)
nextArg = mw.text.trim(nextArg)
else
nextArg = ""
end
-- check for optional entity ID of either item or property
if nextArg:sub(1,1):upper() == "Q" then
ID = nextArg:upper()  -- entity ID of an item was given
elseif nextArg:sub(1,9):lower() == "property:" then
ID = replaceAlias(mw.text.trim(nextArg:sub(10))):upper()  -- entity ID of a property was given
else
-- might be entity ID of a property, or a bogus entity ID that will fail later on
ID = replaceAlias(nextArg):upper()
if ID == "" then
if ID:sub(1,1) ~= "P" then
ID = nil
if ID == "" then
elseif ID:sub(1,9):lower() == "property:" then
-- no positional entity ID was given, so get entity ID from 'eid' if it was given
ID = mw.text.trim(ID:sub(10))
if args["eid"] then
if args["eid"]:sub(1,1):upper() == "Q" then
ID = args["eid"]:upper() 
elseif args["eid"]:sub(1,9):lower() == "property:" then
ID = replaceAlias(mw.text.trim(args["eid"]:sub(10))):upper()
else
-- might be entity ID of a property, or a bogus entity ID that will fail later on
ID = replaceAlias(args["eid"]):upper()
if ID == "" then
-- explicitly return if value for 'eid' is empty
return ""
end
end
else
ID = nil
end
end
end
end
end
end
if ID then
if ID then
ID = replaceAlias(ID):upper()
-- check if this is a valid ID, and if the number is not larger than max int (to prevent error)
if not ID:match('^[QP]%d+$') or tonumber(ID:match('%d+')) > 2147483647 then
return ""
end
_.entityID = ID
_.entityID = ID
else
else
匿名利用者

案内メニュー