|
|
Line 3: |
Line 3: |
| local htmlparse = require'Module:HTMLParse' | | local htmlparse = require'Module:HTMLParse' |
| local colorparse = require'Module:ColorParse' | | local colorparse = require'Module:ColorParse' |
| | local util = require'Module:Favilink Utility' |
|
| |
|
| function p.favilink(frame, searchtype) | | function p.favilink(frame, searchtype) |
Line 25: |
Line 26: |
| end | | end |
|
| |
|
| local wherestr = '' | | local result = util.favilink(name, searchtype) |
|
| |
|
| if (searchtype == 'PlainName') then | | if result ~= nil then |
| wherestr = ' AND PlainName="' .. name:gsub("'", "\'") .. '"'
| |
| elseif (searchtype == 'ID') then
| |
| wherestr = ' AND BINARY ObjectID="' .. name:gsub("'", "\'") .. '"'
| |
| elseif (searchtype == '_pageName') then
| |
| wherestr = ' AND _pageName="' .. name:gsub("'", "\'") .. '"'
| |
| end
| |
| | |
| local result = cargo.query('GeneralData','_pageName=Page, DisplayName, Image, DisplayChar, PlainName',{where='_pageNamespace="0"' .. wherestr, default=name, limit='1'} )
| |
| local resulttrue = 0
| |
| | |
| --[If there was no result, search by alias instead]
| |
| if not next(result) then
| |
| if searchtype == 'PlainName' then
| |
| wherestr = ' AND Aliases HOLDS "' .. name:gsub("'", "\'") .. '"'
| |
| elseif searchtype == 'ID' then
| |
| wherestr = ' AND IDAliases HOLDS "' .. name:gsub("'", "\'") .. '"'
| |
| end
| |
| | |
| result = cargo.query('GeneralData','_pageName=Page, DisplayName, Image, DisplayChar, PlainName',{where='_pageNamespace="0"' .. wherestr, default=name, limit='1'} )
| |
| if next(result) then
| |
| resulttrue = 1
| |
| end
| |
| else
| |
| resulttrue = 1
| |
| end
| |
| | |
| if resulttrue == 1 then
| |
| name = result[1]['PlainName'] | | name = result[1]['PlainName'] |
| else | | else |
Line 112: |
Line 86: |
|
| |
|
| function p.idfavilink(frame) | | function p.idfavilink(frame) |
| return p.favilink(frame,'ID') | | return p.favilink(frame,'ObjectID') |
| end | | end |
|
| |
|