Anonymous

Changes

From KIproBatt Wiki
update from dev-wiki
Line 14: Line 14:  
if args['custom_id'] ~= nil and args['custom_id'] ~= "" and args['custom_id_pattern'] ~= nil and args['custom_id_replace'] then
 
if args['custom_id'] ~= nil and args['custom_id'] ~= "" and args['custom_id_pattern'] ~= nil and args['custom_id_replace'] then
 
args['custom_id'] = string.gsub(args['custom_id'], args['custom_id_pattern'], args['custom_id_replace'])
 
args['custom_id'] = string.gsub(args['custom_id'], args['custom_id_pattern'], args['custom_id_replace'])
 +
end
 +
 +
if args['label'] ~= nil and args['label'] ~= "" and args['name'] ~= nil and args['name'] then
 +
args['label'] = args['name']
 
end
 
end
 
 
Line 57: Line 61:  
        'LabProcessObject'
 
        'LabProcessObject'
 
    }
 
    }
end
+
    end
 +
   
 +
    -- calculate consumed/remaining quantity
 +
properties["HasQuantifyingQuantity"] = "Property:HasNumberOfEntities" --default
 +
properties["HasNumberOfEntities"] = 1 - p.getConsumedQuantity(page.fullText .. "#" .. subobjectId)
    
mw.logObject(properties)
 
mw.logObject(properties)
Line 186: Line 194:  
end
 
end
 
return result
 
return result
 +
end
 +
 +
function p.getConsumedQuantity(obj)
 +
--mw.logObject(obj)
 +
local query = "[[HasPredecessor::" .. obj .. "]] |headers=hide |?#-=page |mainlabel=- |format=plain"
 +
local result = mw.smw.ask( query )
 +
local consumed = 0
 +
if result ~= nil then
 +
--mw.logObject(result)
 +
for num, row in pairs( result ) do
 +
--mw.logObject(row['page'])
 +
consumed = consumed + 1
 +
end
 +
--mw.logObject(result)
 +
end
 +
return consumed
 
end
 
end
  
Bots, bulkpusher, Bureaucrats, checkuser, filepusher, Interface administrators, oversight, pusher, rdfioadministrator, rdfiocurator, Administrators (Semantic MediaWiki), Curators (Semantic MediaWiki), Editors (Semantic MediaWiki), Administrators
5,444

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.