「モジュール: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 positional entity ID was given, so get entity ID from 'eid' if it was given | ||
_.entity = mw.wikibase.getEntity() | 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 | ||
if ID == "" then | |||
-- no positional entity ID was given, so get entity ID from 'eid' if it was given | |||
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 | ||
_.entityID = ID | _.entityID = ID | ||
else | else |