Modiwl:Wd: Gwahaniaeth rhwng fersiynau
Cynnwys wedi'i ddileu Cynnwys wedi'i ychwanegu
Janhrach (sgwrs | cyfraniadau) Updated the module with some code readded from a past revision of enwiki Tagiau: Golygiad drwy declyn symudol Golygiad ar declun symudol |
Dafyddt (sgwrs | cyfraniadau) diweddaru o en Tagiau: Gwrthdröwyd |
||
Llinell 1:
-- Original module located at [[:en:Module:Wd]] and [[:en:Module:Wd/i18n]].
require("strict")
Llinell 66 ⟶ 65:
eid = "eid",
page = "page",
date = "date",
globalSiteId = "globalSiteId"
}
Llinell 100:
column = "P3903",
subjectNamedAs = "P1810",
wikidataProperty = "P1687",
publishedIn = "P1433"
}
Llinell 1,801 ⟶ 1,802:
-- level 2 hook
function State:getReference(statement)
local key, citeWeb, citeQ, label
Llinell 1,811:
local value = ""
local ref = {}
local referenceEmpty = true -- will be set to false if at least one parameter is left unremoved
local numAuthorParameters = 0
local numAuthorNameStringParameters = 0
local tempLink
local additionalRefProperties = {} -- will hold properties of the reference which are not in statement.snaks, namely backup title from "subject named as" and
local wikidataPropertiesOfSource -- will contain "Wikidata property" properties of the item in stated in, if any
local version =
if statement.snaks then
Llinell 1,858 ⟶ 1,859:
-- "stated in" was given but "reference URL" was not.
-- get "Wikidata property" properties from the item in "stated in"
-- if any of the returned properties of the external-id datatype is in statement.snaks, generate a
-- find the "Wikidata property" properties in the item from "stated in"
Llinell 1,866 ⟶ 1,867:
tempLink = self.conf:getValue(statement.snaks[wikidataPropertyOfSource][1], false, true) -- not raw, linked
if mw.ustring.match(tempLink, "^%[%Z- %Z+%]$") then -- getValue returned a URL.
additionalRefProperties[aliasesP.referenceURL] = mw.ustring.gsub(tempLink, "^%[(%Z-) %Z+%]$", "%1") -- the
statement.snaks[wikidataPropertyOfSource] = nil
break
Llinell 1,889 ⟶ 1,890:
if i == aliasesP.author or i == aliasesP.authorNameString then
params[i] = self:getReferenceDetails(statement.snaks, i, false, self.linked, true) -- link = true/false, anyLang = true
-- Get "stated in" raw, as it is wanted (for Cite Q) even if it doesn't have a local language label.
else
params[i] = {self:getReferenceDetail(statement.snaks, i, false,
end
if #params[i] == 0 then
params[i] = nil
else
referenceEmpty = false
if statement.snaks[i][1].datatype == 'external-id' then
key = "external-id"
Llinell 1,974 ⟶ 1,980:
citeQ = split(mw.wikibase.getSitelink(aliasesQ.citeQ) or "", ":")[2] -- split off namespace from front
-- (1) use the general template for citing web references if there is a match and if at least
if citeWeb and not citeMismatch['web'] and citeParams['web'][i18n['cite']['web'][aliasesP.referenceURL
citeParams['web'][i18n['cite']['web'][aliasesP.statedIn]] = self:getReferenceDetail(statement.snaks, aliasesP.statedIn, false, self.linked, true)
useCite = citeWeb
useParams = citeParams['web']
Llinell 1,981 ⟶ 1,989:
-- (2) use the template that expands stated-in references into citations if there is a match and if at least "stated in" is present
elseif citeQ and not citeMismatch['q'] and citeParams['q'][i18n['cite']['q'][aliasesP.statedIn]] then
▲ -- we need the raw "stated in" Q-identifier for the this template
▲ citeParams['q'][i18n['cite']['q'][aliasesP.statedIn]] = self:getReferenceDetail(statement.snaks, aliasesP.statedIn, true) -- raw = true
useCite = citeQ
useParams = citeParams['q']
Llinell 2,000 ⟶ 2,005:
end
-- (3) if the citation couldn't be displayed using Cite web or Cite Q, but has properties other than the removed ones, throw an error
elseif not referenceEmpty then
value = "<span style=\"color:#dd3333\">" .. errorText("malformed-reference") .. "</span>"
▲ end
▲ elseif params[aliasesP.title] then
▲ end
end
Llinell 2,246 ⟶ 2,204:
end
local function getEntityId(arg, eid, page, allowOmitPropPrefix, globalSiteId)
local id = nil
local prop = nil
Llinell 2,277 ⟶ 2,235:
end
id = mw.wikibase.getEntityIdForTitle(page, globalSiteId) or ""
end
Llinell 2,324 ⟶ 2,282:
-- get the entity ID from either the positional argument, the eid argument or the page argument
cfg.entityID, cfg.propertyID = getEntityId(lastArg, args[p.args.eid], args[p.args.page], false, args[p.args.globalSiteId])
if cfg.entityID == "" then
Llinell 2,496 ⟶ 2,454:
-- get the entity ID from either the positional argument, the eid argument or the page argument
cfg.entityID = getEntityId(lastArg, args[p.args.eid], args[p.args.page], true, args[p.args.globalSiteId])
if cfg.entityID == "" or not mw.wikibase.entityExists(cfg.entityID) then
|