Extension:SpeciallyCursed/mw.ext.SpeciallyCursed
The extension also provides a library to give Lua special pages the ability to read request information and to redirect the user to other pages. This extra functionality is only available to SpeciallyCursed pages however, and is not exposed to other modules or pages. Extra functionality can very well be added on request.
isOurSpecialPage
[edit]mw.ext.SpeciallyCursed.isOurSpecialPage
- Example value:
true
A boolean that specified whether or not we are running on a special page created by the extension. If this is false, then the tables request
and output
cannot be accessed, which locks out the majority of the library.
escapeHtml
[edit]mw.ext.SpeciallyCursed.escapeHtml(text)
A convenience function that escapes HTML, available anywhere.
request
[edit]- Only available on SpeciallyCursed pages
mw.ext.SpeciallyCursed.request
A table that holds functions for grabbing data from the GET/POST request in various forms.
getBool
[edit]- Only available on SpeciallyCursed pages
mw.ext.SpeciallyCursed.request.getBool(name)
mw.ext.SpeciallyCursed.request.getBool(name, default)
A function that returns a boolean based on the query parameter for name
. If default
is not specified, it defaults to false
.
Keep in mind that this is effectively functional as (bool)$value
in PHP, which means that "false"
is casted to true
. To avoid this behavior, use request.getFuzzyBool.
getCheck
[edit]- Only available on SpeciallyCursed pages
mw.ext.SpeciallyCursed.request.getCheck(name)
A function that returns true
if the query parameter name
exists, and false
otherwise.
getFuzzyBool
[edit]- Only available on SpeciallyCursed pages
mw.ext.SpeciallyCursed.request.getFuzzyBool(name)
mw.ext.SpeciallyCursed.request.getFuzzyBool(name, default)
A function that returns a boolean based on the query parameter for name
, but it does what you'd expect at first glance (i.e. "false"
and "0"
are "false"
, and "true"
and "1"
are true
). If default
is not specified, it defaults to false
.
getInt
[edit]- Only available on SpeciallyCursed pages
mw.ext.SpeciallyCursed.request.getInt(name)
mw.ext.SpeciallyCursed.request.getInt(name, default)
A function that returns a number based on the query parameter for name
. If default
is not specified, it defaults to 0
.
getIntOrNil
[edit]- Only available on SpeciallyCursed pages
mw.ext.SpeciallyCursed.request.getIntOrNil(name)
- Also available as:
mw.ext.SpeciallyCursed.request.getIntorNull
A function that returns a number based on the query parameter for name
if it exists and can be parsed, or nil
otherwise. Also available as request.getIntOrNull()
with the same semantics.
getIntTable
[edit]- Only available on SpeciallyCursed pages
mw.ext.SpeciallyCursed.request.getIntTable(name)
mw.ext.SpeciallyCursed.request.getIntTable(name, default)
- Also available as:
mw.ext.SpeciallyCursed.request.getIntTable
A function that returns a table of numbers with all of the query parameters for name
. If default
is not specified, it defaults to an empty table. Also available as request.getIntArray()
with the same semantics.
getTable
[edit]- Only available on SpeciallyCursed pages
mw.ext.SpeciallyCursed.request.getTable(name)
mw.ext.SpeciallyCursed.request.getTable(name, default)
- Also available as:
mw.ext.SpeciallyCursed.request.getArray
A function that returns a table of strings with all of the query parameters for name
. If default
is not specified, it defaults to an empty table. Also available as request.getArray()
with the same semantics.
getText
[edit]- Only available on SpeciallyCursed pages
mw.ext.SpeciallyCursed.request.getText(name)
mw.ext.SpeciallyCursed.request.getText(name, default)
A function that returns a string based on the query parameter for name
. If default
is not specified, it defaults to ""
.
output
[edit]- Only available on SpeciallyCursed pages
mw.ext.SpeciallyCursed.output
A table that (at present) holds a singular function that redirects the user.
redirect
[edit]- Only available on SpeciallyCursed pages
mw.ext.SpeciallyCursed.output.redirect(url)
mw.ext.SpeciallyCursed.output.redirect(url, responseCode)
A function that redirects the user to url
. If responseCode
is not specified, it defaults to 302
.