第10行:
第10行:
for j, r in ipairs(res.results) do
for j, r in ipairs(res.results) do
table.insert(ret, r.fulltext)
table.insert(ret, r.fulltext)
+
end
+
return ret
+
end
+
+
function p.query_page_properties(query, properties)
+
local real_query = query
+
for i, p in ipairs(properties) do
+
real_query = real_query .. "|?" .. p
+
end
+
local res = mw.smw.getQueryResult(real_query)
+
local ret = {}
+
for i, r in ipairs(res.results) do
+
local ans = {}
+
local title = r.fulltext
+
for j, prop in ipairs(properties) do
+
local p_values = {}
+
if r.printouts[prop] then
+
for k, t in ipairs(r.printouts[prop]) do
+
table.insert(p_values, t.fulltext)
+
end
+
end
+
ans[prop] = p_values
+
end
+
table.insert(ret, {title=title, properties=ans})
end
end
return ret
return ret