Bearbeiten von „Modul:PropertyLink

    Warnung: Du bist nicht angemeldet. Deine IP-Adresse wird bei Bearbeitungen öffentlich sichtbar. Melde dich an oder erstelle ein Benutzerkonto, damit Bearbeitungen deinem Benutzernamen zugeordnet werden. Ein eigenes Benutzerkonto hat eine ganze Reihe von Vorteilen.

    Die Bearbeitung kann rückgängig gemacht werden. Bitte prüfe den Vergleich unten, um sicherzustellen, dass du dies tun möchtest, und veröffentliche dann unten deine Änderungen, um die Bearbeitung rückgängig zu machen.

    Aktuelle Version Dein Text
    Zeile 1: Zeile 1:
    function getLinkLabel(propValue, frame)
    function getProperty( propertyName )
    if propValue['type'] == 'wikibase-entityid' then
        local entity = mw.wikibase.getEntityObject()
    local isWikipedia = false
        if not entity or not entity.claims then return end--the entity doesnt exist or have no claims
        local property = entity.claims[propertyName]
        if not property then return end--no such property for this item
        property = property[1]
        local propValue = property.mainsnak and property.mainsnak.datavalue
        if not propValue then return end --property doesnt exist
        if propValue['type'] == 'wikibase-entityid' then
             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 7: Zeile 13:
             if targetEntity and targetEntity['sitelinks'] then
             if targetEntity and targetEntity['sitelinks'] then
             if targetEntity['sitelinks']['dewiki'] then
             if targetEntity['sitelinks']['dewiki'] then
             linkTarget = string.gsub('de:' .. targetEntity['sitelinks']['dewiki']['title'], ' ', '_')
             linkTarget = 'wikipedia:de:' .. targetEntity['sitelinks']['dewiki']['title']
            isWikipedia = true
             elseif targetEntity['sitelinks']['enwiki'] then
             elseif targetEntity['sitelinks']['enwiki'] then
             linkTarget = string.gsub(targetEntity['sitelinks']['enwiki']['title'], ' ', '_')
             linkTarget = 'wikipedia:' .. 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 )
            if isWikipedia then
                 or linkTitle
            template = "{{WikipediaLink|%s|%s}}"
         elseif propValue and propValue['type'] == 'string' then return propValue.value end
            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
        return propValue.value
        end
    end
    end
     
    function getProperty(propertyName, frame)
        local entity = mw.wikibase.getEntityObject()
        if not entity or not entity.claims then return end--the entity doesnt exist or have no claims
        local property = entity.claims[propertyName]
        if not property then return end--no such property for this item
        property = property[1]
        local propValue = property.mainsnak and property.mainsnak.datavalue
        if not propValue then return end --property doesnt exist
     
    local label = getLinkLabel(propValue, frame)
    if not label == propValue then
    return label
    end
    if property.qualifiers and property.qualifiers["P27"] then
    return mw.ustring.format( "[%s %s]", property.qualifiers["P27"][1].datavalue.value, label )
    end
    return label
    end
     
    function property( frame )
    function property( frame )
         return getProperty(string.upper(frame.args[1], frame), frame)
         return getProperty(string.upper(frame.args[1]))
    end
    end
     
    function getLabel( propertyName )
    function getLabel( propertyName )
         local entity = mw.wikibase.getEntity()
         local entity = mw.wikibase.getEntity()
    Zeile 74: Zeile 45:
         end
         end
    end
    end
    function getLinkLabels( frame )
    propertyName = frame.args[1]
        local entity = mw.wikibase.getEntityObject()
        if not entity or not entity.claims then return end--the entity doesnt exist or have no claims
        local properties = entity.claims[propertyName]
        if not properties then return end--no such property for this item
       
       
        local retVal = ''
        for propIndex in pairs(properties) do
        local property = properties[propIndex]
    local propValue = property.mainsnak.datavalue
    if not propValue then return '' end --property doesnt exist
    local value = getLinkLabel(propValue, frame)
    if retVal == '' then
    retVal = value
    else
    retVal = retVal .. ', ' .. value
    end
    end
    return retVal
    end
    -- Return the label for property, or the label of the linked entiy of that property
    -- Return the label for property, or the label of the linked entiy of that property
    function label( frame )
    function label( frame )
         return getLabel(string.lower(frame.args[1]))
         return getLabel( string.lower(frame.args[1] ))
    end
    end


    Zeile 129: Zeile 76:
         getProperty = getProperty,
         getProperty = getProperty,
         getImageLink = getImageLink,
         getImageLink = getImageLink,
         getLabel = getLabel,
         getLabel = getLabel
        getLinkLabels = getLinkLabels,
    }
    }
    Bitte kopiere keine Webseiten, die nicht deine eigenen sind, benutze keine urheberrechtlich geschützten Werke ohne Erlaubnis des Urhebers!
    Du gibst uns hiermit deine Zusage, dass du den Text selbst verfasst hast, dass der Text Allgemeingut (public domain) ist, oder dass der Urheber seine Zustimmung gegeben hat. Falls dieser Text bereits woanders veröffentlicht wurde, weise bitte auf der Diskussionsseite darauf hin. Bitte beachte, dass alle Android Wiki-Beiträge automatisch unter der „Creative Commons Attribution/Share-Alike Lizenz 3.0“ stehen. Falls du nicht möchtest, dass deine Arbeit hier von anderen verändert und verbreitet wird, dann klicke nicht auf „Seite speichern“.

    Um das Wiki vor automatisiertem Bearbeitungsspam zu schützen, bitten wir dich, das folgende CAPTCHA zu lösen:

    Abbrechen Bearbeitungshilfe (wird in einem neuen Fenster geöffnet)
    Vorschau der Seite mit dieser Vorlage anzeigen

    Die folgende Vorlage wird auf dieser Seite verwendet: