Модуль:Образец
Материал из Справочника наблюдателя
Описание модуля[]
Документация отсутствует!
Вы можете создать документацию ( создать ).
Задавайте категории на странице документации, а не здесь! Показать подстраницы
Задавайте категории на странице документации, а не здесь! Показать подстраницы
local p = {}
local blank = require( 'Модуль:Бланки' )
local tabformat = {
['pdf'] = {
['alt'] = 'бланк для рукописного заполнения',
['lnk'] = 'Бланк для рукописного заполнения',
['ext'] = '.pdf',
['yes'] = 'Pdf icon.png',
['no'] = 'Pdf icon-none.png',
},
['odt'] = {
['alt'] = 'файл для редактирования в формате Open Document',
['lnk'] = 'Файл в формате Open Document',
['ext'] = '!.odt',
['yes'] = 'LibreOffice_Writer_icon_3.3.1_48_px.svg',
['no'] = 'Rtf-none.gif',
},
['doc'] = {
['alt'] = 'файл для редактирования в формате MS Word',
['lnk'] = 'Файл в формате MS Word',
['ext'] = '!.doc',
['yes'] = 'MS word DOC icon.svg',
['no'] = 'Rtf-none.gif',
},
['.odt'] = {
['alt'] = 'исходный текст бланка',
['lnk'] = 'Исходный текст бланка',
['ext'] = '.odt',
['yes'] = 'LibreOffice_Writer_icon_3.3.1_48_px.svg',
['no'] = 'Rtf-none.gif',
},
}
local function anaList( arg, set )
local res = {}
local arga = mw.text.split( mw.ustring.lower( arg or '' ), '[\t\r\n\f ]*[,;][\t\r\n\f ]*' )
for _, el in ipairs( arga ) do
if set[el] then
res[el] = true
elseif el ~= '' then
return el
end
end
return res
end
function fileExists( name )
local fiti = mw.title.new (name, 'File')
return fiti.id ~= 0
end
local function aboutFile( title, subtitle, ext )
local fiti = fileExists( title.text .. subtitle .. tabformat[ext].ext )
if fiti then
return
'[[Файл:' .. tabformat[ext].yes .. '|x32px|Скачать ' .. tabformat[ext].alt .. '|link='
.. mw.getCurrentFrame():callParserFunction( 'filepath', title.text .. subtitle .. tabformat[ext].ext ) .. ']]' ,
'[[:Файл:' .. title.text .. tabformat[ext].ext .. '|<span title="Информация о файле"><tt> i</tt></span>]]'
end
return
'[[Файл:' .. tabformat[ext].no .. '|x32px|Пока не создан ' .. tabformat[ext].alt .. '|link='
.. tostring(mw.uri.fullUrl( 'Special:Upload', { wpDestFile = title:partialUrl() .. subtitle .. tabformat[ext].ext
.. '&wpUploadDescription=%7B%7BОбразец%7D%7D'} )) .. ']]',
'[[Набла:Как создавать бланки для скачивания|<tt> ?</tt>]][[Категория:Образцы с отсутствующими файлами ' .. ext .. ']]'
end
local function fileCells( title, subtitle, pdf, doc )
if subtitle ~= '' then
subtitle = ' (' .. subtitle .. ')'
end
local x, y = {}, {}
if pdf then
x[1], y[1] = aboutFile( title, subtitle, 'pdf' )
end
if doc then
x[2], y[2] = aboutFile( title, subtitle, 'doc' )
x[3], y[3] = aboutFile( title, subtitle, 'odt' )
end
local res = {}
for i = 1, 3 do
res[#res+1] = '<td style="border:1px solid gray; width:33.3%; padding:1px; ">'
res[#res+1] = '<div style="text-align:center; width:100%; ">'
res[#res+1] = x[i] or ''
res[#res+1] = '</div><div style="text-align:right; width:100%; font-size:75%; line-height:90%; padding-top: 2px;">'
res[#res+1] = y[i] or ''
res[#res+1] = '</div></td>'
end
return table.concat( res )
end
local constTo = { ['уик'] = true, ['тик'] = true, ['иксрф'] = true, ['цик'] = true,
['ик'] = true, ['полиция'] = true, ['прокуратура'] = true, ['ск'] = true,
['адм'] = true, ['суд'] = true, ['иные'] = true, ['варианты'] = true, }
local constUser = { ['прг'] = true, ['чпрг'] = true, ['псг'] = true,
['чпсг'] = true, ['набл'] = true, ['наблюдатель'] = true, ['сми'] = true,
['список30'] = true, ['избиратель'] = true, ['любой'] = true, ['гражданин'] = true,
['особый'] = true, ['варианты'] = true, }
local constWhere = {
['уик'] = 'УИК',
['тик'] = 'ТИК (или иная вышестоящая комиссия)',
['иксрф'] = 'избирательная комиссия субъекта Российской Федерации',
['ик'] = 'избирательная комиссия любого уровня',
['варианты'] = true,
}
local constFormat = { ['pdf'] = true, ['doc'] = true, }
function p.Main( frame )
local args = frame:getParent().args
local page = mw.text.trim( args[1] or '' )
if page ~= '' then
page = mw.title.new( page )
else
page = mw.title.getCurrentTitle()
end
if page.nsText == 'Файл' then
return mainFile( frame, page )
end
local patternTo = anaList( args['куда'], constTo )
local patternUser = anaList( args['для'], constUser )
local patternWhere = anaList( args['где'], constWhere )
local patternFormat = anaList( args['формат'], constFormat )
local patternCase = args['ТС'] or ''
local patternDescr = args['описание'] or args['ТСдоп'] or ''
local patternStatus = mw.ustring.lower (args ['сила'] or args['статус'] or '')
local patternSource = args['док'] or ''
local patternAlso = args['см.'] or ''
local patternComment= args['комментарий'] or args['правки'] or ''
-- local patternReg = args['регион'] or ''
-- local patternMain = args['общий'] or ''
local patternVar = args['вариант'] or ''
local out = {}
if patternVar ~= '' then
out[#out+1] = '<hr>'
end
local number, mode, father, template = blank.getNumber( page.text )
if patternVar ~= '' then
number = number .. '-' .. patternVar
end
out[#out+1] = '<table class="pull-right col-xs-12" style="border:1px solid gray; margin-left:5px; width:150px; border-collapse: collapse; "><tr>'
out[#out+1] = fileCells( page, patternVar, patternFormat.pdf, patternFormat.doc )
out[#out+1] = '</tr>'
-- здесь надо добавить номер
out[#out+1] = '<tr><td colspan=3 style="text-align:center; font-weight:bold; font-size:115%">' .. number .. '</td></tr>'
out[#out+1] = '</table><div class="clearfix visible-xs-block"></div>'
if patternCase ~= '' then
out[#out+1] = '<p>' .. patternCase .. '</p>'
end
if patternDescr ~= '' then
out[#out+1] = '<p class=small>' .. patternDescr .. '</p>'
end
if patternStatus ~= '' and patternStatus ~= 'нет' then
out[#out+1] = '<p><i>Статус образца:</i> '
if patternStatus == 'норматив' or patternStatus == 'норма' then
out[#out+1] = 'обязательный'
elseif patternStatus == 'рекомендация' then
out[#out+1] = 'официально рекомендованная форма'
elseif patternStatus == 'позиция' then
out[#out+1] = 'ненормативная рекомендация'
else
out[#out+1] = '<span class=error>' .. patternStatus .. '</span>'
end
if patternSource ~= '' then
out[#out+1] = ' (' .. patternSource .. ')'
end
out[#out+1] = '.</p>'
end
if next( patternWhere ) and not patternWhere['варианты'] then
out[#out+1] = '<p><i>Места возникновения ситуации:</i> '
if patternWhere['ик'] then
out[#out+1] = constWhere['ик']
else
local uu = {}
for u, _ in pairs( patternWhere ) do
uu[#uu+1] = constWhere[u]
end
out[#out+1] = table.concat( uu, '; ' )
end
out[#out+1] = '.</p>'
end
patternUser['любой'] = patternUser['любой'] or patternUser['гражданин']
patternUser['прг'] = patternUser['прг'] or patternUser['чпрг'] or patternUser['любой']
patternUser['псг'] = patternUser['псг'] or patternUser['чпсг'] or patternUser['любой']
patternUser['набл'] = patternUser['набл'] or patternUser['наблюдатель'] or patternUser['любой']
patternUser['список30'] = patternUser['список30'] or patternUser['любой'] -- or patternUser['список30:1']
patternUser['сми'] = patternUser['сми'] or patternUser['список30']
if next( patternUser ) and not patternUser['варианты'] then
out[#out+1] = '<p><i>Документ могут использовать:</i> '
if patternUser['любой'] then
out[#out+1] = 'любые лица, независимо от наличия статуса'
else
local uu = {}
if patternUser['прг'] and patternUser['псг'] then
uu[#uu+1] = 'члены комиссий с правом решающего и совещательного голоса'
elseif patternUser['прг'] then
uu[#uu+1] = 'члены комиссий с правом решающего голоса'
elseif patternUser['псг'] then
uu[#uu+1] = 'члены комиссий с правом совещательного голоса'
end
if patternUser['набл'] then
uu[#uu+1] = 'наблюдатели'
end
if patternUser['список30'] then
uu[#uu+1] = 'представители СМИ и иные лица, указанные в [[НПА:Об основных гарантиях избирательных прав (федеральный закон от 12.06.2002 № 67-ФЗ):Статья 30|п. 1 ст. 30 ФЗГ]]'
elseif patternUser['сми'] then
uu[#uu+1] = 'представители СМИ'
end
out[#out+1] = table.concat( uu, '; ' )
end
out[#out+1] = '.</p>'
end
-- patternWhere['уик'] = patternWhere['уик'] or patternWhere['ик']
-- patternWhere['тик'] = patternWhere['тик'] or patternWhere['ик']
-- patternWhere['иксрф'] = patternWhere['иксрф'] or patternWhere['ик']
-- patternWhere['цик'] = patternWhere['цик'] or patternWhere['ик']
if next( patternTo ) and not patternTo['варианты'] then
out[#out+1] = '<p><i>Адресаты документа:</i> '
local uu = {}
if patternTo['ик'] then
uu[#uu+1] = 'избирательные комиссии всех уровней'
else
if patternTo['уик'] then
uu[#uu+1] = 'УИК'
end
if patternTo['тик'] then
uu[#uu+1] = 'ТИК (или иная вышестоящая комиссия)'
end
if patternTo['иксрф'] then
uu[#uu+1] = 'избирательная комиссия субъекта Федерации'
end
if patternTo['цик'] then
uu[#uu+1] = 'Центральная избирательная комиссия'
end
end
if patternTo['адм'] then
uu[#uu+1] = 'местная администрация'
end
if patternTo['полиция'] then
uu[#uu+1] = 'полиция'
end
if patternTo['прокуратура'] then
uu[#uu+1] = 'прокуратура'
end
if patternTo['ск'] then
uu[#uu+1] = 'следственные органы'
end
if patternTo['суд'] then
uu[#uu+1] = 'суд '
end
if patternTo['иные'] then
uu[#uu+1] = 'иные органы (см. пояснения)'
end
out[#out+1] = table.concat( uu, '; ' )
out[#out+1] = '.</p>'
end
if patternVar == '' then
if template.poses then
out[#out+1] = '<p><i>Варианты документа для отдельных статусов:</i></p>'
for _, v in ipairs( template.poses ) do
out[#out+1] = '\n* [[' .. v.title .. ']]'
end
out[#out+1] = '\n'
end
if template.regions then
out[#out+1] = '<p><i>Варианты документа для отдельных регионов/кампаний:</i></p>'
for _, v in ipairs( template.regions ) do
out[#out+1] = '\n* [[' .. v.title .. ']]'
end
out[#out+1] = '\n'
end
if father then
out[#out+1] = '<p><i>Более универсальный вариант документа:</i> '
out[#out+1] = '[[' .. father.title .. ']]'
out[#out+1] = '.</p>'
end
end
if patternComment ~= '' then
out[#out+1] = '<p>'
out[#out+1] = patternComment
out[#out+1] = '</p>'
end
out[#out+1] = '<div class="clearfix"></div>'
return table.concat( out )
end
return p