יחידה:PropertyLink: הבדלים בין גרסאות בדף

Upper and lower case properties
קצת ניקיון
שורה 1: שורה 1:
function getProperty( propertyName )
function getProperty( propertyName )
     local entity = mw.wikibase.getEntity()
     local entity = mw.wikibase.getEntity()
     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
 
     local property = entity.claims[propertyName]
     local property = entity.claims[propertyName]
     if not property then return end--no such property for this item
     if not property then return end --no such property for this item
 
     property = property[0]
     property = property[0]
     local propValue = property.mainsnak and property.mainsnak.datavalue
     local propValue = property.mainsnak and property.mainsnak.datavalue
     if not propValue then return end --property doesnt exist
     if not propValue then return end --property doesnt exist
     if propValue['type'] == 'wikibase-entityid' then
     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'] )
         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 )
         return linkTarget and linkTitle and mw.ustring.format( "[[%s|%s]]", linkTarget, linkTitle )
             or linkTitle
             or linkTitle
שורה 23: שורה 26:
     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
     local property = entity.claims[propertyName]
     local property = entity.claims[propertyName]
     if not property then return end--no such property for this item
     if not property then return end --no such property for this item
      
      
     property = property[0]
     property = property[0]
שורה 29: שורה 32:
     if not propValue then return '' end --property doesnt exist
     if not propValue then return '' end --property doesnt exist


     if propValue['type']=='wikibase-entityid' then
     if propValue['type'] == 'wikibase-entityid' then
         return mw.wikibase.label( "Q" ..propValue.value['numeric-id'] )
         return mw.wikibase.label( "Q" ..propValue.value['numeric-id'] )
     elseif propValue['type'] == 'string' then
     elseif propValue['type'] == 'string' then