Editing
Module:BioboxDatabases
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local databasesModule = require('Module:BioboxDatabases/databases') local databases = databasesModule.databases local databaseOrder = databasesModule.databaseOrder local PBD = require('Module:PBD') local PBDIB = require('Module:PornBaseDataIB') local function isEmpty(value) return value == nil or value == '' end local function formatField(state, label, value, fieldName, rowIndex) if isEmpty(value) then return '' end local rowStyle = state:getRowStyle(rowIndex) return string.format('|-\n! style="%s %s" | \'\'\'%s\'\'\'\n| style="%s text-align:left; max-width: 100px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;" | %s', rowStyle, state.STYLES.LABEL, label, rowStyle, value) end function collectParametersWithSuffixes(args, paramBase, maxCount) local values = {} maxCount = tonumber(maxCount) or 4 for i = 1, maxCount do local suffix = i > 1 and i or "" local paramName = paramBase .. suffix if not isEmpty(args[paramName]) then table.insert(values, args[paramName]) end end return values end function p.formatDatabase(state, args, databaseConfig, rowIndex) local section = {} local values = {} if databaseConfig.paramBase then values = collectParametersWithSuffixes( args, databaseConfig.paramBase, databaseConfig.maxCount ) end if #values == 0 and args.qid then local entity = mw.wikibase.getEntity(args.qid) if databaseConfig.pbdProps then for _, pbdProp in ipairs(databaseConfig.pbdProps) do if entity and entity.claims and entity.claims[pbdProp] then if databaseConfig.name == "iafd" and #values > 0 and pbdProp == "P169" then break end for _, statement in ipairs(entity.claims[pbdProp]) do if statement.mainsnak.snaktype == "value" and statement.mainsnak.datavalue then local id if statement.mainsnak.datavalue.type == "string" then id = statement.mainsnak.datavalue.value elseif statement.mainsnak.datavalue.type == "wikibase-entityid" then id = statement.mainsnak.datavalue.value.id end if id then if pbdProp == "P16" and not id:match("^nm") then id = "nm" .. id end table.insert(values, {id = id, pbdProp = pbdProp}) end end end end end end end if #values > 0 then local displayValues = {} for _, entry in ipairs(values) do local id, pbdProp if type(entry) == "table" then id = entry.id pbdProp = entry.pbdProp else id = entry end local urlFormat = databaseConfig.urlFormat if databaseConfig.name == "iafd" then if id:match("^%x+%-%x+%-%x+%-%x+%-%x+$") then urlFormat = "https://www.iafd.com/person.rme/id=%s" else urlFormat = "https://www.iafd.com/person.rme/perfid=%s/gender=m" end end if databaseConfig.name == "imdb" then if not id:match("^nm%d+$") then id = "nm" .. id end end local displayValue = string.format('[%s %s]', urlFormat:format(id), id:gsub("^nm", "")) table.insert(displayValues, displayValue) end local combinedDisplay = table.concat(displayValues, '<br>') local label if databaseConfig.labelFunc then label = databaseConfig.labelFunc() else local frame = mw.getCurrentFrame() label = frame:expandTemplate{ title = 'abbr', args = { databaseConfig.abbr, databaseConfig.label } } end section[#section + 1] = formatField(state, label, combinedDisplay, databaseConfig.name, rowIndex) rowIndex = rowIndex + 1 end return section, rowIndex end function p.formatDatabasesSection(state, args, rowIndex) local section = {} local databaseSections = {} local hasAny = false for _, databaseName in ipairs(databaseOrder) do local config = databases[databaseName] if config then local databaseSection, newRowIndex = p.formatDatabase(state, args, config, rowIndex) if #databaseSection > 0 then hasAny = true for _, line in ipairs(databaseSection) do databaseSections[#databaseSections + 1] = line end rowIndex = newRowIndex end end end if hasAny then section[#section + 1] = string.format('|-\n! colspan="2" %s | \'\'\'Databases\'\'\'', state.STYLES.SECTION_HEADER) for _, line in ipairs(databaseSections) do section[#section + 1] = line end end return section, rowIndex end return p
Summary:
Please note that all contributions to Porn Base Central may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Porn Base Central:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:BioboxDatabases/doc
(
view source
)
Navigation menu
Personal tools
English
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Tools
What links here
Related changes
Upload file
Page information
In other projects