Foruma hoş geldin 👋, Ziyaretçi

Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

Modül:GHS ibareleri

bullvar_katip

Administrator
Katılım
21 Mayıs 2024
Mesajlar
532,105
-------------------------------------------------------------------------------- -- Module:GHS phrases -- -- main: reads GHS parameters (arguments like "H301", "P401") -- and returns for each (listtype='abbr'): -- phraseID visible; formal phrase text as <abbr title="...">' end -------------------------------------------------------------------------------- -- formatPhraseInline -- -- format phraseID and text, for inline form (in sentence) -- adds "quotes" -------------------------------------------------------------------------------- local function formatPhraseInline(phraseID, sPhrase) return inMono(phraseID) .. ': \"' .. sPhrase .. '\"' end -------------------------------------------------------------------------------- -- formatPhraseList -- -- as inline, but no "quotes" added. -------------------------------------------------------------------------------- local function formatPhraseList(phraseID, sPhrase) return inMono(phraseID) .. ': ' .. sPhrase end -------------------------------------------------------------------------------- -- getSetID -- -- Determines setID (expected either 'H' or 'P') -- First route is: read |setid= -- When |setid= is not set, -- it looks for a first parameter that has an H of P prefix (in |P201|P202|...) -- when not found, 'GHS' is retured -- In one call, P and H numbers can *not* be mixed -- so "|H201|P202|" will cause error "P202 not found" (... in H-list) -------------------------------------------------------------------------------- local function getSetID(tArgs) local setIDfound = 'GHS' local paramsetID = tArgs['setid'] or nil if (paramsetID ~= nil) and (paramsetID 'P' or paramsetID 'H') then setIDfound = paramsetID else local initial = nil for i, v in ipairs(tArgs) do initial = mw.ustring.match(v, '^[PH]') if initial ~=nil then setIDfound = initial break end end end return setIDfound end -------------------------------------------------------------------------------- -- getListType -- -- Checks list format, including those from Module:List -------------------------------------------------------------------------------- local function getListType(tArgs) local listTypes = { ['abbr'] = true, ['bulleted'] = true, ['unbulleted'] = true, ['horizontal'] = true, ['ordered'] = true, ['horizontal_ordered'] = true, ['horizontal ordered'] = true, ['inline'] = true } local sListType = tArgs['listtype'] or 'abbr' if sListType or sListType 'abbr' then return 'abbr' elseif listTypes[sListType] true then if sListType 'horizontal ordered' then sListType = 'horizontal_ordered' end return sListType else sListType = 'abbr' end return sListType end -------------------------------------------------------------------------------- -- getDoOmitRules -------------------------------------------------------------------------------- local function getDoOmitRules(tArgs) local b = yesno(tArgs['omit'], true) if b == nil then b = true end return yesno(b, true) end -------------------------------------------------------------------------------- -- prepareArgs -- -- First: determine setID (from |setID= OR from prefixes in parameters) -- Then: clean up & format phrase IDs (=unnamed parameters) -- remove bad characters, create H/P pattern "H201", "P310+P302" -- straight array, no nil's, sorted -------------------------------------------------------------------------------- local function prepareArgs(tArgs) tArgName['setID'] = getSetID(tArgs) tArgName['listtype'] = getListType(tArgs) tArgName['omit'] = getDoOmitRules(tArgs) tArgs = tTools.compressSparseArray(tArgs) -- removes all named args if string.len(tArgName['setID']) == 1 and #tArgs > 0 then for i, v in ipairs(tArgs) do v = mw.text.decode(v) v = mw.ustring.gsub(v, '[^%d%+A-Za-z]', ) v = mw.ustring.gsub(v, '^(%d)', tArgName['setID'] .. '%1') v = mw.ustring.gsub(v, '%+(%d)', '+' .. tArgName['setID'] .. '%1') tArgs = v end table.sort(tArgs) end return tArgs end -------------------------------------------------------------------------------- -- listAll -- -- Returns wikitable rows for each phrase id. -- requires |setID=P/H -- returns full list, all phrases, for a setID -- 2-columns wikitable, sorted, sortable, anchor like "H201" for each -------------------------------------------------------------------------------- function r.listAll(frame) local newArgs = getArgs(frame) local tL = {} prepareArgs(newArgs) local tRead if tArgName['setID'] 'H' then tRead GHSdata['Hphrases'] elseif tArgName['setID'] 'P' then tRead = GHSdata['Pphrases'] else errorHPsetIDmissing return showPreviewMsg end -- Intermediate table t2 to maintain order; read from original table (/data) local t2 = {} local iPh for s, v in pairs(tRead) do iPh = tonumber(mw.ustring.match(s, '[PH](%d%d%d)')) if string.len(s) > 4 then iPh = tTools.size(t2) + 1 end table.insert(t2, iPh, s) end t2 = tTools.compressSparseArray(t2) table.sort(t2) local sTR, v, sAnchor -- i = array index, s = phraseID, v = phrase text for i, s in ipairs(t2) do v = tRead sAnchor = sTR = '|- ' .. sAnchor .. '\n| datasortvalue="' .. i .. '" | || ' .. v table.insert(tL, sTR) end return table.concat(tL, '\n') end -------------------------------------------------------------------------------- -- numberOfPhrases -- -- Documentation -- requires |setID=H/P -- Returns number of phrases, in format -- "GHS H-phrases (123)" -------------------------------------------------------------------------------- function r.numberOfPhrases(frame) local newArgs = getArgs(frame) prepareArgs(newArgs) local iT if tArgName['setID'] 'H' then iT tTools.size(GHSdata['Hphrases']) elseif tArgName['setID'] 'P' then iT = tTools.size(GHSdata['Pphrases']) else errorHPsetIDmissing return showPreviewMsg end return 'GHS ' .. PHlabel .. ' ' end -------------------------------------------------------------------------------- -- listOmitRules -- -- self-documentation -------------------------------------------------------------------------------- function r.listOmitRules local tRules = GHSdata['tOmitRules'] local tL = {} local s s = wlHelpPage('Çıkarılma kuralları') .. ': kimliği mevcut olduğunda, kimliği ifadesi gösterilmez' table.insert(tL, s) for keep, omit in pairs (tRules) do s = ' tutma ' .. inMono(keep) .. ', çıkarılma ' .. inMono(omit) table.insert(tL, s) end return table.concat(tL, ) end -------------------------------------------------------------------------------- -- _main -- -- processes setID (H, P) and phrase codes -- error: setID not P, H -- code not found -- cannot mix H and P phrases -- reads phrases from /data H or P phrases tables -- formats phrase (abbreviation, abbr-title, phraseID) -------------------------------------------------------------------------------- function r._main(tArgs) tArgs = prepareArgs(tArgs) if #tArgs 0 then return showPreviewMsg -- no content elseif tArgName['setID'] 'GHS' then return errorHPsetIDnotFound end tArgs = applyRemoveDuplicates(tArgs) if tArgName['omit'] then tArgs = applyOmitRules(tArgs) end local formatterF if tArgName['listtype'] 'abbr' then formatterF formatPhraseAbbr elseif tArgName['listtype'] 'inline' then formatterF = formatPhraseInline else --- Module:List options formatterF = formatPhraseList end local tReadD = {} if tArgName['setID'] 'H' then tReadD GHSdata['Hphrases'] elseif tArgName['setID'] 'P' then tReadD = GHSdata['Pphrases'] else return showPreviewMsg end local sPhrase local tR = {} for i, v in ipairs(tArgs) do sPhrase = tReadD[v] if sPhrase nil then table.insert(tR, errorPhraseIDnotFound(tostring(v))) else table.insert(tR, formatterF(v, sPhrase)) end end if tArgName['listtype'] 'abbr' then return table.concat(tR, ', ') .. showPreviewMsg elseif tArgName['listtype'] == 'inline' then return table.concat(tR, ', ') .. showPreviewMsg else local mList = require('Modül:Liste') return mList[tArgName['listtype']](tR) .. showPreviewMsg end end -------------------------------------------------------------------------------- -- main -- -- handles template input frame, then calls generic _main function -- To be invoked from -------------------------------------------------------------------------------- function r.main(frame) local newArgs = getArgs(frame) return r._main(newArgs) end return r
 

Tema özelleştirme sistemi

Bu menüden forum temasının bazı alanlarını kendinize özel olarak düzenleye bilirsiniz.

Zevkine göre renk kombinasyonunu belirle

Tam ekran yada dar ekran

Temanızın gövde büyüklüğünü sevkiniz, ihtiyacınıza göre dar yada geniş olarak kulana bilirsiniz.

Izgara yada normal mod

Temanızda forum listeleme yapısını ızgara yapısında yada normal yapıda listemek için kullanabilirsiniz.

Forum arkaplan resimleri

Forum arkaplanlarına eklenmiş olan resimlerinin kontrolü senin elinde, resimleri aç/kapat

Sidebar blogunu kapat/aç

Forumun kalabalığında kurtulmak için sidebar (kenar çubuğunu) açıp/kapatarak gereksiz kalabalıklardan kurtula bilirsiniz.

Yapışkan sidebar kapat/aç

Yapışkan sidebar ile sidebar alanını daha hızlı ve verimli kullanabilirsiniz.

Radius aç/kapat

Blok köşelerinde bulunan kıvrımları kapat/aç bu şekilde tarzını yansıt.

Foruma hoş geldin 👋, Ziyaretçi

Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

Geri