Module:Wd: Difference between revisions

Content deleted Content added
Fixed issue where no short name was retrieved when a call to 'label' with 'short' flag and without item ID was done
Removed redundant code
Line 1,732:
_.curState = State.new(_)
local ID = nil
local label = ""
local title = nil
Line 1,745:
if nextArg then
nextArgID = mw.text.trim(nextArg)
else
nextArgif ID == "" then
labelID = nil
end
end
IDif =ID nextArgthen
if ID ~= "" then
if aliasesP[ID] then
ID = aliasesP[ID]
Line 1,776:
end
end
else
return label
if ID:sub(1,1) == "P" then
if not _.pageTitle then
label = mw.wikibase.label(ID) or ""
if _.curState.linked and label ~= "" then
label = "[[d:Property:" .. ID .. "|" .. label .. "]]"
end
end
else
if not _.pageTitle then
if _.curState.shortName then
label = getShortName(ID)
end
-- at this point, 'label' will be a string and not nil
if label == "" then
label = mw.wikibase.label(ID)
end
else
-- set 'label' to nil so 'title' will always prevail
label = nil
end
-- at this point, 'label' will be nil or a non-empty string
if _.curState.linked or label == nil then
title = mw.wikibase.sitelink(ID)
end
if _.curState.linked and title then
label = "[[" .. title .. "|" .. (label or title) .. "]]"
else
label = label or title or ""
end
end
end
else
Line 1,820 ⟶ 1,785:
if _.curState.linked and label ~= "" then
label = "[[d:" .. label .. "|" .. label .. "]]"
end
else
if not _.pageTitle then
if _.curState.shortName then
label = getShortName()
end
-- at this point, 'label' will be a string and not nil
if label == "" then
label = mw.wikibase.label()
end
else
-- set 'label' to nil so 'title' will always prevail
label = nil
end
return label
-- at this point, 'label' will be nil or a non-empty string
end
end
if ID and ID:sub(1,1) == "P" then
if not _.pageTitle then
label = mw.wikibase.label(ID) or ""
if _.curState.linked orand label =~= nil"" then
label = "[[d:Property:" .. ID .. "|" .. label .. "]]"
title = mw.title.getCurrentTitle().prefixedText
end
end
else
if not _.pageTitle then
if _.curState.shortName then
label = getShortName(ID)
end
-- at this point, 'label' will be a string and not nil
if _.curState.linked then
label = "[[" .. title .. "|" .. (label or title) .. "]]" -- not much use since it links to the current page, but does add wiki mark-up
if IDlabel ~== "" then
label = mw.wikibase.label(ID)
end
else
-- set 'label' to nil so 'title' will always prevail
if label == "" thennil
end
-- at this point, 'label' will be nil or a non-empty string
if _.curState.linked andor label ~== ""nil then
if not _.pageTitleID then
title = mw.wikibase.sitelink(ID)
else
labeltitle = label or mw.title.getCurrentTitle().prefixedText
end
end
if _.curState.linked orand label == niltitle then
label = "[[" .. title .. "|" .. (label or title) .. "]]"
else
label = label or title or ""
end
end