Mô đun:Bad title suggestion
Giao diện
Mô đun này sẽ đề xuất tiêu đề hợp lệ cho thông báo "Tựa trang sai" tại MediaWiki:Title-invalid-characters. Khi một thành viên nhập tên trang chứa ký tự không hợp lệ, mô đun này sẽ kiểm tra tiêu đề đã cho đến ký tự không hợp lệ đầu tiên. Nếu nó tồn tại, {{Did you mean box}} sẽ được hiển thị.
Cách sử dụng
{{#invoke:Bad title suggestion|main|invalid_char|bad_title_encoded}}
Đối với trường hợp tại MediaWiki:Title-invalid-characters, nó sẽ là:
{{#invoke:Bad title suggestion|main|$1|$2}}
Ví dụ
- Foobar>:
{{#invoke:Bad title suggestion|main|>|Foobar>}}
| Có phải bạn muốn xem Foobar? |
- Wikipedia:Thảo luận}}:
{{#invoke:Bad title suggestion|main|}|Wikipedia:Thảo luận}}}}
| Có phải bạn muốn xem Wikipedia:Thảo luận? |
- Trang Chính|title text!:
{{#invoke:Bad title suggestion|main|||Trang Chính|title text!}}
| Có phải bạn muốn xem Trang Chính? |
- Trang này hoàn toàn không tồn tại>:
{{#invoke:Bad title suggestion|main|>|Trang này hoàn toàn không tồn tại>}}
(không hiển thị gì)
- Thể loại:Tất cả>:
{{#invoke:Bad title suggestion|main|>|Thể loại:Tất cả>}}
| Có phải bạn muốn xem Thể loại:Tất cả? |
- <Foobar>:
{{#invoke:Bad title suggestion|main|<|#60;Foobar#62;}}
(không hiển thị gì)
local getArgs = require("Module:Arguments").getArgslocal p = {}function p.main(frame) local args = getArgs(frame) -- The invalid character, e.g. ">" or "}" local chr = args[1] -- The escaped bad title, e.g. "Foobar>" or "Foobar|text" local title = args[2] -- A pipe (|) as the invalid character is a special case; it is not -- escaped, so instead the module thinks it got two empty arguments -- and the title as the third argument. if chr == nil and title == nil then chr = "|" title = args[3] end if chr == nil or title == nil then return "" end -- Determine the suggested title by taking a prefix of the bad title -- up to the first invalid character. Only display the suggestion box -- if the page exists. local index = mw.ustring.find(title, mw.text.nowiki(chr), 1, true) if index == nil then return "" end local page = mw.title.new(mw.ustring.sub(title, 1, index - 1)) if page == nil or not page.exists then return "" end return frame:expandTemplate{ title = "No article text/Did you mean box", args = { 'Có phải bạn muốn xem [[:' .. page.fullText .. ']]?' } }endreturn p