Module:TestModule: Difference between revisions

AdamZachar (talk | contribs)
No edit summary
AdamZachar (talk | contribs)
No edit summary
 
(20 intermediate revisions by the same user not shown)
Line 7: Line 7:
  local topics, errors = mw.ext.externaldata.getExternalData {
  local topics, errors = mw.ext.externaldata.getExternalData {
   source = "CaseData",
   source = "CaseData",
   query = "childrenTopics",
   query = "childrenTopics", --Note: this query is deprecated in deference to ChildrenTopicsByID, since it relied on topics.topic_parentname
   data = "topicName=topic_name",
   data = "topicName=topic_name",
   parameters = parentTopic
   parameters = parentTopic
Line 31: Line 31:
function p.recurseLineage( frame )
function p.recurseLineage( frame )


  return funcRecurseLineage(frame.args.parentTopic)
  return funcRecurseLineage(frame.args.parentTopic) --Note: this query is deprecated in deference to ChildrenTopicsByID


end
end
Line 54: Line 54:
   for i, topic in ipairs(topics) do
   for i, topic in ipairs(topics) do
   output = output .. " <li>" .. "[[" .. topic.topicName .. "]]"
   output = output .. " <li>" .. "[[" .. topic.topicName .. "]]"
   output = output .. funcRecurseLineage(topic.topicID)
   output = output .. funcRecurseLineageNumber(topic.topicID)
   end
   end
   output = output .. "</ul>"
   output = output .. "</ul>"
Line 64: Line 64:




function p.recurseLineageNumber( frame )
function p.recurseLineageByID( frame )
 
local topics, errors = mw.ext.externaldata.getExternalData {
  source = "CaseData",
  query = "childrenTopicsByID",
  data = "topicName=topic_name, topicID=topic_id",
  parameters = frame.args.parentID
  }
 
if topics == nil then return "N/A" end


  return funcRecurseLineageNumber(frame.args.parentID)
  return funcRecurseLineageNumber(frame.args.parentID)
Line 70: Line 79:
end
end


function p.topicIDByName( frame )
local topics, errors = mw.ext.externaldata.getExternalData {
  source = "CaseData",
  query = "oneTopic",
  data = "topicID=topic_id",
  parameters = frame.args.topicName
  }
if topics == nil then return 0 end
return topics.topicID
end
function p.topicListByCaseName( frame )
local output = ""
local topics, errors = mw.ext.externaldata.getExternalData {
  source = "CaseData",
  query = "topicsByCase",
  data = "topicName=topic_name",
  parameters = frame.args.caseTitle
  }
if topics == nil then return output end
output = output .. "<ul>"
for i, topic in ipairs(topics) do
  output = output .. " <li>" .. "[[" .. topic.topicName .. "]]"
end
output = output .. "</ul>"
return output
end


return p
return p