モジュール:前後年月カテゴリ
表示
![](http://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Test_Template_Info-Icon_-_Version_%282%29.svg/50px-Test_Template_Info-Icon_-_Version_%282%29.svg.png)
local objLINKYMCAT = {}; objLINKYMCAT.divdateCore = function( ymm ) local tbl = {} local len = mw.ustring.len( ymm ) local c = "" tbl['y'] = "" tbl['m1'] = "" tbl['m2'] = "" if 5 <= len then tbl['y'] = mw.ustring.sub( ymm, 1, 4 ) if 5 == len then tbl['m1'] = "1" tbl['m2'] = "12" elseif 7 <= len then c = mw.ustring.sub( ymm, 7, 7 ) if c == "月" then tbl['m1'] = mw.ustring.sub( ymm, 6, 6 ) tbl['m2'] = tbl['m1'] if 10 <= len then c = mw.ustring.sub( ymm, 10, 10 ) if c == "月" then tbl['m2'] = mw.ustring.sub( ymm, 9, 9 ) else tbl['m2'] = mw.ustring.sub( ymm, 9, 10 ) end end elseif c == "前" then -- 「以前」 tbl['m1'] = "12" tbl['m2'] = "12" -- else tbl['m1'] = mw.ustring.sub( ymm, 6, 7 ) tbl['m2'] = tbl['m1'] if 11 <= len then c = mw.ustring.sub( ymm, 11, 11 ) if c == "月" then tbl['m2'] = mw.ustring.sub( ymm, 10, 10 ) else tbl['m2'] = mw.ustring.sub( ymm, 10, 11 ) end end end end end return tbl end objLINKYMCAT.divdate = function( frame ) local sel = frame.args[2]; local tbl = objLINKYMCAT.divdateCore( frame.args[1] ) local str = "" if sel == "y" then str = tbl['y'] elseif sel == "m1" then str = tbl['m1'] elseif sel == "m2" then str = tbl['m2'] elseif sel == "年" then str = tbl['y'] .. "年" elseif sel == "月1" then str = tbl['m1'] .. "月" elseif sel == "月2" then str = tbl['m2'] .. "月" elseif sel == "年月1" then str = tbl['y'] .. "年" .. tbl['m1'] .. "月" elseif sel == "年月2" then str = tbl['y'] .. "年" .. tbl['m2'] .. "月" end return str end objLINKYMCAT.show = function( frame ) local cat = frame.args[1] local sep = frame.args[2] local ym = frame.args[3] local ymY = frame.args['当年'] local ymLL = frame.args['前年末月'] local ymL = frame.args['前月'] local ymR = frame.args['後月'] local ymRR = frame.args['後年始月'] local catinfo = objLINKYMCAT.getcatinfo( frame ) local strU = "" local strM = "" local strL = "" local m = "" local lenYM = 0 -- 上段 if catinfo['catU1'] ~= "" then if catinfo['catU2'] ~= "" then strU = objLINKYMCAT.catlinkCore( catinfo['catU1'], "", "", "→ " .. catinfo['catU1'] ) .. "<br />" .. objLINKYMCAT.catlinkCore( catinfo['catU2'], "", "", "→ " .. catinfo['catU2'] ) .. "<br />" else strU = objLINKYMCAT.catlinkCore( catinfo['catU1'], "", "", "→ " .. catinfo['catU1'] ) .. "<br />" end elseif catinfo['catU2'] ~= "" then strU = objLINKYMCAT.catlinkCore( catinfo['catU2'], "", "", "→ " .. catinfo['catU2'] ) .. "<br />" end -- 下段 if catinfo['catL1'] ~= "" then if catinfo['catL2'] ~= "" then strL = objLINKYMCAT.catlinkCore( catinfo['catL1'], "", "", "→ " .. catinfo['catL1'] ) .. "<br />" .. objLINKYMCAT.catlinkCore( catinfo['catL2'], "", "", "→ " .. catinfo['catL2'] ) .. "<br />" else strL = objLINKYMCAT.catlinkCore( catinfo['catL1'], "", "", "→ " .. catinfo['catL1'] ) .. "<br />" end elseif catinfo['catL2'] ~= "" then strL = objLINKYMCAT.catlinkCore( catinfo['catL2'], "", "", "→ " .. catinfo['catL2'] ) .. "<br />" end -- 中段 strM = objLINKYMCAT.catlinkCore( cat, "", "", "→ " .. cat ) if ym ~= nil and ym ~= "" then lenYM = mw.ustring.len( ym ) strM = strM .. sep .. " " if ymL ~= nil and ymL ~= "" then if mw.ustring.sub( ym, 6, 7 ) ~= "以前" then if ymLL ~= nil and ymLL ~= "" then if mw.ustring.sub( ymL, 6, 7 ) ~= "以前" then strM = strM .. objLINKYMCAT.catlinkCore( cat, sep, ymLL, mw.ustring.sub(ymLL, 1, 5) ) .. " << " end end strM = strM .. objLINKYMCAT.catlinkCore( cat, sep, ymL, ymL ) .. " < " end end if ymY ~= nil and ymY ~= "" then if 6 <= lenYM then m = mw.ustring.sub( ym, 6, lenYM ) end strM = strM .. "<b>" .. objLINKYMCAT.catlinkCore( cat, sep, ymY, ymY ) .. m .. "</b>" else strM = strM .. "<b>" .. ym .. "</b>" end if ymR ~= nil and ymR ~= "" then strM = strM .. " > " .. objLINKYMCAT.catlinkCore( cat, sep, ymR, ymR ) if ymRR ~= nil and ymRR ~= "" then strM = strM .. " >> " .. objLINKYMCAT.catlinkCore( cat, sep, ymRR, mw.ustring.sub(ymRR, 1, 5) ) end end end strM = strM .. "<br />" return strU .. strM ..strL end objLINKYMCAT.catlink = function( frame ) return objLINKYMCAT.catlinkCore( frame.args[1], frame.args[2], frame.args[3], frame.args[4] ) end objLINKYMCAT.catlinkCore = function( cat, sep, ym, show ) local linkstr = "" local showstr = "" if ym == nil or ym == "" then linkstr = cat else linkstr = cat .. sep .. ym end if show == nil or show == "" then showstr = linkstr else showstr = show end return "[[:Category:" .. linkstr .. "|" .. showstr.. "]]" end objLINKYMCAT.mboxmsg = function( frame ) local tag local msg if frame.args['説明'] ~= nil and frame.args['説明'] ~= "" and frame.args['説明'] ~= "1" then msg = frame.args['説明'] else if frame.args['タグ'] ~= nil and frame.args['タグ'] ~= "" then tag = frame.args['タグ'] else tag = objLINKYMCAT.taglink( frame ) end msg = tag .. "が貼り付けられた月順に並んでいます。Aは10月、Bは11月、Cは12月 です。各同一月内については、タグにソートキーが設定されている場合を除きページ名順です。異なる月の2つ以上のタグが貼られている場合、どのタグの月に分類されているかは各タグのページ内での位置によります。" end return msg end objLINKYMCAT.taglink = function( frame ) local catinfo = objLINKYMCAT.getcatinfo ( frame ) return catinfo['tag'] end objLINKYMCAT.getcatinfo = function( frame ) local catinfo = {}; local cat = frame.args[1] local cat2 = "" local catU0 = "修正が必要なページ" local catU1 = "出典を必要とする記事" local catU2 = "" local catL1 = "" local catL2 = "" local tag = "タグ" catinfo['catU1'] = "" catinfo['catU2'] = "" catinfo['catL1'] = "" catinfo['catL2'] = "" catinfo['tag'] = tag if cat == nil or cat == "" then return catinfo end cat2 = mw.ustring.sub(cat, 1, 1 ); if cat2 == "W" then tag = "{{[[Template:Wikify|Wikify]]}}" catU1 = catU0 elseif cat2 == "外" then tag = "{{[[Template:リンク切れ|リンク切れ]]}}" catU1 = catU0 elseif cat2 == "検" then local catRI = "検証が求められている記事" local catRID = "検証が求められている記述のある記事" if cat == catRI then tag = "{{[[Template:未検証|未検証]]}}" catL1 = catRID elseif cat == catRID then tag = "{{[[Template:要検証|要検証]]}}・{{[[Template:要検証範囲|要検証範囲]]}}" catU2 = catRI end elseif cat2 == "国" then tag = "{{[[Template:国際化|国際化]]}}" catU1 = catU0 elseif cat2 == "言" then local catWS = "言葉を濁した記述のある記事" if cat == catWS then tag = "{{[[Template:言葉を濁さない|言葉を濁さない]]}}" elseif cat == catWS .. " (誰)" then tag = "{{[[Template:誰|誰]]}}・{{[[Template:誰範囲|誰範囲]]}}" catU2 = catWS elseif cat == catWS .. " (誰2)" then tag = "{{[[Template:誰2|誰2]]}}・{{[[Template:誰2範囲|誰2範囲]]}}・{{[[Template:誰範囲2|誰範囲2]]}}" catU2 = catWS elseif cat == catWS .. " (いつ)" then tag = "{{[[Template:いつ|いつ]]}}・{{[[Template:いつ範囲|いつ範囲]]}}" catU2 = catWS elseif cat == catWS .. " (どこ)" then tag = "{{[[Template:どこ|どこ]]}}・{{[[Template:どこ範囲|どこ範囲]]}}" catU2 = catWS end elseif cat2 == "雑" then tag = "{{[[Template:雑多な内容の箇条書き|雑多な内容の箇条書き]]}}" catU1 = catU0 elseif cat2 == "字" then tag = "{{[[Template:字引|字引]]}}" catU1 = catU0 elseif cat2 == "出" then local catCN = catU1 local catCNS = "出典を必要とする節のある記事" local catCND = "出典を必要とする記述のある記事" local catBS = "出典を必要とする存命人物記事" local catBU = "出典皆無な存命人物記事" if cat == catCN then tag = "{{[[Template:出典の明記|出典の明記]]}}" catU1 = catU0 catL1 = catCNS catL2 = catCND elseif cat == catCNS then tag = "{{[[Template:出典の明記|出典の明記|section=1]]}}" elseif cat == catCND then tag = "{{[[Template:要出典|要出典]]}}・{{[[Template:要出典範囲|要出典範囲]]}}" elseif cat == catBS then tag = "{{[[Template:存命人物の出典明記|存命人物の出典明記]]}}" catL1 = catBU elseif cat == catBU then tag = "{{[[Template:BLP unsourced|BLP unsourced]]}}" catU2 = catBS end elseif cat2 == "情" then tag = "{{[[Template:更新|更新]]}}" catU1 = catU0 elseif cat2 == "宣" then tag = "{{[[Template:宣伝|宣伝]]}}" catU1 = catU0 elseif cat2 == "独" then local catOR = "独自研究の除去が必要な記事" local catORS = "独自研究の除去が必要な節のある記事" local catORD = "独自研究の除去が必要な記述のある記事" if cat == catOR then tag = "{{[[Template:独自研究|独自研究]]}}" catL1 = catORS catL2 = catORD elseif cat == catORS then tag = "{{[[Template:独自研究|独自研究|section=1]]}}" catU2 = catOR elseif cat == catORD then tag = "{{[[Template:独自研究範囲|独自研究範囲]]}}" catU2 = catOR end elseif cat2 == "特" then tag = "{{[[Template:特筆性|特筆性]]}}" elseif cat2 == "翻" then tag = "{{[[Template:翻訳中途|翻訳中途]]}}" catU1 = "" elseif cat2 == "無" then tag = "{{[[Template:出典無効|出典無効]]}}" end catinfo['catU1'] = catU1 catinfo['catU2'] = catU2 catinfo['catL1'] = catL1 catinfo['catL2'] = catL2 catinfo['tag'] = tag return catinfo end return objLINKYMCAT