Nicht angemeldeter Benutzer - Bearbeiten von Seiten ist nur als angemeldeter Benutzer möglich.

Änderungen

Zur Navigation springen Zur Suche springen
1.809 Bytes hinzugefügt ,  17:04, 18. Sep. 2020
Test, ob wikibase vorhanden
Zeile 12: Zeile 12:  
["property-not-found"] = "Eigenschaft nicht gefunden.",
 
["property-not-found"] = "Eigenschaft nicht gefunden.",
 
["entity-not-found"] = "Wikidata-Eintrag nicht gefunden.",
 
["entity-not-found"] = "Wikidata-Eintrag nicht gefunden.",
 +
["entity-not-valid"] = "Die an die Wikidata-Schnittstelle übergebene Item-ID ist nicht gültig.",
 
["unknown-claim-type"] = "Unbekannter Aussagentyp.",
 
["unknown-claim-type"] = "Unbekannter Aussagentyp.",
 
["unknown-entity-type"] = "Unbekannter Entity-Typ.",
 
["unknown-entity-type"] = "Unbekannter Entity-Typ.",
Zeile 389: Zeile 390:  
function formatReference(ref)
 
function formatReference(ref)
 
-- "imported from"-references are useless, skip them:
 
-- "imported from"-references are useless, skip them:
if ref["P143"] then return nil end
+
if ref["P143"] or ref["P4656"] then return nil end
 
 
 
-- load [[Modul:Zitation]]
 
-- load [[Modul:Zitation]]
Zeile 395: Zeile 396:  
if type(r) == "table" then
 
if type(r) == "table" then
 
Zitation = r.Zitation()
 
Zitation = r.Zitation()
 +
-- clear Zitation state from previous invocations
 +
Zitation.o = nil
 
end
 
end
 
-- assert (ZitationSuccess, i18n["errors"]["module-not-loaded"])
 
-- assert (ZitationSuccess, i18n["errors"]["module-not-loaded"])
Zeile 441: Zeile 444:  
local URLutil = Zitation.fetch("URLutil")
 
local URLutil = Zitation.fetch("URLutil")
 
Zitation.fill("bas", "Titel", URLutil.getHost(ref["P854"]))
 
Zitation.fill("bas", "Titel", URLutil.getHost(ref["P854"]))
elseif not (ref["P1476"]) then
  −
Zitation.fill("bas", "Titel", ref["P854"])
   
end
 
end
 
refFormatted, f = Zitation.format()
 
refFormatted, f = Zitation.format()
return refFormatted
+
return refFormatted, f
 
end
 
end
   Zeile 465: Zeile 466:  
end
 
end
 
end
 
end
local formattedRef = formatReference(refTable)
+
local formattedRef, f = formatReference(refTable)
if formattedRef then result = result .. frame:extensionTag("ref", formattedRef) end
+
-- log errors that occur during formatting
 +
if f then
 +
mw.log(f)
 +
end
 +
if formattedRef and formattedRef ~= "" then
 +
local hash = mw.hash.hashValue('fnv164', formattedRef)
 +
result = result .. frame:extensionTag("ref", formattedRef, { name = '_' .. hash })
 +
end
 
end
 
end
 
return result
 
return result
Zeile 483: Zeile 491:     
local function qualifierhasvalue(claim, property, value)
 
local function qualifierhasvalue(claim, property, value)
 +
-- TODO: not yet documented!
 
if not claim.qualifiers then return false end
 
if not claim.qualifiers then return false end
 
if not claim.qualifiers[property] then return false end
 
if not claim.qualifiers[property] then return false end
Zeile 536: Zeile 545:     
return true
 
return true
 +
end
 +
 +
local function notdeprecated(claim, sourceproperty)
 +
  return not (claim.rank == "deprecated")
 
end
 
end
   Zeile 556: Zeile 569:  
filter('hassource', hassource)
 
filter('hassource', hassource)
 
filter('atdate', atdate)
 
filter('atdate', atdate)
 +
if not frame.args.includedeprecated then
 +
frame.args.notdeprecated = true
 +
    filter('notdeprecated', notdeprecated)
 +
    end
 
 
 +
-- use additional unnamed parameters as qualifier conditions (in pairs)
 +
-- not yet documented!
 +
-- TODO: not sure if this is good approach. Maybe use named parameter that has pairs split by semicolon
 
for key, val in pairs(frame.args) do
 
for key, val in pairs(frame.args) do
 
if type(key) == "number" and key > 2 and key % 2 == 1 then
 
if type(key) == "number" and key > 2 and key % 2 == 1 then
Zeile 584: Zeile 604:  
local result
 
local result
 
result = isParent(frame.args["id"], frame.args["parent"], frame.args["exitItem"], maxDepth)
 
result = isParent(frame.args["id"], frame.args["parent"], frame.args["exitItem"], maxDepth)
 +
 
if frame.args["returnInt"] then
 
if frame.args["returnInt"] then
if result == true then return 1 else return 0 end
+
if result == true then return 1 else return "" end
 
else
 
else
if result then return result else return "" end
+
if result then return result else return false end
 
end
 
end
 +
 
end
 
end
   Zeile 608: Zeile 630:  
local id = frame.args[2]
 
local id = frame.args[2]
 
-- return label of a Wikidata entity in the given language or the default language of this Wikipedia site
 
-- return label of a Wikidata entity in the given language or the default language of this Wikipedia site
local entity = mw.wikibase.getEntity(id)
+
if mw.wikibase then
 +
    local entity = mw.wikibase.getEntity(id)
 +
end
 
if entity and entity.labels then
 
if entity and entity.labels then
 
local label = entity.labels[langcode or wiki.langcode]
 
local label = entity.labels[langcode or wiki.langcode]
Zeile 635: Zeile 659:     
-- get wikidata entity
 
-- get wikidata entity
local entity = mw.wikibase.getEntity(id)
+
if id then
 +
if not mw.wikibase.isValidEntityId(id) then
 +
if showerrors then return printError("entity-not-valid") else return default end
 +
elseif not mw.wikibase.entityExists(id) then
 +
if showerrors then return printError("entity-not-found") else return default end
 +
end
 +
end
 +
 +
if mw.wikibase then
 +
    local entity = mw.wikibase.getEntity(id)
 +
end
 
if not entity then
 
if not entity then
 
if showerrors then return printError("entity-not-found") else return default end
 
if showerrors then return printError("entity-not-found") else return default end
Zeile 658: Zeile 692:  
local comparator
 
local comparator
 
if sort then
 
if sort then
-- sort by time qualifier
+
comparator = function(a, b) --comparator function for sorting statements based on qualifier value
comparator = function(a, b)
+
-- load qualifier values
local timea = getQualifierSortValue(claims[a], sort)
+
local QualifierSortValueA = getQualifierSortValue(claims[a], sort)
local timeb = getQualifierSortValue(claims[b], sort)
+
local QualifierSortValueB = getQualifierSortValue(claims[b], sort)
if type(timea) ~= type(timeb) and not (tonumber(timea) and tonumber(timeb)) then
+
if tonumber(timea) then return true
+
-- if either of the two statements does not have this qualifer, always sort it to the end. If neither of the two statements has this qualifier, statement A is ordered first
elseif tonumber(timeb) then return false
+
if not QualifierSortValueB then return true end
elseif tostring(timea) and tostring(timeb) then
+
if not QualifierSortValueA then return false end
if inverse then return tostring(timea) > tostring(timeb) else return tostring(timea) < tostring(timeb) end
+
 +
if type(QualifierSortValueA) ~= type(QualifierSortValueB) and not (tonumber(QualifierSortValueA) and tonumber(QualifierSortValueB)) then
 +
if tonumber(QualifierSortValueA) then return true
 +
elseif tonumber(QualifierSortValueB) then return false
 +
elseif tostring(QualifierSortValueA) and tostring(QualifierSortValueB) then
 +
if inverse then return tostring(QualifierSortValueA) > tostring(QualifierSortValueB) else return tostring(QualifierSortValueA) < tostring(QualifierSortValueB) end
 
else return false end -- different types, neither numbers nor strings, no chance to compare => random result to avoid script error
 
else return false end -- different types, neither numbers nor strings, no chance to compare => random result to avoid script error
elseif tonumber(timea) and tonumber(timeb) then
+
elseif tonumber(QualifierSortValueA) and tonumber(QualifierSortValueB) then
timea = tonumber(timea)
+
QualifierSortValueA = tonumber(QualifierSortValueA)
timeb = tonumber(timeb)
+
QualifierSortValueB = tonumber(QualifierSortValueB)
 
end
 
end
 
if inverse then
 
if inverse then
return timea > timeb
+
return QualifierSortValueA > QualifierSortValueB
 
else
 
else
return timea < timeb
+
return QualifierSortValueA < QualifierSortValueB
 
end
 
end
 
end
 
end
Zeile 767: Zeile 806:  
local id = frame.args[1]
 
local id = frame.args[1]
 
local entity = mw.wikibase.getEntity(id)
 
local entity = mw.wikibase.getEntity(id)
if not entity then return nil else return entity.id end
+
if not entity then return "" else return entity.id end
 
end
 
end
  
Cookies helfen uns bei der Bereitstellung von imedwiki. Durch die Nutzung von imedwiki erklärst du dich damit einverstanden, dass wir Cookies speichern.

Navigationsmenü