Модуль:PersTools: различия между версиями
Перейти к навигации
Перейти к поиску
StasR (обсуждение | вклад) Нет описания правки |
StasR (обсуждение | вклад) Нет описания правки |
||
Строка 1: | Строка 1: | ||
local perstools = {} | local perstools = {} | ||
local markerCode = { | local markerCode = { | ||
nil, | nil, | ||
nil, | nil, | ||
'<i class="fa fa-$1 fa-2x" style="color:#bbbbbb" title="$2"></i>', | '<i class="fa fa-$1 fa-2x" style="color:#bbbbbb" title="$2"></i>', | ||
Строка 31: | Строка 31: | ||
.. '<i class="fa fa-$1 fa-stack-1x" style="color:#f4cb43"></i>' | .. '<i class="fa fa-$1 fa-stack-1x" style="color:#f4cb43"></i>' | ||
.. '<i class="fa fa-ban fa-stack-2x" style="color:#ff6363"></i></span>', | .. '<i class="fa fa-ban fa-stack-2x" style="color:#ff6363"></i></span>', | ||
} | } | ||
-- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | -- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ||
perstools.preposition = { '', '', 'на', 'до', 'до', 'до', '', 'c', '', '', '', 'c', '', '' } | perstools.preposition = { '', '', 'на', 'до', 'до', 'до', '', 'c', '', '', '', 'c', '', '' } | ||
function perstools.fixedColumns( origin, marker, date, precision, noPrep, icon ) | function perstools.fixedColumns( origin, marker, date, precision, noPrep, icon ) | ||
Строка 64: | Строка 64: | ||
.. '<td class="nkvd-table-date">' .. da .. '</td>' | .. '<td class="nkvd-table-date">' .. da .. '</td>' | ||
end | end | ||
function perstools.makeWhere( gFio ) | |||
local where = {} | |||
local tmp | |||
for _, fio in ipairs( gFio ) do | |||
tmp = 'lastN="' .. fio.f .. '"' | |||
if fio.f then | |||
tmp = tmp .. ' AND (nFirst="" OR nFirst LIKE "' .. mw.ustring.sub( fio.f, 1, 1 ) .. '%")' | |||
end | |||
if fio.m then | |||
tmp = tmp .. ' AND (nMiddle="" OR nMiddle LIKE "' .. mw.ustring.sub( fio.m, 1, 1 ) .. '%")' | |||
end | |||
if fio.d then | |||
tmp = tmp .. ' AND nDisambig IN (NULL, "' .. fio.d .. '")' | |||
end | |||
where[#where+1] = tmp | |||
end | |||
return table.concat( where, ' OR ' ) | |||
end | |||
--[===[ | |||
function perstools.makePerson( row ) | |||
local person, i, o, d = row.nLast, row.nFirst, row.nMiddle, row.nDisambig | |||
if i ~= '' or o ~= '' then | |||
person = person .. ', ' | |||
if i == '' then | |||
i = '...' | |||
elseif mw.ustring.len( i ) == 1 then | |||
i = i .. '.' | |||
end | |||
person = person .. i | |||
if o ~= '' then | |||
if mw.ustring.len( o ) == 1 then | |||
o = o .. '.' | |||
end | |||
person = person .. ' ' .. o | |||
end | |||
end | |||
if d then | |||
return person .. ' ' .. d | |||
end | |||
return person | |||
end | |||
--]===] | |||
function perstools.makePersonLink( row ) | |||
local person, i, o, d = row.nLast, row.nFirst, row.nMiddle, row.nDisambig | |||
if i ~= '' or o ~= '' then | |||
person = person .. ', ' | |||
if i == '' then | |||
i = '...' | |||
elseif mw.ustring.len( i ) == 1 then | |||
i = i .. '.' | |||
end | |||
person = person .. i | |||
if o ~= '' then | |||
if mw.ustring.len( o ) == 1 then | |||
o = o .. '.' | |||
end | |||
person = person .. ' ' .. o | |||
end | |||
end | |||
if d ~= '' then | |||
local ds = d | |||
-- if d == '(*)' then | |||
-- ds = '<i class="fa fa-asterisk fa-lg"></i>' | |||
-- end | |||
return '[[' .. person .. ' ' .. d .. '|' | |||
.. person .. ' <span class="nkvd-idx">' .. ds .. '</span>]]' | |||
end | |||
return '[[' .. person .. ']]' | |||
end | |||
return perstools | return perstools |
Версия от 00:49, 27 февраля 2017
Для документации этого модуля может быть создана страница Модуль:PersTools/doc
local perstools = {}
local markerCode = {
nil,
nil,
'<i class="fa fa-$1 fa-2x" style="color:#bbbbbb" title="$2"></i>',
'<i class="fa fa-$1 fa-2x" style="color:#888888" title="$2"></i>',
'<span class="fa-stack" title="$2">'
.. '<i class="fa fa-$1 fa-stack-1x" style="color:#bbbbbb"></i>' -- было 888888
.. '<i class="fa fa-circle-o fa-stack-2x" style="color:#888888"></i></span>', -- было ff6363
'<span class="fa-stack" title="$2">'
.. '<i class="fa fa-$1 fa-stack-1x" style="color:#bbbbbb"></i>' -- было 888888
.. '<i class="fa fa-ban fa-stack-2x" style="color:#888888"></i></span>', -- было ff6363
nil,
'<span class="fa-stack" title="$2">'
.. '<i class="fa fa-square fa-stack-2x" style="color:#888888"></i>'
.. '<i class="fa fa-$1 fa-stack-1x" style="color:#bbbbbb"></i></span>',
'<span class="fa-stack" title="$2">'
.. '<i class="fa fa-square fa-stack-2x" style="color:#888888"></i>'
.. '<i class="fa fa-$1 fa-stack-1x" style="color:#bbbbbb"></i>'
.. '<i class="fa fa-circle-o fa-stack-2x" style="color:#dc8383"></i></span>',
'<span class="fa-stack" title="$2">'
.. '<i class="fa fa-square fa-stack-2x" style="color:#888888"></i>'
.. '<i class="fa fa-$1 fa-stack-1x" style="color:#bbbbbb"></i>'
.. '<i class="fa fa-ban fa-stack-2x" style="color:#dc8383"></i></span>',
'<i class="fa fa-times-circle fa-2x" style="color:#ff6363" title="$2"></i>',
'<i class="fa fa-$1 fa-2x" style="color:#f4cb43" title="$2"></i>',
'<span class="fa-stack" title="$2">'
.. '<i class="fa fa-$1 fa-stack-1x" style="color:#f4cb43"></i>'
.. '<i class="fa fa-circle-o fa-stack-2x" style="color:#ff6363">',
'<span class="fa-stack" title="$2">'
.. '<i class="fa fa-$1 fa-stack-1x" style="color:#f4cb43"></i>'
.. '<i class="fa fa-ban fa-stack-2x" style="color:#ff6363"></i></span>',
}
-- 1 2 3 4 5 6 7 8 9 10 11 12 13 14
perstools.preposition = { '', '', 'на', 'до', 'до', 'до', '', 'c', '', '', '', 'c', '', '' }
function perstools.fixedColumns( origin, marker, date, precision, noPrep, icon )
origin = tonumber(origin)
local x = markerCode[origin] or ''
if noPrep then
noPrep = ''
else
noPrep = perstools.preposition[origin]
end
local da
if date == '' then
da = '—'
noPrep = ''
else
da = string.sub( date, 1, 4 )
if precision ~= '3' then
da = string.sub( date, 6, 7 ) .. '.' .. da
end
if precision == '1' then
da = string.sub( date, 9, 10 ) .. '.' .. da
end
end
if not icon then
icon = string.gsub( x, '%$[12]', { ['$1'] = marker.icon, ['$2'] = marker[origin] } )
end
return '<td class="nkvd-table-marker">' .. icon .. '</td>'
.. '<td class="nkvd-table-preposition">' .. (noPrep or '') .. '</td>'
.. '<td class="nkvd-table-date">' .. da .. '</td>'
end
function perstools.makeWhere( gFio )
local where = {}
local tmp
for _, fio in ipairs( gFio ) do
tmp = 'lastN="' .. fio.f .. '"'
if fio.f then
tmp = tmp .. ' AND (nFirst="" OR nFirst LIKE "' .. mw.ustring.sub( fio.f, 1, 1 ) .. '%")'
end
if fio.m then
tmp = tmp .. ' AND (nMiddle="" OR nMiddle LIKE "' .. mw.ustring.sub( fio.m, 1, 1 ) .. '%")'
end
if fio.d then
tmp = tmp .. ' AND nDisambig IN (NULL, "' .. fio.d .. '")'
end
where[#where+1] = tmp
end
return table.concat( where, ' OR ' )
end
--[===[
function perstools.makePerson( row )
local person, i, o, d = row.nLast, row.nFirst, row.nMiddle, row.nDisambig
if i ~= '' or o ~= '' then
person = person .. ', '
if i == '' then
i = '...'
elseif mw.ustring.len( i ) == 1 then
i = i .. '.'
end
person = person .. i
if o ~= '' then
if mw.ustring.len( o ) == 1 then
o = o .. '.'
end
person = person .. ' ' .. o
end
end
if d then
return person .. ' ' .. d
end
return person
end
--]===]
function perstools.makePersonLink( row )
local person, i, o, d = row.nLast, row.nFirst, row.nMiddle, row.nDisambig
if i ~= '' or o ~= '' then
person = person .. ', '
if i == '' then
i = '...'
elseif mw.ustring.len( i ) == 1 then
i = i .. '.'
end
person = person .. i
if o ~= '' then
if mw.ustring.len( o ) == 1 then
o = o .. '.'
end
person = person .. ' ' .. o
end
end
if d ~= '' then
local ds = d
-- if d == '(*)' then
-- ds = '<i class="fa fa-asterisk fa-lg"></i>'
-- end
return '[[' .. person .. ' ' .. d .. '|'
.. person .. ' <span class="nkvd-idx">' .. ds .. '</span>]]'
end
return '[[' .. person .. ']]'
end
return perstools