跳至內容
主選單
主選單
移至側邊欄
隱藏
導覽
首頁
近期變更
建立新頁面
隨機頁面
五大觀念?
新手使用指南
頁面存廢討論
百科財務報告
微國家百科
搜尋
搜尋
建立帳號
登入
個人工具
建立帳號
登入
暗色模式
檢視 模組:Uses TemplateStyles 的原始碼
模組
討論
English
閱讀
檢視原始碼
檢視歷史
工具
工具
移至側邊欄
隱藏
操作
閱讀
檢視原始碼
檢視歷史
一般
連結至此的頁面
相關變更
特殊頁面
頁面資訊
取得短網址
←
模組:Uses TemplateStyles
由於以下原因,您無權編輯此頁面:
您請求的操作只有這個群組的使用者能使用:
使用者
您可以檢視並複製此頁面的原始碼。
-- This module implements the {{Uses TemplateStyles}} template. local yesno = require('Module:Yesno') local mList = require('Module:List') local mTableTools = require('Module:TableTools') local mMessageBox = require('Module:Message box') local p = {} function p.main(frame) local origArgs = frame:getParent().args local args = {} for k, v in pairs(origArgs) do v = v:match('^%s*(.-)%s*$') if v ~= '' then args[k] = v end end return p._main(args) end function p._main(args) local tStyles = mTableTools.compressSparseArray(args) local box = p.renderBox(tStyles) local trackingCategories = p.renderTrackingCategories(args, tStyles) return box .. trackingCategories end function p.renderBox(tStyles) local boxArgs = {} if #tStyles < 1 then boxArgs.text = '<strong class="error">錯誤:未指定模板樣式</strong>' else local tStylesLinks = {} for i, ts in ipairs(tStyles) do local sandboxLink = nil local tsTitle = mw.title.new(ts) if tsTitle then local tsSandboxTitle = mw.title.new(string.format('%s:%s/sandbox/%s', tsTitle.nsText, tsTitle.baseText, tsTitle.subpageText)) if tsSandboxTitle and tsSandboxTitle.exists then sandboxLink = string.format('​([[:%s|沙盒]])', tsSandboxTitle.prefixedText) end end tStylesLinks[i] = string.format('[[:%s]]%s', ts, sandboxLink or '') end local tStylesList = mList.makeList('bulleted', tStylesLinks) boxArgs.text = '本' .. (mw.title.getCurrentTitle():inNamespaces(828,829) and '模組' or '模板') .. '使用以下[[Help:模板樣式|模板樣式]]:\n' .. tStylesList end boxArgs.type = 'notice' boxArgs.small = true boxArgs.image = '[[File:Farm-Fresh css add.svg|32px|alt=CSS]]' return mMessageBox.main('mbox', boxArgs) end function p.renderTrackingCategories(args, tStyles, titleObj) if yesno(args.nocat) then return '' end local cats = {} -- Error category if #tStyles < 1 then cats[#cats + 1] = '有模板樣式錯誤的模板' end -- TemplateStyles category titleObj = titleObj or mw.title.getCurrentTitle() local subpageBlacklist = { doc = true, sandbox = true, sandbox2 = true, testcases = true } if titleObj.namespace == 10 and not subpageBlacklist[titleObj.subpageText] then local category = args.category if not category then category = category or '使用模板樣式的模板' end cats[#cats + 1] = category local currentProt = titleObj.protectionLevels["edit"] and titleObj.protectionLevels["edit"][1] or nil for i, ts in ipairs(tStyles) do local tsTitleObj = mw.title.new(ts) local tsProt = tsTitleObj.protectionLevels["edit"] and tsTitleObj.protectionLevels["edit"][1] or nil if tsProt ~= currentProt then cats[#cats + 1] = "使用模板樣式並受保護的模板" break end end end for i, cat in ipairs(cats) do cats[i] = string.format('[[Category:%s]]', cat) end return table.concat(cats) end return p
此頁面使用了以下模板:
模組:Uses TemplateStyles/doc
(
檢視原始碼
)
返回到「
模組:Uses TemplateStyles
」。
切換限制內容寬度