پودمان:Infobox: تفاوت میان نسخه‌ها

۱٬۹۳۲ بایت اضافه‌شده ،  ‏۲۳ مارس ۲۰۱۸
بدون خلاصۀ ویرایش
جز (۱ نسخه واردشده)
بدون خلاصۀ ویرایش
خط ۴: خط ۴:
   
   
local p = {}
local p = {}
local navbar = require('Module:Navbar')._navbar


local args = {}
local args = {}
local origArgs
local origArgs
local root
local root
local function notempty( s ) return s and s:match( '%S' ) end
local function fixChildBoxes(sval, tt)
if notempty(sval) then
local marker = '<span class=special_infobox_marker>'
local s = sval
s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1')
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker)
if s:match(marker) then
s = mw.ustring.gsub(s, marker .. '%s*' .. marker, '')
s = mw.ustring.gsub(s, '([\r\n]|-[^\r\n]*[\r\n])%s*' .. marker, '%1')
s = mw.ustring.gsub(s, marker .. '%s*([\r\n]|-)', '%1')
s = mw.ustring.gsub(s, '(</[Cc][Aa][Pp][Tt][Ii][Oo][Nn]%s*>%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '(<%s*[Tt][Aa][Bb][Ll][Ee][^<>]*>%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '^(%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '([\r\n]%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
s = mw.ustring.gsub(s,  marker .. '(%s*</[Tt][Aa][Bb][Ll][Ee]%s*>)', '%1')
s = mw.ustring.gsub(s,  marker .. '(%s*\n|%})', '%1')
end
if s:match(marker) then
local subcells = mw.text.split(s, marker)
s = ''
for k = 1, #subcells do
if k == 1 then
s = s .. subcells[k] .. '</' .. tt .. '></tr>'
elseif k == #subcells then
local rowstyle = ' style="display:none"'
if notempty(subcells[k]) then rowstyle = '' end
s = s .. '<tr' .. rowstyle ..'><' .. tt .. ' colspan=2>\n' .. subcells[k]
elseif notempty(subcells[k]) then
if (k % 2) == 0 then
s = s .. subcells[k]
else
s = s .. '<tr><' .. tt .. ' colspan=2>\n' .. subcells[k] .. '</' .. tt .. '></tr>'
end
end
end
end
return s
else
return sval
end
end


local function union(t1, t2)
local function union(t1, t2)
خط ۵۴: خط ۱۰۰:
                     :css('text-align', 'center')
                     :css('text-align', 'center')
                     :cssText(args.headerstyle)
                     :cssText(args.headerstyle)
                     :wikitext(rowArgs.header)
                    :cssText(rowArgs.rowcellstyle)
                     :wikitext(fixChildBoxes(rowArgs.header, 'th'))
     elseif rowArgs.data then
     elseif rowArgs.data then
         local row = root:tag('tr')
         local row = root:tag('tr')
خط ۶۵: خط ۱۱۲:
                     :attr('scope', 'row')
                     :attr('scope', 'row')
                     :attr('id', rowArgs.labelid)
                     :attr('id', rowArgs.labelid)
                    :css('text-align', 'right')
                     :cssText(args.labelstyle)
                     :cssText(args.labelstyle)
                    :cssText(rowArgs.rowcellstyle)
                     :wikitext(rowArgs.label)
                     :wikitext(rowArgs.label)
                     :done()
                     :done()
خط ۸۱: خط ۱۲۸:
             :addClass(rowArgs.class)
             :addClass(rowArgs.class)
             :cssText(rowArgs.datastyle)
             :cssText(rowArgs.datastyle)
            :cssText(rowArgs.rowcellstyle)
             :newline()
             :newline()
             :wikitext(rowArgs.data)
             :wikitext(fixChildBoxes(rowArgs.data, 'td'))
     end
     end
end
end
خط ۱۰۸: خط ۱۵۶:
                 :css('font-weight', 'bold')
                 :css('font-weight', 'bold')
                 :cssText(args.abovestyle)
                 :cssText(args.abovestyle)
                 :wikitext(args.above)
                 :wikitext(fixChildBoxes(args.above,'th'))
end
end


خط ۱۲۲: خط ۱۷۰:
                 :cssText(args.belowstyle)
                 :cssText(args.belowstyle)
                 :newline()
                 :newline()
                 :wikitext(args.below)
                 :wikitext(fixChildBoxes(args.below,'td'))
end
end


خط ۱۸۳: خط ۲۳۱:
             rowclass = args['rowclass' .. tostring(num)],
             rowclass = args['rowclass' .. tostring(num)],
             rowstyle = args['rowstyle' .. tostring(num)],
             rowstyle = args['rowstyle' .. tostring(num)],
            rowcellstyle = args['rowcellstyle' .. tostring(num)],
             dataid = args['dataid' .. tostring(num)],
             dataid = args['dataid' .. tostring(num)],
             labelid = args['labelid' .. tostring(num)],
             labelid = args['labelid' .. tostring(num)],
خط ۱۹۹: خط ۲۴۸:
                 :attr('colspan', '2')
                 :attr('colspan', '2')
                 :css('text-align', 'left')
                 :css('text-align', 'left')
                 :wikitext(mw.getCurrentFrame():expandTemplate({  
                 :wikitext(navbar{
                     title = 'navbar',
                     args.name,
                    args = { args.name, mini = 1 }
                    mini = 1,
                 }))
                 })
end
end


خط ۲۱۸: خط ۲۶۷:
         end
         end
         if args.child == 'yes' and args.title then
         if args.child == 'yes' and args.title then
             root:wikitext('[[Category:Articles which use embedded infobox templates with the title parameter]]')
             root:wikitext('[[Category:Pages which use embedded infobox templates with the title parameter]]')
         end
         end
     end
     end
خط ۲۳۰: خط ۲۷۹:
          
          
         root
         root
             :addClass('infobox')
             :addClass((args.subbox ~= 'yes') and 'infobox' or nil)
             :addClass(args.bodyclass)
             :addClass(args.bodyclass)
              
              
خط ۳۴۶: خط ۳۹۵:
     end
     end
      
      
     -- Parse the data parameters in the same order that the old {{infobox}} did, so that
     -- Parse the data parameters in the same order that the old {{Infobox}} did, so that
     -- references etc. will display in the expected places. Parameters that depend on
     -- references etc. will display in the expected places. Parameters that depend on
     -- another parameter are only processed if that parameter is present, to avoid
     -- another parameter are only processed if that parameter is present, to avoid
خط ۳۷۶: خط ۴۲۵:
         {prefix = 'rowclass'},
         {prefix = 'rowclass'},
         {prefix = 'rowstyle'},
         {prefix = 'rowstyle'},
        {prefix = 'rowcellstyle'},
         {prefix = 'class'},
         {prefix = 'class'},
         {prefix = 'dataid'},
         {prefix = 'dataid'},