Module:NewsItem

local util_args = require('Module:ArgsUtil') local util_cargo = require('Module:CargoUtil') local m_team = require('Module:Team') local m_region = require('Module:Region') local util_vars = require('Module:VarsUtil') local util_table = require('Module:TableUtil') local League = require('Module:League').league

local h = {}

function h.makeNews(args) local region_image = m_region(args.region):image local output = { '|-',		'|class="news-region"|' .. region_image, '|class="news-subject"|' .. args.subject, '|class="news-text"|' .. (args.text or ''), }	if args.cargo then h.storeCargo(args, region_image) end return table.concat(output,'\n') end

function h.storeCargo(args, region_image) local tbl = { _table = 'News', Date = util_vars.getVar('date', frame), ItemNo = util_vars.setGlobalIndex('NewsItem'), Region = m_region.long(args.region), Region_Markup = m_region.rightmedium(args.region), Region_Image = region_image, Text = args.text }	tbl.UniqueLine = mw.title.getCurrentTitle.text .. '_' .. tbl.ItemNo util_table.merge(tbl, args.cargo) util_cargo.store(tbl) return end

local p = {}

function p.team(frame) local args = util_args.merge(true) args.subject = m_team.rightshortlinked(args.team, {size=60}) if util_vars.getVar('newsCargo') and not args.nocargo then args.cargo = { Type = 'Team', Team = m_team.teamlinkname(args.team), Team_Markup = m_team.rightmediumlinked(args.team), }		args.cargo.Subject = args.cargo.Team args.cargo.Subject_Markup = args.cargo.Team_Markup end return h.makeNews(args) end

function p.tournament(frame) local args = util_args.merge(true) args.subject = League{args.tournament,'rightshortdiv60linked',size='25px',link=args.link} if util_vars.getVar('newsCargo') and not args.nocargo then args.cargo = { _table = 'News', Type = 'Tournament', Tournament = args.link, Tournament_Markup = args.subject, Subject = args.link, Subject_Markup = args.subject }	end return h.makeNews(args) end

return p