Module:Favilink: Difference between revisions

Jump to navigation Jump to search
mNo edit summary
(added idfavilink)
Line 4: Line 4:
local colorparse = require'Module:ColorParse'
local colorparse = require'Module:ColorParse'


function p.favilink(frame,arg)
function p.favilink(frame, searchtype)
local displayname_tooltip_override = false
local displayname_tooltip_override = false


Line 12: Line 12:
local modifier
local modifier


if frame.args ~=nil and frame.args ~= '' then
searchtype = searchtype or 'PlainName'
if frame.args ~= nil and frame.args ~= '' then
   if frame.args[1] ~= nil and frame.args[1] ~= '' then
   if frame.args[1] ~= nil and frame.args[1] ~= '' then
   name = mw.text.trim(frame:preprocess(frame.args[1]))
   name = mw.text.trim(frame:preprocess(frame.args[1]))
Line 19: Line 21:
     error "There is no argument specified! [[Category:pages with favilink errors]]"
     error "There is no argument specified! [[Category:pages with favilink errors]]"
   end
   end
else
  name = mw.text.trim(frame) or "No Value"
  modifier = mw.text.trim(arg) or "No Value"
end
end


local wherestr = ''


local result = cargo.query('GeneralData','_pageName=Page, DisplayName, Image, DisplayChar',{where='_pageNamespace="0" AND PlainName="' .. name:gsub("'", "\'") .. '"', default=name, limit='1'} )
if (searchtype == 'PlainName') then
  wherestr = ' AND PlainName="' .. name:gsub("'", "\'") .. '"'
elseif (searchtype == 'ID') then
  wherestr = ' AND ObjectID="' .. name:gsub("'", "\'") .. '"'
end
 
local result = cargo.query('GeneralData','_pageName=Page, DisplayName, Image, DisplayChar',{where='_pageNamespace="0"' .. wherestr, default=name, limit='1'} )


if not next(result) then
if not next(result) then
Line 80: Line 86:
return tostring(qudimage)
return tostring(qudimage)


end
function p.idfavilink(frame)
  return p.favilink(frame,'ID')
end
end


return p
return p