Modul:Copied
![]() | Modul Lua ini digunakan pada banyak halaman dan perubahannya kemungkinan memicu perubahan massal pada semua halaman yang menggunakannya. Uji cobalah di subhalaman /bak pasir atau /kasus uji Modul:Copied, atau bak pasir modul Anda. Pertimbangkan untuk mendiskusikan perubahan di halaman pembicaraan sebelum mengimplementasikannya. |
![]() | Modul ini menggunakan Lua: |
Modul ini mengimplementasikan {{Disalin}}. Baca halaman templatnya untuk dokumentasi.
local MessageBox = require('Module:Message box')
local p = {}
local function singleText(args)
local from_oldid = args["from_oldid"] or args["from_oldid1"] or ""
local from = args["from"] or args["from1"] or ""
local to = args["to"] or args["to1"] or ""
local date = args["date"] or args["date1"] or ""
local afd = args["afd"] or args["afd1"] or ""
local merge = args["merge"] or args["merge1"] or ""
local text = "Teks dan/atau konten kreatif lainnya dari"
if not (from_oldid == "") then
text = string.format("%s [%s versi ini] dari", text, tostring(mw.uri.fullUrl(from, {oldid=from_oldid} )))
end
if from then
text = string.format("%s <span class='plainlinks'>[%s %s]</span>",text, tostring(mw.uri.fullUrl(from, {redirect="no"} )), from)
else
text = text .. '[[]]'
end
if (merge == "yes") or not (afd == "") then
text = text .. " telah digabung ke"
else
text = text .. " telah disalin dan/atau dipindahkan ke"
end
if (merge == "yes") and (to == "") then
text = string.format("%s [[%s:%s]]",text,mw.title.getCurrentTitle().nsText,mw.title.getCurrentTitle().text) --If no merge target given assume current page is the target
else
text = string.format("%s [[%s]]",text,to)
end
local diff = args["diff"] or args["diff1"]
local to_diff = args["to_diff"] or args["to_diff1"]
local to_oldid = args["to_oldid"] or args["to_oldid1"]
if (diff) then
text = string.format("%s dengan [%s suntingan ini]",text,diff)
elseif (to_oldid or to_diff) then
text = string.format("%s dengan [%s suntingan ini]",text,tostring(mw.uri.fullUrl(to, {diff=to_diff or "brkt", oldid = to_oldid or "sblm"} )))
end
if not (date == "") then
text = string.format("%s pada %s",text,date)
end
if not (afd == "") then
if (mw.ustring.match(afd, "Wikipedia:", 1 )) then --If no venue is given add AfD prefix
text = string.format("%s setelah [[%s|diusulkan untuk dihapus]]",text,afd)
else
text = string.format("%s setelah [[Wikipedia:Usulan penghapusan artikel/%s|diusulkan untuk dihapus]]",text,afd)
end
end
text = text .. "." -- Finish first sentance
text = string.format("%s [%s Riwayat] lama halaman sekarang sudah dipindahkan ke tempat baru, dengan [[WP:Menyalin dalam artikel|menyertakan atribusi]] untuk konten tersebut di halaman baru, dan tidak boleh dihapus setelah berpindah ke halaman baru.",text,tostring(mw.uri.fullUrl(from,{action="riwayat"}) or ""))
return text
end
local function row(args, i)
local text = ""
local afd = args["afd" .. i]
if (afd or args["merge" .. i]) then
text = string.format("%s\n*Digabungkan",text)
else
text = string.format("%s\n*Telah disalin",text)
end
local from = args["from" .. i] or ""
text = string.format("%s [%s %s] (",text,tostring(mw.uri.fullUrl(from, {redirect = "no"} )),from)
local from_oldid = args["from_oldid" .. i]
if (from_oldid) then
text = string.format("%s[%s oldid], ",text,tostring(mw.uri.fullUrl(from, {oldid = from_oldid} )))
end
local to = args["to".. i] or ""
text = string.format("%s[%s riwayat]) → [[%s]]",text,tostring(mw.uri.fullUrl(from, {action = "riwayat"} )), to)
local diff = args["diff" .. i]
if (diff) then
text = string.format("%s ([%s diff])",text,diff)
elseif (args["to_oldid" .. i] or args["to_diff".. i]) then
local to_diff = args["to_diff".. i] or "brkt"
local to_oldid = args["to_oldid" .. i] or "sblm"
text = string.format("%s ([%s diff])",text,tostring(mw.uri.fullUrl(to, {diff=to_diff, oldid = to_oldid} )))
end
local date = args["date" .. i]
if (date) then
text = string.format("%s pada %s",text,date)
end
if (afd) then
if (mw.ustring.match(afd, "Wikipedia:", 1 )) then --If no venue is given add AfD prefix
text = string.format("%s setelah [[%s|diusulkan untuk dihapus]]",text,afd)
else
text = string.format("%s setelah [[Wikipedia:Usulan penghapusan artikel/%s|diusulkan untuk dihapus]]",text,afd)
end
end
if (not (args["to_oldid" .. i] or args["to_diff".. i])) then
text = string.format("%s[[Category:Halaman Wikipedia dengan templat disalin tanpa oldid]]",text)
end
return text
end
local function list(args)
local text = ""
local from1 = args["from1"]
if (from1) then --Support from1 and from in case of multiple rows
text = string.format("%s%s",text,row(args, 1))
else
text = string.format("%s%s",text,row(args, ""))
end
local i = 2
while (args["from" .. i]) do
text = string.format("%s%s",text,row(args, i))
i = i + 1 --Check if from(i+1) exists
end
return text
end
local function multiText(args)
local pageType
if (mw.title.getCurrentTitle():inNamespace(1)) then
pageType = "artikel"
else
pageType = "halaman"
end
local historyList = list(args)
if (args["collapse"] == 'yes') then
local collapsedText = '<table style="width:100%%; background: transparent;" class="mw-collapsible mw-collapsed">\n<tr><th>Halaman yang disalin:</th></tr>\n<tr><td> %s </td></tr></table>'
historyList = string.format(collapsedText, historyList)
end
local text = "Teks ini telah disalin dari atau ke %s berikut. Halaman sumber sekarang sudah dipindahkan ke tempat baru, dengan [[WP:Menyalin dalam artikel|menyertakan atribusi]] untuk konten tersebut di halaman baru, dan tidak boleh dihapus setelah berpindah ke halaman baru. Untuk atribusi dan untuk mengakses versi lama teks yang disalin, lihat pranala ke riwayat suntingan di bawah ini. %s"
text = string.format(text, pageType, historyList)
return text
end
local function categories(args,multiUsed)
local to_oldid = args["to_oldid"] or args["to_diff"] or args["diff"] or args["to_oldid1"] or args["to_diff1"] or args["diff1"]
local from_oldid = args["from_oldid"] or args["from_oldid1"]
local text = "[[Category:Halaman Wikipedia dengan templat disalin]]"
if ((not from_oldid) or (not to_oldid)) and not multiUsed then
text = text .. "[[Category:Halaman Wikipedia dengan templat disalin]]"
end
return text
end
local function BannerText(args)
--Checks if there are multiple rows
local text
local from2 = args["from2"]
if (from2) then
text = multiText(args) .. categories(args,true)
else
text = singleText(args) .. categories(args,false)
end
return text
end
local function renderBanner(args)
return MessageBox.main('tmbox', {
class = "copiednotice",
small = args["small"],
image = '[[File:Splitsection.svg|frameless|upright=0.23|link=|alt=]]',
text = BannerText(args)
})
end
function p.main(frame)
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame)
return renderBanner(args)
end
return p