Zum Inhalt springen

Modul:PropertyLink: Unterschied zwischen den Versionen

416 Bytes hinzugefügt ,  25. Juli 2018
keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
function getLinkLabel(propValue)
function getLinkLabel(propValue, frame)
if propValue['type'] == 'wikibase-entityid' then
if propValue['type'] == 'wikibase-entityid' then
local isWikipedia = false
         local linkTarget = mw.wikibase.sitelink( "Q" .. propValue.value['numeric-id'] )
         local linkTarget = mw.wikibase.sitelink( "Q" .. propValue.value['numeric-id'] )
         if not linkTarget then
         if not linkTarget then
Zeile 6: Zeile 7:
         if targetEntity and targetEntity['sitelinks'] then
         if targetEntity and targetEntity['sitelinks'] then
         if targetEntity['sitelinks']['dewiki'] then
         if targetEntity['sitelinks']['dewiki'] then
         linkTarget = 'wikipedia:de:' .. targetEntity['sitelinks']['dewiki']['title']
         linkTarget = string.gsub('de:' .. targetEntity['sitelinks']['dewiki']['title'], ' ', '_')
        isWikipedia = true
         elseif targetEntity['sitelinks']['enwiki'] then
         elseif targetEntity['sitelinks']['enwiki'] then
         linkTarget = 'wikipedia:' .. targetEntity['sitelinks']['enwiki']['title']
         linkTarget = string.gsub(targetEntity['sitelinks']['enwiki']['title'], ' ', '_')
        isWikipedia = true
     end
     end
end
end
    end
end
         local linkTitle = mw.wikibase.label( "Q" ..propValue.value['numeric-id'] )
         local linkTitle = mw.wikibase.label( "Q" ..propValue.value['numeric-id'] )
         return linkTarget and linkTitle and mw.ustring.format( "[[%s|%s]]", linkTarget, linkTitle )
          
             or linkTitle
        if isWikipedia then
        template = "{{WikipediaLink|%s|%s}}"
        end
        if linkTarget and linkTitle then
        if isWikipedia then
        return frame:expandTemplate{ title = 'WikipediaLink', args = { linkTarget, linkTitle } }
        end
        return mw.ustring.format( "[[%s|%s]]", linkTarget, linkTitle )
        else
             return linkTitle
        end
     elseif propValue and propValue['type'] == 'string' then
     elseif propValue and propValue['type'] == 'string' then
     return propValue.value
     return propValue.value
Zeile 20: Zeile 33:
end
end


function getProperty( propertyName )
function getProperty(propertyName, frame)
     local entity = mw.wikibase.getEntityObject()
     local entity = mw.wikibase.getEntityObject()
     if not entity or not entity.claims then return end--the entity doesnt exist or have no claims
     if not entity or not entity.claims then return end--the entity doesnt exist or have no claims
Zeile 29: Zeile 42:
     if not propValue then return end --property doesnt exist
     if not propValue then return end --property doesnt exist


return getLinkLabel(propValue)
return getLinkLabel(propValue, frame)
end
end
   
   
function property( frame )
function property( frame )
     return getProperty(string.upper(frame.args[1]))
     return getProperty(string.upper(frame.args[1], frame))
end
end


Zeile 66: Zeile 79:
if not propValue then return '' end --property doesnt exist
if not propValue then return '' end --property doesnt exist


local value = getLinkLabel(propValue)
local value = getLinkLabel(propValue, frame)
if retVal == '' then
if retVal == '' then
retVal = value
retVal = value
11.008

Bearbeitungen

Cookies helfen uns bei der Bereitstellung von Android Wiki. Durch die Nutzung von Android Wiki erklärst du dich damit einverstanden, dass wir Cookies speichern.