Модуль:Образец документа
Материал из Справочника наблюдателя
Документация отсутствует!
Вы можете создать документацию ( создать ).
Задавайте категории на странице документации, а не здесь! Показать подстраницы
Задавайте категории на странице документации, а не здесь! Показать подстраницы
local p = {}
local outres = {}
local blank = require( 'Модуль:Бланки' )
function split (txt)
return mw.text.split (txt, '[\t\r\n\f ]*[,;][\t\r\n\f ]*')
end
function anaList (fact, set)
local res = {}
local wasRes
for i = 1, #fact do
if fact[i] ~= '' then
for j = 1, #set do
if fact[i] == set[j] then
res[set[j]] = true
wasRes = true
end
end
end
end
return res, wasRes
end
function fileEx (frame, name)
local fiti = mw.title.new (name, 'File')
if fiti.id == 0 then
return false
else
return fiti
end
end
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',
},
}
function aboutFile (frame, page, ext)
local fiti = fileEx (frame, page.text .. tabformat [ext]['ext'])
if fiti then
outres [#outres+1] = '<div style="text-align:center; width:100%;border:0x">[[Файл:' .. tabformat[ext]['yes'] .. '|x32px|Скачать ' .. tabformat[ext]['alt'] .. '|link='
.. frame:callParserFunction('filepath', page.text .. tabformat [ext]['ext']) .. ']]</div>'
.. '<div style="text-align:right; width:100%; font-size:75%;line-height:90%">[[:Файл:' .. page.text .. tabformat [ext]['ext'] .. '|<span title="Информация о файле"><tt> i</tt></span>]]</div>'
else
outres [#outres+1] = '<div style="text-align:center; width:100%">[[Файл:' .. tabformat[ext]['no'] .. '|x32px|Отсутствует ' .. tabformat[ext]['alt'] .. '|link='
.. frame:callParserFunction{name='fullurl', args = {'Special:Upload',
wpDestFile = page:partialUrl() .. tabformat [ext]['ext'].. '&wpUploadDescription=%7B%7BОбразец%20документа%7D%7D'}} .. ']]</div>'
.. '<div style="text-align:right; width:100%; font-size:75%;line-height:80%">[[Набла:Как создавать бланки для скачивания|?]]</div>[[Категория:Образцы с отсутствующими файлами ' .. ext .. ']]'
end
end
function linkFile (frame, name, ext)
local fiti = fileEx (frame, name .. tabformat [ext]['ext'])
if fiti then
outres [#outres+1] = '[[:Файл:' .. name .. tabformat [ext]['ext'] .. '|' .. tabformat [ext]['lnk'] .. ']] [[Файл:Download-icon.gif|16px|link='
.. frame:callParserFunction('filepath', name .. tabformat [ext]['ext']) .. ']]'
else
outres [#outres+1] = tabformat [ext]['lnk'] .. ' (' .. ext .. ')[' .. frame:callParserFunction{name='fullurl', args = {'Special:Upload',
wpDestFile = mw.uri.encode (name .. tabformat [ext]['ext'], 'PATH') .. '&wpUploadDescription=%7B%7BОбразец%20документа%7D%7D'}} .. ' ↑]'
end
end
function MainFile (frame, page)
local name,doc,ext = mw.ustring.match (page.text, '^([^!]+)(!?)%.([a-z0-9A-Z]+)$')
outres [#outres+1] = '<br /><br /><table width=100% class=standard><tr>'
outres [#outres+1] = '<th>('
outres [#outres+1] = blank.getNumber( name )
outres [#outres+1] = ') [[' .. name .. ']]<th></tr><tr><td align=center class=plainlinks>'
outres [#outres+1] = '[[' .. name .. '|Текст (просмотр)]] • '
linkFile (frame, name, 'pdf')
outres [#outres+1] = ' • '
linkFile (frame, name, '.odt')
outres [#outres+1] = ' • '
linkFile (frame, name, 'doc')
outres [#outres+1] = ' • '
linkFile (frame, name, 'odt')
outres [#outres+1] = '</td></tr></table><small>[[Набла:Как создавать бланки для скачивания|Как создавать бланки для скачивания]][[Категория:Образцы документов]]</small><br /> <br />'
return table.concat(outres)
end
function p.Main (frame)
local page = mw.title.getCurrentTitle()
local args = frame:getParent().args
if page.nsText == 'Файл' then
return MainFile (frame, page)
end
local patternTo = split (mw.ustring.lower (args ['куда' ] or ''))
local patternUser = split (mw.ustring.lower (args ['для' ] or ''))
local patternWhere = split (mw.ustring.lower (args ['где' ] or ''))
local patternFormat = split (mw.ustring.lower (args ['формат'] or ''))
local patternCase = args ['ТС'] or ''
local patternComment= args ['ТСдоп'] or ''
local patternStatus = mw.ustring.lower (args ['сила'] or frame:getParent().args ['статус'] or '')
local patternSource = args ['док'] or ''
local patternAlso = args ['см.'] or ''
local patternEdit = args ['правки'] or ''
local patternReg = args ['регион'] or ''
local patternMain = args ['общий'] or ''
-- local wasEl
local formats = anaList (patternFormat, {'pdf','doc'})
outres [#outres+1] = '<div style="width:150px; float:right; margin-left:5px; "><table class=wikitable width=100%><tr>'
outres [#outres+1] = '<td width=34% style="" >'
if formats['pdf'] then
aboutFile (frame, page, 'pdf')
end
outres [#outres+1] = '</td><td width=33% style="" >'
if formats['doc'] then
aboutFile (frame, page, 'odt')
end
outres [#outres+1] = '</td><td width=33% style="" >'
if formats['doc'] then
aboutFile (frame, page, 'doc')
end
outres [#outres+1] = '</td></tr><tr><td colspan=3 style="font-size:18px; text-align:center; font-weight:bold">'
outres [#outres+1] = '[[Номер бланка::' .. blank.getNumber( page.text ) .. ']]'
outres [#outres+1] = '</td></tr></table></div>'
if patternReg ~= '' then
local regMo = require ('Module:Region')
local regName, eleName = regMo.electionsName (patternReg)
outres [#outres+1] = '[[Регион образца::' .. patternReg .. '| ]]<big><b>[[' .. regName .. ']][[Category:' .. regName .. ']]' .. eleName .. '</b></big><br />'
if patternMain == '' then
regName = mw.title.getCurrentTitle()
if regName.text ~= regName.baseText then
patternMain = regName.baseText --..
end
end
if patternMain == '' then
outres [#outres+1] = '<span style="color:red;font-size:120%;font-weight:bold>Не указан общий вариант</span><br />'
else
outres [#outres+1] = '<i>Универсальный вариант:</i> [[Универсальный образец::' .. patternMain .. ']]<br />'
end
end
if patternCase ~= '' then
outres [#outres+1] = patternCase .. '<br />'
else
outres [#outres+1] = '[[Категория:Образцы документов без указания на ситуацию]]'
end
if patternComment ~= '' then
outres [#outres+1] = '<table style="font-size:93%;line-height:105%"><tr><td>' .. patternComment .. '</td></tr></table>'
end
if patternStatus ~= '' and patternStatus ~= 'нет' then
outres [#outres+1] = '<i>Статус образца:</i> '
if patternStatus == 'норматив' or patternStatus == 'норма' then
outres [#outres+1] = 'обязательный'
elseif patternStatus == 'рекомендация' then
outres [#outres+1] = 'официально рекомендованная форма'
elseif patternStatus == 'позиция' then
outres [#outres+1] = 'ненормативная рекомендация'
else
outres [#outres+1] = '<b>ОШИБКА</b>'
end
if patternSource ~= '' then
outres [#outres+1] = ' (' .. patternSource .. ')'
end
outres [#outres+1] = '<br />'
end
local out = {}
local where, wasEl = anaList (patternWhere, {'уик', 'тик', 'ик', 'иксрф'})
if wasEl then
where ['уик'] = where ['уик'] or where ['ик']
where ['тик'] = where ['тик'] or where ['ик']
where ['иксрф'] = where ['иксрф'] or where ['ик']
outres [#outres+1] = '<i>Места возникновения ситуации:</i> '
if where ['ик'] then
out [#out+1] = 'избирательная комиссия любого уровня[[Место возникновения::УИК| ]][[Место возникновения::ТИК| ]][[Место возникновения::ИКСРФ| ]][[Место возникновения::ИК| ]]'
else
if where ['уик'] then
out [#out+1] = 'УИК[[Место возникновения::УИК| ]]'
end
if where ['тик'] then
out [#out+1] = 'ТИК[[Место возникновения::ТИК| ]]'
end
if where ['иксрф'] then
out [#out+1] = 'ИКСРФ[[Место возникновения::ИКСРФ| ]]'
end
end
outres [#outres+1] = table.concat( out, ' • ' )
outres [#outres+1] = '<br>'
end
local users = anaList (patternUser, {'прг', 'чпрг', 'псг', 'чпсг', 'набл', 'наблюдатель', 'сми', 'список30', 'избиратель', 'любой', 'гражданин', 'особый'})
users ['любой'] = users ['любой'] or users ['гражданин']
users ['список30'] = users ['список30'] or users ['список30:1'] or users ['любой']
users ['прг'] = users ['прг'] or users ['чпрг'] or users ['любой']
users ['псг'] = users ['псг'] or users ['чпсг'] or users ['любой']
users ['набл'] = users ['набл'] or users ['наблюдатель'] or users ['любой']
users ['сми'] = users ['сми'] or users ['список30']
outres [#outres+1] = '<i>Документ могут использовать:</i> '
out = {}
if users ['любой'] then
out [#out+1] = 'любые лица, независимо от наличия статуса[[Пользователь документа::любой| ]]'
else
-- if users ['прг'] and users ['псг'] then
-- out [#out+1] = 'члены комиссий с правом решающего и совещательного голоса'
-- elseif users ['прг'] then
if users ['прг'] then
out [#out+1] = 'члены комиссий с правом решающего голоса'
elseif users ['псг'] then
-- out [#out+1] = 'члены комиссий с правом совещательного голоса'
end
if users ['набл'] then
out [#out+1] = 'наблюдатели'
end
if users ['список30'] then
out [#out+1] = 'представители СМИ и иные лица, указанные в [[НПА:Федеральный закон от 12.06.2002 № 67-ФЗ:Статья 30|п. 1 ст. 30 ФЗГ]]'
elseif users ['сми'] then
out [#out+1] = 'представители СМИ'
end
end
if #out == 0 then
outres [#outres+1] = '[[Категория:Образцы документов с непонятным пользователем]]'
else
outres [#outres+1] = table.concat( out, ' • ' )
if users ['прг'] then
outres [#outres+1] = '[[Пользователь документа::ПРГ| ]]'
end
if users ['псг'] then
outres [#outres+1] = '[[Пользователь документа::ПСГ| ]]'
end
if users ['набл'] then
outres [#outres+1] = '[[Пользователь документа::набл| ]]'
end
if users ['сми'] then
outres [#outres+1] = '[[Пользователь документа::СМИ| ]]'
end
if users ['список30'] then
outres [#outres+1] = '[[Пользователь документа::присутствующий| ]]'
end
end
outres [#outres+1] = '<br />'
where = anaList (patternTo, {'уик', 'тик', 'иксрф', 'цик', 'ик', 'полиция', 'прокуратура', 'ск', 'адм', 'суд', 'иные'})
where ['уик'] = where ['уик'] or where ['ик']
where ['тик'] = where ['тик'] or where ['ик']
where ['иксрф'] = where ['иксрф'] or where ['ик']
where ['цик'] = where ['цик'] or where ['ик']
outres [#outres+1] = '<i>Адресат документа:</i> '
out = {}
if where ['ик'] then
out [#out+1] = 'избирательные комиссии всех уровней[[Адресат документа::УИК| ]][[Адресат документа::ТИК| ]][[Адресат документа::ИК| ]]'
else
if where ['уик'] then
out [#out+1] = 'УИК[[Адресат документа::УИК| ]]'
end
if where ['тик'] then
out [#out+1] = 'ТИК (или иная вышестоящая комиссия)[[Адресат документа::ТИК| ]]'
end
if where ['иксрф'] then
out [#out+1] = 'избирательная комиссия субъекта Федерации[[Адресат документа::ИКСРФ| ]]'
end
if where ['цик'] then
out [#out+1] = 'Центральная избирательная комиссия[[Адресат документа::ЦИК| ]]'
end
end
if where ['адм'] then
out [#out+1] = 'местная администрация[[Адресат документа::администрация| ]]'
end
if where ['полиция'] then
out [#out+1] = 'полиция[[Адресат документа::полиция| ]]'
end
if where ['прокуратура'] then
out [#out+1] = 'прокуратура[[Адресат документа::прокуратура| ]]'
end
if where ['ск'] then
out [#out+1] = 'следственные органы[[Адресат документа::СК| ]]'
end
if where ['суд'] then
out [#out+1] = 'суд[[Адресат документа::суд| ]]'
end
if where ['иные'] then
out [#out+1] = 'иные органы (см. пояснения)[[Адресат документа::иной| ]]'
end
if #out == 0 then
outres [#outres+1] = '[[Категория:Образцы документов с непонятным адресатом]]'
end
outres [#outres+1] = table.concat( out, ' • ' )
outres [#outres+1] = '<br />'
-- {{#ask:[[Универсальный образец::{{PAGENAME}}]]|?Регион образца
-- |intro=''Региональные варианты'': <div class=hlist style=display:inline-block><ul>|outro=</ul></div>|format=template|link=none|template=<!-- ShowArgs -->Образец документа/Региональный вариант}} )))
outres [#outres+1] = frame:callParserFunction('#ask', {'[[Универсальный образец::' .. mw.title.getCurrentTitle().text .. ']]', '?Регион образца',
['intro'] = '<i>Региональные варианты:</i> <div class=hlist style=display:inline-block><ul>', ['outro'] = '</ul></div><br />', ['format'] = 'template', ['link'] = 'none',
['template'] = 'Образец документа/Региональный вариант' })
if patternAlso ~= '' then
outres [#outres+1] = '<i>См. также:</i> ' .. patternAlso .. '<br />'
end
if patternEdit ~= '' then
outres [#outres+1] = patternEdit .. '<br />'
end
outres [#outres+1] = '[[Категория:Образцы документов]]<br /><br />'
return table.concat(outres)
end
function p.RegList (frame)
local regMo = require ('Module:Region')
local regName, eleName = regMo.electionsName (frame:getParent().args[2])
return '\n<li> [[' .. frame:getParent().args[1] .. '|' .. regName .. eleName .. ']]</li>'
end
return p